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

1、车辆上报相关接口;

zk 2 лет назад
Родитель
Сommit
8e8fbd07a0
18 измененных файлов с 749 добавлено и 74 удалено
  1. 4 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/constant/Global.java
  2. 9 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/RegularUtils.java
  3. 41 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java
  4. 37 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java
  5. 154 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckReportController.java
  6. 25 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfChangeFleetDto.java
  7. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfDriverCardDto.java
  8. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfDriverDto.java
  9. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfDriverExport.java
  10. 12 4
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfTruckReportDto.java
  11. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfDriverVo.java
  12. 14 2
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckReportVo.java
  13. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckVo.java
  14. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfDriverService.java
  15. 314 59
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckReportService.java
  16. 1 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java
  17. 6 1
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml
  18. 126 0
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckReportMapper.xml

+ 4 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/constant/Global.java

@@ -118,9 +118,12 @@ public class Global {
     /**系统初始密码*/
     public static final String PASSWORD = "123456";
 
-    /**逗号*/
+    /**逗号-英文*/
     public static final String COMMA = ",";
 
+    /**逗号-中文*/
+    public static final String COMMA1 = ",";
+
     /**点*/
     public static final String DOT = ".";
 

+ 9 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/RegularUtils.java

@@ -43,6 +43,11 @@ public class RegularUtils {
      */
     public static final String DOLLAR_BIG_BRACKETS = "(\\$\\{)([\\w]+)(\\})";
 
+    /**
+     * 身份证
+     */
+    public static final String IDCARD = "(^\\d{18}$)|(^\\d{15}$)";
+
     /**
      * @description 校验
      * @author zk
@@ -56,4 +61,8 @@ public class RegularUtils {
         boolean isMatch = m.matches();
         return isMatch;
     }
+
+    public static void main(String[] args) {
+        System.out.println(matchs(DECIMAL_REG, "111.00"));
+    }
 }

+ 41 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
+import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.easyexcel.RequestHolder;
 import com.sckw.excel.utils.ExcelUtil;
@@ -67,6 +68,46 @@ public class KwfDriverController {
         return HttpResult.ok(driverJson);
     }
 
+    /**
+     * @param phone 司机手机号
+     * @desc 根据司机手机号查询
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @GetMapping("/findByPhone")
+    public HttpResult findByPhone(String phone) throws SystemException {
+        Long id = null;
+        List<Map<String, Object>> drivers = driverService.findList(new HashMap(){{ put("phone", phone); }});
+        if (com.sckw.core.utils.CollectionUtils.isEmpty(drivers)) {
+            return HttpResult.ok();
+        } else {
+            Map<String, Object> driver = drivers.get(0);
+            if (StringUtils.isBlank(driver.get("id"))){
+                return HttpResult.ok();
+            }
+            id = Long.parseLong(String.valueOf(driver.get("id")));
+        }
+
+        //司机信息
+        KwfDriver driver = driverService.selectByKey(id);
+
+        //身份证信息
+        KwfDriverCard cardJson = driverService.findCarByKey(driver.getId());
+
+        //司机驾驶证信息
+        KwfDriverLicense licenseJson = driverService.findLicenseByKey(driver.getId());
+
+        //司机从业资格证
+        KwfDriverQualification qualificationJson = driverService.findQualificationByKey(driver.getId());
+
+        //数据组装
+        JSONObject driverJson = JSONObject.parseObject(JSON.toJSONString(driver));
+        driverJson.put("driverCard", cardJson);
+        driverJson.put("driverLicense", licenseJson);
+        driverJson.put("driverQualification", qualificationJson);
+        return HttpResult.ok(driverJson);
+    }
+
     /**
      * @param params
      * @desc 统计

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

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
+import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.easyexcel.RequestHolder;
 import com.sckw.excel.utils.ExcelUtil;
@@ -61,6 +62,42 @@ public class KwfTruckController {
         return HttpResult.ok(truckJson);
     }
 
+    /**
+     * @param truckNo 车牌号
+     * @desc 根据车牌号查询
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @GetMapping("/findByTruckNo")
+    public HttpResult selectByKey(String truckNo) throws SystemException {
+        Long id = null;
+        List<Map<String, Object>> trucks = truckService.findList(new HashMap(){{ put("truckNo", truckNo); }});
+        if (com.sckw.core.utils.CollectionUtils.isEmpty(trucks)) {
+            return HttpResult.ok();
+        } else {
+            Map<String, Object> truck = trucks.get(0);
+            if (StringUtils.isBlank(truck.get("id"))){
+                return HttpResult.ok();
+            }
+            id = Long.parseLong(String.valueOf(truck.get("id")));
+        }
+
+        //车辆信息
+        KwfTruck truck = truckService.selectByKey(id);
+
+        //车辆行驶证信息
+        KwfTruckLicense truckLicense = truckService.findTruckLicenseByKey(id);
+
+        //车辆道路运输许可证
+        KwfTransportLicense transportLicense = truckService.findTransportLicenseByKey(id);
+
+        //数据组装
+        JSONObject truckJson = JSONObject.parseObject(JSON.toJSONString(truck));
+        truckJson.put("truckLicense", truckLicense);
+        truckJson.put("transportLicense", transportLicense);
+        return HttpResult.ok(truckJson);
+    }
+
     /**
      * @param params
      * @desc 统计

+ 154 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckReportController.java

@@ -0,0 +1,154 @@
+package com.sckw.fleet.controller;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.exception.SystemException;
+import com.sckw.core.model.page.PageHelperUtil;
+import com.sckw.core.model.page.PageResult;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.easyexcel.RequestHolder;
+import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.fleet.model.KwfTruckReport;
+import com.sckw.fleet.model.dto.KwfChangeFleetDto;
+import com.sckw.fleet.model.dto.KwfTruckDto;
+import com.sckw.fleet.model.dto.KwfTruckReportDto;
+import com.sckw.fleet.model.vo.KwfTruckReportVo;
+import com.sckw.fleet.service.KwfTruckReportService;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author zk
+ * @desc 车辆上报
+ * @date 2023/7/18 0018
+ */
+@RestController
+@RequestMapping("/kwfReport")
+public class KwfTruckReportController {
+
+    @Autowired
+    KwfTruckReportService reportService;
+
+    /**
+     * @param params
+     * @desc 统计
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @PostMapping("/statistics")
+    public HttpResult statistics(@RequestBody HashMap params) throws SystemException {
+        Map countMaps = reportService.statistics(params);
+        return HttpResult.ok(countMaps);
+    }
+
+    /**
+     * @param params {page:页数、pageSize:每页条数、。。。}
+     * @desc 分页查询
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @PostMapping("/select")
+    public HttpResult findPage(@RequestBody HashMap params) throws SystemException {
+        // 设置分页参数
+        PageHelper.startPage(PageResult.getPage(params), PageResult.getPageSize(params));
+        List<KwfTruckReportVo> list = reportService.findPage(params);
+        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));
+        return HttpResult.ok(pageResult);
+    }
+
+    /**
+     * @param params 查询参数
+     * @description 导出
+     * @author zk
+     * @date 2023/07/18
+     **/
+    @PostMapping("/export")
+    public HttpResult export(@RequestBody HashMap params) {
+        /**查询数据**/
+        List<KwfTruckReportVo> trucks = reportService.findPage(params);
+
+        if (!CollectionUtils.isEmpty(trucks)) {
+            HttpServletResponse response = RequestHolder.getResponse();
+            ExcelUtil.download(response, KwfTruckReportVo.class, trucks);
+            return null;
+        }
+        return HttpResult.error("无数据!");
+    }
+
+    /**
+     * @param file 导入文件
+     * @description 导入
+     * @author zk
+     * @date 2023/07/18
+     **/
+    @PostMapping("/import")
+    public HttpResult importExcel(@RequestParam("file") MultipartFile file) {
+        return null;
+    }
+
+    /**
+     * @param params 新增参数
+     * @return HttpResult
+     * @desc 新增用户
+     * @author czh
+     * @date 2023/7/18
+     */
+    @PostMapping("/add")
+    public HttpResult add(@Valid @RequestBody List<KwfTruckReportDto> params) throws SystemException{
+        return reportService.add(params);
+    }
+
+    /**
+     * @param params {}
+     * @description 更新
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @PostMapping("/update")
+    public HttpResult update(@Valid @RequestBody KwfTruckReport params) throws SystemException {
+        return reportService.update(params);
+    }
+
+    /**
+     * @param {ids:主键ID(多个以逗号隔开)}
+     * @description 删除
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @DeleteMapping("/dels")
+    public HttpResult del(@RequestParam String ids) throws SystemException {
+        return reportService.del(ids);
+    }
+
+    /**
+     * @param params {}
+     * @description 车队变更
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @PostMapping("/changeFleet")
+    public HttpResult changeFleet(@Valid @RequestBody KwfChangeFleetDto params) throws SystemException {
+        return reportService.changeFleet(params);
+    }
+
+    /**
+     * @param params {}
+     * @description 校验识别
+     * @author zk
+     * @date 2023/7/18
+     **/
+    @PostMapping("/identify")
+    public HttpResult checkReports(@Valid @RequestBody List<String> params) throws SystemException {
+        return reportService.checkReports(params);
+    }
+
+
+}

+ 25 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfChangeFleetDto.java

@@ -0,0 +1,25 @@
+package com.sckw.fleet.model.dto;
+
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+/**
+ * @author zk
+ * @desc 车队变更参数
+ * @date 2023/7/18 0018
+ */
+@Data
+public class KwfChangeFleetDto {
+
+    /**
+     * 上报主键
+     */
+    @NotNull(message = "主键不能为空!")
+    private Long id;
+
+    /**
+     * 车队班组主键
+     */
+    @NotNull(message = "车队班组主键不能为空!")
+    private Long fleetId;
+}

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

@@ -27,7 +27,7 @@ public class KwfDriverCardDto {
     /**
      * 身份证号
      */
-    @Pattern(regexp = "(^\\d{18}$)|(^\\d{15}$)", message = "身份证号码格式不正确!")
+    @Pattern(regexp = "[0-9A-Za-z]{18}", message = "身份证号码格式不正确!")
     private String idcard;
 
     /**

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

@@ -34,7 +34,7 @@ public class KwfDriverDto {
     /**
      * 身份证号
      */
-    @Pattern(regexp = "(^\\d{18}$)|(^\\d{15}$)", message = "身份证号码格式不正确!")
+    @Pattern(regexp = "[0-9A-Za-z]{18}", message = "身份证号码格式不正确!")
     private String idcard;
 
     /**

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

@@ -100,7 +100,7 @@ public class KwfDriverExport {
      * 创建时间
      */
     @ExcelProperty(value = "创建时间", index = 14)
-    private String crateTime;
+    private String createTime;
 
     /**
      * 更新时间

+ 12 - 4
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfTruckReportDto.java

@@ -5,6 +5,8 @@ import jakarta.validation.constraints.Pattern;
 import jakarta.validation.constraints.Size;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 /**
  * @author zk
  * @desc 车辆上报信息
@@ -25,19 +27,25 @@ public class KwfTruckReportDto {
      */
     @NotBlank(message = "司机姓名不能为空!")
     @Size(max=10, message = "司机姓名长度不能大于10个字符!")
-    private String driverName;
+    private String name;
 
     /**
      * 司机电话
      */
     @NotBlank(message = "司机电话号码不能为空!")
     @Pattern(regexp = "^1[3456789]\\d{9}$", message = "电话号码格式不正确!")
-    private String driverPhone;
+    private String phone;
 
     /**
      * 司机身份证
      */
     @NotBlank(message = "司机身份证号不能为空!")
-    @Pattern(regexp = "(^\\d{18}$)|(^\\d{15}$)", message = "身份证号码格式不正确!")
-    private String driverIdcard;
+    @Pattern(regexp = "[0-9A-Za-z]{18}", message = "身份证号码格式不正确!")
+    private String idcard;
+
+    /**
+     * 标准荷载(净重)
+     */
+    @NotBlank(message = "标准荷载不能为空!")
+    private BigDecimal actualWeight;
 }

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

@@ -126,7 +126,7 @@ public class KwfDriverVo {
      * 创建时间
      */
     @ExcelProperty(value = "创建时间", index = 15)
-    private String crateTime;
+    private String createTime;
 
     /**
      * 更新时间

+ 14 - 2
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckReportVo.java

@@ -93,6 +93,12 @@ public class KwfTruckReportVo {
     @ExcelProperty(value = "车队班组")
     private String truckFleetName;
 
+    /**
+     * 车辆类型
+     */
+    @ExcelIgnore
+    private String truckType;
+
     /**
      * 车辆类型
      */
@@ -108,9 +114,15 @@ public class KwfTruckReportVo {
     /**
      * 车牌颜色
      */
-    @ExcelProperty(value = "车牌颜色")
+    @ExcelIgnore
     private String color;
 
+    /**
+     * 车牌颜色
+     */
+    @ExcelProperty(value = "车牌颜色")
+    private String colorName;
+
     /**
      * 挂车号
      */
@@ -133,7 +145,7 @@ public class KwfTruckReportVo {
      * 上报时间
      */
     @ExcelProperty(value = "上报时间")
-    private Date crateTime;
+    private Date createTime;
 
     /**
      * 更新时间

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

@@ -199,7 +199,7 @@ public class KwfTruckVo {
      * 创建时间
      */
     @ExcelProperty(value = "创建时间")
-    private Date crateTime;
+    private Date createTime;
 
     /**
      * 备注

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

@@ -197,7 +197,7 @@ public class KwfDriverService {
         /**车队班组绑定**/
         driverFleetEdit(driver.getId(), params.getFleetId());
 
-        return HttpResult.ok("司机信息新增成功!");
+        return HttpResult.ok("司机信息新增成功!", driver);
     }
 
     /**

+ 314 - 59
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckReportService.java

@@ -1,26 +1,32 @@
 package com.sckw.fleet.service;
 
+import com.sckw.core.common.enums.enums.DictTypeEnum;
 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.CollectionUtils;
+import com.sckw.core.utils.RegularUtils;
 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.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.SysDictResDto;
 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.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -99,12 +105,16 @@ public class KwfTruckReportService {
         }
 
         /**获取查询数据**/
+        String prefix = Global.REDIS_SYS_DICT_PREFIX, pound = Global.POUND;
         List<Long> createBys = new ArrayList<>();
         List<Long> entIds = new ArrayList<>();
+        List<String> dictKey = new ArrayList<>();
         for (KwfTruckReportVo truck:trucks) {
             createBys.add(Long.parseLong(truck.getCreateBy()));
             entIds.add(Long.parseLong(truck.getDriverEntId()));
             entIds.add(Long.parseLong(truck.getTruckEntId()));
+            dictKey.add(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getColor());
+            dictKey.add(prefix + DictTypeEnum.TRUCK_TYPE.getType() + pound + truck.getTruckType());
         }
         //用户数据集
         createBys = createBys.stream().distinct().collect(Collectors.toList());
@@ -112,15 +122,22 @@ public class KwfTruckReportService {
         //企业数据集
         entIds = entIds.stream().distinct().collect(Collectors.toList());
         Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
+        //数据字典
+        dictKey = dictKey.stream().distinct().collect(Collectors.toList());
+        Map<Long, SysDictResDto> dicts = null;//remoteSystemService.queryDictByType(dictKey);
 
         /**数据组装**/
         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()));
+            SysDictResDto color = dicts == null ? null : dicts.get(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getColor());
+            SysDictResDto type = dicts == null ? null : dicts.get(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getTruckType());
             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);
+            truck.setColorName(color != null ? color.getLabel() : null);
+            truck.setTruckTypeName(type != null ? type.getLabel() : null);
         }
         return trucks;
     }
