Przeglądaj źródła

Merge branch 'dev' into sky_v1

15928045575 2 lat temu
rodzic
commit
bcd5d04783
65 zmienionych plików z 2393 dodań i 254 usunięć
  1. 7 5
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java
  2. 22 21
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java
  3. 1 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/response/Result.java
  4. 167 15
      sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java
  5. 5 6
      sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/SckwTradeOrder.java
  6. 35 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java
  7. 30 7
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/LedgerCount.java
  8. 36 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/SettlementMoney.java
  9. 17 4
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java
  10. 5 0
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/res/FindCooperateByEntResVo.java
  11. 24 2
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java
  12. 4 1
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java
  13. 1 1
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java
  14. 2 2
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java
  15. 16 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderGoodsService.java
  16. 27 9
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java
  17. 1 1
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml
  18. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  19. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  20. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  21. 10 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  22. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSize.java
  23. 12 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/MoneyType.java
  24. 4 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  25. 4 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  26. 12 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  27. 13 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  28. 130 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  29. 158 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DateTimeUtil.java
  30. 24 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DecimalUtils.java
  31. 4 4
      sckw-modules/sckw-payment/src/main/resources/bootstrap-test.yml
  32. 19 7
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  33. 12 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  34. 33 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml
  35. 37 4
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml
  36. 6 6
      sckw-modules/sckw-report/src/main/java/com/sckw/report/model/dto/WorkbenchOrderStsDTO.java
  37. 5 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/TOrderDataStsResVO.java
  38. 20 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/WbTOrderDataStsResVO.java
  39. 4 5
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java
  40. 43 20
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderStatisticsService.java
  41. 4 4
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwWorkService.java
  42. 6 7
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/vo/OrderListRes.java
  43. 4 0
      sckw-modules/sckw-system/pom.xml
  44. 11 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsUserController.java
  45. 5 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindEntUserPojo.java
  46. 6 8
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java
  47. 13 4
      sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml
  48. 22 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/AcceptCarriageOrderController.java
  49. 16 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java
  50. 1 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/enterpriseApp/AppWayBillController.java
  51. 108 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/operationManagement/ManagementWaybillOrderController.java
  52. 41 16
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java
  53. 31 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/enums/OrderTypeEnum.java
  54. 74 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/ManagementWaybillOrderQuery.java
  55. 168 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/ManagementCarWaybillVo.java
  56. 63 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsByOrderVO.java
  57. 84 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/execlVo/ManagementWaybillOrderExcelVO.java
  58. 112 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  59. 38 35
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/CommonService.java
  60. 133 8
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  61. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java
  62. 6 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java
  63. 323 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementWaybillOrderService.java
  64. 8 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java
  65. 135 17
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

+ 7 - 5
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java

@@ -25,12 +25,14 @@ public class GlobalSystemExceptionHandler {
     @ExceptionHandler(value = SystemException.class)
     @ResponseBody
     public HttpResult handlerSystemException(SystemException e) {
+        log.error("业务异常:", e);
         return HttpResult.error(e.getCode(), e.getMessage());
     }
 
     @ExceptionHandler(value = RuntimeException.class)
     @ResponseBody
     public HttpResult handlerRuntimeException(RuntimeException e) {
+        log.error("业务异常:", e);
         return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
     }
 
@@ -43,7 +45,7 @@ public class GlobalSystemExceptionHandler {
     @ResponseBody
     @ExceptionHandler(BusinessException.class)
     public HttpResult businessExceptionHandler(BusinessException ex) {
-        log.info("业务异常,message={},param={}", ex.getMsg(), ex.getParam());
+        log.error("业务异常,message={},param={}", ex.getMsg(), ex.getParam());
         return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, ex.getMessage());
     }
 
@@ -56,7 +58,7 @@ public class GlobalSystemExceptionHandler {
     @ResponseBody
     @ExceptionHandler(CustomPromptException.class)
     public HttpResult customPromptExceptionHandler(CustomPromptException ex) {
-        log.info("前端自定义提示异常,code={},message={},param={}", ex.getCode(), ex.getMsg(), ex.getParam());
+        log.error("前端自定义提示异常,code={},message={},param={}", ex.getCode(), ex.getMsg(), ex.getParam());
         return HttpResult.error(ex.getCode(), ex.getMessage());
     }
 
@@ -70,7 +72,7 @@ public class GlobalSystemExceptionHandler {
     @ResponseBody
     @ExceptionHandler(NotLoginException.class)
     public HttpResult notLoginException(NotLoginException ex) {
-        log.info("用户未登录, message={}, param={}", ex.getMsg(), ex.getParam());
+        log.error("用户未登录, message={}, param={}", ex.getMsg(), ex.getParam());
         return HttpResult.error(HttpStatus.UN_LOGIN_CODE, HttpStatus.UN_LOGIN_MESSAGE, ex.getMessage());
     }
 
@@ -103,14 +105,14 @@ public class GlobalSystemExceptionHandler {
             }
         }
         String errMsg = sb.toString();
-        log.info("参数校验异常:{}", errMsg);
+        log.error("参数校验异常:{}", errMsg);
         return HttpResult.error(HttpStatus.PARAMETERS_PATTERN_ERROR_CODE, errMsg);
     }
 
     @ResponseBody
     @ExceptionHandler(ConstraintViolationException.class)
     public HttpResult constraintViolationExceptionHandler(ConstraintViolationException ex) {
-        log.info("参数校验异常c:{}", ex.getMessage());
+        log.error("参数校验异常c:{}", ex.getMessage());
         Set<ConstraintViolation<?>> constraintViolations = ex.getConstraintViolations();
         StringBuilder sb = new StringBuilder();
         if (!CollectionUtils.isEmpty(constraintViolations)) {

+ 22 - 21
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java

@@ -1,15 +1,11 @@
 package com.sckw.core.utils;
 
 import cn.hutool.core.date.DateUtil;
-import org.springframework.util.Assert;
 
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.Duration;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Objects;
@@ -611,32 +607,37 @@ public class DateUtils extends DateUtil {
     }
 
     /**
-     * @desc: 获取指定时间的周/月开始时间
+     * @desc: 获取指定时间的周/月开始时间
      * @author: yzc
-     * @date: 2023-09-11 16:08
-     * @Param dateType:  1周、2月
+     * @date: 2023-09-12 10:20
+     * @Param dateType:
+     * @Param time:
      * @return: java.util.Date
      */
-    public static Date getStartTimeByDateType(Integer dateType, LocalDateTime time) {
-        Assert.notNull(dateType, "获取上周/月开始时间,日期类型参数缺失");
-        Assert.notNull(time, "获取上周/月开始时间,日期类型参数缺失");
-        int days = Objects.equals(dateType, 1) ? 6 : 29;
-        LocalDateTime startTime = time.minusDays(days).with(LocalDateTime.MIN);
+    public static Date getStartTime(Integer dateType, LocalDateTime time) {
+        LocalDateTime startTime;
+        if (Objects.equals(dateType, 1)) {
+            startTime = LocalDateTime.of(time.toLocalDate().minusDays(6), LocalTime.MIN);
+        } else {
+            startTime = LocalDateTime.of(time.toLocalDate().minusMonths(1).plusDays(1), LocalTime.MIN);
+        }
         return formatDate(startTime);
     }
 
     /**
-     * @desc: 获取指定时间的一周/月结束时间
+     * @desc: 获取周/月结束时间
      * @author: yzc
-     * @date: 2023-09-11 16:43
-     * @Param dateType: 1周、2月
+     * @date: 2023-09-12 10:21
+     * @Param dateType:
      * @return: java.util.Date
      */
-    public static Date getEndTimeByDateType(Integer dateType, LocalDateTime time) {
-        Assert.notNull(dateType, "获取上周/月结束时间,时间参数缺失");
-        Assert.notNull(time, "获取上周/月结束时间,时间参数缺失");
-        int days = Objects.equals(dateType, 1) ? 7 : 30;
-        LocalDateTime endTime = time.minusDays(days).with(LocalDateTime.MAX);
+    public static Date getLastEndTime(Integer dateType) {
+        LocalDateTime endTime;
+        if (Objects.equals(dateType, 1)) {
+            endTime = LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MAX);
+        } else {
+            endTime = LocalDateTime.of(LocalDate.now().minusMonths(1), LocalTime.MAX);
+        }
         return formatDate(endTime);
     }
 

+ 1 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/response/Result.java

@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 
 /**
  * @description:
- * @author: LengFaQiang
+ * @author: lfdc
  * @copyright
  * @create: 2022-01-27 10:17
  **/

+ 167 - 15
sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java

@@ -522,8 +522,8 @@ public class DateUtil {
     }
 
     public static void main(String[] args) throws ParseException {
-        String lastTwoMonthDate = getLastTwoMonthDateStart();
-        String lastTwoMonthDateEnd = getLastTwoMonthDateEnd();
+//        String lastTwoMonthDate = getLastTwoMonthDateStart();
+//        String lastTwoMonthDateEnd = getLastTwoMonthDateEnd();
 //        String s = "2023-12-12";
 //        Date date = DateUtil.stringPatchingStartToDateTime(s);
 //        Date date1 = DateUtil.stringPatchingEndToDateTime(s);
@@ -549,15 +549,42 @@ public class DateUtil {
 //        System.out.println(localDateTime);
 //        LocalDateTime beforeWeekDateEnd = getBeforeWeekDateEnd(6);
 //        System.out.println(beforeWeekDateEnd);
-        String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN));
-        System.out.println(format);
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
-        LocalDateTime parse = LocalDateTime.parse(format, formatter);
-        System.out.println(parse);
-        LocalDateTime lastWeekDateStart = getLastWeekDateStart(6);
-        System.out.println(lastWeekDateStart);
-        LocalDateTime lastWeekDateEnd = getLastWeekDateEnd(6);
-        System.out.println(lastWeekDateEnd);
+//        String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN));
+//        System.out.println(format);
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
+//        LocalDateTime parse = LocalDateTime.parse(format, formatter);
+//        System.out.println(parse);
+//        LocalDateTime lastWeekDateStart = getLastWeekDateStart(6);
+//        System.out.println(lastWeekDateStart);
+//        LocalDateTime lastWeekDateEnd = getLastWeekDateEnd(6);
+//        System.out.println(lastWeekDateEnd);
+
+
+//        //本月
+//        //开始时间
+//
+//        String weekDateStart = getBeforeMonthDateAndDaysStartToString(1, -1);
+//        System.out.println(weekDateStart);
+//        //结束时间
+//        String weekDateEnd = getLastWeekDateEndToString(0);
+//        System.out.println(weekDateEnd);
+//        //环比本月
+//        //开始时间
+//        String beforeMonthDateAndDaysEndToString = getBeforeMonthDateAndDaysStartToString(2, -1);
+//        System.out.println(beforeMonthDateAndDaysEndToString);
+//        //结束时间
+//        String beforeMonthDateAndDaysEndToString1 = getBeforeMonthDateAndDaysEndToString(1, 0);
+//        System.out.println(beforeMonthDateAndDaysEndToString1);
+        //月
+        //开始时间
+        String monthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 1, -1);
+        //结束时间
+        String monthDateEnd = DateUtil.getLastWeekDateEndToString(0);
+        //环比上月
+        //开始时间
+        String lastMonthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 2, -1);
+        //结束时间
+        String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(),1, 0);
 
     }
 
@@ -749,6 +776,23 @@ public class DateUtil {
         return localDateTime;
     }
 
+    /**
+     * 当前时间的前一个星期[传递6即为一周]
+     *
+     * @return 2023-09-12 00:00:00
+     */
+    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);
+//        String start = format.format(c.getTime()) + " 00:00:00";
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
+//        LocalDateTime localDateTime = LocalDateTime.parse(start, formatter);
+        LocalDateTime localDateTime = localDate.minusDays(amount).atStartOfDay();
+        String format = localDateTime.format(YYYY_MM_DD_HH_MM_SS);
+        return format;
+    }
+
 
     /**
      * 当前时间的前一个星期 [传递6即为一周]
@@ -765,6 +809,19 @@ public class DateUtil {
         return parse;
     }
 
+    /**
+     * 当前时间的前一个星期 [传递6即为一周]
+     *
+     * @return 2023-09-12 23:59:59
+     */
+    public static String getLastWeekDateEndToString(int amount) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.DAY_OF_MONTH, -amount);
+        String start = format.format(c.getTime()) + " 23:59:59";
+        return start;
+    }
+
     /**
      * 当前时间的前一个星期
      *
@@ -846,7 +903,7 @@ public class DateUtil {
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         Calendar c = Calendar.getInstance();
         c.add(Calendar.MONTH, -1);
-        String start = format.format(c.getTime())+" 00:00:00";
+        String start = format.format(c.getTime()) + " 00:00:00";
         System.out.println(start);
         return start;
     }
@@ -860,7 +917,7 @@ public class DateUtil {
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         Calendar c = Calendar.getInstance();
         c.add(Calendar.MONTH, -1);
-        String start = format.format(c.getTime())+" 23:59:59";
+        String start = format.format(c.getTime()) + " 23:59:59";
         return start;
     }
 
@@ -879,11 +936,106 @@ public class DateUtil {
         return start;
     }
 
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @return 2023-09-13 00:00:00
+     */
+    public static LocalDateTime getBeforeMonthDateStart(int amount) {
+        LocalDateTime localDateTime = LocalDateTime.now().minusMonths(amount);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 00:00:00";
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
+        LocalDateTime returnLocalDateTime = LocalDateTime.parse(start, formatter);
+        return returnLocalDateTime;
+    }
+
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @return 2023-09-13 00:00:00
+     */
+    public static LocalDateTime getBeforeMonthDateAndDaysStart(int amount, long days) {
+        LocalDateTime localDateTime = LocalDateTime.now().minusMonths(amount).minusDays(days);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 00:00:00";
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
+        LocalDateTime returnLocalDateTime = LocalDateTime.parse(start, formatter);
+        return returnLocalDateTime;
+    }
+
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @return 2023-09-13 00:00:00
+     */
+    public static String getBeforeMonthDateStartToString(int amount) {
+        LocalDateTime localDateTime = LocalDateTime.now().minusMonths(amount);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 00:00:00";
+        return start;
+    }
+
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @return 2023-09-13 00:00:00
+     */
+    public static String getBeforeMonthDateAndDaysStartToString(LocalDateTime localDateTime, int amount, long days) {
+        localDateTime = localDateTime.minusMonths(amount).minusDays(days);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 00:00:00";
+        return start;
+    }
+
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @return 2023-09-13 23:59:59
+     */
+    public static LocalDateTime getBeforeMonthDateEnd(int amount) {
+        LocalDateTime localDateTime = LocalDateTime.now().minusMonths(amount);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 23:59:59";
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
+        LocalDateTime returnLocalDateTime = LocalDateTime.parse(start, formatter);
+        return returnLocalDateTime;
+    }
+
+
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @param days   减去几天
+     * @return 2023-09-13 23:59:59
+     */
+    public static String getBeforeMonthDateAndDaysEndToString(LocalDateTime localDateTime, int amount, long days) {
+        localDateTime = localDateTime.minusMonths(amount).minusDays(days);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 23:59:59";
+        return start;
+    }
+
+    /**
+     * 获取当前日期之前的时间
+     *
+     * @param amount 往前推多久时间[月为单位]
+     * @param days   减去几天
+     * @return 2023-09-13 23:59:59
+     */
+    public static LocalDateTime getBeforeMonthDateAndDaysEndToLocalDateTime(int amount, long days) {
+        LocalDateTime localDateTime = LocalDateTime.now().minusMonths(amount).minusDays(days);
+        String start = localDateTime.format(DateTimeFormatter.ofPattern(DEF_DATE_FORMAT)) + " 23:59:59";
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);
+        LocalDateTime returnLocalDateTime = LocalDateTime.parse(start, formatter);
+        return returnLocalDateTime;
+    }
+
 
     /**
      * 当天日期前两个月
      *
-     * @return
+     * @return 2023-09-13 00:00:00
      */
     public static String getLastTwoMonthDateStart() {
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -897,7 +1049,7 @@ public class DateUtil {
     /**
      * 当天日期前两个月
      *
-     * @return
+     * @return 2023-09-13 23:59:59
      */
     public static String getLastTwoMonthDateEnd() {
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 5 - 6
sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/SckwTradeOrder.java

@@ -9,7 +9,6 @@ import lombok.experimental.Accessors;
 import org.springframework.data.annotation.Id;
 import org.springframework.data.mongodb.core.mapping.Document;
 
-import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.Date;
 
@@ -46,7 +45,7 @@ public class SckwTradeOrder {
     /**
      * 订单成交数量
      */
-    private BigDecimal amount;
+    private Double amount;
 
     /**
      * 订单单位(吨、方、箱、件)
@@ -56,12 +55,12 @@ public class SckwTradeOrder {
     /**
      * 订单金额
      */
-    private BigDecimal price;
+    private Double price;
 
     /**
      * 订单成交单价
      */
-    private BigDecimal unitPrice;
+    private Double unitPrice;
 
     /**
      * 订单交易方式(预付款、货到付款)
@@ -93,12 +92,12 @@ public class SckwTradeOrder {
     /**
      * 订单已委托量
      */
-    private BigDecimal entrustAmount;
+    private Double entrustAmount;
 
     /**
      * 订单实际交付量
      */
-    private BigDecimal actualAmount;
+    private Double actualAmount;
 
     /**
      * 是否关联对账单:0未关联,1已关联

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

@@ -2,6 +2,7 @@ package com.sckw.payment.api.dubbo;
 
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.dto.LedgerCount;
+import com.sckw.payment.api.model.dto.SettlementMoney;
 
 import java.util.List;
 import java.util.Map;
@@ -35,4 +36,38 @@ public interface PaymentDubboService {
      */
     LedgerCount countLedger(Long entId);
 
+    //工作台金额统计数据四个接口
+
+    /**
+     * 销售统计,以当前日向前推一月、一周
+     *
+     * @param countType 1-周 2-月
+     * @return
+     */
+    SettlementMoney countSell(Long entId, Integer countType);
+
+    /**
+     * 采购统计,以当前日向前推一月、一周
+     *
+     * @param countType 1-周 2-月
+     * @return
+     */
+    SettlementMoney countPurchase(Long entId, Integer countType);
+
+    /**
+     * 承运统计,以当前日向前推一月、一周
+     *
+     * @param countType 1-周 2-月
+     * @return
+     */
+    SettlementMoney countCarrier(Long entId, Integer countType);
+
+    /**
+     * 托运统计,以当前日向前推一月、一周
+     *
+     * @param countType 1-周 2-月
+     * @return
+     */
+    SettlementMoney countShipper(Long entId, Integer countType);
+
 }

+ 30 - 7
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/LedgerCount.java

@@ -1,10 +1,33 @@
 package com.sckw.payment.api.model.dto;
 
-/**
- * @param sell     销售对账单数量
- * @param purchase 采购对账单数量
- * @param carrier  承运对账单数量
- * @param shipper  托运对账单数量
- */
-public record LedgerCount(Integer sell, Integer purchase, Integer carrier, Integer shipper) {
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+
+@Getter
+@Setter
+@AllArgsConstructor
+public class LedgerCount implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 5036501461520398876L;
+    /**
+     * 销售对账单数量
+     */
+    private Integer sell;
+    /**
+     * 采购对账单数量
+     */
+    private Integer purchase;
+    /**
+     * 承运对账单数量
+     */
+    private Integer carrier;
+    /**
+     * 托运对账单数量
+     */
+    private Integer shipper;
 }

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

@@ -0,0 +1,36 @@
+package com.sckw.payment.api.model.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class SettlementMoney implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 339614434734438926L;
+    /**
+     * 销售对账单数量
+     */
+    private String current;
+    /**
+     * 采购对账单数量
+     */
+    private String before;
+    /**
+     * 环比
+     */
+    private String percent;
+    /**
+     * 1-增长 2-下降
+     */
+    private Integer flag;
+
+
+}

+ 17 - 4
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java

@@ -33,9 +33,22 @@ public class TestController {
     public R<List<WalletDto>> wall(@RequestParam("uid") Long uid, String channel, Long filter) {
         return payCenterDubboService.wallet(uid, null, filter);
     }
-//    @GetMapping("/test")
-//    public R<Object> test(@RequestParam("entId") Long entId) {
-//        return R.ok(paymentDubboService.checkSettlement(entId));
-//    }
+
+    @GetMapping("/test")
+    public R<Object> test(@RequestParam("entId") Long entId,Integer type) {
+        return R.ok(paymentDubboService.countSell(entId, type));
+    }
+    @GetMapping("/test1")
+    public R<Object> test1(@RequestParam("entId") Long entId,Integer type) {
+        return R.ok(paymentDubboService.countPurchase(entId, type));
+    }
+    @GetMapping("/test2")
+    public R<Object> test2(@RequestParam("entId") Long entId,Integer type) {
+        return R.ok(paymentDubboService.countCarrier(entId, type));
+    }
+    @GetMapping("/test3")
+    public R<Object> test3(@RequestParam("entId") Long entId,Integer type) {
+        return R.ok(paymentDubboService.countShipper(entId, type));
+    }
 
 }

+ 5 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/res/FindCooperateByEntResVo.java

@@ -86,5 +86,10 @@ public class FindCooperateByEntResVo implements Serializable {
      */
     private String targetPhone;
 
+    /**
+     * 备注
+     */
+    private String remark;
+
 }
 

+ 24 - 2
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java

@@ -197,8 +197,6 @@ public class CommonBusinessService {
 
             CooperateManageQueryResVo cooperateManageQueryResVo = new CooperateManageQueryResVo();
             cooperateManageQueryResVo.setId(cooperateManageQueryResDto.getId());
-            cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
-
             cooperateManageQueryResVo.setRemark(cooperateManageQueryResDto.getRemark());
             cooperateManageQueryResVo.setStatus(cooperateManageQueryResDto.getStatus());
             cooperateManageQueryResVo.setApplyTypeCode(cooperateManageQueryResDto.getApplyTypeCode());
@@ -218,6 +216,7 @@ public class CommonBusinessService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviterPhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviterContactsId());
+                cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
             } else {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviterPhone());
@@ -225,6 +224,7 @@ public class CommonBusinessService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
+                cooperateManageQueryResVo.setCooperateTypes(changeCooperateType(cooperateManageQueryResDto.getTypes()));
             }
 
             //转换合作属性
