Просмотр исходного кода

Merge remote-tracking branch 'origin/dev' into dev

lengfaqiang 2 лет назад
Родитель
Сommit
e491582a09
46 измененных файлов с 1485 добавлено и 672 удалено
  1. 24 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/base/TimeBase.java
  2. 7 4
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsService.java
  3. 7 0
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsUnitService.java
  4. 10 6
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractTradeService.java
  5. 46 23
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractTradeUnitService.java
  6. 1 1
      sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractLogisticsMapper.xml
  7. 2 2
      sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractTradeMapper.xml
  8. 23 21
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  9. 15 14
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  10. 0 13
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementLogisticsTrackController.java
  11. 78 21
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java
  12. 0 13
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeTrackController.java
  13. 3 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  14. 1 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  15. 14 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  16. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LogisticsUnitType.java
  17. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementEnum.java
  18. 36 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java
  19. 80 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java
  20. 137 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java
  21. 27 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java
  22. 2 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerReq.java
  23. 2 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java
  24. 0 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java
  25. 49 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java
  26. 98 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java
  27. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  28. 0 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java
  29. 39 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/SettlementSumVo.java
  30. 19 19
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  31. 15 16
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  32. 115 36
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  33. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  34. 42 142
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  35. 85 145
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  36. 138 29
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml
  37. 4 5
      sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwTransportController.java
  38. 8 1
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java
  39. 5 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java
  40. 11 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/WaybillManagementController.java
  41. 59 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WayBillDetailDTO.java
  42. 10 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WaybillOrderDTO.java
  43. 9 4
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillDataVO.java
  44. 257 134
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java
  45. 1 1
      sckw-modules/sckw-transport/src/main/resources/bootstrap-dev.yml
  46. 1 1
      sckw-modules/sckw-transport/src/main/resources/bootstrap.yml

+ 24 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/base/TimeBase.java

@@ -0,0 +1,24 @@
+package com.sckw.core.model.base;
+
+import com.sckw.core.utils.StringTimeUtil;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-27 19:30:53
+ */
+public interface TimeBase {
+    default String getStartDateTime(String time) {
+        if (StringUtils.isBlank(time)) {
+            return null;
+        }
+        return StringTimeUtil.fillStart(time);
+    }
+
+    default String getEndDateTime(String time) {
+        if (StringUtils.isBlank(time)) {
+            return null;
+        }
+        return StringTimeUtil.fillEnd(time);
+    }
+}

+ 7 - 4
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsService.java

@@ -195,12 +195,12 @@ public class KwcContractLogisticsService {
             }
 
             logisticsBaseInfoResVo.setChargingName(DictEnum.getLabel(DictTypeEnum.CHARGING_TYPE.getType(), String.valueOf(kwcContractLogistics.getCharging())));
-            logisticsBaseInfoResVo.setCharging(String.valueOf(kwcContractLogistics.getCharging()));
+            logisticsBaseInfoResVo.setCharging(StringUtils.objectStr(kwcContractLogistics.getCharging()));
             logisticsBaseInfoResVo.setContractCode(kwcContractLogistics.getContractNo());
             logisticsBaseInfoResVo.setContractName(kwcContractLogistics.getName());
             logisticsBaseInfoResVo.setEndTime(Objects.isNull(kwcContractLogistics.getEndTime()) ? Global.EMPTY_STRING : DateUtils.format(kwcContractLogistics.getEndTime()));
             logisticsBaseInfoResVo.setSigningWayName(DictEnum.getLabel(DictTypeEnum.SIGNING_WAY.getType(), String.valueOf(kwcContractLogistics.getSigningWay())));
-            logisticsBaseInfoResVo.setSigningWay(String.valueOf(kwcContractLogistics.getSigningWay()));
+            logisticsBaseInfoResVo.setSigningWay(StringUtils.objectStr(kwcContractLogistics.getSigningWay()));
             logisticsBaseInfoResVo.setStartTime(kwcContractLogistics.getStartTime());
             logisticsBaseInfoResVo.setAmount(kwcContractLogistics.getAmount());
             logisticsBaseInfoResVo.setPerformedAmount(kwcContractLogistics.getPerformedAmount());
@@ -469,8 +469,11 @@ public class KwcContractLogisticsService {
         for (QueryListResDto queryListResDto : queryListResDtos) {
             QueryListResVo queryListResVo = new QueryListResVo();
             BeanUtils.copyProperties(queryListResDto, queryListResVo);
-            queryListResVo.setCheckedEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.LOGISTICS3.getCode()) == 0 ? queryListResDto.getEntName() : queryListResDto.getTargetEntName());
-            queryListResVo.setCarrierEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.LOGISTICS3.getCode()) == 0 ? queryListResDto.getTargetEntName() : queryListResDto.getEntName());
+
+            if (Objects.nonNull(queryListResDto.getUnitType())) {
+                queryListResVo.setCheckedEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.LOGISTICS3.getCode()) == 0 ? queryListResDto.getEntName() : queryListResDto.getTargetEntName());
+                queryListResVo.setCarrierEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.LOGISTICS3.getCode()) == 0 ? queryListResDto.getTargetEntName() : queryListResDto.getEntName());
+            }
 
             UserCacheResDto userCacheResDto = longUserCacheResDtoMap.get(queryListResDto.getInitiateBy());
             if (Objects.nonNull(userCacheResDto)) {

+ 7 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsUnitService.java

@@ -89,10 +89,17 @@ public class KwcContractLogisticsUnitService {
         Long carrierEntId = logisticsBaseInfoReqVo.getCarrierEntId();
         if (Objects.nonNull(carrierEntId)) {
             kwcContractLogisticsUnit.setId(new IdWorker(1L).nextId());
+            kwcContractLogisticsUnit.setContractId(contractId);
             kwcContractLogisticsUnit.setUnitType(CooperateTypeEnum.CARRIAGE.getCode());
             kwcContractLogisticsUnit.setEntId(carrierEntId);
             saveEnt(entCacheResDtoMap, kwcContractLogisticsUnit);
             kwcContractLogisticsUnit.setSignPhone(logisticsBaseInfoReqVo.getCarrierPhone());
+            kwcContractLogisticsUnit.setStatus(Global.NO);
+            kwcContractLogisticsUnit.setCreateBy(LoginUserHolder.getUserId());
+            kwcContractLogisticsUnit.setCreateTime(date);
+            kwcContractLogisticsUnit.setUpdateBy(LoginUserHolder.getUserId());
+            kwcContractLogisticsUnit.setUpdateTime(date);
+            kwcContractLogisticsUnit.setDelFlag(Global.NO);
             if (kwcContractLogisticsUnitMapper.insert(kwcContractLogisticsUnit) <= 0) {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             }

+ 10 - 6
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractTradeService.java

@@ -109,8 +109,11 @@ public class KwcContractTradeService {
             QueryListResVo queryListResVo = new QueryListResVo();
             BeanUtils.copyProperties(queryListResDto, queryListResVo);
 
-            queryListResVo.setProvideEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.SUPPLIER.getCode()) == 0 ? queryListResDto.getEntName() : queryListResDto.getTargetEntName());
-            queryListResVo.setPurchaseEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.SUPPLIER.getCode()) == 0 ? queryListResDto.getTargetEntName() : queryListResDto.getEntName());
+
+            if (Objects.nonNull(queryListResDto.getUnitType())) {
+                queryListResVo.setProvideEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.SUPPLIER.getCode()) == 0 ? queryListResDto.getEntName() : queryListResDto.getTargetEntName());
+                queryListResVo.setPurchaseEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.SUPPLIER.getCode()) == 0 ? queryListResDto.getTargetEntName() : queryListResDto.getEntName());
+            }
 
             UserCacheResDto userCacheResDto = longUserCacheResDtoMap.get(queryListResDto.getInitiateBy());
             if (Objects.nonNull(userCacheResDto)) {
@@ -244,10 +247,10 @@ public class KwcContractTradeService {
         tradeBaseInfoResVo.setContractName(kwcContractTrade.getName());
         tradeBaseInfoResVo.setEndTime(Objects.isNull(kwcContractTrade.getEndTime()) ? Global.EMPTY_STRING : DateUtils.format(kwcContractTrade.getEndTime()));
         tradeBaseInfoResVo.setSigningWayName(DictEnum.getLabel(DictTypeEnum.SIGNING_WAY.getType(), String.valueOf(kwcContractTrade.getSigningWay())));
-        tradeBaseInfoResVo.setSigningWay(String.valueOf(kwcContractTrade.getSigningWay()));
+        tradeBaseInfoResVo.setSigningWay(StringUtils.objectStr(kwcContractTrade.getSigningWay()));
         tradeBaseInfoResVo.setStartTime(kwcContractTrade.getStartTime());
         tradeBaseInfoResVo.setTradingName(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), String.valueOf(kwcContractTrade.getTrading())));
-        tradeBaseInfoResVo.setTrading(String.valueOf(kwcContractTrade.getTrading()));
+        tradeBaseInfoResVo.setTrading(StringUtils.objectStr(kwcContractTrade.getTrading()));
 
         ContractTradeDetailResVo contractTradeDetailResVo = new ContractTradeDetailResVo();
         List<KwcContractTradeUnit> kwcContractTradeUnits = kwcContractTradeUnitService.queryByContractId(id);
@@ -261,7 +264,7 @@ public class KwcContractTradeService {
 
                 if (kwcContractTradeUnit.getUnitType().compareTo(EntTypeEnum.PURCHASER.getCode()) == 0) {
                     tradeBaseInfoResVo.setPurchaseEntName(kwcContractTradeUnit.getFirmName());
-                    tradeBaseInfoResVo.setPurchasePhone(kwcContractTradeUnit.getPhone());
+                    tradeBaseInfoResVo.setPurchasePhone(kwcContractTradeUnit.getSignPhone());
                     tradeBaseInfoResVo.setPurchaseEntId(kwcContractTradeUnit.getEntId());
                 }
             }
@@ -306,7 +309,7 @@ public class KwcContractTradeService {
         List<String> fileList = new ArrayList<>();
         fileList.add(kwcContractTrade.getSigningUrl());
         fileList.add(kwcContractTrade.getSignedUrl());
-        contractTradeDetailResVo.setContractFile(fileList);
+        contractTradeDetailResVo.setContractFile(fileList.stream().filter(StringUtils::isNotBlank).toList());
 
         List<KwcContractTrade> supplementList = getSupplementList(id);
         if (CollectionUtils.isNotEmpty(supplementList)) {
@@ -316,6 +319,7 @@ public class KwcContractTradeService {
             }
             contractTradeDetailResVo.setChild(child);
         }
+        contractTradeDetailResVo.setRemark(kwcContractTrade.getRemark());
         return contractTradeDetailResVo;
     }
 

+ 46 - 23
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractTradeUnitService.java

