Browse Source

1、车队服务dubbo接口;

zk 2 years ago
parent
commit
3430398deb

+ 1 - 0
sckw-modules-api/pom.xml

@@ -19,6 +19,7 @@
         <module>sckw-transport-api</module>
         <module>sckw-product-api</module>
         <module>sckw-order-api</module>
+        <module>sckw-fleet-api</module>
     </modules>
 
     <properties>

+ 25 - 0
sckw-modules-api/sckw-fleet-api/pom.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>sckw-modules-api</artifactId>
+        <groupId>com.sckw</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>sckw-fleet-api</artifactId>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 29 - 0
sckw-modules-api/sckw-fleet-api/src/main/java/com/sckw/fleet/api/RemoteFleetService.java

@@ -0,0 +1,29 @@
+package com.sckw.fleet.api;
+
+import com.sckw.fleet.api.model.vo.RDriverVo;
+import com.sckw.fleet.api.model.vo.RTruckVo;
+import java.util.Map;
+
+/**
+ * @author zk
+ * @desc 车队服务
+ * @date 2023/7/18 0018
+ */
+public interface RemoteFleetService {
+
+    /**
+     * @param driverIds 司机档案主键id,多个已逗号隔开
+     * @desc 查询司机信息
+     * @author zk
+     * @date 2023/7/18
+     **/
+    Map<Long, RDriverVo> findDriver(String driverIds);
+
+    /**
+     * @param truckNos 车牌号,多个已逗号隔开
+     * @desc 查询车辆信息
+     * @author zk
+     * @date 2023/7/18
+     **/
+    Map<Long, RTruckVo> findTruck(String truckNos);
+}

+ 49 - 0
sckw-modules-api/sckw-fleet-api/src/main/java/com/sckw/fleet/api/model/vo/RDriverVo.java

@@ -0,0 +1,49 @@
+package com.sckw.fleet.api.model.vo;
+
+import lombok.Data;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author zk
+ * @desc 司机
+ * @date 2023/7/17 0017
+ */
+@Data
+public class RDriverVo implements Serializable {
+
+    /**
+     * 司机档案主键id
+     */
+    private Long id;
+
+    /**
+     * 司机姓名
+     */
+    private String name;
+
+    /**
+     * 司机手机号
+     */
+    private String phone;
+
+    /**
+     * 身份证号
+     */
+    private String idcard;
+
+    /**
+     * 总运单完成量
+     */
+    private Integer totalComplete;
+
+    /**
+     * 总运单接单量
+     */
+    private Integer totalTake;
+
+    /**
+     * 总运量(净重)
+     */
+    private BigDecimal totalWeight;
+}

+ 54 - 0
sckw-modules-api/sckw-fleet-api/src/main/java/com/sckw/fleet/api/model/vo/RTruckVo.java

@@ -0,0 +1,54 @@
+package com.sckw.fleet.api.model.vo;
+
+import lombok.Data;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author zk
+ * @desc 车辆档案
+ * @date 2023/7/17 0017
+ */
+@Data
+public class RTruckVo implements Serializable {
+
+    /**
+     * 车辆档案主键id
+     */
+    private Long id;
+
+    /**
+     * 车牌号
+     */
+    private String truckNo;
+
+    /**
+     * 核定载质量/吨
+     */
+    private Double actualWeight;
+
+    /**
+     * 挂车号
+     */
+    private String trailerNo;
+
+    /**
+     * 总运单完成量
+     */
+    private Integer totalComplete;
+
+    /**
+     * 总运单接单量
+     */
+    private Integer totalTake;
+
+    /**
+     * 总运量(净重)
+     */
+    private BigDecimal totalWeight;
+
+    /**
+     * 车辆业务状态
+     */
+    private Integer businessStatus;
+}

+ 6 - 0
sckw-modules-api/sckw-modules-bom/pom.xml

@@ -34,6 +34,12 @@
                 <artifactId>sckw-message-api</artifactId>
                 <version>${project.version}</version>
             </dependency>
+
+            <dependency>
+                <groupId>com.sckw</groupId>
+                <artifactId>sckw-fleet-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 </project>

