Commit f6d033e8b0ef7e6b568b9259092ea423de6d7bdb

Authored by yeqianyong
2 parents a296951e 1a904837

Merge branch 'master_cj_zq' into master_sample_order

@@ -28,7 +28,9 @@ import org.springframework.transaction.annotation.Transactional; @@ -28,7 +28,9 @@ import org.springframework.transaction.annotation.Transactional;
28 import org.springframework.stereotype.Service; 28 import org.springframework.stereotype.Service;
29 import java.time.LocalDateTime; 29 import java.time.LocalDateTime;
30 import java.util.ArrayList; 30 import java.util.ArrayList;
  31 +import java.util.Collections;
31 import java.util.List; 32 import java.util.List;
  33 +import java.util.Map;
32 34
33 @Service 35 @Service
34 public class FundOrderingUnitDetailServiceImpl extends BaseMpServiceImpl<FundOrderingUnitDetailMapper, FundOrderingUnitDetail> implements FundOrderingUnitDetailService { 36 public class FundOrderingUnitDetailServiceImpl extends BaseMpServiceImpl<FundOrderingUnitDetailMapper, FundOrderingUnitDetail> implements FundOrderingUnitDetailService {
@@ -157,6 +159,15 @@ public class FundOrderingUnitDetailServiceImpl extends BaseMpServiceImpl<FundOrd @@ -157,6 +159,15 @@ public class FundOrderingUnitDetailServiceImpl extends BaseMpServiceImpl<FundOrd
157 } 159 }
158 160
159 @Override 161 @Override
  162 + public List<Map<String, Object>> listByLedgerIds(List<String> ledgerIds) {
  163 + if (CollectionUtils.isEmpty(ledgerIds)) {
  164 + return Collections.emptyList();
  165 + }
  166 +
  167 + return getBaseMapper().queryFundsCoordinateStatus(ledgerIds);
  168 + }
  169 +
  170 + @Override
160 public void cleanCacheByKey(Serializable key) { 171 public void cleanCacheByKey(Serializable key) {
161 172
162 } 173 }
@@ -28,6 +28,7 @@ import com.lframework.starter.web.core.components.resp.PageResult; @@ -28,6 +28,7 @@ import com.lframework.starter.web.core.components.resp.PageResult;
28 import com.lframework.starter.common.utils.Assert; 28 import com.lframework.starter.common.utils.Assert;
29 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; 29 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
30 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 30 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
  31 +import com.lframework.xingyun.sc.service.ledger.FundOrderingUnitDetailService;
31 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; 32 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
32 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; 33 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
33 import com.lframework.xingyun.sc.service.shipments.ShipmentsOrderInfoService; 34 import com.lframework.xingyun.sc.service.shipments.ShipmentsOrderInfoService;
@@ -50,6 +51,7 @@ import java.math.RoundingMode; @@ -50,6 +51,7 @@ import java.math.RoundingMode;
50 import java.time.LocalDate; 51 import java.time.LocalDate;
51 import java.time.LocalDateTime; 52 import java.time.LocalDateTime;
52 import java.time.YearMonth; 53 import java.time.YearMonth;
  54 +import java.time.format.DateTimeFormatter;
53 import java.time.temporal.ChronoUnit; 55 import java.time.temporal.ChronoUnit;
54 import java.time.temporal.TemporalAdjusters; 56 import java.time.temporal.TemporalAdjusters;
55 import java.util.*; 57 import java.util.*;
@@ -84,6 +86,8 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -84,6 +86,8 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
84 private ContractDistributorStandardService contractDistributorStandardService; 86 private ContractDistributorStandardService contractDistributorStandardService;
85 @Resource 87 @Resource
86 private DraftRequestCarTicketService draftRequestCarTicketService; 88 private DraftRequestCarTicketService draftRequestCarTicketService;
  89 + @Resource
  90 + private FundOrderingUnitDetailService fundOrderingUnitDetailService;