@@ -141,73 +158,91 @@ public class KwfTruckReportService {
      * @author zk
      * @date 2023/7/15
      **/
-    public HttpResult add(KwfTruckReportDto params) {
-        KwfTruckReport truckReport = new KwfTruckReport();
-        truckReport.setEntId(LoginUserHolder.getEntId());
+    public HttpResult add(List<KwfTruckReportDto> params) {
+        /**数据校验**/
+        if (CollectionUtils.isEmpty(params)) {
+            return HttpResult.error("请选择需要上报的数据!");
+        }
 
-        /**车辆信息**/
-        //校验车辆档案是否存在
-        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;
+        for (KwfTruckReportDto reportDto:params){
+            boolean bool = checkReport(reportDto);
+            if (!bool) {
+                return HttpResult.error("上报数据已存在,请重新识别!");
             }
-        } 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());
+        }
+
+        /**数据更新**/
+        int count = 0;
+        for (KwfTruckReportDto reportDto:params){
+            KwfTruckReport truckReport = new KwfTruckReport();
+            truckReport.setEntId(LoginUserHolder.getEntId());
+
+            /**车辆信息**/
+            //校验车辆档案是否存在
+            List<Map<String, Object>> trucks = truckDao.findList(new HashMap() {{
+                put("truckNo", reportDto.getTruckNo());
             }});
             if (CollectionUtils.isEmpty(trucks)) {
-                //新增
-                truckReport.setTruckId(Long.parseLong(String.valueOf(truckId)));
+                //新增车辆档案
+                KwfTruckDto truckDto = new KwfTruckDto();
+                truckDto.setTruckNo(reportDto.getTruckNo());
+                HttpResult result = truckService.add(truckDto);
+                if (result.getCode() != HttpStatus.SUCCESS_CODE) {
+                    return result;
+                }
+                KwfTruck truck = (KwfTruck) result.getData();
+                truckReport.setTruckId(truck.getId());
             } 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(reports)) {
+                    truckReport.setTruckId(Long.parseLong(String.valueOf(truckId)));
+                } else {
+                    continue;
+                }
             }
