Просмотр исходного кода

1、地图监控托运方查询业务关联进行中的车辆;;

zk 2 лет назад
Родитель
Сommit
a4ec93ac2d

+ 30 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/EntTypeEnum.java

@@ -1,6 +1,7 @@
 package com.sckw.core.model.enums;
 
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.StringUtils;
 import lombok.Getter;
 
 import java.util.ArrayList;
@@ -51,4 +52,33 @@ public enum EntTypeEnum {
         }
         return String.join(Global.COMMA, entNames);
     }
+
+    /**
+     * @param entTypes 企业属性
+     * @desc 校验企业是否为托运单位(供应商、采购商、4P物流)
+     * @author zk
+     * @date 2023/10/7
+     **/
+    public static Boolean check(String entTypes) {
+        if (StringUtils.isBlank(entTypes)) {
+            return null;
+        }
+        return entTypes.contains(String.valueOf(EntTypeEnum.SUPPLIER.getCode()))
+                || entTypes.contains(String.valueOf(EntTypeEnum.PURCHASER.getCode()))
+                || entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS3.getCode()));
+    }
+
+    /**
+     * @param entTypes 企业属性
+     * @desc 校验企业是否为承运单位(4P物流、3P物流)
+     * @author zk
+     * @date 2023/10/7
+     **/
+    public static Boolean carrier(String entTypes) {
+        if (StringUtils.isBlank(entTypes)) {
+            return null;
+        }
+        return entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS3.getCode()))
+                || entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS4.getCode()));
+    }
 }

+ 9 - 0
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/dubbo/TransportDubboService.java

@@ -8,6 +8,7 @@ import com.sckw.transport.api.model.dto.RWaybillOrderDto;
 import com.sckw.transport.api.model.param.ContractSignLogisticsParam;
 import com.sckw.transport.api.model.param.LogisticsOrderParam;
 import com.sckw.transport.api.model.vo.KwtLogisticsOrderVO;
+import com.sckw.transport.api.model.vo.RTruckMonitorVo;
 import com.sckw.transport.api.model.vo.RWaybillOrderVo;
 import java.util.List;
 import java.util.Map;
@@ -115,4 +116,12 @@ public interface TransportDubboService {
      * @date 2023/9/6
      **/
     List<RWaybillOrderVo> findWaybillOrder(RWaybillOrderDto params);
+
+    /**
+     * @param checkEntId 托运企业ID
+     * @desc 查询托运方关联任务中的车辆
+     * @author zk
+     * @date 2023/10/8
+     **/
+    List<RTruckMonitorVo> truckInTask(Long checkEntId);
 }

+ 51 - 0
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/vo/RTruckMonitorVo.java

@@ -0,0 +1,51 @@
+package com.sckw.transport.api.model.vo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * desc 车辆监控
+ * author zk
+ * date 2023/9/5 0005
+ */
+@Data
+public class RTruckMonitorVo implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -7951209824419412406L;
+
+    /**
+     *企业id
+     */
+    private Long entId;
+
+    /**
+     *企业名称
+     */
+    private String firmName;
+
+    /**
+     *车牌号
+     */
+    private String truckNo;
+
+    /**
+     *业务状态(0空闲、1任务中)
+     */
+    private Integer businessStatus;
+
+    /**
+     *运行状态(0行驶、1停止、2离线)
+     */
+    private Integer runStatus;
+
+    public RTruckMonitorVo() {
+    }
+
+    public RTruckMonitorVo(Long entId, String truckNo, Integer businessStatus) {
+        this.entId = entId;
+        this.truckNo = truckNo;
+        this.businessStatus = businessStatus;
+    }
+}

+ 14 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckMonitorVo.java

@@ -2,13 +2,18 @@ package com.sckw.fleet.model.vo;
 
 import lombok.Data;
 
+import java.io.Serial;
+import java.io.Serializable;
+
 /**
  * desc 车辆监控
  * author zk
  * date 2023/9/5 0005
  */
 @Data
-public class KwfTruckMonitorVo {
+public class KwfTruckMonitorVo implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -7951209824419412416L;
 
     /**
      *企业id
@@ -35,4 +40,12 @@ public class KwfTruckMonitorVo {
      */
     private Integer runStatus;
 
+    public KwfTruckMonitorVo() {
+    }
+
+    public KwfTruckMonitorVo(Long entId, String truckNo, Integer businessStatus) {
+        this.entId = entId;
+        this.truckNo = truckNo;
+        this.businessStatus = businessStatus;
+    }
 }

+ 26 - 5
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -10,6 +10,7 @@ import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.common.enums.enums.FileEnum;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.EntTypeEnum;
 import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.file.FileInfo;
 import com.sckw.core.utils.*;