87 91
88 92
89 // 定义状态优先级顺序(从高到低) 93 // 定义状态优先级顺序(从高到低)
@@ -121,11 +125,34 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -121,11 +125,34 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
121 List<SysDataDicItem> debtStatusList = sysDataDicItemService.findByDicCode("DEBT_STATUS"); 125 List<SysDataDicItem> debtStatusList = sysDataDicItemService.findByDicCode("DEBT_STATUS");
122 Map<String, String> debtStatusMap = debtStatusList.stream() 126 Map<String, String> debtStatusMap = debtStatusList.stream()
123 .collect(Collectors.toMap(SysDataDicItem::getCode, SysDataDicItem::getName, (v1, v2) -> v1)); 127 .collect(Collectors.toMap(SysDataDicItem::getCode, SysDataDicItem::getName, (v1, v2) -> v1));
  128 + // 获取资金协调状态
  129 + Map<String, String> fundCoordinateStatusMap = new HashMap<>();
  130 + List<String> ledgerIds = infoList.stream().map(ReceiptLedgerInfo::getId).collect(Collectors.toList());
  131 + List<Map<String, Object>> fundCoordinateStatusList = fundOrderingUnitDetailService.listByLedgerIds(ledgerIds);
  132 + if (CollectionUtils.isNotEmpty(fundCoordinateStatusList)) {
  133 + for (Map<String, Object> map : fundCoordinateStatusList) {
  134 + String ledgerId = (String) map.get("ledger_id");
  135 + String debtStatus = (String) map.get("debt_status");
  136 + String status = (String) map.get("status");
  137 +
  138 + fundCoordinateStatusMap.put(ledgerId + "_" + debtStatus, status);
  139 + }
  140 + }
124 for (ReceiptLedgerInfo info : infoList) { 141 for (ReceiptLedgerInfo info : infoList) {
125 String customerType = info.getCustomerType(); 142 String customerType = info.getCustomerType();
126 String enterpriseType = enterpriseTypeMap.get(customerType); 143 String enterpriseType = enterpriseTypeMap.get(customerType);
127 String debtStatus = info.getDebtStatus(); 144 String debtStatus = info.getDebtStatus();
128 String debtStatusName = debtStatusMap.get(debtStatus); 145 String debtStatusName = debtStatusMap.get(debtStatus);
  146 + String applyStatus = fundCoordinateStatusMap.get(info.getId() + "_" + debtStatusName);
  147 + if ("FIRST_COORDINATE".equals(debtStatus) || "SECOND_COORDINATE".equals(debtStatus) || "CLEAR_DEBTS".equals(debtStatus)) {
  148 + if ("AUDIT".equals(applyStatus)) {
  149 + info.setApplyStatus("批复中");
  150 + } else if ("PASS".equals(applyStatus) || "REFUSE".equals(applyStatus)) {
  151 + info.setApplyStatus("已申请");
  152 + } else {
  153 + info.setApplyStatus("未申请");
  154 + }
  155 + }
129 156
130 info.setCustomerType(enterpriseType); 157 info.setCustomerType(enterpriseType);
131 info.setDebtStatus(debtStatusName); 158 info.setDebtStatus(debtStatusName);
@@ -457,6 +484,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -457,6 +484,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
457 public PageResult<ReceiptLedgerReportBo> report(Integer pageIndex, Integer pageSize, ReceiptLedgerReportVo vo) { 484 public PageResult<ReceiptLedgerReportBo> report(Integer pageIndex, Integer pageSize, ReceiptLedgerReportVo vo) {
458 Assert.greaterThanZero(pageIndex); 485 Assert.greaterThanZero(pageIndex);
459 Assert.greaterThanZero(pageSize); 486 Assert.greaterThanZero(pageSize);
  487 + // 获取当月1号和当前时间
  488 + LocalDateTime endTime = LocalDateTime.now();
  489 + LocalDateTime startTime = LocalDate.now().withDayOfMonth(1).atStartOfDay();
  490 + if (vo.getStartTime() == null) {
  491 + vo.setStartTime(startTime);
  492 + }
  493 + if (vo.getEndTime() == null) {
  494 + vo.setEndTime(endTime);
  495 + }
  496 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
460 // 开启分页 497 // 开启分页
461 PageHelperUtil.startPage(pageIndex, pageSize); 498 PageHelperUtil.startPage(pageIndex, pageSize);
462 List<ReceiptLedgerReportBo> dataList = getBaseMapper().report(vo); 499 List<ReceiptLedgerReportBo> dataList = getBaseMapper().report(vo);
@@ -465,11 +502,15 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -465,11 +502,15 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
465 return result; 502 return result;
466 } 503 }
467 List<String> shortNames = dataList.stream().map(ReceiptLedgerReportBo::getCustomerShortName).distinct().collect(Collectors.toList()); 504 List<String> shortNames = dataList.stream().map(ReceiptLedgerReportBo::getCustomerShortName).distinct().collect(Collectors.toList());
468 - // 根据简称获取台账明细数据  
469 - Map<String, List<ReceiptLedgerInfo>> agreementDataMap = getLedgerInfoByShortName(shortNames, Boolean.FALSE);  
470 - Map<String, List<ReceiptLedgerInfo>> overdueDataMap = getLedgerInfoByShortName(shortNames, Boolean.TRUE); 505 + // 获取当月所有台账明细数据(内贸)
  506 + QueryReceiptLedgerInfoVo ledgerInfoVo = new QueryReceiptLedgerInfoVo();
  507 + ledgerInfoVo.setType("INSIDE");
  508 + ledgerInfoVo.setCreateTimeStart(startTime.format(formatter));
  509 + ledgerInfoVo.setCreateTimeEnd(endTime.format(formatter));
  510 + List<ReceiptLedgerInfo> ledgerInfoList = getBaseMapper().query(ledgerInfoVo);
471 // 统计各个阶段欠款金额数据 511 // 统计各个阶段欠款金额数据
472 - List<Map<String, Object>> debtAmountList = getBaseMapper().statisticsDebtByShortName(shortNames, null, "INSIDE"); 512 + List<Map<String, Object>> debtAmountList = getBaseMapper().statisticsDebtByShortName(shortNames, null, "INSIDE"
  513 + , vo.getStartTime(), vo.getEndTime());
473 if (CollectionUtils.isEmpty(debtAmountList)) { 514 if (CollectionUtils.isEmpty(debtAmountList)) {
474 return result; 515 return result;
475 } 516 }
@@ -485,6 +526,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -485,6 +526,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
485 List<Map<String, Object>> list = debtMap.computeIfAbsent(shortName, k -> new ArrayList<>()); 526 List<Map<String, Object>> list = debtMap.computeIfAbsent(shortName, k -> new ArrayList<>());
486 list.add(map); 527 list.add(map);
487 } 528 }
  529 + Set<String> customerNames = new HashSet<>();
