17358629955 2 лет назад
Родитель
Сommit
5d154c2750

+ 24 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckReportMapper.java

@@ -2,7 +2,11 @@ package com.sckw.fleet.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.fleet.model.KwfTruckReport;
+import com.sckw.fleet.model.vo.KwfTableTopCount;
+import com.sckw.fleet.model.vo.KwfTruckReportVo;
 import org.apache.ibatis.annotations.Mapper;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @desc 车辆上报 Mapper 接口
@@ -12,4 +16,24 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface KwfTruckReportMapper extends BaseMapper<KwfTruckReport> {
 
+    /**
+     * 统计
+     * @param params
+     * @return
+     */
+    List<KwfTableTopCount> statistics(Map<String, Object> params);
+
+    /**
+     * 分页查询
+     * @param params
+     * @return
+     */
+    List<KwfTruckReportVo> findPage(Map<String, Object> params);
+
+    /**
+     * 查询
+     * @param params
+     * @return
+     */
+    List<Map<String, Object>> findList(Map<String, Object> params);
 }

+ 1 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfTruckReport.java

@@ -23,7 +23,7 @@ public class KwfTruckReport extends BaseModel {
     /**
      * 车牌号
      */
-    private String truckNo;
+    private Long truckId;
 
     /**
      * 司机id

+ 1 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfDriverDto.java

@@ -18,7 +18,7 @@ public class KwfDriverDto {
     private String id;
 
     /**
-     * 车队名称
+     * 司机名称
      */
     @NotBlank(message = "司机姓名不能为空!")
     @Size(max=10, message = "司机姓名长度不能大于10个字符!")

+ 43 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfTruckReportDto.java

@@ -0,0 +1,43 @@
+package com.sckw.fleet.model.dto;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Pattern;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+/**
+ * @author zk
+ * @desc 车辆上报信息
+ * @date 2023/7/15 0012
+ */
+@Data
+public class KwfTruckReportDto {
+
+    /**
+     * 车牌号
+     */
+    @NotBlank(message = "车牌号不能为空!")
+    @Size(max=7, message = "车牌号长度不能大于7个字符!")
+    private String truckNo;
+
+    /**
+     * 司机名称
+     */
+    @NotBlank(message = "司机姓名不能为空!")
+    @Size(max=10, message = "司机姓名长度不能大于10个字符!")
+    private String driverName;
+
+    /**
+     * 司机电话
+     */
+    @NotBlank(message = "司机电话号码不能为空!")
+    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "电话号码格式不正确!")
+    private String driverPhone;
+
+    /**
+     * 司机身份证
+     */
+    @NotBlank(message = "司机身份证号不能为空!")
+    @Pattern(regexp = "(^\\d{18}$)|(^\\d{15}$)", message = "身份证号码格式不正确!")
+    private String driverIdcard;
+}

+ 150 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckReportVo.java