+ 5 - 0
sckw-modules/sckw-fleet/pom.xml

@@ -64,6 +64,11 @@
             <artifactId>sckw-system-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-fleet-api</artifactId>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 0 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java

@@ -17,7 +17,6 @@ import com.sckw.fleet.model.vo.KwfTruckVo;
 import com.sckw.fleet.service.KwfTruckService;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
-import org.checkerframework.checker.units.qual.K;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;

+ 93 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dubbo/RemoteFleetServiceImpl.java

@@ -0,0 +1,93 @@
+package com.sckw.fleet.dubbo;
+
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.fleet.api.RemoteFleetService;
+import com.sckw.fleet.api.model.vo.RDriverVo;
+import com.sckw.fleet.api.model.vo.RTruckVo;
+import com.sckw.fleet.dao.KwfDriverMapper;
+import com.sckw.fleet.dao.KwfTruckMapper;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author zk
+ * @desc 车队服务
+ * @date 2023/7/18 0018
+ */
+@DubboService(group = "design", version = "1.0.0")
+@Service
+public class RemoteFleetServiceImpl implements RemoteFleetService {
+
+    @Autowired
+    KwfTruckMapper truckDao;
+    @Autowired
+    KwfDriverMapper driverDao;
+
+    /**
+     * @param driverIds 司机档案主键id,多个已逗号隔开
+     * @desc 查询司机信息
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @Override
+    public Map<Long, RDriverVo> findDriver(String driverIds) {
+        /**获取数据**/
+        Map<Long, RDriverVo> driverMap = new HashMap();
+        List<Map<String, Object>> drivers = driverDao.findList(new HashMap(){{put("ids", driverIds);}});
+        if (CollectionUtils.isEmpty(drivers)) {
+            return driverMap;
+        }
+
+        /**数据处理**/
+        for (Map<String, Object> driver:drivers) {
+            RDriverVo driverVo = new RDriverVo();
+            driverVo.setId(driver.get("id") != null ? Long.parseLong(String.valueOf(driver.get("id"))) : null);
+            driverVo.setName(driver.get("name") != null ? String.valueOf(driver.get("name")) : null);
+            driverVo.setPhone(driver.get("phone") != null ? String.valueOf(driver.get("phone")) : null);
+            driverVo.setIdcard(driver.get("idcard") != null ? String.valueOf(driver.get("idcard")) : null);
+            driverVo.setTotalComplete(driver.get("totalComplete") != null ? Integer.parseInt(String.valueOf(driver.get("totalComplete"))) : null);
+            driverVo.setTotalTake(driver.get("totalTake") != null ? Integer.parseInt(String.valueOf(driver.get("totalTake"))) : null);
+            driverVo.setTotalWeight(driver.get("totalWeight") != null ? new BigDecimal(Double.parseDouble(String.valueOf(driver.get("totalWeight")))) : null);
+            driverMap.put(driverVo.getId(), driverVo);
+        }
+
+        return driverMap;
+    }
+
+    /**
+     * @param truckNos 车牌号,多个已逗号隔开
+     * @desc 查询车辆信息
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @Override
+    public Map<Long, RTruckVo> findTruck(String truckNos) {
+        /**获取数据**/
+        Map<Long, RTruckVo> truckMap = new HashMap();
+        List<Map<String, Object>> trucks = truckDao.findList(new HashMap(){{put("truckNos", truckNos);}});
+        if (CollectionUtils.isEmpty(trucks)) {
+            return truckMap;
+        }
+
+        /**数据处理**/
+        for (Map<String, Object> truck:trucks) {
+            RTruckVo truckVo = new RTruckVo();
+            truckVo.setId(truck.get("id") != null ? Long.parseLong(String.valueOf(truck.get("id"))) : null);
+            truckVo.setTruckNo(truck.get("truckNo") != null ? String.valueOf(truck.get("truckNo")) : null);
+            truckVo.setActualWeight(truck.get("actualWeight") != null ? Double.parseDouble(String.valueOf(truck.get("actualWeight"))) : null);
+            truckVo.setTrailerNo(truck.get("trailerNo") != null ? String.valueOf(truck.get("trailerNo")) : null);
+            truckVo.setTotalComplete(truck.get("totalComplete") != null ? Integer.parseInt(String.valueOf(truck.get("totalComplete"))) : null);
+            truckVo.setTotalTake(truck.get("totalTake") != null ? Integer.parseInt(String.valueOf(truck.get("totalTake"))) : null);
+            truckVo.setTotalWeight(truck.get("totalWeight") != null ? new BigDecimal(Double.parseDouble(String.valueOf(truck.get("totalWeight")))) : null);
+            truckVo.setBusinessStatus(truck.get("businessStatus") != null ? Integer.parseInt(String.valueOf(truck.get("businessStatus"))) : null);
+            truckMap.put(truckVo.getId(), truckVo);
+        }
+
+        return truckMap;
+    }
+}