@@ -263,6 +263,28 @@ public class CommonBusinessService {
         return null;
     }
 
+    public String changeCooperateType(String types) {
+        String str = "";
+
+        if (types.contains(String.valueOf(CooperateTypeEnum.SUPPLIER.getCode()))) {
+            str += CooperateTypeEnum.PURCHASER.getCode() + Global.COMMA;
+        }
+
+        if (types.contains(String.valueOf(CooperateTypeEnum.PURCHASER.getCode()))) {
+            str += CooperateTypeEnum.SUPPLIER.getCode() + Global.COMMA;
+        }
+
+        if (types.contains(String.valueOf(CooperateTypeEnum.CONSIGN.getCode()))) {
+            str += CooperateTypeEnum.CARRIAGE.getCode() + Global.COMMA;
+        }
+
+        if (types.contains(String.valueOf(CooperateTypeEnum.CARRIAGE.getCode()))) {
+            str += CooperateTypeEnum.CONSIGN.getCode() + Global.COMMA;
+        }
+
+        return str.substring(0, str.length() - 1);
+    }
+
     /**
      * @return FindListGroupResVo
      * @desc: 初始化分组返参

+ 4 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java

@@ -121,7 +121,6 @@ public class KwmCooperateApplyService {
 
             CooperateManageQueryResVo cooperateManageQueryResVo = new CooperateManageQueryResVo();
             cooperateManageQueryResVo.setId(cooperateManageQueryResDto.getId());
-            cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
             cooperateManageQueryResVo.setCreateTime(cooperateManageQueryResDto.getCreateTime());
             cooperateManageQueryResVo.setRemark(cooperateManageQueryResDto.getRemark());
             cooperateManageQueryResVo.setStatus(cooperateManageQueryResDto.getStatus());
@@ -141,6 +140,8 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviterPhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviterContactsId());
+                cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
+
             } else {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviterPhone());
@@ -148,6 +149,8 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
+                cooperateManageQueryResVo.setCooperateTypes(commonBusinessService.changeCooperateType(cooperateManageQueryResDto.getTypes()));
+
             }
 
             result.add(cooperateManageQueryResVo);

+ 1 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -513,7 +513,7 @@ public class KwmCooperateManageService {
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             FindCooperateByEntResVo findCooperateByEntResVo = new FindCooperateByEntResVo();
             findCooperateByEntResVo.setId(kwmCooperate.getId());
-
+            findCooperateByEntResVo.setRemark(kwmCooperate.getRemark());
             //设置合作属性
             List<KwmCooperateType> kwmCooperateTypes1 = collect.get(kwmCooperate.getId());
             if (CollectionUtils.isNotEmpty(kwmCooperateTypes1)) {

+ 2 - 2
sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java

@@ -135,7 +135,7 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
             kwoTradeOrderService.updateById(order);
             //更新mongodb
             SckwTradeOrder updateParam = new SckwTradeOrder();
-            updateParam.setTOrderId(order.getId()).setEntrustAmount(totalEntrustAmount)
+            updateParam.setTOrderId(order.getId()).setEntrustAmount(totalEntrustAmount.doubleValue())
                     .setUpdateBy(param.getUpdateBy()).setUpdateByName(param.getUpdateByName()).setUpdateTime(new Date());
             saveMongoDb(updateParam);
         } finally {
@@ -194,7 +194,7 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
             kwoTradeOrderService.updateById(order);
             //更新mongodb
             SckwTradeOrder updateParam = new SckwTradeOrder();
-            updateParam.setTOrderId(order.getId()).setActualAmount(totalActualAmount).setStatus(order.getStatus())
+            updateParam.setTOrderId(order.getId()).setActualAmount(totalActualAmount.doubleValue()).setStatus(order.getStatus())
                     .setUpdateBy(param.getUpdateBy()).setUpdateByName(param.getUpdateByName()).setUpdateTime(new Date());
             saveMongoDb(updateParam);
         } finally {

+ 16 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderGoodsService.java

@@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -74,4 +75,19 @@ public class KwoTradeOrderGoodsService {
                 .set(KwoTradeOrderGoods::getDelFlag, Global.YES);
         kwoTradeOrderGoodsMapper.update(null, wrapper);
     }
+
+    /**
+     * @desc: 更新商品价格
+     * @author: yzc
+     * @date: 2023-09-12 15:52
+     * @Param orderId:
+     * @Param unitPrice:
+     * @return: void
+     */
+    public void updateUnitPrice(Long orderId, BigDecimal unitPrice) {
+        LambdaUpdateWrapper<KwoTradeOrderGoods> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(KwoTradeOrderGoods::getTOrderId, orderId).eq(KwoTradeOrderGoods::getDelFlag, Global.NO)
+                .set(KwoTradeOrderGoods::getUnitPrice, unitPrice);
+        kwoTradeOrderGoodsMapper.update(null, wrapper);
+    }
 }

+ 27 - 9
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -129,8 +129,16 @@ public class KwoTradeOrderService {
         Long id = tradeOrder.getId();
         String tOrderNo = tradeOrder.getTOrderNo();
         SckwTradeOrder order = new SckwTradeOrder();
-        order.setFirmName(LoginUserHolder.getEntName()).setTOrderId(id).setCreateByName(LoginUserHolder.getUserName())
-                .setUpdateByName(LoginUserHolder.getUserName()).setAssociateStatement(0);
+        order.setFirmName(LoginUserHolder.getEntName())
+                .setCreateByName(LoginUserHolder.getUserName())
+                .setUpdateByName(LoginUserHolder.getUserName())
+                .setTOrderId(id)
+                .setAssociateStatement(0)
+                .setPrice(tradeOrder.getPrice().doubleValue())
+                .setAmount(tradeOrder.getAmount().doubleValue())
+                .setEntrustAmount(tradeOrder.getEntrustAmount().doubleValue())
+                .setActualAmount(tradeOrder.getActualAmount().doubleValue());
+
         BeanUtils.copyProperties(tradeOrder, order);
         //商品信息
         kwoTradeOrderGoodsService.delByOrderId(id);
@@ -144,12 +152,12 @@ public class KwoTradeOrderService {
             }
             goods.setTOrderId(id).setTOrderNo(tOrderNo).setGoodsType(goodsDetail.getGoodsType());
             kwoTradeOrderGoodsService.insert(goods);
-            order.setGoodsId(goodsDetail.getId()).setUnit(goodsDetail.getUnit()).setUnitPrice(goods.getUnitPrice())
+            order.setGoodsId(goodsDetail.getId()).setUnit(goodsDetail.getUnit()).setUnitPrice(goods.getUnitPrice().doubleValue())
                     .setGoodsName(goodsDetail.getName()).setGoodsType(goodsDetail.getGoodsType()).setGoodsCode(goodsDetail.getCode())
                     .setGoodsTaxRate(goodsDetail.getTaxRate()).setGoodsSpec(goodsDetail.getSpec()).setGoodsThumb(goodsDetail.getThumb());
         }
         if (Objects.isNull(order.getUnitPrice())) {
-            order.setUnitPrice(new BigDecimal("0.00"));
+            order.setUnitPrice(BigDecimal.ZERO.doubleValue());
         }
         //单位信息
         kwoTradeOrderUnitService.delByOrderId(id);
@@ -876,6 +884,8 @@ public class KwoTradeOrderService {
             throw new BusinessException("Invalid contract status");
         }
         kwoTradeOrderMapper.updateById(order);
+        //更新商品价格
+        kwoTradeOrderGoodsService.updateUnitPrice(param.getId(),param.getUnitPrice());
         //保存合同信息
         KwoTradeOrderContract tradeOrderContract = BeanUtils.copyProperties(contractInfo, KwoTradeOrderContract.class);
         tradeOrderContract.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo());
@@ -893,10 +903,18 @@ public class KwoTradeOrderService {
         }
         //更新mongodb
         SckwTradeOrder updateParam = BeanUtils.copyProperties(param, SckwTradeOrder.class);
-        updateParam.setTOrderId(param.getId()).setStatus(order.getStatus()).setContractId(contractInfo.getContractId())
-                .setContractNo(contractInfo.getContractNo()).setContractName(contractInfo.getContractName())
-                .setContractSigningWay(contractInfo.getContractSigningWay()).setUpdateBy(LoginUserHolder.getUserId())
-                .setUpdateByName(LoginUserHolder.getUserName()).setUpdateTime(new Date());
+        updateParam.setTOrderId(param.getId())
+                .setStatus(order.getStatus())
+                .setPrice(order.getPrice().doubleValue())
+                .setAmount(order.getAmount().doubleValue())
+                .setUnitPrice(param.getUnitPrice().doubleValue())
+                .setContractId(contractInfo.getContractId())
+                .setContractNo(contractInfo.getContractNo())
+                .setContractName(contractInfo.getContractName())
+                .setContractSigningWay(contractInfo.getContractSigningWay())
+                .setUpdateBy(LoginUserHolder.getUserId())
+                .setUpdateByName(LoginUserHolder.getUserName())
+                .setUpdateTime(new Date());
         saveMongoDb(3, updateParam);
 
     }
@@ -1049,7 +1067,7 @@ public class KwoTradeOrderService {
             remoteContractService.updatePerformed(contract.getContractId(), actualAmount);
             //mongodb更新订单状态
             SckwTradeOrder updateParam = new SckwTradeOrder();
-            updateParam.setTOrderId(order.getId()).setActualAmount(order.getActualAmount()).setStatus(order.getStatus())
+            updateParam.setTOrderId(order.getId()).setActualAmount(order.getActualAmount().doubleValue()).setStatus(order.getStatus())
                     .setUpdateBy(LoginUserHolder.getUserId()).setUpdateByName(LoginUserHolder.getUserName()).setUpdateTime(new Date());
             saveMongoDb(3, updateParam);
         } finally {

+ 1 - 1
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml

@@ -36,7 +36,7 @@
         <result column="remark" property="remark"/>
         <result column="createTime" property="createTime"/>
         <result column="updateTime" property="updateTime"/>
-        <collection property="wantBuyTradings" column="id" ofType="com.sckw.order.model.vo.res.WantBuyTradingRes"  javaType="java.util.List" >
+        <collection property="wantBuyTradings" column="id" ofType="com.sckw.order.model.vo.res.WantBuyTradingRes"  javaType="java.util.List" select="tradingSql">
             <id column="wantBuyId" property="wantBuyId"/>
             <result column="trading" property="trading"/>
         </collection>

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

@@ -5,6 +5,7 @@ import com.sckw.payment.model.KwpLedgerLogistics;
 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.req.LogisticsReq;
 import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -74,4 +75,12 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      * @return
      */
     List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
+
+    /**
+     * 根据顶级企业id统计对账单数量,仅不包含已保存
+     *
+     * @param entId 顶级企业id
+     * @return
+     */
+    LedgerSize countSize(@Param("entId") Long entId);
 }

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpLedgerTrade;
 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.req.TradeReq;
 import com.sckw.payment.model.vo.res.LedgerCountSumVo;
@@ -52,4 +53,6 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
      * @return
      */
     List<String> selectJoin(@Param("entId")Long entId, @Param("entTarget")Long entTarget);
+
+    LedgerSize countSize(@Param("entId")Long entId);
 }

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

@@ -3,12 +3,14 @@ package com.sckw.payment.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.dto.LedgerUnitDto;
+import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -68,4 +70,11 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
      * @return
      */
     List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
+    /**
+     * @param entId    顶级企业id
+     * @param cur       当月/周
+     * @param pre       上月/周
+     * @param unitType 企业类型
+     */
+    List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
 }

+ 10 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -3,12 +3,14 @@ package com.sckw.payment.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.dto.LedgerUnitDto;
+import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.model.dto.SettlementTradeDto;
 import com.sckw.payment.model.vo.req.SettlementTradeReq;
 import com.sckw.payment.model.vo.res.SettlementSumVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
 
@@ -31,7 +33,7 @@ public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade>
 
     List<LedgerUnitDto> getListById(@Param("id") Long id);
 
-    SettlementTradeDto selectDetail(@Param("id") Long id, @Param("unitTYpe") Integer unitType);
+    SettlementTradeDto selectDetail(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     /**
      * 根据双方企业查询
@@ -42,4 +44,11 @@ public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade>
      */
     List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
 
+    /**
+     * @param entId    顶级企业id
+     * @param cur       当月/周
+     * @param pre       上月/周
+     * @param unitType 企业类型
+     */
+    List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
 }

+ 9 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSize.java

@@ -0,0 +1,9 @@
+package com.sckw.payment.model.dto;
+
+
+/**
+ * @param send    对账发起方
+ * @param receive 对账接收方
+ */
+public record LedgerSize(Integer send, Integer receive) {
+}

+ 12 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/MoneyType.java

@@ -0,0 +1,12 @@
+package com.sckw.payment.model.dto;
+
+import java.math.BigDecimal;
+
+/**
+ * 按类型统计结算单金额
+ *
+ * @param money 金额
+ * @param type  1-当月/周 2-上月/周
+ */
+public record MoneyType(BigDecimal money, Integer type) {
+}

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

@@ -787,4 +787,8 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     public List<String> checkOrder(Long entId, Long entTarget) {
         return logisticsMapper.selectJoin(entId, entTarget);
     }
+
+    public LedgerSize count(Long entId) {
+        return logisticsMapper.countSize(entId);
+    }
 }

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