@@ -8,6 +8,7 @@ import com.sckw.contract.model.vo.req.TradeBaseInfoReqVo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.CooperateTypeEnum;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
@@ -39,8 +40,18 @@ public class KwcContractTradeUnitService {
      */
     public void saveContractTradeUnit(long contractId, TradeBaseInfoReqVo baseInfo) {
         List<Long> entIdList = new ArrayList<>();
-        entIdList.add(baseInfo.getProvideEntId());
-        entIdList.add(baseInfo.getPurchaseEntId());
+        if (Objects.nonNull(baseInfo.getProvideEntId())) {
+            entIdList.add(baseInfo.getProvideEntId());
+        }
+
+        if (Objects.nonNull(baseInfo.getPurchaseEntId())) {
+            entIdList.add(baseInfo.getPurchaseEntId());
+        }
+
+        if (CollectionUtils.isEmpty(entIdList)) {
+            return;
+        }
+
         Map<Long, EntCacheResDto> entCacheResDtoMap = commonBusinessService.queryEntCacheMapByIds(entIdList);
 
         Date date = new Date();
@@ -50,31 +61,43 @@ public class KwcContractTradeUnitService {
     private void saveProvideAndPurchase(long contractId, Map<Long, EntCacheResDto> entCacheResDtoMap, Date date, TradeBaseInfoReqVo baseInfo) {
         //存供应商
         KwcContractTradeUnit kwcContractTradeUnit = new KwcContractTradeUnit();
-        kwcContractTradeUnit.setId(new IdWorker(1L).nextId());
-        kwcContractTradeUnit.setContractId(contractId);
-        kwcContractTradeUnit.setUnitType(CooperateTypeEnum.SUPPLIER.getCode());
-        kwcContractTradeUnit.setEntId(baseInfo.getProvideEntId());
-        saveEnt(entCacheResDtoMap, kwcContractTradeUnit);
-        kwcContractTradeUnit.setSignPhone(baseInfo.getProvidePhone());
-        kwcContractTradeUnit.setStatus(Global.NO);
-        kwcContractTradeUnit.setCreateBy(LoginUserHolder.getUserId());
-        kwcContractTradeUnit.setCreateTime(date);
-        kwcContractTradeUnit.setUpdateBy(LoginUserHolder.getUserId());
-        kwcContractTradeUnit.setUpdateTime(date);
-        kwcContractTradeUnit.setDelFlag(Global.NO);
-        if (kwcContractTradeUnitMapper.insert(kwcContractTradeUnit) <= 0) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+        if(Objects.nonNull(baseInfo.getProvideEntId())) {
+            kwcContractTradeUnit.setId(new IdWorker(1L).nextId());
+            kwcContractTradeUnit.setContractId(contractId);
+            kwcContractTradeUnit.setUnitType(CooperateTypeEnum.SUPPLIER.getCode());
+            kwcContractTradeUnit.setEntId(baseInfo.getProvideEntId());
+            saveEnt(entCacheResDtoMap, kwcContractTradeUnit);
+            kwcContractTradeUnit.setSignPhone(baseInfo.getProvidePhone());
+            kwcContractTradeUnit.setStatus(Global.NO);
+            kwcContractTradeUnit.setCreateBy(LoginUserHolder.getUserId());
+            kwcContractTradeUnit.setCreateTime(date);
+            kwcContractTradeUnit.setUpdateBy(LoginUserHolder.getUserId());
+            kwcContractTradeUnit.setUpdateTime(date);
+            kwcContractTradeUnit.setDelFlag(Global.NO);
+            if (kwcContractTradeUnitMapper.insert(kwcContractTradeUnit) <= 0) {
+                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+            }
         }
 
         //存采购商
-        kwcContractTradeUnit.setId(new IdWorker(1L).nextId());
-        kwcContractTradeUnit.setUnitType(CooperateTypeEnum.PURCHASER.getCode());
-        kwcContractTradeUnit.setEntId(baseInfo.getPurchaseEntId());
-        saveEnt(entCacheResDtoMap, kwcContractTradeUnit);
-        kwcContractTradeUnit.setSignPhone(baseInfo.getPurchasePhone());
-        if (kwcContractTradeUnitMapper.insert(kwcContractTradeUnit) <= 0) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+        if (Objects.nonNull(baseInfo.getPurchaseEntId())) {
+            kwcContractTradeUnit.setId(new IdWorker(1L).nextId());
+            kwcContractTradeUnit.setUnitType(CooperateTypeEnum.PURCHASER.getCode());
+            kwcContractTradeUnit.setEntId(baseInfo.getPurchaseEntId());
+            kwcContractTradeUnit.setContractId(contractId);
+            saveEnt(entCacheResDtoMap, kwcContractTradeUnit);
+            kwcContractTradeUnit.setSignPhone(baseInfo.getPurchasePhone());
+            kwcContractTradeUnit.setStatus(Global.NO);
+            kwcContractTradeUnit.setCreateBy(LoginUserHolder.getUserId());
+            kwcContractTradeUnit.setCreateTime(date);
+            kwcContractTradeUnit.setUpdateBy(LoginUserHolder.getUserId());
+            kwcContractTradeUnit.setUpdateTime(date);
+            kwcContractTradeUnit.setDelFlag(Global.NO);
+            if (kwcContractTradeUnitMapper.insert(kwcContractTradeUnit) <= 0) {
+                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+            }
         }
+
     }
 
     /**

+ 1 - 1
sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractLogisticsMapper.xml

@@ -68,7 +68,7 @@
           left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
           left join kwc_contract_logistics_unit e on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
         where a.del_flag = 0
-          and b.ent_id = #{entId}
+          and case when a.status = 3 then a.ent_id = #{entId} else b.ent_id = #{entId} end
           <if test="startTime != null">
               and a.create_time >= #{startTime}
           </if>

+ 2 - 2
sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractTradeMapper.xml

@@ -64,9 +64,9 @@
           left join kwc_contract_trade_unit b on a.id = b.contract_id and b.unit_type = #{entType} and b.del_flag = 0
           left join kwc_contract_trade_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
           left join kwc_contract_trade_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
-          left join kwc_contract_trade_unit e on a.id = b.contract_id and b.unit_type != #{entType} and e.del_flag = 0
+          left join kwc_contract_trade_unit e on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
          where a.del_flag = 0
-           and b.ent_id = #{entId}
+           and case when a.status = 3 then a.ent_id = #{entId} else b.ent_id = #{entId} end
         <if test="startTime != null">
             and a.create_time >= #{startTime}
         </if>

+ 23 - 21
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java

@@ -1,9 +1,9 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.dto.ILedger;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.LedgerLogisticsVo;
@@ -29,34 +29,25 @@ public class KwpLedgerLogisticsController {
     @Resource
     private KwpLedgerLogisticsService kwpLedgerLogisticsService;
 
-    private void fill(LogisticsSendReq logisticsSendReq) {
-        if (CollectionUtils.isEmpty(logisticsSendReq.getIdList())) {
-            throw new BusinessException("物流订单不能为空");
-        }
-        logisticsSendReq.setOrders(logisticsSendReq.getIdList());
-    }
-
     /**
-     * 物流对账单-发起对账(保存草稿)
+     * 物流对账单-发起对账(保存草稿)(承运方)
      *
      * @param logisticsReq
      * @return
      */
     @PostMapping("sendDraft")
     public HttpResult sendDraft(@RequestBody @Valid LogisticsSendReq logisticsReq) {
-        fill(logisticsReq);
         return HttpResult.ok(kwpLedgerLogisticsService.sendLedgerDraft(logisticsReq));
     }
 
     /**
-     * 物流对账单-发起对账
+     * 物流对账单-发起对账(承运方)
      *
      * @param logisticsReq
      * @return
      */
     @PostMapping("send")
     public HttpResult send(@RequestBody @Valid LogisticsSendReq logisticsReq) {
-        fill(logisticsReq);
         return HttpResult.ok(kwpLedgerLogisticsService.sendLedger(logisticsReq));
     }
 
@@ -72,7 +63,7 @@ public class KwpLedgerLogisticsController {
     }
 
     /**
-     * 承运方物流对账单列表查询
+     * 承运方物流对账单列表查询(物流公司、收钱方)
      *
      * @param logisticsReq
      * @return
@@ -83,18 +74,29 @@ public class KwpLedgerLogisticsController {
     }
 
     /**
-     * 查询物流对账单详情
+     * 承运方-查询物流对账单详情
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("queryCarrierDetail")
+    public HttpResult queryCarrierDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id), LogisticsUnitType.SHIPPER));
+    }
+
+    /**
+     * 托运方-查询物流对账单详情
      *
      * @param id
      * @return
      */
-    @GetMapping("queryDetail")
+    @GetMapping("queryShipperDetail")
     public HttpResult queryDetail(@RequestParam("id") String id) {
-        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id)));
+        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id), LogisticsUnitType.CARRIER));
     }
 
     /**
-     * 修改物流对账单详情(修改物流对账单接口使用)
+     * 修改物流对账单详情(修改物流对账单接口使用) 仅发起对账方支持修改
      *
      * @param id
      * @return
@@ -110,8 +112,8 @@ public class KwpLedgerLogisticsController {
      * @return
      */
     @GetMapping("shipperCount")
-    public HttpResult shipperCount() {
-        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(1));
+    public HttpResult shipperCount(@Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 1));
     }
 
     /**
@@ -120,8 +122,8 @@ public class KwpLedgerLogisticsController {
      * @return
      */
     @GetMapping("carrierCount")
-    public HttpResult carrierCount() {
-        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(2));
+    public HttpResult carrierCount(@Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 2));
     }
 
     /**

+ 15 - 14
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java

@@ -1,9 +1,9 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.dto.ILedger;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.LedgerTradeVo;
@@ -32,12 +32,6 @@ public class KwpLedgerTradeController {
     @Resource
     private KwpLedgerTradeService kwpLedgerTradeService;
 
-    private void fill(TradeSendReq tradeSendReq) {
-        if (CollectionUtils.isEmpty(tradeSendReq.getIdList())) {
-            throw new BusinessException("销售订单不能为空");
-        }
-        tradeSendReq.setOrders(tradeSendReq.getIdList());
-    }
 
     /**
      * 贸易对账单-发起对账(保存草稿)
@@ -47,7 +41,6 @@ public class KwpLedgerTradeController {
      */
     @PostMapping("sendDraft")
     public HttpResult sendDraft(@RequestBody @Valid TradeSendReq tradeSendReq) {
-        fill(tradeSendReq);
         return HttpResult.ok(kwpLedgerTradeService.sendLedgerDraft(tradeSendReq));
     }
 
@@ -59,7 +52,6 @@ public class KwpLedgerTradeController {
      */
     @PostMapping("send")
     public HttpResult send(@RequestBody @Valid TradeSendReq tradeSendReq) {
-        fill(tradeSendReq);
         return HttpResult.ok(kwpLedgerTradeService.sendLedger(tradeSendReq));
     }
 
@@ -86,16 +78,25 @@ public class KwpLedgerTradeController {
     }
 
     /**
-     * 查询贸易对账单详情
+     * 销售-查询贸易对账单详情
      *
      * @param id
      * @return
      */
-    @GetMapping("queryDetail")
-    public HttpResult queryDetail(@RequestParam("id") String id) {
-        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id)));
+    @GetMapping("querySellDetail")
+    public HttpResult querySellDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id), TradeUnitType.PURCHASE));
+    }
+    /**
+     * 采购-查询贸易对账单详情
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("queryPurchaseDetail")
+    public HttpResult queryPurchaseDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id),TradeUnitType.SELL));
     }
-
     /**
      * 修改贸易对账单详情(修改物流对账单接口使用)
      *

+ 0 - 13
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementLogisticsTrackController.java

@@ -1,13 +0,0 @@
-package com.sckw.payment.controller;
-import org.springframework.web.bind.annotation.*;
-
-/**
-* 结算-物流订单-状态信息
-*
-* @author xucaiqin
-*/
-@RestController
-@RequestMapping("/kwp_settlement_logistics_track")
-public class KwpSettlementLogisticsTrackController {
-    
-}

+ 78 - 21
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java

@@ -3,8 +3,9 @@ package com.sckw.payment.controller;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
-import com.sckw.payment.model.dto.SettlementTradeDto;
-import com.sckw.payment.model.vo.req.SettlementReq;
+import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.dto.ISettlement;
+import com.sckw.payment.model.vo.req.SettlementTradeReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsVo;
 import com.sckw.payment.service.KwpSettlementTradeService;
 import jakarta.annotation.Resource;
