Commit 21038a2b6c6bcb9e6a9ad5d0cd0fe5860ba119ac

Authored by yeqianyong
1 parent 42c89eef

楚江erp:台账报表金额转换成万元

... ... @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
38 38
39 39 import javax.annotation.Resource;
40 40 import java.math.BigDecimal;
  41 +import java.math.RoundingMode;
41 42 import java.time.LocalDate;
42 43 import java.time.temporal.ChronoUnit;
43 44 import java.util.*;
... ... @@ -409,6 +410,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
409 410 if (CollectionUtils.isEmpty(debtAmountList)) {
410 411 return result;
411 412 }
  413 + List<String> customerNameList = new ArrayList<>();
412 414 // 根据简称分组
413 415 Map<String, List<Map<String, Object>>> debtMap = new HashMap<>();
414 416 for (Map<String, Object> map : debtAmountList) {
... ... @@ -440,16 +442,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
440 442 }
441 443 reportDetail.setCustomerName(customerName);
442 444 if ("AGREEMENT".equals(debtStatus)) {
443   - reportDetail.setAgreement(debtAmount);
  445 + reportDetail.setAgreement(valueConvert(debtAmount));
444 446 agreementTotal = agreementTotal.add(debtAmount);
445 447 } else if ("FIRST_COORDINATE".equals(debtStatus)) {
446   - reportDetail.setFirstCoordinate(debtAmount);
  448 + reportDetail.setFirstCoordinate(valueConvert(debtAmount));
447 449 firstCoordinateTotal = firstCoordinateTotal.add(debtAmount);
448 450 } else if ("SECOND_COORDINATE".equals(debtStatus)) {
449   - reportDetail.setSecondCoordinate(debtAmount);
  451 + reportDetail.setSecondCoordinate(valueConvert(debtAmount));
450 452 secondCoordinateTotal = secondCoordinateTotal.add(debtAmount);
451 453 } else if ("CLEAR_DEBTS".equals(debtStatus)) {
452   - reportDetail.setClearDebt(debtAmount);
  454 + reportDetail.setClearDebt(valueConvert(debtAmount));
453 455 clearDebtTotal = clearDebtTotal.add(debtAmount);
454 456 }
455 457 debtTotal = debtTotal.add(debtAmount);
... ... @@ -457,17 +459,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
457 459 reportDetailMap.put(reportDetail.getCustomerName(), reportDetail);
458 460 }
459 461 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values());
460   - for (ReceiptLedgerReportDetail detail : details) {
461   - BigDecimal total = getDebtTotal(detail);
462   - detail.setDebtTotal(total);
463   - }
464 462 report.setDetailList(details);
465 463
466   - report.setDebtTotal(debtTotal);
467   - report.setAgreementTotal(agreementTotal);
468   - report.setFirstCoordinateTotal(firstCoordinateTotal);
469   - report.setSecondCoordinateTotal(secondCoordinateTotal);
470   - report.setClearDebtTotal(clearDebtTotal);
  464 + report.setDebtTotal(valueConvert(debtTotal));
  465 + report.setAgreementTotal(valueConvert(agreementTotal));
  466 + report.setFirstCoordinateTotal(valueConvert(firstCoordinateTotal));
  467 + report.setSecondCoordinateTotal(valueConvert(secondCoordinateTotal));
  468 + report.setClearDebtTotal(valueConvert(clearDebtTotal));
471 469 report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal);
472 470 }
473 471 return result;
... ... @@ -522,4 +520,21 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
522 520 throw new DefaultClientException("日期数据异常!");
523 521 }
524 522 }
  523 +
  524 +
  525 + /**
  526 + * 转换成万元
  527 + *
  528 + */
  529 + private BigDecimal valueConvert(BigDecimal targetValue) {
  530 + if (targetValue == null || targetValue.compareTo(BigDecimal.ZERO) == 0) {
  531 + return targetValue;
  532 + }
  533 + targetValue = targetValue.divide(BigDecimal.valueOf(10000), 6, RoundingMode.HALF_UP);
  534 + targetValue = targetValue.stripTrailingZeros();
  535 + if (targetValue.toString().contains("E")) {
  536 + targetValue = new BigDecimal(targetValue.toPlainString());
  537 + }
  538 + return targetValue;
  539 + }
525 540 }
... ...
... ... @@ -203,7 +203,12 @@
203 203
204 204 <select id="report" resultType="com.lframework.xingyun.sc.bo.ledger.receipt.ReceiptLedgerReportBo">
205 205 select tb.short_name as customer_short_name,
206   - tb.type,
  206 + case
  207 + when tb.type = 'DEALER' then '经销商'
  208 + when tb.type = 'TERMINAL' then '终端'
  209 + when tb.type = 'FOREIGN' then '外贸'
  210 + else tb.type
  211 + end as customer_type,
207 212 tb.dept_id,
208 213 d.name as dept_name,
209 214 tb.region,
... ...