-        }
 
-        /**档案信息**/
-        //校验司机档案是否存在
-        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());
+            /**档案信息**/
+            //校验司机档案是否存在
+            List<Map<String, Object>> drivers = driverDao.findList(new HashMap() {{
+                put("phone", reportDto.getPhone());
             }});
-            if (CollectionUtils.isEmpty(trucks)) {
-                if (true) {
+            if (CollectionUtils.isEmpty(drivers)) {
+                //新增司机档案
+                KwfDriverDto driverDto = new KwfDriverDto();
+                driverDto.setName(reportDto.getName());
+                driverDto.setPhone(reportDto.getPhone());
+                driverDto.setIdcard(reportDto.getIdcard());
+                HttpResult result = driverService.add(driverDto);
+                if (result.getCode() != HttpStatus.SUCCESS_CODE) {
+                    return result;
+                }
+                KwfDriver driver = (KwfDriver) result.getData();
+                truckReport.setDriverId(driver.getId());
+            } 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(reports)) {
                     truckReport.setDriverId(Long.parseLong(String.valueOf(driverId)));
                 } else {
-
+                    continue;
                 }
             }
+
+            count += truckReportDao.insert(truckReport);
         }
 
-        truckReportDao.insert(truckReport);
-        return HttpResult.ok("车辆上报成功!");
+        return HttpResult.ok("车辆上报成功"+count+"条!");
     }
 
     /**
@@ -216,19 +251,37 @@ public class KwfTruckReportService {
      * @author zk
      * @date 2023/7/15
      **/