@@ -0,0 +1,150 @@
+package com.sckw.fleet.model.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Data;
+import java.util.Date;
+
+/**
+ * @desc 车辆上报
+ * @author zk
+ * @date 2023/7/15
+ */
+@Data
+@ExcelContext(fileName = "车辆上报信息", sheetName = "车辆上报信息")
+public class KwfTruckReportVo {
+
+    /**
+     * 车辆主键id
+     */
+    @ExcelIgnore
+    private Long id;
+
+    /**
+     * 车辆主键id
+     */
+    @ExcelIgnore
+    private Long truckId;
+
+    /**
+     * 车牌号
+     */
+    @ExcelProperty(value = "车牌号")
+    private String truckNo;
+
+    /**
+     * 司机主键id
+     */
+    @ExcelIgnore
+    private Long driverId;
+
+    /**
+     * 司机姓名
+     */
+    @ExcelProperty(value = "司机姓名")
+    private String driverName;
+
+    /**
+     * 司机电话
+     */
+    @ExcelProperty(value = "司机电话")
+    private String driverPhone;
+
+    /**
+     * 司机身份证
+     */
+    @ExcelProperty(value = "司机身份证")
+    private String driverIdcard;
+
+    /**
+     * 司机归档企业主键id
+     */
+    @ExcelIgnore
+    private String driverEntId;
+
+    /**
+     * 司机归档企业
+     */
+    @ExcelProperty(value = "司机归档企业")
+    private String driverFirmName;
+
+    /**
+     * 车辆归档企业主键id
+     */
+    @ExcelIgnore
+    private String truckEntId;
+
+    /**
+     * 车辆归档企业
+     */
+    @ExcelProperty(value = "车辆归档企业")
+    private String truckFirmName;
+
+    /**
+     * 车队班组主键id
+     */
+    @ExcelIgnore
+    private String truckFleetId;
+
+    /**
+     * 车队班组
+     */
+    @ExcelProperty(value = "车队班组")
+    private String truckFleetName;
+
+    /**
+     * 车辆类型
+     */
+    @ExcelProperty(value = "车辆类型")
+    private String truckTypeName;
+
+    /**
+     * 核载质量/吨
+     */
+    @ExcelProperty(value = "核载质量/吨")
+    private double actualWeight;
+
+    /**
+     * 车牌颜色
+     */
+    @ExcelProperty(value = "车牌颜色")
+    private String color;
+
+    /**
+     * 挂车号
+     */
+    @ExcelProperty(value = "挂车号")
+    private String trailerNo;
+
+    /**
+     * 上报人
+     */
+    @ExcelIgnore
+    private String createBy;
+
+    /**
+     * 上报人
+     */
+    @ExcelProperty(value = "上报人")
+    private String createByName;
+
+    /**
+     * 上报时间
+     */
+    @ExcelProperty(value = "上报时间")
+    private Date crateTime;
+
+    /**
+     * 更新时间
+     */
+    @ExcelProperty(value = "更新时间")
+    private Date updateTime;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+}

+ 258 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckReportService.java

