Quellcode durchsuchen

1.运营端新增运单列表接口
2.对账结算根据产品要求修改付款金额计算公式
3.工作台新增报表统计接口
4.新增文件上传保存数据库接口
5.bug-fix,修复订单完结返回数据至贸易订单

lengfaqiang vor 2 Jahren
Ursprung
Commit
a5dc400684
16 geänderte Dateien mit 714 neuen und 117 gelöschten Zeilen
  1. 31 2
      sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java
  2. 8 2
      sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/dto/LogisticsOrderDTO.java
  3. 18 0
      sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/vo/LogisticsOrderVO.java
  4. 20 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java
  5. 18 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/operationManagement/ManagementLogisticsOrderController.java
  6. 5 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java
  7. 30 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderQuery.java
  8. 30 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderStatisticsParam.java
  9. 26 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsOrderStatisticsVO.java
  10. 38 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsByOrderVO.java
  11. 44 29
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  12. 104 24
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  13. 121 27
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementLogisticsOrderService.java
  14. 67 4
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java
  15. 61 17
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportDubboServiceImpl.java
  16. 93 12
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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