Răsfoiți Sursa

派车逻辑修改
司机端统计查询
司机端运单展示查询

lengfaqiang 2 ani în urmă
părinte
comite
e2d17d8d84
16 a modificat fișierele cu 379 adăugiri și 237 ștergeri
  1. 1 1
      sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/annotation/Translates.java
  2. 1 1
      sckw-modules/sckw-report/src/main/java/com/sckw/report/consumer/SckwBusSumConsumer.java
  3. 4 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java
  4. 16 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/AcceptCarriageOrderController.java
  5. 3 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java
  6. 2 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/LogisticsConsignmentController.java
  7. 10 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderCirculateMapper.java
  8. 9 16
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtLogisticsOrderCirculate.java
  9. 86 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillDetailVO.java
  10. 10 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderVO.java
  11. 62 14
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  12. 129 14
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/DriverService.java
  13. 1 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java
  14. 3 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java
  15. 40 184
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderCirculateMapper.xml
  16. 2 1
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.xml

+ 1 - 1
sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/annotation/Translates.java

@@ -7,7 +7,7 @@ import java.lang.annotation.*;
  * 组合注解
  * 用于指定翻译多个字段
  *
- * @author liyue
+ * @author lfdc
  * @version v1
  * @create 2020-11-28 15:37:35
  * @copyright

+ 1 - 1
sckw-modules/sckw-report/src/main/java/com/sckw/report/consumer/SckwBusSumConsumer.java

