Browse Source

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

czh 2 years ago
parent
commit
25d8c615cb
87 changed files with 3592 additions and 243 deletions
  1. 70 4
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java
  2. 31 2
      sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java
  3. 4 4
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java
  4. 2 2
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/SettlementMoney.java
  5. 8 2
      sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/dto/LogisticsOrderDTO.java
  6. 18 0
      sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/vo/LogisticsOrderVO.java
  7. 33 14
      sckw-modules/sckw-file/src/main/java/com/sckw/file/controller/FileApiController.java
  8. 24 2
      sckw-modules/sckw-file/src/main/java/com/sckw/file/service/FileService.java
  9. 1 3
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java
  10. 1 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfFleetController.java
  11. 1 3
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java
  12. 1 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckReportController.java
  13. 2 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfDriverService.java
  14. 19 6
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java
  15. 3 3
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml
  16. 8 0
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfFleetMapper.xml
  17. 4 4
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml
  18. 1 1
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckReportMapper.xml
  19. 38 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwoTradeOrderStatisticsController.java
  20. 11 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwoTradeOrderMapper.java
  21. 55 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/dto/WbTOrderExcelStsReqDTO.java
  22. 37 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/dto/WbTOrderExcelStsResDTO.java
  23. 51 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WbTOrderExcelStsParam.java
  24. 36 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WbTOrderExcelStsResVO.java
  25. 16 1
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java
  26. 107 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderStatisticsService.java
  27. 3 1
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTransportDemandService.java
  28. 4 4
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java
  29. 34 7
      sckw-modules/sckw-order/src/main/resources/mapper/KwoTradeOrderMapper.xml
  30. 37 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WorkbenchController.java
  31. 110 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/LedgerLogisticsController.java
  32. 112 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/LedgerTradeController.java
  33. 104 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/SettlementLogisticsController.java
  34. 179 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/SettlementTradeController.java
  35. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  36. 26 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  37. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  38. 20 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementRecordMapper.java
  39. 4 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  40. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java
  41. 5 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementLogistics.java
  42. 93 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementRecord.java
  43. 5 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementTrade.java
  44. 10 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/WalletOverview.java
  45. 134 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerLogistics.java
  46. 129 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerSell.java
  47. 42 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java
  48. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletDetail.java
  49. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  50. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  51. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
  52. 26 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementRecordService.java
  53. 3 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  54. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java
  55. 23 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java
  56. 11 11
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  57. 203 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/operate/LedgerLogisticsService.java
  58. 282 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/operate/LedgerTradeService.java
  59. 68 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/FinanceTask.java
  60. 122 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  61. 71 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  62. 28 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml
  63. 52 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml
  64. 27 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml
  65. 33 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/controller/KwpGoodsStatisticsController.java
  66. 76 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/WorkbenchGoodsRes.java
  67. 17 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java
  68. 74 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsStatisticsService.java
  69. 13 5
      sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwOrderStatisticsController.java
  70. 2 2
      sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/WbTOrderDataStsParam.java
  71. 68 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/WorkbenchPurchaseVO.java
  72. 5 1
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java
  73. 63 31
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderStatisticsService.java
  74. 5 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/vo/OrderListRes.java
  75. 20 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java
  76. 18 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/operationManagement/ManagementLogisticsOrderController.java
  77. 5 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java
  78. 30 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderQuery.java
  79. 30 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderStatisticsParam.java
  80. 26 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsOrderStatisticsVO.java
  81. 38 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsByOrderVO.java
  82. 44 29
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  83. 104 24
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  84. 121 27
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementLogisticsOrderService.java
  85. 67 4
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java
  86. 61 17
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportDubboServiceImpl.java
  87. 93 12
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

+ 70 - 4
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java

@@ -1,11 +1,13 @@
 package com.sckw.core.utils;
 
 import cn.hutool.core.date.DateUtil;
+import com.sckw.core.exception.BusinessException;
 
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.*;
+import java.time.format.DateTimeFormatter;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Objects;
@@ -607,7 +609,7 @@ public class DateUtils extends DateUtil {
     }
 
     /**
-     * @desc: 获取指定时间的周/月开始时间
+     * @desc: 获取指定时间的1日/2周/3/4年开始时间
      * @author: yzc
      * @date: 2023-09-12 10:20
      * @Param dateType:
@@ -617,15 +619,19 @@ public class DateUtils extends DateUtil {
     public static Date getStartTime(Integer dateType, LocalDateTime time) {
         LocalDateTime startTime;
         if (Objects.equals(dateType, 1)) {
+            startTime = LocalDateTime.of(time.toLocalDate(), LocalTime.MIN);
+        } else if (Objects.equals(dateType, 2)) {
             startTime = LocalDateTime.of(time.toLocalDate().minusDays(6), LocalTime.MIN);
-        } else {
+        } else if (Objects.equals(dateType, 3)) {
             startTime = LocalDateTime.of(time.toLocalDate().minusMonths(1).plusDays(1), LocalTime.MIN);
+        } else {
+            startTime = LocalDateTime.of(time.toLocalDate().minusYears(1).plusDays(1), LocalTime.MIN);
         }
         return formatDate(startTime);
     }
 
     /**
-     * @desc: 获取上周/月结束时间
+     * @desc: 获取上1日/2周/3/4年结束时间
      * @author: yzc
      * @date: 2023-09-12 10:21
      * @Param dateType:
@@ -634,13 +640,49 @@ public class DateUtils extends DateUtil {
     public static Date getLastEndTime(Integer dateType) {
         LocalDateTime endTime;
         if (Objects.equals(dateType, 1)) {
+            endTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MAX);
+        } else if (Objects.equals(dateType, 2)) {
             endTime = LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MAX);
-        } else {
+        } else if (Objects.equals(dateType, 3)) {
             endTime = LocalDateTime.of(LocalDate.now().minusMonths(1), LocalTime.MAX);
+        } else {
+            endTime = LocalDateTime.of(LocalDate.now().minusYears(1), LocalTime.MAX);
         }
         return formatDate(endTime);
     }
 
+    /**
+     * @desc: 获取当前时间倒推一年开始时间
+     * @author: yzc
+     * @date: 2023-09-13 10:29
+     * @return: java.util.Date
+     */
+    public static Date getYearStartTime() {
+        //当前时间减去11个月
+        LocalDate localDate = LocalDate.now().minusMonths(11);
+        //获取localDate当月第一天
+        LocalDate date = LocalDate.of(localDate.getYear(), localDate.getMonth(), 1);
+        return formatDate(date.atStartOfDay());
+    }
+
+    /**
+     * @desc: 获取日期转换格式
+     * @author: yzc
+     * @date: 2023-09-13 9:32
+     * @Param dateType:  1日/3月/4年
+     * @return: java.lang.String
+     */
+    public static String getDateFormat(Integer dateType) {
+        String dateFormat;
+        switch (dateType) {
+            case 1 -> dateFormat = "%Y-%m-%d";
+            case 3 -> dateFormat = "%Y-%m";
+            case 4 -> dateFormat = "%Y";
+            default -> throw new BusinessException("Invalid dateType");
+        }
+        return dateFormat;
+    }
+
     /**
      * @desc: LocalDateTime转换为Date
      * @author: yzc
@@ -651,4 +693,28 @@ public class DateUtils extends DateUtil {
     public static Date formatDate(LocalDateTime time) {
         return Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
     }
+
+    /**
+     * @desc: date转换为LocalDate
+     * @author: yzc
+     * @date: 2023-09-13 15:14
+     * @Param date:
+     * @return: java.time.LocalDate
+     */
+    public static LocalDate dateToLocalDate(Date date) {
+        return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+    }
+
+    /**
+     * @desc: localDate转换为String
+     * @author: yzc
+     * @date: 2023-09-13 15:21
+     * @Param date:
+     * @Param pattern:
+     * @return: java.lang.String
+     */
+    public static String localDateToString(LocalDate date, String pattern) {
+        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern);
+        return date.format(fmt);
+    }
 }

+ 31 - 2
sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java

@@ -584,7 +584,7 @@ public class DateUtil {
         //开始时间
         String lastMonthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 2, -1);
         //结束时间
-        String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(),1, 0);
+        String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(), 1, 0);
 
     }
 