488 // 获取待交付订货单数 530 // 获取待交付订货单数
489 Map<String, Long> orderCountMap = shipmentsOrderInfoService.countWaitDeliveredOrder(customerNameList); 531 Map<String, Long> orderCountMap = shipmentsOrderInfoService.countWaitDeliveredOrder(customerNameList);
490 for (ReceiptLedgerReportBo report : dataList) { 532 for (ReceiptLedgerReportBo report : dataList) {
@@ -494,28 +536,19 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -494,28 +536,19 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
494 continue; 536 continue;
495 } 537 }
496 long waitDeliveredOrderTotal = 0; 538 long waitDeliveredOrderTotal = 0;
497 - List<String> creditStatusList = new ArrayList<>();  
498 - List<String> debtStates = new ArrayList<>();  
499 Map<String, ReceiptLedgerReportDetail> reportDetailMap = new LinkedHashMap<>(); 539 Map<String, ReceiptLedgerReportDetail> reportDetailMap = new LinkedHashMap<>();
500 for (Map<String, Object> map : list) { 540 for (Map<String, Object> map : list) {
501 String customerName = (String) map.get("name"); 541 String customerName = (String) map.get("name");
502 String debtStatus = (String) map.get("debt_status"); 542 String debtStatus = (String) map.get("debt_status");
503 - debtStates.add(debtStatus);  
504 BigDecimal debtAmount = (BigDecimal) map.get("debt_amount"); 543 BigDecimal debtAmount = (BigDecimal) map.get("debt_amount");
505 544
506 ReceiptLedgerReportDetail reportDetail = reportDetailMap.get(customerName); 545 ReceiptLedgerReportDetail reportDetail = reportDetailMap.get(customerName);
507 if (reportDetail == null) { 546 if (reportDetail == null) {
508 reportDetail = new ReceiptLedgerReportDetail(); 547 reportDetail = new ReceiptLedgerReportDetail();
  548 + reportDetail.setCustomerName(customerName);
509 } 549 }
510 - reportDetail.setCustomerName(customerName);  
511 - if ("AGREEMENT".equals(debtStatus) || "DEPOSIT".equals(debtStatus)) {  
512 - BigDecimal agreement = reportDetail.getAgreement();  
513 - if (agreement == null) {  
514 - agreement = debtAmount;  
515 - } else {  
516 - agreement = agreement.add(debtAmount);  
517 - }  
518 - reportDetail.setAgreement(valueConvert(agreement)); 550 + if ("AGREEMENT".equals(debtStatus)) {
  551 + reportDetail.setAgreement(valueConvert(debtAmount));
519 reportDetail.setTimingStatus("约定内"); 552 reportDetail.setTimingStatus("约定内");
520 } else if ("FIRST_COORDINATE".equals(debtStatus)) { 553 } else if ("FIRST_COORDINATE".equals(debtStatus)) {
521 reportDetail.setFirstCoordinate(valueConvert(debtAmount)); 554 reportDetail.setFirstCoordinate(valueConvert(debtAmount));
@@ -527,17 +560,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -527,17 +560,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
527 reportDetail.setClearDebt(valueConvert(debtAmount)); 560 reportDetail.setClearDebt(valueConvert(debtAmount));
528 reportDetail.setTimingStatus("超期3"); 561 reportDetail.setTimingStatus("超期3");
529 } 562 }
530 - // 计算超额数据(授信状态)  
531 - String creditStatus = calculateExcess(debtAmount, report.getQuota());  
532 - if (StringUtils.isNotBlank(creditStatus)) {  
533 - report.setCreditStatus(creditStatus);  
534 - creditStatusList.add(creditStatus);  
535 - }  
536 // 统计待交付订单数 563 // 统计待交付订单数
537 Long count = orderCountMap.get(customerName); 564 Long count = orderCountMap.get(customerName);
538 - if (count != null) { 565 + if (count != null && !customerNames.contains(customerName)) {
539 waitDeliveredOrderTotal += count; 566 waitDeliveredOrderTotal += count;
540 reportDetail.setWaitDeliveredOrder(count); 567 reportDetail.setWaitDeliveredOrder(count);
  568 + // 防止重复相加
  569 + customerNames.add(customerName);
541 } 570 }
542 // 计算总欠款 571 // 计算总欠款
543 BigDecimal debtTotal = reportDetail.getDebtTotal(); 572 BigDecimal debtTotal = reportDetail.getDebtTotal();
@@ -551,22 +580,28 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -551,22 +580,28 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
551 } 580 }
552 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values()); 581 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values());
553 if (CollectionUtils.isNotEmpty(details)) { 582 if (CollectionUtils.isNotEmpty(details)) {
554 - // 转换成万元  
555 for (ReceiptLedgerReportDetail detail : details) { 583 for (ReceiptLedgerReportDetail detail : details) {
  584 + // 转换成万元
556 BigDecimal debtTotal = detail.getDebtTotal(); 585 BigDecimal debtTotal = detail.getDebtTotal();
557 detail.setDebtTotal(valueConvert(debtTotal)); 586 detail.setDebtTotal(valueConvert(debtTotal));
  587 + // 计算超额数据(授信状态)
  588 + String creditStatus = calculateExcess(debtTotal, report.getQuota());
  589 + if (StringUtils.isNotBlank(creditStatus)) {
  590 + detail.setCreditStatus(creditStatus);
  591 + }
558 } 592 }
559 } 593 }
560 report.setDetailList(details); 594 report.setDetailList(details);
561 595
562 // 处理约定内、一次协调、二次协调、清欠小计数据 596 // 处理约定内、一次协调、二次协调、清欠小计数据
563 - handleSubtotal(agreementDataMap, overdueDataMap, report);  
564 - // 授时状态  
565 - report.setTimingStatus(getHighestPriorityStatus(debtStates)); 597 + handleSubtotal(ledgerInfoList, report);
566 // 授信状态 598 // 授信状态
567 - report.setCreditStatus(findMaxPercentageString(creditStatusList));  
568 - report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal);  
569 BigDecimal debtTotal = report.getDebtTotal(); 599 BigDecimal debtTotal = report.getDebtTotal();
  600 + String creditStatus = calculateExcess(debtTotal, report.getQuota());
  601 + if (StringUtils.isNotBlank(creditStatus)) {
  602 + report.setCreditStatus(creditStatus);
  603 + }
  604 + report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal);