-    public HttpResult update(KwfTruckReportDto params) {
+    public HttpResult update(KwfTruckReport params) {
         /**数据校验**/
+        if (StringUtils.isBlank(params.getId())) {
+            return HttpResult.error("参数不正确!");
+        }
+        KwfTruckReport truckReport = truckReportDao.selectById(params.getId());
+        if (truckReport == null) {
+            return HttpResult.error("信息已不存在!");
+        }
 
+        /**更新**/
+        List<Map<String, Object>> reports = truckReportDao.findList(new HashMap() {{
+            put("driverId", params.getDriverId());
+            put("entId", LoginUserHolder.getEntId());
+        }});
+        if (!CollectionUtils.isEmpty(reports)) {
+            Map<String, Object> report = reports.get(0);
+            Long id = StringUtils.isBlank(report.get("id")) ? 0 : Long.parseLong(String.valueOf(report.get("id")));
+            if (!id.equals(params.getId())) {
+                return HttpResult.error("司机已关联车辆!");
+            }
+        }
 
-        /**车辆信息**/
-
-
-        return HttpResult.ok("车辆信息修改成功!");
+        /**更新数据**/
+        int count = truckReportDao.updateById(params);
+        return count > 0 ? HttpResult.ok("修改成功!") : HttpResult.error("修改失败!");
     }
 
     /**
      * @param {ids:主键ID(多个以逗号隔开)}
-     * @description 删除
+     * @desc 删除
      * @author zk
      * @date 2023/7/15
      **/
@@ -251,4 +304,206 @@ public class KwfTruckReportService {
         }
         return HttpResult.ok("删除成功!");
     }
