Răsfoiți Sursa

1、添加循环派车查询

zk 2 ani în urmă
părinte
comite
a4a1ea20f0

+ 9 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java

@@ -52,4 +52,13 @@ public enum CarWaybillEnum {
         }
         return null;
     }
+
+    public static String getName(Integer code) {
+        for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
+            if (waybillEnum.getCode().equals(code)) {
+                return waybillEnum.getDestination();
+            }
+        }
+        return null;
+    }
 }

+ 9 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/LogisticsOrderEnum.java

@@ -53,4 +53,13 @@ public enum LogisticsOrderEnum {
         }
         return null;
     }
+
+    public static String getName(Integer code) {
+        for (LogisticsOrderEnum logisticsOrderEnum : LogisticsOrderEnum.values()) {
+            if (logisticsOrderEnum.getCode().equals(code)) {
+                return logisticsOrderEnum.getDestination();
+            }
+        }
+        return null;
+    }
 }

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtWaybillOrderController.java

@@ -100,7 +100,7 @@ public class KwtWaybillOrderController {
         if (CollectionUtils.isEmpty(params)) {
             return HttpResult.error("请选择委派车辆信息!");
         }
-        return waybillOrderService.commitSendCar(params);
+        return waybillOrderService.sendCar(params);
     }
 
 

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

@@ -2,7 +2,10 @@ package com.sckw.transport.model;
 
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.sckw.core.model.base.BaseModel;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -15,12 +18,9 @@ import java.util.Date;
  * @date 2023-06-26 16:06:12
  */
 @Data