@@ -0,0 +1,258 @@
+package com.sckw.fleet.service;
+
+import com.sckw.core.exception.SystemException;
+import com.sckw.core.model.auth.context.LoginUserHolder;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.constant.HttpStatus;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.fleet.dao.KwfDriverMapper;
+import com.sckw.fleet.dao.KwfTruckMapper;
+import com.sckw.fleet.dao.KwfTruckReportMapper;
+import com.sckw.fleet.model.KwfDriver;
+import com.sckw.fleet.model.KwfTruck;
+import com.sckw.fleet.model.KwfTruckEnt;
+import com.sckw.fleet.model.KwfTruckReport;
+import com.sckw.fleet.model.dto.*;
+import com.sckw.fleet.model.vo.KwfTableTopCount;
+import com.sckw.fleet.model.vo.KwfTruckReportVo;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author zk
+ * @desc 车辆上报
+ * @date 2023/7/15 0006
+ */
+@Service
+public class KwfTruckReportService {
+
+    @Autowired
+    KwfTruckMapper truckDao;
+    @Autowired
+    KwfDriverMapper driverDao;
+    @Autowired
+    KwfTruckReportMapper truckReportDao;
+    @Autowired
+    KwfDriverService driverService;
+    @Autowired
+    KwfTruckService truckService;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+
+    /**
+     * @param key 主键id
+     * @desc 根据主键查询
+     * @author zk
+     * @date 2023/7/15
+     **/
+    public KwfTruckReport selectByKey(Long key) {
+        return null;
+    }
+
+    /**
+     * @param params 参数
+     * @desc 统计
+     * @author zk
+     * @date 2023/7/11
+     **/
+    public Map statistics(Map<String, Object> params) {
+        /**统计数据**/
+        List<KwfTableTopCount> counts = truckReportDao.statistics(params);
+        long tatol = 0;
+        for (KwfTableTopCount topCount:counts) {
+            tatol += topCount.getTotal();
+        }
+
+        /**全部数据-处理**/
+        KwfTableTopCount allCount = new KwfTableTopCount();
+        allCount.setValue(String.valueOf(Global.NUMERICAL_ZERO));
+        allCount.setTotal(tatol);
+        counts.add(allCount);
+
+        /**数据组装**/
+        Map tableCount = new HashMap();
+        tableCount.put("tableTop", counts);
+        tableCount.put("tableBottom", tatol);
+        return tableCount;
+    }
+
+    /**
+     * @param params 分页参数
+     * @desc 分页查询
+     * @author zk
+     * @date 2023/7/15
+     **/
+    public List<KwfTruckReportVo> findPage(Map<String, Object> params) {
+        /**查询分页数据**/
+        List<KwfTruckReportVo> trucks = truckReportDao.findPage(params);
+        if (CollectionUtils.isEmpty(trucks)) {
+            return trucks;
+        }
+
+        /**获取查询数据**/
+        List<Long> createBys = new ArrayList<>();
+        List<Long> entIds = new ArrayList<>();
+        for (KwfTruckReportVo truck:trucks) {
+            createBys.add(Long.parseLong(truck.getCreateBy()));
+            entIds.add(Long.parseLong(truck.getDriverEntId()));
+            entIds.add(Long.parseLong(truck.getTruckEntId()));
+        }
+        //用户数据集
+        createBys = createBys.stream().distinct().collect(Collectors.toList());
+        Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(createBys);
+        //企业数据集
+        entIds = entIds.stream().distinct().collect(Collectors.toList());
+        Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
+
+        /**数据组装**/
+        for (KwfTruckReportVo truck:trucks) {
+            UserCacheResDto user = users == null ? null : users.get(Long.parseLong(truck.getCreateBy()));
+            EntCacheResDto ent = ents == null ? null : ents.get(Long.parseLong(truck.getDriverEntId()));
+            truck.setCreateByName(user != null ? user.getName() : null);
+            truck.setDriverFirmName(ent != null ? ent.getFirmName() : null);
+            ent = ents == null ? null : ents.get(Long.parseLong(truck.getTruckEntId()));
+            truck.setTruckFirmName(ent != null ? ent.getFirmName() : null);
+        }
+        return trucks;
+    }
+
+    /**
+     * @param {}
+     * @description 导出
+     * @author zk
+     * @date 2023/07/11
+     **/
+    public HttpResult importExcel(MultipartFile file) {
+        return null;
+    }
+
+    /**
+     * @param params 参数
+     * @desc 新增车辆上报
+     * @author zk
+     * @date 2023/7/15
+     **/
+    public HttpResult add(KwfTruckReportDto params) {
+        KwfTruckReport truckReport = new KwfTruckReport();
+        truckReport.setEntId(LoginUserHolder.getEntId());
+
+        /**车辆信息**/
+        //校验车辆档案是否存在
+        List<Map<String, Object>> trucks = truckDao.findList(new HashMap() {{
+            put("truckNo", params.getTruckNo());
+        }});
+        if (CollectionUtils.isEmpty(trucks)) {
+            //新增车辆档案
+            KwfTruckDto truckDto = new KwfTruckDto();
+            truckDto.setTruckNo(params.getTruckNo());
+            HttpResult result = truckService.add(truckDto);
+            if (result.getCode() != HttpStatus.SUCCESS_CODE) {
+                return result;
+            }
+        } else {
+            //校验车辆是否已上报
+            Map<String, Object> truck = trucks.get(0);
+            Object truckId = truck.get("id");
+            List<Map<String, Object>> reports = truckReportDao.findList(new HashMap() {{
+                put("truckId", truckId);
+                put("entId", LoginUserHolder.getEntId());
+            }});
+            if (CollectionUtils.isEmpty(trucks)) {
+                //新增
+                truckReport.setTruckId(Long.parseLong(String.valueOf(truckId)));
+            } else {
+
+            }
+        }
+
+        /**档案信息**/
+        //校验司机档案是否存在
+        List<Map<String, Object>> drivers = driverDao.findList(new HashMap() {{
+            put("phone", params.getDriverPhone());
+        }});
+        if (CollectionUtils.isEmpty(drivers)) {
+            //新增司机档案
+            KwfDriverDto driverDto = new KwfDriverDto();
+            driverDto.setName(params.getDriverName());
+            driverDto.setPhone(params.getDriverPhone());
+            driverDto.setIdcard(params.getDriverIdcard());
+            HttpResult result = driverService.add(driverDto);
+            if (result.getCode() != HttpStatus.SUCCESS_CODE) {
+                return result;
+            }
+        } else {
+            //校验司机是否已上报
+            Map<String, Object> driver = trucks.get(0);
+            Object driverId = driver.get("id");
+            List<Map<String, Object>> reports = truckReportDao.findList(new HashMap() {{
+                put("driverId", driverId);
+                put("entId", LoginUserHolder.getEntId());
+            }});
+            if (CollectionUtils.isEmpty(trucks)) {
+                if (true) {
+                    truckReport.setDriverId(Long.parseLong(String.valueOf(driverId)));
+                } else {
+
+                }
+            }
+        }
+
+        truckReportDao.insert(truckReport);
+        return HttpResult.ok("车辆上报成功!");
+    }
+
+    /**
+     * @param params 参数
+     * @desc 车辆上报修改
+     * @author zk
+     * @date 2023/7/15
+     **/
+    public HttpResult update(KwfTruckReportDto params) {
+        /**数据校验**/
+
+
+        /**车辆信息**/
+
+
+        return HttpResult.ok("车辆信息修改成功!");
+    }
+
+    /**
+     * @param {ids:主键ID(多个以逗号隔开)}
+     * @description 删除
+     * @author zk
+     * @date 2023/7/15
+     **/
+    public HttpResult del(String ids) {
+        /**数据校验**/
+        if (StringUtils.isBlank(ids)) {
+            return HttpResult.error("请选择要删除的数据!");
+        }
+
+        /**数据组装**/
+        String[] idArray = ids.split(",");
+        for (String id : idArray) {
+            KwfTruckReport truckReport = truckReportDao.selectById(id);
+            if (truckReport != null) {
+                truckReport.setDelFlag(Global.YES);
+                if (truckReportDao.updateById(truckReport) <= 0) {
+                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
+                }
+            }
+        }
+        return HttpResult.ok("删除成功!");
+    }
+}

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