570 report.setDebtTotal(valueConvert(debtTotal)); 605 report.setDebtTotal(valueConvert(debtTotal));
571 } 606 }
572 return result; 607 return result;
@@ -1006,13 +1041,111 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -1006,13 +1041,111 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
1006 /** 1041 /**
1007 * 处理“小计”数据 1042 * 处理“小计”数据
1008 * 1043 *
1009 - * @param agreementDataMap 约定内数据集合  
1010 - * @param overdueDataMap 逾期数据集合  
1011 - * @param report 报表数据 1044 + * @param ledgerInfoList 台账明细数据
  1045 + * @param report 报表数据
1012 */ 1046 */
1013 - private void handleSubtotal(Map<String, List<ReceiptLedgerInfo>> agreementDataMap, Map<String, List<ReceiptLedgerInfo>> overdueDataMap  
1014 - , ReceiptLedgerReportBo report) {  
1015 - String customerShortName = report.getCustomerShortName(); 1047 + private void handleSubtotal(List<ReceiptLedgerInfo> ledgerInfoList, ReceiptLedgerReportBo report) {
  1048 + if (CollectionUtils.isEmpty(ledgerInfoList) || report == null) {
  1049 + return;
  1050 + }
  1051 + BigDecimal debtTotal = report.getDebtTotal();
  1052 + // 约定内欠款
  1053 + BigDecimal agreement = getAgreementDebt(ledgerInfoList, report);
  1054 + if (agreement.compareTo(debtTotal) >= 0) {
  1055 + report.setAgreementTotal(valueConvert(debtTotal));
  1056 + report.setTimingStatus("约定内");
  1057 + return;
  1058 + }
  1059 + // 一次协调欠款
  1060 + BigDecimal firstCoordinate = BigDecimal.ZERO;
  1061 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1062 + String customerShortName = report.getCustomerShortName();
  1063 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1064 + continue;
  1065 + }
  1066 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1067 + String debtStatus = ledgerInfo.getDebtStatus();
  1068 + if ("FIRST_COORDINATE".equals(debtStatus)) {
  1069 + firstCoordinate = firstCoordinate.add(startAccountReceivable);
  1070 + }
  1071 + }
  1072 + if (firstCoordinate.add(agreement).compareTo(debtTotal) >= 0) {
  1073 + BigDecimal difference = debtTotal.subtract(agreement);
  1074 + report.setAgreementTotal(valueConvert(agreement));
  1075 + report.setFirstCoordinateTotal(valueConvert(difference));
  1076 + report.setTimingStatus("超期1");
  1077 + return;
  1078 + }
  1079 + // 二次协调欠款
  1080 + BigDecimal secondCoordinate = BigDecimal.ZERO;
  1081 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1082 + String customerShortName = report.getCustomerShortName();
  1083 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1084 + continue;
  1085 + }
  1086 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1087 + String debtStatus = ledgerInfo.getDebtStatus();
  1088 + if ("SECOND_COORDINATE".equals(debtStatus)) {
  1089 + secondCoordinate = secondCoordinate.add(startAccountReceivable);
  1090 + }
  1091 + }
  1092 + BigDecimal secondCoordinateDifference = debtTotal.subtract(agreement).subtract(firstCoordinate);
  1093 + if (secondCoordinate.add(firstCoordinate).add(agreement).compareTo(debtTotal) >= 0) {
  1094 + report.setAgreementTotal(valueConvert(agreement));
  1095 + report.setFirstCoordinateTotal(valueConvert(firstCoordinate));
  1096 + report.setSecondCoordinateTotal(valueConvert(secondCoordinateDifference));
  1097 + report.setTimingStatus("超期2");
  1098 + return;
  1099 + }
  1100 + // 清欠阶段欠款
  1101 + BigDecimal clearDebt = BigDecimal.ZERO;
  1102 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1103 + String customerShortName = report.getCustomerShortName();
  1104 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1105 + continue;
  1106 + }
  1107 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1108 + String debtStatus = ledgerInfo.getDebtStatus();
  1109 + if ("CLEAR_DEBTS".equals(debtStatus)) {
  1110 + clearDebt = clearDebt.add(startAccountReceivable);
  1111 + }
  1112 + }
  1113 + report.setAgreementTotal(valueConvert(agreement));
  1114 + report.setFirstCoordinateTotal(valueConvert(firstCoordinate));
  1115 + report.setSecondCoordinateTotal(valueConvert(secondCoordinate));
  1116 + report.setTimingStatus("超期3");
  1117 + if (clearDebt.add(secondCoordinate).add(firstCoordinate).add(agreement).compareTo(debtTotal) >= 0) {
  1118 + BigDecimal difference = secondCoordinateDifference.subtract(secondCoordinate);
  1119 + report.setClearDebtTotal(valueConvert(difference));
  1120 + } else {
  1121 + report.setClearDebtTotal(valueConvert(clearDebt));
  1122 + }
  1123 + }
  1124 +
  1125 + /**
  1126 + * 获取约定内欠款小计
  1127 + *
  1128 + * @param ledgerInfoList 应收款台账明细数据
  1129 + * @param report 报表数据
  1130 + * @return BigDecimal
  1131 + */
  1132 + private static BigDecimal getAgreementDebt(List<ReceiptLedgerInfo> ledgerInfoList, ReceiptLedgerReportBo report) {
  1133 + BigDecimal agreement = BigDecimal.ZERO;
  1134 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1135 + String customerShortName = report.getCustomerShortName();
  1136 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1137 + continue;
  1138 + }
  1139 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1140 + String debtStatus = ledgerInfo.getDebtStatus();
  1141 + if ("AGREEMENT".equals(debtStatus) || "SETTLE_UP".equals(debtStatus)) {
  1142 + agreement = agreement.add(startAccountReceivable);
  1143 + } else if ("DEPOSIT".equals(debtStatus)) {
  1144 + BigDecimal endAccountReceivable = ledgerInfo.getEndAccountReceivable();
  1145 + agreement = agreement.add(endAccountReceivable.abs());
  1146 + }
  1147 + }
  1148 + return agreement;