@@ -880,4 +880,8 @@ public class KwpLedgerTradeService extends AbsLedger {
     public void updateActualPrice(Long id, BigDecimal totalPrice) {
         tradeMapper.updatePrice(id, totalPrice);
     }
+
+    public LedgerSize count(Long entId) {
+        return tradeMapper.countSize(entId);
+    }
 }

+ 12 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -13,6 +13,7 @@ import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.dto.LedgerUnitDto;
+import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
@@ -29,6 +30,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.time.LocalDateTime;
 import java.util.*;
 
 /**
@@ -337,4 +339,14 @@ public class KwpSettlementLogisticsService {
     public List<String> checkOrder(Long entId, Long entTarget) {
         return settlementLogisticsMapper.selectJoin(entId, entTarget);
     }
+    /**
+     * @param entId    顶级企业id
+     * @param cur       当月/周
+     * @param pre       上月/周
+     * @param unitType 企业类型 2-销售 1-采购
+     */
+    public List<MoneyType> moneySum(Long entId, List<LocalDateTime> cur, List<LocalDateTime> pre, Integer unitType) {
+        return settlementLogisticsMapper.sumMoneyType(entId,  cur, pre,  unitType);
+
+    }
 }

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

@@ -26,6 +26,7 @@ import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -228,13 +229,14 @@ public class KwpSettlementTradeService {
     public void updateById(KwpSettlementTrade kwpSettlementTrade) {
         settlementTradeMapper.updateById(kwpSettlementTrade);
     }
+
     /**
      * @param entId     企业id 采购方
      * @param entTarget 另一方企业id 销售方
      * @return
      */
     public List<String> checkOrder(Long entId, Long entTarget) {
-        return settlementTradeMapper.selectJoin(entId,entTarget);
+        return settlementTradeMapper.selectJoin(entId, entTarget);
     }
 
     /**
@@ -260,4 +262,14 @@ public class KwpSettlementTradeService {
         List<SettlementWalletDto> settlementWallet = settlementWalletService.queryList(id, SettlementOrderTypeEnum.TRADE.getStatus(), TradingEnum.getPrefix(trading));
         return new SettlementDetailDto<>(settlementTradeDto, settlementWallet);
     }
+
+    /**
+     * @param entId    顶级企业id
+     * @param cur       当月/周
+     * @param pre       上月/周
+     * @param unitType 企业类型 2-销售 1-采购
+     */
+    public List<MoneyType> moneySum(Long entId, List<LocalDateTime> cur, List<LocalDateTime> pre, Integer unitType) {
+        return settlementTradeMapper.sumMoneyType(entId, cur, pre, unitType);
+    }
 }

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

@@ -4,19 +4,26 @@ import com.sckw.core.exception.BusinessException;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.dto.LedgerCount;
+import com.sckw.payment.api.model.dto.SettlementMoney;
+import com.sckw.payment.model.constant.LogisticsUnitType;
+import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.dto.LedgerSize;
+import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.service.KwpLedgerLogisticsService;
 import com.sckw.payment.service.KwpLedgerTradeService;
 import com.sckw.payment.service.KwpSettlementLogisticsService;
 import com.sckw.payment.service.KwpSettlementTradeService;
+import com.sckw.payment.utils.DateTimeUtil;
+import com.sckw.payment.utils.DecimalUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.stereotype.Service;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.time.LocalDateTime;
+import java.util.*;
 
 /**
  * @author xucaiqin
@@ -32,6 +39,23 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
     private final KwpSettlementLogisticsService settlementLogisticsService;
     private final KwpSettlementTradeService settlementTradeService;
 
+
+    private SettlementMoney change(List<MoneyType> moneyType) {
+        DecimalFormat df = new DecimalFormat("0.00");
+        BigDecimal curMoney = new BigDecimal("0.0"), preMoney = new BigDecimal("0.0");
+        for (MoneyType type : moneyType) {
+            if (type.type() == 1) {
+                curMoney = type.money();
+            } else {
+                preMoney = type.money();
+            }
+        }
+        int flag = curMoney.compareTo(preMoney) > 0 ? 1 : 2;
+
+        String percent = DecimalUtils.percent(curMoney.subtract(preMoney), preMoney);
+        return new SettlementMoney(df.format(curMoney), df.format(preMoney), percent, flag);
+    }
+
     @Override
     public Map<OrderEnum, List<String>> checkLedger(Long entId, Long entTarget) {
         if (Objects.isNull(entId) || Objects.isNull(entTarget)) {
@@ -60,8 +84,108 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
 
     @Override
     public LedgerCount countLedger(Long entId) {
-        //todo-xcq
-        return new LedgerCount(1, 1, 1, 1);
+        LedgerSize count = ledgerLogisticsService.count(entId);
+        LedgerSize ledgerSize = ledgerTradeService.count(entId);
+        return new LedgerCount(ledgerSize.send(), ledgerSize.receive(), count.send(), count.receive());
+    }
+
+
+    @Override
+    public SettlementMoney countSell(Long entId, Integer countType) {
+        log.info("销售统计:{} {}", entId, countType);
+        if (Objects.isNull(countType)) {
+            return new SettlementMoney("0.00", "0.00", "0.00%", 1);
+        }
+        List<LocalDateTime> cur = new ArrayList<>();
+        List<LocalDateTime> pre = new ArrayList<>();
+        //按周统计
+        if (countType == 1) {
+            cur.add(DateTimeUtil.getComputeDaysStart(-6));
+            cur.add(DateTimeUtil.getComputeDaysEnd(0));
+            pre.add(DateTimeUtil.getComputeDaysStart(-13));
+            pre.add(DateTimeUtil.getComputeDaysEnd(-7));
+        } else {
+            cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
+            cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
+            pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
+            pre.add(DateTimeUtil.getComputeMonthEnd(-1, 0));
+        }
+        List<MoneyType> moneyType = settlementTradeService.moneySum(entId, cur, pre, TradeUnitType.SELL);
+        return change(moneyType);
+    }
+
+    @Override
+    public SettlementMoney countPurchase(Long entId, Integer countType) {
+        log.info("采购统计:{} {}", entId, countType);
+        if (Objects.isNull(countType)) {
+            return new SettlementMoney("0.00", "0.00", "0.00%", 1);
+        }
+        List<LocalDateTime> cur = new ArrayList<>();
+        List<LocalDateTime> pre = new ArrayList<>();
+        //按周统计
+        if (countType == 1) {
+            cur.add(DateTimeUtil.getComputeDaysStart(-6));
+            cur.add(DateTimeUtil.getComputeDaysEnd(0));
+            pre.add(DateTimeUtil.getComputeDaysStart(-13));
+            pre.add(DateTimeUtil.getComputeDaysEnd(-7));
+        } else {
+            cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
+            cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
+            pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
+            pre.add(DateTimeUtil.getComputeMonthEnd(-1, 0));
+        }
+        List<MoneyType> moneyType = settlementTradeService.moneySum(entId, cur, pre, TradeUnitType.PURCHASE);
+        return change(moneyType);
+    }
+
+
+    @Override
+    public SettlementMoney countCarrier(Long entId, Integer countType) {
+        log.info("承运统计:{} {}", entId, countType);
+        if (Objects.isNull(countType)) {
+            return new SettlementMoney("0.00", "0.00", "0.00%", 1);
+        }
+        List<LocalDateTime> cur = new ArrayList<>();
+        List<LocalDateTime> pre = new ArrayList<>();
+        //按周统计
+        if (countType == 1) {
+            cur.add(DateTimeUtil.getComputeDaysStart(-6));
+            cur.add(DateTimeUtil.getComputeDaysEnd(0));
+            pre.add(DateTimeUtil.getComputeDaysStart(-13));
+            pre.add(DateTimeUtil.getComputeDaysEnd(-7));
+        } else {
+            cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
+            cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
+            pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
+            pre.add(DateTimeUtil.getComputeMonthEnd(-1, 0));
+        }
+        List<MoneyType> moneyType = settlementLogisticsService.moneySum(entId, cur, pre, LogisticsUnitType.CARRIER);
+        return change(moneyType);
+
+    }
+
+    @Override
+    public SettlementMoney countShipper(Long entId, Integer countType) {
+        log.info("托运统计:{} {}", entId, countType);
+        if (Objects.isNull(countType)) {
+            return new SettlementMoney("0.00", "0.00", "0.00%", 1);
+        }
+        List<LocalDateTime> cur = new ArrayList<>();
+        List<LocalDateTime> pre = new ArrayList<>();
+        //按周统计
+        if (countType == 1) {
+            cur.add(DateTimeUtil.getComputeDaysStart(-6));
+            cur.add(DateTimeUtil.getComputeDaysEnd(0));
+            pre.add(DateTimeUtil.getComputeDaysStart(-13));
+            pre.add(DateTimeUtil.getComputeDaysEnd(-7));
+        } else {
+            cur.add(DateTimeUtil.getComputeMonthStart(-1, 1));
+            cur.add(DateTimeUtil.getComputeMonthEnd(0, 0));
+            pre.add(DateTimeUtil.getComputeMonthStart(-2, 1));
+            pre.add(DateTimeUtil.getComputeMonthEnd(-1, 0));
+        }
+        List<MoneyType> moneyType = settlementLogisticsService.moneySum(entId, cur, pre, LogisticsUnitType.SHIPPER);
+        return change(moneyType);
     }
 }
 

+ 158 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DateTimeUtil.java

@@ -0,0 +1,158 @@
+package com.sckw.payment.utils;
+
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * @description: 时间工具类
+ * @author: LengFaQiang
+ * @copyright
+ * @create: 2022-01-27 16:04
+ **/
+public class DateTimeUtil {
+    public static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";
+    public static final DateTimeFormatter YYYY_MM_DD_HH_MM_SS = DateTimeFormatter.ofPattern(DEFAULT_PATTERN);
+    public static final DateTimeFormatter YYYYMMDDHHMMSS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+    public static final DateTimeFormatter YYYY_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+    public static final DateTimeFormatter HH_MM_SS = DateTimeFormatter.ofPattern("HH:mm:ss");
+    
+
+
+    /**
+     * 当前时间的前一个星期
+     *
+     * @return
+     */
+    public static String format(LocalDateTime localDateTime) {
+        return YYYY_MM_DD_HH_MM_SS.format(localDateTime);
+    }
+
+    /**
+     * 从当前日期计算月数差
+     *
+     * @param months 加或减的月数
+     * @return LocalDate
+     */
+    public static LocalDate getComputeMonth(long months) {
+        return getComputeMonth(LocalDate.now(), months);
+    }
+
+    /**
+     * 从给定的日期计算月数差
+     *
+     * @param months    加或减的月数
+     * @param localDate 给定的日期
+     * @return LocalDate
+     */
+    public static LocalDate getComputeMonth(LocalDate localDate, long months) {
+        return localDate.plusMonths(months);
+    }
+
+    /**
+     * 从给定的日期时间计算月数差
+     *
+     * @param months        加或减的月数
+     * @param localDateTime 给定的日期时间
+     * @return LocalDate
+     */
+    public static LocalDateTime getComputeMonth(LocalDateTime localDateTime, long months) {
+        return localDateTime.plusMonths(months);
+    }
+
+
+    /**
+     * 从当前日期计算月数差
+     *
+     * @param months 加或减的月数
+     * @param offset 偏移的天数 ±1
+     * @return LocalDateTime,时间最小值
+     */
+    public static LocalDateTime getComputeMonthStart(long months, long offset) {
+        return LocalDateTime.of(getComputeMonth(months), LocalTime.MIN).plusDays(offset);
+    }
+
+    /**
+     * 从当前日期计算月数差
+     *
+     * @param months 加或减的月数
+     * @param offset 偏移的天数 ±1
+     * @return LocalDateTime,时间最大值
+     */
+    public static LocalDateTime getComputeMonthEnd(long months, long offset) {
+        return LocalDateTime.of(getComputeMonth(months), LocalTime.MAX).plusDays(offset);
+    }
+
+    /**
+     * 从当前时间,计算天数差
+     *
+     * @param days 加或减的天数
+     * @return LocalDate
+     */
+    public static LocalDate getComputeDays(long days) {
+        return getComputeDays(LocalDate.now(), days);
+    }
+
+    /**
+     * 从给定的日期计算天数差
+     *
+     * @param days      加或减的天数
+     * @param localDate 给定的日期
+     * @return LocalDate
+     */
+    public static LocalDate getComputeDays(LocalDate localDate, long days) {
+        return localDate.plusDays(days);
+    }
+
+    /**
+     * 从给定日期时间计算天数差
+     *
+     * @param days          加或减的天数
+     * @param localDateTime 给定的日期时间
+     * @return LocalDate
+     */
+    public static LocalDateTime getComputeDays(LocalDateTime localDateTime, long days) {
+        return localDateTime.plusDays(days);
+    }
+
+
+    /**
+     * 从当前时间,计算天数差
+     *
+     * @param days 加或减的天数
+     * @return LocalDateTime,时间最小值
+     */
+    public static LocalDateTime getComputeDaysStart(long days) {
+        return LocalDateTime.of(getComputeDays(days), LocalTime.MIN);
+    }
+
+    /**
+     * 从当前时间,计算天数差
+     *
+     * @param days 加或减的天数
+     * @return LocalDateTime,时间最大值
+     */
+    public static LocalDateTime getComputeDaysEnd(long days) {
+        return LocalDateTime.of(getComputeDays(days), LocalTime.MAX);
+    }
+
+    /**
+     * 今天开始时间
+     *
+     * @return LocalDateTime yyyy-MM-dd 00:00:00
+     */
+    public static LocalDateTime todayStart() {
+        return LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
+    }
+
+    /**
+     * 今天结束时间
+     *
+     * @return LocalDateTime yyyy-MM-dd 23:59:59
+     */
+    public static LocalDateTime todayEnd() {
+        return LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
+    }
+}

+ 24 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DecimalUtils.java

@@ -1,6 +1,8 @@
 package com.sckw.payment.utils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
 import java.util.Objects;
 
 /**
@@ -8,10 +10,28 @@ import java.util.Objects;
  * @date 2023-07-31 15:25:57
  */
 public class DecimalUtils {
-    public static BigDecimal add(BigDecimal one,BigDecimal two){
-        if(Objects.isNull(one)&&Objects.isNull(two)){
-            return null;
+    private final static DecimalFormat df = new DecimalFormat("0.####");
+
+    /**
+     * @param dividend 被除数
+     * @param divisor  除数
+     * @return 百分比数据
+     */
+    public static String percent(BigDecimal dividend, BigDecimal divisor) {
+        if (Objects.isNull(dividend)) {
+            dividend = new BigDecimal("0.00");
+        }
+        //除数为0
+        if (Objects.isNull(divisor)) {
+            divisor = new BigDecimal("0.00");
+        }
+
+        if (BigDecimal.ZERO.compareTo(dividend) != 0 && BigDecimal.ZERO.compareTo(divisor) == 0) {
+            return "100.00%";
+        }
+        if (BigDecimal.ZERO.compareTo(dividend) == 0 && BigDecimal.ZERO.compareTo(divisor) == 0) {
+            return "0.00%";
         }
-        return null;
+        return df.format(dividend.divide(divisor, 6, RoundingMode.HALF_UP).multiply(new BigDecimal("100.0")).abs()) + "%";
     }
 }

+ 4 - 4
sckw-modules/sckw-payment/src/main/resources/bootstrap-test.yml

@@ -3,16 +3,16 @@ spring:
     nacos:
       discovery:
         # 服务注册地址
-        server-addr: @nacos.server@
+        server-addr: 10.10.10.224:8848
         # 命名空间
-        namespace: @nacos.namespace@
+        namespace: sckw-service-platform
         # 共享配置
         group: sckw-service-platform
       config:
         # 配置中心地址
-        server-addr: @nacos.server@
+        server-addr: 10.10.10.224:8848
         # 命名空间
-        namespace: @nacos.namespace@
+        namespace: sckw-service-platform
         # 共享配置
         group: sckw-service-platform
         # 配置文件格式

+ 19 - 7
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -83,7 +83,7 @@
         kll.receipt_time  receiptTime,
         kll.remark,
         kll.status,
-        kll.create_by createBy,
+        kll.create_by     createBy,
         kllu.top_ent_id   checkEntId,
         kllu.contacts,
         kllu.phone,
@@ -234,7 +234,7 @@
                                kllu2.unit_type = #{logisticsReq.unitTypeTwo,jdbcType=INTEGER}
         <where>
             kll.del_flag = 0
-            and kllu2.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+              and kllu2.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
             <if test="logisticsReq.unitType != null and logisticsReq.unitType == 2">
                 and kll.status not in (1, 6)
             </if>
@@ -243,14 +243,14 @@
             </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}
+                    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}, '%')
-                )
+                            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>
     </select>
@@ -313,4 +313,16 @@
               and kllu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
         </where>
     </select>
+
+    <select id="countSize" resultType="com.sckw.payment.model.dto.LedgerSize">
+        select count(distinct if(kllu.unit_type = 2, kll.id, null)) send,
+               count(distinct if(kllu.unit_type = 1, kll.id, null)) receive
+        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.status != 1
+              and kllu.top_ent_id = #{entId,jdbcType=BIGINT}
+        </where>
+    </select>
 </mapper>

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

@@ -403,4 +403,16 @@
               and kltu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
         </where>
     </select>
+
+    <select id="countSize" resultType="com.sckw.payment.model.dto.LedgerSize">
+        select count(distinct if(kltu.unit_type = 2, klt.id, null)) send,
+               count(distinct if(kltu.unit_type = 1, klt.id, null)) receive
+        from kwp_ledger_trade klt
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <where>
+            klt.del_flag = 0
+              and klt.status != 1
+              and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
+        </where>
+    </select>
 </mapper>

+ 33 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -251,4 +251,37 @@
               and lu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
         </where>
     </select>