@@ -30,24 +31,52 @@ public class KwpSettlementTradeController {
     private KwpSettlementTradeService kwpSettlementTradeService;
 
     //   ========= 收款 销售 =========
-    @PostMapping(name = "收款-销售结算单列表", path = "pageListCollection")
-    public HttpResult pageListCollection(@RequestBody @Valid SettlementReq settlementReq) {
+
+    /**
+     * 销售分页列表
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-销售结算单列表", path = "pageSellList")
+    public HttpResult pageListCollection(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
         return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
     }
 
-    @GetMapping(name = "收款-销售结算单列表头部汇总数量", path = "getCountListCollection")
-    public HttpResult getCountListCollection(@RequestBody @Valid SettlementReq settlementReq) {
+    /**
+     * 待结算、部分结算、全部结算
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表头统计数量", path = "getSellCount")
+    public HttpResult getCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
+    }
+
+    /**
+     * 表尾金额结算数据
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表尾金额结算数据", path = "getSellSum")
+    public HttpResult getSellSum(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
         return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
     }
 
     @PostMapping(name = "收款-根据ids导出销售结算单列表", path = "exportCollection")
-    public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
-        List<SettlementTradeDto> list;
+    public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
+        List<ISettlement> list;
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
         if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            PageRes<SettlementTradeDto> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
+            PageRes<ISettlement> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
             list = pageResult.getList();
         } else {
-            list = kwpSettlementTradeService.selectList(settlementReq.getIdList());
+            list = kwpSettlementTradeService.selectList(settlementReq.getIdList(),TradeUnitType.PURCHASE);
         }
         return this.export(response, list);
     }
@@ -59,24 +88,52 @@ public class KwpSettlementTradeController {
 
 
     //   ========= 付款 采购 =========
-    @PostMapping(name = "付款-采购结算单列表", path = "pageListPayment")
-    public HttpResult pageListPayment(@RequestBody @Valid SettlementReq settlementReq) {
-        return HttpResult.ok(kwpSettlementTradeService.pageListPayment(settlementReq));
+
+    /**
+     * 采购分页列表
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "付款-采购结算单列表", path = "pagePurchaseList")
+    public HttpResult pageListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
     }
 
-    @GetMapping(name = "收款-物流结算订单列表头部汇总数量", path = "getCountListPayment")
-    public HttpResult getCountListPayment(@RequestBody @Valid SettlementReq settlementReq) {
-        return HttpResult.ok(kwpSettlementTradeService.getCountListPayment(settlementReq));
+    /**
+     * 待结算、部分结算、全部结算
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表头统计数量", path = "getPurchaseCount")
+    public HttpResult getPurchaseCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
+    }
+
+    /**
+     * 表尾金额结算数据
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-物流结算订单列表头部汇总数量", path = "getPurchaseSum")
+    public HttpResult getCountListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
     }
 
     @PostMapping(name = "付款-根据ids导出采购结算单列表", path = "exportPayment")
-    public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
-        List<SettlementTradeDto> list;
+    public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
+        List<ISettlement> list;
+        settlementReq.setUnitType(TradeUnitType.SELL);
         if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            PageRes<SettlementTradeDto> pageResult = kwpSettlementTradeService.pageListPayment(settlementReq);
+            PageRes<ISettlement> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
             list = pageResult.getList();
         } else {
-            list = kwpSettlementTradeService.selectList(settlementReq.getIdList());
+            list = kwpSettlementTradeService.selectList(settlementReq.getIdList(),TradeUnitType.SELL);
         }
         return this.export(response, list);
     }
@@ -92,7 +149,7 @@ public class KwpSettlementTradeController {
      * @author Aick Spt
      * @date 2023-07-24 15:49
      */
-    private HttpResult export(HttpServletResponse response, List<SettlementTradeDto> list) {
+    private HttpResult export(HttpServletResponse response, List<ISettlement> list) {
         if (CollectionUtils.isEmpty(list)) {
             return HttpResult.error("没有可导出的数据");
         }

+ 0 - 13
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeTrackController.java

@@ -1,13 +0,0 @@
-package com.sckw.payment.controller;
-import org.springframework.web.bind.annotation.*;
-
-/**
-* 结算-交易订单-状态信息
-*
-* @author xucaiqin
-*/
-@RestController
-@RequestMapping("/kwp_settlement_trade_track")
-public class KwpSettlementTradeTrackController {
-    
-}

+ 3 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java

@@ -29,16 +29,16 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
     List<LedgerShipperDto> shipperSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
     /**
-     * 承运方
+     * 承运方 对账发起方,客户公司是托运方
      *
      * @param logisticsReq
      * @return
      */
     List<LedgerCarrierDto> carrierSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
-    Map<String, Long> countOrder(@Param("entId") Long entId, @Param("unitType") Integer unitType);
+    Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("unitType") Integer unitType);
 
-    LedgerLogisticsDto selectId(@Param("id") Long id);
+    LedgerLogisticsDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
 
     List<LedgerShipperDto> selectShipperIds(@Param("ids") List<Long> ids);

+ 1 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java

@@ -19,7 +19,6 @@ import java.util.Map;
 
 @Mapper
 public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
-    List<LedgerTradeDto> pageSelect(@Param("tradeReq") TradeReq tradeReq);
 
     List<LedgerSellDto> sellList(@Param("tradeReq") TradeReq tradeReq);
 
@@ -27,7 +26,7 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     Map<String, Long> countOrder(@Param("entId") Long entId, @Param("unitType") Integer unitType);
 
-    LedgerTradeDto selectId(@Param("id") Long id);
+    LedgerTradeDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     List<LedgerSellDto> selectSellIds(@Param("ids") List<Long> ids);
 

+ 14 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -2,7 +2,14 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementTrade;
+import com.sckw.payment.model.dto.SettlementTradeDto;
+import com.sckw.payment.model.vo.req.SettlementTradeReq;
+import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
+import com.sckw.payment.model.vo.res.SettlementSumVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @author xucaiqin
@@ -11,4 +18,11 @@ import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
 public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade> {
+    List<SettlementTradeDto> pageSelect(@Param("settlementReq") SettlementTradeReq settlementReq);
+
+    SettlementSumVo sumMoney(@Param("settlementReq")SettlementTradeReq settlementReq);
+
+    SettlementLogisticsStatusCountVo countOrder(@Param("settlementReq")SettlementTradeReq settlementReq);
+
+    List<SettlementTradeDto> selectByIds(@Param("ids") List<Long> ids);
 }

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LogisticsUnitType.java

@@ -6,11 +6,11 @@ package com.sckw.payment.model.constant;
  */
 public interface LogisticsUnitType {
     /**
-     * 托运方(客户单位)
+     * 托运方 货物的委托人或发货人,即发送货物的一方
      */
     Integer SHIPPER = 1;
     /**
-     * 承运方
+     * 承运方 发起对账的一方
      */
     Integer CARRIER = 2;
 }

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementEnum.java

@@ -8,6 +8,7 @@ package com.sckw.payment.model.constant;
  * @date 2023-07-11 12:00:52
  */
 public enum SettlementEnum {
+    ALL(0, "全部"),
     WAITING_PAYMENT(1, "待结算"),
     PARTIAL_PAYMENT(2, "部分结算"),
     ALL_PAYMENT(3, "全部结算");

+ 36 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java

@@ -0,0 +1,36 @@
+package com.sckw.payment.model.dto;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.Objects;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-28 08:42:13
+ */
+public interface ISettlement {
+
+    void setTrading(Integer trading);
+
+    Integer getTrading();
+
+    void setTradingLabel(String tradingLabel);
+
+    void setStatus(Integer status);
+
+    Integer getStatus();
+
+    void setStatusLabel(String statusLabel);
+
+    private DecimalFormat df() {
+        return new DecimalFormat("0.00");
+    }
+
+    default String changePrice(BigDecimal price) {
+        if (Objects.isNull(price)) {
+            //金额为null时显示的金额
+            return "";
+        }
+        return df().format(price);
+    }
+}

+ 80 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java

@@ -0,0 +1,80 @@
+package com.sckw.payment.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 销售结算 采购方
+ *
+ * @author xucaiqin
+ * @date 2023-07-20 12:26
+ */
+@Getter
+@Setter
+public class SettlementPurchaseDto implements ISettlement {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 结算单编号
+     */
+    private String stOrderNo;
+
+    /**
+     * 结算单名称
+     */
+    private String name;
+
+    /**
+     * 总应收/元
+     */
+    private String totalPrice;
+
+    /**
+     * 已收款/元
+     */
+    private String actualPrice;
+    /**
+     * 剩余带回款金额
+     */
+    private String waitPrice;
+
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date receiptTime;
+
+    /**
+     * 对账销售财务联系人名称
+     */
+    private String successUser;
+
+    /**
+     * 对账销售财务联系人电话
+     */
+    private String successPhone;
+    /**
+     * 交易方式
+     */
+    private Integer trading;
+    private String tradingLabel;
+
+    /**
+     * 状态(待回款、部分回款、全部回款、回退)
+     */
+    private Integer status;
+    private String statusLabel;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+}

+ 137 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java

@@ -0,0 +1,137 @@
+package com.sckw.payment.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.Date;
+
+/**
+ * 销售结算 销售方
+ *
+ * @author Aick Spt
+ * @date 2023-07-20 12:26
+ */
+@Setter
+@ToString
+public class SettlementSellDto implements ISettlement {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 结算单编号
+     */
+    private String stOrderNo;
+
+    /**
+     * 结算单名称
+     */
+    private String name;
+
+    /**
+     * 总应收/元
+     */
+    private String totalPrice;
+
+    /**
+     * 已收款/元
+     */
+    private String actualPrice;
+    /**
+     * 剩余带回款金额
+     */
+    private String waitPrice;
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date receiptTime;
+
+    /**
+     * 对账采购财务联系人名称
+     */
+    private String auditUser;
+
+    /**
+     * 对账采购财务联系人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private Integer trading;
+    private String tradingLabel;
+
+    /**
+     * 状态(待回款、部分回款、全部回款、回退)
+     */
+    private Integer status;
+    private String statusLabel;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getStOrderNo() {
+        return stOrderNo;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getTotalPrice() {
+        return totalPrice;
+    }
+
+    public String getActualPrice() {
+        return actualPrice;
+    }
+
+    public String getWaitPrice() {
+        return waitPrice;
+    }
+
+    public Date getReceiptTime() {
+        return receiptTime;
+    }
+
+    public String getAuditUser() {
+        return auditUser;
+    }
+
+    public String getAuditPhone() {
+        return auditPhone;
+    }
+
+    @Override
+    public Integer getTrading() {
+        return trading;
+    }
+
+    public String getTradingLabel() {
+        return tradingLabel;
+    }
+
+    @Override
+    public Integer getStatus() {
+        return status;
+    }
+
+    public String getStatusLabel() {
+        return statusLabel;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+}

+ 27 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java

@@ -3,17 +3,19 @@ package com.sckw.payment.model.dto;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 /**
  * 结算-交易订单
+ *
  * @author Aick Spt
  * @date 2023-07-20 12:26
  */
 @Getter
 @Setter
-public class SettlementTradeDto {
+public class SettlementTradeDto implements ISettlement {
 
     /**
      * 主键
@@ -49,6 +51,10 @@ public class SettlementTradeDto {
      * 已收款/元
      */
     private BigDecimal actualPrice;
+    /**
+     * 带回款金额(扩展的计算字段)
+     */
+    private BigDecimal waitPrice;
 
     /**
      * 预计收款日期
@@ -139,4 +145,24 @@ public class SettlementTradeDto {
                 ", delFlag=" + delFlag +
                 '}';
     }
+
+    @Override
+    public void setTrading(Integer trading) {
+
+    }
+
+    @Override
+    public Integer getTrading() {
+        return null;
+    }
+
+    @Override
+    public void setTradingLabel(String tradingLabel) {
+
+    }
+
+    @Override
+    public void setStatusLabel(String statusLabel) {
+
+    }
 }

+ 2 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerReq.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.model.vo.req;
 
+import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
@@ -12,7 +13,7 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class LedgerReq {
+public class LedgerReq implements IdsList {
     @NotNull(message = "对账单id不能为空")
     private String id;
     @NotBlank(message = "驳回原因不能为空")

+ 2 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.vo.req;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
@@ -17,7 +18,7 @@ import java.time.LocalDate;
  */
 @Getter
 @Setter
-public class LedgerSuccessReq {
+public class LedgerSuccessReq implements IdsList {
     @NotNull(message = "物流对账单id不能为空")
     private String id;
     @NotBlank(message = "财务联系人不能为空")

+ 0 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java

@@ -9,7 +9,6 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * @author xucaiqin
@@ -83,7 +82,6 @@ public class LogisticsSendReq implements IdsList {
     @NotEmpty(message = "承运订单不能为空")
     private String ids;
 
-    private List<Long> orders;
     private LocalDateTime generateTime;
     private Integer status;
 

+ 49 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java

@@ -0,0 +1,49 @@
+package com.sckw.payment.model.vo.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.vo.BasePara;
+import com.sckw.payment.model.constant.SettlementEnum;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serial;
+import java.time.LocalDateTime;
+
+/**
+ * @author Aick Spt
+ * @date 2023-07-18 11:29
+ */
+@Getter
+@Setter
+public class SettlementOfflinePayReq extends BasePara {
+    @Serial
+    private static final long serialVersionUID = 6537008434516489423L;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "创建时间开始日期不能为空")
+    private LocalDateTime startCreateTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "创建时间结束日期不能为空")
+    private LocalDateTime endCreateTime;
+
+        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "预计回款开始日期不能为空")
+    private LocalDateTime startReceiptTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "预计回款结束日期不能为空")
+    private LocalDateTime endReceiptTime;
+
+    /**
+     * @see SettlementEnum
+     */
+    private Integer status;
+
+    private String ids;
+}

+ 98 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java

@@ -0,0 +1,98 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.base.TimeBase;
+import com.sckw.core.model.vo.BasePara;
+import com.sckw.payment.model.constant.SettlementEnum;
+
+import java.io.Serial;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-18 11:29
+ */
+public class SettlementTradeReq extends BasePara implements TimeBase {
+    @Serial
+    private static final long serialVersionUID = -508783597831158781L;
+
+    private String startCreateTime;
+
+    private String endCreateTime;
+
+    private String startReceiptTime;
+
+    private String endReceiptTime;
+
+    /**
+     * @see SettlementEnum
+     */
+    private Integer status;
+    private Integer unitType;
+
+    private String ids;
+    private Long entId;
+
+    public Long getEntId() {
+        return entId;
+    }
+
+    public void setEntId(Long entId) {
+        this.entId = entId;
+    }
+
+    public Integer getUnitType() {
+        return unitType;
+    }
+
+    public void setUnitType(Integer unitType) {
+        this.unitType = unitType;
+    }
+
+    public String getStartCreateTime() {
+        return getStartDateTime(startCreateTime);
+    }
+
+    public void setStartCreateTime(String startCreateTime) {
+        this.startCreateTime = startCreateTime;
+    }
+
+    public String getEndCreateTime() {
+        return getEndDateTime(endCreateTime);
+    }
+
+    public void setEndCreateTime(String endCreateTime) {
+        this.endCreateTime = endCreateTime;
+    }
+
+    public String getStartReceiptTime() {
+        return getStartDateTime(startReceiptTime);
+    }
+
+    public void setStartReceiptTime(String startReceiptTime) {
+        this.startReceiptTime = startReceiptTime;
+    }
+
+    public String getEndReceiptTime() {
+        return getEndDateTime(endReceiptTime);
+    }
+
+    public void setEndReceiptTime(String endReceiptTime) {
+        this.endReceiptTime = endReceiptTime;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    @Override
+    public String getIds() {
+        return ids;
+    }
+
+    public void setIds(String ids) {
+        this.ids = ids;
+    }
+}

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java

@@ -25,5 +25,6 @@ public class TradeReq extends BasePara {
     private Integer status;
     private String ids;
     private Long entId;
+    private Integer unitType;
 
 }

+ 0 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java

@@ -84,7 +84,6 @@ public class TradeSendReq implements IdsList {
     @NotBlank(message = "销售订单不能为空")
     private String ids;
 
-    private List<Long> orders;
     private LocalDateTime generateTime;
     private Integer status;
 }

+ 39 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/SettlementSumVo.java

@@ -0,0 +1,39 @@
+package com.sckw.payment.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 表尾结算统计数据
+ *
+ * @author xucaiqin
+ * @date 2023-07-21 14:44
+ */
+@Getter
+@Setter
+public class SettlementSumVo {
+
+    /**
+     * 合计数量
+     */
+    public Long allCount;
+
+    /**
+     * 实际应收
+     */
+    public BigDecimal receiveAll;
+
+    /**
+     * 当前收款
+     */
+    public BigDecimal alreadyReceive;
+
+    /**
+     * 代收款
+     */
+    public BigDecimal waitReceive;
+
+
+}

+ 19 - 19
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java

@@ -98,6 +98,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
     public PageRes<ILedger> shipperList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
+        logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
         List<LedgerShipperDto> kwpLedgerLogisticsList = logisticsMapper.shipperSelect(logisticsReq);
         //字典转换
@@ -112,6 +113,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     public PageRes<ILedger> carrierList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
+        logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
         List<LedgerCarrierDto> kwpLedgerLogisticsList = logisticsMapper.carrierSelect(logisticsReq);
         //字典转换
         if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
@@ -159,7 +161,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
     private Long saveDraft(LogisticsSendReq logisticsSendReq) {
         KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
-        kwpLedgerLogistics.setId(StringUtils.isBlank(logisticsSendReq.getId()) ? new IdWorker(1).nextId() : Long.parseLong(logisticsSendReq.getId()));
+        kwpLedgerLogistics.setId(Objects.isNull(logisticsSendReq.getIdLong()) ? new IdWorker(1).nextId() : logisticsSendReq.getIdLong());
         kwpLedgerLogistics.setEntId(LoginUserHolder.getEntId());
         kwpLedgerLogistics.setName(logisticsSendReq.getName());
         if (StringUtils.isNotBlank(logisticsSendReq.getStartTime())) {
@@ -177,7 +179,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setAuditUser("");
         kwpLedgerLogistics.setAuditPhone("");
         kwpLedgerLogistics.setReceiptTime(null);
-        kwpLedgerLogistics.setOrderCount(logisticsSendReq.getOrders().size());
+        kwpLedgerLogistics.setOrderCount(logisticsSendReq.getIdList().size());
         kwpLedgerLogistics.setUrl("");
         kwpLedgerLogistics.setGenerateTime(logisticsSendReq.getGenerateTime());
         kwpLedgerLogistics.setRemark("");
@@ -191,7 +193,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
             kwpLedgerLogistics.setLLedgerNo(OrderGenerateUtils.generateOrderNo("LL"));
             logisticsMapper.insert(kwpLedgerLogistics);
         } else {
-            KwpLedgerLogistics ledgerLogistics = logisticsMapper.selectById(logisticsSendReq.getId());
+            KwpLedgerLogistics ledgerLogistics = logisticsMapper.selectById(logisticsSendReq.getIdLong());
             orderCheck(ledgerLogistics);
             updateCheck(ledgerLogistics.getStatus());
             kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
@@ -199,10 +201,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
             logisticsMapper.updateById(kwpLedgerLogistics);
         }
         /*保存物流订单关联数据*/
-        List<Long> ids = logisticsSendReq.getOrders();
+        List<Long> ids = logisticsSendReq.getIdList();
         //todo-xcq 校验当前订单是否已存在绑定的对账单
         logisticsOrderService.check(ids);
-        List<KwtLogisticsOrderVO> acceptCarriageOrderDetail = transportDubboService.getAcceptCarriageOrderDetail(ids.stream().map(a -> Long.toString(a)).toList());
+        List<KwtLogisticsOrderVO> acceptCarriageOrderDetail = transportDubboService.getAcceptCarriageOrderDetail(logisticsSendReq.getIdsList());
         if (CollectionUtils.isEmpty(acceptCarriageOrderDetail) || acceptCarriageOrderDetail.size() < ids.size()) {
             throw new BusinessException("未找到物流订单!");
         }
@@ -353,8 +355,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      * @return
      */
     public Integer doBack(LedgerReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
-        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getIdLong());
         if (Objects.isNull(kwpLedgerLogistics)) {
             throw new BusinessException("对账单不存在!");
         }
@@ -363,7 +364,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         logisticsMapper.updateById(kwpLedgerLogistics);
-        return logisticsTrackService.saveTrack(id, ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
+        return logisticsTrackService.saveTrack(ledgerReq.getIdLong(), ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
     }
 
     /**
@@ -375,8 +376,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public Integer confirmOrder(LedgerConfirmReq confirmReq) {
-        Long id = Long.parseLong(confirmReq.getId());
-        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(confirmReq.getIdLong());
         orderCheck(kwpLedgerLogistics);
         confirmCheck(kwpLedgerLogistics.getStatus());
         kwpLedgerLogistics.setStatus(LedgerEnum.LEDGERED.getStatus());
@@ -386,7 +386,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
         logisticsMapper.updateById(kwpLedgerLogistics);
-        return logisticsTrackService.saveTrack(id, "", LedgerTrackEnum.CONFIRM);
+        return logisticsTrackService.saveTrack(confirmReq.getIdLong(), "", LedgerTrackEnum.CONFIRM);
     }
 
     /**
@@ -397,8 +397,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String orderSuccess(LedgerSuccessReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
-        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getIdLong());
         orderCheck(kwpLedgerLogistics);
 
         successCheck(kwpLedgerLogistics.getStatus());
@@ -432,7 +431,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
         settlementLogisticsService.save(kwpSettlementLogistics);
 
-        logisticsTrackService.saveTrack(id, "", LedgerTrackEnum.SUCCESS);
+        logisticsTrackService.saveTrack(ledgerReq.getIdLong(), "", LedgerTrackEnum.SUCCESS);
         return "对账完成";
     }
 
@@ -440,8 +439,9 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      * @param unitType 1-托运方 2-承运方
      * @return
      */
-    public List<LedgerCountVo> orderCount(Integer unitType) {
-        Map<String, Long> map = logisticsMapper.countOrder(LoginUserHolder.getEntId(), unitType);
+    public List<LedgerCountVo> orderCount(LogisticsReq logisticsReq, Integer unitType) {
+        logisticsReq.setEntId(LoginUserHolder.getEntId());
+        Map<String, Long> map = logisticsMapper.countOrder(logisticsReq, unitType);
         LedgerCountVo ledgerCountVo;
         List<LedgerCountVo> res = new ArrayList<>();
         for (LedgerEnum value : LedgerEnum.values()) {
@@ -481,14 +481,14 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     }
 
     public LedgerLogisticsDetailVo queryUpdate(Long id) {
-        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id);
+        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id, LogisticsUnitType.SHIPPER);
         orderCheck(ledgerLogisticsDto);
         updateCheck(ledgerLogisticsDto.getStatus());
         return getLedgerLogisticsDetailVo(ledgerLogisticsDto);
     }
 
-    public LedgerLogisticsDetailVo queryDetail(Long id) {
-        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id);
+    public LedgerLogisticsDetailVo queryDetail(Long id, Integer unitType) {
+        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id, unitType);
         orderCheck(ledgerLogisticsDto);
         return getLedgerLogisticsDetailVo(ledgerLogisticsDto);
     }

+ 15 - 16
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -101,6 +101,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     public PageRes<ILedger> sellList(TradeReq tradeReq) {
         fillPara(tradeReq);
         PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        tradeReq.setUnitType(TradeUnitType.PURCHASE);
         List<LedgerSellDto> ledgerTradeDto = tradeMapper.sellList(tradeReq);
         //字典转换
         if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
@@ -120,6 +121,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     public PageRes<ILedger> purchaseList(TradeReq tradeReq) {
         fillPara(tradeReq);
         PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        tradeReq.setUnitType(TradeUnitType.SELL);
         List<LedgerPurchaseDto> ledgerTradeDto = tradeMapper.purchaseList(tradeReq);
         //字典转换
         if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
@@ -141,7 +143,7 @@ public class KwpLedgerTradeService extends AbsLedger {
 
     private Long saveDraft(TradeSendReq tradeSendReq) {
         KwpLedgerTrade kwpLedgerTrade = new KwpLedgerTrade();
-        kwpLedgerTrade.setId(StringUtils.isBlank(tradeSendReq.getId()) ? new IdWorker(1).nextId() : Long.parseLong(tradeSendReq.getId()));
+        kwpLedgerTrade.setId(Objects.isNull(tradeSendReq.getId()) ? new IdWorker(1).nextId() : tradeSendReq.getIdLong());
         kwpLedgerTrade.setEntId(LoginUserHolder.getEntId());
         kwpLedgerTrade.setName(tradeSendReq.getName());
         if (StringUtils.isNotBlank(tradeSendReq.getStartTime())) {
@@ -160,7 +162,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpLedgerTrade.setAuditPhone("");
         kwpLedgerTrade.setGenerateTime(tradeSendReq.getGenerateTime());
         kwpLedgerTrade.setReceiptTime(null);
-        kwpLedgerTrade.setOrderCount(tradeSendReq.getOrders().size());
+        kwpLedgerTrade.setOrderCount(tradeSendReq.getIdList().size());
         kwpLedgerTrade.setUrl("");
         kwpLedgerTrade.setRemark("");
         kwpLedgerTrade.setStatus(tradeSendReq.getStatus());
@@ -183,7 +185,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         }
 
         /*保存贸易订单关联数据*/
-        List<Long> ids = tradeSendReq.getOrders();
+        List<Long> ids = tradeSendReq.getIdList();
         //todo-xcq 校验当前订单是否已存在绑定的对账单
         tradeOrderService.check(ids);
         List<OrderDetailRes> resList = new ArrayList<>();
@@ -276,8 +278,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     @Transactional(rollbackFor = Exception.class)
     public String sendLedger(TradeSendReq tradeSendReq) {
         log.info("保存对账单入参:{}", JSONObject.toJSONString(tradeSendReq));
-        String id = tradeSendReq.getId();
-        if (StringUtils.isBlank(id)) {
+        if (Objects.isNull(tradeSendReq.getIdLong())) {
             //新增
             tradeSendReq.setGenerateTime(LocalDateTime.now());
             tradeSendReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
@@ -285,7 +286,7 @@ public class KwpLedgerTradeService extends AbsLedger {
             tradeTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
         } else {
             //先删除
-            removeDraft(Long.parseLong(id));
+            removeDraft(tradeSendReq.getIdLong());
             //在新增
             tradeSendReq.setGenerateTime(LocalDateTime.now());
             tradeSendReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
@@ -364,15 +365,14 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @return
      */
     public String doBack(LedgerReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
-        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(id);
+        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(ledgerReq.getIdLong());
         orderCheck(kwpLedgerTrade);
         backCheck(kwpLedgerTrade.getStatus());
         kwpLedgerTrade.setStatus(LedgerEnum.BACK.getStatus());
         kwpLedgerTrade.setUpdateBy(LoginUserHolder.getUserId());
         kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
         tradeMapper.updateById(kwpLedgerTrade);
-        tradeTrackService.saveTrack(id, ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
+        tradeTrackService.saveTrack(ledgerReq.getIdLong(), ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
         return "驳回成功";
     }
 
@@ -384,8 +384,7 @@ public class KwpLedgerTradeService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String confirmOrder(LedgerConfirmReq confirmReq) {
-        Long id = Long.parseLong(confirmReq.getId());
-        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(id);
+        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(confirmReq.getIdLong());
         orderCheck(kwpLedgerTrade);
         confirmCheck(kwpLedgerTrade.getStatus());
         kwpLedgerTrade.setStatus(LedgerEnum.LEDGERED.getStatus());
@@ -395,7 +394,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpLedgerTrade.setUpdateBy(LoginUserHolder.getUserId());
         kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
         tradeMapper.updateById(kwpLedgerTrade);
-        tradeTrackService.saveTrack(id, "", LedgerTrackEnum.CONFIRM);
+        tradeTrackService.saveTrack(confirmReq.getIdLong(), "", LedgerTrackEnum.CONFIRM);
         return "对账确认成功";
     }
 
@@ -407,7 +406,7 @@ public class KwpLedgerTradeService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String orderSuccess(LedgerSuccessReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
+        Long id = ledgerReq.getIdLong();
 
         KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(id);
         orderCheck(kwpLedgerTrade);
@@ -473,7 +472,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     }
 
     public LedgerTradeDetailVo queryUpdate(Long id) {
-        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id);
+        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id,TradeUnitType.PURCHASE);
         orderCheck(ledgerTradeDto);
         updateCheck(ledgerTradeDto.getStatus());
         List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());
@@ -500,8 +499,8 @@ public class KwpLedgerTradeService extends AbsLedger {
         return ledgerTradeDetailVo;
     }
 
-    public LedgerTradeDetailVo queryDetail(Long id) {
-        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id);
+    public LedgerTradeDetailVo queryDetail(Long id, Integer unitType) {
+        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id,unitType);
         orderCheck(ledgerTradeDto);
 
         List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());

+ 115 - 36
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java

@@ -1,71 +1,150 @@
 package com.sckw.payment.service;
 
+import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementTradeMapper;
 import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.constant.SettlementEnum;
-import com.sckw.payment.model.dto.SettlementLogisticsDto;
+import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.dto.ISettlement;
+import com.sckw.payment.model.dto.SettlementPurchaseDto;
+import com.sckw.payment.model.dto.SettlementSellDto;
 import com.sckw.payment.model.dto.SettlementTradeDto;
-import com.sckw.payment.model.dto.SettlementWalletDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
+import com.sckw.payment.model.vo.req.SettlementTradeReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
-import lombok.AllArgsConstructor;
+import com.sckw.payment.model.vo.res.SettlementSumVo;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.SysDictResDto;
+import jakarta.annotation.Resource;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * @author xucaiqin
  * @date 2023-07-10 16:38:36
  */
 @Service
-@AllArgsConstructor
 public class KwpSettlementTradeService {
-    private final KwpSettlementTradeMapper settlementTradeMapper;
+    @Resource
+    private KwpSettlementTradeMapper settlementTradeMapper;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+
+    public KwpSettlementTrade getById(Long id) {
+        return settlementTradeMapper.selectById(id);
+    }
 
     public void save(KwpSettlementTrade kwpSettlementTrade) {
         settlementTradeMapper.insert(kwpSettlementTrade);
     }
 
-    public PageRes<SettlementTradeDto> pageListCollection(SettlementReq settlementReq) {
-//        //todo 查询缓存,获取客户企业id
-//        String keywords = settlementReq.getKeywords();
-//        if (StringUtils.isNotBlank(keywords)) {
-//            System.out.println("关键之:" + keywords);
-//        }
-//        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
-//
-//        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementOfflineMapper.pageSelect(settlementReq);
-//
-//        return new PageRes<>(new PageInfo<>(kwpLedgerLogisticsList));
+    private void changeDict(List<ISettlement> list) {
+        //字典等数据转换
+        Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.TRADE_TYPE.getType());
+        for (ISettlement iSettlement : list) {
+            Integer trading = iSettlement.getTrading();
+            SysDictResDto sysDictResDto = dictResDtoMap.get(String.valueOf(trading));
+            if (Objects.nonNull(sysDictResDto)) {
+                iSettlement.setTradingLabel(sysDictResDto.getLabel());
+            }
+            iSettlement.setStatusLabel(SettlementEnum.getStatusDesc(iSettlement.getStatus()));
+        }
+    }
+
+    public PageRes<ISettlement> pageListCollection(SettlementTradeReq settlementReq) {
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
+        List<SettlementTradeDto> kwpLedgerLogisticsList = settlementTradeMapper.pageSelect(settlementReq);
+        if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
+            //根据企业类型进行对应的数据
+            if (Objects.equals(settlementReq.getUnitType(), TradeUnitType.PURCHASE)) {
+                List<SettlementPurchaseDto> list = kwpLedgerLogisticsList.stream().map(a -> {
+                    SettlementPurchaseDto settlementSellDto = new SettlementPurchaseDto();
+                    BeanUtils.copyProperties(a, settlementSellDto);
+                    settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
+                    settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
+                    settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
+                    return settlementSellDto;
+                }).toList();
+                List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
+                changeDict(ledgerShipperDto);
+                return new PageRes<>(new PageInfo<>(ledgerShipperDto));
+            }
+            if (Objects.equals(settlementReq.getUnitType(), TradeUnitType.SELL)) {
+                List<SettlementSellDto> list = kwpLedgerLogisticsList.stream().map(a -> {
+                    SettlementSellDto settlementSellDto = new SettlementSellDto();
+                    BeanUtils.copyProperties(a, settlementSellDto);
+                    settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
+                    settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
+                    settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
+                    return settlementSellDto;
+                }).toList();
+                List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
+                changeDict(ledgerShipperDto);
+                return new PageRes<>(new PageInfo<>(ledgerShipperDto));
+            }
+        }
         return new PageRes<>(new PageInfo<>());
     }
 
-    public SettlementLogisticsStatusCountVo getCountListCollection(SettlementReq settlementReq) {
-        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-        //总
-//        settlementReq.setStatus(null);
-//        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-//
-//        //待结算
-//        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
-//        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-//
-//        //部分结算
-//        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-//        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-//
-//        //全部结算
-//        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-//        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
+    public SettlementLogisticsStatusCountVo getCount(SettlementTradeReq settlementReq) {
+        return settlementTradeMapper.countOrder(settlementReq);
+    }
 
-        return settlementLogisticsStatusCountVos;
+    /**
+     * 表尾统计数据
+     *
+     * @param settlementReq
+     * @return
+     */
+    public SettlementSumVo getCountListCollection(SettlementTradeReq settlementReq) {
+        return settlementTradeMapper.sumMoney(settlementReq);
     }
 
 
-    public List<SettlementTradeDto> selectList(List<Long> ids) {
-        return null;
+    public List<ISettlement> selectList(List<Long> ids, int unitType) {
+        List<SettlementTradeDto> kwpSettlementTrades = settlementTradeMapper.selectByIds(ids);
+        if (!CollectionUtils.isEmpty(kwpSettlementTrades)) {
+            //根据企业类型进行对应的数据
+            if (unitType == TradeUnitType.PURCHASE) {
+                List<SettlementPurchaseDto> list = kwpSettlementTrades.stream().map(a -> {
+                    SettlementPurchaseDto settlementSellDto = new SettlementPurchaseDto();
+                    BeanUtils.copyProperties(a, settlementSellDto);
+                    settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
+                    settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
+                    settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
+                    return settlementSellDto;
+                }).toList();
+                List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
+                changeDict(ledgerShipperDto);
+                return ledgerShipperDto;
+            }
+            if (unitType == TradeUnitType.SELL) {
+                List<SettlementSellDto> list = kwpSettlementTrades.stream().map(a -> {
+                    SettlementSellDto settlementSellDto = new SettlementSellDto();
+                    BeanUtils.copyProperties(a, settlementSellDto);
+                    settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
+                    settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
+                    settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
+                    return settlementSellDto;
+                }).toList();
+                List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
+                changeDict(ledgerShipperDto);
+                return ledgerShipperDto;
+            }
+        }
+        return new ArrayList<>();
     }
 
     /**

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -30,7 +30,6 @@ import org.springframework.util.CollectionUtils;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
-import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -51,6 +50,7 @@ public class KwpSettlementWalletService {
     private final KwpSettlementTradeService kwpSettlementTradeService;
 
     private final KwpSettlementTradeMapper kwpSettlementTradeMapper;
+    private final KwpLedgerTradeService ledgerTradeService;
 
     /**
      * 物流-电子钱包付款(货到付款)结算记录-列表

+ 42 - 142
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -58,36 +58,39 @@
         update_time,
         del_flag
     </sql>
-
-    <select id="shipperSelect" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+    <sql id="list_col">
+        kll.id,
+        kll.l_ledger_no   lLedgerNo,
+        kll.name,
+        kll.start_time    startTime,
+        kll.end_time      endTime,
+        kll.tax_rate      taxRate,
+        kll.trading,
+        kll.total_price   totalPrice,
+        kll.ex_tax_price  exTaxPrice,
+        kll.settle_price  settlePrice,
+        kll.actual_price  actualPrice,
+        kll.audit_phone   auditPhone,
+        kll.audit_user    auditUser,
+        kll.url,
+        kll.generate_time generateTime,
+        kll.receipt_time  receiptTime,
+        kll.remark,
+        kll.status,
+        kllu.contacts,
+        kllu.phone,
+        kllu.firm_name    firmName,
+        kll.order_count   orderCount
+    </sql>
+    <sql id="pageList">
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
             kll.del_flag = 0
-              and kllu.unit_type = 1
-              and kllu.ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+              and kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
+              and kllu.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
             <if test="logisticsReq.status != null">
                 and kll.status = #{logisticsReq.status}
             </if>
@@ -107,55 +110,12 @@
             </if>
         </where>
         order by kll.generate_time desc
+    </sql>
+    <select id="shipperSelect" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
+        <include refid="pageList"/>
     </select>
     <select id="carrierSelect" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
-        from kwp_ledger_logistics kll
-                 inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
-        <where>
-            kll.del_flag = 0
-              and kllu.unit_type = 2
-              and kllu.ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
-            <if test="logisticsReq.status != null">
-                and kll.status = #{logisticsReq.status}
-            </if>
-            <if test="logisticsReq.trading != null">
-                and kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
-            </if>
-            <if test="logisticsReq.startCreateTime != null and logisticsReq.endCreateTime != null">
-                and kll.generate_time between #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
-                    and #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
-            </if>
-            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
-                and (
-                            kll.l_ledger_no like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kllu.firm_name like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
-                    )
-            </if>
-        </where>
-        order by kll.generate_time desc
+        <include refid="pageList"/>
     </select>
 
     <select id="countOrder" resultType="java.util.Map">
@@ -170,32 +130,12 @@
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         WHERE kll.del_flag = 0
           and kllu.unit_type = #{unitType,jdbcType=INTEGER}
-          and kllu.ent_id = #{entId,jdbcType=BIGINT}
+          and kllu.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
     </select>
 
     <select id="selectCarrierIds" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
@@ -209,33 +149,13 @@
         order by kll.generate_time desc
     </select>
     <select id="selectShipperIds" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
             kll.del_flag = 0
-              and kllu.unit_type = 1
+              and kllu.unit_type = 2
               and kll.id in
             <foreach collection="ids" item="id" close=")" open="(" separator=",">
                 #{id,jdbcType=BIGINT}
@@ -244,33 +164,13 @@
         order by kll.generate_time desc
     </select>
     <select id="selectId" resultType="com.sckw.payment.model.dto.LedgerLogisticsDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
             kll.del_flag = 0
-              and kllu.unit_type = 1
+              and kllu.unit_type = #{unitType,jdbcType=INTEGER}
               and kll.id = #{id}
         </where>
     </select>

+ 85 - 145
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -58,83 +58,64 @@
         update_time,
         del_flag
     </sql>
-
-    <select id="pageSelect" resultType="com.sckw.payment.model.dto.LedgerTradeDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
-        from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
-        <where>
-            klt.del_flag = 0
-              and kltu.unit_type = 1
-            <if test="tradeReq.status != null">
-                and klt.status = #{tradeReq.status}
-            </if>
-            <if test="tradeReq.trading != null">
-                and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
-            </if>
-            <if test="tradeReq.startCreateTime != null and tradeReq.endCreateTime != null">
-                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP} and
-                    #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
-            </if>
-            <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
-                and (
-                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                    )
-            </if>
-        </where>
-        order by klt.generate_time desc
-    </select>
+    <sql id="sell_col">
+         klt.id,
+        klt.t_ledger_no   tLedgerNo,
+        klt.name,
+        klt.start_time    startTime,
+        klt.end_time      endTime,
+        klt.tax_rate      taxRate,
+        klt.trading,
+        klt.total_price   totalPrice,
+        klt.ex_tax_price  exTaxPrice,
+        klt.settle_price  settlePrice,
+        klt.actual_price  actualPrice,
+        klt.audit_phone   auditPhone,
+        klt.audit_user    auditUser,
+        klt.url,
+        klt.generate_time generateTime,
+        klt.receipt_time  receiptTime,
+        klt.remark,
+        klt.status,
+        kltu.contacts,
+        kltu.phone,
+        kltu.firm_name    firmName,
+        klt.order_count   orderCount
+    </sql>
+    <sql id="purchase_col">
+        klt.id,
+        klt.t_ledger_no   tLedgerNo,
+        klt.name,
+        klt.start_time    startTime,
+        klt.end_time      endTime,
+        klt.tax_rate      taxRate,
+        klt.trading,
+        klt.total_price   totalPrice,
+        klt.ex_tax_price  exTaxPrice,
+        klt.settle_price  settlePrice,
+        klt.actual_price  actualPrice,
+        klt.audit_phone   auditPhone,
+        klt.audit_user    auditUser,
+        klt.url,
+        klt.generate_time generateTime,
+        klt.receipt_time  receiptTime,
+        klt.remark,
+        klt.status,
+        kltu.contacts,
+        kltu.phone,
+        kltu.firm_name    firmName,
+        klt.order_count   orderCount
+    </sql>
     <select id="sellList" resultType="com.sckw.payment.model.dto.LedgerSellDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
+        select
+        <include refid="sell_col"/>
         from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu
+        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             klt.del_flag = 0
-              and kltu.unit_type = 2
+            and kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+            and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
@@ -142,63 +123,57 @@
                 and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
             </if>
             <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
-                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP} and
-                    #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                 and (
-                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
+                    klt.t_ledger_no like concat('%'
+                  , #{tradeReq.keywords,jdbcType=VARCHAR}
+                  , '%')
+                 or kltu.firm_name like concat('%'
+                  , #{tradeReq.keywords,jdbcType=VARCHAR}
+                  , '%')
+                 or kltu.contacts like concat('%'
+                  , #{tradeReq.keywords,jdbcType=VARCHAR}
+                  , '%')
                     )
             </if>
         </where>
         order by klt.generate_time desc
     </select>
     <select id="purchaseList" resultType="com.sckw.payment.model.dto.LedgerPurchaseDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
+        select
+        <include refid="purchase_col"/>
         from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        inner join kwp_ledger_trade_unit kltu
+        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             klt.del_flag = 0
-              and kltu.unit_type = 1
+            and kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+            and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
             <if test="tradeReq.trading != null">
                 and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
             </if>
-            <if test="tradeReq.startCreateTime != null and tradeReq.endCreateTime != null">
-                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP} and
-                    #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+            <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                 and (
-                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                    )
+                klt.t_ledger_no like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                or kltu.firm_name like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                or kltu.contacts like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                )
             </if>
         </where>
         order by klt.generate_time desc
@@ -218,41 +193,6 @@
           and kltu.ent_id = #{entId,jdbcType=BIGINT}
     </select>
 
-    <select id="selectIds" resultType="com.sckw.payment.model.dto.LedgerTradeDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
-        from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
-        <where>
-            klt.del_flag = 0
-              and kltu.unit_type = 1
-              and klt.id in
-            <foreach collection="ids" item="id" close=")" open="(" separator=",">
-                #{id,jdbcType=BIGINT}
-            </foreach>
-        </where>
-        order by klt.generate_time desc
-    </select>
     <select id="selectSellIds" resultType="com.sckw.payment.model.dto.LedgerSellDto">
         select klt.id,
         klt.t_ledger_no   tLedgerNo,
@@ -350,7 +290,7 @@
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             klt.del_flag = 0
-              and kltu.unit_type = 1
+              and kltu.unit_type = #{unitType,jdbcType=INTEGER}
               and klt.id = #{id,jdbcType=BIGINT}
         </where>
     </select>

+ 138 - 29
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -1,33 +1,142 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.payment.dao.KwpSettlementTradeMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementTrade">
-    <!--@mbg.generated-->
-    <!--@Table kwp_settlement_trade-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="ent_id" jdbcType="BIGINT" property="entId" />
-    <result column="t_ledger_id" jdbcType="BIGINT" property="tLedgerId" />
-    <result column="st_order_no" jdbcType="VARCHAR" property="stOrderNo" />
-    <result column="name" jdbcType="VARCHAR" property="name" />
-    <result column="total_price" jdbcType="DECIMAL" property="totalPrice" />
-    <result column="actual_price" jdbcType="DECIMAL" property="actualPrice" />
-    <result column="receipt_time" jdbcType="TIMESTAMP" property="receiptTime" />
-    <result column="audit_user" jdbcType="VARCHAR" property="auditUser" />
-    <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone" />
-    <result column="success_user" jdbcType="VARCHAR" property="successUser" />
-    <result column="success_phone" jdbcType="VARCHAR" property="successPhone" />
-    <result column="remark" jdbcType="VARCHAR" property="remark" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-    <result column="create_by" jdbcType="BIGINT" property="createBy" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, ent_id, t_ledger_id, st_order_no, `name`, total_price, actual_price, receipt_time, 
-    audit_user, audit_phone, success_user, success_phone, remark, `status`, create_by, 
-    create_time, update_by, update_time, del_flag
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementTrade">
+        <!--@mbg.generated-->
+        <!--@Table kwp_settlement_trade-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="ent_id" jdbcType="BIGINT" property="entId"/>
+        <result column="t_ledger_id" jdbcType="BIGINT" property="tLedgerId"/>
+        <result column="st_order_no" jdbcType="VARCHAR" property="stOrderNo"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
+        <result column="actual_price" jdbcType="DECIMAL" property="actualPrice"/>
+        <result column="receipt_time" jdbcType="TIMESTAMP" property="receiptTime"/>
+        <result column="audit_user" jdbcType="VARCHAR" property="auditUser"/>
+        <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone"/>
+        <result column="success_user" jdbcType="VARCHAR" property="successUser"/>
+        <result column="success_phone" jdbcType="VARCHAR" property="successPhone"/>
+        <result column="remark" jdbcType="VARCHAR" property="remark"/>
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id,
+        ent_id,
+        t_ledger_id,
+        st_order_no,
+        `name`,
+        total_price,
+        actual_price,
+        receipt_time,
+        audit_user,
+        audit_phone,
+        success_user,
+        success_phone,
+        remark,
+        `status`,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        del_flag
+    </sql>
+    <sql id="query">
+        <where>
+            kst.del_flag = 0
+              and kltu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
+            <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
+                and (
+                            klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+            <if test="settlementReq.status != null">
+                and kst.status = #{settlementReq.status,jdbcType=INTEGER}
+            </if>
+            <if test="settlementReq.startCreateTime != null and settlementReq.startCreateTime != '' and settlementReq.endCreateTime != null and settlementReq.endCreateTime != ''">
+                and kst.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="settlementReq.startReceiptTime != null and settlementReq.startReceiptTime != '' and settlementReq.endReceiptTime != null and settlementReq.endReceiptTime != ''">
+                and kst.receipt_time between #{settlementReq.startReceiptTime,jdbcType=TIMESTAMP} and #{settlementReq.endReceiptTime,jdbcType=TIMESTAMP}
+            </if>
+        </where>
+    </sql>
+    <select id="pageSelect" resultType="com.sckw.payment.model.dto.SettlementTradeDto">
+        select kst.id,
+               kst.status,
+               kst.st_order_no,
+               kst.create_time,
+               kst.receipt_time,
+               cast(kst.actual_price as char)                     actualPrice,
+               cast(kst.total_price as char)                      totalPrice,
+               cast((kst.total_price - kst.actual_price) as char) waitPrice,
+               kst.audit_user,
+               kst.audit_phone,
+               kst.success_user,
+               kst.success_phone,
+               kst.create_time,
+               klt.name,
+               klt.trading,
+               kltu.firm_name
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <include refid="query"/>
+        order by kst.create_time desc
+    </select>
+
+    <select id="sumMoney" resultType="com.sckw.payment.model.vo.res.SettlementSumVo">
+        select count(1)                                                allCount,
+               IFNULL(sum(kst.total_price), 0)                         receiveAll,
+               IFNULL(sum(kst.actual_price), 0)                        alreadyReceive,
+               IFNULL(sum(kst.total_price) - sum(kst.actual_price), 0) waitReceive
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <include refid="query"/>
+    </select>
+    <select id="countOrder" resultType="com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo">
+        select count(1)                           allCount,
+               count(if(kst.status = 3, 1, null)) allPaymentCount,
+               count(if(kst.status = 2, 1, null)) partialPaymentCount,
+               count(if(kst.status = 1, 1, null)) waitingPaymentCount
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <include refid="query"/>
+    </select>
+
+    <select id="selectByIds" resultType="com.sckw.payment.model.dto.SettlementTradeDto">
+        select kst.id,
+               kst.status,
+               kst.st_order_no,
+               kst.create_time,
+               kst.receipt_time,
+               cast(kst.actual_price as char)                     actualPrice,
+               cast(kst.total_price as char)                      totalPrice,
+               cast((kst.total_price - kst.actual_price) as char) waitPrice,
+               kst.audit_user,
+               kst.audit_phone,
+               kst.success_user,
+               kst.success_phone,
+               kst.create_time,
+               klt.name,
+               klt.trading,
+               kltu.firm_name
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <where>
+            kst.id in
+            <foreach collection="ids" open="(" close=")" item="item">
+                #{item,jdbcType=BIGINT}
+            </foreach>
+        </where>
+    </select>
 </mapper>

+ 4 - 5
sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwTransportController.java

@@ -164,8 +164,8 @@ public class KwTransportController {
      * @param query
      * @return
      */
-    @RequestMapping(value = "/getWaybillOrders", method = RequestMethod.POST)
-    public HttpResult getWayBillOrders(@Validated @RequestBody WaybillOrderQuery query){
+    @RequestMapping(value = "/getWaybillOrders", method = RequestMethod.GET)
+    public HttpResult getWayBillOrders(WaybillOrderQuery query){
         HttpResult httpResult = new HttpResult();
         try {
             httpResult = transportService.getWaybillOrders(query);
@@ -184,8 +184,8 @@ public class KwTransportController {
      * @author jc
      * @date 2023/07/21
      */
-    @RequestMapping(value = "/getWayBillStatistics", method = RequestMethod.POST)
-    public HttpResult wayBillStatistics(@Validated @RequestBody WaybillOrderQuery query) {
+    @RequestMapping(value = "/getWayBillStatistics", method = RequestMethod.GET)
+    public HttpResult wayBillStatistics(WaybillOrderQuery query) {
         try {
             return transportService.getWayBillStatistics(query);
         } catch (Exception e) {
@@ -231,5 +231,4 @@ public class KwTransportController {
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
-
 }

+ 8 - 1
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java

@@ -238,6 +238,12 @@ public class KwTransportService {
         List<TableTops> results = outputTypeCount.getMappedResults();
         // 填充默认值
         List<TableTops> list = new ArrayList<>();
+        TableTops topTotal = new TableTops();
+        topTotal.setName("全部");
+        topTotal.setValue(null);
+        topTotal.setTotal(0);
+        list.add(topTotal);
+
         TableTops topExpired = new TableTops();
         topExpired.setName("已作废");
         topExpired.setValue(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
@@ -246,7 +252,6 @@ public class KwTransportService {
         expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
         expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
         expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
-
         for (CarWaybillEnum status : CarWaybillEnum.values()) {
             boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
             TableTops top = new TableTops();
@@ -271,6 +276,8 @@ public class KwTransportService {
             }
         }
         list.add(topExpired);
+        // 总计
+        topTotal.setTotal(list.parallelStream().mapToInt(item -> item.getTotal()).sum());
         // 查询结果
         return HttpResult.ok(list);
     }

+ 5 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java

@@ -177,6 +177,11 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
             return Collections.emptyList();
         }
 
+        if (CollectionUtils.isEmpty(sysDictGroupResDto.getChild())) {
+            SysDictResDto sysDictResDto = new SysDictResDto();
+            BeanUtils.copyProperties(sysDictGroupResDto, sysDictResDto);
+            return Collections.singletonList(sysDictResDto);
+        }
         return BeanUtils.copyToList(checkNextLevelDict(sysDictGroupResDto.getChild()), SysDictResDto.class);
     }
 

+ 11 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/WaybillManagementController.java

@@ -8,6 +8,7 @@ import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -48,4 +49,14 @@ public class WaybillManagementController {
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
+
+    @RequestMapping(name = "运单看板TOP", value = "/waybillIndexStatistics", method = RequestMethod.GET)
+    public HttpResult waybillIndexStatistics(WaybillOrderDTO waybillOrderDTO) {
+        try {
+            return waybillManagementService.waybillIndexStatistics(waybillOrderDTO);
+        } catch (Exception e) {
+            log.error("运单看板TOP:订单id {},error {} ", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
 }

+ 59 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WayBillDetailDTO.java

@@ -10,27 +10,80 @@ import lombok.Data;
  **/
 @Data
 public class WayBillDetailDTO {
+    /**
+     * 运单ID
+     */
     private Long wOrderId;
+    /**
+     * 运单号
+     */
     private String wOrderNo;
+    /**
+     * 承运单号
+     */
     private String lOrderNo;
+    /**
+     * 车辆ID
+     */
     private Long truckId;
+    /**
+     * 车牌号
+     */
     private String truckNo;
+    /**
+     * 司机ID
+     */
     private Long driverId;
+    /**
+     * 司机姓名
+     */
     private String driverName;
+    /**
+     * 司机电话
+     */
     private String driverPhone;
+    /**
+     * 司机身份证
+     */
     private String driverIdcard;
+    /**
+     * 运单ID
+     */
     private Long lOrderId;
+    /**
+     * 分配任务量
+     */
     private String entrustAmount;
+    /**
+     * 运单类型
+     */
     private String type;
+    /**
+     * 计划开始时间
+     */
     private String startTime;
+    /**
+     * 计划结束时间
+     */
     private String endTime;
+    /**
+     * 创建人
+     */
     private String createBy;
+    /**
+     * 计费方式
+     */
     private String priceType;
+    /**
+     * 商品名
+     */
     private String goodsName;
-    private String startAddressId;
-    private String endAddressId;
-    private String startLocationName;
-    private String startLocationAddress;
-    private String endLocationName;
-    private String endLocationAddress;
+    /**
+     * 装载地址
+     */
+    private String loadDetailAddress;
+    /**
+     * 卸货地址
+     */
+    private String unloadDetailAddress;
 }

+ 10 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WaybillOrderDTO.java

@@ -58,9 +58,18 @@ public class WaybillOrderDTO extends PageRequest implements Serializable {
     /**
      * 关键字搜索
      */
-    @NotBlank(message = "关键字不能为空")
     private String keywords;
 
+    /**
+     * 装载城市
+     */
+    private String loadCityName;
+
+    /**
+     * 卸载城市
+     */
+    private String unloadCityName;
+
     /**
      * 运单状态
      */

+ 9 - 4
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillDataVO.java

@@ -15,21 +15,26 @@ public class WaybillDataVO {
     /**
      * 基础信息
      */
-    private WayBillDetailDTO transportMessage;
+    private WayBillDetailDTO transport;
 
     /**
      * 车辆人员
      */
-    private WaybillCarVO carMessage;
+    private WaybillCarVO car;
 
     /**
      * 履约协议
      */
-    private WaybillTicketVO agreementMessage;
+    private WaybillTicketVO agreement;
 
     /**
      * 业务日志
      */
-    private List<WaybillTrackVO> logsMessage;
+    private List<WaybillTrackVO> logs;
+
+    /**
+     * 进度数据
+     */
+    private List<WaybillStatusVO> process;
 }
 

+ 257 - 134
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -13,6 +13,7 @@ import com.sckw.excel.utils.DateUtil;
 import com.sckw.fleet.api.RemoteFleetService;
 import com.sckw.fleet.api.model.vo.RTruckVo;
 import com.sckw.mongo.model.SckwWaybillOrder;
+import com.sckw.mongo.model.TableTops;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.dao.KwtWaybillOrderAddressMapper;
@@ -32,9 +33,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.data.mongodb.core.aggregation.AggregationResults;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
 import java.util.*;
 import java.util.regex.Pattern;
@@ -76,107 +80,144 @@ public class WaybillManagementService {
      * @return
      */
     public HttpResult waybillData(@Param("id") Long id) {
-        WayBillDetailDTO kwtWaybillOrder = kwtWaybillOrderMapper.selectWaybillRelate(id);
-        // 收发地址
-        List<KwtWaybillOrderAddress> kwtWaybillOrderAddressList = kwtWaybillOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderAddress>()
-                .eq(KwtWaybillOrderAddress::getWOrderId, kwtWaybillOrder.getLOrderId()));
-        if (CollectionUtils.isNotEmpty(kwtWaybillOrderAddressList)) {
-            for (KwtWaybillOrderAddress kwtWaybillOrderAddress : kwtWaybillOrderAddressList) {
-                // 1装货地址、2卸货地址
-                if (kwtWaybillOrderAddress.getAddressType().equals(NumberConstant.ONE)) {
-                    kwtWaybillOrder.setStartLocationName(kwtWaybillOrderAddress.getName());
-                    kwtWaybillOrder.setStartLocationAddress(kwtWaybillOrderAddress.getDetailAddress());
-                }
-                if (kwtWaybillOrderAddress.getAddressType().equals(NumberConstant.TWO)) {
-                    kwtWaybillOrder.setEndLocationName(kwtWaybillOrderAddress.getName());
-                    kwtWaybillOrder.setEndLocationAddress(kwtWaybillOrderAddress.getDetailAddress());
-                }
+        List<Integer> statuses = initWaybillIndexStatus();
+        // 初始化各状态
+        Map<String, WaybillStatusVO> statusMap = new HashMap<>();
+        statuses.forEach(e -> {
+            WaybillStatusVO waybillStatusVO = new WaybillStatusVO();
+            waybillStatusVO.setStatus(false);
+            waybillStatusVO.setCode(e);
+            switch (e){
+                case 2 -> waybillStatusVO.setDestination("司机接单");
+                case 3 -> waybillStatusVO.setDestination("已出车");
+                case 4 -> waybillStatusVO.setDestination("到装货地");
+                case 5 -> waybillStatusVO.setDestination("已装货");
+                case 6 -> waybillStatusVO.setDestination("到卸货地");
+                case 7 -> waybillStatusVO.setDestination("已卸货");
+                case 8 -> waybillStatusVO.setDestination("已核单");
             }
-        }
-        WaybillDataVO waybillDataVO = new WaybillDataVO();
-        waybillDataVO.setTransportMessage(kwtWaybillOrder);
+            statusMap.put(String.valueOf(e), waybillStatusVO);
+        });
 
-        // 车辆信息
-        List<String> list = new ArrayList<>(NumberConstant.SIXTEEN);
-        list.add(kwtWaybillOrder.getTruckNo());
-        Map<String, RTruckVo> trucks = remoteFleetService.findTruck(list);
-        WaybillCarVO waybillCarVO = new WaybillCarVO();
-        if (CollectionUtils.isNotEmpty(trucks)) {
-            waybillCarVO.setType(trucks.get(0).getTruckType());
-            waybillCarVO.setTruckId(String.valueOf(trucks.get(0).getId()));
-            waybillCarVO.setTrailerNo(trucks.get(0).getTrailerNo());
-        }
-        waybillCarVO.setDriverId(String.valueOf(kwtWaybillOrder.getDriverId()))
-                .setTruckNo(kwtWaybillOrder.getTruckNo())
-                .setDriverName(kwtWaybillOrder.getDriverName())
-                .setDriverPhone(kwtWaybillOrder.getDriverPhone());
-        waybillDataVO.setCarMessage(waybillCarVO);
-        // 履约信息
-        List<KwtWaybillOrderTicket> kwtWaybillOrderTicket = kwtWaybillOrderTicketMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
-                .eq(KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getWOrderId()));
-        WaybillTicketVO waybillTicketVO = new WaybillTicketVO();
-        if (CollectionUtils.isNotEmpty(kwtWaybillOrderTicket)) {
-            for (KwtWaybillOrderTicket ticket : kwtWaybillOrderTicket) {
-                // 装货
-                if (ticket.getType().equals(NumberConstant.ONE)) {
-                    waybillTicketVO.setLoadUrl(ticket.getUrls())
-                            .setLoadWeight(String.valueOf(ticket.getGrossAmount()))
-                            .setLoadTime(String.valueOf(ticket.getCreateTime()));
-                }
-                // 卸货
-                if (ticket.getType().equals(NumberConstant.TWO)) {
-                    waybillTicketVO.setUnloadUrl(ticket.getUrls())
-                            .setUnloadWeight(String.valueOf(ticket.getGrossAmount()))
-                            .setUnloadTime(String.valueOf(ticket.getCreateTime()));
-                }
-            }
-        }
-        waybillDataVO.setAgreementMessage(waybillTicketVO);
-        // 业务日志
-        List<WaybillTrackVO> waybillTrackVOS = new ArrayList<>();
-        List<KwtWaybillOrderTrack> kwtWaybillOrderTracks = kwtWaybillOrderTrackMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderTrack>()
-                .eq(KwtWaybillOrderTrack::getWOrderId, kwtWaybillOrder.getWOrderId()));
-        if (CollectionUtils.isNotEmpty(kwtWaybillOrderTracks)) {
-            List<Long> userIds = new ArrayList<>();
-            for (KwtWaybillOrderTrack track : kwtWaybillOrderTracks) {
-                userIds.add(track.getCreateBy());
-            }
-            List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
-            for (KwtWaybillOrderTrack track : kwtWaybillOrderTracks) {
-                WaybillTrackVO waybillTrackVO = new WaybillTrackVO();
-                waybillTrackVO.setId(String.valueOf(track.getId()))
-                        .setRemark(track.getRemark())
-                        .setStatus(String.valueOf(track.getStatus()))
-                        .setCreateBy(String.valueOf(track.getCreateBy()));
-                for (UserCacheResDto user : users) {
-                    if (Long.valueOf(user.getId()).equals(track.getCreateBy())) {
-                        waybillTrackVO.setCreateByName(user.getName())
-                                .setCreateByPhone(user.getPhone());
-                        break;
-                    }
-                }
-                waybillTrackVOS.add(waybillTrackVO);
-            }
+//        WayBillDetailDTO kwtWaybillOrder = kwtWaybillOrderMapper.selectWaybillRelate(id);
+//        // 收发地址
+//        List<KwtWaybillOrderAddress> kwtWaybillOrderAddressList = kwtWaybillOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderAddress>()
+//                .eq(KwtWaybillOrderAddress::getWOrderId, kwtWaybillOrder.getLOrderId()));
+//        if (CollectionUtils.isNotEmpty(kwtWaybillOrderAddressList)) {
+//            for (KwtWaybillOrderAddress kwtWaybillOrderAddress : kwtWaybillOrderAddressList) {
+//                // 1装货地址、2卸货地址
+//                if (kwtWaybillOrderAddress.getAddressType().equals(NumberConstant.ONE)) {
+//                    kwtWaybillOrder.setStartLocationName(kwtWaybillOrderAddress.getName());
+//                    kwtWaybillOrder.setStartLocationAddress(kwtWaybillOrderAddress.getDetailAddress());
+//                }
+//                if (kwtWaybillOrderAddress.getAddressType().equals(NumberConstant.TWO)) {
+//                    kwtWaybillOrder.setEndLocationName(kwtWaybillOrderAddress.getName());
+//                    kwtWaybillOrder.setEndLocationAddress(kwtWaybillOrderAddress.getDetailAddress());
+//                }
+//            }
+//        }
+//        WaybillDataVO waybillDataVO = new WaybillDataVO();
+//        waybillDataVO.setTransport(kwtWaybillOrder);
+//
+//        // 车辆信息
+//        List<String> list = new ArrayList<>();
+//        list.add(kwtWaybillOrder.getTruckNo());
+////        Map<String, RTruckVo> trucks = remoteFleetService.findTruck(list);
+//        Map<String, RTruckVo> trucks = new HashMap<>();
+//        WaybillCarVO waybillCarVO = new WaybillCarVO();
+//        if (CollectionUtils.isNotEmpty(trucks)) {
+//            waybillCarVO.setType(trucks.get(0).getTruckType());
+//            waybillCarVO.setTruckId(String.valueOf(trucks.get(0).getId()));
+//            waybillCarVO.setTrailerNo(trucks.get(0).getTrailerNo());
+//        }
+//        waybillCarVO.setDriverId(String.valueOf(kwtWaybillOrder.getDriverId()))
+//                .setTruckNo(kwtWaybillOrder.getTruckNo())
+//                .setDriverName(kwtWaybillOrder.getDriverName())
+//                .setDriverPhone(kwtWaybillOrder.getDriverPhone());
+//        waybillDataVO.setCar(waybillCarVO);
+//        // 履约信息
+//        List<KwtWaybillOrderTicket> kwtWaybillOrderTicket = kwtWaybillOrderTicketMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
+//                .eq(KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getWOrderId()));
+//        WaybillTicketVO waybillTicketVO = new WaybillTicketVO();
+//        if (CollectionUtils.isNotEmpty(kwtWaybillOrderTicket)) {
+//            for (KwtWaybillOrderTicket ticket : kwtWaybillOrderTicket) {
+//                // 装货
+//                if (ticket.getType().equals(NumberConstant.ONE)) {
+//                    waybillTicketVO.setLoadUrl(ticket.getUrls())
+//                            .setLoadWeight(String.valueOf(ticket.getGrossAmount()))
+//                            .setLoadTime(String.valueOf(ticket.getCreateTime()));
+//                }
+//                // 卸货
+//                if (ticket.getType().equals(NumberConstant.TWO)) {
+//                    waybillTicketVO.setUnloadUrl(ticket.getUrls())
+//                            .setUnloadWeight(String.valueOf(ticket.getGrossAmount()))
+//                            .setUnloadTime(String.valueOf(ticket.getCreateTime()));
+//                }
+//            }
+//        }
+//        waybillDataVO.setAgreement(waybillTicketVO);
+//        // 业务日志
+//        List<WaybillTrackVO> waybillTrackVOS = new ArrayList<>();
+//        List<KwtWaybillOrderTrack> kwtWaybillOrderTracks = kwtWaybillOrderTrackMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderTrack>()
+//                .eq(KwtWaybillOrderTrack::getWOrderId, kwtWaybillOrder.getWOrderId()));
+//        if (CollectionUtils.isNotEmpty(kwtWaybillOrderTracks)) {
+//            List<Long> userIds = new ArrayList<>();
+//            for (KwtWaybillOrderTrack track : kwtWaybillOrderTracks) {
+//                userIds.add(track.getCreateBy());
+//            }
+//            List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
+//            Map<String, UserCacheResDto> userMap = new HashMap<>();
+//            if(!ObjectUtils.isEmpty(users)) {
+//                users.forEach(e -> userMap.put(String.valueOf(e.getId()), e));
+//            }
+//            for (KwtWaybillOrderTrack track : kwtWaybillOrderTracks) {
+//                WaybillTrackVO waybillTrackVO = new WaybillTrackVO();
+//                if(statusMap.containsKey(String.valueOf(track.getStatus()))) {
+//                    statusMap.get(String.valueOf(track.getStatus()))
+//                            .setCreateTime(DateUtil.getDateTime(track.getCreateTime()))
+//                            .setCreateByName(userMap.get(String.valueOf(track.getCreateBy())).getName())
+//                            .setStatus(true)
+//                            .setId(track.getId());
+//                }
+//                waybillTrackVO.setId(String.valueOf(track.getId()))
+//                        .setRemark(track.getRemark())
+//                        .setStatus(String.valueOf(track.getStatus()))
+//                        .setCreateBy(userMap.get(String.valueOf(track.getCreateBy())).getName());
+//                waybillTrackVOS.add(waybillTrackVO);
+//            }
+//        }
+//        waybillDataVO.setLogs(waybillTrackVOS);
+//        waybillDataVO.setProcess(statusMap.values().stream().toList());
+//        return HttpResult.ok(waybillDataVO);
+
+        WaybillDataVO waybillDataVO = new WaybillDataVO();
+        Criteria criteria = new Criteria();
+        criteria.and("wOrderId").is(id);
+        criteria.and("entId").is(LoginUserHolder.getEntId());
+        criteria.and("delFlag").is(NumberConstant.ZERO);
+        Query queryFormat = new Query(criteria);
+        SckwWaybillOrder info = mongoTemplate.findOne(queryFormat, SckwWaybillOrder.class);
+        WayBillDetailDTO wayBillDetailDTO = new WayBillDetailDTO();
+        if(!ObjectUtils.isEmpty(info)) {
+            wayBillDetailDTO.setDriverId(info.getDriverId());
+            wayBillDetailDTO.setDriverName(info.getDriverName());
+            wayBillDetailDTO.setDriverPhone(info.getDriverPhone());
+            wayBillDetailDTO.setDriverId(info.getDriverId());
         }
-        waybillDataVO.setLogsMessage(waybillTrackVOS);
+        waybillDataVO.setTransport(wayBillDetailDTO);
         return HttpResult.ok(waybillDataVO);
     }
 
     /**
      * 运单看板列表
+     * @param query
      * @return
+     * @throws Exception
      */
-    public HttpResult waybillIndex(WaybillOrderDTO query) {
+    public HttpResult waybillIndex(WaybillOrderDTO query) throws Exception {
         // mongo查询列数据,不足的数据单独关联表查询
         // 状态查询 status [2-8]
-        List<Integer> statuses = new ArrayList<>();
-        statuses.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
-        statuses.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
-        statuses.add(CarWaybillEnum.WAIT_LOADING.getCode());
-        statuses.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
-        statuses.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
-        statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
-        statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode());
+        List<Integer> statuses = initWaybillIndexStatus();
         // 初始化各状态
         List<WaybillStatusVO> statusVOS = new ArrayList<>();
         statuses.forEach(e -> {
@@ -195,51 +236,7 @@ public class WaybillManagementService {
             statusVOS.add(waybillStatusVO);
         });
 
-        Criteria criteria = new Criteria();
-        criteria.and("entId").is(LoginUserHolder.getEntId());
-        criteria.and("delFlag").is(NumberConstant.ZERO);
-
-        List<Long> wOrderIds = StringUtils.splitStrToList(query.getIds(), ",", Long.class);
-        if (CollectionUtils.isNotEmpty(wOrderIds)) {
-            Criteria.where("wOrderId").in(wOrderIds);
-        }
-
-        if (StringUtils.isNotBlank(query.getStatus())) {
-            criteria.and("status").is(query.getStatus());
-        } else {
-            criteria.and("status").in(statuses);
-        }
-        // 装载时间
-        if (StringUtils.isNotBlank(query.getStartLoadTime()) && StringUtils.isNotEmpty(query.getEndLoadTime())) {
-            criteria.andOperator(Criteria.where("loadTime").gte(query.getStartLoadTime()), Criteria.where("loadTime")
-                    .lte(query.getEndLoadTime()));
-        }
-        if (StringUtils.isNotBlank(query.getStartLoadTime()) && StringUtils.isNotEmpty(query.getEndLoadTime())) {
-            criteria.andOperator(Criteria.where("loadTime").gte(query.getStartLoadTime()), Criteria.where("loadTime")
-                    .lte(query.getEndLoadTime()));
-        }
-        // 派车时间
-        if (StringUtils.isNotBlank(query.getStartSendCarTime()) && StringUtils.isNotEmpty(query.getEndSendCarTime())) {
-            criteria.andOperator(Criteria.where("sendCarTime").gte(query.getStartSendCarTime()), Criteria.where("sendCarTime")
-                    .lte(query.getEndSendCarTime()));
-        }
-        // 卸货时间
-        if (StringUtils.isNotBlank(query.getStartUnloadTime()) && StringUtils.isNotEmpty(query.getEndUnloadTime())) {
-            criteria.andOperator(Criteria.where("unloadTime").gte(query.getStartUnloadTime()), Criteria.where("unloadTime")
-                    .lte(query.getEndUnloadTime()));
-        }
-        // 多条件模糊查询
-        List<Criteria> orCriteria = new ArrayList<>();
-        if (StringUtils.isNotBlank(query.getKeywords())) {
-            Pattern pattern = Pattern.compile("^.*" + query.getKeywords() + ".*$", Pattern.CASE_INSENSITIVE);
-            orCriteria.add(Criteria.where("wOrderNo").regex(pattern));
-            orCriteria.add(Criteria.where("truckNo").regex(pattern));
-            orCriteria.add(Criteria.where("driverName").regex(pattern));
-            orCriteria.add(Criteria.where("firmName").regex(pattern));
-            orCriteria.add(Criteria.where("loadAddress").regex(pattern));
-            orCriteria.add(Criteria.where("unloadAddress").regex(pattern));
-            criteria.orOperator(orCriteria);
-        }
+        Criteria criteria = buildWaybillIndexQuery(query, statuses);
         Query queryFormat = new Query(criteria);
         long total = mongoTemplate.count(queryFormat, SckwWaybillOrder.class);
         queryFormat.with(PageRequest.of(query.getPage() - 1, query.getPageSize(),
@@ -300,4 +297,130 @@ public class WaybillManagementService {
         PageResult build = PageResult.build(query.getPage(), query.getPageSize(), total, orders);
         return HttpResult.ok(build);
     }
+
+    /**
+     *
+     * @return
+     */
+    public  List<Integer> initWaybillIndexStatus() {
+        List<Integer> statuses = new ArrayList<>();
+        statuses.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
+        statuses.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
+        statuses.add(CarWaybillEnum.WAIT_LOADING.getCode());
+        statuses.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
+        statuses.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
+        statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
+        statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode());
+        return statuses;
+    }
+
+    /**
+     * 运单看板 查询条件构造
+     * @param query
+     * @param statuses
+     * @return
+     */
+    public Criteria buildWaybillIndexQuery(WaybillOrderDTO query,List<Integer> statuses) {
+        Criteria criteria = new Criteria();
+        criteria.and("entId").is(LoginUserHolder.getEntId());
+        criteria.and("delFlag").is(NumberConstant.ZERO);
+
+        List<Long> wOrderIds = StringUtils.splitStrToList(query.getIds(), ",", Long.class);
+        if (CollectionUtils.isNotEmpty(wOrderIds)) {
+            Criteria.where("wOrderId").in(wOrderIds);
+        }
+
+        if (StringUtils.isNotBlank(query.getStatus())) {
+            criteria.and("status").is(query.getStatus());
+        } else {
+            criteria.and("status").in(statuses);
+        }
+
+        // 装货城市
+        if (StringUtils.isNotBlank(query.getLoadCityName()) && StringUtils.isNotEmpty(query.getLoadCityName())) {
+            criteria.and("loadCityName").is(query.getLoadCityName());
+        }
+        // 卸货城市
+        if (StringUtils.isNotBlank(query.getUnloadCityName()) && StringUtils.isNotEmpty(query.getUnloadCityName())) {
+            criteria.and("unloadCityName").is(query.getUnloadCityName());
+        }
+        // 装载时间
+        if (StringUtils.isNotBlank(query.getStartLoadTime()) && StringUtils.isNotEmpty(query.getEndLoadTime())) {
+            criteria.andOperator(Criteria.where("loadTime").gte(query.getStartLoadTime()), Criteria.where("loadTime")
+                    .lte(query.getEndLoadTime()));
+        }
+        if (StringUtils.isNotBlank(query.getStartLoadTime()) && StringUtils.isNotEmpty(query.getEndLoadTime())) {
+            criteria.andOperator(Criteria.where("loadTime").gte(query.getStartLoadTime()), Criteria.where("loadTime")
+                    .lte(query.getEndLoadTime()));
+        }
+        // 派车时间
+        if (StringUtils.isNotBlank(query.getStartSendCarTime()) && StringUtils.isNotEmpty(query.getEndSendCarTime())) {
+            criteria.andOperator(Criteria.where("sendCarTime").gte(query.getStartSendCarTime()), Criteria.where("sendCarTime")
+                    .lte(query.getEndSendCarTime()));
+        }
+        // 卸货时间
+        if (StringUtils.isNotBlank(query.getStartUnloadTime()) && StringUtils.isNotEmpty(query.getEndUnloadTime())) {
+            criteria.andOperator(Criteria.where("unloadTime").gte(query.getStartUnloadTime()), Criteria.where("unloadTime")
+                    .lte(query.getEndUnloadTime()));
+        }
+        // 多条件模糊查询
+        List<Criteria> orCriteria = new ArrayList<>();
+        if (StringUtils.isNotBlank(query.getKeywords())) {
+            Pattern pattern = Pattern.compile("^.*" + query.getKeywords() + ".*$", Pattern.CASE_INSENSITIVE);
+            orCriteria.add(Criteria.where("wOrderNo").regex(pattern));
+            orCriteria.add(Criteria.where("truckNo").regex(pattern));
+            orCriteria.add(Criteria.where("driverName").regex(pattern));
+            orCriteria.add(Criteria.where("firmName").regex(pattern));
+            orCriteria.add(Criteria.where("loadAddress").regex(pattern));
+            orCriteria.add(Criteria.where("unloadAddress").regex(pattern));
+            criteria.orOperator(orCriteria);
+        }
+        return criteria;
+    }
+
+    /**
+     *  运单看板TOP
+     * @param query
+     * @return
+     */
+    public HttpResult waybillIndexStatistics(WaybillOrderDTO query){
+        List<Integer> statuses = initWaybillIndexStatus();
+        Criteria criteria = buildWaybillIndexQuery(query, statuses);
+        Aggregation aggregation = Aggregation.newAggregation(
+                Aggregation.match(criteria),
+                Aggregation.group("status").count().as("total"),
+                Aggregation.project("total").and("value").previousOperation()
+        );
+        AggregationResults<TableTops> outputTypeCount = mongoTemplate.aggregate(aggregation, SckwWaybillOrder.class, TableTops.class);
+        List<TableTops> results = outputTypeCount.getMappedResults();
+
+        Map<String, TableTops> listMap = new HashMap<>();
+        TableTops topTotal = new TableTops();
+        topTotal.setName("全部");
+        topTotal.setValue("");
+        topTotal.setTotal(0);
+        listMap.put("", topTotal);
+        statuses.forEach(e -> {
+            TableTops top = new TableTops();
+            top.setValue(String.valueOf(e));
+            top.setTotal(0);
+            switch (e){
+                case 2 -> top.setName("司机接单");
+                case 3 -> top.setName("出车");
+                case 4 -> top.setName("到装货地");
+                case 5 -> top.setName("装货");
+                case 6 -> top.setName("到卸货地");
+                case 7 -> top.setName("卸货");
+                case 8 -> top.setName("核单");
+            }
+            listMap.put(String.valueOf(e), top);
+        });
+        if(CollectionUtils.isNotEmpty(results)) {
+            for(TableTops result: results) {
+                listMap.get(result.getValue()).setTotal(result.getTotal());
+            }
+        }
+        listMap.get("").setTotal(listMap.values().parallelStream().mapToInt(e -> e.getTotal()).sum());
+        return HttpResult.ok(listMap.values());
+    }
 }

+ 1 - 1
sckw-modules/sckw-transport/src/main/resources/bootstrap-dev.yml

@@ -14,7 +14,7 @@ spring:
         # 配置文件格式
         file-extension: yaml
         # 命名空间
-        namespace: sckw-service-platform-dev
+        namespace: sckw_jc
         # 共享配置
         group: sckw-service-platform
         #可以读多个配置文件  需要在同一个命名空间下面可以是不同的组

+ 1 - 1
sckw-modules/sckw-transport/src/main/resources/bootstrap.yml

@@ -5,7 +5,7 @@ spring:
   application:
     name: sckw-transport
   profiles:
-    active: @profiles.active@
+    active: ${DEPLOY_MODE:dev}
   main:
     allow-bean-definition-overriding: true
     allow-circular-references: true