1016 } 1149 }
1017 1150
1018 1151
@@ -1073,8 +1206,12 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -1073,8 +1206,12 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
1073 } 1206 }
1074 data.setSettleTerm(credit.getCompanySettlementPeriod()); 1207 data.setSettleTerm(credit.getCompanySettlementPeriod());
1075 } 1208 }
1076 - data.setDeptId(deptId);  
1077 - data.setRegion(region); 1209 + if (StringUtils.isNotBlank(deptId) && !deptId.equals("null")) {
  1210 + data.setDeptId(deptId);
  1211 + }
  1212 + if (StringUtils.isNotBlank(region) && !region.equals("null")) {
  1213 + data.setRegion(region);
  1214 + }
1078 data.setCustomerId(shipmentsOrderInfo.getCustomerId()); 1215 data.setCustomerId(shipmentsOrderInfo.getCustomerId());
1079 data.setShipmentDate(shipmentsOrderInfo.getShipmentsDate()); 1216 data.setShipmentDate(shipmentsOrderInfo.getShipmentsDate());
1080 1217
@@ -6,6 +6,7 @@ import com.lframework.xingyun.sc.vo.ledger.detail.QueryFundOrderingUnitDetailVo; @@ -6,6 +6,7 @@ import com.lframework.xingyun.sc.vo.ledger.detail.QueryFundOrderingUnitDetailVo;
6 import org.apache.ibatis.annotations.Param; 6 import org.apache.ibatis.annotations.Param;
7 7
8 import java.util.List; 8 import java.util.List;
  9 +import java.util.Map;