@@ -781,7 +781,7 @@ public class DateUtil {
      *
      * @return 2023-09-12 00:00:00
      */
-    public static String getLastWeekDateStartToString(LocalDate localDate,long amount) {
+    public static String getLastWeekDateStartToString(LocalDate localDate, long amount) {
 //        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
 //        Calendar c = Calendar.getInstance();
 //        c.add(Calendar.DAY_OF_MONTH, -6);
@@ -1074,4 +1074,33 @@ public class DateUtil {
         return start;
     }
 
+    /**
+     * 当天时间(含当天)往前推日期
+     * amount 传递29时,即固定往前推送30天
+     *
+     * @param dateTime 2023-07-17
+     * @return 2023-06-18
+     * @throws ParseException
+     */
+    public static String getThirtyDaysDate(String dateTime, int amount) throws ParseException {
+        //获取当前日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        //Date today = new Date();
+        Date parse = sdf.parse(dateTime);
+        //当前日期
+        String endDate = sdf.format(parse);
+        //获取三十天前日期
+        Calendar theCa = Calendar.getInstance();
+        theCa.setTime(parse);
+        //最后一个数字30可改,30天的意思
+        theCa.add(Calendar.DATE, -amount);
+        Date start = theCa.getTime();
+        //三十天之前日期
+        String startDate = sdf.format(start);
+        System.out.println(endDate);
+        System.out.println(startDate);
+        return startDate;
+    }
+
+
 }

+ 4 - 4
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java

@@ -41,7 +41,7 @@ public interface PaymentDubboService {
     /**
      * 销售统计,以当前日向前推一月、一周
      *
-     * @param countType 1-周 2-月
+     * @param countType 1-日 2-周 3-月
      * @return
      */
     SettlementMoney countSell(Long entId, Integer countType);
@@ -49,7 +49,7 @@ public interface PaymentDubboService {
     /**
      * 采购统计,以当前日向前推一月、一周
      *
-     * @param countType 1-周 2-月
+     * @param countType 1-日 2-周 3-月
      * @return
      */
     SettlementMoney countPurchase(Long entId, Integer countType);
@@ -57,7 +57,7 @@ public interface PaymentDubboService {
     /**
      * 承运统计,以当前日向前推一月、一周
      *
-     * @param countType 1-周 2-月
+     * @param countType 1-日 2-周 3-月
      * @return
      */
     SettlementMoney countCarrier(Long entId, Integer countType);
@@ -65,7 +65,7 @@ public interface PaymentDubboService {
     /**
      * 托运统计,以当前日向前推一月、一周
      *
-     * @param countType 1-周 2-月
+     * @param countType 1-日 2-周 3-月
      * @return
      */
     SettlementMoney countShipper(Long entId, Integer countType);

+ 2 - 2
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/SettlementMoney.java

@@ -16,11 +16,11 @@ public class SettlementMoney implements Serializable {
     @Serial
     private static final long serialVersionUID = 339614434734438926L;
     /**
-     * 销售对账单数量
+     * 当月/周 金额
      */
     private String current;
     /**
-     * 采购对账单数量
+     * 上月/周 金额
      */
     private String before;
     /**

+ 8 - 2
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/dto/LogisticsOrderDTO.java

@@ -294,11 +294,17 @@ public class LogisticsOrderDTO implements Serializable {
      * 发货单位
      */
     @JsonProperty("forwardingUnit")
-   private  String forwardingUnit;
+    private String forwardingUnit;
 
     /**
      * 收货单位
      */
     @JsonProperty("consignee")
-   private  String consignee;
+    private String consignee;
+
+    @JsonProperty("totalLoadAmount")
+    private BigDecimal totalLoadAmount;
+
+    @JsonProperty("totalUnloadAmount")
+    private BigDecimal totalUnloadAmount;
 }

+ 18 - 0
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/vo/LogisticsOrderVO.java

@@ -296,4 +296,22 @@ public class LogisticsOrderVO implements Serializable {
      */
     @JsonProperty("taxMoney")
     private BigDecimal taxMoney;
+
+    /**
+     * 发货单位
+     */
+    @JsonProperty("forwardingUnit")
+    private String forwardingUnit;
+
+    /**
+     * 收货单位
+     */
+    @JsonProperty("consignee")
+    private String consignee;
+
+    @JsonProperty("totalLoadAmount")
+    private BigDecimal totalLoadAmount;
+
+    @JsonProperty("totalUnloadAmount")
+    private BigDecimal totalUnloadAmount;
 }

+ 33 - 14
sckw-modules/sckw-file/src/main/java/com/sckw/file/controller/FileApiController.java

@@ -4,6 +4,7 @@ import com.sckw.core.model.file.FileInfo;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.Result;
+import com.sckw.core.web.response.Status;
 import com.sckw.file.api.dto.FileInfoDTO;
 import com.sckw.file.service.FileService;
 import com.sckw.file.service.dubbo.FileDubboApiServiceImpl;
@@ -27,7 +28,6 @@ import java.util.Map;
  * @version 1.0
  * @className FileApiController
  * @description alibaba-oss测试用例
- *
  * @company sckw
  * @date 2023-06-02 16:06:43
  */
@@ -55,14 +55,15 @@ public class FileApiController {
             //获取上传文件
             return fileService.uploadFile(file);
         } catch (Exception e) {
-            log.error("文件上传失败:{}",e.getMessage(),e);
-            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE,e.getMessage());
+            log.error("文件上传失败:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
 
     }
 
     /**
      * 批量上传文件至OSS
+     *
      * @param file
      * @return
      */
@@ -75,29 +76,31 @@ public class FileApiController {
 
     /**
      * OSS下载文件/获取文件地址
+     *
      * @return
      */
-    @RequestMapping(value = "/fileDownload",method = RequestMethod.GET)
+    @RequestMapping(value = "/fileDownload", method = RequestMethod.GET)
     public HttpResult fileDownload(@NotBlank @RequestParam("fileName") String fileName) {
         try {
             fileService.fileDownload(fileName);
             return HttpResult.ok();
         } catch (Exception e) {
-            log.error("文件下载失败:{}",e.getMessage(),e);
-            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE,e.getMessage());
+            log.error("文件下载失败:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
 
     /**
      * oss删除文件
-     * @param fileName  https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230621/07ccbec381a011d121a215719199ac49.html
+     *
+     * @param fileName https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230621/07ccbec381a011d121a215719199ac49.html
      * @return
      */
-    @RequestMapping(value = "/remove",method = RequestMethod.GET)
+    @RequestMapping(value = "/remove", method = RequestMethod.GET)
     public HttpResult remove(String fileName) {
         //获取上传文件
         fileService.remove(fileName);
-        return HttpResult.ok(HttpStatus.SUCCESS_CODE,HttpStatus.SUCCESS_MESSAGE);
+        return HttpResult.ok(HttpStatus.SUCCESS_CODE, HttpStatus.SUCCESS_MESSAGE);
     }
 
     /***
@@ -110,32 +113,45 @@ public class FileApiController {
     @RequestMapping("downAllOssFile")
     @ResponseBody
     public HttpResult downAllOssFile(@RequestParam("fileAllName") String fileAllName, HttpServletRequest request, HttpServletResponse response) {
-        return fileService.downAllOssFile(fileAllName,request,response);
+        return fileService.downAllOssFile(fileAllName, request, response);
     }
 
     /**
      * 前端调用接口获取oss信息-使用中
+     *
      * @param file
      * @return
      */
     @RequestMapping(value = "/uploadFileInfo", method = RequestMethod.POST)
     public HttpResult uploadFileInfo(@RequestParam("file") MultipartFile file) {
-        return fileService.uploadFileInfo(file);
+        try {
+            return fileService.uploadFileInfo(file);
+        } catch (Exception e) {
+            log.info("上传文件失败:{}",e.getMessage(),e);
+            return HttpResult.error("上传文件失败:" + e.getMessage());
+        }
     }
 
 
     /**
      * app-前端调用接口上传oss
+     *
      * @param file
      * @return
      */
     @RequestMapping(value = "/appUploadFileInfo", method = RequestMethod.POST)
     public Result appUploadFileInfo(@RequestParam("file") MultipartFile file) {
-        return fileService.appUploadFileInfo(file);
+        try {
+            return fileService.appUploadFileInfo(file);
+        } catch (Exception e) {
+            log.info("上传文件失败:{}",e.getMessage(),e);
+            return Result.build(Status.FAILURE,"上传文件失败:" + e.getMessage());
+        }
     }
 
     /**
      * dubbo接收文件信息保存至数据库
+     *
      * @param fileInfo
      * @return
      */
@@ -151,13 +167,14 @@ public class FileApiController {
 
     /**
      * dubbo接收上传文件至OSS
+     *
      * @param inputStream
      * @param FileInfoDTO
      * @return
      */
     @RequestMapping(value = "/fileDubboUpload", method = RequestMethod.POST)
     public HttpResult fileDubboUpload(InputStream inputStream, FileInfoDTO FileInfoDTO) {
-        return fileService.fileDubboUpload(inputStream,FileInfoDTO);
+        return fileService.fileDubboUpload(inputStream, FileInfoDTO);
     }
 
     /**
@@ -173,6 +190,7 @@ public class FileApiController {
 
     /**
      * file-feign-demo
+     *
      * @param userName
      * @return
      */
@@ -184,10 +202,11 @@ public class FileApiController {
 
     /**
      * file-feign-demo1
+     *
      * @param map
      * @return
      */
-    @RequestMapping(value = "fileFeignDemo1",method = RequestMethod.POST)
+    @RequestMapping(value = "fileFeignDemo1", method = RequestMethod.POST)
     public HttpResult fileFeignDemo1(@RequestBody Map<String, String> map) {
         return HttpResult.ok(map);
     }

+ 24 - 2
sckw-modules/sckw-file/src/main/java/com/sckw/file/service/FileService.java

@@ -36,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.*;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
+import java.text.ParseException;
 import java.util.*;
 import java.util.zip.Adler32;
 import java.util.zip.CheckedOutputStream;
@@ -249,7 +250,7 @@ public class FileService {
         return null;
     }
 
-    public HttpResult uploadFileInfo(MultipartFile file) {
+    public HttpResult uploadFileInfo(MultipartFile file) throws ParseException {
         boolean flag = checkFileFormat(file);
         if (!flag) {
             throw new RuntimeException("上传文件格式错误!");
@@ -259,11 +260,31 @@ public class FileService {
         FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
         FileInfoVO fileInfoVO = new FileInfoVO();
         BeanUtils.copyProperties(returnFileInfo, fileInfoVO);
+        insertFile(returnFileInfo);
         return HttpResult.ok(fileInfoVO);
     }
 
+    private void insertFile(FileInfo fileInfo) throws ParseException {
+        kwfFileInfo kwfFileInfo = new kwfFileInfo();
+        kwfFileInfo.setOriginalName(fileInfo.getFileOriginalName());
+        kwfFileInfo.setFileSuffix(FilenameUtils.getExtension(fileInfo.getFileOriginalName()));
+        kwfFileInfo.setFileSize(StringUtils.isBlank(fileInfo.getFileSize()) ? new BigDecimal(NumberConstant.ZERO) : fileInfo.getFileSize());
+        kwfFileInfo.setId(new IdWorker(1).nextId());
+        kwfFileInfo.setType(fileInfo.getType());
+        kwfFileInfo.setFileName(fileInfo.getFileName());
+        kwfFileInfo.setMd5(fileInfo.getFileMd5());
+        kwfFileInfo.setFilePath(fileInfo.getFilePath());
+        kwfFileInfo.setCreateTime(new Date());
+        kwfFileInfo.setUpdateTime(new Date());
+        kwfFileInfo.setStatus(0);
+        kwfFileInfo.setDelFlag(0);
+        kwfFileInfo.setCreateBy(LoginUserHolder.getUserId());
+        kwfFileInfo.setUpdateBy(LoginUserHolder.getUserId());
+        fileInfoDao.insert(kwfFileInfo);
+    }
+
 
-    public Result appUploadFileInfo(MultipartFile file) {
+    public Result appUploadFileInfo(MultipartFile file) throws ParseException {
         boolean flag = checkFileFormat(file);
         if (!flag) {
             return Result.build(Status.FAILURE, "上传文件格式错误!");
@@ -273,6 +294,7 @@ public class FileService {
         FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
         FileInfoVO fileInfoVO = new FileInfoVO();
         BeanUtils.copyProperties(returnFileInfo, fileInfoVO);
+        insertFile(returnFileInfo);
         return Result.build(Status.SUCCESS, fileInfoVO);
     }
 

+ 1 - 3
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.utils.StringUtils;
@@ -87,7 +88,6 @@ public class KwfDriverController {
      **/
     @PostMapping("/statistics")
     public HttpResult statistics(@RequestBody Map<String, Object> params) throws SystemException {
-        params.put("entId", LoginUserHolder.getEntId());
         Map countMaps = driverService.statistics(params);
         return HttpResult.ok(countMaps);
     }
@@ -100,7 +100,6 @@ public class KwfDriverController {
      **/
     @PostMapping("/select")
     public HttpResult findPage(@RequestBody Map<String, Object> params) throws SystemException {
-        params.put("entId", LoginUserHolder.getEntId());
         // 设置分页参数
         PageHelper.startPage(PageResult.getPage(params), PageResult.getPageSize(params));
         List<KwfDriverVo> list = driverService.findPage(params);
@@ -128,7 +127,6 @@ public class KwfDriverController {
      **/
     @PostMapping("/export")
     public void export(@RequestBody Map<String, Object> params) {
-        params.put("entId", LoginUserHolder.getEntId());
         /**分页数据**/
         List<KwfDriverVo> drivers = driverService.findPage(params);
 

+ 1 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfFleetController.java

@@ -3,6 +3,7 @@ package com.sckw.fleet.controller;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.context.LoginUserHolder;

+ 1 - 3
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.utils.CollectionUtils;
@@ -98,7 +99,6 @@ public class KwfTruckController {
      **/
     @PostMapping("/statistics")
     public HttpResult statistics(@RequestBody Map<String, Object> params) throws SystemException {
-        params.put("entId", LoginUserHolder.getEntId());
         Map countMaps = truckService.statistics(params);
         return HttpResult.ok(countMaps);
     }
@@ -111,7 +111,6 @@ public class KwfTruckController {
      **/
     @PostMapping("/select")
     public HttpResult findPage(@RequestBody Map<String, Object> params) throws SystemException {
-        params.put("entId", LoginUserHolder.getEntId());
         // 设置分页参数
         PageHelper.startPage(PageResult.getPage(params), PageResult.getPageSize(params));
         List<KwfTruckVo> list = truckService.findPage(params);
@@ -139,7 +138,6 @@ public class KwfTruckController {
      **/
     @PostMapping("/export")
     public HttpResult export(@RequestBody Map<String, Object> params) {
-        params.put("entId", LoginUserHolder.getEntId());
         /**查询数据**/
         List<KwfTruckVo> trucks = truckService.findPage(params);
 

+ 1 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckReportController.java

@@ -3,6 +3,7 @@ package com.sckw.fleet.controller;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.context.LoginUserHolder;

+ 2 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfDriverService.java

@@ -197,6 +197,7 @@ public class KwfDriverService {
             List<KwfTableTopCount> counts = driverDao.statisticsAll(params);
             return counts;
         } else {
+            params.put("entId", LoginUserHolder.getEntId());
             List<KwfTableTopCount> counts = driverDao.statistics(params);
             return counts;
         }
@@ -258,6 +259,7 @@ public class KwfDriverService {
             List<KwfDriverVo> drivers = driverDao.findPageAll(params);
             return drivers;
         } else {
+            params.put("entId", LoginUserHolder.getEntId());
             List<KwfDriverVo> drivers = driverDao.findPage(params);
             return drivers;
         }

+ 19 - 6
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -31,6 +31,7 @@ import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.api.dubbo.TransportDubboService;
 import com.sckw.transport.api.model.dto.RWaybillOrderDto;
 import com.sckw.transport.api.model.vo.RWaybillOrderVo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -47,6 +48,7 @@ import java.util.stream.Collectors;
  * @desc 车辆
  * @date 2023/7/6 0006
  */
+@Slf4j
 @Service
 @SuppressWarnings("all")
 @Transactional(rollbackFor = Exception.class)
@@ -126,7 +128,7 @@ public class KwfTruckService {
      **/
     public Map statistics(Map<String, Object> params) {
         /**统计数据**/
-        List<KwfTableTopCount> counts = truckDao.statistics(params);
+        List<KwfTableTopCount> counts = statisticsHandle(params);
         long tatol = 0;
         for (KwfTableTopCount topCount:counts) {
             tatol += topCount.getTotal();
@@ -174,6 +176,7 @@ public class KwfTruckService {
             List<KwfTableTopCount> counts = truckDao.statisticsAll(params);
             return counts;
         } else {
+            params.put("entId", LoginUserHolder.getEntId());
             List<KwfTableTopCount> counts = truckDao.statistics(params);
             return counts;
         }
@@ -187,7 +190,7 @@ public class KwfTruckService {
      **/
     public List<KwfTruckVo> findPage(Map<String, Object> params) {
         /**查询分页数据**/
-        List<KwfTruckVo> trucks = truckDao.findPage(params);
+        List<KwfTruckVo> trucks = findPageHandle(params);
         if (CollectionUtils.isEmpty(trucks)) {
             return trucks;
         }
@@ -246,6 +249,7 @@ public class KwfTruckService {
             List<KwfTruckVo> counts = truckDao.findPageAll(params);
             return counts;
         } else {
+            params.put("entId", LoginUserHolder.getEntId());
             List<KwfTruckVo> counts = truckDao.findPage(params);
             return counts;
         }
@@ -636,6 +640,7 @@ public class KwfTruckService {
      * @date 2023/9/5
      **/
     public List<KwfTruckMonitorVo> findTruck(Map params){
+        long begTime = System.currentTimeMillis();
         /**车辆查询**/
         Map queryParams = new HashMap<>(Global.NUMERICAL_SIXTEEN){{ put("truckNo", params.get("truckNo"));}};
         List<KwfTruckMonitorVo> truckList = findTruckMonitor(queryParams);
@@ -650,12 +655,15 @@ public class KwfTruckService {
             entIds.add(truck.getEntId());
             truckNos.add(truck.getTruckNo());
         }
-
+        long begTime1 = System.currentTimeMillis();
+        log.info("获取数据="+(begTime1 - begTime));
         //企业数据集
         entIds = entIds.stream().distinct().collect(Collectors.toList());
         Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
         //车辆定位数据集
         Map<String, KwfTruckGpsVo> truckGpsMap = findTruckLocateHandle(truckNos);
+        long begTime2 = System.currentTimeMillis();
+        log.info("获取GPS="+(begTime2 - begTime1));
 
         /**数据组装**/
         for (KwfTruckMonitorVo truck:truckList) {
@@ -664,7 +672,8 @@ public class KwfTruckService {
             truck.setFirmName(ent != null ? ent.getFirmName() : null);
             truck.setRunStatus(truckGps != null ? truckGps.getRunStatus() : null);
         }
-
+        long begTime3 = System.currentTimeMillis();
+        log.info("数据组装="+(begTime3 - begTime2));
         return truckList;
     }
 
@@ -903,7 +912,7 @@ public class KwfTruckService {
      **/
     public Map<String, KwfTruckGpsVo> findTruckLocateHandle(List<String> truckNos){
         /**车牌号超过100则分批次请求数据**/
-        int maxLimit = 100;
+        int maxLimit = 500;
         List<List<String>> truckNoList = new ArrayList<List<String>>();
         List<String> findTruckSon = null;
         for (int i = 0; i < truckNos.size(); i++) {
@@ -962,7 +971,11 @@ public class KwfTruckService {
             Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
                 put("vehicleNoList", truckNos);
             }};
+
+            long begTime = System.currentTimeMillis();
             String httpResult = HttpClientUtil.post(queryLocate, JSON.toJSONString(params));
+            System.out.println(httpResult);
+            long entTime = System.currentTimeMillis();
             if (StringUtils.isNotBlank(httpResult)) {
                 JSONObject result = JSONObject.parseObject(httpResult);
                 if (result.getInteger("code") != null && result.getInteger("code") != 200) {
@@ -971,7 +984,7 @@ public class KwfTruckService {
 
                 }
                 JSONArray trucks = result.getJSONArray("data");
-                System.out.println((trucks != null ? trucks.size() : 0) + "==="+ truckNos.size() + "===" + truckNos);
+                log.info("车牌号数量="+ truckNos.size() + " GPS数量=" + (trucks != null ? trucks.size() : 0) + " 响应时间="+(entTime - begTime));
                 for (int i=0; trucks != null && i < trucks.size(); i++) {
                     JSONObject truck = trucks.getJSONObject(i);
                     JSONObject locateInfo = truck.getJSONObject("locateInfo");

+ 3 - 3
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml

@@ -131,7 +131,7 @@
             and DATE( dr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
         <choose>
-            <when test="ids != null and ids != '' ">
+            <when test="ids != null and ids != '' and ids.size() > 0">
                 and dr.id in
                 <foreach collection="ids" item="id" open="(" close=")" separator=",">
                     #{id,jdbcType=BIGINT}
@@ -200,7 +200,7 @@
             )
         </if>
         <choose>
-            <when test="ids != null and ids != '' ">
+            <when test="ids != null and ids != '' and ids.size() > 0">
                 and dr.id in
                 <foreach collection="ids" item="id" open="(" close=")" separator=",">
                     #{id,jdbcType=BIGINT}
@@ -250,7 +250,7 @@
             )
         </if>
         <choose>
-            <when test="ids != null and ids != '' ">
+            <when test="ids != null and ids != '' and ids.size() > 0">
                 and dr.id in
                 <foreach collection="ids" item="id" open="(" close=")" separator=",">
                     #{id,jdbcType=BIGINT}

+ 8 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfFleetMapper.xml

@@ -29,6 +29,14 @@
         <if test="endTime != null and endTime != '' " >
             and DATE( fl.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
+        <choose>
+            <when test="ids != null and ids != '' and ids.size() > 0">
+                and fl.id in
+                <foreach collection="ids" item="id" open="(" close=")" separator=",">
+                    #{id,jdbcType=BIGINT}
+                </foreach>
+            </when>
+        </choose>
         <if test="keywords != null and keywords != ''">
             and (
                 fl.name like concat('%',#{keywords},'%')

+ 4 - 4
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml

@@ -131,7 +131,7 @@
             and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
         <choose>
-            <when test="ids != null">
+            <when test="ids != null and ids != '' and ids.size() > 0">
                 and tr.id in
                 <foreach collection="ids" item="id" open="(" close=")" separator=",">
                     #{id,jdbcType=BIGINT}
@@ -197,7 +197,7 @@
             and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
         <choose>
-            <when test="ids != null">
+            <when test="ids != null and ids != '' and ids.size() > 0">
                 and tr.id in
                 <foreach collection="ids" item="id" open="(" close=")" separator=",">
                     #{id,jdbcType=BIGINT}
@@ -253,7 +253,7 @@
             and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
         <choose>
-            <when test="truckNos != null and truckNos != ''">
+            <when test="truckNos != null and truckNos != '' and truckNos.size() > 0">
                 and tr.truck_no in
                 <foreach collection="truckNos" item="truckNo" open="(" close=")" separator=",">
                     #{truckNo,jdbcType=VARCHAR}
@@ -320,7 +320,7 @@
         from kwf_truck
         where del_flag = 0
         <choose>
-            <when test="entIds != null and entIds.size() > 0">
+            <when test="truckNos != null and truckNos != '' and truckNos.size() > 0">
                 and ent_id in
                 <foreach collection="entIds" item="item" open="(" close=")" separator=",">
                     #{item,jdbcType=BIGINT}

+ 1 - 1
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckReportMapper.xml

@@ -87,7 +87,7 @@
             and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
         <choose>
-            <when test="ids != null">
+            <when test="ids != null and ids != '' and ids.size() > 0">
                 and trr.id in
                 <foreach collection="ids" item="id" open="(" close=")" separator=",">
                     #{id,jdbcType=BIGINT}

+ 38 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwoTradeOrderStatisticsController.java

@@ -0,0 +1,38 @@
+package com.sckw.order.controller;
+
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.order.model.vo.req.WbTOrderExcelStsParam;
+import com.sckw.order.serivce.KwoTradeOrderStatisticsService;
+import lombok.AllArgsConstructor;
+import org.springframework.http.MediaType;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @desc: 订单统计相关接口
+ * @author: yzc
+ * @date: 2023-09-13 8:34
+ */
+@AllArgsConstructor
+@RestController
+@RequestMapping("/kwoTradeOrderStatistics")
+public class KwoTradeOrderStatisticsController {
+
+    private final KwoTradeOrderStatisticsService kwoTradeOrderStatisticsService;
+
+
+    /**
+     * @desc: 工作台贸易订单表格统计
+     * @author: yzc
+     * @date: 2023-09-12 16:38
+     * @Param params:
+     * @return: com.sckw.core.web.response.HttpResult
+     */
+    @PostMapping(value = "/workbenchExcel", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult workbenchExcel(@RequestBody @Validated WbTOrderExcelStsParam params) {
+        return HttpResult.ok(kwoTradeOrderStatisticsService.workbenchExcel(params));
+    }
+}

+ 11 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwoTradeOrderMapper.java

@@ -3,6 +3,8 @@ package com.sckw.order.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.order.api.model.TradeOrderCountStatisticsDTO;
 import com.sckw.order.model.KwoTradeOrder;
+import com.sckw.order.model.dto.WbTOrderExcelStsReqDTO;
+import com.sckw.order.model.dto.WbTOrderExcelStsResDTO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -34,4 +36,13 @@ public interface KwoTradeOrderMapper extends BaseMapper<KwoTradeOrder> {
      * @return: java.util.List<com.sckw.order.api.model.TradeOrderCountStatisticsDTO>
      */
     List<TradeOrderCountStatisticsDTO> getOrderNumByTopEntId(@Param("topEntId") Long topEntId);
+
+    /**
+     * @desc: 工作台贸易订单表格统计
+     * @author: yzc
+     * @date: 2023-09-13 15:46
+     * @Param item:
+     * @return: java.util.List<com.sckw.order.model.dto.WbTOrderExcelStsResDTO>
+     */
+    List<WbTOrderExcelStsResDTO> workbenchExcel(@Param("item") WbTOrderExcelStsReqDTO item);
 }

+ 55 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/dto/WbTOrderExcelStsReqDTO.java

@@ -0,0 +1,55 @@
+package com.sckw.order.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @desc: 工作台表格统计请求dto
+ * @author: yzc
+ * @date: 2023-09-12 17:32
+ */
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+public class WbTOrderExcelStsReqDTO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 443735882514444569L;
+
+    /**
+     * 分组日期格式函数
+     */
+    private String dateFormat;
+
+    /**
+     * 订单类型(1采购订单、2销售订单)
+     */
+    private String unitType;
+
+    /**
+     * 一级企业id
+     */
+    private Long topEntId;
+
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 统计因子1
+     */
+    private Integer stsFactorsOne;
+
+    /**
+     * 统计因子2
+     */
+    private Integer stsFactorsTwo;
+
+}

+ 37 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/dto/WbTOrderExcelStsResDTO.java

@@ -0,0 +1,37 @@
+package com.sckw.order.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @desc: 工作台表格统计响应dto
+ * @author: yzc
+ * @date: 2023-09-12 17:32
+ */
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+public class WbTOrderExcelStsResDTO implements Serializable {
+    public WbTOrderExcelStsResDTO() {
+        this.stsFactorsOneValue = BigDecimal.ZERO;
+        this.stsFactorsTwoValue = BigDecimal.ZERO;
+    }
+
+
+    @Serial
+    private static final long serialVersionUID = 2911684774740265571L;
+
+    private String formatDate;
+
+    private BigDecimal stsFactorsOneValue;
+
+    private BigDecimal stsFactorsTwoValue;
+
+}

+ 51 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WbTOrderExcelStsParam.java

@@ -0,0 +1,51 @@
+package com.sckw.order.model.vo.req;
+
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.hibernate.validator.constraints.Range;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @desc: 工作台贸易订单数据统计请求参数
+ * @author: yzc
+ * @date: 2023-09-11 14:42
+ */
+@Getter
+@Setter
+@ToString
+public class WbTOrderExcelStsParam implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 4503103839537525731L;
+
+
+    /**
+     * 订单类型(1采购订单、2销售订单)
+     */
+    @Range(min = 1, max = 2, message = "非法订单类型")
+    @NotNull(message = "订单类型不能为空")
+    private Integer orderType;
+    /**
+     * 统计因子1
+     */
+    @Range(min = 1, max = 2, message = "非法统计因子")
+    @NotNull(message = "统计因子不能为空")
+    private Integer stsFactorsOne;
+
+    /**
+     * 统计因子2
+     */
+    @Range(min = 1, max = 2, message = "非法统计因子")
+    @NotNull(message = "统计因子不能为空")
+    private Integer stsFactorsTwo;
+    /**
+     * 统计日期类型(1日、3月)
+     */
+    @Range(min = 1, max = 3, message = "非法日期类型")
+    @NotNull(message = "日期类型不能为空")
+    private Integer dateType;
+
+}

+ 36 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WbTOrderExcelStsResVO.java

@@ -0,0 +1,36 @@
+package com.sckw.order.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @desc: 工作台表格统计响应vo
+ * @author: yzc
+ * @date: 2023-09-13 14:55
+ */
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+public class WbTOrderExcelStsResVO implements Serializable {
+    public WbTOrderExcelStsResVO() {
+        this.stsFactorsOneValue = BigDecimal.ZERO;
+        this.stsFactorsTwoValue = BigDecimal.ZERO;
+    }
+
+    @Serial
+    private static final long serialVersionUID = 5199453430808720945L;
+
+    private String formatDate;
+
+    private BigDecimal stsFactorsOneValue;
+
+    private BigDecimal stsFactorsTwoValue;
+
+}

+ 16 - 1
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -25,6 +25,8 @@ import com.sckw.order.api.model.TradeOrderCountStatisticsDTO;
 import com.sckw.order.dao.KwoTradeOrderMapper;
 import com.sckw.order.model.*;
 import com.sckw.order.model.dto.OrderCheckDTO;
+import com.sckw.order.model.dto.WbTOrderExcelStsReqDTO;
+import com.sckw.order.model.dto.WbTOrderExcelStsResDTO;
 import com.sckw.order.model.vo.req.*;
 import com.sckw.order.model.vo.res.*;
 import com.sckw.payment.api.dubbo.PayCenterDubboService;
@@ -885,7 +887,7 @@ public class KwoTradeOrderService {
         }
         kwoTradeOrderMapper.updateById(order);
         //更新商品价格
-        kwoTradeOrderGoodsService.updateUnitPrice(param.getId(),param.getUnitPrice());
+        kwoTradeOrderGoodsService.updateUnitPrice(param.getId(), param.getUnitPrice());
         //保存合同信息
         KwoTradeOrderContract tradeOrderContract = BeanUtils.copyProperties(contractInfo, KwoTradeOrderContract.class);
         tradeOrderContract.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo());
@@ -1227,4 +1229,17 @@ public class KwoTradeOrderService {
     public List<TradeOrderCountStatisticsDTO> getOrderNumByTopEntId(Long topEntId) {
         return kwoTradeOrderMapper.getOrderNumByTopEntId(topEntId);
     }
+
+    /**
+     * @desc: 工作台贸易订单表格统计
+     * @author: yzc
+     * @date: 2023-09-13 15:46
+     * @Param reqDTO:
+     * @return: java.util.List<com.sckw.order.model.dto.WbTOrderExcelStsResDTO>
+     */
+    public List<WbTOrderExcelStsResDTO> workbenchExcel(WbTOrderExcelStsReqDTO reqDTO) {
+        List<WbTOrderExcelStsResDTO> list = kwoTradeOrderMapper.workbenchExcel(reqDTO);
+        return CollectionUtils.emptyIfNull(list);
+    }
+
 }

+ 107 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderStatisticsService.java

@@ -0,0 +1,107 @@
+package com.sckw.order.serivce;
+
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.utils.DateUtils;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.order.model.dto.WbTOrderExcelStsReqDTO;
+import com.sckw.order.model.dto.WbTOrderExcelStsResDTO;
+import com.sckw.order.model.vo.req.WbTOrderExcelStsParam;
+import com.sckw.order.model.vo.res.WbTOrderExcelStsResVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.temporal.TemporalAdjusters;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @desc: 贸易订单统计service
+ * @author: yzc
+ * @date: 2023-09-13 8:36
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class KwoTradeOrderStatisticsService {
+
+    private final KwoTradeOrderService kwoTradeOrderService;
+
+    /**
+     * @desc: 工作台贸易订单表格统计
+     * @author: yzc
+     * @date: 2023-09-13 15:46
+     * @Param params:
+     * @return: java.util.List<com.sckw.order.model.vo.res.WbTOrderExcelStsResVO>
+     */
+    public List<WbTOrderExcelStsResVO> workbenchExcel(WbTOrderExcelStsParam params) {
+        Integer dateType = params.getDateType();
+        Date startTime;
+        if (Objects.equals(1, dateType)) {
+            startTime = DateUtils.getStartTime(3, LocalDateTime.now());
+        } else if (Objects.equals(3, dateType)) {
+            startTime = DateUtils.getYearStartTime();
+        } else {
+            throw new BusinessException("Invalid date type");
+        }
+        List<WbTOrderExcelStsResVO> res = buildFormatDate(dateType, startTime);
+        WbTOrderExcelStsReqDTO reqDTO = new WbTOrderExcelStsReqDTO();
+        reqDTO.setUnitType(String.valueOf(params.getOrderType()))
+                .setDateFormat(DateUtils.getDateFormat(dateType))
+                .setStartTime(startTime)
+                .setTopEntId(LoginUserHolder.getEntId())
+                .setStsFactorsOne(params.getStsFactorsOne())
+                .setStsFactorsTwo(params.getStsFactorsTwo());
+        Map<String, WbTOrderExcelStsResDTO> map = kwoTradeOrderService.workbenchExcel(reqDTO).stream()
+                .collect(Collectors.toMap(WbTOrderExcelStsResDTO::getFormatDate, e -> e, (k1, k2) -> k1));
+        res.forEach(e->{
+            WbTOrderExcelStsResDTO dto = map.get(e.getFormatDate());
+            if (Objects.nonNull(dto)) {
+                e.setStsFactorsOneValue(dto.getStsFactorsOneValue());
+                e.setStsFactorsTwoValue(dto.getStsFactorsTwoValue());
+            }
+        });
+        return res;
+    }
+
+    /**
+     * @desc: 构建时间转换格式
+     * @author: yzc
+     * @date: 2023-09-13 15:45
+     * @Param dateType:
+     * @Param startTime:
+     * @return: java.util.List<com.sckw.order.model.vo.res.WbTOrderExcelStsResVO>
+     */
+    private List<WbTOrderExcelStsResVO> buildFormatDate(Integer dateType, Date startTime) {
+        LocalDate start = DateUtils.dateToLocalDate(startTime);
+        LocalDate end = LocalDate.now();
+        List<WbTOrderExcelStsResVO> res = new ArrayList<>();
+        if (dateType == 1) {
+            while (start.isBefore(end)) {
+                WbTOrderExcelStsResVO vo = new WbTOrderExcelStsResVO();
+                vo.setFormatDate(start.toString());
+                start = start.plusDays(1);
+                res.add(vo);
+            }
+            WbTOrderExcelStsResVO vo = new WbTOrderExcelStsResVO();
+            vo.setFormatDate(end.toString());
+            res.add(vo);
+        } else {
+            //当月第一天
+            end = end.with(TemporalAdjusters.firstDayOfMonth());
+            while (start.isBefore(end)) {
+                WbTOrderExcelStsResVO vo = new WbTOrderExcelStsResVO();
+                vo.setFormatDate(DateUtils.localDateToString(start, "yyyy-MM"));
+                start = start.plusMonths(1);
+                res.add(vo);
+            }
+            WbTOrderExcelStsResVO vo = new WbTOrderExcelStsResVO();
+            vo.setFormatDate(DateUtils.localDateToString(end, "yyyy-MM"));
+            res.add(vo);
+        }
+        return res;
+    }
+}
+

+ 3 - 1
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTransportDemandService.java

@@ -9,6 +9,7 @@ import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.model.vo.TableBottom;
 import com.sckw.core.model.vo.TableStatisticRes;
@@ -210,8 +211,9 @@ public class KwoTransportDemandService {
      * @return: com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.sckw.order.model.KwoTransportDemand>
      */
     private LambdaQueryWrapper<KwoTransportDemand> buildWrapper(ExportTransportDemandParam param) {
+        Long entId = LoginUserHolder.getSystemType() != SystemTypeEnum.MANAGE.getCode() ? LoginUserHolder.getEntId() : null;
         LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
+        wrapper.eq(KwoTransportDemand::getEntId, entId).eq(KwoTransportDemand::getDelFlag, Global.NO);
         if (StringUtils.isNotBlank(param.getIds())) {
             List<Long> ids = StringUtils.splitStrToList(param.getIds(), ",", Long.class);
             wrapper.in(KwoTransportDemand::getId, ids).orderByDesc(KwoTransportDemand::getCreateTime);

+ 4 - 4
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -8,6 +8,7 @@ import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.model.vo.TableBottom;
 import com.sckw.core.model.vo.TableStatisticRes;
@@ -131,7 +132,6 @@ public class KwpWantBuyService {
      * @Date 11:50 2023/8/1 0001
      **/
     public PageRes<WantBuySelectRes> select(WantBuySelectParam wantBuySelectParam) {
-
         if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
             List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
             wantBuySelectParam.setTradings(longList);
@@ -142,7 +142,7 @@ public class KwpWantBuyService {
             List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
             wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
         }
-        wantBuySelectParam.setEntId(LoginUserHolder.getEntId());
+        wantBuySelectParam.setEntId(LoginUserHolder.getSystemType() != SystemTypeEnum.MANAGE.getCode() ? LoginUserHolder.getEntId() : null);
         PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
         List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.pageSelect(wantBuySelectParam);
         if (CollectionUtils.isEmpty(wantBuyDto)) {
@@ -444,7 +444,7 @@ public class KwpWantBuyService {
             List<String> goodsTypes = goodsTypeHandle(params);
             params.setGoodsTypeValueSearch(goodsTypes);
         }
-        params.setEntId(LoginUserHolder.getEntId());
+        params.setEntId(LoginUserHolder.getSystemType() != SystemTypeEnum.MANAGE.getCode() ? LoginUserHolder.getEntId() : null);
         List<WantBuySelectRes> result = kwpWantBuyMapper.pageSelect(params);
         Map<Integer, List<WantBuySelectRes>> map = result.stream().collect(Collectors.groupingBy(WantBuySelectRes::getStatus));
         List<TableTop> tableTops = new ArrayList<>();
@@ -483,7 +483,7 @@ public class KwpWantBuyService {
                 selectParam.setGoodsTypeValueSearch(goodsTypes);
             }
         }
-        selectParam.setEntId(LoginUserHolder.getEntId());
+        selectParam.setEntId(LoginUserHolder.getSystemType() != SystemTypeEnum.MANAGE.getCode() ? LoginUserHolder.getEntId() : null);
         List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.pageSelect(selectParam);
         if (CollectionUtils.isEmpty(wantBuyDto)) {
             return Collections.emptyList();

+ 34 - 7
sckw-modules/sckw-order/src/main/resources/mapper/KwoTradeOrderMapper.xml

@@ -4,17 +4,44 @@
 
 
     <select id="getMaxOrderNoByDate" resultType="java.lang.String">
-        SELECT MAX(t_order_no) FROM kwo_trade_order WHERE create_time &gt;= #{date};
+        SELECT MAX(t_order_no)
+        FROM kwo_trade_order
+        WHERE create_time &gt;= #{date};
     </select>
 
     <select id="getOrderNumByTopEntId" resultType="com.sckw.order.api.model.TradeOrderCountStatisticsDTO">
-        SELECT
-            u.unit_type AS orderType,
-            COUNT(*) AS num
+        SELECT u.unit_type AS orderType,
+               COUNT(*)    AS num
         FROM kwo_trade_order o
-        LEFT JOIN kwo_trade_order_unit u
-        ON o.id = u.t_order_id
-        WHERE o.del_flag =0 AND o.status != 0 and u.del_flag = 0 AND u.top_ent_id = #{topEntId}
+                 LEFT JOIN kwo_trade_order_unit u
+                           ON o.id = u.t_order_id
+        WHERE o.del_flag = 0
+          AND o.status != 0 and u.del_flag = 0 AND u.top_ent_id = #{topEntId}
         GROUP BY u.unit_type
     </select>
+
+    <select id="workbenchExcel" resultType="com.sckw.order.model.dto.WbTOrderExcelStsResDTO">
+        SELECT DATE_FORMAT(create_time, #{item.dateFormat}) AS formatDate,
+               SUM(CASE
+                       WHEN #{item.stsFactorsOne} = 1 THEN amount
+                       WHEN #{item.stsFactorsOne} = 2 THEN 1
+                       ELSE 0
+                   END)                                     AS stsFactorsOneValue,
+               SUM(CASE
+                       WHEN #{item.stsFactorsTwo} = 1 THEN amount
+                       WHEN #{item.stsFactorsTwo} = 2 THEN 1
+                       ELSE 0
+                   END)                                     AS stsFactorsTwoValue
+        FROM kwo_trade_order
+        WHERE
+          id IN (SELECT t_order_id
+                FROM kwo_trade_order_unit
+                WHERE del_flag = 0
+                AND unit_type = #{item.unitType}
+                AND top_ent_id = #{item.topEntId})
+          AND create_time >= #{item.startTime}
+          AND status NOT IN (0, 2)
+          AND del_flag = 0
+        GROUP BY DATE_FORMAT(create_time, #{item.dateFormat});
+    </select>
 </mapper>

+ 37 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WorkbenchController.java

@@ -0,0 +1,37 @@
+package com.sckw.payment.controller;
+
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.vo.req.FinanceCount;
+import com.sckw.payment.service.WorkbenchService;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 工作台
+ *
+ * @author xucaiqin
+ * @date 2023-08-28 15:36:48
+ */
+@Validated
+@RestController
+@RequestMapping("/workbench")
+@Slf4j
+public class WorkbenchController {
+    @Resource
+    private WorkbenchService workbenchService;
+
+    /**
+     * 财务数据
+     *
+     * @return
+     */
+    @GetMapping("finance")
+    public HttpResult finance(FinanceCount financeCount) {
+        return HttpResult.ok(workbenchService.financeCount(financeCount));
+    }
+
+}

+ 110 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/LedgerLogisticsController.java

@@ -0,0 +1,110 @@
+package com.sckw.payment.controller.operate;
+
+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.vo.LedgerLogistics;
+import com.sckw.payment.model.vo.req.LedgerListReq;
+import com.sckw.payment.model.vo.req.LogisticsReq;
+import com.sckw.payment.model.vo.res.LedgerLogisticsVo;
+import com.sckw.payment.service.operate.LedgerLogisticsService;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ */
+@Validated
+@RestController
+@RequestMapping("/ledgerLogistics")
+public class LedgerLogisticsController {
+    @Resource
+    private LedgerLogisticsService ledgerLogisticsService;
+
+
+    /**
+     *
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return
+     */
+    @PostMapping("list")
+    public HttpResult list(@RequestBody LogisticsReq logisticsReq) {
+        return HttpResult.ok(ledgerLogisticsService.list(logisticsReq));
+    }
+
+    /**
+     * 对账单关联订单
+     *
+     * @param ledgerListReq 对账单id
+     * @return
+     */
+    @GetMapping("orderList")
+    public HttpResult orderList(@Valid LedgerListReq ledgerListReq) {
+        return HttpResult.ok(ledgerLogisticsService.orderList(ledgerListReq));
+    }
+
+
+    /**
+     * 查询物流对账单详情
+     *
+     * @param id 物流对账单id
+     * @return 物流对账单详情
+     */
+    @GetMapping("queryDetail")
+    public HttpResult queryDetail(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(ledgerLogisticsService.queryDetail(Long.valueOf(id)));
+    }
+
+    /**
+     *
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return 物流对账单统计数据
+     */
+    @PostMapping("count")
+    public HttpResult count(@RequestBody LogisticsReq logisticsReq) {
+        return HttpResult.ok(ledgerLogisticsService.orderCount(logisticsReq));
+    }
+
+
+    /**
+     * 导出 todo
+     *
+     * @param response
+     * @param logisticsReq
+     * @return
+     */
+    @PostMapping("export")
+    public HttpResult export(HttpServletResponse response, @RequestBody LogisticsReq logisticsReq) {
+        List<LedgerLogistics> list;
+        if (CollectionUtils.isEmpty(logisticsReq.getIdList())) {
+            PageRes<LedgerLogistics> pageResult = ledgerLogisticsService.list(logisticsReq);
+            list = pageResult.getList();
+        } else {
+            list = ledgerLogisticsService.selectList(logisticsReq.getIdList());
+        }
+        if (CollectionUtils.isEmpty(list)) {
+            return HttpResult.error("没有可导出的数据");
+        }
+        List<LedgerLogisticsVo> collect = list.stream().map(a -> {
+            LedgerLogisticsVo ledgerLogisticsVo = new LedgerLogisticsVo();
+            BeanUtils.copyProperties(a, ledgerLogisticsVo);
+            return ledgerLogisticsVo;
+        }).collect(Collectors.toList());
+
+        ExcelUtil.downData(response, LedgerLogisticsVo.class, collect);
+        return null;
+    }
+}

+ 112 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/LedgerTradeController.java

@@ -0,0 +1,112 @@
+package com.sckw.payment.controller.operate;
+
+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.vo.LedgerSell;
+import com.sckw.payment.model.vo.req.LedgerListReq;
+import com.sckw.payment.model.vo.req.TradeReq;
+import com.sckw.payment.model.vo.res.LedgerTradeVo;
+import com.sckw.payment.service.operate.LedgerTradeService;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 对账-交易订单
+ *
+ * @author xucaiqin
+ */
+@RestController
+@RequestMapping("/ledgerTrade")
+@Validated
+public class LedgerTradeController {
+    @Resource
+    private LedgerTradeService ledgerTradeService;
+
+
+    /**
+     *
+     *
+     * @param tradeReq
+     * @return
+     */
+    @PostMapping("list")
+    public HttpResult list(@RequestBody TradeReq tradeReq) {
+        return HttpResult.ok(ledgerTradeService.list(tradeReq));
+    }
+
+    /**
+     *
+     * @param ledgerListReq 对账单id
+     * @return
+     */
+    @GetMapping("orderList")
+    public HttpResult orderList(@Valid LedgerListReq ledgerListReq) {
+        return HttpResult.ok(ledgerTradeService.orderList(ledgerListReq));
+    }
+
+
+    /**
+     *
+     * @param id 对账单id
+     * @return
+     */
+    @GetMapping("queryDetail")
+    public HttpResult queryDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(ledgerTradeService.queryDetail(Long.valueOf(id)));
+    }
+
+    /**
+     * 贸易订单数分类统计
+     *
+     * @return
+     */
+    @PostMapping("count")
+    public HttpResult count(@RequestBody  TradeReq tradeReq) {
+        return HttpResult.ok(ledgerTradeService.orderCount(tradeReq));
+    }
+
+
+
+    /**
+     * 导出 todo
+     *
+     * @param response
+     * @param tradeReq
+     * @return
+     */
+    @PostMapping("export")
+    public HttpResult export(HttpServletResponse response, @RequestBody @Valid TradeReq tradeReq) {
+        List<LedgerSell> list = null;
+
+        if (CollectionUtils.isEmpty(tradeReq.getIdList())) {
+            tradeReq.setPage(0);
+            tradeReq.setPageSize(0);
+            PageRes<LedgerSell> pageResult = ledgerTradeService.list(tradeReq);
+            list = pageResult.getList();
+        } else {
+//            list = ledgerTradeService.selectSellList(tradeReq.getIdList());
+        }
+
+        if (CollectionUtils.isEmpty(list)) {
+            return HttpResult.error("没有可导出的数据");
+        }
+        List<LedgerTradeVo> collect = list.stream().map(a -> {
+            LedgerTradeVo ledgerTradeVo = new LedgerTradeVo();
+            BeanUtils.copyProperties(a, ledgerTradeVo);
+            return ledgerTradeVo;
+        }).collect(Collectors.toList());
+        ExcelUtil.downData(response, LedgerTradeVo.class, collect);
+        return null;
+    }
+
+
+}

+ 104 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/SettlementLogisticsController.java

@@ -0,0 +1,104 @@
+package com.sckw.payment.controller.operate;
+
+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.SettlementLogisticsDto;
+import com.sckw.payment.model.vo.req.SettlementReq;
+import com.sckw.payment.model.vo.res.SettlementLogisticsVo;
+import com.sckw.payment.service.KwpSettlementLogisticsService;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 结算-物流订单
+ *
+ * @author Aick Spt
+ * @date 2023-07-18 16:34
+ */
+@RestController
+@Slf4j
+@RequestMapping( "/settlementLogistics")
+public class SettlementLogisticsController {
+
+    @Resource
+    private KwpSettlementLogisticsService kwpSettlementLogisticsService;
+
+    //   ========= 运费收款 承运方 =========
+    @PostMapping(name = "运费收款-物流订单列表", path = "pageListCollection")
+    public HttpResult pageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.pageSelectCollection(settlementReq));
+    }
+
+    @PostMapping(name = "运费收款-物流订单各状态列表总数", path = "getCountListCollection")
+    public HttpResult getCountListCollection(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.getCountListCollection(settlementReq));
+    }
+
+    @PostMapping(name = "运费收款-根据条件导出物流订单表数据", path = "exportCollection")
+    public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
+        List<SettlementLogisticsDto> list;
+        list = kwpSettlementLogisticsService.selectList(settlementReq);
+        return this.export(response, list);
+    }
+
+    @GetMapping(name = "运费收款-物流订单详情", path = "detailCollection")
+    public HttpResult detailCollection(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpSettlementLogisticsService.detailCollection(id));
+    }
+
+
+    //   ========= 运费付款 托运方 =========
+    @PostMapping(name = "运费付款-物流订单列表", path = "pageListPayment")
+    public HttpResult pageSelectPayment(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.pageSelectPayment(settlementReq));
+    }
+
+    @PostMapping(name = "运费付款-物流订单各状态列表总数", path = "getCountListPayment")
+    public HttpResult getCountListPayment(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.getCountListPayment(settlementReq));
+    }
+
+    @PostMapping(name = "运费付款-根据条件导出物流订单表数据", path = "exportPayment")
+    public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
+        List<SettlementLogisticsDto> list;
+        list = kwpSettlementLogisticsService.selectList(settlementReq);
+        return this.export(response, list);
+    }
+
+    @GetMapping(name = "物流订单详情", path = "detailPayment")
+    public HttpResult detailPayment(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpSettlementLogisticsService.detailPayment(id));
+    }
+
+    /**
+     * 导出
+     *
+     * @author Aick Spt
+     * @date 2023-07-24 15:49
+     */
+    private HttpResult export(HttpServletResponse response, List<SettlementLogisticsDto> list) {
+        if (CollectionUtils.isEmpty(list)) {
+            return HttpResult.error("没有可导出的数据");
+        }
+        List<SettlementLogisticsVo> collect = list.stream().map(a -> {
+            SettlementLogisticsVo settlementLogisticsVo = new SettlementLogisticsVo();
+            BeanUtils.copyProperties(a, settlementLogisticsVo);
+            return settlementLogisticsVo;
+        }).collect(Collectors.toList());
+        ExcelUtil.downData(response, SettlementLogisticsVo.class, collect);
+        return null;
+    }
+
+
+}

+ 179 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/SettlementTradeController.java

@@ -0,0 +1,179 @@
+package com.sckw.payment.controller.operate;
+
+import com.sckw.core.model.page.PageRes;
+import com.sckw.core.web.context.LoginUserHolder;
+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.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;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 结算-交易订单
+ *
+ * @author xucaiqin
+ */
+@RestController
+@RequestMapping( "/settlementTrade")
+public class SettlementTradeController {
+
+    @Resource
+    private KwpSettlementTradeService kwpSettlementTradeService;
+
+    //   ========= 收款 销售 =========
+
+    /**
+     * 销售分页列表
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-销售结算单列表", path = "pageSellList")
+    public HttpResult pageListCollection(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
+        settlementReq.check();
+        return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
+    }
+
+    /**
+     * 待结算、部分结算、全部结算
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表头统计数量", path = "getSellCount")
+    public HttpResult getCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        settlementReq.check();
+        return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
+    }
+
+    /**
+     * 表尾金额结算数据
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表尾金额结算数据", path = "getSellSum")
+    public HttpResult getSellSum(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
+    }
+
+    @PostMapping(name = "收款-根据ids导出销售结算单列表", path = "exportCollection")
+    public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        List<ISettlement> list;
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
+        if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
+            PageRes<ISettlement> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
+            list = pageResult.getList();
+        } else {
+            list = kwpSettlementTradeService.selectList(settlementReq.getIdList(), TradeUnitType.PURCHASE);
+        }
+        return this.export(response, list);
+    }
+
+
+    //   ========= 付款 采购 =========
+
+    /**
+     * 采购分页列表
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "付款-采购结算单列表", path = "pagePurchaseList")
+    public HttpResult pageListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
+    }
+
+    /**
+     * 待结算、部分结算、全部结算
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表头统计数量", path = "getPurchaseCount")
+    public HttpResult getPurchaseCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
+    }
+
+    /**
+     * 表尾金额结算数据
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-物流结算订单列表头部汇总数量", path = "getPurchaseSum")
+    public HttpResult getCountListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
+    }
+
+    @PostMapping(name = "付款-根据ids导出采购结算单列表", path = "exportPayment")
+    public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        List<ISettlement> list;
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
+            PageRes<ISettlement> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
+            list = pageResult.getList();
+        } else {
+            list = kwpSettlementTradeService.selectList(settlementReq.getIdList(), TradeUnitType.SELL);
+        }
+        return this.export(response, list);
+    }
+    /**
+     * 导出
+     *
+     * @author Aick Spt
+     * @date 2023-07-24 15:49
+     */
+    private HttpResult export(HttpServletResponse response, List<ISettlement> list) {
+        if (CollectionUtils.isEmpty(list)) {
+            return HttpResult.error("没有可导出的数据");
+        }
+        List<SettlementLogisticsVo> collect = list.stream().map(a -> {
+            SettlementLogisticsVo settlementLogisticsVo = new SettlementLogisticsVo();
+            BeanUtils.copyProperties(a, settlementLogisticsVo);
+            return settlementLogisticsVo;
+        }).collect(Collectors.toList());
+        ExcelUtil.downData(response, SettlementLogisticsVo.class, collect);
+        return null;
+    }
+
+
+}

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

@@ -6,6 +6,7 @@ import com.sckw.payment.model.dto.LedgerCarrierDto;
 import com.sckw.payment.model.dto.LedgerLogisticsDto;
 import com.sckw.payment.model.dto.LedgerShipperDto;
 import com.sckw.payment.model.dto.LedgerSize;
+import com.sckw.payment.model.vo.LedgerLogistics;
 import com.sckw.payment.model.vo.req.LogisticsReq;
 import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -31,6 +32,14 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     List<LedgerShipperDto> shipperSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
+    /**
+     * 运营端
+     *
+     * @param logisticsReq
+     * @return
+     */
+    List<LedgerLogistics> list(@Param("logisticsReq") LogisticsReq logisticsReq);
+
     /**
      * 承运方 对账发起方,客户公司是托运方
      *
@@ -47,10 +56,19 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq);
 
+    /**
+     * 运营端统计
+     *
+     * @param logisticsReq
+     * @return
+     */
+    Map<String, Long> countOrder2(@Param("logisticsReq") LogisticsReq logisticsReq);
+
     LedgerLogisticsDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
 
     List<LedgerShipperDto> selectShipperIds(@Param("ids") List<Long> ids);
+    List<LedgerLogistics> selectIds(@Param("ids") List<Long> ids);
 
     /**
      * 承运方

+ 26 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java

@@ -6,6 +6,7 @@ import com.sckw.payment.model.dto.LedgerPurchaseDto;
 import com.sckw.payment.model.dto.LedgerSellDto;
 import com.sckw.payment.model.dto.LedgerSize;
 import com.sckw.payment.model.dto.LedgerTradeDto;
+import com.sckw.payment.model.vo.LedgerSell;
 import com.sckw.payment.model.vo.req.TradeReq;
 import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -25,6 +26,14 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     List<LedgerSellDto> sellList(@Param("tradeReq") TradeReq tradeReq);
 
+    /**
+     * 运营端 对账列表数据
+     *
+     * @param tradeReq
+     * @return
+     */
+    List<LedgerSell> list(@Param("tradeReq") TradeReq tradeReq);
+
     /**
      * 采购方数据需要过滤已保存、已撤回状态的数据
      *
@@ -34,8 +43,22 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     List<LedgerPurchaseDto> purchaseList(@Param("tradeReq") TradeReq tradeReq);
 
+    /**
+     * 统计对账单数量
+     *
+     * @param tradeReq
+     * @return
+     */
     Map<String, Long> countOrder(@Param("tradeReq") TradeReq tradeReq);
 
+    /**
+     * 运营端统计对账单数量
+     *
+     * @param tradeReq
+     * @return
+     */
+    Map<String, Long> countOrder2(@Param("tradeReq") TradeReq tradeReq);
+
     LedgerTradeDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     List<LedgerSellDto> selectSellIds(@Param("ids") List<Long> ids);
@@ -47,12 +70,11 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
     void updatePrice(@Param("id") Long id, @Param("totalPrice") BigDecimal totalPrice);
 
     /**
-     *
-     * @param entId 采购单位
+     * @param entId     采购单位
      * @param entTarget 销售单位
      * @return
      */
-    List<String> selectJoin(@Param("entId")Long entId, @Param("entTarget")Long entTarget);
+    List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
 
-    LedgerSize countSize(@Param("entId")Long entId);
+    LedgerSize countSize(@Param("entId") Long entId);
 }

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

@@ -2,6 +2,7 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.KwpSettlementRecord;
 import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
@@ -77,4 +78,6 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
      * @param unitType 企业类型
      */
     List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
+
+    List<KwpSettlementRecord> queryRecord();
 }

+ 20 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementRecordMapper.java

@@ -0,0 +1,20 @@
+package com.sckw.payment.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.payment.model.KwpSettlementRecord;
+import com.sckw.payment.model.vo.req.FinanceCount;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+* @date 2023-09-13 18:48:30
+* @author xucaiqin
+*/
+@Mapper
+public interface KwpSettlementRecordMapper extends BaseMapper<KwpSettlementRecord> {
+    void insertBatch(@Param("list") List<KwpSettlementRecord> list);
+
+    void countByDay(FinanceCount financeCount);
+}

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

@@ -1,6 +1,7 @@
 package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.payment.model.KwpSettlementRecord;
 import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.MoneyType;
@@ -51,4 +52,7 @@ public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade>
      * @param unitType 企业类型
      */
     List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
+
+    List<KwpSettlementRecord> queryRecord();
+
 }

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java

@@ -23,8 +23,8 @@ public class AsyncPool {
     }
 
     private static class ThreadPool {
-        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,
-                1,
+        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,
+                2,
                 1,
                 TimeUnit.MINUTES,
                 new LinkedBlockingQueue<>(12));

+ 5 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementLogistics.java

@@ -75,7 +75,11 @@ public class KwpSettlementLogistics {
      */
     @TableField(value = "remark")
     private String remark;
-
+    /**
+     * 冗余字段,写统计接口时增加
+     */
+    @TableField(value = "trading")
+    private String trading;
     /**
      * 对账托运方财务联系人
      */

+ 93 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementRecord.java

@@ -0,0 +1,93 @@
+package com.sckw.payment.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+* @date 2023-09-13 18:48:30
+* @author xucaiqin
+*/
+/**
+    * 结算归档表
+    */
+@Data
+@TableName(value = "kwp_settlement_record")
+public class KwpSettlementRecord {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.INPUT)
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    @TableField(value = "ent_id")
+    private Long entId;
+
+    /**
+     * 总应收金额
+     */
+    @TableField(value = "total_receive_money")
+    private BigDecimal totalReceiveMoney;
+
+    /**
+     * 待收金额
+     */
+    @TableField(value = "exact_money")
+    private BigDecimal exactMoney;
+
+    /**
+     * 已收金额(累加金额)
+     */
+    @TableField(value = "received_money")
+    private BigDecimal receivedMoney;
+
+    /**
+     * 逾期待收金额
+     */
+    @TableField(value = "overdue_exact_money")
+    private BigDecimal overdueExactMoney;
+
+    /**
+     * 总应付金额
+     */
+    @TableField(value = "total_pay_money")
+    private BigDecimal totalPayMoney;
+
+    /**
+     * 待付金额
+     */
+    @TableField(value = "unpaid_money")
+    private BigDecimal unpaidMoney;
+
+    /**
+     * 已付金额(累加金额)
+     */
+    @TableField(value = "paid_money")
+    private BigDecimal paidMoney;
+
+    /**
+     * 逾期待付金额
+     */
+    @TableField(value = "overdue_paid_money")
+    private BigDecimal overduePaidMoney;
+
+    /**
+     * 创建日期
+     */
+    @TableField(value = "create_time")
+    private LocalDate createTime;
+
+    /**
+     * 1-物流 2-贸易
+     */
+    @TableField(value = "order_type")
+    private Integer orderType;
+}

+ 5 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementTrade.java

@@ -92,7 +92,11 @@ public class KwpSettlementTrade {
      */
     @TableField(value = "success_phone")
     private String successPhone;
-
+    /**
+     * 冗余字段,写统计接口时增加
+     */
+    @TableField(value = "trading")
+    private String trading;
     /**
      * 备注
      */

+ 10 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/WalletOverview.java

@@ -29,6 +29,16 @@ public class WalletOverview implements Serializable {
      */
     @JSONField(name = "ap_money")
     private Long apMoney;
+    /**
+     * 提现中金额
+     */
+    @JSONField(name = "wding_money")
+    private Long wdingMoney;
+    /**
+     * 充值中金额
+     */
+    @JSONField(name = "charging_money")
+    private Long chargingMoney;
     /**
      * 提现余额
      */

+ 134 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerLogistics.java

@@ -0,0 +1,134 @@
+package com.sckw.payment.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.payment.model.dto.ILedger;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 18:11:24
+ */
+@Getter
+@Setter
+public class LedgerLogistics implements ILedger {
+    /**
+     * 主键
+     */
+    private Long id;
+    /**
+     * 物流对账单编号
+     */
+    private String lLedgerNo;
+
+    /**
+     * 对账单名称
+     */
+    private String name;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 托运单位
+     */
+    private String shipperFirmName;
+
+    /**
+     * 承运单位
+     */
+    private String carrierFirmName;
+
+
+
+    /**
+     * 发票税率(%)
+     */
+    private String taxRateLabel;
+    private Integer taxRate;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private String trading;
+    private String tradingLabel;
+    /**
+     * 对账托运方财务联系人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 对账托运方财务联系人名称
+     */
+    private String auditUser;
+    /**
+     * 对账承运方财务联系人名称
+     */
+    private String successUser;
+    /**
+     * 对账承运方财务联系人电话
+     */
+    private String successPhone;
+
+    /**
+     * 总应收/元
+     */
+    private BigDecimal totalPrice;
+    /**
+     * 不含税金额
+     */
+    private BigDecimal exTaxPrice;
+
+    /**
+     * 实际结算金额
+     */
+    private BigDecimal settlePrice;
+
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+
+    /**
+     * 对账清单凭证
+     */
+    private String url;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
+    /**
+     * 预计收款时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDateTime receiptTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态状态(1-已保存、2-待对账、3-已对账、4-已完成、5-已退回)
+     */
+    private Integer status;
+    private String statusLabel;
+    /**
+     * 创建人
+     */
+    private Long createBy;
+    private String createByName;
+
+    /**
+     * 订单数量
+     */
+    private Integer orderCount;
+}

+ 129 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerSell.java

@@ -0,0 +1,129 @@
+package com.sckw.payment.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.sckw.payment.model.dto.ILedger;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 对账-贸易订单 销售方
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 18:11:24
+ */
+@Getter
+@Setter
+public class LedgerSell implements ILedger {
+    /**
+     * 主键
+     */
+    private Long id;
+    /**
+     * 贸易对账单编号
+     */
+    @JsonProperty("tLedgerNo")
+    private String tLedgerNo;
+
+    /**
+     * 对账单名称
+     */
+    private String name;
+
+
+    /**
+     * 开始日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime startTime;
+
+    /**
+     * 结束日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime endTime;
+
+    /**
+     * 发票税率(%)
+     */
+    private Integer taxRate;
+    private String taxRateLabel;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private String trading;
+    private String tradingLabel;
+
+
+    /**
+     * 总应收/元
+     */
+    private BigDecimal totalPrice;
+    /**
+     * 不含税金额
+     */
+    private BigDecimal exTaxPrice;
+
+    /**
+     * 实际结算金额
+     */
+    private BigDecimal settlePrice;
+
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+
+    /**
+     * 对账审核人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 对账审核人名称
+     */
+    private String auditUser;
+
+    /**
+     * 对账清单凭证
+     */
+    private String url;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDateTime receiptTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态(1-已保存、2-待对账、3-已对账、4-已完成、5-已退回)
+     */
+    private Integer status;
+    private String statusLabel;
+    private String contacts;
+    private String phone;
+    private String firmName;
+    /**
+     * 创建人
+     */
+    private Long createBy;
+    private String createByName;
+
+    /**
+     * 订单数量
+     */
+    private Integer orderCount;
+}

+ 42 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java

@@ -0,0 +1,42 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 财务统计
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class FinanceCount {
+    /**
+     * 周期维度 日、月
+     */
+    @NotBlank(message = "周期维度不能为空")
+    private Integer circle;
+    /**
+     * 开始时间
+     */
+//    @NotBlank(message = "周期维度不能为空")
+    private String startTime;
+    /**
+     * 结束时间
+     */
+//    @NotBlank(message = "周期维度不能为空")
+    private String endTime;
+    /**
+     * 统计因子
+     */
+    @Size(message = "统计因子不能为空", min = 1)
+    @NotNull(message = "统计因子不能为空")
+    private List<Integer> factor;
+
+}

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletDetail.java

@@ -8,5 +8,5 @@ import java.util.List;
  * @author xucaiqin
  * @date 2023-08-28 15:43:49
  */
-public record WalletDetail(String entName, String money, String moneyYuan, int channel, List<String> channels) {
+public record WalletDetail(String entName, String money, String chargingMoney,String wdingMoney ,int channel, List<String> channels) {
 }

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

@@ -579,6 +579,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         //实际结算金额就是结算单实际需付金额
         kwpSettlementLogistics.setTotalPrice(kwpLedgerLogistics.getSettlePrice());
         kwpSettlementLogistics.setActualPrice(kwpLedgerLogistics.getActualPrice());
+        kwpSettlementLogistics.setTrading(kwpLedgerLogistics.getTrading());
         kwpSettlementLogistics.setRemark(Global.EMPTY_STRING);
         kwpSettlementLogistics.setAuditUser(kwpLedgerLogistics.getAuditUser());
         kwpSettlementLogistics.setAuditPhone(kwpLedgerLogistics.getAuditPhone());

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

@@ -587,6 +587,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpSettlementTrade.setTotalPrice(kwpLedgerTrade.getSettlePrice());
         kwpSettlementTrade.setActualPrice(kwpLedgerTrade.getActualPrice());
         kwpSettlementTrade.setRemark(Global.EMPTY_STRING);
+        kwpSettlementTrade.setTrading(kwpLedgerTrade.getTrading());
         kwpSettlementTrade.setAuditUser(kwpLedgerTrade.getAuditUser());
         kwpSettlementTrade.setAuditPhone(kwpLedgerTrade.getAuditPhone());
         kwpSettlementTrade.setSuccessUser(ledgerReq.getSuccessUser());

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -61,7 +61,7 @@ public class KwpSettlementOfflineService {
     private final KwpSettlementTradeService settlementTradeService;
     private final KwpLedgerTradeOrderService tradeOrderService;
     private final KwpSettlementTradeTrackService settlementTradeTrackService;
-    private final KwpLedgerTradeService ledgerTradeService;
+    private final KwpLedgerTradeService kwpLedgerTradeService;
     private final MessageSender messageSender;
     private final KwpLedgerTradeUnitService tradeUnitService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
@@ -388,7 +388,7 @@ public class KwpSettlementOfflineService {
 
                 settlementOfflineMapper.insert(kwpSettlementOffline);
                 //预付款-更新对账单已付金额
-                ledgerTradeService.updateActualPrice(byId.gettLedgerId(), payReq.getPayPrice());
+                kwpLedgerTradeService.updateActualPrice(byId.gettLedgerId(), payReq.getPayPrice());
 
                 //记录表记录数据
                 settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.OFFLINE_PAY.getStatus()));

+ 26 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementRecordService.java

@@ -0,0 +1,26 @@
+package com.sckw.payment.service;
+
+import com.sckw.payment.dao.KwpSettlementRecordMapper;
+import com.sckw.payment.model.vo.req.FinanceCount;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 归档记录
+ *
+ * @author xucaiqin
+ * @date 2023-08-28 15:38:53
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class KwpSettlementRecordService {
+    private final KwpSettlementRecordMapper kwpSettlementRecordMapper;
+
+
+    public String financeCount(FinanceCount financeCount) {
+        kwpSettlementRecordMapper.countByDay(financeCount);
+        return null;
+    }
+}

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

@@ -85,7 +85,7 @@ public class KwpSettlementWalletService {
     private TransportDubboService transportDubboService;
     private final KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
     @Resource
-    private KwpLedgerTradeService ledgerTradeService;
+    private KwpLedgerTradeService kwpLedgerTradeService;
 
 
     /**
@@ -386,7 +386,7 @@ public class KwpSettlementWalletService {
                 kwpSettlementWallet.setDelFlag(Global.UN_DELETED);
                 settlementWalletMapper.insert(kwpSettlementWallet);
                 //货到付款-更新对账单已付金额
-                ledgerTradeService.updateActualPrice(byId.getLedgerId(), price);
+                kwpLedgerTradeService.updateActualPrice(byId.getLedgerId(), price);
                 //更新交易结算单状态和金额
                 KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
                 kwpSettlementTrade.setId(byId.getId());
@@ -561,7 +561,7 @@ public class KwpSettlementWalletService {
                 kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
                 kwpSettlementTradeService.updateById(kwpSettlementTrade);
                 //预付款-更新对账单已付金额
-                ledgerTradeService.updateActualPrice(byId.gettLedgerId(), byId.getTotalPrice());
+                kwpLedgerTradeService.updateActualPrice(byId.gettLedgerId(), byId.getTotalPrice());
                 //新增电子钱包结算记录
                 KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
                 kwpSettlementWallet.setId(new IdWorker(1).nextId());

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -200,9 +200,9 @@ public class WalletService {
         R<WalletOverview> wallet = payCenterService.general(relation);
         if (wallet.getStatus()) {
             WalletOverview data = wallet.getData();
-            return new WalletDetail(LoginUserHolder.getEntName(), String.valueOf(data.getTotalMoney()), String.valueOf(data.getTotalMoney() / 100D), data.getChannelTotal(), data.getChannels());
+            return new WalletDetail(LoginUserHolder.getEntName(), String.valueOf(data.getTotalMoney() / 100D), String.valueOf(data.getChargingMoney()), String.valueOf(data.getWdingMoney()), data.getChannelTotal(), data.getChannels());
         }
-        return new WalletDetail(LoginUserHolder.getEntName(), "-", "-", 0, new ArrayList<>());
+        return new WalletDetail(LoginUserHolder.getEntName(), "-", "-", "-", 0, new ArrayList<>());
     }
 
     /**

+ 23 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java

@@ -0,0 +1,23 @@
+package com.sckw.payment.service;
+
+import com.sckw.payment.model.vo.req.FinanceCount;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 工作台
+ *
+ * @author xucaiqin
+ * @date 2023-08-28 15:38:53
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class WorkbenchService {
+
+
+    public String financeCount(FinanceCount financeCount) {
+        return null;
+    }
+}

+ 11 - 11
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -35,7 +35,7 @@ import java.util.*;
 @Slf4j
 public class PaymentDubboServiceImpl implements PaymentDubboService {
     private final KwpLedgerLogisticsService ledgerLogisticsService;
-    private final KwpLedgerTradeService ledgerTradeService;
+    private final KwpLedgerTradeService kwpLedgerTradeService;
     private final KwpSettlementLogisticsService settlementLogisticsService;
     private final KwpSettlementTradeService settlementTradeService;
 
@@ -62,7 +62,7 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
             throw new BusinessException("企业id不能为空");
         }
         List<String> logistics = ledgerLogisticsService.checkOrder(entId, entTarget);
-        List<String> trade = ledgerTradeService.checkOrder(entId, entTarget);
+        List<String> trade = kwpLedgerTradeService.checkOrder(entId, entTarget);
         Map<OrderEnum, List<String>> res = new HashMap<>(2);
         res.put(OrderEnum.LOGISTICS, logistics);
         res.put(OrderEnum.TRADE, trade);
@@ -85,7 +85,7 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
     @Override
     public LedgerCount countLedger(Long entId) {
         LedgerSize count = ledgerLogisticsService.count(entId);
-        LedgerSize ledgerSize = ledgerTradeService.count(entId);
+        LedgerSize ledgerSize = kwpLedgerTradeService.count(entId);
         return new LedgerCount(ledgerSize.send(), ledgerSize.receive(), count.send(), count.receive());
     }
 
@@ -99,12 +99,12 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         List<LocalDateTime> cur = new ArrayList<>();
         List<LocalDateTime> pre = new ArrayList<>();
         //按周统计
-        if (countType == 1) {
+        if (countType == 2) {
             cur.add(DateTimeUtil.getComputeDaysStart(-6));
             cur.add(DateTimeUtil.getComputeDaysEnd(0));
             pre.add(DateTimeUtil.getComputeDaysStart(-13));
             pre.add(DateTimeUtil.getComputeDaysEnd(-7));
-        } else {
+        } else if (countType == 3) {
             cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
             cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
             pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
@@ -123,12 +123,12 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         List<LocalDateTime> cur = new ArrayList<>();
         List<LocalDateTime> pre = new ArrayList<>();
         //按周统计
-        if (countType == 1) {
+        if (countType == 2) {
             cur.add(DateTimeUtil.getComputeDaysStart(-6));
             cur.add(DateTimeUtil.getComputeDaysEnd(0));
             pre.add(DateTimeUtil.getComputeDaysStart(-13));
             pre.add(DateTimeUtil.getComputeDaysEnd(-7));
-        } else {
+        } else if (countType == 3) {
             cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
             cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
             pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
@@ -148,12 +148,12 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         List<LocalDateTime> cur = new ArrayList<>();
         List<LocalDateTime> pre = new ArrayList<>();
         //按周统计
-        if (countType == 1) {
+        if (countType == 2) {
             cur.add(DateTimeUtil.getComputeDaysStart(-6));
             cur.add(DateTimeUtil.getComputeDaysEnd(0));
             pre.add(DateTimeUtil.getComputeDaysStart(-13));
             pre.add(DateTimeUtil.getComputeDaysEnd(-7));
-        } else {
+        } else if (countType == 3) {
             cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
             cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
             pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
@@ -173,12 +173,12 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         List<LocalDateTime> cur = new ArrayList<>();
         List<LocalDateTime> pre = new ArrayList<>();
         //按周统计
-        if (countType == 1) {
+        if (countType == 2) {
             cur.add(DateTimeUtil.getComputeDaysStart(-6));
             cur.add(DateTimeUtil.getComputeDaysEnd(0));
             pre.add(DateTimeUtil.getComputeDaysStart(-13));
             pre.add(DateTimeUtil.getComputeDaysEnd(-7));
-        } else {
+        } else if (countType == 3) {
             cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
             cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
             pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));

+ 203 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/operate/LedgerLogisticsService.java

@@ -0,0 +1,203 @@
+package com.sckw.payment.service.operate;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.vo.TableTop;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.StringTimeUtil;
+import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
+import com.sckw.payment.model.KwpLedgerLogistics;
+import com.sckw.payment.model.KwpLedgerLogisticsOrder;
+import com.sckw.payment.model.constant.LedgerEnum;
+import com.sckw.payment.model.dto.ILedger;
+import com.sckw.payment.model.vo.LedgerLogistics;
+import com.sckw.payment.model.vo.req.LedgerListReq;
+import com.sckw.payment.model.vo.req.LogisticsReq;
+import com.sckw.payment.model.vo.res.LedgerLogisticsDetailVo;
+import com.sckw.payment.service.AbsLedger;
+import com.sckw.payment.service.KwpLedgerLogisticsOrderService;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.SysDictResDto;
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
+import com.sckw.transport.api.dubbo.TransportDubboService;
+import com.sckw.transport.api.model.dto.LogisticsOrderDTO;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-10 16:38:36
+ */
+@Service
+@Slf4j
+public class LedgerLogisticsService extends AbsLedger {
+    @Resource
+    private KwpLedgerLogisticsOrderService logisticsOrderService;
+    @Resource
+    private KwpLedgerLogisticsMapper logisticsMapper;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private TransportDubboService transportDubboService;
+
+    private void changeDict(List<? extends ILedger> list) {
+        List<SysDictResDto> taxRateDict = remoteSystemService.queryDictByType(DictTypeEnum.TAX_RATE.getType());
+        Map<String, String> taxRateMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        Map<String, String> tradingMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+
+        if (!CollectionUtils.isEmpty(taxRateDict)) {
+            taxRateMap = taxRateDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
+        }
+        List<SysDictResDto> tradingDict = remoteSystemService.queryDictByType(DictTypeEnum.TRADE_TYPE.getType());
+        if (!CollectionUtils.isEmpty(tradingDict)) {
+            tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
+        }
+        for (ILedger logisticsDto : list) {
+            String trading = logisticsDto.getTrading();
+            logisticsDto.setTradingLabel(tradingMap.get(trading));
+            Integer taxRate = logisticsDto.getTaxRate();
+            logisticsDto.setTaxRateLabel(taxRateMap.get(String.valueOf(taxRate)));
+
+            logisticsDto.setStatusLabel(LedgerEnum.getDesc(logisticsDto.getStatus()));
+
+            UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(logisticsDto.getCreateBy());
+            if (Objects.nonNull(userCacheResDto)) {
+                logisticsDto.setCreateByName(userCacheResDto.getName());
+            }
+        }
+    }
+
+    private void fillPara(LogisticsReq logisticsReq) {
+        if (StringUtils.isNotBlank(logisticsReq.getStartCreateTime())) {
+            logisticsReq.setStartCreateTime(StringTimeUtil.fillStart(logisticsReq.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(logisticsReq.getEndCreateTime())) {
+            logisticsReq.setEndCreateTime(StringTimeUtil.fillEnd(logisticsReq.getEndCreateTime()));
+        }
+    }
+
+    /**
+     * 托运方物流对账单列表查询
+     *
+     * @param logisticsReq
+     * @return 托运方对账订单分页数据
+     */
+    public PageRes<LedgerLogistics> list(LogisticsReq logisticsReq) {
+        fillPara(logisticsReq);
+        PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
+        List<LedgerLogistics> kwpLedgerLogisticsList = logisticsMapper.list(logisticsReq);
+        PageInfo<LedgerLogistics> ledgerShipperDtoPageInfo = new PageInfo<>(kwpLedgerLogisticsList);
+        //字典转换
+        if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
+            changeDict(ledgerShipperDtoPageInfo.getList());
+            return new PageRes<>(ledgerShipperDtoPageInfo);
+        }
+        return new PageRes<>(ledgerShipperDtoPageInfo);
+    }
+
+    public PageRes<LogisticsOrderDTO> orderList(LedgerListReq ledgerListReq) {
+        PageHelper.startPage(ledgerListReq.getPage(), ledgerListReq.getPageSize());
+        List<KwpLedgerLogisticsOrder> kwpLedgerLogisticsOrders = logisticsOrderService.queryList(ledgerListReq.getIdLong());
+        if (CollectionUtils.isEmpty(kwpLedgerLogisticsOrders)) {
+            return new PageRes<>();
+        }
+        PageInfo<KwpLedgerLogisticsOrder> pageInfo = new PageInfo<>(kwpLedgerLogisticsOrders);
+        List<LogisticsOrderDTO> acceptCarriageOrderList = transportDubboService.getAcceptCarriageOrderList(kwpLedgerLogisticsOrders.stream().map(a -> String.valueOf(a.getLOrderId())).toList());
+        return PageRes.build(pageInfo, acceptCarriageOrderList);
+    }
+
+
+    /**
+     * 按类型统计表头的数据
+     * 1-托运方 2-承运方
+     *
+     * @param logisticsReq 查询参数
+     * @return 统计数据
+     */
+    public List<TableTop> orderCount(LogisticsReq logisticsReq) {
+        Map<String, Long> map = logisticsMapper.countOrder2(logisticsReq);
+        TableTop ledgerCountVo;
+        /*统计数据转换*/
+        List<TableTop> res = new ArrayList<>();
+        for (LedgerEnum value : LedgerEnum.values()) {
+            ledgerCountVo = new TableTop();
+            ledgerCountVo.setTotal(Math.toIntExact(map.get(value.getLabel())));
+            ledgerCountVo.setName(value.getDesc());
+            ledgerCountVo.setValue(value.getStatus());
+            res.add(ledgerCountVo);
+        }
+        return res;
+    }
+
+    /**
+     * 查询物流对账单
+     *
+     * @param ids 对账单id列表
+     * @return 物流对账单列表
+     */
+    public List<LedgerLogistics> selectList(List<Long> ids) {
+        List<LedgerLogistics> ledgerLogisticsDto = logisticsMapper.selectIds(ids);
+        changeDict(ledgerLogisticsDto);
+        return ledgerLogisticsDto;
+    }
+
+    /**
+     * 查询物流对账单详情
+     *
+     * @param id 物流对账单id
+     * @return
+     */
+    public LedgerLogisticsDetailVo queryDetail(Long id) {
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        orderCheck(kwpLedgerLogistics);
+        return getLedgerLogisticsDetailVo(kwpLedgerLogistics);
+    }
+
+    /**
+     * 转换物流对账单详情数据
+     *
+     * @param ledgerLogisticsDto
+     * @return
+     */
+    private LedgerLogisticsDetailVo getLedgerLogisticsDetailVo(KwpLedgerLogistics ledgerLogisticsDto) {
+        /*获取物流对账单关联的物流订单*/
+        List<KwpLedgerLogisticsOrder> kwpLedgerLogisticsOrders = logisticsOrderService.queryList(ledgerLogisticsDto.getId());
+        LedgerLogisticsDetailVo ledgerLogisticsDetailVo = new LedgerLogisticsDetailVo();
+        SysDictResDto trading = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TRADE_TYPE.getType(), ledgerLogisticsDto.getTrading());
+        SysDictResDto taxRate = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TRADE_TYPE.getType(), String.valueOf(ledgerLogisticsDto.getTaxRate()));
+
+        ledgerLogisticsDetailVo.setId(ledgerLogisticsDto.getId());
+        ledgerLogisticsDetailVo.setLLedgerNo(ledgerLogisticsDto.getLLedgerNo());
+        ledgerLogisticsDetailVo.setName(ledgerLogisticsDto.getName());
+        ledgerLogisticsDetailVo.setTrading(ledgerLogisticsDto.getTrading());
+        ledgerLogisticsDetailVo.setTradingLabel(Objects.nonNull(trading) ? trading.getLabel() : "");
+
+        ledgerLogisticsDetailVo.setTaxRate(ledgerLogisticsDto.getTaxRate());
+        ledgerLogisticsDetailVo.setTaxRateLabel(Objects.nonNull(taxRate) ? taxRate.getLabel() : "");
+        ledgerLogisticsDetailVo.setTotalPrice(ledgerLogisticsDto.getTotalPrice());
+        ledgerLogisticsDetailVo.setSettlePrice(ledgerLogisticsDto.getSettlePrice());
+        ledgerLogisticsDetailVo.setActualPrice(ledgerLogisticsDto.getActualPrice());
+        ledgerLogisticsDetailVo.setStartTime(ledgerLogisticsDto.getStartTime());
+        ledgerLogisticsDetailVo.setEndTime(ledgerLogisticsDto.getEndTime());
+        ledgerLogisticsDetailVo.setRemark(ledgerLogisticsDto.getRemark());
+        /*查询物流订单详情*/
+        if (!CollectionUtils.isEmpty(kwpLedgerLogisticsOrders)) {
+            List<LogisticsOrderDTO> acceptCarriageOrderList = transportDubboService.getAcceptCarriageOrderList(kwpLedgerLogisticsOrders.stream().map(a -> Long.toString(a.getLOrderId())).collect(Collectors.toList()));
+            if (CollectionUtils.isEmpty(acceptCarriageOrderList)) {
+                ledgerLogisticsDetailVo.setOrderList(new ArrayList<>());
+            } else {
+                ledgerLogisticsDetailVo.setOrderList(acceptCarriageOrderList);
+            }
+        }
+        return ledgerLogisticsDetailVo;
+    }
+}

+ 282 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/operate/LedgerTradeService.java

@@ -0,0 +1,282 @@
+package com.sckw.payment.service.operate;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.vo.TableTop;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.StringTimeUtil;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
+import com.sckw.order.api.model.*;
+import com.sckw.payment.dao.KwpLedgerTradeMapper;
+import com.sckw.payment.model.KwpLedgerTrade;
+import com.sckw.payment.model.KwpLedgerTradeOrder;
+import com.sckw.payment.model.constant.LedgerEnum;
+import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.dto.ILedger;
+import com.sckw.payment.model.dto.LedgerSellDto;
+import com.sckw.payment.model.dto.OrderDto;
+import com.sckw.payment.model.vo.LedgerSell;
+import com.sckw.payment.model.vo.req.LedgerListReq;
+import com.sckw.payment.model.vo.req.TradeReq;
+import com.sckw.payment.model.vo.res.LedgerTradeDetailVo;
+import com.sckw.payment.service.*;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.SysDictResDto;
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
+import jakarta.annotation.Resource;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-10 16:38:36
+ */
+
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class LedgerTradeService extends AbsLedger {
+    private final KwpLedgerTradeMapper tradeMapper;
+    private final KwpLedgerTradeTrackService tradeTrackService;
+    private final KwpLedgerTradeOrderService tradeOrderService;
+    private final KwpLedgerTradeUnitService tradeUnitService;
+    private final MessageSender messageSender;
+    @Resource
+    private KwpSettlementTradeService settlementTradeService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private TradeOrderInfoService tradeOrderInfoService;
+
+    /**
+     * 转换字典数据
+     *
+     * @param list
+     */
+    private void changeDict(List<? extends ILedger> list) {
+        List<SysDictResDto> taxRateDict = remoteSystemService.queryDictByType(DictTypeEnum.TAX_RATE.getType());
+        Map<String, String> taxRateMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        Map<String, String> tradingMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+
+        if (!CollectionUtils.isEmpty(taxRateDict)) {
+            taxRateMap = taxRateDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
+        }
+        List<SysDictResDto> tradingDict = remoteSystemService.queryDictByType(DictTypeEnum.TRADE_TYPE.getType());
+        if (!CollectionUtils.isEmpty(tradingDict)) {
+            tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
+        }
+        for (ILedger tradeDto : list) {
+            String trading = tradeDto.getTrading();
+            tradeDto.setTradingLabel(tradingMap.get(trading));
+            Integer taxRate = tradeDto.getTaxRate();
+            tradeDto.setTaxRateLabel(taxRateMap.get(String.valueOf(taxRate)));
+
+            tradeDto.setStatusLabel(LedgerEnum.getDesc(tradeDto.getStatus()));
+            UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(tradeDto.getCreateBy());
+            if (Objects.nonNull(userCacheResDto)) {
+                tradeDto.setCreateByName(userCacheResDto.getName());
+            }
+        }
+    }
+
+    /**
+     * 填充时间等参数
+     *
+     * @param tradeReq 请求参数
+     */
+    private void fillPara(TradeReq tradeReq) {
+        tradeReq.setEntId(LoginUserHolder.getEntId());
+        if (StringUtils.isNotBlank(tradeReq.getStartCreateTime())) {
+            tradeReq.setStartCreateTime(StringTimeUtil.fillStart(tradeReq.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(tradeReq.getEndCreateTime())) {
+            tradeReq.setEndCreateTime(StringTimeUtil.fillEnd(tradeReq.getEndCreateTime()));
+        }
+    }
+
+    /**
+     * 销售方
+     *
+     * @param tradeReq
+     * @return
+     */
+    public PageRes<LedgerSell> list(TradeReq tradeReq) {
+        fillPara(tradeReq);
+        if (tradeReq.getPage() != 0 && tradeReq.getPageSize() != 0) {
+            PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        }
+        tradeReq.setUnitType(TradeUnitType.PURCHASE);
+        tradeReq.setUnitTypeTwo(TradeUnitType.SELL);
+        List<LedgerSell> ledgerTradeDto = tradeMapper.list(tradeReq);
+        //字典转换
+        if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
+            changeDict(ledgerTradeDto);
+            return new PageRes<>(ledgerTradeDto);
+        }
+        return new PageRes<>();
+    }
+
+    /**
+     * 按分类统计对账单表头数量
+     *
+     * @param tradeReq 查询参数
+     * @return
+     */
+    public List<TableTop> orderCount(TradeReq tradeReq) {
+        Map<String, Long> map = tradeMapper.countOrder2(tradeReq);
+        TableTop ledgerCountVo;
+        List<TableTop> res = new ArrayList<>();
+        for (LedgerEnum value : LedgerEnum.values()) {
+            ledgerCountVo = new TableTop();
+            ledgerCountVo.setTotal(Math.toIntExact(map.get(value.getLabel())));
+            ledgerCountVo.setName(value.getDesc());
+            ledgerCountVo.setValue(value.getStatus());
+            res.add(ledgerCountVo);
+        }
+        return res;
+    }
+
+    /**
+     * 根据id查询对账单列表
+     *
+     * @param ids 对账单id列表
+     * @return 对账单数据
+     */
+    public List<LedgerSellDto> selectSellList(List<Long> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
+            return new ArrayList<>();
+        }
+        List<LedgerSellDto> ledgerTradeDto = tradeMapper.selectSellIds(ids);
+        changeDict(ledgerTradeDto);
+        return ledgerTradeDto;
+    }
+
+    private LedgerTradeDetailVo getDetail(KwpLedgerTrade ledgerTradeDto) {
+        List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());
+        LedgerTradeDetailVo ledgerTradeDetailVo = new LedgerTradeDetailVo();
+        ledgerTradeDetailVo.setId(ledgerTradeDto.getId());
+        ledgerTradeDetailVo.setTLedgerNo(ledgerTradeDto.getTLedgerNo());
+        ledgerTradeDetailVo.setName(ledgerTradeDto.getName());
+        SysDictResDto trading = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TRADE_TYPE.getType(), ledgerTradeDto.getTrading());
+        ledgerTradeDetailVo.setTrading(ledgerTradeDto.getTrading());
+        ledgerTradeDetailVo.setTradingLabel(Objects.nonNull(trading) ? trading.getLabel() : "");
+        SysDictResDto taxRate = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TAX_RATE.getType(), String.valueOf(ledgerTradeDto.getTaxRate()));
+        ledgerTradeDetailVo.setTaxRate(ledgerTradeDto.getTaxRate());
+        ledgerTradeDetailVo.setTaxRateLabel(Objects.nonNull(taxRate) ? taxRate.getLabel() : "");
+        ledgerTradeDetailVo.setTotalPrice(ledgerTradeDto.getTotalPrice());
+        ledgerTradeDetailVo.setSettlePrice(ledgerTradeDto.getSettlePrice());
+        ledgerTradeDetailVo.setActualPrice(ledgerTradeDto.getActualPrice());
+        ledgerTradeDetailVo.setStartTime(ledgerTradeDto.getStartTime());
+        ledgerTradeDetailVo.setEndTime(ledgerTradeDto.getEndTime());
+        ledgerTradeDetailVo.setRemark(ledgerTradeDto.getRemark());
+        List<Long> collect = kwpLedgerTradeOrders.stream().map(KwpLedgerTradeOrder::getTOrderId).toList();
+        List<OrderDto> detailRes = new ArrayList<>();
+        OrderDetailRes orderDetailById;
+        //查询贸易订单详情
+        for (Long aLong : collect) {
+            orderDetailById = tradeOrderInfoService.getOrderDetailById(aLong);
+            detailRes.add(changeOrder(orderDetailById));
+        }
+        ledgerTradeDetailVo.setOrderList(detailRes);
+        return ledgerTradeDetailVo;
+    }
+
+    private OrderDto changeOrder(OrderDetailRes orderDetailRes) {
+        OrderDto orderDto = new OrderDto();
+        BeanUtils.copyProperties(orderDetailRes, orderDto);
+        List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
+        if (!CollectionUtils.isEmpty(unitInfo)) {
+            for (UnitInfoDetailRes unitInfoDetailRes : unitInfo) {
+                //2-销售
+                if (StringUtils.equals(unitInfoDetailRes.getUnitType(), "2")) {
+                    orderDto.setSupplyEntId(unitInfoDetailRes.getEntId());
+                    orderDto.setSupplyFirmName(unitInfoDetailRes.getFirmName());
+                }
+                //1-采购
+                if (StringUtils.equals(unitInfoDetailRes.getUnitType(), "1")) {
+                    orderDto.setProcureEntId(unitInfoDetailRes.getEntId());
+                    //采购企业名称
+                    orderDto.setProcureFirmName(unitInfoDetailRes.getFirmName());
+                }
+            }
+        }
+        ContractInfo contractInfo = orderDetailRes.getContractInfo();
+        if (Objects.nonNull(contractInfo)) {
+            orderDto.setContractId(contractInfo.getContractId());
+            orderDto.setContractNo(contractInfo.getContractNo());
+            orderDto.setContractName(contractInfo.getContractName());
+            orderDto.setContractSigningWay(contractInfo.getContractSigningWay());
+        }
+        GoodsInfoDetailRes goodsInfo = orderDetailRes.getGoodsInfo();
+        if (Objects.nonNull(goodsInfo)) {
+            orderDto.setGoodsId(goodsInfo.getGoodsId());
+            orderDto.setGoodsSpec(goodsInfo.getSpec());
+            orderDto.setGoodsName(goodsInfo.getName());
+            orderDto.setGoodsType(goodsInfo.getGoodsType());
+            orderDto.setGoodsTypeLabel(goodsInfo.getGoodsTypeLabel());
+            orderDto.setUnit(goodsInfo.getUnit());
+            orderDto.setUnitLabel(goodsInfo.getUnitLabel());
+            orderDto.setUnitPrice(goodsInfo.getUnitPrice());
+            orderDto.setGoodsAmount(goodsInfo.getGoodsAmount());
+            orderDto.setTaxRate(goodsInfo.getTaxRate());
+            orderDto.setTaxRateLabel(goodsInfo.getTaxRateLabel());
+        }
+        List<AddressInfoDetail> addressInfo = orderDetailRes.getAddressInfo();
+        if (!CollectionUtils.isEmpty(addressInfo)) {
+            for (AddressInfoDetail addressInfoDetail : addressInfo) {
+                if (StringUtils.equals(addressInfoDetail.getAddressType(), "1")) {
+                    orderDto.setLoadName(addressInfoDetail.getName());
+                    orderDto.setLoadDetailAddressInfo(addressInfoDetail.getDetailAddress());
+                }
+                if (StringUtils.equals(addressInfoDetail.getAddressType(), "2")) {
+                    orderDto.setUnloadName(addressInfoDetail.getName());
+                    orderDto.setUnloadDetailAddressInfo(addressInfoDetail.getDetailAddress());
+                }
+            }
+        }
+        orderDto.setTOrderId(orderDetailRes.getId());
+        return orderDto;
+    }
+
+    /**
+     * 查询对账单详情
+     *
+     * @param id       对账单id
+     * @return 对账单详情
+     */
+    public LedgerTradeDetailVo queryDetail(Long id) {
+        KwpLedgerTrade ledgerTrade = tradeMapper.selectById(id);
+        orderCheck(ledgerTrade);
+        return getDetail(ledgerTrade);
+    }
+
+    public PageRes<OrderDto> orderList(LedgerListReq ledgerListReq) {
+        PageHelper.startPage(ledgerListReq.getPage(), ledgerListReq.getPageSize());
+        List<KwpLedgerTradeOrder> kwpLedgerLogisticsOrders = tradeOrderService.queryList(ledgerListReq.getIdLong());
+        if (CollectionUtils.isEmpty(kwpLedgerLogisticsOrders)) {
+            return new PageRes<>();
+        }
+        PageInfo<KwpLedgerTradeOrder> pageInfo = new PageInfo<>(kwpLedgerLogisticsOrders);
+        List<OrderDto> detailRes = new ArrayList<>();
+        for (KwpLedgerTradeOrder kwpLedgerLogisticsOrder : kwpLedgerLogisticsOrders) {
+            OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(kwpLedgerLogisticsOrder.getTOrderId());
+            log.info("销售订单:{}", JSONObject.toJSONString(orderDetailById));
+            detailRes.add(changeOrder(orderDetailById));
+        }
+        return PageRes.build(pageInfo, detailRes);
+    }
+
+
+}

+ 68 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/FinanceTask.java

@@ -0,0 +1,68 @@
+package com.sckw.payment.task;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
+import com.sckw.payment.dao.KwpSettlementRecordMapper;
+import com.sckw.payment.dao.KwpSettlementTradeMapper;
+import com.sckw.payment.model.KwpSettlementRecord;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * 财务定时任务
+ *
+ * @author xucaiqin
+ * @date 2023-09-05 19:37:00
+ */
+@Slf4j
+@Component
+@EnableScheduling
+public class FinanceTask {
+    @Resource
+    private KwpSettlementTradeMapper kwpSettlementTradeMapper;
+    @Resource
+    private KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
+    @Resource
+    private KwpSettlementRecordMapper kwpSettlementRecordMapper;
+
+    @Scheduled(cron = "0 0 0 ? * *")
+//    @Scheduled(cron = "0 0/1 * * * ?")
+    public void task() {
+        LocalDate now = LocalDate.now().minusDays(1);
+        log.info("结算记录归档:{}", now);
+        List<KwpSettlementRecord> moneyArchivedDto = kwpSettlementTradeMapper.queryRecord();
+        List<KwpSettlementRecord> kwpSettlementRecords = kwpSettlementLogisticsMapper.queryRecord();
+
+        try {
+            if (!CollectionUtils.isEmpty(moneyArchivedDto)) {
+                for (KwpSettlementRecord kwpSettlementRecord : moneyArchivedDto) {
+                    kwpSettlementRecord.setId(new IdWorker(NumberConstant.ONE).nextId());
+                    kwpSettlementRecord.setOrderType(2);
+                    kwpSettlementRecord.setCreateTime(now);
+                }
+                kwpSettlementRecordMapper.insertBatch(moneyArchivedDto);
+                log.info("贸易归档:{}", JSONObject.toJSONString(moneyArchivedDto));
+            }
+            if (!CollectionUtils.isEmpty(kwpSettlementRecords)) {
+                for (KwpSettlementRecord kwpSettlementRecord : kwpSettlementRecords) {
+                    kwpSettlementRecord.setId(new IdWorker(NumberConstant.ONE).nextId());
+                    kwpSettlementRecord.setOrderType(1);
+                    kwpSettlementRecord.setCreateTime(now);
+                }
+                kwpSettlementRecordMapper.insertBatch(kwpSettlementRecords);
+                log.info("物流归档:{}", JSONObject.toJSONString(kwpSettlementRecords));
+            }
+        } catch (Exception ex) {
+            log.error("结算记录归档异常:{}", ex, ex);
+        }
+    }
+}

+ 122 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -150,6 +150,95 @@
         </where>
         order by kll.generate_time desc
     </select>
+    <select id="list" resultType="com.sckw.payment.model.vo.LedgerLogistics">
+        SELECT kll.id,
+               MAX(kll.l_ledger_no)                                                 AS lLedgerNo,
+               MAX(kll.name)                                                        AS name,
+               MAX(kll.start_time)                                                  AS startTime,
+               MAX(kll.end_time)                                                    AS endTime,
+               MAX(kll.tax_rate)                                                    AS taxRate,
+               MAX(kll.trading)                                                     AS trading,
+               MAX(kll.total_price)                                                 AS totalPrice,
+               MAX(kll.ex_tax_price)                                                AS exTaxPrice,
+               MAX(kll.settle_price)                                                AS settlePrice,
+               MAX(kll.actual_price)                                                AS actualPrice,
+               MAX(kll.success_phone)                                               AS successPhone,
+               MAX(kll.success_user)                                                AS successUser,
+               MAX(kll.url)                                                         AS url,
+               MAX(kll.generate_time)                                               AS generateTime,
+               MAX(kll.receipt_time)                                                AS receiptTime,
+               MAX(kll.remark)                                                      AS remark,
+               MAX(kll.status)                                                      AS status,
+               MAX(kll.order_count)                                                 AS orderCount,
+               MAX(kll.create_by)                                                   AS createBy,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.top_ent_id ELSE NULL END) AS shipperEntId,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.firm_name ELSE NULL END)  AS shipperFirmName,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.top_ent_id ELSE NULL END) AS carrierEntId,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.firm_name ELSE NULL END)  AS carrierFirmName
+        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
+            <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.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                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>
+        GROUP BY kll.id
+        order by generateTime desc
+    </select>
+    <select id="selectIds" resultType="com.sckw.payment.model.vo.LedgerLogistics">
+        SELECT kll.id,
+               MAX(kll.l_ledger_no)                                                 AS lLedgerNo,
+               MAX(kll.name)                                                        AS name,
+               MAX(kll.start_time)                                                  AS startTime,
+               MAX(kll.end_time)                                                    AS endTime,
+               MAX(kll.tax_rate)                                                    AS taxRate,
+               MAX(kll.trading)                                                     AS trading,
+               MAX(kll.total_price)                                                 AS totalPrice,
+               MAX(kll.ex_tax_price)                                                AS exTaxPrice,
+               MAX(kll.settle_price)                                                AS settlePrice,
+               MAX(kll.actual_price)                                                AS actualPrice,
+               MAX(kll.success_phone)                                               AS successPhone,
+               MAX(kll.success_user)                                                AS successUser,
+               MAX(kll.url)                                                         AS url,
+               MAX(kll.generate_time)                                               AS generateTime,
+               MAX(kll.receipt_time)                                                AS receiptTime,
+               MAX(kll.remark)                                                      AS remark,
+               MAX(kll.status)                                                      AS status,
+               MAX(kll.order_count)                                                 AS orderCount,
+               MAX(kll.create_by)                                                   AS createBy,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.top_ent_id ELSE NULL END) AS shipperEntId,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.firm_name ELSE NULL END)  AS shipperFirmName,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.top_ent_id ELSE NULL END) AS carrierEntId,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.firm_name ELSE NULL END)  AS carrierFirmName
+        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 kll.id in
+            <foreach collection="ids" item="id" close=")" open="(" separator=",">
+                #{id,jdbcType=BIGINT}
+            </foreach>
+        </where>
+        GROUP BY kll.id
+        order by generateTime desc
+    </select>
     <select id="countSum" resultType="com.sckw.payment.model.vo.res.LedgerCountSumVo">
         select IFNULL(count(1), 0)  "ledgerCount",
                sum(kll.total_price) "totalPrice"
@@ -255,6 +344,39 @@
         </where>
     </select>
 
+    <select id="countOrder2" resultType="java.util.Map">
+        SELECT count(1)                                    "0",
+               count(IF(kll_distinct.status = 1, 1, NULL)) "1",
+               count(IF(kll_distinct.status = 2, 1, NULL)) "2",
+               count(IF(kll_distinct.status = 3, 1, NULL)) "3",
+               count(IF(kll_distinct.status = 4, 1, NULL)) "4",
+               count(IF(kll_distinct.status = 5, 1, NULL)) "5",
+               count(IF(kll_distinct.status = 6, 1, NULL)) "6"
+        FROM (
+        SELECT DISTINCT kll.id, kll.status
+        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
+            <if test="logisticsReq.trading != null">
+                AND kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="logisticsReq.startCreateTime != null and logisticsReq.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                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>
+        ) kll_distinct
+    </select>
+
     <select id="selectCarrierIds" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
         select
         <include refid="list_col"/>

+ 71 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -152,6 +152,45 @@
         </where>
         order by klt.generate_time desc
     </select>
+    <select id="list" resultType="com.sckw.payment.model.vo.LedgerSell">
+        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 and
+        kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+        inner join kwp_ledger_trade_unit kltu2
+        on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and kltu2.unit_type =
+        #{tradeReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            klt.del_flag = 0
+            and kltu2.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.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}
+                , '%')
+                )
+            </if>
+        </where>
+        order by klt.generate_time desc
+    </select>
     <select id="purchaseList" resultType="com.sckw.payment.model.dto.LedgerPurchaseDto">
         select
         <include refid="purchase_col"/>
@@ -277,6 +316,38 @@
             </if>
         </where>
     </select>
+    <select id="countOrder2" resultType="java.util.Map">
+        SELECT count(1)                                    "0",
+               count(IF(kll_distinct.status = 1, 1, NULL)) "1",
+               count(IF(kll_distinct.status = 2, 1, NULL)) "2",
+               count(IF(kll_distinct.status = 3, 1, NULL)) "3",
+               count(IF(kll_distinct.status = 4, 1, NULL)) "4",
+               count(IF(kll_distinct.status = 5, 1, NULL)) "5",
+               count(IF(kll_distinct.status = 6, 1, NULL)) "6"
+        FROM (
+        SELECT distinct klt.id, klt.status
+        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
+            <if test="tradeReq.trading != null">
+                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}
+            </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>
+        ) kll_distinct
+    </select>
 
     <select id="selectSellIds" resultType="com.sckw.payment.model.dto.LedgerSellDto">
         select klt.id,

+ 28 - 1
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -13,6 +13,7 @@
         <result column="actual_price" jdbcType="DECIMAL" property="actualPrice"/>
         <result column="receipt_time" jdbcType="TIMESTAMP" property="receiptTime"/>
         <result column="remark" jdbcType="VARCHAR" property="remark"/>
+        <result column="trading" jdbcType="VARCHAR" property="trading"/>
         <result column="audit_user" jdbcType="VARCHAR" property="auditUser"/>
         <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone"/>
         <result column="success_user" jdbcType="VARCHAR" property="successUser"/>
@@ -35,6 +36,7 @@
         actual_price,
         receipt_time,
         remark,
+        trading,
         audit_user,
         audit_phone,
         success_user,
@@ -115,7 +117,7 @@
         <if test="settlementReq.trading != null and settlementReq.trading != ''">
             and l.trading = #{settlementReq.trading,jdbcType=VARCHAR}
         </if>
-        <if test="settlementReq.startCreateTime != null and settlementReq.endCreateTime != null">
+        <if test="settlementReq.startCreateTime != null and settlementReq.startCreateTime != ''  and settlementReq.endCreateTime != null  and settlementReq.endCreateTime != ''">
             and s.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
         </if>
         <if test="settlementReq.startReceiptTime != null and settlementReq.endReceiptTime != null">
@@ -284,4 +286,29 @@
             </foreach>
         </where>
     </select>
+
+    <select id="queryRecord" resultType="com.sckw.payment.model.KwpSettlementRecord">
+        SELECT kllu.top_ent_id                                                      entId,
+               sum(IF(kllu.unit_type = 2, ksl.total_price, 0.0))                    totalReceiveMoney,
+               sum(IF(kllu.unit_type = 1, ksl.total_price, 0.0))                    totalPayMoney,
+               sum(IF(kllu.unit_type = 2, ksl.actual_price, 0.0))                   receivedMoney,
+               sum(IF(kllu.unit_type = 1, ksl.actual_price, 0.0))                   paidMoney,
+               sum(IF(kllu.unit_type = 2, ksl.total_price - ksl.actual_price, 0.0)) exactMoney,
+               sum(IF(kllu.unit_type = 1, ksl.total_price - ksl.actual_price, 0.0)) unpaidMoney,
+               sum(
+                       IF
+                           (ksl.receipt_time &lt; now() &amp;&amp; kllu.unit_type = 2,
+                            ksl.total_price - ksl.actual_price, 0.0)
+                   )                                                                overdueExactMoney,
+               sum(
+                       IF
+                           (ksl.receipt_time &lt; now() &amp;&amp; kllu.unit_type = 2,
+                            ksl.total_price - ksl.actual_price, 0.0)
+                   )                                                                overduePaidMoney
+        FROM kwp_settlement_logistics ksl
+                 LEFT JOIN kwp_ledger_logistics_unit kllu ON ksl.l_ledger_id = kllu.l_ledger_id
+            AND kllu.del_flag = 0
+        WHERE ksl.del_flag = 0
+        GROUP BY kllu.top_ent_id
+    </select>
 </mapper>

+ 52 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml

@@ -0,0 +1,52 @@
+<?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.KwpSettlementRecordMapper">
+  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementRecord">
+    <!--@mbg.generated-->
+    <!--@Table kwp_settlement_record-->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="ent_id" jdbcType="BIGINT" property="entId" />
+    <result column="total_receive_money" jdbcType="DECIMAL" property="totalReceiveMoney" />
+    <result column="exact_money" jdbcType="DECIMAL" property="exactMoney" />
+    <result column="received_money" jdbcType="DECIMAL" property="receivedMoney" />
+    <result column="overdue_exact_money" jdbcType="DECIMAL" property="overdueExactMoney" />
+    <result column="total_pay_money" jdbcType="DECIMAL" property="totalPayMoney" />
+    <result column="unpaid_money" jdbcType="DECIMAL" property="unpaidMoney" />
+    <result column="paid_money" jdbcType="DECIMAL" property="paidMoney" />
+    <result column="overdue_paid_money" jdbcType="DECIMAL" property="overduePaidMoney" />
+    <result column="create_time" jdbcType="DATE" property="createTime" />
+    <result column="order_type" jdbcType="INTEGER" property="orderType" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money, 
+    total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
+  </sql>
+
+  <insert id="insertBatch">
+      insert into kwp_settlement_record
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+          id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money,
+          total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
+      </trim>
+      values
+      <foreach collection="list" item="item" separator=",">
+          <trim prefix="(" suffix=")" suffixOverrides=",">
+              #{item.id,jdbcType=BIGINT},
+              #{item.entId,jdbcType=BIGINT},
+              #{item.totalReceiveMoney,jdbcType=DECIMAL},
+              #{item.exactMoney,jdbcType=DECIMAL},
+              #{item.receivedMoney,jdbcType=DECIMAL},
+              #{item.overdueExactMoney,jdbcType=DECIMAL},
+              #{item.totalPayMoney,jdbcType=DECIMAL},
+              #{item.unpaidMoney,jdbcType=DECIMAL},
+              #{item.paidMoney,jdbcType=DECIMAL},
+              #{item.overduePaidMoney,jdbcType=DECIMAL},
+              #{item.createTime,jdbcType=TIMESTAMP},
+              #{item.orderType,jdbcType=INTEGER}
+          </trim>
+      </foreach>
+  </insert>
+    <select id="countByDay">
+    </select>
+</mapper>

+ 27 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -16,6 +16,7 @@
         <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="trading" jdbcType="VARCHAR" property="trading"/>
         <result column="remark" jdbcType="VARCHAR" property="remark"/>
         <result column="status" jdbcType="INTEGER" property="status"/>
         <result column="create_by" jdbcType="BIGINT" property="createBy"/>
@@ -37,6 +38,7 @@
         audit_user,
         audit_phone,
         success_user,
+        trading,
         success_phone,
         remark,
         `status`,
@@ -347,4 +349,29 @@
             </foreach>
         </where>
     </select>
+
+    <select id="queryRecord" resultType="com.sckw.payment.model.KwpSettlementRecord">
+        SELECT kltu.top_ent_id                                                      entId,
+               sum(IF(kltu.unit_type = 2, kst.total_price, 0.0))                    totalReceiveMoney,
+               sum(IF(kltu.unit_type = 1, kst.total_price, 0.0))                    totalPayMoney,
+               sum(IF(kltu.unit_type = 2, kst.actual_price, 0.0))                   receivedMoney,
+               sum(IF(kltu.unit_type = 1, kst.actual_price, 0.0))                   paidMoney,
+               sum(IF(kltu.unit_type = 2, kst.total_price - kst.actual_price, 0.0)) exactMoney,
+               sum(IF(kltu.unit_type = 1, kst.total_price - kst.actual_price, 0.0)) unpaidMoney,
+               sum(
+                       IF
+                           (kst.receipt_time &lt; now() &amp;&amp; kltu.unit_type = 2,
+                            kst.total_price - kst.actual_price, 0.0)
+                   )                                                                overdueExactMoney,
+               sum(
+                       IF
+                           (kst.receipt_time &lt; now() &amp;&amp; kltu.unit_type = 2,
+                            kst.total_price - kst.actual_price, 0.0)
+                   )                                                                overduePaidMoney
+        FROM `kwp_settlement_trade` kst
+                 LEFT JOIN kwp_ledger_trade_unit kltu ON kst.t_ledger_id = kltu.t_ledger_id
+            AND kltu.del_flag = 0
+        WHERE kst.del_flag = 0
+        GROUP BY kltu.top_ent_id
+    </select>
 </mapper>

+ 33 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/controller/KwpGoodsStatisticsController.java

@@ -0,0 +1,33 @@
+package com.sckw.product.controller;
+
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.product.service.KwpGoodsStatisticsService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @desc: 工作台商品统计相关接口
+ * @author: yzc
+ * @date: 2023-07-03 8:28
+ */
+@RestController
+@RequestMapping(value = "/kwpGoodsStatistics")
+@RequiredArgsConstructor
+public class KwpGoodsStatisticsController {
+
+    private final KwpGoodsStatisticsService service;
+
+    /**
+     * @desc: 获取工作台商品列表
+     * @author: yzc
+     * @date: 2023-09-13 18:55
+     * @return: com.sckw.core.web.response.HttpResult
+     */
+    @GetMapping(value = "/workbenchList")
+    public HttpResult workbenchList() {
+        return HttpResult.ok(service.workbenchList());
+    }
+
+}

+ 76 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/WorkbenchGoodsRes.java

@@ -0,0 +1,76 @@
+package com.sckw.product.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @desc: 工作台商品信息响应实体
+ * @author: yzc
+ * @date: 2023-09-13 18:39
+ */
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+public class WorkbenchGoodsRes implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 7648240540364985991L;
+
+
+    /**
+     * 商品id
+     */
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    /**
+     * 供应企业名称
+     */
+    private String supplyFireName;
+
+    /**
+     * 商品类型
+     */
+    private String goodsType;
+
+    /**
+     * 商品类型Label
+     */
+    private String goodsTypeLabel;
+
+    /**
+     * 计量单位(吨、方、件、箱、其他)
+     */
+    private String unit;
+
+    /**
+     * 计量单位lab
+     */
+    private String unitLabel;
+
+    /**
+     * 尺寸大小
+     */
+    private String spec;
+
+    /**
+     * 库存数量
+     */
+    private BigDecimal amount;
+
+    /**
+     * 最低单价
+     */
+    private BigDecimal lowestPrice;
+
+}

+ 17 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -1121,4 +1121,21 @@ public class KwpGoodsService {
         Long count = kwpGoodsMapper.selectCount(wrapper);
         return Objects.isNull(count) ? 0L : count;
     }
+
+    /**
+     * @desc: 获取工作台商品列表
+     * @author: yzc
+     * @date: 2023-09-13 18:38
+     * @return: java.util.List<com.sckw.product.model.KwpGoods>
+     */
+    public List<KwpGoods> getWorkbenchList() {
+        LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpGoods::getEntId, LoginUserHolder.getEntId())
+                .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
+                .eq(KwpGoods::getDelFlag, Global.NO)
+                .orderByDesc(KwpGoods::getCreateTime)
+                .last("LIMIT 10");
+        List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
+        return CollectionUtils.emptyIfNull(list);
+    }
 }

+ 74 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsStatisticsService.java

@@ -0,0 +1,74 @@
+package com.sckw.product.service;
+
+import com.sckw.core.common.enums.enums.DictEnum;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.product.model.KwpGoods;
+import com.sckw.product.model.KwpGoodsPriceRange;
+import com.sckw.product.model.vo.res.WorkbenchGoodsRes;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @desc: 工作台商品统计相关接口
+ * @author: yzc
+ * @date: 2023-09-13 17:57
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class KwpGoodsStatisticsService {
+
+    private final KwpGoodsService service;
+    private final KwpGoodsPriceRangeService priceRangeService;
+
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+
+    /**
+     * @desc: 获取工作台商品列表
+     * @author: yzc
+     * @date: 2023-09-13 18:55
+     * @return: java.util.List<com.sckw.product.model.vo.res.WorkbenchGoodsRes>
+     */
+    public List<WorkbenchGoodsRes> workbenchList() {
+        List<KwpGoods> goodsList = service.getWorkbenchList();
+        if (CollectionUtils.isEmpty(goodsList)) {
+            return Collections.emptyList();
+        }
+        List<WorkbenchGoodsRes> result = new ArrayList<>();
+        List<Long> goodsIds = goodsList.stream().map(KwpGoods::getId).toList();
+        List<Long> supplyEntIds = goodsList.stream().map(KwpGoods::getSupplyEntId).toList();
+        Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = priceRangeService.getByGoodsIds(goodsIds).stream()
+                .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
+        //供应企业信息
+        List<EntCacheResDto> entList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(supplyEntIds)) {
+            entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        }
+        Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+        goodsList.forEach(e -> {
+            WorkbenchGoodsRes goods = BeanUtils.copyProperties(e, WorkbenchGoodsRes.class);
+            goods.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
+                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
+                    .setSupplyFireName(entMap.get(e.getSupplyEntId()));
+            List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
+            if (CollectionUtils.isNotEmpty(priceRanges)) {
+                goods.setLowestPrice(priceRanges.get(0).getPrice());
+            }
+            result.add(goods);
+        });
+        return result;
+    }
+}

+ 13 - 5
sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwOrderStatisticsController.java

@@ -6,10 +6,7 @@ import com.sckw.report.service.KwOrderStatisticsService;
 import lombok.AllArgsConstructor;
 import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @desc: 订单统计相关接口
@@ -31,8 +28,19 @@ public class KwOrderStatisticsController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/workbenchData", produces = MediaType.APPLICATION_JSON_VALUE)
-    public HttpResult select(@RequestBody @Validated WbTOrderDataStsParam params) {
+    public HttpResult workbenchData(@RequestBody @Validated WbTOrderDataStsParam params) {
         return HttpResult.ok(kwOrderStatisticsService.workbenchData(params));
     }
 
+    /**
+     * @desc: 工作台采购订单列表
+     * @author: yzc
+     * @date: 2023-09-13 19:13
+     * @return: com.sckw.core.web.response.HttpResult
+     */
+    @GetMapping(value = "/workbenchPurchaseList", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult workbenchPurchaseList() {
+        return HttpResult.ok(kwOrderStatisticsService.workbenchPurchaseList());
+    }
+
 }

+ 2 - 2
sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/WbTOrderDataStsParam.java

@@ -33,9 +33,9 @@ public class WbTOrderDataStsParam implements Serializable {
      */
     private String unit;
     /**
-     * 统计日期类型(1周、2月)
+     * 统计日期类型(2周、3月)
      */
-    @Range(min = 1, max = 2, message = "非法日期类型")
+    @Range(min = 2, max = 3, message = "非法日期类型")
     @NotNull(message = "日期类型不能为空")
     private Integer dateType;
 

+ 68 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/WorkbenchPurchaseVO.java

@@ -0,0 +1,68 @@
+package com.sckw.report.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @desc: 工作台采购订单列表vo
+ * @author: yzc
+ * @date: 2023-09-13 19:22
+ */
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+public class WorkbenchPurchaseVO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 3393583069721972947L;
+
+    /**
+     * 订单主键
+     */
+    @JsonProperty("tOrderId")
+    private Long tOrderId;
+
+    /**
+     * 订单成交数量
+     */
+    private Double amount;
+
+    /**
+     * 订单单位(吨、方、箱、件)
+     */
+    private String unit;
+
+    private String unitLabel;
+
+    /**
+     * 商品名称
+     */
+    private String goodsName;
+
+    /**
+     * 商品类型
+     */
+    private String goodsType;
+
+    private String goodsTypeLabel;
+
+    /**
+     * 采购企业名称
+     */
+    private String procureFirmName;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd", timezone = "GMT+8")
+    private Date createTime;
+
+}

+ 5 - 1
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java

@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
@@ -90,6 +91,8 @@ public class KwOrderService {
         List<SckwTradeOrder> list = mongoTemplate.find(query, SckwTradeOrder.class);
         List<OrderListRes> result = new ArrayList<>();
         list.forEach(e -> {
+            BigDecimal actualAmount = Objects.isNull(e.getActualAmount()) ? BigDecimal.ZERO : BigDecimal.valueOf(e.getActualAmount());
+            BigDecimal unitPrice = Objects.isNull(e.getUnitPrice()) ? BigDecimal.ZERO : BigDecimal.valueOf(e.getUnitPrice());
             OrderListRes order = BeanUtils.copyProperties(e, OrderListRes.class);
             String loadCityName = Objects.isNull(e.getLoadCityName()) ? "" : e.getLoadCityName();
             String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();
@@ -105,7 +108,8 @@ public class KwOrderService {
                     .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
                     .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
                     .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
-                    .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount()));
+                    .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount()))
+                    .setActualPrice(actualAmount.multiply(unitPrice).doubleValue());
             result.add(order);
         });
         return PageResult.build(page, pageSize, count, result);

+ 63 - 31
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderStatisticsService.java

@@ -1,33 +1,38 @@
 package com.sckw.report.service;
 
 import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.common.enums.enums.DictEnum;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.DateUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.mongo.model.SckwTradeOrder;
+import com.sckw.payment.api.dubbo.PaymentDubboService;
+import com.sckw.payment.api.model.dto.SettlementMoney;
 import com.sckw.product.api.dubbo.GoodsStatisticsService;
 import com.sckw.product.api.model.GoodsNumStsParam;
 import com.sckw.report.model.dto.WorkbenchOrderStsDTO;
 import com.sckw.report.model.vo.TOrderDataStsResVO;
 import com.sckw.report.model.vo.WbTOrderDataStsParam;
 import com.sckw.report.model.vo.WbTOrderDataStsResVO;
+import com.sckw.report.model.vo.WorkbenchPurchaseVO;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
+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 java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @desc: TODO
@@ -43,6 +48,8 @@ public class KwOrderStatisticsService {
 
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private GoodsStatisticsService goodsStatisticsService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private PaymentDubboService paymentDubboService;
 
 
     /**
@@ -68,6 +75,9 @@ public class KwOrderStatisticsService {
         GoodsNumStsParam goodsNumStsParam = new GoodsNumStsParam();
         goodsNumStsParam.setTopEntId(entId).setUnit(unit);
         Long currentGoodsNum = goodsStatisticsService.getOnShelfGoodsNum(goodsNumStsParam);
+        //待付款金额
+        SettlementMoney settlement = Objects.equals(orderType, 1) ?
+                paymentDubboService.countPurchase(entId, dateType) : paymentDubboService.countSell(entId, dateType);
         //订单统计
         WorkbenchOrderStsDTO currentOrderSts = getOrderStsInfo(orderType, unit, currentStart, null);
         BigDecimal currentAmount = BigDecimal.valueOf(currentOrderSts.getOrderAmount());
@@ -76,8 +86,8 @@ public class KwOrderStatisticsService {
                 .setGoodsNum(currentGoodsNum)
                 .setOrderAmount(currentAmount)
                 .setOrderPrice(currentPrice)
+                .setWaitCollectedPrice(new BigDecimal(settlement.getCurrent()))
                 .setNotArrivedAmount(currentAmount.subtract(BigDecimal.valueOf(currentOrderSts.getOrderActualAmount())));
-        //todo 待付款金额
         list.add(currentDataSts);
 
         //上周/上月数据
@@ -93,45 +103,27 @@ public class KwOrderStatisticsService {
                 .setGoodsNum(lastGoodsNum)
                 .setOrderAmount(lastAmount)
                 .setOrderPrice(lastPrice)
+                .setWaitCollectedPrice(new BigDecimal(settlement.getBefore()))
                 .setNotArrivedAmount(lastAmount.subtract(BigDecimal.valueOf(lastOrderSts.getOrderActualAmount())));
-        //todo 待付款金额
         list.add(lastDataSts);
         res.setTOrderDataStsList(list);
-        //环比数据
         //商品数量环比
-        BigDecimal goodsNumRingRate = Objects.isNull(lastGoodsNum) || lastGoodsNum == 0L ? NumberConstant.ONE_HUNDRED :
-                new BigDecimal((currentGoodsNum - lastGoodsNum)).multiply(NumberConstant.ONE_HUNDRED)
-                        .divide(new BigDecimal(lastGoodsNum), 2, RoundingMode.HALF_UP);
+        BigDecimal goodsNumRingRate = getRingRate(new BigDecimal(currentGoodsNum), new BigDecimal(lastGoodsNum));
         boolean goodsNumFlag = goodsNumRingRate.compareTo(BigDecimal.ZERO) >= 0;
         goodsNumRingRate = goodsNumRingRate.abs();
         //订单总量环比
-        BigDecimal orderAmountRingRate = lastAmount.compareTo(BigDecimal.ZERO) == 0 ? NumberConstant.ONE_HUNDRED :
-                (currentAmount.subtract(lastAmount)).multiply(NumberConstant.ONE_HUNDRED)
-                        .divide(lastAmount, 2, RoundingMode.HALF_UP);
+        BigDecimal orderAmountRingRate = getRingRate(currentAmount, lastAmount);
         boolean orderAmountFlag = orderAmountRingRate.compareTo(BigDecimal.ZERO) >= 0;
         orderAmountRingRate = orderAmountRingRate.abs();
         //订单总金额环比
-        BigDecimal orderPriceRingRate = lastPrice.compareTo(BigDecimal.ZERO) == 0 ? NumberConstant.ONE_HUNDRED :
-                (currentPrice.subtract(lastPrice)).multiply(NumberConstant.ONE_HUNDRED)
-                        .divide(lastPrice, 2, RoundingMode.HALF_UP);
+        BigDecimal orderPriceRingRate = getRingRate(currentPrice, lastPrice);
         boolean orderPriceFlag = orderPriceRingRate.compareTo(BigDecimal.ZERO) >= 0;
         orderPriceRingRate = orderPriceRingRate.abs();
         //未到货量环比
-        BigDecimal currentNotArrived = currentDataSts.getNotArrivedAmount();
-        BigDecimal lastNotArrived = lastDataSts.getNotArrivedAmount();
-        BigDecimal notArrivedAmountRingRate = lastNotArrived.compareTo(BigDecimal.ZERO) == 0 ? NumberConstant.ONE_HUNDRED :
-                (currentNotArrived.subtract(lastNotArrived)).multiply(NumberConstant.ONE_HUNDRED)
-                        .divide(lastNotArrived, 2, RoundingMode.HALF_UP);
+        BigDecimal notArrivedAmountRingRate = getRingRate(currentDataSts.getNotArrivedAmount(), lastDataSts.getNotArrivedAmount());
         boolean notArrivedAmountFlag = notArrivedAmountRingRate.compareTo(BigDecimal.ZERO) >= 0;
         notArrivedAmountRingRate = notArrivedAmountRingRate.abs();
-        //待付款金额环比
-        BigDecimal currentWaitPrice = currentDataSts.getWaitCollectedPrice();
-        BigDecimal lastWaitPrice = lastDataSts.getWaitCollectedPrice();
-        BigDecimal waitCollectedPriceRingRate = lastWaitPrice.compareTo(BigDecimal.ZERO) == 0 ? NumberConstant.ONE_HUNDRED :
-                (currentWaitPrice.subtract(lastWaitPrice)).multiply(NumberConstant.ONE_HUNDRED)
-                        .divide(lastWaitPrice, 2, RoundingMode.HALF_UP);
-        boolean waitCollectedPriceFlag = waitCollectedPriceRingRate.compareTo(BigDecimal.ZERO) >= 0;
-        waitCollectedPriceRingRate = waitCollectedPriceRingRate.abs();
+
         res.setGoodsNumRingRate(goodsNumRingRate)
                 .setGoodsNumFlag(goodsNumFlag)
                 .setOrderAmountRingRate(orderAmountRingRate)
@@ -140,8 +132,18 @@ public class KwOrderStatisticsService {
                 .setOrderPriceFlag(orderPriceFlag)
                 .setNotArrivedAmountRingRate(notArrivedAmountRingRate)
                 .setNotArrivedAmountFlag(notArrivedAmountFlag)
-                .setWaitCollectedPriceRingRate(waitCollectedPriceRingRate)
-                .setWaitCollectedPriceFlag(waitCollectedPriceFlag);
+                .setWaitCollectedPriceRingRate(new BigDecimal(settlement.getPercent().replace("%", "")))
+                .setWaitCollectedPriceFlag(Objects.equals(settlement.getFlag(), 1));
+        return res;
+    }
+
+    private BigDecimal getRingRate(BigDecimal current, BigDecimal last) {
+        BigDecimal res;
+        if (last.compareTo(BigDecimal.ZERO) == 0) {
+            res = (current.subtract(last)).compareTo(BigDecimal.ZERO) != 0 ? NumberConstant.ONE_HUNDRED : BigDecimal.ZERO;
+        } else {
+            res = (current.subtract(last)).multiply(NumberConstant.ONE_HUNDRED).divide(last, 2, RoundingMode.HALF_UP);
+        }
         return res;
     }
 
@@ -184,4 +186,34 @@ public class KwOrderStatisticsService {
         }
         return mappedResults.get(0);
     }
+
+    /**
+     * @desc: 工作台采购订单列表
+     * @author: yzc
+     * @date: 2023-09-13 19:37
+     * @return: java.util.List<com.sckw.report.model.vo.WorkbenchPurchaseVO>
+     */
+    public List<WorkbenchPurchaseVO> workbenchPurchaseList() {
+        Long entId = LoginUserHolder.getEntId();
+        Criteria criteria = new Criteria();
+        criteria.and("procureTopEntId").is(entId)
+                .and("status").nin(0, 2, 7)
+                .and("delFlag").is(0);
+        Query query = new Query();
+        query.addCriteria(criteria)
+                .with(Sort.by(Sort.Direction.DESC, "createTime"))
+                .limit(10);
+        List<SckwTradeOrder> orders = mongoTemplate.find(query, SckwTradeOrder.class);
+        if (CollectionUtils.isEmpty(orders)) {
+            return Collections.emptyList();
+        }
+        List<WorkbenchPurchaseVO> result = new ArrayList<>();
+        orders.forEach(e -> {
+            WorkbenchPurchaseVO vo = BeanUtils.copyProperties(e, WorkbenchPurchaseVO.class);
+            vo.setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
+                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()));
+            result.add(vo);
+        });
+        return result;
+    }
 }

+ 5 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/vo/OrderListRes.java

@@ -155,6 +155,11 @@ public class OrderListRes {
      * 实际交付量
      */
     private Double actualAmount;
+
+    /**
+     * 实际订单金额
+     */
+    private Double actualPrice;
     /**
      * 归属项目
      */

+ 20 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java

@@ -17,6 +17,7 @@ import com.sckw.transport.model.dto.StopOrderTakingDTO;
 import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
 import com.sckw.transport.model.param.ConsignOrderQuery;
 import com.sckw.transport.model.param.DriverParam;
+import com.sckw.transport.model.param.LogisticsOrderStatisticsParam;
 import com.sckw.transport.model.vo.execlVo.ConsignOrderExcelVo;
 import com.sckw.transport.service.ConsignOrderService;
 import jakarta.servlet.http.HttpServletResponse;
@@ -276,6 +277,7 @@ public class ConsignOrderController {
      */
     @RequestMapping(value = "/commitConsignOrderFinish", method = RequestMethod.POST)
     public HttpResult commitConsignOrderFinish(@Validated @RequestBody OrderFinishDTO orderFinishDTO) {
+        log.error("托运订单-完结订单:订单 {}", JSONObject.toJSONString(orderFinishDTO));
         try {
             return consignOrderService.commitConsignOrderFinish(orderFinishDTO);
         } catch (Exception e) {
@@ -330,4 +332,22 @@ public class ConsignOrderController {
         }
     }
 
+
+    /**
+     * 工作台-物流运输数据统计
+     *
+     * @return
+     */
+    @RequestMapping(value = "/workbenchLogisticsOrderStatistics", method = RequestMethod.POST)
+    public HttpResult workbenchLogisticsOrderStatistics(@RequestBody LogisticsOrderStatisticsParam logisticsOrderStatistics) {
+        log.info("工作台-物流运输数据统计 {}", JSONObject.toJSONString(logisticsOrderStatistics));
+        try {
+            return consignOrderService.workbenchLogisticsOrderStatistics(logisticsOrderStatistics);
+        } catch (Exception e) {
+            log.error("工工作台-托运业务统计 error:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+
 }

+ 18 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/operationManagement/ManagementLogisticsOrderController.java

@@ -6,6 +6,7 @@ import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.config.easyexcel.RequestHolder;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.transport.model.param.LogisticsOrderQuery;
 import com.sckw.transport.model.param.ManagementLogisticsOrderQuery;
 import com.sckw.transport.model.vo.execlVo.ManagementLogisticsOrderExcelVo;
 import com.sckw.transport.service.ManagementLogisticsOrderService;
@@ -110,4 +111,21 @@ public class ManagementLogisticsOrderController {
         }
     }
 
+
+    /**
+     * 运营端-物流订单-获取运单信息
+     *
+     * @param orderDto
+     * @return
+     */
+    @RequestMapping(value = "/getCarWaybillByOrder", method = RequestMethod.POST)
+    public HttpResult getCarWaybillByOrder(@Valid @RequestBody LogisticsOrderQuery orderDto) {
+        log.info("运营端-物流订单-获取车辆运单 query {}", JSONObject.toJSONString(orderDto));
+        try {
+            return managementLogisticsOrderService.getCarWaybillByOrder(orderDto);
+        } catch (Exception e) {
+            log.error("运营端-物流订单-获取车辆运单失败:订单ids {},error {} ", JSONObject.toJSONString(orderDto), e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
 }

+ 5 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -327,6 +327,11 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     StatisticsByOrderVO selectStatisticsByOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
 
+    List<LogisticsOrderStatisticsVO> workbenchLogisticsOrderStatisticsByMonth(@Param("id") Long id, @Param("statusList") List<Integer> statusList,@Param("type") Integer type, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
+
+
+    List<LogisticsOrderStatisticsVO> workbenchLogisticsOrderStatisticsByDays(@Param("id") Long id, @Param("statusList") List<Integer> statusList,@Param("type") Integer type, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
+
 
 //    List<TableTops> countAppLogisticsOrderListByStatus(@Param("type") String type,@Param("entId") Long entId
 //    );

+ 30 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderQuery.java

@@ -0,0 +1,30 @@
+package com.sckw.transport.model.param;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.sckw.core.model.page.PageRequest;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 运营端查询
+ * @date 2023-09-13 13:09:37
+ */
+@Data
+public class LogisticsOrderQuery extends PageRequest implements Serializable {
+//    @JsonProperty("orderNo")
+//    @NotNull(message = "单据编号不能为空")
+//    private String orderNo;
+
+    @JsonProperty("ids")
+    @NotNull(message = "数据ids不能为空")
+    private String ids;
+    /**
+     * 1 托运 2 承运
+     */
+    @JsonProperty("type")
+//    @NotNull(message = "单据类型不能为空")
+    private String type;
+}

+ 30 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderStatisticsParam.java

@@ -0,0 +1,30 @@
+package com.sckw.transport.model.param;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.annotations.SerializedName;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+/**
+ * @author lfdc
+ * @description 工作台物流运输统计param
+ * @date 2023-09-12 17:09:04
+ */
+@Data
+public class LogisticsOrderStatisticsParam {
+    /**
+     * 统计周期纬度 1日 2周 3月 4年
+     */
+    @NotBlank(message = "类型不能为空")
+    @JsonProperty("dateType")
+    @SerializedName("dateType")
+    private String dateType;
+
+//    /**
+//     * 统计因子 1,4,5,6
+//     */
+//    @NotBlank(message = "统计因子")
+//    @JsonProperty("type")
+//    @SerializedName("type")
+//    private String types;
+}

+ 26 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsOrderStatisticsVO.java

@@ -0,0 +1,26 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description 工作台首页图形统计VO
+ * @date 2023-09-13 09:09:24
+ */
+@Data
+public class LogisticsOrderStatisticsVO {
+    /**
+     * 统计时间
+     */
+    private String dateTime;
+    /**
+     * 统计数
+     */
+    private Integer num;
+    /**
+     * 统计金额
+     */
+    private BigDecimal totalAmount;
+}

+ 38 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsByOrderVO.java

@@ -60,4 +60,42 @@ public class StatisticsByOrderVO implements Serializable {
      */
     @JsonProperty("flag")
     private Integer flag;
+
+
+    /**
+     * 环比上次待分配量
+     */
+    @JsonProperty("lastWaitingAmount")
+    private BigDecimal lastWaitingAmount;
+
+    /**
+     * 环比上次已委托量(上游给他分配的量)-承运量
+     */
+    @JsonProperty("lastAmount")
+    private BigDecimal lastAmount;
+
+    /**
+     * 环比上次已委托量(自己承运,给下游司机分配的量)-委托给下游的量
+     */
+    @JsonProperty("lastEntrustAmount")
+    private BigDecimal lastEntrustAmount;
+
+    /**
+     * 环比上次分包量
+     */
+    @JsonProperty("lastSubcontractAmount")
+    private BigDecimal lastSubcontractAmount;
+
+    /**
+     * 环比上次运价
+     */
+    @JsonProperty("lastPrice")
+    private BigDecimal lastPrice;
+
+    /**
+     * 环比上次运输总额
+     */
+    @JsonProperty("lastTotalPrice")
+    private BigDecimal lastTotalPrice;
+
 }

+ 44 - 29
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java

@@ -1424,7 +1424,7 @@ public class AcceptCarriageOrderService {
             });
         }
         /**是否是一级订单,是->推送至贸易,否,数据推送至物流订单上级*/
-        if (logisticsOrder.getPid() != null) {
+        if (logisticsOrder.getPid() == null && logisticsOrder.getType().equals("1") ) {
             //数据推送至贸易订单
             CompleteLogisticsOrderParam tradeOrder = new CompleteLogisticsOrderParam();
             //todo 2023-09-07 修改为传递页面传输值  不传递总量
@@ -2347,40 +2347,45 @@ public class AcceptCarriageOrderService {
             vo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
             vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
             if (vo.getTOrderId() != null) {
-                OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
-                if (orderDetailRes != null) {
-                    List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
-                    for (UnitInfoDetailRes detailRes : unitInfo) {
-                        if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
-                            vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
-                            vo.setShipmentsUnit(detailRes.getFirmName());
-                        } else {
-                            vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
-                            vo.setReceiveGoodsUnit(detailRes.getFirmName());
-                        }
-                    }
-                }
-            }
-            vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
-            String tOrderId = vo.getTOrderId();
-            if (StringUtils.isNotBlank(tOrderId)) {
-                OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
-                if (orderDetailById != null) {
-                    List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
-                    if (CollectionUtils.isNotEmpty(unitInfo)) {
+                try {
+                    OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
+                    if (orderDetailRes != null) {
+                        List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
                         for (UnitInfoDetailRes detailRes : unitInfo) {
-                            if ("1".equals(detailRes.getUnitType())) {
-                                vo.setReceiveGoodsUnit(detailRes.getFirmName());
-                                vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
-                            }
-                            if ("2".equals(detailRes.getUnitType())) {
+                            if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
+                                vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
                                 vo.setShipmentsUnit(detailRes.getFirmName());
-                                vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                            } else {
+                                vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
+                                vo.setReceiveGoodsUnit(detailRes.getFirmName());
                             }
                         }
                     }
+                } catch (NumberFormatException e) {
+//                    throw new RuntimeException(e);
+                    log.info("查询失败:{},信息:{}",vo.getTOrderId(),e.getMessage(),e);
                 }
             }
+            vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
+//            String tOrderId = vo.getTOrderId();
+//            if (StringUtils.isNotBlank(tOrderId)) {
+//                OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
+//                if (orderDetailById != null) {
+//                    List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
+//                    if (CollectionUtils.isNotEmpty(unitInfo)) {
+//                        for (UnitInfoDetailRes detailRes : unitInfo) {
+//                            if ("1".equals(detailRes.getUnitType())) {
+//                                vo.setReceiveGoodsUnit(detailRes.getFirmName());
+//                                vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+//                            }
+//                            if ("2".equals(detailRes.getUnitType())) {
+//                                vo.setShipmentsUnit(detailRes.getFirmName());
+//                                vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+//                            }
+//                        }
+//                    }
+//                }
+//            }
 
         }
         return PageRes.build(pageInfo, list);
@@ -2699,7 +2704,17 @@ public class AcceptCarriageOrderService {
         StatisticsByOrderVO lastWeek = logisticsOrderMapper.selectStatisticsByOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType());
         //环比计算
         StatisticsByOrderVO vo = new StatisticsByOrderVO();
-        BeanUtils.copyProperties(currentWeek, vo);
+        vo.setWaitingAmount(currentWeek.getWaitingAmount());
+        vo.setAmount(currentWeek.getAmount());
+        vo.setEntrustAmount(currentWeek.getEntrustAmount());
+        vo.setSubcontractAmount(currentWeek.getSubcontractAmount());
+        vo.setTotalPrice(currentWeek.getTotalPrice());
+
+        vo.setLastWaitingAmount(lastWeek.getWaitingAmount());
+        vo.setLastAmount(lastWeek.getAmount());
+        vo.setLastEntrustAmount(lastWeek.getEntrustAmount());
+        vo.setLastSubcontractAmount(lastWeek.getSubcontractAmount());
+        vo.setLastTotalPrice(lastWeek.getTotalPrice());
         Integer flag = 1;
         BigDecimal chainRatio = new BigDecimal("0.00");
         if (currentWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0

+ 104 - 24
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -1,5 +1,7 @@
 package com.sckw.transport.service;
 
+import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -47,6 +49,7 @@ import com.sckw.transport.model.dto.*;
 import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
 import com.sckw.transport.model.param.ConsignOrderQuery;
 import com.sckw.transport.model.param.DriverParam;
+import com.sckw.transport.model.param.LogisticsOrderStatisticsParam;
 import com.sckw.transport.model.vo.*;
 import com.sckw.transport.model.vo.execlVo.ConsignOrderExcelVo;
 import jakarta.annotation.Resource;
@@ -62,11 +65,14 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.text.ParseException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.sckw.excel.utils.DateUtil.DEF_DATE_FORMAT;
+
 /**
  * @author lfdc
  * @description 托运订单service
@@ -814,7 +820,7 @@ public class ConsignOrderService {
             });
         }
         /**是否是一级订单,是->推送至贸易,否,数据推送至物流订单上级*/
-        if (logisticsOrder.getPid() != null) {
+        if (logisticsOrder.getPid() == null && logisticsOrder.getType().equals("1")) {
             //数据推送至贸易订单
             CompleteLogisticsOrderParam tradeOrder = new CompleteLogisticsOrderParam();
             //todo 2023-09-07 修改为不传递总量,只传递当前单据页面传递值
@@ -1677,38 +1683,47 @@ public class ConsignOrderService {
             vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
             vo.setPriceLabel(vo.getPriceType() == null ? null : priceDictData.get(vo.getPriceType()));
             if (vo.getTOrderId() != null) {
-                OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
-                if (orderDetailRes != null) {
-                    List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
-                    for (UnitInfoDetailRes detailRes : unitInfo) {
-                        if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
-                            vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
-                            vo.setShipmentsUnit(detailRes.getFirmName());
-                        } else {
-                            vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
-                            vo.setReceiveGoodsUnit(detailRes.getFirmName());
+                try {
+                    OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
+                    if (orderDetailRes != null) {
+                        List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
+                        for (UnitInfoDetailRes detailRes : unitInfo) {
+                            if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
+                                vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
+                                vo.setShipmentsUnit(detailRes.getFirmName());
+                            } else {
+                                vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
+                                vo.setReceiveGoodsUnit(detailRes.getFirmName());
+                            }
                         }
                     }
+                } catch (Exception e) {
+//                    throw new RuntimeException(e);
+                    log.info(vo.getTOrderId() + "查询错误:{}", e.getMessage(), e);
                 }
             }
             vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
             String tOrderId = vo.getTOrderId();
             if (StringUtils.isNotBlank(tOrderId)) {
-                OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
-                if (orderDetailById != null) {
-                    List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
-                    if (CollectionUtils.isNotEmpty(unitInfo)) {
-                        for (UnitInfoDetailRes detailRes : unitInfo) {
-                            if ("1".equals(detailRes.getUnitType())) {
-                                vo.setReceiveGoodsUnit(detailRes.getFirmName());
-                                vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
-                            }
-                            if ("2".equals(detailRes.getUnitType())) {
-                                vo.setShipmentsUnit(detailRes.getFirmName());
-                                vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                try {
+                    OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
+                    if (orderDetailById != null) {
+                        List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
+                        if (CollectionUtils.isNotEmpty(unitInfo)) {
+                            for (UnitInfoDetailRes detailRes : unitInfo) {
+                                if ("1".equals(detailRes.getUnitType())) {
+                                    vo.setReceiveGoodsUnit(detailRes.getFirmName());
+                                    vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                                }
+                                if ("2".equals(detailRes.getUnitType())) {
+                                    vo.setShipmentsUnit(detailRes.getFirmName());
+                                    vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                                }
                             }
                         }
                     }
+                } catch (Exception e) {
+                    log.info(vo.getTOrderId() + "查询错误:{}", e.getMessage(), e);
                 }
             }
 
@@ -2019,6 +2034,17 @@ public class ConsignOrderService {
         StatisticsByOrderVO lastStatisticsByOrderVO = kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
         //全部的未履约量
         BigDecimal lastWaitingAmount = lastStatistics.getWaitingAmount().add(lastStatisticsByOrderVO.getWaitingAmount());
+        BigDecimal lastAmount = lastStatistics.getAmount().add(lastStatisticsByOrderVO.getAmount());
+        BigDecimal lastEntrustAmount = lastStatistics.getEntrustAmount().add(lastStatisticsByOrderVO.getEntrustAmount());
+        BigDecimal lastSubcontractAmount = lastStatistics.getSubcontractAmount().add(lastStatisticsByOrderVO.getSubcontractAmount());
+        BigDecimal lastTotalPrice = lastStatistics.getTotalPrice().add(lastStatisticsByOrderVO.getTotalPrice());
+
+        vo.setLastWaitingAmount(lastWaitingAmount);
+        vo.setLastAmount(lastAmount);
+        vo.setLastEntrustAmount(lastEntrustAmount);
+        vo.setLastSubcontractAmount(lastSubcontractAmount);
+        vo.setLastTotalPrice(lastTotalPrice);
+
         //环比计算
         BigDecimal chainRatio = new BigDecimal("0.00");
         Integer flag = 1;
@@ -2031,7 +2057,7 @@ public class ConsignOrderService {
         } else if (lastWaitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
             chainRatio = new BigDecimal("100.00").subtract(chainRatio);
         } else {
-            chainRatio = (waitingAmount.subtract(lastWaitingAmount)).divide(lastWaitingAmount,NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
+            chainRatio = (waitingAmount.subtract(lastWaitingAmount)).divide(lastWaitingAmount, NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
                     .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
         }
         if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
@@ -2042,4 +2068,58 @@ public class ConsignOrderService {
         httpResult.setData(vo);
         return httpResult;
     }
+
+
+    /**
+     * 工作台-物流运输数据统计
+     *
+     * @return
+     */
+    public HttpResult workbenchLogisticsOrderStatistics(LogisticsOrderStatisticsParam logisticsOrderStatistics) {
+//        List<String> stringList = StringUtils.splitStrToList(logisticsOrderStatistics.getTypes(), String.class);
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
+        if (entCacheResDto == null) {
+            return HttpResult.ok();
+        }
+        Long id = entCacheResDto.getId();
+        //获取完结的单据-排除掉不做统计中的数据
+        List<Integer> statusList = new ArrayList<>();
+        statusList.add(LogisticsOrderEnum.TO_BE_PLANNED.getCode());
+        statusList.add(LogisticsOrderEnum.PENDING_ORDER.getCode());
+        statusList.add(LogisticsOrderEnum.WAIT_DELIVERY.getCode());
+        statusList.add(LogisticsOrderEnum.IN_TRANSIT.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
+
+        /**1.目前只统计承运单位属性的数据
+         * 2.月统计->默认当前往前推12个月
+         * 3.日统计->默认当前往前推30天*/
+        if (String.valueOf(NumberConstant.THREE).equals(logisticsOrderStatistics.getDateType())) {
+            //本月
+            //开始时间
+            DateTime dateTime = cn.hutool.core.date.DateUtil.truncate(new Date(), DateField.MONTH);
+            LocalDateTime localDateTime = dateTime.toLocalDateTime().minusMonths(11);
+            String dateStart = cn.hutool.core.date.DateUtil.format(localDateTime, DEF_DATE_FORMAT);
+            //结束时间
+            String dateEnd = cn.hutool.core.date.DateUtil.format(dateTime, DEF_DATE_FORMAT);
+
+            List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByMonth(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
+            return HttpResult.ok(list);
+        } else if (String.valueOf(NumberConstant.ONE).equals(logisticsOrderStatistics.getDateType())) {
+            //开始时间
+            String format = cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), DEF_DATE_FORMAT);
+            String dateStart = null;
+            try {
+                dateStart = DateUtil.getThirtyDaysDate(format, 29);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+            //结束时间
+            String dateEnd = DateUtil.getLastWeekDateEndToString(0);
+            List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByDays(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
+            return HttpResult.ok(list);
+        }
+        return null;
+    }
 }

+ 121 - 27
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementLogisticsOrderService.java

@@ -9,13 +9,16 @@ import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.CarWaybillEnum;
 import com.sckw.core.model.enums.LogisticsOrderEnum;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.page.PageResult;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.utils.DateUtil;
 import com.sckw.mongo.model.TableTops;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.OrderDetailRes;
@@ -25,7 +28,9 @@ import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.*;
+import com.sckw.transport.model.param.LogisticsOrderQuery;
 import com.sckw.transport.model.param.ManagementLogisticsOrderQuery;
+import com.sckw.transport.model.vo.CarWaybillVO;
 import com.sckw.transport.model.vo.ManagementLogsiticsOrderVO;
 import com.sckw.transport.model.vo.OrderDetailVO;
 import com.sckw.transport.model.vo.execlVo.ManagementLogisticsOrderExcelVo;
@@ -82,6 +87,12 @@ public class ManagementLogisticsOrderService {
     @Autowired
     public KwtWaybillOrderMapper waybillOrderMapper;
 
+    @Autowired
+    public KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
+
+    @Autowired
+    public KwtWaybillOrderTrackMapper waybillOrderTrackMapper;
+
     /**
      * @param query
      * @return
@@ -156,39 +167,28 @@ public class ManagementLogisticsOrderService {
             vo.setStatusLabel(LogisticsOrderEnum.getName(vo.getStatus()));
             vo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
             vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
-            if (vo.getTOrderId() != null) {
-                OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
-                if (orderDetailRes != null) {
-                    List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
-                    for (UnitInfoDetailRes detailRes : unitInfo) {
-                        if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
-                            vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
-                            vo.setShipmentsUnit(detailRes.getFirmName());
-                        } else {
-                            vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
-                            vo.setReceiveGoodsUnit(detailRes.getFirmName());
-                        }
-                    }
-                }
-            }
             vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
             String tOrderId = vo.getTOrderId();
             if (StringUtils.isNotBlank(tOrderId)) {
-                OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
-                if (orderDetailById != null) {
-                    List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
-                    if (CollectionUtils.isNotEmpty(unitInfo)) {
-                        for (UnitInfoDetailRes detailRes : unitInfo) {
-                            if ("1".equals(detailRes.getUnitType())) {
-                                vo.setReceiveGoodsUnit(detailRes.getFirmName());
-                                vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
-                            }
-                            if ("2".equals(detailRes.getUnitType())) {
-                                vo.setShipmentsUnit(detailRes.getFirmName());
-                                vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                try {
+                    OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
+                    if (orderDetailById != null) {
+                        List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
+                        if (CollectionUtils.isNotEmpty(unitInfo)) {
+                            for (UnitInfoDetailRes detailRes : unitInfo) {
+                                if ("1".equals(detailRes.getUnitType())) {
+                                    vo.setReceiveGoodsUnit(detailRes.getFirmName());
+                                    vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                                }
+                                if ("2".equals(detailRes.getUnitType())) {
+                                    vo.setShipmentsUnit(detailRes.getFirmName());
+                                    vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
+                                }
                             }
                         }
                     }
+                } catch (NumberFormatException e) {
+                    System.out.println("查询贸易订单失败!" + tOrderId + ";" + e.getMessage());
                 }
             }
 
@@ -537,4 +537,98 @@ public class ManagementLogisticsOrderService {
         httpResult.setData(orderDetailVO);
         return httpResult;
     }
+
+    public HttpResult getCarWaybillByOrder(LogisticsOrderQuery orderDto) {
+        List<Long> list = StringUtils.splitStrToList(orderDto.getIds(), Long.class);
+        if (CollectionUtils.isEmpty(list)) {
+            return HttpResult.ok();
+        }
+        List<CarWaybillVO> returnList = new ArrayList<>();
+        list = list.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
+        for (Long id : list) {
+            KwtLogisticsOrder order = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
+                    .eq(StringUtils.isNotBlank(id), KwtLogisticsOrder::getId, id)
+            );
+            if (ObjectUtils.isEmpty(order)) {
+                continue;
+            }
+            List<KwtWaybillOrder> kwtWaybillOrders = waybillOrderMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrder>()
+                    .eq(StringUtils.isNotBlank(order.getId()), KwtWaybillOrder::getLOrderId, order.getId())
+                    .orderByDesc(KwtWaybillOrder::getCreateTime));
+
+            if (CollectionUtils.isNotEmpty(kwtWaybillOrders)) {
+                for (KwtWaybillOrder kwtWaybillOrder : kwtWaybillOrders) {
+                    CarWaybillVO carWaybillVo = new CarWaybillVO();
+                    KwtWaybillOrderTicket loadTicket = waybillOrderTicketMapper.selectOne(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
+                            .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getId())
+                            .eq(KwtWaybillOrderTicket::getType, NumberConstant.ONE));
+                    KwtWaybillOrderTicket unloadTicket = waybillOrderTicketMapper.selectOne(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
+                            .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getId())
+                            .eq(KwtWaybillOrderTicket::getType, NumberConstant.TWO));
+                    //合理损耗
+                    BigDecimal loss = order.getLoss() == null ? new BigDecimal("0.00") : order.getLoss();
+                    /**亏吨量/吨->装货量-卸货量
+                     * 合理损耗值=装货量*合理损耗
+                     扣亏量/吨->亏吨量-合理损耗值
+                     */
+                    BigDecimal loadAmount = kwtWaybillOrder.getLoadAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getLoadAmount();
+                    //已委托量
+                    BigDecimal entrustAmount = kwtWaybillOrder.getEntrustAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getEntrustAmount();
+                    //合理损耗值
+                    BigDecimal multiply = loadAmount.multiply(loss.divide(BigDecimal.valueOf(1000L)));
+                    //亏吨量
+                    BigDecimal defectiveWeigh = kwtWaybillOrder.getDeficitAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getDeficitAmount();
+                    //扣亏量/吨
+                    BigDecimal deduct = defectiveWeigh.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : defectiveWeigh.subtract(multiply);
+                    carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
+                    carWaybillVo.setWOrderNo(order.getLOrderNo());
+                    carWaybillVo.setTruckNo(kwtWaybillOrder.getTruckNo());
+                    carWaybillVo.setStatus(String.valueOf(kwtWaybillOrder.getStatus()));
+                    carWaybillVo.setStatusLabel(CarWaybillEnum.getName(kwtWaybillOrder.getStatus()));
+                    carWaybillVo.setWaybillType(kwtWaybillOrder.getType());
+                    carWaybillVo.setDriverName(kwtWaybillOrder.getDriverName());
+                    //todo 取mongo
+//                SckwWaybillOrder sckwWaybillOrder = mongoTemplate.findById(kwtWaybillOrder.getId(), SckwWaybillOrder.class);
+                    /** 2023-07-24 原值为承运车队-去除后更换展示为承运公司*/
+//                carWaybillVo.setConsignMotorcade(sckwWaybillOrder == null ? null : sckwWaybillOrder.getCarrierFirmName());
+                    //派车量
+                    carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
+                    carWaybillVo.setSendCarDate(DateUtil.getDateTime(kwtWaybillOrder.getCreateTime()));
+                    if (loadTicket != null) {
+                        carWaybillVo.setLoadAmount(loadTicket.getAmount() == null ? null : String.valueOf(loadTicket.getAmount()));
+                        carWaybillVo.setLoadDateTime(loadTicket.getOperateTime() == null ? null : DateUtil.getDateTime(loadTicket.getOperateTime()));
+                    } else {
+                        carWaybillVo.setLoadAmount(null);
+                        carWaybillVo.setLoadDateTime(null);
+                    }
+                    if (unloadTicket != null) {
+                        carWaybillVo.setUnloadAmount(unloadTicket.getAmount() == null ? null : String.valueOf(unloadTicket.getAmount()));
+                        carWaybillVo.setUnloadDateTime(unloadTicket.getOperateTime() == null ? null : DateUtil.getDateTime(unloadTicket.getOperateTime()));
+                    } else {
+                        carWaybillVo.setUnloadAmount(null);
+                        carWaybillVo.setUnloadDateTime(null);
+                    }
+                    /**亏吨量/吨->装货量-卸货量
+                     扣亏量/吨->亏吨量-合理损耗*/
+                    carWaybillVo.setDefectiveWeigh(kwtWaybillOrder.getDeficitAmount() == null ? null : String.valueOf(kwtWaybillOrder.getDeficitAmount()));
+                    carWaybillVo.setDeduct(deduct);
+                    carWaybillVo.setCreateTime(kwtWaybillOrder.getCreateTime());
+//                carWaybillVo.setAppointor(remoteSystemService.queryUserCacheById(kwtWaybillOrder.getCreateBy()) == null ?
+//                        String.valueOf(kwtWaybillOrder.getCreateBy()) : remoteSystemService.queryUserCacheById(kwtWaybillOrder.getCreateBy()).getName());
+                    carWaybillVo.setLOrderNo(order.getLOrderNo());
+                    carWaybillVo.setLOrderId(String.valueOf(order.getId()));
+                    carWaybillVo.setLoss(loss);
+                    SysDictResDto sysDictResDto = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TAX_RATE_TYPE.getType(), order.getLossUnit());
+                    carWaybillVo.setLossLabel(sysDictResDto == null ? null : sysDictResDto.getLabel());
+                    returnList.add(carWaybillVo);
+                }
+            }
+        }
+        List<CarWaybillVO> collect = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(returnList)) {
+            collect = returnList.stream().skip((orderDto.getPage() - 1) * orderDto.getPageSize()).limit(orderDto.getPageSize()).collect(Collectors.toList());
+        }
+        PageResult result = PageResult.build(orderDto.getPage(), orderDto.getPageSize(), returnList.stream().count(), collect);
+        return HttpResult.ok(result);
+    }
 }

+ 67 - 4
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java

@@ -532,6 +532,29 @@ public class TransportCommonService {
         Map<String, String> taxRateTypeDictData = getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
         if (CollectionUtils.isNotEmpty(list)) {
             for (LogisticsOrderVO logisticsOrderDTO : list) {
+
+                String tOrderId = logisticsOrderDTO.getTOrderId();
+                if (StringUtils.isNotBlank(tOrderId)) {
+                    try {
+                        OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
+                        if (orderDetailById != null) {
+                            List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
+                            if (CollectionUtils.isNotEmpty(unitInfo)) {
+                                for (UnitInfoDetailRes detailRes : unitInfo) {
+                                    if ("1".equals(detailRes.getUnitType())) {
+                                        logisticsOrderDTO.setConsignee(detailRes.getFirmName());
+                                    }
+                                    if ("2".equals(detailRes.getUnitType())) {
+                                        logisticsOrderDTO.setForwardingUnit(detailRes.getFirmName());
+                                    }
+                                }
+                            }
+                        }
+                    } catch (NumberFormatException e) {
+                        System.out.println("查询不到贸易订单数据,id" + tOrderId);
+                    }
+                }
+
                 KwtLogisticsOrderUnit consignOrderUnit = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
                         .eq(KwtLogisticsOrderUnit::getLOrderId, logisticsOrderDTO.getLOrderId())
                         .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.ONE));
@@ -556,14 +579,54 @@ public class TransportCommonService {
                 logisticsOrderDTO.setGoodsName(orderGoods == null ? null : orderGoods.getGoodsName());
 
                 String billingMode = logisticsOrderDTO.getBillingMode();
+
+                /**
+                 * 一、罚款值计算:
+                 * 1、合理损耗值=实装量*合理损耗(‰)
+                 *  1.1 亏吨量= 实装量-实卸量
+                 * 2、扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
+                 * 3、罚款值=扣亏量 * 扣亏货值
+                 *
+                 * 二、运价计算:
+                 * 1、按装货量:总运价=实装量*运价
+                 * 2、按卸货量:总运价=实卸量*运价-罚款值
+                 * 3、按趟次:总运价=运价*趟次【后期加】
+                 */
+                //运价
+                BigDecimal price = logisticsOrderDTO.getPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getPrice();
+
+
+                /**亏吨量/吨->装货量-卸货量
+                 扣亏量/吨->亏吨量-合理损耗值
+                 扣亏量/吨->亏吨量-合理损耗值(装货量*合理损耗)*/
+                BigDecimal loadAmount = logisticsOrderDTO.getTotalLoadAmount() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getTotalLoadAmount();
+                BigDecimal unloadAmount = logisticsOrderDTO.getTotalUnloadAmount() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getTotalUnloadAmount();
+
+                //亏吨量
+                BigDecimal defectiveWeighNumber = loadAmount.subtract(unloadAmount);
+                //合理损耗值
+                BigDecimal lossAmount = loadAmount.multiply(logisticsOrderDTO.getLoss() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getLoss());
+                //扣亏量
+                BigDecimal deductWeighNumber = defectiveWeighNumber.subtract(lossAmount);
+                if (deductWeighNumber.compareTo(new BigDecimal("0")) < 0) {
+                    deductWeighNumber = new BigDecimal("0.00");
+                }
+                //罚款值
+                BigDecimal fineValue = (logisticsOrderDTO.getGoodsPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getGoodsPrice()).multiply(deductWeighNumber);
+                /**
+                 *
+                 * 二、运价计算:
+                 * 1、按装货量:总运价=实装量*运价
+                 * 2、按卸货量:总运价=实卸量*运价-罚款值
+                 * 3、按趟次:总运价=运价*趟次【后期加】
+                 */
                 BigDecimal actualAmount = new BigDecimal("0.00");
                 if (DictEnum.CHARGING_TYPE_1.getValue().equals(billingMode)) {
-                    actualAmount = logisticsOrderDTO.getLoadAmount();
+                    actualAmount = logisticsOrderDTO.getTotalLoadAmount().multiply(price);
                 } else if (DictEnum.CHARGING_TYPE_2.getValue().equals(billingMode)) {
-                    actualAmount = logisticsOrderDTO.getUnloadAmount();
+                    actualAmount = logisticsOrderDTO.getTotalUnloadAmount().multiply(price).subtract(fineValue);
                 }
-                BigDecimal price = logisticsOrderDTO.getPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getPrice();
-                logisticsOrderDTO.setTaxMoney(actualAmount.multiply(price));
+                logisticsOrderDTO.setTaxMoney(actualAmount);
 //                logisticsOrderDTO.setContractId();
                 logisticsOrderDTO.setContractName(contract.getContractName());
                 logisticsOrderDTO.setContractNo(contract.getContractNo());

+ 61 - 17
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportDubboServiceImpl.java

@@ -138,19 +138,23 @@ public class TransportDubboServiceImpl implements TransportDubboService {
             for (LogisticsOrderDTO logisticsOrderDTO : list) {
                 String tOrderId = logisticsOrderDTO.getTOrderId();
                 if (StringUtils.isNotBlank(tOrderId)) {
-                    OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
-                    if (orderDetailById != null) {
-                        List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
-                        if (CollectionUtils.isNotEmpty(unitInfo)){
-                            for (UnitInfoDetailRes detailRes : unitInfo) {
-                                if ("1".equals(detailRes.getUnitType())){
-                                    logisticsOrderDTO.setConsignee(detailRes.getFirmName());
-                                }
-                                if ("2".equals(detailRes.getUnitType())){
-                                    logisticsOrderDTO.setForwardingUnit(detailRes.getFirmName());
+                    try {
+                        OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
+                        if (orderDetailById != null) {
+                            List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
+                            if (CollectionUtils.isNotEmpty(unitInfo)) {
+                                for (UnitInfoDetailRes detailRes : unitInfo) {
+                                    if ("1".equals(detailRes.getUnitType())) {
+                                        logisticsOrderDTO.setConsignee(detailRes.getFirmName());
+                                    }
+                                    if ("2".equals(detailRes.getUnitType())) {
+                                        logisticsOrderDTO.setForwardingUnit(detailRes.getFirmName());
+                                    }
                                 }
                             }
                         }
+                    } catch (NumberFormatException e) {
+                        System.out.println("查询不到贸易订单数据,id" + tOrderId);
                     }
                 }
 
@@ -177,14 +181,54 @@ public class TransportDubboServiceImpl implements TransportDubboService {
                 );
                 logisticsOrderDTO.setGoodsName(orderGoods == null ? null : orderGoods.getGoodsName());
                 String billingMode = logisticsOrderDTO.getBillingMode();
+
+                /**
+                 * 一、罚款值计算:
+                 * 1、合理损耗值=实装量*合理损耗(‰)
+                 *  1.1 亏吨量= 实装量-实卸量
+                 * 2、扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
+                 * 3、罚款值=扣亏量 * 扣亏货值
+                 *
+                 * 二、运价计算:
+                 * 1、按装货量:总运价=实装量*运价
+                 * 2、按卸货量:总运价=实卸量*运价-罚款值
+                 * 3、按趟次:总运价=运价*趟次【后期加】
+                 */
+                //运价
+                BigDecimal price = logisticsOrderDTO.getPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getPrice();
+
+
+                /**亏吨量/吨->装货量-卸货量
+                 扣亏量/吨->亏吨量-合理损耗值
+                 扣亏量/吨->亏吨量-合理损耗值(装货量*合理损耗)*/
+                BigDecimal loadAmount = logisticsOrderDTO.getTotalLoadAmount() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getTotalLoadAmount();
+                BigDecimal unloadAmount = logisticsOrderDTO.getTotalUnloadAmount() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getTotalUnloadAmount();
+
+                //亏吨量
+                BigDecimal defectiveWeighNumber = loadAmount.subtract(unloadAmount);
+                //合理损耗值
+                BigDecimal lossAmount = loadAmount.multiply(logisticsOrderDTO.getLoss() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getLoss());
+                //扣亏量
+                BigDecimal deductWeighNumber = defectiveWeighNumber.subtract(lossAmount);
+                if (deductWeighNumber.compareTo(new BigDecimal("0")) < 0) {
+                    deductWeighNumber = new BigDecimal("0.00");
+                }
+                //罚款值
+                BigDecimal fineValue = (logisticsOrderDTO.getGoodsPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getGoodsPrice()).multiply(deductWeighNumber);
+                /**
+                *
+                 * 二、运价计算:
+                 * 1、按装货量:总运价=实装量*运价
+                 * 2、按卸货量:总运价=实卸量*运价-罚款值
+                 * 3、按趟次:总运价=运价*趟次【后期加】
+                 */
                 BigDecimal actualAmount = new BigDecimal("0.00");
                 if (DictEnum.CHARGING_TYPE_1.getValue().equals(billingMode)) {
-                    actualAmount = logisticsOrderDTO.getLoadAmount();
+                    actualAmount = logisticsOrderDTO.getTotalLoadAmount().multiply(price);
                 } else if (DictEnum.CHARGING_TYPE_2.getValue().equals(billingMode)) {
-                    actualAmount = logisticsOrderDTO.getUnloadAmount();
+                    actualAmount = logisticsOrderDTO.getTotalUnloadAmount().multiply(price).subtract(fineValue);
                 }
-                BigDecimal price = logisticsOrderDTO.getPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getPrice();
-                logisticsOrderDTO.setTaxMoney(actualAmount.multiply(price));
+                logisticsOrderDTO.setTaxMoney(actualAmount);
 //                logisticsOrderDTO.setContractId();
                 logisticsOrderDTO.setContractName(contract.getContractName());
                 logisticsOrderDTO.setContractNo(contract.getContractNo());
@@ -553,7 +597,7 @@ public class TransportDubboServiceImpl implements TransportDubboService {
     @Override
     public List<RWaybillOrderVo> findWaybillOrder(RWaybillOrderDto params) {
         List<RWaybillOrderVo> waybillOrderVos = new ArrayList<>();
-        Map<String, Object> queryParams = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+        Map<String, Object> queryParams = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
             put("truckNo", params.getTruckNo());
             put("busStatus", params.getBusStatus());
         }};
@@ -562,11 +606,11 @@ public class TransportDubboServiceImpl implements TransportDubboService {
             return waybillOrderVos;
         }
 
-        for (KwtWaybillOrder waybillOrder:waybillOrders) {
+        for (KwtWaybillOrder waybillOrder : waybillOrders) {
             RWaybillOrderVo order = new RWaybillOrderVo();
             BeanUtils.copyProperties(waybillOrder, order);
             KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(waybillOrder.getId(), CarWaybillEnum.EXIT_COMPLETED.getCode());
-            order.setDepartureTime(track != null ? track.getOperateTime(): null);
+            order.setDepartureTime(track != null ? track.getOperateTime() : null);
             waybillOrderVos.add(order);
         }
 

+ 93 - 12
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -214,6 +214,8 @@
         a.tax_rate as taxRate,
         a.load_amount AS loadAmount,
         a.unload_amount AS unloadAmount,
+        a.total_load_amount AS totalLoadAmount,
+        a.total_unload_amount AS totalUnloadAmount,
         a.settlement_cycle as settlementCycle,
         a.start_time AS startTime,
         a.end_time AS endTime,
@@ -568,6 +570,8 @@
         a.tax_rate as taxRate,
         a.load_amount AS loadAmount,
         a.unload_amount AS unloadAmount,
+        a.total_load_amount AS totalLoadAmount,
+        a.total_unload_amount AS totalUnloadAmount,
         a.settlement_cycle as settlementCycle,
         a.start_time AS startTime,
         a.end_time AS endTime,
@@ -982,8 +986,8 @@
         LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
         <where>
             a.del_flag = 0
-            <if test="type == 1">
-                and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
+<!--            <if test="type == 1">-->
+<!--                and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
                 <!--                AND (-->
                 <!--                a.ent_id = #{entId}-->
                 <!--                <if test="userIds != null and userIds.size()>0">-->
@@ -1002,9 +1006,9 @@
                 <!--                    </foreach>-->
                 <!--                </if>-->
                 <!--                 )-->
-            </if>
-            <if test="type == 2">
-                and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
+<!--            </if>-->
+<!--            <if test="type == 2">-->
+<!--                and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
                 <!--                AND (-->
                 <!--                a.ent_id = #{entId}-->
                 <!--                <if test="userIds != null and userIds.size()>0">-->
@@ -1023,7 +1027,7 @@
                 <!--                    </foreach>-->
                 <!--                </if>-->
                 <!--                )-->
-            </if>
+<!--            </if>-->
             <if test="query.keywords != null and query.keywords != ''">
                 and (
                 a.t_order_no like concat('%',#{query.keywords},'%')
@@ -1190,8 +1194,8 @@
         LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
         <where>
             a.del_flag = 0
-            <if test="type == 1">
-                and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
+<!--            <if test="type == 1">-->
+<!--                and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
                 <!--                AND (-->
                 <!--                a.ent_id = #{entId}-->
                 <!--                <if test="userIds != null and userIds.size()>0">-->
@@ -1210,9 +1214,9 @@
                 <!--                    </foreach>-->
                 <!--                </if>-->
                 <!--                )-->
-            </if>
-            <if test="type == 2">
-                and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
+<!--            </if>-->
+<!--            <if test="type == 2">-->
+<!--                and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
                 <!--                AND (-->
                 <!--                a.ent_id = #{entId}-->
                 <!--                <if test="userIds != null and userIds.size()>0">-->
@@ -1231,7 +1235,7 @@
                 <!--                    </foreach>-->
                 <!--                </if>-->
                 <!--                )-->
-            </if>
+<!--            </if>-->
             <if test="query.keywords != null and query.keywords != ''">
                 and (
                 a.t_order_no like concat('%',#{query.keywords},'%')
@@ -1666,4 +1670,81 @@
         </if>
         ) t1
     </select>
+
+    <select id="workbenchLogisticsOrderStatisticsByMonth" resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
+        SELECT  A.date_time as dateTime, COALESCE(B.num, 0) as num,IFNULL(B.totalAmount,0) AS totalAmount FROM
+        (
+        SELECT
+        DATE_FORMAT( DATE_ADD( #{dateStart}, INTERVAL ROW1 MONTH ), '%Y-%m' ) date_time
+        FROM
+        (
+        SELECT
+        @ROW := @ROW +1 as ROW1
+        FROM
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
+        (SELECT @row:=-1) r
+        ) se
+        WHERE
+        DATE_FORMAT( date_add( #{dateStart}, INTERVAL ROW1 MONTH ), '%Y-%m' ) &lt;= DATE_FORMAT(
+        #{dateEnd},
+        '%Y-%m')
+        ) A
+        LEFT JOIN
+        (
+        SELECT DATE_FORMAT(a.create_time, '%Y-%m') date_time, COUNT(*) num,sum(a.amount) as totalAmount
+        FROM kwt_logistics_order a LEFT JOIN  kwt_logistics_order_unit b ON a.id = b.l_order_id
+        WHERE a.del_flag = 0 AND b.unit_type = #{type}
+            <if test="statusList != null and statusList.size() > 0">
+                and a.status in
+                <foreach collection="statusList" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+        GROUP BY DATE_FORMAT(a.create_time, '%Y-%m')
+        ) B
+        ON  A.date_time = B.date_time
+    </select>
+
+    <select id="workbenchLogisticsOrderStatisticsByDays"
+            resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
+        SELECT  A.date as dateTime, COALESCE(B.num, 0) as num,IFNULL(B.totalAmount,0) AS totalAmount FROM
+        (
+        select date_add(#{dateStart}, interval row1 DAY) date from
+        (
+        SELECT @row := @row + 1 as row1 FROM
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
+        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
+        (SELECT @row:=-1) r
+        ) se
+        where date_add(#{dateStart}, interval row1 DAY) &lt;=  #{dateEnd}
+        ) A
+        LEFT JOIN
+        (
+        SELECT
+<!--        <if test="type == 1">-->
+<!--            COUNT(*) num,-->
+<!--        </if>-->
+<!--        <if test="type == 1">-->
+<!--            sum(a.amount) as totalAmount ,-->
+<!--        </if>-->
+        COUNT(*) num,
+        sum(a.amount) as totalAmount ,
+        DATE_FORMAT(a.create_time, '%Y-%m-%d') date_time
+        FROM kwt_logistics_order a LEFT JOIN  kwt_logistics_order_unit b ON a.id =b.l_order_id
+        WHERE a.del_flag = 0 AND b.unit_type = b.unit_type = #{type}
+        <if test="statusList != null and statusList.size() > 0">
+            and a.status in
+            <foreach collection="statusList" close=")" open="(" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY DATE_FORMAT(a.create_time, '%Y-%m-%d')
+        ) B
+        ON  A.date= B.date_time;
+    </select>
 </mapper>