Commit 21038a2b6c6bcb9e6a9ad5d0cd0fe5860ba119ac

Authored by yeqianyong
1 parent 42c89eef

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

@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service; @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
38 38
39 import javax.annotation.Resource; 39 import javax.annotation.Resource;
40 import java.math.BigDecimal; 40 import java.math.BigDecimal;
  41 +import java.math.RoundingMode;
41 import java.time.LocalDate; 42 import java.time.LocalDate;
42 import java.time.temporal.ChronoUnit; 43 import java.time.temporal.ChronoUnit;
43 import java.util.*; 44 import java.util.*;
@@ -409,6 +410,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -409,6 +410,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
409 if (CollectionUtils.isEmpty(debtAmountList)) { 410 if (CollectionUtils.isEmpty(debtAmountList)) {
410 return result; 411 return result;
411 } 412 }
  413 + List<String> customerNameList = new ArrayList<>();
412 // 根据简称分组 414 // 根据简称分组
413 Map<String, List<Map<String, Object>>> debtMap = new HashMap<>(); 415 Map<String, List<Map<String, Object>>> debtMap = new HashMap<>();
414 for (Map<String, Object> map : debtAmountList) { 416 for (Map<String, Object> map : debtAmountList) {
@@ -440,16 +442,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -440,16 +442,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
440 } 442 }
441 reportDetail.setCustomerName(customerName); 443 reportDetail.setCustomerName(customerName);
442 if ("AGREEMENT".equals(debtStatus)) { 444 if ("AGREEMENT".equals(debtStatus)) {
443 - reportDetail.setAgreement(debtAmount); 445 + reportDetail.setAgreement(valueConvert(debtAmount));
444 agreementTotal = agreementTotal.add(debtAmount); 446 agreementTotal = agreementTotal.add(debtAmount);
445 } else if ("FIRST_COORDINATE".equals(debtStatus)) { 447 } else if ("FIRST_COORDINATE".equals(debtStatus)) {
446 - reportDetail.setFirstCoordinate(debtAmount); 448 + reportDetail.setFirstCoordinate(valueConvert(debtAmount));
447 firstCoordinateTotal = firstCoordinateTotal.add(debtAmount); 449 firstCoordinateTotal = firstCoordinateTotal.add(debtAmount);
448 } else if ("SECOND_COORDINATE".equals(debtStatus)) { 450 } else if ("SECOND_COORDINATE".equals(debtStatus)) {
449 - reportDetail.setSecondCoordinate(debtAmount); 451 + reportDetail.setSecondCoordinate(valueConvert(debtAmount));
450 secondCoordinateTotal = secondCoordinateTotal.add(debtAmount); 452 secondCoordinateTotal = secondCoordinateTotal.add(debtAmount);
451 } else if ("CLEAR_DEBTS".equals(debtStatus)) { 453 } else if ("CLEAR_DEBTS".equals(debtStatus)) {
452 - reportDetail.setClearDebt(debtAmount); 454 + reportDetail.setClearDebt(valueConvert(debtAmount));
453 clearDebtTotal = clearDebtTotal.add(debtAmount); 455 clearDebtTotal = clearDebtTotal.add(debtAmount);
454 } 456 }
455 debtTotal = debtTotal.add(debtAmount); 457 debtTotal = debtTotal.add(debtAmount);
@@ -457,17 +459,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -457,17 +459,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
457 reportDetailMap.put(reportDetail.getCustomerName(), reportDetail); 459 reportDetailMap.put(reportDetail.getCustomerName(), reportDetail);
458 } 460 }
459 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values()); 461 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values());
460 - for (ReceiptLedgerReportDetail detail : details) {  
461 - BigDecimal total = getDebtTotal(detail);  
462 - detail.setDebtTotal(total);  
463 - }  
464 report.setDetailList(details); 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 report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal); 469 report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal);
472 } 470 }
473 return result; 471 return result;
@@ -522,4 +520,21 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -522,4 +520,21 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
522 throw new DefaultClientException("日期数据异常!"); 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,7 +203,12 @@
203 203
204 <select id="report" resultType="com.lframework.xingyun.sc.bo.ledger.receipt.ReceiptLedgerReportBo"> 204 <select id="report" resultType="com.lframework.xingyun.sc.bo.ledger.receipt.ReceiptLedgerReportBo">
205 select tb.short_name as customer_short_name, 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 tb.dept_id, 212 tb.dept_id,
208 d.name as dept_name, 213 d.name as dept_name,
209 tb.region, 214 tb.region,