9 10
10 /** 11 /**
11 * <p> 12 * <p>
@@ -23,4 +24,12 @@ public interface FundOrderingUnitDetailMapper extends BaseMapper<FundOrderingUni @@ -23,4 +24,12 @@ public interface FundOrderingUnitDetailMapper extends BaseMapper<FundOrderingUni
23 List<FundOrderingUnitDetail> query(@Param("vo") QueryFundOrderingUnitDetailVo vo); 24 List<FundOrderingUnitDetail> query(@Param("vo") QueryFundOrderingUnitDetailVo vo);
24 25
25 void batchAdd(@Param("list") List<FundOrderingUnitDetail> list); 26 void batchAdd(@Param("list") List<FundOrderingUnitDetail> list);
  27 +
  28 + /**
  29 + * 根据应收款台账ID获取协调状态
  30 + *
  31 + * @param ledgerIds 应收款台账ID集合
  32 + * @return List<Map<String, Object>>
  33 + */
  34 + List<Map<String, Object>> queryFundsCoordinateStatus(@Param("ledgerIds") List<String> ledgerIds);
26 } 35 }
@@ -7,6 +7,7 @@ import com.lframework.xingyun.sc.vo.ledger.receipt.QueryReceiptLedgerInfoVo; @@ -7,6 +7,7 @@ import com.lframework.xingyun.sc.vo.ledger.receipt.QueryReceiptLedgerInfoVo;
7 import com.lframework.xingyun.sc.vo.ledger.receipt.ReceiptLedgerReportVo; 7 import com.lframework.xingyun.sc.vo.ledger.receipt.ReceiptLedgerReportVo;
8 import org.apache.ibatis.annotations.Param; 8 import org.apache.ibatis.annotations.Param;
9 9
  10 +import java.time.LocalDateTime;