-@TableName("kwt_logistics_order_circulate")
-public class KwtLogisticsOrderCirculate implements Serializable {
-    /**
-     * 主键
-     */
-    private Long id;
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class KwtLogisticsOrderCirculate extends BaseModel {
 
     /**
      * 企业id
@@ -36,6 +36,11 @@ public class KwtLogisticsOrderCirculate implements Serializable {
      */
     private Long wOrderId;
 
+    /**
+     * 车辆信息ID
+     */
+    private Long truckId;
+
     /**
      * 车牌号
      */
@@ -43,7 +48,7 @@ public class KwtLogisticsOrderCirculate implements Serializable {
     /**
      * 0趟次1循环
      */
-    private String type;
+    private Integer type;
 
     /**
      * 司机id
@@ -51,43 +56,38 @@ public class KwtLogisticsOrderCirculate implements Serializable {
     private Long driverId;
 
     /**
-     * 标准荷载(净重)
+     * 司机姓名
      */
-    private BigDecimal actualAmount;
+    private String driverName;
 
     /**
-     * 委托量
+     * 司机手机号码
      */
-    private BigDecimal entrustAmount;
-
-    private Date entrustDate;
+    private String driverPhone;
 
     /**
-     * 备注
+     * 司机身份证号
      */
-    private String remark;
+    private String driverIdcard;
 
     /**
-     * 用户状态(0正常、1失效
+     * 标准荷载(净重
      */
-    private Integer status;
-
-    private Long createBy;
-
-    private Date createTime;
+    private BigDecimal actualAmount;
 
-    private Long updateBy;
+    /**
+     * 委托量
+     */
+    private BigDecimal entrustAmount;
 
     /**
-     * 更新时间
+     * 计划开始时间
      */
-    private Date updateTime;
+    private Date startTime;
 
     /**
-     * 是否删除(0未删除,1删除)
+     * 计划结束时间
      */
-    @TableLogic("0")
-    private Integer delFlag;
+    private Date endTime;
 
-    private static final long serialVersionUID = 1L;
 }

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/SendCarDto1.java

@@ -62,7 +62,7 @@ public class SendCarDto1 {
      * 车牌号
      */
     @JsonProperty("truckId")
-    @NotBlank(message = "车辆信息ID不能为空")
+    @NotNull(message = "车辆信息ID不能为空")
     private Long truckId;
 
     /**

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

@@ -3,6 +3,7 @@ package com.sckw.transport.service;
 import com.alibaba.fastjson.JSON;
 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.utils.BeanUtils;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
@@ -17,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cloud.stream.function.StreamBridge;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
@@ -49,20 +49,36 @@ public class KwtWaybillOrderService {
 
     /**
      * @param params
-     * @desc 派车
+     * @desc 派车-趟次
      * @author zk
      * @date 2023/7/19
      **/
     @Transactional(rollbackFor = Exception.class)
-    public HttpResult commitSendCar(List<SendCarDto1> params) {
-        /**校验是车辆委托量否超过物流订单剩余量**/
+    public HttpResult sendCar(List<SendCarDto1> params) {
+        /**校验物流运单是否可以派车**/
         //承运单信息
         KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(params.get(0).getLOrderId());
         if (logisticsOrder == null) {
             return HttpResult.error("订单已不存在!" );
         }
 
-        //下游司机委派量累加
+        //状态校验
+        if (logisticsOrder.getStatus() != LogisticsOrderEnum.WAIT_DELIVERY.getCode()
+                && logisticsOrder.getStatus() != LogisticsOrderEnum.IN_TRANSIT.getCode()) {
+            return HttpResult.error("订单"+LogisticsOrderEnum.getName(logisticsOrder.getStatus())+"不能派车!" );
+        }
+
+        //剩余可运量校验
+        BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getEntrustAmount();
+        BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getSubcontractAmount();
+        //历史下游司机委派量 + 分包量
+        BigDecimal entrustAmountTotal = entrustAmount.add(subcontractAmount);
+        if (entrustAmountTotal.compareTo(logisticsOrder.getAmount()) > 0) {
+            return HttpResult.error("剩余可运量已不能派车!" );
+        }
+
+        /**校验是车辆委托量否超过物流订单剩余量**/
+        //下游司机委派量累加(趟次)
         BigDecimal ranksAmount = new BigDecimal(Global.AMOUNT);
         for (SendCarDto1 sendCarDto:params) {
             if (sendCarDto.getType() == Global.NUMERICAL_ONE) {
@@ -70,18 +86,16 @@ public class KwtWaybillOrderService {
                 if (sendCarDto.getCount() == null || sendCarDto.getCount() <= 0) {
                     return HttpResult.error(sendCarDto.getTruckNo() + "趟次必须等于或大于0!" );
                 }
-                //核定载量 * 趟次
-                Double entrustAmount = sendCarDto.getEntrustAmount() * sendCarDto.getCount();
-                ranksAmount = ranksAmount.add(new BigDecimal(entrustAmount));
-            }
-        }
+                //承运订单该车辆计划运输总量:核定载量 * 趟次
+                Double truckEntrustAmount = sendCarDto.getEntrustAmount() * sendCarDto.getCount();
+                ranksAmount = ranksAmount.add(new BigDecimal(truckEntrustAmount));
 
-        //当前下游司机委派量 + 历史下游司机委派量 + 分包量
-        BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getEntrustAmount();
-        BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getSubcontractAmount();
-        BigDecimal actualAmount = ranksAmount.add(entrustAmount).add(subcontractAmount);
-        if (actualAmount.compareTo(logisticsOrder.getAmount()) > 0) {
-            return HttpResult.error("累计派车量已大于剩余可运量!" );
+                //当前下游司机委派量 + 历史下游司机委派量 + 分包量
+                BigDecimal actualAmount = ranksAmount.add(entrustAmountTotal);
+                if (actualAmount.compareTo(logisticsOrder.getAmount()) > 0) {
+                    return HttpResult.error("累计派车量已大于剩余可运量!" );
+                }
+            }
         }
 
         /**数据处理**/
@@ -119,17 +133,14 @@ public class KwtWaybillOrderService {
             /**KwtWaybillOrder数据组装**/
             KwtWaybillOrder waybillOrder = this.setKwtWaybillOrder(sendCarDto);
 
-            /**车辆运单信息**/
-            waybillOrderDao.insert(waybillOrder);
-
-            /**车辆运单地址信息**/
-            loadAddress.setWOrderId(waybillOrder.getId());
-            waybillOrderAddressDao.insert(loadAddress);
-            unloadAddress.setWOrderId(waybillOrder.getId());
-            waybillOrderAddressDao.insert(unloadAddress);
-
-            /**车辆运单状态记录**/
-            this.setWaybillOrderTrack(waybillOrder.getId(), waybillOrder.getStatus());
+            /**数据存储**/
+            if (sendCarDto.getType() == Global.NUMERICAL_ONE) {
+                //趟次派车存储
+                ranksSave(waybillOrder, loadAddress, unloadAddress);
+            } else {
+                //循环派车存储
+                circulateSave(waybillOrder);
+            }
 
             /**SckwWaybillOrder数据组装**/
             SckwWaybillOrder mongoOrder = setSckwWaybillOrder(sendCarDto, waybillOrder, logisticsOrder, loadAddress,
@@ -153,6 +164,52 @@ public class KwtWaybillOrderService {
         return HttpResult.ok();
     }
 
+
+    /**
+     * @param waybillOrder 车辆订单信息
+     * @param loadAddress 装货地址信息
+     * @param unloadAddress 卸货地址信息
+     * @desc 趟次派车数据存储
+     * @author zk
+     * @date 2023/7/21
+     **/
+    public void ranksSave(KwtWaybillOrder waybillOrder, KwtWaybillOrderAddress loadAddress, KwtWaybillOrderAddress unloadAddress) {
+        /**车辆运单信息**/
+        waybillOrderDao.insert(waybillOrder);
+
+        /**车辆运单地址信息**/
+        loadAddress.setWOrderId(waybillOrder.getId());
+        waybillOrderAddressDao.insert(loadAddress);
+        unloadAddress.setWOrderId(waybillOrder.getId());
+        waybillOrderAddressDao.insert(unloadAddress);
+
+        /**车辆运单状态记录**/
+        this.setWaybillOrderTrack(waybillOrder.getId(), waybillOrder.getStatus());
+    }
+
+    @Autowired
+    KwtLogisticsOrderCirculateMapper logisticsOrderCirculateDao;
+
+    /**
+     * @param waybillOrder 车辆订单信息
+     * @desc 循环派车数据存储
+     * @author zk
+     * @date 2023/7/21
+     **/
+    public boolean circulateSave(KwtWaybillOrder waybillOrder) {
+        //循环派车信息
+        KwtLogisticsOrderCirculate circulate = logisticsOrderCirculateDao.findCirculate(waybillOrder.getLOrderId(),
+                waybillOrder.getTruckNo(), waybillOrder.getDriverId());
+        if (circulate == null || circulate.getStatus() == Global.UN_READ) {
+            circulate = new KwtLogisticsOrderCirculate();
+            BeanUtils.copyProperties(waybillOrder, circulate);
+            circulate.setWOrderId(null);
+            int count = logisticsOrderCirculateDao.insert(circulate);
+            return count > 0 ? true : false;
+        }
+        return true;
+    }
+
     /**
      * @param lOrderId 物流订单ID
      * @param addressType 地址类型(1装货地址、2卸货地址)
@@ -167,6 +224,11 @@ public class KwtWaybillOrderService {
         /**组装数据**/
         KwtWaybillOrderAddress address = new KwtWaybillOrderAddress();
         BeanUtils.copyProperties(orderAddress, address);
+        address.setId(null);
+        address.setCreateBy(null);
+        address.setCreateTime(null);
+        address.setUpdateBy(null);
+        address.setUpdateBy(null);
         return address;
     }
 
@@ -223,9 +285,9 @@ public class KwtWaybillOrderService {
      * @date 2023/7/20
      **/
     public SckwWaybillOrder setSckwWaybillOrder(SendCarDto1 sendCarDto, KwtWaybillOrder waybillOrder,
-                                            KwtLogisticsOrder logisticsOrder, KwtWaybillOrderAddress loadAddress,
-                                            KwtWaybillOrderAddress unloadAddress, KwtLogisticsOrderUnit checkEnt,
-                                            KwtLogisticsOrderUnit carrierEnt, KwtLogisticsOrderGoods goods) {
+                                                KwtLogisticsOrder logisticsOrder, KwtWaybillOrderAddress loadAddress,
+                                                KwtWaybillOrderAddress unloadAddress, KwtLogisticsOrderUnit checkEnt,
+                                                KwtLogisticsOrderUnit carrierEnt, KwtLogisticsOrderGoods goods) {
         //基础信息
         SckwWaybillOrder order = new SckwWaybillOrder();
         order.set_id(waybillOrder.getId());

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

@@ -38,6 +38,6 @@
         from kwt_logistics_order_address
         where del_flag = 0
         and l_order_id = #{lOrderId, jdbcType=BIGINT}
-        and address_type = #{addressType jdbcType=INTEGER}
+        and address_type = #{addressType, jdbcType=INTEGER}
     </select>
 </mapper>

+ 3 - 25
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderCirculateMapper.xml

@@ -1,29 +1,7 @@
 <?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="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
@@ -50,7 +28,7 @@
         from kwt_logistics_order_circulate
         where del_flag = 0
         and l_order_id = #{lOrderId, jdbcType=BIGINT}
-        and truck_no = #{truckNo jdbcType=VARCHAR}
-        and driver_id = #{driverId jdbcType=BIGINT}
+        and truck_no = #{truckNo, dbcType=VARCHAR}
+        and driver_id = #{driverId, jdbcType=BIGINT}
     </select>
 </mapper>

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

@@ -29,7 +29,7 @@
         from kwt_logistics_order_unit
         where del_flag = 0
         and l_order_id = #{lOrderId, jdbcType=BIGINT}
-        and unit_type = #{unitType jdbcType=INTEGER}
+        and unit_type = #{unitType, jdbcType=INTEGER}
     </select>
 
 </mapper>