@@ -30,6 +31,7 @@ import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.api.dubbo.TransportDubboService;
 import com.sckw.transport.api.model.dto.RWaybillOrderDto;
+import com.sckw.transport.api.model.vo.RTruckMonitorVo;
 import com.sckw.transport.api.model.vo.RWaybillOrderVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -733,15 +735,34 @@ public class KwfTruckService {
      * @date 2023/9/6
      **/
     public List<KwfTruckMonitorVo> findTruckMonitor(Map params) {
-        List<KwfTruckMonitorVo> trucks = new ArrayList<>();
+        //企业PC/APP
         if (LoginUserHolder.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
-            params.put("entId", LoginUserHolder.getEntId());
-            trucks = truckDao.findTruckByEnt(params);
+            List<KwfTruckMonitorVo> trucks = new ArrayList<>();
+            //企业属性
+            String entTypes = LoginEntHolder.get().getEntTypes();
+            //承运方
+            Boolean bool = EntTypeEnum.carrier(entTypes);
+            if (bool != null && bool) {
+                params.put("entId", LoginUserHolder.getEntId());
+                List<KwfTruckMonitorVo> carrierTrucks = truckDao.findTruckByEnt(params);
+                trucks.addAll(carrierTrucks);
+            }
+
+            //托运方
+            bool = EntTypeEnum.check(entTypes);
+            if (bool != null && bool) {
+                List<RTruckMonitorVo> checkTrucks = transportDubboService.truckInTask(LoginUserHolder.getEntId());
+                checkTrucks.forEach(order -> trucks.add(new KwfTruckMonitorVo(order.getEntId(), order.getTruckNo(), Global.NUMERICAL_ONE)));
+            }
+
+            return trucks;
         }
+
+        //运营端
         if (LoginUserHolder.getSystemType() == SystemTypeEnum.MANAGE.getCode()) {
-            trucks = truckDao.findTruckByAll(params);
+            return truckDao.findTruckByAll(params);
         }
-        return trucks;
+        return new ArrayList<>();
     }
 
     /**

+ 1 - 1
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml

@@ -348,7 +348,7 @@
 
     <select id="findTruckByEnt" resultType="com.sckw.fleet.model.vo.KwfTruckMonitorVo" >
         SELECT
-            kt.truck_no, kt.business_status businessStatus, kte.ent_id entId
+            kt.truck_no truckNo, kt.business_status businessStatus, kte.ent_id entId
         from kwf_truck kt
         left join kwf_truck_ent kte on kte.truck_id = kt.id
         where kt.del_flag = 0 and kte.del_flag = 0

+ 58 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dubbo/TransportDubboServiceImpl.java

@@ -36,11 +36,13 @@ import com.sckw.transport.api.model.dto.RWaybillOrderDto;
 import com.sckw.transport.api.model.param.ContractSignLogisticsParam;
 import com.sckw.transport.api.model.param.LogisticsOrderParam;
 import com.sckw.transport.api.model.vo.KwtLogisticsOrderVO;
+import com.sckw.transport.api.model.vo.RTruckMonitorVo;
 import com.sckw.transport.api.model.vo.RWaybillOrderVo;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.*;
 import com.sckw.transport.service.CommonService;
 import jakarta.annotation.Resource;
+import jodd.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboService;
@@ -624,4 +626,60 @@ public class TransportDubboServiceImpl implements TransportDubboService {
 
         return waybillOrderVos;
     }
+
+    /**
+     * @param checkEntId 托运企业ID
+     * @desc 查询托运方关联任务中的车辆
+     * @author zk
+     * @date 2023/10/8
+     **/
+    @Override
+    public List<RTruckMonitorVo> truckInTask(Long checkEntId) {
+        //查询物流订单
+        List<Long> orderIds = new ArrayList<>();
+        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+            put("status", LogisticsOrderEnum.IN_TRANSIT.getCode());
+            put("checkEntId", checkEntId);
+        }};
+        List<KwtLogisticsOrder> orders = logisticsOrderMapper.findLogisticsOrder(params);
+        if (!CollectionUtils.isEmpty(orders)) {
+            List<Long> idList = new ArrayList<>();
+            orders.forEach(order -> idList.add(order.getId()));
+            orderIds.addAll(idList);
+            findLogisticsOrderChild(orderIds, StringUtil.join(idList, Global.COMMA));
+        }
+
+        //查询运单
+        List<RTruckMonitorVo> trucks = new ArrayList<>();
+        params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+            put("busStatus", Global.NUMERICAL_THREE);
+            put("lOrderIds", StringUtil.join(orderIds, Global.COMMA));
+        }};
+        List<KwtWaybillOrder> waybillOrders = waybillOrderDao.findWaybillOrder(params);
+        waybillOrders.forEach(order -> trucks.add(new RTruckMonitorVo(order.getEntId(), order.getTruckNo(), Global.NUMERICAL_ONE)));
+        return trucks;
+    }
+
+    /**
+     * @param orderIds 物流订单ID集合
+     * @param ids 当前物流订单ID
+     * @desc 查询下级分包 物流订单
+     * @author zk
+     * @date 2023/10/8
+     **/
+    public void findLogisticsOrderChild(List<Long> orderIds, String ids) {
+        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+            put("status", LogisticsOrderEnum.IN_TRANSIT.getCode());
+            put("pid", ids);
+        }};
+        //查询物流订单
+        List<KwtLogisticsOrder> orders = logisticsOrderMapper.findLogisticsOrder(params);
+        if (!CollectionUtils.isEmpty(orders)) {
+            List<Long> idList = new ArrayList<>();
+            orders.forEach(order -> idList.add(order.getId()));
+            orderIds.addAll(idList);
+            findLogisticsOrderChild(orderIds, StringUtil.join(idList, Global.COMMA));
+        }
+        return;
+    }
 }

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