10 import java.util.List; 11 import java.util.List;
11 import java.util.Map; 12 import java.util.Map;
12 13
@@ -57,7 +58,7 @@ public interface ReceiptLedgerInfoMapper extends BaseMapper<ReceiptLedgerInfo> { @@ -57,7 +58,7 @@ public interface ReceiptLedgerInfoMapper extends BaseMapper<ReceiptLedgerInfo> {
57 * @return List<Map<String, BigDecimal>> 58 * @return List<Map<String, BigDecimal>>
58 */ 59 */
59 List<Map<String, Object>> statisticsDebtByShortName(@Param("shortNames") List<String> shortNames, @Param("debtStatusList") List<String> debtStatusList 60 List<Map<String, Object>> statisticsDebtByShortName(@Param("shortNames") List<String> shortNames, @Param("debtStatusList") List<String> debtStatusList
60 - , @Param("type") String type); 61 + , @Param("type") String type, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
61 62
62 /** 63 /**
63 * 根据客户简称获取台账明细数据 64 * 根据客户简称获取台账明细数据
@@ -7,6 +7,7 @@ import com.lframework.xingyun.sc.vo.ledger.detail.CreateFundOrderingUnitDetailVo @@ -7,6 +7,7 @@ import com.lframework.xingyun.sc.vo.ledger.detail.CreateFundOrderingUnitDetailVo
7 import com.lframework.xingyun.sc.vo.ledger.detail.QueryFundOrderingUnitDetailVo; 7 import com.lframework.xingyun.sc.vo.ledger.detail.QueryFundOrderingUnitDetailVo;
8 import com.lframework.xingyun.sc.vo.ledger.detail.UpdateFundOrderingUnitDetailVo; 8 import com.lframework.xingyun.sc.vo.ledger.detail.UpdateFundOrderingUnitDetailVo;
9 import java.util.List; 9 import java.util.List;
  10 +import java.util.Map;
10 11
11 /** 12 /**
12 * 资金协调手续订货单位明细表 Service 13 * 资金协调手续订货单位明细表 Service
@@ -57,4 +58,12 @@ public interface FundOrderingUnitDetailService extends BaseMpService<FundOrderin @@ -57,4 +58,12 @@ public interface FundOrderingUnitDetailService extends BaseMpService<FundOrderin
57 * 批量新增 58 * 批量新增
58 */ 59 */
59 void batchAdd(List<CreateFundOrderingUnitDetailVo> createFundOrderingUnitDetailVoList); 60 void batchAdd(List<CreateFundOrderingUnitDetailVo> createFundOrderingUnitDetailVoList);
  61 +
  62 + /**
  63 + * 根据应收款台账ID获取协调明细记录
  64 + *
  65 + * @param ledgerIds 应收款台账ID集合
  66 + * @return List<Map<String, Object>>
  67 + */
  68 + List<Map<String, Object>> listByLedgerIds(List<String> ledgerIds);
60 } 69 }
@@ -87,6 +87,9 @@ public class QueryReceiptLedgerInfoVo extends PageVo implements BaseVo, Serializ @@ -87,6 +87,9 @@ public class QueryReceiptLedgerInfoVo extends PageVo implements BaseVo, Serializ
87 @ApiModelProperty("厂别") 87 @ApiModelProperty("厂别")
88 private String factoryType; 88 private String factoryType;
89 89
  90 + /**
  91 + * 欠款状态
  92 + */
90 @ApiModelProperty("欠款状态") 93 @ApiModelProperty("欠款状态")
91 private String debtStatus; 94 private String debtStatus;
92 95
@@ -7,6 +7,7 @@ import lombok.Data; @@ -7,6 +7,7 @@ import lombok.Data;
7 7
8 import java.io.Serializable; 8 import java.io.Serializable;
9 import java.math.BigDecimal; 9 import java.math.BigDecimal;
  10 +import java.time.LocalDateTime;
10 11
11 @Data 12 @Data
12 public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializable { 13 public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializable {
@@ -54,4 +55,16 @@ public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializabl @@ -54,4 +55,16 @@ public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializabl
54 */ 55 */
55 @ApiModelProperty("导出类型") 56 @ApiModelProperty("导出类型")
56 private String exportType; 57 private String exportType;
  58 +
  59 + /**
  60 + * 开始时间
  61 + */
  62 + @ApiModelProperty("开始时间")
  63 + private LocalDateTime startTime;
  64 +
  65 + /**
  66 + * 结束时间
  67 + */
  68 + @ApiModelProperty("结束时间")
  69 + private LocalDateTime endTime;
57 } 70 }
@@ -96,4 +96,15 @@ @@ -96,4 +96,15 @@
96 ) 96 )
97 </foreach> 97 </foreach>
98 </insert> 98 </insert>
  99 +
  100 + <select id="queryFundsCoordinateStatus" resultType="java.util.Map">
  101 + select fud.ledger_id,fud.status as debt_status,fc.status
  102 + from fund_ordering_unit_detail fud
  103 + left join fund_ordering_unit fu on fud.fund_ordering_unit_id = fu.id
  104 + left join fund_coordination fc on fu.fund_id = fc.id
  105 + where fud.ledger_id in
  106 + <foreach collection="ledgerIds" open="(" separator="," close=")" item="item">
  107 + #{item}
  108 + </foreach>
  109 + </select>