+
+    /**
+     * @param params
+     * @desc 变更车队
+     * @author zk
+     * @date 2023/7/18
+     **/
+    public HttpResult changeFleet(KwfChangeFleetDto params) {
+        KwfTruckReport truckReport = truckReportDao.selectById(params.getId());
+        if (truckReport == null) {
+            return HttpResult.error("信息已不存在!");
+        }
+
+        //更新司机所属车队班组
+        HttpResult result = driverService.driverFleetEdit(truckReport.getDriverId(), params.getFleetId());
+        if (result.getCode() == HttpStatus.SUCCESS_CODE) {
+            //更新车辆所属车队班组
+            result = truckService.truckFleetEdit(truckReport.getTruckId(), params.getFleetId());
+        }
+
+        return result;
+    }
+
+    /**
+     * @param params 上报信息
+     * @desc 校验上报
+     * @author zk
+     * @date 2023/7/18
+     **/
+    public HttpResult checkReports(List<String> params) {
+        /**数据校验**/
+        if (CollectionUtils.isEmpty(params)) {
+            return HttpResult.error("请选择需要上报的数据!");
+        }
+
+        //有效上报信息
+        List<KwfTruckReportDto> effective = new ArrayList();
+        //已有运力/识别失败
+        int haveCount = 0, errorCount = 0;
+        for (String str:params){
+            /**识别上报数据**/
+            KwfTruckReportDto reportDto = analysis(str);
+            if (reportDto == null) {
+                errorCount ++;
+                continue;
+            }
+
+            /**车辆信息**/
+            //校验车辆档案是否存在
+            List<Map<String, Object>> trucks = truckDao.findList(new HashMap() {{
+                put("truckNo", reportDto.getTruckNo());
+            }});
+            if (!CollectionUtils.isEmpty(trucks)) {
+                //校验车辆是否已上报
+                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(reports)) {
+                    haveCount ++;
+                    continue;
+                }
+            }
+
+            /**档案信息**/
+            //校验司机档案是否存在
+            List<Map<String, Object>> drivers = driverDao.findList(new HashMap() {{
+                put("phone", reportDto.getPhone());
+            }});
+            if (!CollectionUtils.isEmpty(drivers)) {
+                //校验司机是否已上报
+                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(reports)) {
+                    haveCount ++;
+                    continue;
+                }
+            }
+
+            effective.add(reportDto);
+        }
+
+        /**返回数据**/
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("haveCount", haveCount);
+        resultMap.put("errorCount", errorCount);
+        resultMap.put("fail", haveCount + errorCount);
+        resultMap.put("success", effective.size());
+        resultMap.put("list", effective);
+
+        return HttpResult.ok(resultMap);
+    }
+
+    /**
+     * @param reportDto 上报信息
+     * @desc 校验司机和车辆是否已上报
+     * @author zk
+     * @date 2023/7/18
+     **/
+    public boolean checkReport(KwfTruckReportDto reportDto) {
+        /**车辆信息**/
+        //校验车辆档案是否存在
+        List<Map<String, Object>> trucks = truckDao.findList(new HashMap() {{
+            put("truckNo", reportDto.getTruckNo());
+        }});
+        if (!CollectionUtils.isEmpty(trucks)) {
+            //校验车辆是否已上报
+            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(reports)) {
+                return false;
+            }
+        }
+
+        /**档案信息**/
+        //校验司机档案是否存在
+        List<Map<String, Object>> drivers = driverDao.findList(new HashMap() {{
+            put("phone", reportDto.getPhone());
+        }});
+        if (!CollectionUtils.isEmpty(drivers)) {
+            //校验司机是否已上报
+            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(reports)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * @param str 上报字符串
+     * @desc 上报数据识别
+     * @author zk
+     * @date 2023/7/18
+     **/
+    public KwfTruckReportDto analysis(String str) {
+        /**识别上报数据**/
+        KwfTruckReportDto reportDto = new KwfTruckReportDto();
+        //非控校验
+        if (StringUtils.isBlank(str) || StringUtils.isBlank(str.trim())) {
+            return null;
+        }
+        //字符截取-英文逗号/中文逗号
+        String[] strArray = str.split(Global.COMMA1);
+        strArray = (strArray == null || strArray.length == 0) ? str.split(Global.COMMA) : strArray;
+        if (strArray == null || strArray.length == 0 || strArray.length != 5 ) {
+            return null;
+        }
+
+        /**数据校验**/
+        //车牌号-非空/长度为7
+        String truckNo = strArray[0];
+        if (StringUtils.isBlank(truckNo) || truckNo.trim().length() != 7) {
+            return null;
+        }
+
+        //司机姓名-非空
+        String name = strArray[1];
+        if (StringUtils.isBlank(name) || name.trim().length() == 0) {
+            return null;
+        }
+
+        //司机电话-非空/手机号正则校验
+        String phone = strArray[2];
+        if (StringUtils.isBlank(phone) || !RegularUtils.matchs(RegularUtils.PHONE_REG, phone)) {
+            return null;
+        }
+
+        //身份证号-非空/身份证正则校验
+        String idcard = strArray[3];
+        if (StringUtils.isBlank(idcard) || !RegularUtils.matchs(RegularUtils.IDCARD, idcard)) {
+            return null;
+        }
+
+        //核定载量/吨-非空/数值正则校验
+        String actualWeight = strArray[4];
+        if (StringUtils.isBlank(actualWeight) || !RegularUtils.matchs(RegularUtils.DECIMAL_REG, actualWeight)) {
+            return null;
+        }
+
+        reportDto.setTruckNo(truckNo);
+        reportDto.setName(name);
+        reportDto.setPhone(phone);
+        reportDto.setIdcard(idcard);
+        reportDto.setActualWeight(new BigDecimal(actualWeight));
+        return reportDto;
+    }
 }

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