+
+    <select id="sumMoneyType" resultType="com.sckw.payment.model.dto.MoneyType">
+        select ifnull(sum(ksl.total_price - ksl.actual_price), '0') money,
+               1                                                    type
+        from kwp_settlement_logistics ksl
+                 inner join kwp_ledger_logistics kll on ksl.l_ledger_id = kll.id and kll.del_flag = 0
+                 inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 and
+                                                              kllu.unit_type = #{unitType,jdbcType=INTEGER}
+        <where>
+            ksl.del_flag = 0
+              and kllu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and ksl.create_time
+
+            <foreach collection="cur" item="item" open="between" close="" separator="and">
+                #{item,jdbcType=TIMESTAMP}
+            </foreach>
+        </where>
+        union all
+        select ifnull(sum(ksl.total_price - ksl.actual_price), '0') money,
+               2                                                    type
+        from kwp_settlement_logistics ksl
+                 inner join kwp_ledger_logistics kll on ksl.l_ledger_id = kll.id and kll.del_flag = 0
+                 inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 and
+                                                              kllu.unit_type = #{unitType,jdbcType=INTEGER}
+        <where>
+            ksl.del_flag = 0
+              and kllu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and ksl.create_time
+            <foreach collection="pre" item="item" open="between" close="" separator="and">
+                #{item,jdbcType=TIMESTAMP}
+            </foreach>
+        </where>
+    </select>
 </mapper>

+ 37 - 4
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -292,7 +292,7 @@
         from kwp_settlement_trade kst
                  inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
-                                                          kltu.unit_type = #{unitTYpe,jdbcType=INTEGER}
+                                                          kltu.unit_type = #{unitType,jdbcType=INTEGER}
         <where>
             kst.del_flag = 0
               and kst.id = #{id,jdbcType=BIGINT}
@@ -309,9 +309,42 @@
                                                            kltu2.unit_type = 2
         <where>
             kst.del_flag = 0
-            and kst.status != 3
-            and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
-            and kltu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
+              and kst.status != 3
+              and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and kltu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
+        </where>
+    </select>
+
+    <select id="sumMoneyType" resultType="com.sckw.payment.model.dto.MoneyType">
+        select ifnull(sum(kst.total_price - kst.actual_price), '0') money,
+               1                                                    type
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
+                                                          kltu.unit_type = #{unitType,jdbcType=INTEGER}
+        <where>
+            kst.del_flag = 0
+              and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and kst.create_time
+            <foreach collection="cur" item="item" open="between" close="" separator="and">
+                #{item,jdbcType=TIMESTAMP}
+            </foreach>
+        </where>
+        union all
+        select ifnull(sum(kst.total_price - kst.actual_price), '0') money,
+               2                                                    type
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt
+                            on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
+                                                          kltu.unit_type = #{unitType,jdbcType=INTEGER}
+        <where>
+            kst.del_flag = 0
+              and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and kst.create_time
+            <foreach collection="pre" item="item" open="between" close="" separator="and">
+                #{item,jdbcType=TIMESTAMP}
+            </foreach>
         </where>
     </select>
 </mapper>

+ 6 - 6
sckw-modules/sckw-report/src/main/java/com/sckw/report/model/dto/WorkbenchOrderStsDTO.java