99 </mapper> 110 </mapper>
@@ -237,9 +237,11 @@ @@ -237,9 +237,11 @@
237 left join sys_dept d on tb.dept_id = d.id 237 left join sys_dept d on tb.dept_id = d.id
238 left join sys_dept r on tb.region = r.id 238 left join sys_dept r on tb.region = r.id
239 left join customer_credit cc on tb.customer_id = cc.company_id 239 left join customer_credit cc on tb.customer_id = cc.company_id
240 - left join receipt_ledger_info rl on tb.id = rl.customer_short_id 240 + left join receipt_ledger_info rl on tb.id = rl.customer_short_id and rl.del_flag = false
241 <where> 241 <where>
242 and rl.type = 'INSIDE' 242 and rl.type = 'INSIDE'
  243 + -- 只统计当月数据
  244 + and rl.create_time >= #{vo.startTime} and rl.create_time &lt;= #{vo.endTime}
243 <if test="vo.customerType != null and vo.customerType != ''"> 245 <if test="vo.customerType != null and vo.customerType != ''">
244 and tb.type = #{vo.customerType} 246 and tb.type = #{vo.customerType}
245 </if> 247 </if>
@@ -269,6 +271,9 @@ @@ -269,6 +271,9 @@
269 inner join base_data_customer_short cs on tb.customer_id = cs.customer_id 271 inner join base_data_customer_short cs on tb.customer_id = cs.customer_id
270 inner join base_data_customer c on tb.customer_id = c.id 272 inner join base_data_customer c on tb.customer_id = c.id
271 <where> 273 <where>
  274 + and tb.del_flag = false
  275 + -- 只统计当月数据
  276 + and tb.create_time >= #{startTime} and tb.create_time &lt;= #{endTime}
272 <if test="type != null and type != ''"> 277 <if test="type != null and type != ''">
273 and tb.type = #{type} 278 and tb.type = #{type}
274 </if> 279 </if>
@@ -292,6 +297,7 @@ @@ -292,6 +297,7 @@
292 from receipt_ledger_info tb 297 from receipt_ledger_info tb
293 left join base_data_customer_short cs on tb.customer_id = cs.customer_id 298 left join base_data_customer_short cs on tb.customer_id = cs.customer_id
294 <where> 299 <where>
  300 + and tb.del_flag = false
295 <if test="type != null and type != ''"> 301 <if test="type != null and type != ''">
296 and tb.type = #{type} 302 and tb.type = #{type}
297 </if> 303 </if>