@@ -49,7 +49,7 @@ public class KwfTruckService {
     private RemoteSystemService remoteSystemService;
 
     /**
-     * @param key 逐渐id
+     * @param key 主键id
      * @desc 根据主键查询
      * @author zk
      * @date 2023/7/6
@@ -265,8 +265,8 @@ public class KwfTruckService {
     public HttpResult truckEdit(KwfTruck params) {
         if (StringUtils.isBlank(params.getId())) {
             /**唯一性交易**/
-            List<Map<String, Object>> drivers = truckDao.findList(new HashMap(){{ put("truckNo", params.getTruckNo()); }});
-            if (!CollectionUtils.isEmpty(drivers)) {
+            List<Map<String, Object>> trucks = truckDao.findList(new HashMap(){{ put("truckNo", params.getTruckNo()); }});
+            if (!CollectionUtils.isEmpty(trucks)) {
                 return HttpResult.error("车牌号已存在!");
             }
 
@@ -277,9 +277,9 @@ public class KwfTruckService {
             return count > 0 ? HttpResult.ok() : HttpResult.error("车辆信息新增失败!");
         } else {
             /**唯一性交易**/
-            List<Map<String, Object>> drivers = truckDao.findList(new HashMap(){{ put("truckNo", params.getTruckNo()); }});
+            List<Map<String, Object>> trucks = truckDao.findList(new HashMap(){{ put("truckNo", params.getTruckNo()); }});
             //校验list中对象key值是否存在与value不一致的情况
-            boolean bool = CollectionUtils.listByKeyValueV1(drivers, "id", String.valueOf(params.getId()));
+            boolean bool = CollectionUtils.listByKeyValueV1(trucks, "id", String.valueOf(params.getId()));
             if (bool) {
                 return HttpResult.error("车辆信息已存在!");
             }