Browse Source

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

czh 2 năm trước cách đây
mục cha
commit
132c1746e7
20 tập tin đã thay đổi với 1288 bổ sung26 xóa
  1. 35 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java
  2. 36 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/SettlementMoney.java
  3. 17 4
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java
  4. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  5. 10 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  6. 12 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/MoneyType.java
  7. 12 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  8. 13 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  9. 126 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  10. 158 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DateTimeUtil.java
  11. 24 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DecimalUtils.java
  12. 33 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml
  13. 37 4
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml
  14. 1 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/enterpriseApp/AppWayBillController.java
  15. 108 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/operationManagement/ManagementWaybillOrderController.java
  16. 74 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/ManagementWaybillOrderQuery.java
  17. 168 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/ManagementCarWaybillVo.java
  18. 84 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/execlVo/ManagementWaybillOrderExcelVO.java
  19. 323 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementWaybillOrderService.java
  20. 8 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

+ 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);
+
 }

+ 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));
+    }
 
 }

+ 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);
 }

+ 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) {
+}

+ 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);
+    }
 }

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

@@ -4,20 +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
@@ -33,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)) {
@@ -65,5 +88,104 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         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()) + "%";
     }
 }

+ 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>

+ 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());
+        }
+    }
+
+}

+ 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;
+
+}

+ 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;
+
+}

+ 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;
     }