+ 4 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfDriverService.java

@@ -441,7 +441,10 @@ public class KwfDriverService {
         KwfDriverEnt driverEnt = new KwfDriverEnt();
         driverEnt.setDriverId(params.getId());
         driverEnt.setEntId(params.getEntId());
-        driverEntDao.insert(driverEnt);
+        KwfDriverEnt ent = driverEntDao.findByDriverEnt(driverEnt);
+        if (ent == null) {
+            driverEntDao.insert(driverEnt);
+        }
     }
 
     /**

+ 4 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -399,7 +399,10 @@ public class KwfTruckService {
         KwfTruckEnt truckEnt = new KwfTruckEnt();
         truckEnt.setTruckId(params.getId());
         truckEnt.setEntId(params.getEntId());
-        truckEntDao.insert(truckEnt);
+        KwfTruckEnt ent = truckEntDao.findByTruckEnt(truckEnt);
+        if (ent == null) {
+            truckEntDao.insert(truckEnt);
+        }
     }
 
     /**

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

@@ -54,7 +54,7 @@
         SELECT
         dr.id, dr.name, dr.phone, dr.idcard, dr.status, drc.expire_time idcardExpireTime, drc.address, drl.driver_no driverNo,
         drl.type licenseType, drl.expire_time licenseExpireTime, drl.grant_unit licenseGrantUnit,
-        drq.quali_no qualiNo, dre.ent_id entId, dr.create_by createBy, dr.create_time crateTime,
+        drq.quali_no qualiNo, dr.ent_id entId, dr.create_by createBy, dr.create_time crateTime,
         dr.update_time updateTime, dr.remark, trr.truck_no truckNo, fl.name fleetName
         from kwf_driver dr
         left join kwf_driver_ent dre on dre.driver_id = dr.id
@@ -111,6 +111,9 @@
         from kwf_driver dr
         left join kwf_driver_ent dre on dre.driver_id = dr.id
         where dr.del_flag = 0 and dre.del_flag = 0
+        <if test="ids != null and ids != ''">
+            and FIND_IN_SET(dr.id, #{ids, jdbcType=VARCHAR})
+        </if>
         <if test="entId != null and entId != ''">
             and dre.ent_id = #{entId, jdbcType=VARCHAR}
         </if>
@@ -146,4 +149,5 @@
         and dre.ent_id = #{entId, jdbcType=VARCHAR}
         and dr.id = #{id, jdbcType=VARCHAR}
     </select>
+
 </mapper>

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

@@ -115,6 +115,9 @@
         from kwf_truck tr
         left join kwf_truck_ent tre on tre.truck_id = tr.id
         where tr.del_flag = 0 and tre.del_flag = 0
+        <if test="truckNos != null and truckNos != ''">
+            and FIND_IN_SET(tr.truck_no, #{truckNos, jdbcType=VARCHAR})
+        </if>
         <if test="entId != null and entId != ''">
             and tre.ent_id = #{entId, jdbcType=VARCHAR}
         </if>
@@ -161,6 +164,4 @@
         and tr.id = #{id, jdbcType=VARCHAR}
     </select>
 
-
-
 </mapper>