@@ -203,7 +203,7 @@ public class KwfTruckService {
         /**车队班组绑定**/
         truckFleetEdit(truck.getId(), params.getFleetId());
 
-        return HttpResult.ok("车辆信息新增成功!");
+        return HttpResult.ok("车辆信息新增成功!", truck);
     }
 
     /**

+ 6 - 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, dr.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 createTime,
         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
@@ -129,6 +129,11 @@
         <if test="status != null and status != ''">
             and dr.status = #{status, jdbcType=VARCHAR}
         </if>
+        <if test="noReport != null and noReport != ''">
+            and dr.id not in (
+                select driver_id from kwf_truck_report where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR}
+            )
+        </if>
         <if test="keywords != null and keywords != ''">
             and (
             dr.name like concat('%',#{keyWords},'%')

+ 126 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckReportMapper.xml

@@ -2,4 +2,130 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.fleet.dao.KwfTruckReportMapper">
 
+    <select id="statistics" resultType="com.sckw.fleet.model.vo.KwfTableTopCount" parameterType="java.util.Map" >
+        SELECT
+            tr.`status` value, count(0) total
+        from kwf_truck_report trr
+        left join kwf_truck tr on tr.id = trr.truck_id
+        left join kwf_driver dr on dr.id = trr.driver_id
+        left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.del_flag = 0
+        left join kwf_fleet fl on fl.id = flt.fleet_id and fl.ent_id = trr.ent_id and fl.del_flag = 0
+        where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
+        <if test="entId != null and entId != ''">
+            and trr.ent_id = #{entId, jdbcType=VARCHAR}
+        </if>
+        <if test="truckNo != null and truckNo != ''">
+            and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
+        </if>
+        <if test="truckType != null and truckType != ''">
+            and tr.type = #{type, jdbcType=VARCHAR}
+        </if>
+        <if test="fleetId != null and fleetId != ''">
+            and fl.id = #{fleetId, jdbcType=VARCHAR}
+        </if>
+        <if test="fleetName != null and fleetName != ''">
+            and fl.name like concat('%',#{fleetName},'%')
+        </if>
+        <if test="status != null and status != ''">
+            and tr.status = #{status, jdbcType=VARCHAR}
+        </if>
+        <if test="startTime != null and startTime != '' " >
+            and DATE( trr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="endTime != null and endTime != '' " >
+            and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            and (
+            tr.truck_no like concat('%',#{keyWords},'%')
+            or dr.name like concat('%',#{keyWords},'%')
+            or dr.phone like concat('%',#{keyWords},'%')
+            )
+        </if>
+        GROUP BY tr.`status`
+    </select>
+
+    <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfTruckReportVo" parameterType="java.util.Map" >
+        SELECT
+            trr.id, trr.ent_id entId, trr.truck_id truckId, driver_id driverId, trr.remark, trr.status,
+            trr.create_by createBy, trr.create_time createTime, trr.update_time updateTime, trr.remark,
+            tr.truck_no truckNo, tr.actual_weight actualWeight, tr.business_status businessStatus,
+            dr.`name` driverName, dr.phone driverPhone, dr.idcard driverIdcard, dr.ent_id driverEntId,
+            tr.ent_id truckEntId, fl.name truckFleetName, tr.type truckType, tr.color, tr.trailer_no trailerNo
+        from kwf_truck_report trr
+        left join kwf_truck tr on tr.id = trr.truck_id
+        left join kwf_driver dr on dr.id = trr.driver_id
+        left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.del_flag = 0
+        left join kwf_fleet fl on fl.id = flt.fleet_id and fl.ent_id = trr.ent_id and fl.del_flag = 0
+        where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
+        <if test="entId != null and entId != ''">
+            and trr.ent_id = #{entId, jdbcType=VARCHAR}
+        </if>
+        <if test="truckNo != null and truckNo != ''">
+            and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
+        </if>
+        <if test="truckType != null and truckType != ''">
+            and tr.type = #{type, jdbcType=VARCHAR}
+        </if>
+        <if test="fleetId != null and fleetId != ''">
+            and fl.id = #{fleetId, jdbcType=VARCHAR}
+        </if>
+        <if test="fleetName != null and fleetName != ''">
+            and fl.name like concat('%',#{fleetName},'%')
+        </if>
+        <if test="status != null and status != ''">
+            and tr.status = #{status, jdbcType=VARCHAR}
+        </if>
+        <if test="startTime != null and startTime != '' " >
+            and DATE( trr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="endTime != null and endTime != '' " >
+            and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            and (
+            tr.truck_no like concat('%',#{keyWords},'%')
+            or dr.name like concat('%',#{keyWords},'%')
+            or dr.phone like concat('%',#{keyWords},'%')
+            )
+        </if>
+        ORDER BY tr.create_time desc
+    </select>
+
+    <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
+        SELECT
+            trr.id, trr.ent_id entId, truck_id truckId, driver_id driverId, trr.remark, trr.status,
+            tr.truck_no, tr.actual_weight, tr.business_status, dr.`name`, dr.phone, dr.idcard
+        from kwf_truck_report trr
+        left join kwf_truck tr on tr.id = trr.truck_id
+        left join kwf_driver dr on dr.id = trr.driver_id
+        where trr.del_flag = 0 and tr.del_flag = 0 and dr.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 trr.ent_id = #{entId, jdbcType=VARCHAR}
+        </if>
+        <if test="truckId != null and truckId != ''">
+            and trr.truck_id = #{truckId, jdbcType=VARCHAR}
+        </if>
+        <if test="driverId != null and driverId != ''">
+            and trr.driver_id = #{driverId, jdbcType=VARCHAR}
+        </if>
+        <if test="truckNo != null and truckNo != ''">
+            and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
+        </if>
+        <if test="status != null and status != ''">
+            and trr.status = #{status, jdbcType=VARCHAR}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            and (
+            tr.truck_no like concat('%',#{keyWords},'%')
+            or dr.name like concat('%',#{keyWords},'%')
+            or dr.phone like concat('%',#{keyWords},'%')
+            )
+        </if>
+        ORDER BY tr.create_time desc
+    </select>
+
 </mapper>