@@ -21,9 +21,9 @@ import java.math.BigDecimal;
 public class WorkbenchOrderStsDTO implements Serializable {
 
     public WorkbenchOrderStsDTO() {
-        this.orderAmount = BigDecimal.ZERO;
-        this.orderPrice = BigDecimal.ZERO;
-        this.orderActualAmount = BigDecimal.ZERO;
+        this.orderAmount = BigDecimal.ZERO.doubleValue();
+        this.orderPrice = BigDecimal.ZERO.doubleValue();
+        this.orderActualAmount = BigDecimal.ZERO.doubleValue();
     }
 
     @Serial
@@ -32,16 +32,16 @@ public class WorkbenchOrderStsDTO implements Serializable {
     /**
      * 订单总量
      */
-    private BigDecimal orderAmount;
+    private Double orderAmount;
 
     /**
      * 订单总金额
      */
-    private BigDecimal orderPrice;
+    private Double orderPrice;
 
     /**
      * 订单总实际成交量
      */
-    private BigDecimal orderActualAmount;
+    private Double orderActualAmount;
 
 }

+ 5 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/TOrderDataStsResVO.java

@@ -31,6 +31,11 @@ public class TOrderDataStsResVO implements Serializable {
 
     @Serial
     private static final long serialVersionUID = -6132733716009809627L;
+
+    /**
+     * 1当前周、月;2上周、月
+     */
+    private Integer type;
     /**
      * 商品数量
      */

+ 20 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/WbTOrderDataStsResVO.java

@@ -42,25 +42,45 @@ public class WbTOrderDataStsResVO implements Serializable {
      * 商品数量环比
      */
     private BigDecimal goodsNumRingRate;
+    /**
+     * 商品数量环比标识 true上升,false下降
+     */
+    private Boolean goodsNumFlag;
 
     /**
      * 订单总量环比
      */
     private BigDecimal orderAmountRingRate;
+    /**
+     * 订单总量环比标识 true上升,false下降
+     */
+    private Boolean orderAmountFlag;;
 
     /**
      * 订单金额环比
      */
     private BigDecimal orderPriceRingRate;
+    /**
+     *  订单金额环比标识  true上升,false下降
+     */
+    private Boolean orderPriceFlag;
 
     /**
      * 待付款金额环比
      */
     private BigDecimal waitCollectedPriceRingRate;
+    /**
+     * 待付款金额环比标识  true上升,false下降
+     */
+    private Boolean waitCollectedPriceFlag;
 
     /**
      * 未到货量环比
      */
     private BigDecimal notArrivedAmountRingRate;
+    /**
+     * 未到货量环比标识  true上升,false下降
+     */
+    private Boolean notArrivedAmountFlag;
 
 }

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

@@ -25,7 +25,6 @@ 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;
@@ -118,13 +117,13 @@ public class KwOrderService {
      * @date: 2023-08-25 10:32
      * @Param amount:
      * @Param entrustAmount:
-     * @return: java.math.BigDecimal
+     * @return: java.math.Double
      */
-    private BigDecimal getWaitEntrustAmount(BigDecimal amount, BigDecimal entrustAmount) {
+    private Double getWaitEntrustAmount(Double amount, Double entrustAmount) {
         if (Objects.isNull(amount) || Objects.isNull(entrustAmount)) {
             return amount;
         }
-        return amount.subtract(entrustAmount);
+        return amount - entrustAmount;
     }
 
     /**
@@ -352,7 +351,7 @@ public class KwOrderService {
         List<TradeOrderListExport> list = new ArrayList<>();
         AtomicInteger i = new AtomicInteger(1);
         orders.forEach(e -> {
-            BigDecimal waitEntrustAmount = getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount());
+            Double waitEntrustAmount = getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount());
             String loadCityName = Objects.isNull(e.getLoadCityName()) ? "" : e.getLoadCityName();
             String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
             String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();

+ 43 - 20
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderStatisticsService.java

@@ -59,9 +59,9 @@ public class KwOrderStatisticsService {
         String unit = params.getUnit();
         Integer orderType = params.getOrderType();
         Integer dateType = params.getDateType();
-        Date currentStart = DateUtils.getStartTimeByDateType(dateType, LocalDateTime.now());
-        Date lastEnd = DateUtils.getEndTimeByDateType(dateType, LocalDateTime.now());
-        Date lastStart = DateUtils.getStartTimeByDateType(dateType, DateUtils.toLocalDateTime(currentStart));
+        Date currentStart = DateUtils.getStartTime(dateType, LocalDateTime.now());
+        Date lastEnd = DateUtils.getLastEndTime(dateType);
+        Date lastStart = DateUtils.getStartTime(dateType, DateUtils.toLocalDateTime(lastEnd));
         //当前数据
         TOrderDataStsResVO currentDataSts = new TOrderDataStsResVO();
         //商品数量
@@ -70,12 +70,13 @@ public class KwOrderStatisticsService {
         Long currentGoodsNum = goodsStatisticsService.getOnShelfGoodsNum(goodsNumStsParam);
         //订单统计
         WorkbenchOrderStsDTO currentOrderSts = getOrderStsInfo(orderType, unit, currentStart, null);
-        BigDecimal currentAmount = currentOrderSts.getOrderAmount();
-        BigDecimal currentPrice = currentDataSts.getOrderPrice();
-        currentDataSts.setGoodsNum(currentGoodsNum)
+        BigDecimal currentAmount = BigDecimal.valueOf(currentOrderSts.getOrderAmount());
+        BigDecimal currentPrice = BigDecimal.valueOf(currentOrderSts.getOrderPrice());
+        currentDataSts.setType(NumberConstant.ONE)
+                .setGoodsNum(currentGoodsNum)
                 .setOrderAmount(currentAmount)
                 .setOrderPrice(currentPrice)
-                .setNotArrivedAmount(currentAmount.subtract(currentOrderSts.getOrderActualAmount()));
+                .setNotArrivedAmount(currentAmount.subtract(BigDecimal.valueOf(currentOrderSts.getOrderActualAmount())));
         //todo 待付款金额
         list.add(currentDataSts);
 
@@ -86,40 +87,61 @@ public class KwOrderStatisticsService {
         Long lastGoodsNum = goodsStatisticsService.getOnShelfGoodsNum(goodsNumStsParam);
         //订单统计
         WorkbenchOrderStsDTO lastOrderSts = getOrderStsInfo(orderType, unit, lastStart, lastEnd);
-        BigDecimal lastAmount = lastOrderSts.getOrderAmount();
-        BigDecimal lastPrice = lastOrderSts.getOrderPrice();
-        lastDataSts.setGoodsNum(lastGoodsNum)
+        BigDecimal lastAmount = BigDecimal.valueOf(lastOrderSts.getOrderAmount());
+        BigDecimal lastPrice = BigDecimal.valueOf(lastOrderSts.getOrderPrice());
+        lastDataSts.setType(NumberConstant.TWO)
+                .setGoodsNum(lastGoodsNum)
                 .setOrderAmount(lastAmount)
                 .setOrderPrice(lastPrice)
-                .setNotArrivedAmount(lastAmount.subtract(lastOrderSts.getOrderActualAmount()));
+                .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)).divide(new BigDecimal(lastGoodsNum), 2, RoundingMode.HALF_UP);
+                new BigDecimal((currentGoodsNum - lastGoodsNum)).multiply(NumberConstant.ONE_HUNDRED)
+                        .divide(new BigDecimal(lastGoodsNum), 2, RoundingMode.HALF_UP);
+        boolean goodsNumFlag = goodsNumRingRate.compareTo(BigDecimal.ZERO) >= 0;
+        goodsNumRingRate = goodsNumRingRate.abs();
         //订单总量环比
         BigDecimal orderAmountRingRate = lastAmount.compareTo(BigDecimal.ZERO) == 0 ? NumberConstant.ONE_HUNDRED :
-                (currentAmount.subtract(lastAmount)).divide(lastAmount, 2, RoundingMode.HALF_UP);
+                (currentAmount.subtract(lastAmount)).multiply(NumberConstant.ONE_HUNDRED)
+                        .divide(lastAmount, 2, RoundingMode.HALF_UP);
+        boolean orderAmountFlag = orderAmountRingRate.compareTo(BigDecimal.ZERO) >= 0;
+        orderAmountRingRate = orderAmountRingRate.abs();
         //订单总金额环比
         BigDecimal orderPriceRingRate = lastPrice.compareTo(BigDecimal.ZERO) == 0 ? NumberConstant.ONE_HUNDRED :
-                (currentPrice.subtract(lastPrice)).divide(lastPrice, 2, RoundingMode.HALF_UP);
+                (currentPrice.subtract(lastPrice)).multiply(NumberConstant.ONE_HUNDRED)
+                        .divide(lastPrice, 2, RoundingMode.HALF_UP);
+        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)).divide(lastNotArrived, 2, RoundingMode.HALF_UP);
+                (currentNotArrived.subtract(lastNotArrived)).multiply(NumberConstant.ONE_HUNDRED)
+                        .divide(lastNotArrived, 2, RoundingMode.HALF_UP);
+        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)).divide(lastWaitPrice, 2, RoundingMode.HALF_UP);
+                (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)
+                .setOrderAmountFlag(orderAmountFlag)
                 .setOrderPriceRingRate(orderPriceRingRate)
+                .setOrderPriceFlag(orderPriceFlag)
                 .setNotArrivedAmountRingRate(notArrivedAmountRingRate)
-                .setWaitCollectedPriceRingRate(waitCollectedPriceRingRate);
+                .setNotArrivedAmountFlag(notArrivedAmountFlag)
+                .setWaitCollectedPriceRingRate(waitCollectedPriceRingRate)
+                .setWaitCollectedPriceFlag(waitCollectedPriceFlag);
         return res;
     }
 
@@ -142,10 +164,11 @@ public class KwOrderStatisticsService {
         if (StringUtils.isNotBlank(unit)) {
             criteria.and("unit").is(unit);
         }
-        if (Objects.nonNull(start)) {
+        if (Objects.nonNull(start) && Objects.nonNull(end)) {
+            criteria.and("createTime").gte(start).lte(end);
+        } else if (Objects.nonNull(start)) {
             criteria.and("createTime").gte(start);
-        }
-        if (Objects.nonNull(end)) {
+        } else if (Objects.nonNull(end)) {
             criteria.and("createTime").lte(end);
         }
         Aggregation aggregation = Aggregation.newAggregation(

+ 4 - 4
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwWorkService.java

@@ -144,28 +144,28 @@ public class KwWorkService {
             if (hasSupplier) {
                 QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
                 queryBusinessStatisticsResVo.setType("销售对账");
-                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.sell()) ? Global.NUMERICAL_ZERO : ledgerCount.sell());
+                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getSell()) ? Global.NUMERICAL_ZERO : ledgerCount.getSell());
                 list.add(queryBusinessStatisticsResVo);
             }
 
             if (hasPurchase) {
                 QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
                 queryBusinessStatisticsResVo.setType("采购对账");
-                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.purchase()) ? Global.NUMERICAL_ZERO : ledgerCount.purchase());
+                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getPurchase()) ? Global.NUMERICAL_ZERO : ledgerCount.getPurchase());
                 list.add(queryBusinessStatisticsResVo);
             }
 
             if (hasCarrier) {
                 QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
                 queryBusinessStatisticsResVo.setType("承运对账");
-                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.carrier()) ? Global.NUMERICAL_ZERO : ledgerCount.carrier());
+                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getCarrier()) ? Global.NUMERICAL_ZERO : ledgerCount.getCarrier());
                 list.add(queryBusinessStatisticsResVo);
             }
 
             if (hasCheck) {
                 QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
                 queryBusinessStatisticsResVo.setType("托运对账");
-                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.shipper()) ? Global.NUMERICAL_ZERO : ledgerCount.shipper());
+                queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getShipper()) ? Global.NUMERICAL_ZERO : ledgerCount.getShipper());
                 list.add(queryBusinessStatisticsResVo);
             }
         }

+ 6 - 7
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/vo/OrderListRes.java

@@ -7,7 +7,6 @@ import lombok.Setter;
 import lombok.ToString;
 import lombok.experimental.Accessors;
 
-import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.Date;
 
@@ -134,28 +133,28 @@ public class OrderListRes {
     /**
      * 订单成交单价
      */
-    private BigDecimal unitPrice;
+    private Double unitPrice;
     /**
      * 订单金额
      */
-    private BigDecimal price;
+    private Double price;
 
     /**
      * 订单总量
      */
-    private BigDecimal amount;
+    private Double amount;
     /**
      * 已委托量
      */
-    private BigDecimal entrustAmount;
+    private Double entrustAmount;
     /**
      * 待委托量
      */
-    private BigDecimal waitEntrustAmount;
+    private Double waitEntrustAmount;
     /**
      * 实际交付量
      */
-    private BigDecimal actualAmount;
+    private Double actualAmount;
     /**
      * 归属项目
      */

+ 4 - 0
sckw-modules/sckw-system/pom.xml

@@ -67,6 +67,10 @@
             <artifactId>sckw-common-log</artifactId>
             <version>1.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-transport-api</artifactId>
+        </dependency>
 
     </dependencies>
     <build>

+ 11 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsUserController.java

@@ -3,12 +3,16 @@ package com.sckw.system.controller;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.annotation.RepeatSubmit;
+import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
+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.redis.constant.RedisConstant;
+import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
 import com.sckw.system.model.KwsUser;
 import com.sckw.system.model.vo.req.ForgetPasswordReqVo;
@@ -27,6 +31,7 @@ import java.util.List;
 
 /**
  * 用户
+ *
  * @author zk
  * @date 2023-05-30
  */
@@ -166,6 +171,12 @@ public class KwsUserController {
     public HttpResult register(@Valid @RequestBody RegisterReqDto reqVo,
                                @RequestHeader(name = "System-Type", required = true) int systemType) {
         reqVo.setSystemType(systemType);
+
+        String key = StringUtils.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, DictEnum.SMS_REGISTER.getValue(), reqVo.getPhone());
+        String sms = RedissonUtils.getString(key);
+        if (!reqVo.getCaptcha().equals(sms)) {
+            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.CAPTCHA_ERROR);
+        }
         kwsUserService.register(reqVo);
         return HttpResult.ok(HttpStatus.MSG_007);
     }

+ 5 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindEntUserPojo.java

@@ -47,4 +47,9 @@ public class FindEntUserPojo implements Serializable {
      */
     private String phone;
 
+    /**
+     * 角色名
+     */
+    private String roleName;
+
 }

+ 6 - 8
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -21,7 +21,9 @@ import com.sckw.system.dubbo.RemoteSystemServiceImpl;
 import com.sckw.system.model.*;
 import com.sckw.system.model.vo.req.*;
 import com.sckw.system.model.vo.res.KwsUserResVo;
+import com.sckw.transport.api.dubbo.TransportStatisticsService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -70,6 +72,9 @@ public class KwsUserService {
     @Autowired
     private CommonService commonService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private TransportStatisticsService transportStatisticsService;
+
     /**
      * @param reqVo 入参
      * @desc: 新增
@@ -115,12 +120,6 @@ public class KwsUserService {
      */
     @Transactional(rollbackFor = {})
     public RegisterResDto register(RegisterReqDto reqDto) {
-//        String key = StringUtils.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, DictEnum.SMS_REGISTER.getValue(), reqDto.getPhone());
-//        String sms = RedissonUtils.getString(key);
-//        if (!reqDto.getCaptcha().equals(sms)) {
-//            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.CAPTCHA_ERROR);
-//        }
-
         commonService.checkEntRepeat(reqDto.getEntName(), reqDto.getPhone());
         /*1、数据校验*/
         checkAccountValid(reqDto.getPhone(), reqDto.getSystemType());
@@ -608,11 +607,10 @@ public class KwsUserService {
     }
 
     public List<AreaTreeFrontResDto> test(List<Integer> list) {
-
+        Integer integer = transportStatisticsService.statisticsLogistics(123L);
 
         List<Long> longs = LoginUserHolder.getAuthUserIdList();
 
-//        PageResult pageResult = remoteUserService.queryEntInfoByCityCodeAndEntTypesWithPage(null, Collections.singletonList(1), 1, 10);
         return null;
     }
 

+ 13 - 4
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -99,9 +99,14 @@
       </foreach>
     </if>
     where a.del_flag = 0
-    <if test="dto.approval != null">
-      and a.approval = #{dto.approval}
-    </if>
+      <choose>
+        <when test="dto.approval != null and dto.approval == 3">
+          and a.approval in (3,4)
+        </when>
+        <when test="dto.approval != null and dto.approval != 3">
+          and a.approval = #{dto.approval}
+        </when>
+      </choose>
     <if test="dto.keywords != null">
       and (a.contacts like concat('%', #{dto.keywords}, '%') or a.phone like concat('%', #{dto.keywords}, '%') or a.firm_name like concat('%', #{dto.keywords}, '%'))
     </if>
@@ -209,15 +214,19 @@
            d.id userId,
            d.name,
            d.account,
-           d.phone
+           d.phone,
+           f.name roleName
       from kws_enterprise a
       left join kws_dept b on a.id = b.ent_id
       left join kws_user_dept c on b.id = c.dept_id
       left join kws_user d on c.user_id = d.id
+      left join kws_user_role e on d.id = e.user_id
+      left join kws_role f on e.role_id = f.id
      where a.del_flag = 0
        and b.del_flag = 0
        and c.del_flag = 0
        and d.del_flag = 0
+       and f.del_flag = 0
        and a.id in
         <foreach collection="list" separator="," open="(" close=")" item="item">
           #{item}

+ 22 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/AcceptCarriageOrderController.java

@@ -50,7 +50,6 @@ public class AcceptCarriageOrderController {
     TransportCommonService transportCommonService;
 
 
-
     /**
      * 承运订单首页条件查询
      *
@@ -95,7 +94,7 @@ public class AcceptCarriageOrderController {
     @RequestMapping(value = "/acceptCarriageOrderExport", method = RequestMethod.POST)
     public HttpResult exportAcceptCarriage(@Validated @RequestBody AcceptCarriageOrderQuery query) {
         HttpServletResponse response = RequestHolder.getResponse();
-        List<AcceptCarriageOrderExcelVo> list = acceptCarriageOrderService.exportAcceptCarriage(query,"2");
+        List<AcceptCarriageOrderExcelVo> list = acceptCarriageOrderService.exportAcceptCarriage(query, "2");
         if (!org.springframework.util.CollectionUtils.isEmpty(list)) {
             ExcelUtil.download(response, AcceptCarriageOrderExcelVo.class, list);
             return null;
@@ -123,6 +122,7 @@ public class AcceptCarriageOrderController {
 
     /**
      * 承运合同/托运合同-根据合同id获取托运订单列表
+     *
      * @param contractParam 请求参数
      * @return
      */
@@ -160,7 +160,7 @@ public class AcceptCarriageOrderController {
      */
     @RequestMapping(value = "/getAcceptCarriageOrder", method = RequestMethod.POST)
     public HttpResult getAcceptCarriageOrder(@RequestBody @Valid LogisticsOrderParam logisticsOrderParam) {
-        log.info("对账管理查询物流订单信息:{}",JSONObject.toJSONString(logisticsOrderParam));
+        log.info("对账管理查询物流订单信息:{}", JSONObject.toJSONString(logisticsOrderParam));
         try {
             return transportCommonService.getAcceptCarriageOrder(logisticsOrderParam);
         } catch (Exception e) {
@@ -312,7 +312,7 @@ public class AcceptCarriageOrderController {
         log.info("承运订单-取消派车(撤回派车)/单趟撤回请求参数:{}", JSONObject.toJSONString(baseList));
         List<String> lists = StringUtils.splitStrToList(baseList.getIds(), ",", String.class);
         try {
-            return acceptCarriageOrderService.cancelDelivery(lists,baseList.getIds());
+            return acceptCarriageOrderService.cancelDelivery(lists, baseList.getIds());
         } catch (Exception e) {
             log.error("承运订单-单趟撤回 error:{}", e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
@@ -362,7 +362,7 @@ public class AcceptCarriageOrderController {
     public HttpResult getCancelReason(@NotBlank(message = "物流订单id不能为空") @RequestParam("id") String id,
                                       @NotNull(message = "单据状态不能为空") @RequestParam("status") Integer status) {
         try {
-            return acceptCarriageOrderService.getCancelReason(id,status);
+            return acceptCarriageOrderService.getCancelReason(id, status);
         } catch (Exception e) {
             log.error("承运订单-查看撤销原因 error:{}", e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
@@ -377,7 +377,7 @@ public class AcceptCarriageOrderController {
      */
     @RequestMapping(value = "/addOrder", method = RequestMethod.POST)
     public HttpResult addOrder(@Valid @RequestBody AddOrderDTO addOrderDTO) {
-        log.info("承运订单-页面新建订单 add {}",JSONObject.toJSONString(addOrderDTO));
+        log.info("承运订单-页面新建订单 add {}", JSONObject.toJSONString(addOrderDTO));
         try {
             return acceptCarriageOrderService.addOrder(addOrderDTO);
         } catch (Exception e) {
@@ -386,4 +386,20 @@ public class AcceptCarriageOrderController {
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
+
+    /**
+     * 工作台-承运业务统计
+     *
+     * @return
+     */
+    @RequestMapping(value = "/workbenchStatistics", method = RequestMethod.GET)
+    public HttpResult workbenchStatistics(@RequestParam("dateType") @NotBlank(message = "类型不能为空") String dateType) {
+        log.info("工作台-承运业务统计 {}", dateType);
+        try {
+            return acceptCarriageOrderService.workbenchStatistics(dateType);
+        } catch (Exception e) {
+            log.error("工作台-承运业务统计 error:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
 }

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

@@ -314,4 +314,20 @@ public class ConsignOrderController {
         }
     }
 
+    /**
+     * 工作台-托运业务统计
+     *
+     * @return
+     */
+    @RequestMapping(value = "/workbenchStatistics", method = RequestMethod.GET)
+    public HttpResult workbenchStatistics(@RequestParam("dateType") @NotBlank(message = "类型不能为空") String dateType) {
+        log.info("工作台-托运业务统计 {}", dateType);
+        try {
+            return consignOrderService.workbenchStatistics(dateType);
+        } catch (Exception e) {
+            log.error("工工作台-托运业务统计 error:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
 }

+ 1 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/enterpriseApp/AppWayBillController.java

@@ -3,7 +3,6 @@ package com.sckw.transport.controller.enterpriseApp;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.transport.model.dto.WaybillListAppDTO;
-import com.sckw.transport.model.dto.WaybillOrderDTO;
 import com.sckw.transport.service.WaybillManagementService;
 import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
@@ -51,7 +50,7 @@ public class AppWayBillController {
         try {
             return waybillManagementService.waybillDataApp(waybillOrderDTO);
         } catch (Exception e) {
-            log.error("APP运单列表:订单id {},error {} ", waybillOrderDTO, e.getMessage(), e);
+            log.error("APP运单列表:error-msg: {} ,e: {}", e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }

+ 108 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/operationManagement/ManagementWaybillOrderController.java

@@ -0,0 +1,108 @@
+package com.sckw.transport.controller.operationManagement;
+
+import com.alibaba.fastjson.JSONObject;
+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.ManagementWaybillOrderQuery;
+import com.sckw.transport.model.vo.execlVo.ManagementLogisticsOrderExcelVo;
+import com.sckw.transport.model.vo.execlVo.ManagementWaybillOrderExcelVO;
+import com.sckw.transport.service.ManagementWaybillOrderService;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author  JC
+ * @description 运营管理端-运单controller
+ * @date 2023/09/12 09:20:21
+ */
+@Slf4j
+@Validated
+@RestController
+@RequiredArgsConstructor
+@RequestMapping(value = "/kwtManagementWaybillOrder")
+public class ManagementWaybillOrderController {
+
+    @Autowired
+    ManagementWaybillOrderService managementWaybillOrderService;
+
+
+    /**
+     * 运营管理端-运单-首页条件查询
+     *
+     * @param query 查询参数
+     * @return
+     */
+    @RequestMapping(value = "/select", method = RequestMethod.POST)
+    public HttpResult selectWaybillOrder(@Valid @RequestBody ManagementWaybillOrderQuery query) {
+        try {
+            return managementWaybillOrderService.selectWaybillOrder(query);
+        } catch (Exception e) {
+            log.error("运营管理端-运单-首页条件查询 查询失败:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+
+    /**
+     * 运营管理端-运单-top统计
+     *
+     * @param query 查询参数
+     * @return
+     */
+    @RequestMapping(value = "/statistics", method = RequestMethod.POST)
+    public HttpResult statisticsWaybillOrder(@Valid @RequestBody ManagementWaybillOrderQuery query) {
+        log.error("运营管理端-运单-top统计 查询 :{}", JSONObject.toJSONString(query));
+        try {
+            return managementWaybillOrderService.statisticsWaybillOrder(query);
+        } catch (Exception e) {
+            log.error("运营管理端-运单-top统计 失败 :{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+    /**
+     * 运营管理端-运单-导出
+     *
+     * @param query 查询参数
+     * @return
+     */
+    @RequestMapping(value = "/export", method = RequestMethod.POST)
+    public HttpResult exportWaybillOrder(@Validated @RequestBody ManagementWaybillOrderQuery query) {
+        log.error("运营管理端-运单-导出 query :{}", JSONObject.toJSONString(query));
+        HttpServletResponse response = RequestHolder.getResponse();
+        List<ManagementWaybillOrderExcelVO> list = managementWaybillOrderService.exportWaybillOrder(query);
+        if (!org.springframework.util.CollectionUtils.isEmpty(list)) {
+            ExcelUtil.download(response, ManagementWaybillOrderExcelVO.class, list);
+            return null;
+        }
+        return HttpResult.ok("没有可导出的数据");
+    }
+
+
+    /**
+     * 运营端-运单-获取订单详情
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "/getOrderDetail", method = RequestMethod.GET)
+    public HttpResult getOrderDetail(@RequestParam("id") Long id) {
+        try {
+            return managementWaybillOrderService.getOrderDetail(id);
+        } catch (Exception e) {
+            log.error("运营端-运单-获取订单详情失败:error :单据id:{}, errorMessage:{}", id, e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+}

+ 41 - 16
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -30,7 +30,7 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      *
      * @param logisticsOrderParam 查询参数
      * @param dictValue           字典id
-     * @param entId           托运角色
+     * @param entId               托运角色
      * @param dictValue           承运角色
      * @return
      */
@@ -215,10 +215,10 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      * @return
      */
     List<ManagementLogsiticsOrderVO> selectManagementLogisticsOrderList(@Param("query") ManagementLogisticsOrderQuery query,
-                                                         @Param("orderList") List<Integer> orderList,
-                                                         @Param("entId") Long entId,
-                                                         @Param("contactsIds") List<Long> contactsIds,
-                                                         @Param("userIds") List<Long> userIds
+                                                                        @Param("orderList") List<Integer> orderList,
+                                                                        @Param("entId") Long entId,
+                                                                        @Param("contactsIds") List<Long> contactsIds,
+                                                                        @Param("userIds") List<Long> userIds
     );
 
     /**
@@ -254,9 +254,9 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     /**
      * @param query
-     * @param orderList 单据状态
-     * @param type      代表承运或者托运
-     * @param entId 企业id
+     * @param orderList   单据状态
+     * @param type        代表承运或者托运
+     * @param entId       企业id
      * @param contactsIds 联系人id
      * @return
      */
@@ -269,19 +269,18 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
     );
 
 
-
     /**
      * @param query
-     * @param orderList 单据状态
-     * @param entId 企业id
+     * @param orderList   单据状态
+     * @param entId       企业id
      * @param contactsIds 联系人id
      * @return
      */
     List<TableTops> countManagementLogisticsOrderListByStatus(@Param("query") ManagementLogisticsOrderQuery query,
-                                                    @Param("orderList") List<Integer> orderList,
-                                                    @Param("entId") Long entId,
-                                                    @Param("contactsIds") List<Long> contactsIds,
-                                                    @Param("userIds") List<Long> userIds
+                                                              @Param("orderList") List<Integer> orderList,
+                                                              @Param("entId") Long entId,
+                                                              @Param("contactsIds") List<Long> contactsIds,
+                                                              @Param("userIds") List<Long> userIds
     );
 
     /**
@@ -297,12 +296,38 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     List<String> checkLogisticsOrderIsFinishByEntId(@Param("consignEntId") Long consignEntId, @Param("acceptCarriageEntId") Long acceptCarriageEntId, @Param("orderStatus") List<Integer> orderStatus);
 
-    Integer statisticsWaybillSendCar(@Param("ids")  List<Long> ids, @Param("orderList") List<Integer> orderList);
+    Integer statisticsWaybillSendCar(@Param("ids") List<Long> ids, @Param("orderList") List<Integer> orderList);
 
     List<Long> statisticsLogistics(@Param("topEntId") Long topEntId);
 
     Integer statisticsLogisticsByTopEntIdAndOrderStatus(@Param("topEntId") Long topEntId, @Param("orderList") List<Integer> orderList);
 
+    /**
+     *
+     * @param statusList 单据状态集合
+     * @param dateStart 开始时间
+     * @param dateEnd   结束时间
+     * @param topId 顶级企业id
+     * @param unitType  企业类型【1托运2承运】
+     * @return
+     */
+    StatisticsByOrderVO selectAcceptCarriageFinishOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
+
+    /**
+     *
+     * @param statusList 单据状态集合
+     * @param dateStart 开始时间
+     * @param dateEnd   结束时间
+     * @param topId 顶级企业id
+     * @param unitType  企业类型【1托运2承运】
+     * @return
+     */
+    StatisticsByOrderVO selectAcceptCarriageAwaitFinishOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
+
+
+    StatisticsByOrderVO selectStatisticsByOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
+
+
 //    List<TableTops> countAppLogisticsOrderListByStatus(@Param("type") String type,@Param("entId") Long entId
 //    );
 }

+ 31 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/enums/OrderTypeEnum.java

@@ -0,0 +1,31 @@
+package com.sckw.transport.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 物流订单类型枚举
+ * @author: lfdc
+ * @date: 2023-09-11 11:51
+ */
+@Getter
+@AllArgsConstructor
+public enum OrderTypeEnum {
+    CONSIGN_ORDER(1, "托运订单"),
+    ACCEPT_CARRIAGE_ORDER(2, "承运订单"),
+
+    ;
+
+    private final Integer type;
+
+    private final String label;
+
+    public static String getLabel(Integer type) {
+        for (OrderTypeEnum ele : OrderTypeEnum.values()) {
+            if (ele.getType().equals(type)) {
+                return ele.getLabel();
+            }
+        }
+        return null;
+    }
+}

+ 74 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/ManagementWaybillOrderQuery.java

@@ -0,0 +1,74 @@
+package com.sckw.transport.model.param;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.sckw.core.model.page.PageRequest;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author JC
+ * @version 1.0
+ * @desc TODO
+ * @date 2023/{07}/19 10:20:44
+ **/
+@Data
+@Accessors(chain = true)
+public class ManagementWaybillOrderQuery extends PageRequest implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -7815297050724808472L;
+
+    private String ids;
+    /**
+     * 派车开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date startSendCarTime;
+
+    /**
+     * 派车结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endSendCarTime;
+
+    /**
+     * 启送时间-查询开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date startStartTime;
+
+    /**
+     * 启送时间-查询结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endStartTime;
+
+    /**
+     * 结束时间-查询开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date startEndTime;
+
+    /**
+     * 结束时间-查询结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endEndTime;
+
+    /**
+     * 关键字搜索
+     */
+    private String keywords;
+
+    /**
+     * 运单状态
+     */
+    @JsonProperty("status")
+    @NotNull(message = "订单状态不能为空")
+    private String status;
+}

+ 168 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/ManagementCarWaybillVo.java

@@ -0,0 +1,168 @@
+package com.sckw.transport.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author lfdc
+ * @description 车辆运单
+ * @date 2023-06-27 11:06:08
+ */
+@Data
+@Accessors(chain = true)
+public class ManagementCarWaybillVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 4526063761808958350L;
+    /**
+     * 物流订单id
+     */
+    @JsonProperty(value="wOrderId")
+    private String wOrderId;
+
+    /**
+     * 物流订单号
+     */
+    @JsonProperty(value="wOrderNo")
+    private String wOrderNo;
+
+    /**
+     * 车辆牌照
+     */
+    private String truckNo;
+
+    /**
+     * 司机
+     */
+    private String driverName;
+
+    /**
+     * 运单类型数字
+     */
+    private String type;
+
+    /**
+     * 运单类型字符
+     */
+    private String typeLabel;
+
+    /**
+     * 托量单位
+     */
+    private String unit;
+
+    /**
+     * 托量单位字符
+     */
+    private String unitLabel;
+
+    /**
+     * 运单状态
+     */
+    private String  status;
+
+    /**
+     * 运单状态字符
+     */
+    private String  statusLabel;
+
+    /**
+     * 承运车队
+     */
+    private String firmName;
+
+
+    /**
+     * 派车时间
+     */
+    private String sendCarTime;
+
+    /**
+     * 计划开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date startTime;
+
+    /**
+     * 计划结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endTime;
+
+    /**
+     * 派单量/吨
+     */
+    private String entrustAmount;
+
+    /**
+     * 装货地点名称
+     */
+    private String loadName;
+
+    /**
+     * 装货地点
+     */
+    private String loadAddress;
+
+    /**
+     * 卸货地点点名称
+     */
+    private String unloadName;
+
+    /**
+     * 卸货地点
+     */
+    private String unloadAddress;
+
+    /**
+     * 实装量/吨
+     */
+    private String loadAmount;
+
+    /**
+     * 实卸量/吨
+     */
+    private String unloadAmount;
+
+    /**
+     * 装货时间
+     */
+    private String loadDateTime;
+
+    /**
+     * 卸货时间
+     */
+    private String unloadDateTime;
+
+    /**
+     * 亏吨重量
+     */
+    private String deficitAmount;
+
+    /**
+     * 扣亏损值(合理损耗-(实装-实卸))-单位
+     */
+    private String goodsPriceUnit;
+
+    /**
+     * 扣亏量(合理损耗-(实装-实卸))-单位
+     */
+    private String deficitRealAmount;
+
+    /**
+     * 创建时间
+     */
+    private String createTime;
+
+    /**
+     * 更新时间
+     */
+    private String updateTime;
+
+}

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

@@ -0,0 +1,63 @@
+package com.sckw.transport.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description 物流订单统计vo
+ * @date 2023-09-11 17:09:40
+ */
+@Data
+public class StatisticsByOrderVO implements Serializable {
+    /**
+     * 待分配量
+     */
+    @JsonProperty("waitingAmount")
+    private BigDecimal waitingAmount;
+
+    /**
+     * 已委托量(上游给他分配的量)-承运量
+     */
+    @JsonProperty("amount")
+    private BigDecimal amount;
+
+    /**
+     * 已委托量(自己承运,给下游司机分配的量)-委托给下游的量
+     */
+    @JsonProperty("entrustAmount")
+    private BigDecimal entrustAmount;
+
+    /**
+     * 分包量
+     */
+    @JsonProperty("subcontractAmount")
+    private BigDecimal subcontractAmount;
+
+    /**
+     * 运价
+     */
+    @JsonProperty("price")
+    private BigDecimal price;
+
+    /**
+     * 运输总额
+     */
+    @JsonProperty("totalPrice")
+    private BigDecimal totalPrice;
+
+    /**
+     * 环比
+     */
+    @JsonProperty("chainRatio")
+    private String chainRatio;
+
+    /**
+     * 1 增长 2下降
+     */
+    @JsonProperty("flag")
+    private Integer flag;
+}

+ 84 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/execlVo/ManagementWaybillOrderExcelVO.java

@@ -0,0 +1,84 @@
+package com.sckw.transport.model.vo.execlVo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author JC
+ * @version 1.0
+ * @desc TODO
+ * @date 2023/{07}/19 10:20:44
+ **/
+@Data
+@Accessors(chain = true)
+@ExcelContext(fileName = "运单列表信息", sheetName = "运单列表信息")
+public class ManagementWaybillOrderExcelVO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -2111424783071112237L;
+
+    @ExcelProperty(value = "序号" )
+    private String serialNumber;
+
+    @ExcelProperty(value = "运单" )
+    private String status;
+
+    @ExcelProperty(value = "运单号" )
+    private String wOrderNo;
+
+    @ExcelProperty(value = "车辆车牌" )
+    private String truckNo;
+
+    @ExcelProperty(value = "车辆司机" )
+    private String driverName;
+
+    @ExcelProperty(value = "运单类型")
+    private String type;
+
+    @ExcelProperty(value = "派车时间")
+    private String sendCarTime;
+
+    @ExcelProperty(value = "计划开始时间")
+    private String startTime;
+
+    @ExcelProperty(value = "计划结束时间")
+    private String endTime;
+
+    @ExcelProperty(value = "派车量/吨")
+    private String entrustAmount;
+
+    @ExcelProperty(value = "装货地址名称")
+    private String loadName;
+
+    @ExcelProperty(value = "装货地址明细")
+    private String loadAddress;
+
+    @ExcelProperty(value = "卸货地址名称")
+    private String unloadName;
+
+    @ExcelProperty(value = "卸货地址明细")
+    private String unloadAddress;
+
+    @ExcelProperty(value = "实装量/吨")
+    private String loadAmount;
+
+    @ExcelProperty(value = "实卸量/吨")
+    private String unloadAmount;
+
+    @ExcelProperty(value = "亏吨量/吨")
+    private String deficitAmount;
+
+    @ExcelProperty(value = "装货时间")
+    private String loadDateTime;
+
+    @ExcelProperty(value = "卸货时间")
+    private String unloadDateTime;
+
+    @ExcelProperty(value = "更新时间")
+    private String updateTime;
+
+}

+ 112 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java

@@ -21,6 +21,7 @@ import com.sckw.core.utils.*;
 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.excel.utils.ValidUtil;
 import com.sckw.fleet.api.RemoteFleetService;
 import com.sckw.fleet.api.model.vo.RTruckVo;
@@ -44,13 +45,13 @@ import com.sckw.system.api.model.dto.res.EntCacheResDto;
 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.enums.OrderTypeEnum;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.*;
 import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
 import com.sckw.transport.model.param.DriverParam;
 import com.sckw.transport.model.vo.*;
 import com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo;
-import com.sckw.transport.model.vo.AcceptCarriageOrderVO;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -64,6 +65,8 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -2611,4 +2614,112 @@ public class AcceptCarriageOrderService {
         }
         return exportList;
     }
+
+    /**
+     * 工作台-承运业务统计
+     *
+     * @param dateType
+     * @return
+     */
+    public HttpResult workbenchStatistics(String dateType) {
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
+        Long id = entCacheResDto.getId();
+        //周
+        if (String.valueOf(NumberConstant.ONE).equals(dateType)) {
+
+            //本周时间
+
+            //开始时间
+            String weekDateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 6);
+            //结束时间
+            String weekDateEnd = DateUtil.getLastWeekDateEndToString(0);
+            //环比上周
+            //开始时间
+            String lastWeekDateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 13);
+            //结束时间
+            String lastWeekDateEnd = DateUtil.getLastWeekDateEndToString(7);
+            return computeCompare(id, weekDateStart, weekDateEnd, lastWeekDateStart, lastWeekDateEnd);
+        } else if (String.valueOf(NumberConstant.TWO).equals(dateType)) {
+
+            //本月
+            //开始时间
+            String monthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 1, -1);
+            //结束时间
+            String monthDateEnd = DateUtil.getLastWeekDateEndToString(0);
+
+
+            //环比上月
+
+            //上个月
+            //开始时间
+            String lastMonthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 2, -1);
+            //结束时间
+            String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(), 1, 0);
+            return computeCompare(id, monthDateStart, monthDateEnd, lastMonthDateStart, lastMonthDateEnd);
+        } else if (String.valueOf(NumberConstant.THREE).equals(dateType)) {
+            //年
+            // 获取当前日期
+            String currentDateEnd = DateUtil.format(LocalDate.now()) + " 23:59:59";
+            LocalDate currentDate = LocalDate.now();
+            // 计算一年前的日期
+            LocalDate oneYearAgo = currentDate.minusYears(1);
+            LocalDateTime currentDateStart = oneYearAgo.atStartOfDay();
+
+        } else {
+            HttpResult.error("统计纬度错误!");
+        }
+        return null;
+    }
+
+    /**
+     * 环比计算
+     *
+     * @param id                企业集团id
+     * @param weekDateStart     环比本次开始时间
+     * @param weekDateEnd       环比本次结束时间
+     * @param lastWeekDateStart 环比上次开始时间
+     * @param lastWeekDateEnd   环比上次结束时间
+     * @return
+     */
+    private HttpResult computeCompare(Long id, String weekDateStart, String weekDateEnd, String lastWeekDateStart, String lastWeekDateEnd) {
+        HttpResult httpResult = new HttpResult();
+        //获取完结的单据-排除掉不做统计中的数据
+        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());
+        //本周
+        StatisticsByOrderVO currentWeek = logisticsOrderMapper.selectStatisticsByOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType());
+
+        //上周
+        StatisticsByOrderVO lastWeek = logisticsOrderMapper.selectStatisticsByOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType());
+        //环比计算
+        StatisticsByOrderVO vo = new StatisticsByOrderVO();
+        BeanUtils.copyProperties(currentWeek, vo);
+        Integer flag = 1;
+        BigDecimal chainRatio = new BigDecimal("0.00");
+        if (currentWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0
+                && lastWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("0.00");
+        } else if (currentWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = chainRatio.subtract(new BigDecimal("100.00"));
+            flag = 2;
+        } else if (lastWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("100.00").subtract(chainRatio);
+        } else {
+            chainRatio = (currentWeek.getWaitingAmount().subtract(lastWeek.getWaitingAmount())).divide(lastWeek.getWaitingAmount(),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) {
+            flag = 2;
+        }
+        vo.setFlag(flag);
+        vo.setChainRatio(chainRatio.abs() + "%");
+        httpResult.setData(vo);
+        return httpResult;
+    }
 }

+ 38 - 35
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/CommonService.java

@@ -218,14 +218,14 @@ public class CommonService {
         //用户数据集
         userIds = userIds.stream().distinct().collect(Collectors.toList());
         Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(userIds);
-        users.forEach((key,value) -> {
+        users.forEach((key, value) -> {
             UserInfoVo userInfo = new UserInfoVo();
             BeanUtils.copyProperties(value, userInfo);
             userList.add(userInfo);
         });
 
         Map<Long, RDriverVo> drivers = remoteFleetService.findDriver(userIds);
-        drivers.forEach((key,value) -> {
+        drivers.forEach((key, value) -> {
             UserInfoVo userInfo = new UserInfoVo();
             BeanUtils.copyProperties(value, userInfo);
             userList.add(userInfo);
@@ -345,9 +345,9 @@ public class CommonService {
         Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
         map.put("orderNo", lOrderNo);
         if (flag && createBy.equals(checkUnit.getContactsId())) {
-            sendMessageNewLogisticsOrder(checkUnit, map,MessageEnum.NEW_LOGISTICS_ORDER,consignLogisticsOrderUrl);
+            sendMessageNewLogisticsOrder(checkUnit, map, MessageEnum.NEW_LOGISTICS_ORDER, consignLogisticsOrderUrl);
         } else if (flag && createBy.equals(carriageUnit.getContactsId())) {
-            sendMessageNewLogisticsOrder(carriageUnit, map,MessageEnum.NEW_CARRIAGE_ORDER,carriageLogisticsOrderUrl);
+            sendMessageNewLogisticsOrder(carriageUnit, map, MessageEnum.NEW_CARRIAGE_ORDER, carriageLogisticsOrderUrl);
         } else {
             UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
             //给订单创建人发消息
@@ -365,8 +365,8 @@ public class CommonService {
                     .setCreateBy(LoginUserHolder.getUserId());
             log.info("托运订单/承运订单自建物流订单-创建人:{}", JSON.toJSONString(msg));
             streamBridge.send("sckw-message", JSON.toJSONString(msg));
-            sendMessageNewLogisticsOrder(checkUnit, map,MessageEnum.NEW_LOGISTICS_ORDER,consignLogisticsOrderUrl);
-            sendMessageNewLogisticsOrder(carriageUnit, map,MessageEnum.NEW_CARRIAGE_ORDER,carriageLogisticsOrderUrl);
+            sendMessageNewLogisticsOrder(checkUnit, map, MessageEnum.NEW_LOGISTICS_ORDER, consignLogisticsOrderUrl);
+            sendMessageNewLogisticsOrder(carriageUnit, map, MessageEnum.NEW_CARRIAGE_ORDER, carriageLogisticsOrderUrl);
         }
 
     }
@@ -374,9 +374,10 @@ public class CommonService {
     /**
      * 托运订单-新建订单
      * 承运订单-新建订单
-     * @param checkUnit 托运单位
-     * @param map   请求参数
-     * @param messageEnum   消息枚举
+     *
+     * @param checkUnit                托运单位
+     * @param map                      请求参数
+     * @param messageEnum              消息枚举
      * @param consignLogisticsOrderUrl 页面地址url
      */
     private void sendMessageNewLogisticsOrder(KwtLogisticsOrderUnit checkUnit, Map<String, Object> map, MessageEnum messageEnum, String consignLogisticsOrderUrl) {
@@ -400,16 +401,17 @@ public class CommonService {
 
     /**
      * 撤销托运
-     * @param consignUnit 托运订单
-     * @param carriageUnit 承运订单
-     * @param orderNo  物流订单
-     * @param createBy  创建人
-     * @param entId 当前单据企业id
-     * @param consignMessageEnum 托运单位使用的消息枚举
+     *
+     * @param consignUnit         托运订单
+     * @param carriageUnit        承运订单
+     * @param orderNo             物流订单
+     * @param createBy            创建人
+     * @param entId               当前单据企业id
+     * @param consignMessageEnum  托运单位使用的消息枚举
      * @param carriageMessageEnum 承运单位使用的消息枚举
      */
-    public void cancelLogisticsConsignment(KwtLogisticsOrderUnit consignUnit,KwtLogisticsOrderUnit carriageUnit ,String orderNo, Long createBy, Long entId,
-                                           MessageEnum consignMessageEnum,MessageEnum carriageMessageEnum) {
+    public void cancelLogisticsConsignment(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit, String orderNo, Long createBy, Long entId,
+                                           MessageEnum consignMessageEnum, MessageEnum carriageMessageEnum) {
         boolean flag = false;
         if (createBy.equals(consignUnit.getContactsId()) || createBy.equals(carriageUnit.getContactsId())) {
             flag = true;
@@ -417,9 +419,9 @@ public class CommonService {
         Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
         map.put("orderNo", orderNo);
         if (flag && createBy.equals(consignUnit.getContactsId())) {
-            sendMessagePublicLogistics(consignUnit, carriageUnit, map,consignMessageEnum);
+            sendMessagePublicLogistics(consignUnit, carriageUnit, map, consignMessageEnum);
         } else if (flag && createBy.equals(carriageUnit.getContactsId())) {
-            sendMessagePublicLogistics(consignUnit, carriageUnit, map,carriageMessageEnum);
+            sendMessagePublicLogistics(consignUnit, carriageUnit, map, carriageMessageEnum);
         } else {
             UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
             //给订单创建人发消息
@@ -435,8 +437,8 @@ public class CommonService {
                     .setMsgUrl(consignLogisticsOrderUrl)
                     .setUserInfos(userInfos)
                     .setCreateBy(LoginUserHolder.getUserId());
-            log.info(MessageEnum.getDesc(consignMessageEnum)+"-创建人:{}", JSON.toJSONString(msg));
-
+            log.info(MessageEnum.getDesc(consignMessageEnum) + "-创建人:{}", JSON.toJSONString(msg));
+            streamBridge.send("sckw-message", JSON.toJSONString(msg));
             sendMessagePublicLogistics(consignUnit, carriageUnit, map,consignMessageEnum);
         }
     }
@@ -444,16 +446,17 @@ public class CommonService {
 
     /**
      * 公共推送消息处理
-     * @param consignUnit 托运订单
-     * @param carriageUnit 承运订单
-     * @param orderNo  物流订单
-     * @param createBy  创建人
-     * @param entId 当前单据企业id
-     * @param consignMessageEnum 托运单位使用的消息枚举
+     *
+     * @param consignUnit         托运订单
+     * @param carriageUnit        承运订单
+     * @param orderNo             物流订单
+     * @param createBy            创建人
+     * @param entId               当前单据企业id
+     * @param consignMessageEnum  托运单位使用的消息枚举
      * @param carriageMessageEnum 承运单位使用的消息枚举
      */
-    public void publicLogisticsConsignmentPushMessage(KwtLogisticsOrderUnit consignUnit,KwtLogisticsOrderUnit carriageUnit ,String orderNo, Long createBy, Long entId,
-                                           MessageEnum consignMessageEnum,MessageEnum carriageMessageEnum) {
+    public void publicLogisticsConsignmentPushMessage(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit, String orderNo, Long createBy, Long entId,
+                                                      MessageEnum consignMessageEnum, MessageEnum carriageMessageEnum) {
         boolean flag = false;
         if (createBy.equals(consignUnit.getContactsId()) || createBy.equals(carriageUnit.getContactsId())) {
             flag = true;
@@ -461,9 +464,9 @@ public class CommonService {
         Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
         map.put("orderNo", orderNo);
         if (flag && createBy.equals(consignUnit.getContactsId())) {
-            sendMessagePublicLogistics(consignUnit, carriageUnit, map,consignMessageEnum);
+            sendMessagePublicLogistics(consignUnit, carriageUnit, map, consignMessageEnum);
         } else if (flag && createBy.equals(carriageUnit.getContactsId())) {
-            sendMessagePublicLogistics(consignUnit, carriageUnit, map,carriageMessageEnum);
+            sendMessagePublicLogistics(consignUnit, carriageUnit, map, carriageMessageEnum);
         } else {
             UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
             //给订单创建人发消息
@@ -479,14 +482,14 @@ public class CommonService {
                     .setMsgUrl(consignLogisticsOrderUrl)
                     .setUserInfos(userInfos)
                     .setCreateBy(LoginUserHolder.getUserId());
-            log.info(MessageEnum.getDesc(consignMessageEnum)+"-创建人:{}", JSON.toJSONString(msg));
+            log.info(MessageEnum.getDesc(consignMessageEnum) + "-创建人:{}", JSON.toJSONString(msg));
             streamBridge.send("sckw-message", JSON.toJSONString(msg));
 //            sendMessagePublicLogistics(consignUnit, carriageUnit, map,consignMessageEnum);
         }
     }
 
 
-    private void sendMessagePublicLogistics(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit, Map<String, Object> map,MessageEnum consignMessageEnum) {
+    private void sendMessagePublicLogistics(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit, Map<String, Object> map, MessageEnum consignMessageEnum) {
         //给业务联系人发消息[承运方]
         List<UserInfo> userInfoList = new ArrayList<>();
         UserInfo userInfo = new UserInfo();
@@ -500,7 +503,7 @@ public class CommonService {
                 .setMsgUrl(carriageLogisticsOrderUrl)
                 .setUserInfos(userInfoList)
                 .setCreateBy(LoginUserHolder.getUserId());
-        log.info(MessageEnum.getDesc(consignMessageEnum)+"-[承运方]-业务联系人:{}", JSON.toJSONString(sckwMessage));
+        log.info(MessageEnum.getDesc(consignMessageEnum) + "-[承运方]-业务联系人:{}", JSON.toJSONString(sckwMessage));
         streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
 
 
@@ -517,7 +520,7 @@ public class CommonService {
                 .setMsgUrl(carriageLogisticsOrderUrl)
                 .setUserInfos(list)
                 .setCreateBy(LoginUserHolder.getUserId());
-        log.info(MessageEnum.getDesc(consignMessageEnum)+"-[托运方]-业务联系人:{}", JSON.toJSONString(message));
+        log.info(MessageEnum.getDesc(consignMessageEnum) + "-[托运方]-业务联系人:{}", JSON.toJSONString(message));
         streamBridge.send("sckw-message", JSON.toJSONString(message));
     }
 }

+ 133 - 8
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -41,6 +41,7 @@ import com.sckw.system.api.model.dto.res.EntCacheResDto;
 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.enums.OrderTypeEnum;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.*;
 import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
@@ -61,6 +62,8 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -786,7 +789,7 @@ public class ConsignOrderService {
         logisticsOrder.setUpdateBy(LoginUserHolder.getUserId());
         logisticsOrder.setIgnoreAmount(ignoreAmount);
         kwtLogisticsOrderMapper.updateById(logisticsOrder);
-        updateLogisticOrderTrack(logisticsOrder.getId(),LogisticsOrderEnum.HAVE_FINISHED,orderFinishDTO.getRemark());
+        updateLogisticOrderTrack(logisticsOrder.getId(), LogisticsOrderEnum.HAVE_FINISHED, orderFinishDTO.getRemark());
         //获取物流订单下的子单
         /**完结订单-对应物流订单下子订单都要进行完结*/
         List<KwtLogisticsOrder> kwtLogisticsOrders = kwtLogisticsOrderMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrder>()
@@ -899,15 +902,13 @@ public class ConsignOrderService {
     }
 
 
-
     /**
      * 修改物流表+新增物流状态记录
      *
      * @param lOrderId
      * @param logisticsOrderEnum
-
      */
-    private void updateLogisticOrderTrack(Long lOrderId,LogisticsOrderEnum logisticsOrderEnum,String remark) {
+    private void updateLogisticOrderTrack(Long lOrderId, LogisticsOrderEnum logisticsOrderEnum, String remark) {
         KwtLogisticsOrderTrack track = kwtLogisticsOrderTrackMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderTrack>()
                 .eq(KwtLogisticsOrderTrack::getLOrderId, lOrderId).eq(KwtLogisticsOrderTrack::getStatus, logisticsOrderEnum.getCode())
         );
@@ -1219,7 +1220,7 @@ public class ConsignOrderService {
         /**保存mongodb*/
         saveMongoDb(addOrderDTO, orderStatus, lOrderId, lOrderNo, infoResDto);
         /**消息主体*/
-        commonService.newLogisticsOrder(addOrderDTO,lOrderNo,LoginUserHolder.getUserId(),LoginUserHolder.getEntId());
+        commonService.newLogisticsOrder(addOrderDTO, lOrderNo, LoginUserHolder.getUserId(), LoginUserHolder.getEntId());
         return HttpResult.ok();
     }
 
@@ -1641,7 +1642,7 @@ public class ConsignOrderService {
         List<Long> longs = LoginUserHolder.getAuthUserIdList();
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
-        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
+        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId, longList, longList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
@@ -1750,7 +1751,7 @@ public class ConsignOrderService {
         List<Long> longs = LoginUserHolder.getAuthUserIdList();
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
-        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId,longList,longList);
+        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId, longList, longList);
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
@@ -1844,7 +1845,7 @@ public class ConsignOrderService {
         List<Long> longs = LoginUserHolder.getAuthUserIdList();
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
-        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId,longList,longList);
+        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId, longList, longList);
         /**计费方式*/
         Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/
@@ -1917,4 +1918,128 @@ public class ConsignOrderService {
         }
         return exportList;
     }
+
+    public HttpResult workbenchStatistics(String dateType) {
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
+        if (entCacheResDto == null) {
+            return HttpResult.ok(new StatisticsByOrderVO());
+        }
+        //周
+        if (String.valueOf(NumberConstant.ONE).equals(dateType)) {
+            //本周时间
+
+            //开始时间
+            String weekDateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 6);
+            //结束时间
+            String weekDateEnd = DateUtil.getLastWeekDateEndToString(0);
+            //环比上周
+            //开始时间
+            String lastWeekDateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 13);
+            //结束时间
+            String lastWeekDateEnd = DateUtil.getLastWeekDateEndToString(7);
+            return computeCompare(entCacheResDto.getId(), weekDateStart, weekDateEnd, lastWeekDateStart, lastWeekDateEnd);
+        } else if (String.valueOf(NumberConstant.TWO).equals(dateType)) {
+            //月
+            //开始时间
+            String monthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 1, -1);
+            //结束时间
+            String monthDateEnd = DateUtil.getLastWeekDateEndToString(0);
+            //环比上月
+            //开始时间
+            String lastMonthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 2, -1);
+            //结束时间
+            String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(), 1, 0);
+            return computeCompare(entCacheResDto.getId(), monthDateStart, monthDateEnd, lastMonthDateStart, lastMonthDateEnd);
+        } else if (String.valueOf(NumberConstant.THREE).equals(dateType)) {
+            //年
+
+        } else {
+            HttpResult.error("统计纬度错误!");
+        }
+        return null;
+    }
+
+
+    /**
+     * 托运订单计算环比
+     *
+     * @param id                集团id
+     * @param weekDateStart     环比本次开始时间
+     * @param weekDateEnd       环比本次结束时间
+     * @param lastWeekDateStart 环比上次开始时间
+     * @param lastWeekDateEnd   环比上次结束时间
+     * @return
+     */
+    private HttpResult computeCompare(Long id, String weekDateStart, String weekDateEnd, String lastWeekDateStart, String lastWeekDateEnd) {
+        HttpResult httpResult = new HttpResult();
+        //本周
+        //排除掉不做统计中的数据
+        //获取完结的单据
+        List<Integer> statusList = new ArrayList<>();
+        statusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
+        StatisticsByOrderVO statistics = kwtLogisticsOrderMapper.selectAcceptCarriageFinishOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
+        //获取完结中的单据
+        statusList.clear();
+        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());
+        StatisticsByOrderVO statisticsByOrderVO = kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
+        //全部的未履约量
+        BigDecimal waitingAmount = statistics.getWaitingAmount().add(statisticsByOrderVO.getWaitingAmount());
+        BigDecimal amount = statistics.getAmount().add(statisticsByOrderVO.getAmount());
+        BigDecimal entrustAmount = statistics.getEntrustAmount().add(statisticsByOrderVO.getEntrustAmount());
+        BigDecimal subcontractAmount = statistics.getSubcontractAmount().add(statisticsByOrderVO.getSubcontractAmount());
+        BigDecimal totalPrice = statistics.getTotalPrice().add(statisticsByOrderVO.getTotalPrice());
+
+
+        StatisticsByOrderVO vo = new StatisticsByOrderVO();
+        vo.setWaitingAmount(waitingAmount);
+        vo.setAmount(amount);
+        vo.setEntrustAmount(entrustAmount);
+        vo.setSubcontractAmount(subcontractAmount);
+        vo.setTotalPrice(totalPrice);
+
+        //上周
+
+        //获取完结的单据
+        statusList.clear();
+        statusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
+        StatisticsByOrderVO lastStatistics = kwtLogisticsOrderMapper.selectAcceptCarriageFinishOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
+        //获取完结中的单据
+        statusList.clear();
+        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());
+        StatisticsByOrderVO lastStatisticsByOrderVO = kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
+        //全部的未履约量
+        BigDecimal lastWaitingAmount = lastStatistics.getWaitingAmount().add(lastStatisticsByOrderVO.getWaitingAmount());
+        //环比计算
+        BigDecimal chainRatio = new BigDecimal("0.00");
+        Integer flag = 1;
+        if (waitingAmount.compareTo(new BigDecimal("0.00")) == 0
+                && lastWaitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("0.00");
+        } else if (waitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = chainRatio.subtract(new BigDecimal("100.00"));
+            flag = 2;
+        } 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)
+                    .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
+        }
+        if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
+            flag = 2;
+        }
+        vo.setFlag(flag);
+        vo.setChainRatio(chainRatio.abs() + "%");
+        httpResult.setData(vo);
+        return httpResult;
+    }
 }

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java

@@ -462,7 +462,7 @@ public class KwtWaybillOrderService {
 
                 //当前下游司机委派量 + 历史下游司机委派量 + 分包量
                 BigDecimal actualAmount = ranksAmount.add(entrustAmountTotal);
-                if (actualAmount.compareTo(logisticsOrder.getAmount()) > 0) {
+                if (actualAmount.doubleValue() > logisticsOrder.getAmount().doubleValue()) {
                     return HttpResult.error("累计派车量已大于剩余可运量!");
                 }
             }

+ 6 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java

@@ -1083,15 +1083,15 @@ public class LogisticsConsignmentService {
                 //托运
                 KwtLogisticsOrderUnit consignUnit = kwtLogisticsOrderUnitMapper.selectOne(
                         new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
-                                .eq(KwtLogisticsOrderUnit::getLOrderId,s)
+                                .eq(KwtLogisticsOrderUnit::getLOrderId,kwtLogisticsOrder.getId())
                                 .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.ONE));
                 //承运
                 KwtLogisticsOrderUnit carriageUnit = kwtLogisticsOrderUnitMapper.selectOne(
                         new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
-                                .eq(KwtLogisticsOrderUnit::getLOrderId,s)
+                                .eq(KwtLogisticsOrderUnit::getLOrderId,kwtLogisticsOrder.getId())
                                 .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
-                commonService.cancelLogisticsConsignment(consignUnit,carriageUnit,logisticsOrder.getLOrderNo(),logisticsOrder.getCreateBy(),
-                        logisticsOrder.getEntId(), MessageEnum.CANCELLATION_LOGISTICS,MessageEnum.CARRIAGE_CANCELLATION_LOGISTICS);
+                commonService.cancelLogisticsConsignment(consignUnit,carriageUnit,kwtLogisticsOrder.getLOrderNo(),kwtLogisticsOrder.getCreateBy(),
+                        kwtLogisticsOrder.getEntId(), MessageEnum.CANCELLATION_LOGISTICS,MessageEnum.CARRIAGE_CANCELLATION_LOGISTICS);
             } else {
                 result.setMsg("操作失败:" + httpResult.getMsg());
                 result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
@@ -1184,8 +1184,8 @@ public class LogisticsConsignmentService {
                         new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
                                 .eq(KwtLogisticsOrderUnit::getLOrderId,id)
                                 .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
-                commonService.cancelLogisticsConsignment(consignUnit,carriageUnit,logisticsOrder.getLOrderNo(),logisticsOrder.getCreateBy(),
-                        logisticsOrder.getEntId(), MessageEnum.CANCELLATION_LOGISTICS,MessageEnum.CARRIAGE_CANCELLATION_LOGISTICS);
+                commonService.cancelLogisticsConsignment(consignUnit,carriageUnit,kwtLogisticsOrder.getLOrderNo(),kwtLogisticsOrder.getCreateBy(),
+                        kwtLogisticsOrder.getEntId(), MessageEnum.CANCELLATION_LOGISTICS,MessageEnum.CARRIAGE_CANCELLATION_LOGISTICS);
             } else {
                 result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
                 result.setMsg("操作失败:" + httpResult.getMsg());

+ 323 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementWaybillOrderService.java

@@ -0,0 +1,323 @@
+package com.sckw.transport.service;
+
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.model.enums.CarWaybillEnum;
+import com.sckw.core.model.page.PageResult;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.StringUtils;
+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.SckwWaybillOrder;
+import com.sckw.mongo.model.TableTops;
+import com.sckw.transport.model.param.ManagementWaybillOrderQuery;
+import com.sckw.transport.model.vo.ManagementCarWaybillVo;
+import com.sckw.transport.model.vo.execlVo.ManagementWaybillOrderExcelVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.data.mongodb.core.aggregation.AggregationResults;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Pattern;
+
+/**
+ * @author JC
+ * @version 1.0
+ * @desc TODO
+ * @date 2023/09/12 09:20:21
+ **/
+@Slf4j
+@Service
+public class ManagementWaybillOrderService {
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Autowired
+    private CommonService commonService;
+
+    @Autowired
+    private WaybillManagementService waybillManagementService;
+
+    /**
+     * 构造运单关联查询条件
+     *
+     * @param query
+     * @return
+     */
+    public Criteria newBuildWaybillOrdersQuery(ManagementWaybillOrderQuery query) {
+        // 模糊匹配
+        // 根据条件查询所有并排序,且分页
+        // 设置模糊查询匹配规则  忽略大小写
+        // 创建条件对象
+        Criteria criteria = new Criteria();
+        criteria.and("entId").is(LoginUserHolder.getEntId());
+        criteria.and("delFlag").is(NumberConstant.ZERO);
+        // 运单状态
+        if (StringUtils.isNotBlank(query.getStatus()) && (!"all".equals(query.getStatus()))) {
+            criteria.and("status").is(Integer.valueOf(query.getStatus()));
+        }
+
+        // 派车时间
+        if (Objects.nonNull(query.getStartSendCarTime()) && Objects.nonNull(query.getEndSendCarTime())) {
+            criteria.and("sendCarTime").gte(query.getStartSendCarTime()).lte(DateUtil.offsetDay(query.getEndSendCarTime(), 1));
+        } else if (Objects.nonNull(query.getStartSendCarTime())) {
+            criteria.and("sendCarTime").gte(query.getStartSendCarTime());
+        } else if (Objects.nonNull(query.getEndSendCarTime())) {
+            criteria.and("sendCarTime").lte(DateUtil.offsetDay(query.getEndSendCarTime(), 1));
+        }
+        // 计划开始时间
+        if (Objects.nonNull(query.getStartStartTime()) && Objects.nonNull(query.getEndStartTime())) {
+            criteria.and("startTime").gte(query.getStartStartTime()).lte(DateUtil.offsetDay(query.getEndStartTime(), 1));
+        } else if (Objects.nonNull(query.getStartStartTime())) {
+            criteria.and("startTime").gte(query.getStartStartTime());
+        } else if (Objects.nonNull(query.getEndStartTime())) {
+            criteria.and("startTime").lte(DateUtil.offsetDay(query.getEndStartTime(), 1));
+        }
+        // 计划结束时间
+        if (Objects.nonNull(query.getStartEndTime()) && Objects.nonNull(query.getEndEndTime())) {
+            criteria.and("endTime").gte(query.getStartEndTime()).lte(DateUtil.offsetDay(query.getEndEndTime(), 1));
+        } else if (Objects.nonNull(query.getStartEndTime())) {
+            criteria.and("endTime").gte(query.getStartEndTime());
+        } else if (Objects.nonNull(query.getEndEndTime())) {
+            criteria.and("endTime").lte(DateUtil.offsetDay(query.getEndEndTime(), 1));
+        }
+        // 多条件模糊查询
+        List<Criteria> orCriteria = new ArrayList<>();
+        if (StringUtils.isNotBlank(query.getKeywords())) {
+            Pattern pattern = Pattern.compile("^.*" + query.getKeywords() + ".*$", Pattern.CASE_INSENSITIVE);
+            orCriteria.add(Criteria.where("wOrderNo").regex(pattern));
+            orCriteria.add(Criteria.where("truckNo").regex(pattern));
+            orCriteria.add(Criteria.where("driverName").regex(pattern));
+            orCriteria.add(Criteria.where("firmName").regex(pattern));
+            criteria.orOperator(orCriteria);
+        }
+        return criteria;
+    }
+
+    /**
+     * 运单列表
+     * @param query
+     * @return
+     */
+    public HttpResult selectWaybillOrder(ManagementWaybillOrderQuery query) {
+        Criteria criteria = newBuildWaybillOrdersQuery(query);
+
+        Query queryFormat = new Query(criteria);
+        // in查询
+        List<Long> wOrderIds = StringUtils.splitStrToList(query.getIds(), ",", Long.class);
+        if (CollectionUtils.isNotEmpty(wOrderIds)) {
+            queryFormat.addCriteria(Criteria.where("wOrderId").in(wOrderIds));
+        }
+        // 总记录数
+        long total = mongoTemplate.count(queryFormat, SckwWaybillOrder.class);
+        queryFormat.with(PageRequest.of(query.getPage() - 1, query.getPageSize(),
+                Sort.by(Sort.Order.desc("createTime"))));
+        // 执行查询
+        List<SckwWaybillOrder> list = mongoTemplate.find(queryFormat, SckwWaybillOrder.class);
+
+        List<ManagementCarWaybillVo> returnList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(list)) {
+            for (SckwWaybillOrder waybillOrder : list) {
+                ManagementCarWaybillVo vo = new ManagementCarWaybillVo();
+                vo.setWOrderNo(waybillOrder.getWOrderNo() == null ?
+                        null : waybillOrder.getWOrderNo());
+                vo.setWOrderId(waybillOrder.getWOrderId() == null ?
+                        String.valueOf(waybillOrder.get_id()) : String.valueOf(waybillOrder.getWOrderId()));
+                vo.setTruckNo(waybillOrder.getTruckNo());
+                vo.setDriverName(waybillOrder.getDriverName() == null ?
+                        null : String.valueOf(waybillOrder.getDriverName()));
+                vo.setType(String.valueOf(waybillOrder.getType()));
+                String typeString = "";
+                if (waybillOrder.getType().equals(NumberConstant.ONE)) {
+                    typeString = "趟次";
+                }
+                if (waybillOrder.getType().equals(NumberConstant.TWO)) {
+                    typeString = "循环";
+                }
+                vo.setTypeLabel(typeString);
+                vo.setStatus(waybillOrder.getStatus() == null ?
+                        null : String.valueOf(waybillOrder.getStatus()));
+                vo.setStatusLabel(CarWaybillEnum.getName(waybillOrder.getStatus()));
+                // 托量单位
+                vo.setUnit(waybillOrder.getUnit() == null ? null : waybillOrder.getUnit());
+                if(waybillOrder.getUnit() != null) {
+                    Map<String, String> unitType = commonService.getDictData(DictTypeEnum.UNIT_TYPE.getType());
+                    String sysDict = unitType.get(waybillOrder.getUnit());
+                    vo.setUnitLabel(sysDict);
+                }
+                vo.setSendCarTime(waybillOrder.getCreateTime() == null ?
+                        null : DateUtil.getDateTime(waybillOrder.getCreateTime()));
+                vo.setStartTime(waybillOrder.getStartTime() == null ?
+                        null : waybillOrder.getStartTime());
+                vo.setEndTime(waybillOrder.getEndTime() == null ?
+                        null : waybillOrder.getEndTime());
+                vo.setEntrustAmount(String.valueOf(waybillOrder.getEntrustAmount()));
+                vo.setLoadName(waybillOrder.getLoadName() == null ?
+                        null : waybillOrder.getLoadName());
+                vo.setLoadAddress((waybillOrder.getLoadCityName() == null ? "" : waybillOrder.getLoadCityName())
+                        .concat(waybillOrder.getLoadDetailAddress() == null ? "" : waybillOrder.getLoadDetailAddress()));
+                vo.setUnloadName(waybillOrder.getUnloadName() == null ?
+                        null : waybillOrder.getUnloadName());
+                vo.setUnloadAddress((waybillOrder.getUnloadCityName() == null ? "" : waybillOrder.getUnloadCityName())
+                        .concat(waybillOrder.getUnloadDetailAddress() == null ? "" : waybillOrder.getUnloadDetailAddress()));
+                vo.setLoadAmount(waybillOrder.getLoadAmount() == null ?
+                        null : String.valueOf(waybillOrder.getLoadAmount()));
+                vo.setUnloadAmount(waybillOrder.getUnloadAmount() == null ?
+                        null : String.valueOf(waybillOrder.getUnloadAmount()));
+                vo.setLoadDateTime(waybillOrder.getLoadTime() == null ?
+                        null : DateUtil.getDateTime(waybillOrder.getLoadTime()));
+                vo.setUnloadDateTime(waybillOrder.getUnloadTime() == null ?
+                        null : DateUtil.getDateTime(waybillOrder.getUnloadTime()));
+                vo.setCreateTime(waybillOrder.getCreateTime() == null ?
+                        null : DateUtil.getDateTime(waybillOrder.getCreateTime()));
+                vo.setUpdateTime(waybillOrder.getUpdateTime() == null ?
+                        null : DateUtil.getDateTime(waybillOrder.getUpdateTime()));
+                // 货损量
+                BigDecimal deficitAmount = waybillOrder.getDeficitAmount() == null ?
+                        BigDecimal.valueOf(0) : waybillOrder.getDeficitAmount();
+                vo.setDeficitAmount(String.valueOf(deficitAmount));
+                // 存在装卸货差时 计算扣亏量
+                BigDecimal lossAmount = BigDecimal.valueOf(0);
+                BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
+                if (deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
+                    String lossUnit = waybillOrder.getLossUnit();
+                    Map<String, String> LossUnitType = commonService.getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
+                    String lossUnitString = LossUnitType.get(lossUnit);
+
+                    if (lossUnitString.equals("%")) {
+                        // 百分比
+                        lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
+                    } else {
+                        // 千分比
+                        lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
+                    }
+                    lossAmount = deficitAmount.subtract(lossAmount);
+                    if (lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
+                        lossAmount = new BigDecimal("0.00");
+                    }
+                }
+                // 实际扣亏量
+                vo.setDeficitRealAmount(lossAmount.setScale(2).toString());
+                vo.setGoodsPriceUnit(waybillOrder.getGoodsPriceUnit() == null ?
+                        null : String.valueOf(waybillOrder.getGoodsPriceUnit()));
+                returnList.add(vo);
+            }
+        }
+        PageResult build = PageResult.build(query.getPage(), query.getPageSize(), total, returnList);
+        return HttpResult.ok(build);
+    }
+
+    /**
+     * 运单分类统计
+     * @param query
+     * @return
+     */
+    public HttpResult statisticsWaybillOrder(ManagementWaybillOrderQuery query) {
+        Criteria criteria = newBuildWaybillOrdersQuery(query);
+        List<Integer> statuses = new ArrayList<>();
+        statuses.add(CarWaybillEnum.PENDING_ORDER.getCode());
+        statuses.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
+        statuses.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
+        statuses.add(CarWaybillEnum.WAIT_LOADING.getCode());
+        statuses.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
+        statuses.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
+        statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
+        statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode());
+        statuses.add(CarWaybillEnum.REJECT_ORDER.getCode());
+        Aggregation aggregation = Aggregation.newAggregation(
+                Aggregation.match(criteria),
+                Aggregation.group("status").count().as("total"),
+                Aggregation.project("total").and("value").previousOperation()
+        );
+        AggregationResults<TableTops> outputTypeCount = mongoTemplate.aggregate(aggregation, SckwWaybillOrder.class, TableTops.class);
+        List<TableTops> results = outputTypeCount.getMappedResults();
+        // 填充默认值
+        Map<String,TableTops> listMap = new HashMap<>();
+        TableTops topTotal = new TableTops();
+        topTotal.setName("全部");
+        topTotal.setValue("all");
+        topTotal.setTotal(NumberConstant.ZERO);
+        listMap.put("all", topTotal);
+        for (Integer status : statuses) {
+            TableTops top = new TableTops();
+            top.setName(CarWaybillEnum.getName(status));
+            top.setValue(status.toString());
+            top.setTotal(NumberConstant.ZERO);
+            listMap.put(status.toString(), top);
+        }
+        Integer allTotal = 0;
+        for (TableTops result : results) {
+            if(listMap.containsKey(result.getValue())) {
+                listMap.get(result.getValue()).setTotal(result.getTotal());
+            }
+            allTotal += result.getTotal();
+        }
+        topTotal.setTotal(allTotal);
+        return HttpResult.ok(listMap.values().stream().toList());
+    }
+
+    /**
+     * 导出运单列表
+     * @param query
+     * @return
+     */
+    public List<ManagementWaybillOrderExcelVO> exportWaybillOrder(ManagementWaybillOrderQuery query) {
+        Criteria criteria = newBuildWaybillOrdersQuery(query);
+        Query queryFormat = new Query(criteria);
+        List<Long> wOrderIds = StringUtils.splitStrToList(query.getIds(), ",", Long.class);
+        if (CollectionUtils.isNotEmpty(wOrderIds)) {
+            queryFormat.addCriteria(Criteria.where("wOrderId").in(wOrderIds));
+        }
+        List<SckwWaybillOrder> wOrders = mongoTemplate.find(queryFormat, SckwWaybillOrder.class);
+        List<ManagementWaybillOrderExcelVO> list = new ArrayList<>();
+        AtomicInteger i = new AtomicInteger(1);
+        wOrders.forEach(e -> {
+            ManagementWaybillOrderExcelVO export = BeanUtils.copyProperties(e, ManagementWaybillOrderExcelVO.class);
+            export.setSerialNumber(String.valueOf(i.getAndIncrement()))
+                    .setStatus(CarWaybillEnum.getName(e.getStatus()))
+                    .setWOrderNo(e.getWOrderNo())
+                    .setTruckNo(e.getTruckNo())
+                    .setDriverName(e.getDriverName())
+                    .setType(e.getType().equals(NumberConstant.ONE) ? "趟次" : "循环")
+                    .setSendCarTime(e.getCreateTime() == null ? null : DateUtil.getDateTime(e.getCreateTime()))
+                    .setStartTime(e.getStartTime() == null ? null : DateUtil.getDateTime(e.getStartTime()))
+                    .setEndTime(e.getEndTime() == null ? null : DateUtil.getDateTime(e.getEndTime()))
+                    .setEntrustAmount(String.valueOf(e.getEntrustAmount()))
+                    .setLoadName(e.getLoadName())
+                    .setLoadAddress((e.getLoadCityName() == null ? "" : e.getLoadCityName())
+                            .concat(e.getLoadDetailAddress() == null ? "" : e.getLoadDetailAddress()))
+                    .setUnloadName(e.getUnloadName())
+                    .setUnloadAddress((e.getUnloadCityName() == null ? "" : e.getUnloadCityName())
+                            .concat(e.getUnloadDetailAddress() == null ? "" : e.getUnloadDetailAddress()))
+                    .setLoadAmount(String.valueOf(e.getLoadAmount()))
+                    .setUnloadAmount(String.valueOf(e.getUnloadAmount()))
+                    .setDeficitAmount(String.valueOf(e.getDeficitAmount()))
+                    .setLoadDateTime(e.getLoadTime() == null ? null : DateUtil.getDateTime(e.getLoadTime()))
+                    .setUnloadDateTime(e.getUnloadTime() == null ? null : DateUtil.getDateTime(e.getUnloadTime()))
+                    .setUpdateTime(e.getUpdateTime() == null ? null : DateUtil.getDateTime(e.getUpdateTime()));
+            list.add(export);
+        });
+        return list;
+    }
+
+    /**
+     * 运单详情
+     * @param id
+     * @return
+     */
+    public HttpResult getOrderDetail(Long id) {
+        return waybillManagementService.waybillData(id);
+    }
+}

+ 8 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -450,9 +450,9 @@ public class WaybillManagementService {
             // 运单量单位
             waybillBoardListVO.setUnit(sckwWaybillOrder.getUnit());
             if(sckwWaybillOrder.getUnit() != null) {
-                Map<String, SysDictResDto> unitType = remoteSystemService.queryDictMapByType(DictTypeEnum.UNIT_TYPE.getType());
-                SysDictResDto sysDict = unitType.get(sckwWaybillOrder.getUnit());
-                waybillBoardListVO.setUnitLabel(sysDict.getLabel());
+                Map<String, String> unitType = commonService.getDictData(DictTypeEnum.UNIT_TYPE.getType());
+                String sysDict = unitType.get(sckwWaybillOrder.getUnit());
+                waybillBoardListVO.setUnitLabel(sysDict);
             }
             // 运单进度
             List<KwtWaybillOrderTrack> kwtWaybillOrderTracks = kwtWaybillOrderTrackMapper
@@ -832,7 +832,7 @@ public class WaybillManagementService {
         _finish.put("total", "0");
         List<Long> finishStates = getWallBillStatues("finish");
         Long finishCount = kwtWaybillOrderMapper.selectWaybillOrderCountByStatus(entId, finishStates, keyword);
-        _onway.put("total", finishCount.toString());
+        _finish.put("total", finishCount.toString());
         List<Map<String, String>> _list = new ArrayList<>();
         _list.add(_onway);
         _list.add(_finish);
@@ -861,11 +861,11 @@ public class WaybillManagementService {
             orCriteria.add(Criteria.where("firmName").regex(pattern));
             criteria.orOperator(orCriteria);
         }
-        Query queryFormat = new Query(criteria);
         // in查询
         if (CollectionUtils.isNotEmpty(_statuses)) {
-            queryFormat.addCriteria(Criteria.where("status").in(_statuses));
+            criteria.and("status").in(_statuses);
         }
+        Query queryFormat = new Query(criteria);
         // 总记录数
         long total = mongoTemplate.count(queryFormat, SckwWaybillOrder.class);
         queryFormat.with(PageRequest.of(query.getPage() - 1, query.getPageSize(),
@@ -926,6 +926,8 @@ public class WaybillManagementService {
         if (status.equals("finish")) {
             _list.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
             _list.add(CarWaybillEnum.APPROVAL_PASS.getCode().longValue());
+            _list.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
+            _list.add(CarWaybillEnum.APPROVAL_IN.getCode().longValue());
         }
         return _list;
     }

+ 135 - 17
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -964,8 +964,6 @@
     </select>
 
 
-
-
     <select id="selectManagementLogisticsOrderList" resultType="com.sckw.transport.model.vo.ManagementLogsiticsOrderVO">
         SELECT
         <include refid="Query_Column_List">
@@ -1522,30 +1520,150 @@
     </select>
 
     <select id="statisticsLogistics" resultType="java.lang.Long">
-        SELECT
-            DISTINCT a.id
-        FROM
-            kwt_logistics_order a
-                LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
-        WHERE
-            a.del_flag = 0
+        SELECT DISTINCT a.id
+        FROM kwt_logistics_order a
+                 LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
+        WHERE a.del_flag = 0
           AND b.del_flag = 0
-          AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
+          AND (b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId})
     </select>
 
     <select id="statisticsLogisticsByTopEntIdAndOrderStatus" resultType="java.lang.Integer">
         SELECT
-            count(DISTINCT a.id)
+        count(DISTINCT a.id)
         FROM
-            kwt_logistics_order a
-                LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
         WHERE
-            a.del_flag = 0
-          AND b.del_flag = 0
-          AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
+        a.del_flag = 0
+        AND b.del_flag = 0
+        AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
         And a.status in
-            <foreach collection="orderList" open="(" close=")" separator="," item="item">
+        <foreach collection="orderList" open="(" close=")" separator="," item="item">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="selectAcceptCarriageFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
+        SELECT
+        IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
+        IFNULL( SUM( t1.amount ), 0 ) AS amount ,
+        IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
+        IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
+        IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
+        FROM
+        (
+        SELECT
+        ( a.amount - IFNULL(a.total_load_amount,0)) AS WaitingAmount,
+        a.amount,
+        a.entrust_amount AS entrustAmount,
+        a.subcontract_amount AS subcontractAmount,
+        a.price ,
+        a.amount * IFNULL(a.price,0) AS totalPrice
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
+        AND a.del_flag = 0
+        AND b.del_flag = 0
+        WHERE
+        b.unit_type = #{unitType}
+        <if test="topId != null and topId !=''">
+            and b.top_ent_id = #{topId}
+        </if>
+        <if test="statusList != null and statusList.size()>0">
+            and a.`status` IN
+            <foreach collection="statusList" item="item" separator="," open="(" close=")">
                 #{item}
             </foreach>
+        </if>
+        <if test="dateStart != null and dateStart != ''">
+            and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
+        </if>
+        <if test="dateEnd != null and dateEnd != ''">
+            and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
+        </if>
+        ) t1
+    </select>
+
+    <select id="selectStatisticsByOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
+        SELECT
+        IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
+        IFNULL( SUM( t1.amount ), 0 ) AS amount ,
+        IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
+        IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
+        IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
+        FROM
+        (
+        SELECT
+        ( a.amount - a.entrust_amount - a.subcontract_amount ) AS WaitingAmount,
+        a.amount,
+        a.entrust_amount AS entrustAmount,
+        a.subcontract_amount AS subcontractAmount,
+        a.price ,
+        a.amount * IFNULL(a.price,0) AS totalPrice
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
+        AND a.del_flag = 0
+        AND b.del_flag = 0
+        WHERE
+        b.unit_type =  #{unitType}
+        <if test="topId != null and topId !=''">
+            and b.top_ent_id = #{topId}
+        </if>
+        <if test="statusList != null and statusList.size()>0">
+            and a.`status` IN
+            <foreach collection="statusList" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="dateStart != null and dateStart != ''">
+            and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
+        </if>
+        <if test="dateEnd != null and dateEnd != ''">
+            and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
+        </if>
+        ) t1
+    </select>
+
+    <select id="selectAcceptCarriageAwaitFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
+        SELECT
+        IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
+        IFNULL( SUM( t1.amount ), 0 ) AS amount ,
+        IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
+        IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
+        IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
+        FROM
+        (
+        SELECT
+        ( a.amount - a.entrust_amount - a.subcontract_amount) AS WaitingAmount,
+        a.amount,
+        a.entrust_amount AS entrustAmount,
+        a.subcontract_amount AS subcontractAmount,
+        a.price ,
+        a.amount * IFNULL(a.price,0) AS totalPrice
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
+        AND a.del_flag = 0
+        AND b.del_flag = 0
+        WHERE
+        b.unit_type = #{unitType}
+        <if test="topId != null and topId !=''">
+            and b.top_ent_id = #{topId}
+        </if>
+        <if test="statusList != null and statusList.size()>0">
+            and a.`status` IN
+            <foreach collection="statusList" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="dateStart != null and dateStart != ''">
+            and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
+        </if>
+        <if test="dateEnd != null and dateEnd != ''">
+            and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
+        </if>
+        ) t1
     </select>
 </mapper>