@@ -40,6 +40,7 @@ import com.sckw.transport.model.vo.WaybillCountVo;
 import com.sckw.transport.model.vo.WaybillOrderDriverVo;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
+import jodd.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -2543,7 +2544,6 @@ public class KwtWaybillOrderService {
 
     /**
      * 承运订单-托运订单-订单详情数据统计
-     *
      * @param orderId
      * @param type
      * @return
@@ -2562,7 +2562,6 @@ public class KwtWaybillOrderService {
 
     /**
      * 承运数据统计
-     *
      * @param orderId
      * @return
      */
@@ -2605,7 +2604,6 @@ public class KwtWaybillOrderService {
 
     /**
      * 托运数据统计
-     *
      * @param orderId
      * @return
      */
@@ -2649,7 +2647,6 @@ public class KwtWaybillOrderService {
 
     /**
      * 查询已排量、待运量数据
-     *
      * @param orderId 物流订单id
      * @return
      */

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

@@ -787,6 +787,12 @@
         <if test="id != null and id != ''">
             and id = #{id, jdbcType=BIGINT}
         </if>
+        <if test="pid != null and pid != ''">
+            and pid in (#{pid, jdbcType=VARCHAR})
+        </if>
+        <if test="status != null and status != ''">
+            and status = #{status, jdbcType=INTEGER}
+        </if>
         <if test="upperlOrderId != null and upperlOrderId != ''">
             and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
         </if>
@@ -802,8 +808,11 @@
                 or FIND_IN_SET(id, #{currentlOrderId, jdbcType=VARCHAR})
             )
         </if>
-
+        <if test="checkEntId != null and checkEntId != ''">
+            and id in (select l_order_id from kwt_logistics_order_unit where unit_type = 1 and top_ent_id = #{checkEntId, jdbcType=BIGINT})
+        </if>
     </select>
+
     <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
         SELECT a.id          as lOrderId,
                a.l_order_no  as lOrderNo,
@@ -2603,4 +2612,5 @@
             and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
         </if>
     </select>
+
 </mapper>

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

@@ -644,7 +644,7 @@
         kwo.id worderId, kwo.w_order_no worderNo, kwo.l_order_id lOrderId, kwo.type, kwo.ent_id carrierEntId, kwo.start_time startTime,
         kwo.end_time endTime, kwo.entrust_amount entrustAmount, kwo.load_amount loadAmount, kwo.unload_amount unloadAmount,
         kwo.deficit_amount deficitAmount, kwo.deficit_price deficitPrice, kwo.truck_id truckId, kwo.truck_no truckNo, kwo.status,
-        kwo.create_time createTime, kwo.driver_id driverId, kwo.driver_name driverName, kwo.driver_phone driverPhone
+        kwo.create_time createTime, kwo.driver_id driverId, kwo.driver_name driverName, kwo.driver_phone driverPhone, kwo.ent_id entId
         FROM kwt_waybill_order kwo
         where kwo.del_flag = 0
         <if test="tOrderId != null and tOrderId != ''">
@@ -653,6 +653,9 @@
         <if test="lOrderId != null and lOrderId != ''">
             and kwo.l_order_id = #{lOrderId, jdbcType=BIGINT}
         </if>
+        <if test="lOrderIds != null and lOrderIds != ''">
+            and kwo.l_order_id in ( #{lOrderIds, jdbcType=VARCHAR} )
+        </if>
         <if test="driverId != null and driverId != ''">
             and kwo.driver_id = #{driverId, jdbcType=BIGINT}
         </if>