@@ -118,7 +118,7 @@ public class SckwBusSumConsumer {
         /**车辆运单**/
         if (busSum.getBusSumType().equals("waybillOrder")) {
             SckwWaybillOrder order = JSONObject.parseObject(JSON.toJSONString(busSum.getObject()), SckwWaybillOrder.class);
-            order.set_id(order.getWOrderId());
+            order.set_id(order.getWOrderId() == null ? order.get_id() : order.getWOrderId());
             if (busSum.getMethod() == 1) {
                 /**新增**/
                 waybillOrderRepository.insert(order);

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

@@ -5,6 +5,7 @@ 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.SckwLogisticsOrder;
@@ -57,6 +58,7 @@ public class KwTransportService {
         // 创建条件对象
         Criteria criteria = new Criteria();
         // 1. 全等于
+        criteria.and("entId").is(LoginUserHolder.getEntId());
         if (StringUtils.isNotBlank(query.getLoadAddress())) {
             criteria.and("loadDetailAddress").is(query.getLoadAddress());
         }
@@ -116,6 +118,7 @@ public class KwTransportService {
         // 创建条件对象
         Criteria criteria = new Criteria();
         // 1. 全等于
+        criteria.and("entId").is(LoginUserHolder.getEntId());
         if (StringUtils.isNotBlank(param.getLoadAddress())) {
             criteria.and("loadDetailAddress").is(param.getLoadAddress());
         }
@@ -167,6 +170,7 @@ public class KwTransportService {
         // 创建条件对象
         Criteria criteria = new Criteria();
         // 1. 全等于
+        criteria.and("entId").is(LoginUserHolder.getEntId());
         if (StringUtils.isNotBlank(query.getLoadAddress())) {
             criteria.and("loadDetailAddress").is(query.getLoadAddress());
         }

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

@@ -14,6 +14,7 @@ import com.sckw.transport.service.AcceptCarriageOrderService;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -122,4 +123,19 @@ public class AcceptCarriageOrderController {
         }
     }
 
+    /**
+     * 承运订单-获取运单详情
+     * @param wOrderId 运单id
+     * @return
+     */
+    @RequestMapping(value = "/getWaybillData", method = RequestMethod.GET)
+    public HttpResult getWaybillData(@Param("wOrderId") String wOrderId) {
+        try {
+//            return acceptCarriageOrderService.getWaybillData(wOrderId);
+            return null;
+        } catch (Exception e) {
+            log.error("承运订单-获取运单详情 error:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
 }

+ 3 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java

@@ -27,7 +27,7 @@ public class ConsignOrderController {
     @Autowired
     ConsignOrderService consignOrderService;
     /**
-     * 托运订单获取车辆运单
+     * 托运订单/承运订单-获取车辆运单
      *
      * @param orderDto
      * @return
@@ -69,8 +69,9 @@ public class ConsignOrderController {
         try {
             return null;
         } catch (Exception e) {
-            log.error("托运订单-撤销托运运单失败:订单id {},error {} ", orderDto.getId(), e.getMessage(), e);
+            log.error("托运订单-完结订单失败:订单id {},error {} ", orderDto.getId(), e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
+
 }

+ 2 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/LogisticsConsignmentController.java

@@ -27,7 +27,7 @@ public class LogisticsConsignmentController {
     LogisticsConsignmentService logisticsConsignmentService;
 
     /**
-     * 采购订单-物流托运
+     * 采购订单-物流托运生成托运订单
      * @param logisticsConsignmentParam
      * @return
      */
@@ -78,7 +78,7 @@ public class LogisticsConsignmentController {
     }
 
     /**
-     * 销售订单-物流托运
+     * 销售订单-物流托运生成托运订单
      * @param logisticsConsignmentParam
      * @return
      */

+ 10 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderCirculateMapper.java

@@ -3,6 +3,9 @@ package com.sckw.transport.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.transport.model.KwtLogisticsOrderCirculate;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 public interface KwtLogisticsOrderCirculateMapper extends BaseMapper<KwtLogisticsOrderCirculate> {
@@ -17,4 +20,11 @@ public interface KwtLogisticsOrderCirculateMapper extends BaseMapper<KwtLogistic
     int updateByPrimaryKeySelective(KwtLogisticsOrderCirculate record);
 
     int updateByPrimaryKey(KwtLogisticsOrderCirculate record);
+    /**
+     * 查询循环单-根据司机id单据状态-联查表
+     * @param id
+     * @param loopStatus
+     * @return
+     */
+    List<Long> selectDriverOrderByStatus(@Param("id") Long id, @Param("status") List<Long> loopStatus);
 }

+ 9 - 16
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtLogisticsOrderCirculate.java

@@ -31,11 +31,19 @@ public class KwtLogisticsOrderCirculate implements Serializable {
      * 物流订单id
      */
     private Long lOrderId;
+    /**
+     * 物流订单id
+     */
+    private Long wOrderId;
 
     /**
      * 车牌号
      */
     private String truckNo;
+    /**
+     * 0趟次1循环
+     */
+    private String type;
 
     /**
      * 司机id
@@ -54,28 +62,13 @@ public class KwtLogisticsOrderCirculate implements Serializable {
 
     private Date entrustDate;
 
-    /**
-     * 卸货量
-     */
-    private BigDecimal unloadAmount;
-
-    /**
-     * 装货量
-     */
-    private BigDecimal loadAmount;
-
-    /**
-     * 亏吨量(装货量-卸货量)
-     */
-    private BigDecimal deficitAmount;
-
     /**
      * 备注
      */
     private String remark;
 
     /**
-     * 用户状态(0正常、1已锁
+     * 用户状态(0正常、1失效)
      */
     private Integer status;
 

+ 86 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillDetailVO.java

@@ -0,0 +1,86 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lfdc
+ * @description 运单详情vo
+ * @date 2023-07-18 16:07:54
+ */
+@Data
+public class WaybillDetailVO {
+    /**
+     * 派车量
+     */
+    private BigDecimal sendCarWeigh;
+    /**
+     * 实装量
+     */
+    private BigDecimal loadAmount;
+    /**
+     * 实卸量
+     */
+    private BigDecimal unloadAmount;
+    /**
+     * 装货时间
+     */
+    private Date stowageDateTime;
+    /**
+     * 卸货时间
+     */
+    private Date unloadDateTime;
+    /**
+     * 运单类型
+     */
+    private String waybillType;
+    /**
+     * 亏吨量
+     */
+    private BigDecimal deficitAmount;
+    /**
+     * 亏吨量
+     */
+    private BigDecimal loss;
+    /**
+     * 扣亏损值
+     */
+    private BigDecimal goodsPrice;
+    /**
+     * 派车人
+     */
+    private String appointor;
+    /**
+     * 承运车队
+     */
+    private String fleetName;
+    /**
+     * 车牌号
+     */
+    private String truckNo;
+    /**
+     * 司机姓名
+     */
+    private String driverName;
+    /**
+     * 计划开始时间
+     */
+    private Date startTime;
+    /**
+     * 计划结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 计划开始时间
+     */
+    private Date loadTime;
+    /**
+     * 计划结束时间
+     */
+    private Date unloadTime;
+
+}
+

+ 10 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderVO.java

@@ -242,6 +242,16 @@ public class WaybillOrderVO {
      */
     private String fleetName;
 
+    /**
+     * 企业名称(指的是物流公司)
+     */
+    private String firmName;
+
+    /**
+     * 企业id
+     */
+    private String entId;
+
     /**
      * 计划结束时间
      */

+ 62 - 14
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java

@@ -22,10 +22,7 @@ import com.sckw.system.api.RemoteSystemService;
 import com.sckw.transport.common.enums.CarWaybillEnum;
 import com.sckw.transport.common.enums.LogisticsOrderEnum;
 import com.sckw.transport.dao.*;
-import com.sckw.transport.model.KwtLogisticsOrder;
-import com.sckw.transport.model.KwtLogisticsOrderTrack;
-import com.sckw.transport.model.KwtWaybillOrder;
-import com.sckw.transport.model.KwtWaybillOrderTrack;
+import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.CarListDTO;
 import com.sckw.transport.model.dto.OrderDTO;
 import com.sckw.transport.model.dto.OrderTakingDTO;
@@ -79,6 +76,9 @@ public class AcceptCarriageOrderService {
     @Autowired
     private KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
 
+    @Autowired
+    private KwtLogisticsOrderCirculateMapper logisticsOrderCirculateMapper;
+
     public HttpResult list(AcceptCarriageOrderQuery query) {
         List<AcceptCarriageOrderVO> list = new ArrayList<>();
         AcceptCarriageOrderVO acceptCarriageOrderVo = new AcceptCarriageOrderVO();
@@ -172,7 +172,7 @@ public class AcceptCarriageOrderService {
             return result;
         }
         List<SckwWaybillOrder> list = new ArrayList<>();
-        if (String.valueOf(NumberConstant.ZERO).equals(sendCarDTO.getType())) {
+        if (String.valueOf(NumberConstant.ONE).equals(sendCarDTO.getType())) {
             for (CarListDTO car : sendCarDTO.getCarList()) {
                 if (ObjectUtils.isEmpty(car.getCount())) {
                     throw new RuntimeException("趟次派车时,趟次次数不能为空");
@@ -189,20 +189,28 @@ public class AcceptCarriageOrderService {
 //                    insertWaybillOrderTrack(wOrderId);
                 }
             }
-        } else if (String.valueOf(NumberConstant.ONE).equals(sendCarDTO.getType())) {
+        } else if (String.valueOf(NumberConstant.TWO).equals(sendCarDTO.getType())) {
             for (CarListDTO car : sendCarDTO.getCarList()) {
                 if (ObjectUtils.isEmpty(sendCarDTO.getWaitingVolume())) {
                     throw new RuntimeException("循环派车时,剩余可运量不能为空");
                 }
                 for (int i = 0; i < car.getCount(); i++) {
-                    Long wOrderId = new IdWorker(NumberConstant.ONE).nextId();
-                    String wOrderNo = com.sckw.transport.utils.StringUtils.getWaybillNoUtil() + i;
-                    KwtWaybillOrder waybillOrder = new KwtWaybillOrder();
-                    String type = String.valueOf(NumberConstant.ONE);
-                    waybillOrder.setType(type);
-                    waybillOrder.setEntrustAmount(new BigDecimal(sendCarDTO.getWaitingVolume()));
-                    insertWaybillOrder(waybillOrder, wOrderId, wOrderNo, logisticsOrder, car, sendCarDTO, list, type);
-//                    insertWaybillOrderTrack(wOrderId);
+                    KwtLogisticsOrderCirculate circulate = new KwtLogisticsOrderCirculate();
+                    circulate.setId(new IdWorker(NumberConstant.ONE).nextId());
+                    circulate.setEntId(logisticsOrder.getEntId());
+                    circulate.setLOrderId(Long.parseLong(sendCarDTO.getLOrderId()));
+                    circulate.setTruckNo(car.getTruckNo());
+                    circulate.setDriverId(Long.parseLong(car.getDriverId()));
+                    circulate.setActualAmount(new BigDecimal(car.getLoadAmount()));
+                    circulate.setEntrustAmount(new BigDecimal(sendCarDTO.getWaitingVolume()));
+                    circulate.setEntrustDate(new Date());
+                    circulate.setCreateBy(LoginUserHolder.getUserId());
+                    circulate.setCreateTime(new Date());
+                    circulate.setUpdateBy(LoginUserHolder.getUserId());
+                    circulate.setUpdateTime(new Date());
+                    circulate.setType(String.valueOf(NumberConstant.ONE));
+                    logisticsOrderCirculateMapper.insert(circulate);
+                    sendMongoDbData(list, logisticsOrder, car, sendCarDTO, String.valueOf(NumberConstant.ONE));
                 }
             }
         } else {
@@ -225,6 +233,45 @@ public class AcceptCarriageOrderService {
         }
         return result;
     }
+    private void sendMongoDbData(List<SckwWaybillOrder> list, KwtLogisticsOrder logisticsOrder
+            , CarListDTO carListDTO, SendCarDTO sendCarDTO, String type) {
+        //放入mongodb实体
+        SckwWaybillOrder waybillCarDTO = new SckwWaybillOrder();
+        waybillCarDTO.set_id(new IdWorker(NumberConstant.ONE).nextId());
+        waybillCarDTO.setStatus(CarWaybillEnum.PENDING_ORDER.getCode().toString());
+        waybillCarDTO.setType(type);
+        waybillCarDTO.setLOrderId(StringUtils.isBlank(sendCarDTO.getLOrderId()) ? null : Long.parseLong(sendCarDTO.getLOrderId()));
+        waybillCarDTO.setLOrderNo(sendCarDTO.getLOrderNo());
+        waybillCarDTO.setTOrderId(logisticsOrder.getTOrderId());
+        waybillCarDTO.setTOrderNo(logisticsOrder.getTOrderNo());
+        waybillCarDTO.setEntId(logisticsOrder.getEntId());
+        waybillCarDTO.setFirmName(remoteSystemService.queryEntCacheById(logisticsOrder.getEntId()).getFirmName());
+        waybillCarDTO.setTruckNo(carListDTO.getTruckNo());
+        //todo 司机dubbo查询
+//        waybillCarDTO.setTruckType();
+//        waybillCarDTO.setTruckEnergyType();
+//        waybillCarDTO.setTruckColor()
+//        waybillCarDTO.setTruckTrailerNo();
+//        waybillCarDTO.setTruckFleetName();
+        waybillCarDTO.setDriverId(StringUtils.isBlank(carListDTO.getDriverId()) ? null : Long.parseLong(carListDTO.getDriverId()));
+//        waybillCarDTO.setDriverPhone();
+//        waybillCarDTO.setDriverIdcard();
+        waybillCarDTO.setDriverName(carListDTO.getDriverName());
+        waybillCarDTO.setStartTime(sendCarDTO.getLoadDateTime());
+        waybillCarDTO.setEndTime(sendCarDTO.getUnloadDateTime());
+        waybillCarDTO.setFleetId(carListDTO.getFleetId());
+        waybillCarDTO.setFleetName(carListDTO.getFleetName());
+        waybillCarDTO.setGoodsName(sendCarDTO.getGoodsName());
+        waybillCarDTO.setGoodsId(StringUtils.isBlank(sendCarDTO.getGoodsId()) ? null : Integer.valueOf(sendCarDTO.getGoodsId()));
+        waybillCarDTO.setLoadingCity(sendCarDTO.getLoadCity());
+        waybillCarDTO.setLoadTime(sendCarDTO.getLoadDateTime());
+        waybillCarDTO.setLoadingAddress(sendCarDTO.getLoadAddress());
+        waybillCarDTO.setUnloadingCity(sendCarDTO.getUnloadCity());
+        waybillCarDTO.setUnloadTime(sendCarDTO.getUnloadDateTime());
+        waybillCarDTO.setUnloadingAddress(sendCarDTO.getUnloadAddress());
+        waybillCarDTO.setDelFlag(Integer.valueOf(NumberConstant.ZERO));
+        list.add(waybillCarDTO);
+    }
 
     /**
      * 保存车辆运单状态信息
@@ -281,6 +328,7 @@ public class AcceptCarriageOrderService {
         waybillOrder.setCreateTime(createTime);
         waybillOrder.setUpdateTime(new Date());
         waybillOrder.setUpdateBy(LoginUserHolder.getUserId());
+        waybillOrder.setStatus(CarWaybillEnum.PENDING_ORDER.getCode());
         waybillOrderMapper.insert(waybillOrder);
 
         //状态表保存

+ 129 - 14
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/DriverService.java

@@ -6,13 +6,16 @@ import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.mongo.model.TobleTop;
+import com.sckw.system.api.RemoteSystemService;
 import com.sckw.transport.common.enums.CarWaybillEnum;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.KwtLogisticsOrderAddress;
+import com.sckw.transport.model.KwtLogisticsOrderCirculate;
 import com.sckw.transport.model.KwtLogisticsOrderGoods;
 import com.sckw.transport.model.KwtWaybillOrder;
 import com.sckw.transport.model.vo.WaybillOrderVO;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -30,6 +33,9 @@ import java.util.stream.Collectors;
 @Service
 public class DriverService {
 
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    RemoteSystemService remoteSystemService;
+
     @Autowired
     private KwtWaybillOrderMapper waybillOrderMapper;
 
@@ -51,6 +57,9 @@ public class DriverService {
     @Autowired
     private KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
 
+    @Autowired
+    private KwtLogisticsOrderCirculateMapper logisticsOrderCirculateMapper;
+
 
     /**
      * @param id
@@ -98,8 +107,9 @@ public class DriverService {
 
     /**
      * 根据当前登录 id获取派给当前id的车辆运单
-     * @param id 司机id
-     * @param type  展示页签类型
+     *
+     * @param id   司机id
+     * @param type 展示页签类型
      * @return
      */
     public HttpResult getWaybillDriverDetail(Long id, String type) {
@@ -111,26 +121,131 @@ public class DriverService {
          * 完结: 对应[已卸货]、[已核单]
          * */
         HttpResult result = new HttpResult();
-        List<Long> status = new ArrayList<>();
+        List<Long> tripStatus = new ArrayList<>();
+        List<Long> loopStatus = new ArrayList<>();
         if (String.valueOf(NumberConstant.ONE).equals(type)) {
-            status.add(CarWaybillEnum.PENDING_ORDER.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.PENDING_ORDER.getCode().longValue());
         } else if (String.valueOf(NumberConstant.TWO).equals(type)) {
-            status.add(CarWaybillEnum.PENDING_VEHICLE.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.PENDING_VEHICLE.getCode().longValue());
+            loopStatus.add(CarWaybillEnum.PENDING_VEHICLE.getCode().longValue());
         } else if (String.valueOf(NumberConstant.THREE).equals(type)) {
-            status.add(CarWaybillEnum.EXIT_COMPLETED.getCode().longValue());
-            status.add(CarWaybillEnum.WAIT_LOADING.getCode().longValue());
-            status.add(CarWaybillEnum.COMPLETION_LOADING.getCode().longValue());
-            status.add(CarWaybillEnum.WAIT_UNLOADING.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.EXIT_COMPLETED.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.WAIT_LOADING.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.COMPLETION_LOADING.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.WAIT_UNLOADING.getCode().longValue());
+
+            loopStatus.add(CarWaybillEnum.EXIT_COMPLETED.getCode().longValue());
+            loopStatus.add(CarWaybillEnum.WAIT_LOADING.getCode().longValue());
+            loopStatus.add(CarWaybillEnum.COMPLETION_LOADING.getCode().longValue());
+            loopStatus.add(CarWaybillEnum.WAIT_UNLOADING.getCode().longValue());
         } else if (String.valueOf(NumberConstant.FOUR).equals(type)) {
-            status.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
-            status.add(CarWaybillEnum.APPROVAL_COMPLETED.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
+            tripStatus.add(CarWaybillEnum.APPROVAL_COMPLETED.getCode().longValue());
+
+            loopStatus.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
+            loopStatus.add(CarWaybillEnum.APPROVAL_COMPLETED.getCode().longValue());
         } else {
             result.setMsg("类型错误");
             result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
             return result;
         }
-        List<Long> list = waybillOrderMapper.selectDriverOrder(id, status);
         List<WaybillOrderVO> orderVOList = new ArrayList<>();
+        /**趟次*/
+        tripPackageData(id, tripStatus, orderVOList);
+        /**循环*/
+        loopPackageData(id,loopStatus,orderVOList);
+        orderVOList = orderVOList.stream().sorted(Comparator.comparing(WaybillOrderVO::getCreateTime)).collect(Collectors.toList());
+        return HttpResult.ok(orderVOList);
+    }
+    private void loopPackageData(Long id, List<Long> loopStatus, List<WaybillOrderVO> orderVOList) {
+        if(CollectionUtils.isEmpty(loopStatus)){
+            List<KwtLogisticsOrderCirculate> list = logisticsOrderCirculateMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderCirculate>()
+                    .eq(KwtLogisticsOrderCirculate::getDriverId,id)
+                    .isNull(KwtLogisticsOrderCirculate::getWOrderId)
+                    .eq(KwtLogisticsOrderCirculate::getStatus,NumberConstant.ZERO));
+            if (CollectionUtils.isNotEmpty(list)){
+                for (KwtLogisticsOrderCirculate circulate : list) {
+                    KwtLogisticsOrderAddress loadAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+                            .eq(KwtLogisticsOrderAddress::getLOrderId, circulate.getLOrderId()).eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
+                    KwtLogisticsOrderAddress unloadAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+                            .eq(KwtLogisticsOrderAddress::getLOrderId, circulate.getLOrderId()).eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
+                    KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
+                            .eq(KwtLogisticsOrderGoods::getLOrderId, circulate.getLOrderId()));
+                    List<KwtWaybillOrder> waybillOrders = waybillOrderMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrder>()
+                            .eq(KwtWaybillOrder::getLOrderId, circulate.getLOrderId()).eq(KwtWaybillOrder::getDriverId, id));
+                    for (KwtWaybillOrder waybill : waybillOrders) {
+                        WaybillOrderVO vo = new WaybillOrderVO();
+                        vo.setLOrderId(circulate.getLOrderId());
+                        vo.setLoadCityCode(loadAddress.getCityCode());
+                        vo.setLoadCityName(loadAddress.getCityName());
+                        vo.setLoadDetailAddress(loadAddress.getDetailAddress());
+                        vo.setUnloadCityName(unloadAddress.getCityName());
+                        vo.setUnloadCityCode(unloadAddress.getCityCode());
+                        vo.setEntId(String.valueOf(waybill.getEntId()));
+                        vo.setFirmName(remoteSystemService.queryEntCacheById(waybill.getEntId()).getFirmName());
+                        vo.setGoodsName(orderGoods == null ? null : (orderGoods.getGoodsName() == null ? null : orderGoods.getGoodsName()));
+                        vo.setGoodsCode(orderGoods == null ? null : (orderGoods.getSkuId() == null ? null : String.valueOf(orderGoods.getSkuId())));
+                        vo.setWOrderId(waybill.getId());
+                        vo.setWOrderNo(waybill.getWOrderNo());
+                        vo.setCreateTime(waybill.getCreateTime());
+                        vo.setStartTime(waybill.getStartTime());
+                        vo.setEndTime(waybill.getEndTime());
+                        //todo 查询车队服务dubbo
+//                    vo.setFleetName();
+//                    vo.setFleetId();
+//                    vo.setTruckFleetName();
+                        vo.setEntrustAmount(waybill.getEntrustAmount());
+                        vo.setType(waybill.getType());
+                        vo.setTruckNo(waybill.getTruckNo());
+                        orderVOList.add(vo);
+                    }
+                }
+            }
+        }else {
+            List<Long> list = logisticsOrderCirculateMapper.selectDriverOrderByStatus(id, loopStatus);
+            if (CollectionUtils.isNotEmpty(list)){
+                for (Long aLong : list) {
+                    KwtLogisticsOrderAddress loadAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+                            .eq(KwtLogisticsOrderAddress::getLOrderId, aLong).eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
+                    KwtLogisticsOrderAddress unloadAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+                            .eq(KwtLogisticsOrderAddress::getLOrderId, aLong).eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
+                    KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
+                            .eq(KwtLogisticsOrderGoods::getLOrderId, aLong));
+                    List<KwtWaybillOrder> waybillOrders = waybillOrderMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrder>()
+                            .eq(KwtWaybillOrder::getLOrderId, aLong).eq(KwtWaybillOrder::getDriverId, id));
+                    for (KwtWaybillOrder waybill : waybillOrders) {
+                        WaybillOrderVO vo = new WaybillOrderVO();
+                        vo.setLOrderId(aLong);
+                        vo.setLoadCityCode(loadAddress.getCityCode());
+                        vo.setLoadCityName(loadAddress.getCityName());
+                        vo.setLoadDetailAddress(loadAddress.getDetailAddress());
+                        vo.setUnloadCityName(unloadAddress.getCityName());
+                        vo.setUnloadCityCode(unloadAddress.getCityCode());
+                        vo.setEntId(String.valueOf(waybill.getEntId()));
+                        vo.setFirmName(remoteSystemService.queryEntCacheById(waybill.getEntId()).getFirmName());
+                        vo.setGoodsName(orderGoods == null ? null : (orderGoods.getGoodsName() == null ? null : orderGoods.getGoodsName()));
+                        vo.setGoodsCode(orderGoods == null ? null : (orderGoods.getSkuId() == null ? null : String.valueOf(orderGoods.getSkuId())));
+                        vo.setWOrderId(waybill.getId());
+                        vo.setWOrderNo(waybill.getWOrderNo());
+                        vo.setCreateTime(waybill.getCreateTime());
+                        vo.setStartTime(waybill.getStartTime());
+                        vo.setEndTime(waybill.getEndTime());
+                        //todo 查询车队服务dubbo
+//                    vo.setFleetName();
+//                    vo.setFleetId();
+//                    vo.setTruckFleetName();
+                        vo.setEntrustAmount(waybill.getEntrustAmount());
+                        vo.setType(waybill.getType());
+                        vo.setTruckNo(waybill.getTruckNo());
+                        orderVOList.add(vo);
+                    }
+                }
+            }
+        }
+    }
+
+    private void tripPackageData(Long id, List<Long> tripStatus, List<WaybillOrderVO> orderVOList) {
+        List<Long> list = waybillOrderMapper.selectDriverOrder(id, tripStatus);
         if (CollectionUtils.isNotEmpty(list)) {
             for (Long aLong : list) {
                 KwtLogisticsOrderAddress loadAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
@@ -149,6 +264,8 @@ public class DriverService {
                     vo.setLoadDetailAddress(loadAddress.getDetailAddress());
                     vo.setUnloadCityName(unloadAddress.getCityName());
                     vo.setUnloadCityCode(unloadAddress.getCityCode());
+                    vo.setEntId(String.valueOf(waybill.getEntId()));
+                    vo.setFirmName(remoteSystemService.queryEntCacheById(waybill.getEntId()).getFirmName());
                     vo.setGoodsName(orderGoods == null ? null : (orderGoods.getGoodsName() == null ? null : orderGoods.getGoodsName()));
                     vo.setGoodsCode(orderGoods == null ? null : (orderGoods.getSkuId() == null ? null : String.valueOf(orderGoods.getSkuId())));
                     vo.setWOrderId(waybill.getId());
@@ -166,8 +283,6 @@ public class DriverService {
                     orderVOList.add(vo);
                 }
             }
-            orderVOList = orderVOList.stream().sorted(Comparator.comparing(WaybillOrderVO::getCreateTime)).collect(Collectors.toList());
         }
-        return HttpResult.ok(orderVOList);
     }
 }

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

@@ -342,6 +342,7 @@ public class LogisticsConsignmentService {
         order.setCreateTime(new Date());
         order.setUpdateBy(LoginUserHolder.getUserId());
         order.setUpdateTime(new Date());
+        order.setStatus(LogisticsOrderEnum.PENDING_ORDER.getCode());
         kwtLogisticsOrderMapper.insert(order);
     }
 

+ 3 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java

@@ -242,6 +242,7 @@ public class TransportCommonService {
         } else {
             /**即代表存在分包,当次是属于被分包.需要将数据回归到上游数据。*/
             Long pid = logisticsOrder.getPid();
+            /**指的是上游单据进行回归*/
             KwtLogisticsOrder order = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
                     .eq(KwtLogisticsOrder::getId, pid));
             //上游分配量
@@ -254,11 +255,11 @@ public class TransportCommonService {
             BigDecimal add = order.getSubcontractAmount().add(subtract);
             logisticsOrderMapper.update(null, new LambdaUpdateWrapper<KwtLogisticsOrder>()
                     .eq(KwtLogisticsOrder::getId, order.getId())
-                    .set(KwtLogisticsOrder::getDelFlag, NumberConstant.ONE)
+                    .set(KwtLogisticsOrder::getDelFlag, NumberConstant.ZERO)
                     .set(KwtLogisticsOrder::getSubcontractAmount, add)
                     .set(KwtLogisticsOrder::getUpdateBy, LoginUserHolder.getUserId())
                     .set(KwtLogisticsOrder::getUpdateTime, new Date()));
-
+            /**下游订单进行删除*/
             logisticsOrderMapper.update(null, new LambdaUpdateWrapper<KwtLogisticsOrder>()
                     .eq(KwtLogisticsOrder::getId, logisticsOrder.getId())
                     .set(KwtLogisticsOrder::getDelFlag, NumberConstant.ONE)

+ 40 - 184
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderCirculateMapper.xml

@@ -1,188 +1,44 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.transport.dao.KwtLogisticsOrderCirculateMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtLogisticsOrderCirculate">
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="ent_id" jdbcType="BIGINT" property="entId" />
-    <result column="order_id" jdbcType="BIGINT" property="orderId" />
-    <result column="car_num" jdbcType="VARCHAR" property="carNum" />
-    <result column="driver_id" jdbcType="BIGINT" property="driverId" />
-    <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount" />
-    <result column="remark" jdbcType="VARCHAR" property="remark" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-    <result column="create_by" jdbcType="BIGINT" property="createBy" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    id, ent_id, order_id, car_num, driver_id, entrust_amount, remark, `status`, create_by, 
-    create_time, update_by, update_time, del_flag
-  </sql>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    select 
-    <include refid="Base_Column_List" />
-    from kwt_logistics_order_circulate
-    where id = #{id,jdbcType=BIGINT}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-    delete from kwt_logistics_order_circulate
-    where id = #{id,jdbcType=BIGINT}
-  </delete>
-  <insert id="insert" parameterType="com.sckw.transport.model.KwtLogisticsOrderCirculate">
-    insert into kwt_logistics_order_circulate (id, ent_id, order_id, 
-      car_num, driver_id, entrust_amount, 
-      remark, `status`, create_by, 
-      create_time, update_by, update_time, 
-      del_flag)
-    values (#{id,jdbcType=BIGINT}, #{entId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, 
-      #{carNum,jdbcType=VARCHAR}, #{driverId,jdbcType=BIGINT}, #{entrustAmount,jdbcType=DECIMAL}, 
-      #{remark,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createBy,jdbcType=BIGINT}, 
-      #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, 
-      #{delFlag,jdbcType=INTEGER})
-  </insert>
-  <insert id="insertSelective" parameterType="com.sckw.transport.model.KwtLogisticsOrderCirculate">
-    insert into kwt_logistics_order_circulate
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        id,
-      </if>
-      <if test="entId != null">
-        ent_id,
-      </if>
-      <if test="orderId != null">
-        order_id,
-      </if>
-      <if test="carNum != null">
-        car_num,
-      </if>
-      <if test="driverId != null">
-        driver_id,
-      </if>
-      <if test="entrustAmount != null">
-        entrust_amount,
-      </if>
-      <if test="remark != null">
-        remark,
-      </if>
-      <if test="status != null">
-        `status`,
-      </if>
-      <if test="createBy != null">
-        create_by,
-      </if>
-      <if test="createTime != null">
-        create_time,
-      </if>
-      <if test="updateBy != null">
-        update_by,
-      </if>
-      <if test="updateTime != null">
-        update_time,
-      </if>
-      <if test="delFlag != null">
-        del_flag,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=BIGINT},
-      </if>
-      <if test="entId != null">
-        #{entId,jdbcType=BIGINT},
-      </if>
-      <if test="orderId != null">
-        #{orderId,jdbcType=BIGINT},
-      </if>
-      <if test="carNum != null">
-        #{carNum,jdbcType=VARCHAR},
-      </if>
-      <if test="driverId != null">
-        #{driverId,jdbcType=BIGINT},
-      </if>
-      <if test="entrustAmount != null">
-        #{entrustAmount,jdbcType=DECIMAL},
-      </if>
-      <if test="remark != null">
-        #{remark,jdbcType=VARCHAR},
-      </if>
-      <if test="status != null">
-        #{status,jdbcType=INTEGER},
-      </if>
-      <if test="createBy != null">
-        #{createBy,jdbcType=BIGINT},
-      </if>
-      <if test="createTime != null">
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateBy != null">
-        #{updateBy,jdbcType=BIGINT},
-      </if>
-      <if test="updateTime != null">
-        #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="delFlag != null">
-        #{delFlag,jdbcType=INTEGER},
-      </if>
-    </trim>
-  </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.sckw.transport.model.KwtLogisticsOrderCirculate">
-    update kwt_logistics_order_circulate
-    <set>
-      <if test="entId != null">
-        ent_id = #{entId,jdbcType=BIGINT},
-      </if>
-      <if test="orderId != null">
-        order_id = #{orderId,jdbcType=BIGINT},
-      </if>
-      <if test="carNum != null">
-        car_num = #{carNum,jdbcType=VARCHAR},
-      </if>
-      <if test="driverId != null">
-        driver_id = #{driverId,jdbcType=BIGINT},
-      </if>
-      <if test="entrustAmount != null">
-        entrust_amount = #{entrustAmount,jdbcType=DECIMAL},
-      </if>
-      <if test="remark != null">
-        remark = #{remark,jdbcType=VARCHAR},
-      </if>
-      <if test="status != null">
-        `status` = #{status,jdbcType=INTEGER},
-      </if>
-      <if test="createBy != null">
-        create_by = #{createBy,jdbcType=BIGINT},
-      </if>
-      <if test="createTime != null">
-        create_time = #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateBy != null">
-        update_by = #{updateBy,jdbcType=BIGINT},
-      </if>
-      <if test="updateTime != null">
-        update_time = #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="delFlag != null">
-        del_flag = #{delFlag,jdbcType=INTEGER},
-      </if>
-    </set>
-    where id = #{id,jdbcType=BIGINT}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.sckw.transport.model.KwtLogisticsOrderCirculate">
-    update kwt_logistics_order_circulate
-    set ent_id = #{entId,jdbcType=BIGINT},
-      order_id = #{orderId,jdbcType=BIGINT},
-      car_num = #{carNum,jdbcType=VARCHAR},
-      driver_id = #{driverId,jdbcType=BIGINT},
-      entrust_amount = #{entrustAmount,jdbcType=DECIMAL},
-      remark = #{remark,jdbcType=VARCHAR},
-      `status` = #{status,jdbcType=INTEGER},
-      create_by = #{createBy,jdbcType=BIGINT},
-      create_time = #{createTime,jdbcType=TIMESTAMP},
-      update_by = #{updateBy,jdbcType=BIGINT},
-      update_time = #{updateTime,jdbcType=TIMESTAMP},
-      del_flag = #{delFlag,jdbcType=INTEGER}
-    where id = #{id,jdbcType=BIGINT}
-  </update>
+    <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtLogisticsOrderCirculate">
+        <id column="id" jdbcType="BIGINT" property="id" />
+        <result column="ent_id" jdbcType="BIGINT" property="entId" />
+        <result column="l_order_id" jdbcType="BIGINT" property="lOrderId" />
+        <result column="w_order_id" jdbcType="BIGINT" property="wOrderId" />
+        <result column="truck_no" jdbcType="VARCHAR" property="truckNo" />
+        <result column="driver_id" jdbcType="BIGINT" property="driverId" />
+        <result column="type" jdbcType="BIGINT" property="type" />
+        <result column="actual_amount" jdbcType="DECIMAL" property="actualAmount" />
+        <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount" />
+        <result column="entrust_date" jdbcType="TIMESTAMP" property="entrustDate" />
+        <result column="remark" jdbcType="VARCHAR" property="remark" />
+        <result column="status" jdbcType="INTEGER" property="status" />
+        <result column="create_by" jdbcType="BIGINT" property="createBy" />
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+        <result column="update_by" jdbcType="BIGINT" property="updateBy" />
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
+    </resultMap>
+    <sql id="Base_Column_List">
+        id, ent_id, l_order_id, w_order_id, truck_no,type, driver_id, actual_amount, entrust_amount,
+    entrust_date, remark, `status`, create_by, create_time, update_by, update_time, del_flag
+    </sql>
+    <select id="selectDriverOrderByStatus" resultType="java.lang.Long">
+        SELECT b.w_order_id as wOrderId
+        FROM kwt_waybill_order a
+        LEFT JOIN `kwt_logistics_order_circulate` b ON a.id = b.w_order_id
+        WHERE a.del_flag = '0'
+        AND b.`status` = '0'
+        AND a.type = '1'
+        <if test="id != null and id !=''">
+           and  b.driver_id = #{id,jdbcType=BIGINT}
+        </if>
+        <if test="status != null and status.size() > 0">
+            AND a.`status` IN
+            <foreach collection="status" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 </mapper>

+ 2 - 1
sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.xml

@@ -75,12 +75,13 @@
         LEFT JOIN kwt_waybill_order_track b ON a.id = b.w_order_id
         AND a.del_flag = '0'
         AND b.del_flag = '0'
+        AND a.type='0'
         <where>
             <if test="id != null and id !=''">
                 a.driver_id = #{id,jdbcType=BIGINT}
             </if>
             <if test="status != null and status.size() > 0">
-                AND b.`status` IN
+                AND a.`status` IN
                 <foreach collection="status" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>