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

+ 3 - 3
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/PasswordUtils.java

@@ -122,13 +122,13 @@ public class PasswordUtils {
 
     public static void main(String[] args) {
 
-        String password = PasswordUtils.entryptPassword(PasswordUtils.md5("18482106067"));
-        String md5 = PasswordUtils.md5("123456");
+        String password = PasswordUtils.entryptPassword(PasswordUtils.md5("17358629958"));
+        String md5 = PasswordUtils.md5("17358629958");
         System.out.println(password);
         System.out.println(md5);
         System.out.println(validatePassword(md5, password));
 //        System.out.println(PasswordUtils.md5("czh"));
 //        System.out.println(PasswordUtils.entryptPassword(PasswordUtils.md5("czh")));
-
+        System.out.println(validatePassword(md5, "86e07d48c04c8a4bd9fe9dc819c608c43efda576b215995e9f138809"));
     }
 }

+ 10 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/StringUtils.java

@@ -683,6 +683,16 @@ public class StringUtils {
         return new String(newCodePoints, 0, outOffset);
     }
 
+    /**
+     * 值替换
+     * @param prefix
+     * @param args
+     * @return
+     */
+    public static String getKey(String prefix, String args) {
+        return String.format(prefix, args);
+    }
+
     public static void main(String[] args){
         Map<String, Object> param = new HashMap();
         param.put("account", "17358629955");

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

@@ -54,6 +54,11 @@
             <artifactId>sckw-common-sentinel</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-excel</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.sckw</groupId>
             <artifactId>sckw-system-api</artifactId>
@@ -61,4 +66,20 @@
 
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

+ 72 - 5
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java

@@ -7,24 +7,27 @@ 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.CollectionUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.easyexcel.RequestHolder;
+import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.fleet.model.KwfDriver;
 import com.sckw.fleet.model.KwfDriverCard;
 import com.sckw.fleet.model.KwfDriverLicense;
 import com.sckw.fleet.model.KwfDriverQualification;
-import com.sckw.fleet.model.dto.KwfDriverCardDto;
-import com.sckw.fleet.model.dto.KwfDriverDto;
-import com.sckw.fleet.model.dto.KwfDriverLicenseDto;
-import com.sckw.fleet.model.dto.KwfDriverQualificationDto;
+import com.sckw.fleet.model.dto.*;
 import com.sckw.fleet.model.vo.KwfDriverVo;
 import com.sckw.fleet.service.KwfDriverService;
+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;
 
 /**
  * @desc 司机
@@ -66,6 +69,18 @@ public class KwfDriverController {
         return HttpResult.ok(driverJson);
     }
 
+    /**
+     * @param params {page:页数、pageSize:每页条数、。。。}
+     * @desc 分页查询
+     * @author zk
+     * @date 2023/7/6
+     **/
+    @PostMapping("/statistics")
+    public HttpResult statistics(@RequestBody HashMap params) throws SystemException {
+        Map countMaps = driverService.statistics(params);
+        return HttpResult.ok(countMaps);
+    }
+
     /**
      * @param params {page:页数、pageSize:每页条数、。。。}
      * @desc 分页查询
@@ -92,6 +107,36 @@ public class KwfDriverController {
         return HttpResult.ok(driverService.findList(params));
     }
 
+    /**
+     * @param params 查询参数
+     * @description 导出
+     * @author zk
+     * @date 2023/07/11
+     **/
+    @PostMapping("/export")
+    public HttpResult export(@RequestBody HashMap params) {
+        /**查询分页数据**/
+        List<KwfDriverVo> drivers = driverService.findPage(params);
+
+        if (!CollectionUtils.isEmpty(drivers)) {
+            HttpServletResponse response = RequestHolder.getResponse();
+            ExcelUtil.download(response, KwfDriverVo.class, drivers);
+            return null;
+        }
+        return HttpResult.error("无数据!");
+    }
+
+    /**
+     * @param file 导入文件
+     * @description 导入
+     * @author zk
+     * @date 2023/07/11
+     **/
+    @PostMapping("/import")
+    public HttpResult importExcel(@RequestParam("file") MultipartFile file) {
+        return driverService.importExcel(file);
+    }
+
     /**
      * @param params 新增参数
      * @return HttpResult
@@ -159,4 +204,26 @@ public class KwfDriverController {
         return driverService.driverQualificationEdit(params);
     }
 
+    /**
+     * @param {password 旧密码、newPassword 新密码、account 账号}
+     * @description 修改密码
+     * @author zk
+     * @date 2023/07/11
+     **/
+    @PostMapping("/updatePassword")
+    public HttpResult updatePassword(@Valid @RequestBody UpdatePasswordDto params) {
+        return driverService.updatePassword(params);
+    }
+
+    /**
+     * @param {driverId 司机主键id/登陆后缓存中取、phone 手机号、captcha 短信验证码}
+     * @description 更换手机号
+     * @author zk
+     * @date 2023/07/11
+     **/
+    @PostMapping("/replacePhone")
+    public HttpResult replacePhone(@Valid @RequestBody ReplacePhoneDto params) {
+        return driverService.replacePhone(params);
+    }
+
 }

+ 8 - 2
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sckw.fleet.model.KwfDriver;
 import com.sckw.fleet.model.vo.KwfDriverVo;
+import com.sckw.fleet.model.vo.KwfTableTopCount;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,6 +20,13 @@ import java.util.Map;
 @Mapper
 public interface KwfDriverMapper extends BaseMapper<KwfDriver> {
 
+    /**
+     * 统计
+     * @param params
+     * @return
+     */
+    List<KwfTableTopCount> statistics(Map<String, Object> params);
+
     /**
      * 分页查询
      * @param params
@@ -26,8 +34,6 @@ public interface KwfDriverMapper extends BaseMapper<KwfDriver> {
      */
     List<KwfDriverVo> findPage(Map<String, Object> params);
 
-    IPage<KwfDriverVo> findPageV1(IPage<KwfDriverVo> page, @Param("params") KwfDriverVo params);
-
     /**
      * 查询
      * @param params

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

@@ -0,0 +1,131 @@
+package com.sckw.fleet.model.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author zk
+ * @desc 司机信息导出
+ * @date 2023/7/11 0011
+ */
+@Data
+@Accessors(chain = true)
+@ExcelContext(fileName = "司机信息", sheetName = "司机信息")
+public class KwfDriverExport {
+
+    @ExcelProperty(value = "司机姓名", index = 0)
+    private String name;
+
+    /**
+     * 电话
+     */
+    @ExcelProperty(value = "电话", index = 1)
+    private String phone;
+
+    /**
+     * 身份证号
+     */
+    @ExcelProperty(value = "身份证号", index = 2)
+    private String idcard;
+
+    /**
+     * 身份证有效时间
+     */
+    @ExcelProperty(value = "身份证有效时间", index = 3)
+    private String idcardExpireTime;
+
+    /**
+     * 身份证住址
+     */
+    @ExcelProperty(value = "身份证住址", index = 4)
+    private String address;
+
+    /**
+     * 驾驶证编号
+     */
+    @ExcelProperty(value = "驾驶证编号", index = 5)
+    private String driverNo;
+
+    /**
+     * 准驾车型
+     */
+    @ExcelProperty(value = "准驾车型", index = 6)
+    private String licenseType;
+
+    /**
+     * 驾驶证有效期至
+     */
+    @ExcelProperty(value = "驾驶证有效期至", index = 7)
+    private String licenseExpireTime;
+
+    /**
+     * 驾驶证发证机关
+     */
+    @ExcelProperty(value = "驾驶证发证机关", index = 8)
+    private String licenseGrantUnit;
+
+    /**
+     * 从业资格证号
+     */
+    @ExcelProperty(value = "从业资格证号", index = 9)
+    private String qualiNo;
+
+    /**
+     * 企业名称
+     */
+    @ExcelProperty(value = "企业名称", index = 10)
+    private String firmName;
+
+    /**
+     * 车队班组
+     */
+    @ExcelProperty(value = "车队班组", index = 11)
+    private String fleetName;
+
+    /**
+     * 车牌号
+     */
+    @ExcelProperty(value = "车牌号", index = 12)
+    private String truckNo;
+
+    /**
+     * 创建人
+     */
+    @ExcelProperty(value = "创建人", index = 13)
+    private String createByName;
+
+    /**
+     * 创建时间
+     */
+    @ExcelProperty(value = "创建时间", index = 14)
+    private String crateTime;
+
+    /**
+     * 更新时间
+     */
+    @ExcelProperty(value = "更新时间", index = 15)
+    private String updateTime;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注", index = 16)
+    private String remark;
+
+    /**
+     * 状态
+     */
+    @ExcelProperty(value = "状态", index = 17)
+    private String statusName;
+
+    /**
+     * 状态
+     */
+    private int status;
+
+    public String getStatusName() {
+        return status == 1 ? "已认证" : status == 2 ? "临时" : "异常";
+    }
+}

+ 29 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/ReplacePhoneDto.java

@@ -0,0 +1,29 @@
+package com.sckw.fleet.model.dto;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Pattern;
+import lombok.Data;
+
+/**
+ * @author zk
+ * @desc 更换手机
+ * @date 2023/7/11 0011
+ */
+@Data
+public class ReplacePhoneDto {
+
+    /**
+     * 手机号
+     */
+    @NotBlank(message = "手机号不能为空!")
+    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "电话号码格式不正确!")
+    private String phone;
+
+    /**
+     * 验证码
+     */
+    @NotBlank(message = "验证码不能为空!")
+    private String captcha;
+
+    private Long driverId;
+}

+ 33 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/UpdatePasswordDto.java

@@ -0,0 +1,33 @@
+package com.sckw.fleet.model.dto;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+/**
+ * @author zk
+ * @desc 修改密码
+ * @date 2023/7/11 0011
+ */
+@Data
+public class UpdatePasswordDto {
+
+    /**
+     * 账号
+     */
+    @NotBlank(message = "账号不能为空!")
+    private String account;
+
+    /**
+     * 旧密码
+     */
+    @NotBlank(message = "旧密码不能为空!")
+    private String password;
+
+    /**
+     * 新密码
+     */
+    @NotBlank(message = "新密码不能为空!")
+    private String newPassword;
+
+    private Long driverId;
+}

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

@@ -1,11 +1,152 @@
 package com.sckw.fleet.model.vo;
 
-import com.sckw.fleet.model.KwfDriver;
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Data;
 
 /**
  * @author zk
- * @desc TODO
+ * @desc 司机档案
  * @date 2023/7/7 0007
  */
-public class KwfDriverVo extends KwfDriver {
+@Data
+@ExcelContext(fileName = "司机信息", sheetName = "司机信息")
+public class KwfDriverVo {
+
+    /**
+     * 司机主键id
+     */
+    @ExcelIgnore
+    private String id;
+
+    /**
+     * 司机姓名
+     */
+    @ExcelProperty(value = "司机姓名", index = 0)
+    private String name;
+
+    /**
+     * 电话
+     */
+    @ExcelProperty(value = "电话", index = 1)
+    private String phone;
+
+    /**
+     * 状态
+     */
+    @ExcelProperty(value = "状态", index = 2)
+    private String statusName;
+
+    /**
+     * 身份证号
+     */
+    @ExcelProperty(value = "身份证号", index = 3)
+    private String idcard;
+
+    /**
+     * 身份证有效时间
+     */
+    @ExcelProperty(value = "身份证有效时间", index = 4)
+    private String idcardExpireTime;
+
+    /**
+     * 身份证住址
+     */
+    @ExcelProperty(value = "身份证住址", index = 5)
+    private String address;
+
+    /**
+     * 驾驶证编号
+     */
+    @ExcelProperty(value = "驾驶证编号", index = 6)
+    private String driverNo;
+
+    /**
+     * 准驾车型
+     */
+    @ExcelProperty(value = "准驾车型", index = 7)
+    private String licenseType;
+
+    /**
+     * 驾驶证有效期至
+     */
+    @ExcelProperty(value = "驾驶证有效期至", index = 8)
+    private String licenseExpireTime;
+
+    /**
+     * 驾驶证发证机关
+     */
+    @ExcelProperty(value = "驾驶证发证机关", index = 9)
+    private String licenseGrantUnit;
+
+    /**
+     * 从业资格证号
+     */
+    @ExcelProperty(value = "从业资格证号", index = 10)
+    private String qualiNo;
+
+    /**
+     * 车牌号
+     */
+    @ExcelProperty(value = "车牌号", index = 11)
+    private String truckNo;
+
+    /**
+     * 企业主键ID
+     */
+    @ExcelIgnore
+    private String entId;
+
+    /**
+     * 企业名称
+     */
+    @ExcelProperty(value = "企业名称", index = 12)
+    private String firmName;
+
+    /**
+     * 车队班组
+     */
+    @ExcelProperty(value = "车队班组", index = 13)
+    private String fleetName;
+
+    /**
+     * 创建人
+     */
+    @ExcelIgnore
+    private String createBy;
+
+    /**
+     * 创建人
+     */
+    @ExcelProperty(value = "创建人", index = 14)
+    private String createByName;
+
+    /**
+     * 创建时间
+     */
+    @ExcelProperty(value = "创建时间", index = 15)
+    private String crateTime;
+
+    /**
+     * 更新时间
+     */
+    @ExcelProperty(value = "更新时间", index = 16)
+    private String updateTime;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注", index = 17)
+    private String remark;
+
+    /**
+     * 状态
+     */
+    @ExcelIgnore
+    private int status;
+
+    public String getStatusName() {
+        return status == 1 ? "已认证" : status == 2 ? "临时" : "异常";
+    }
 }

+ 26 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTableTopCount.java

@@ -0,0 +1,26 @@
+package com.sckw.fleet.model.vo;
+
+import lombok.Data;
+
+/**
+ * @author zk
+ * @desc 表头统计值
+ * @date 2023/7/11 0011
+ */
+@Data
+public class KwfTableTopCount {
+    /**
+     * tab名称
+     */
+    private String name;
+
+    /**
+     * 状态值
+     */
+    private String value;
+
+    /**
+     * 统计值
+     */
+    private long total;
+}

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageHelperUtil;
@@ -15,19 +16,28 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.utils.EasyExcelUtil;
 import com.sckw.fleet.dao.*;
 import com.sckw.fleet.model.*;
-import com.sckw.fleet.model.dto.KwfDriverCardDto;
-import com.sckw.fleet.model.dto.KwfDriverDto;
-import com.sckw.fleet.model.dto.KwfDriverLicenseDto;
-import com.sckw.fleet.model.dto.KwfDriverQualificationDto;
+import com.sckw.fleet.model.dto.*;
 import com.sckw.fleet.model.vo.KwfDriverVo;
+import com.sckw.fleet.model.vo.KwfTableTopCount;
+import com.sckw.redis.constant.RedisConstant;
+import com.sckw.redis.utils.RedissonUtils;
+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.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @desc 司机
@@ -48,6 +58,8 @@ public class KwfDriverService {
     KwfDriverLicenseMapper KwfDriverLicenseDao;
     @Autowired
     KwfDriverQualificationMapper KwfDriverQualificationDao;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
 
     /**
      * @param key 逐渐id
@@ -59,6 +71,33 @@ public class KwfDriverService {
         return driverDao.selectById(key);
     }
 
+    /**
+     * @param params 参数
+     * @desc 统计
+     * @author zk
+     * @date 2023/7/11
+     **/
+    public Map statistics(Map<String, Object> params) {
+        /**统计数据**/
+        List<KwfTableTopCount> counts = driverDao.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 分页查询
@@ -66,7 +105,34 @@ public class KwfDriverService {
      * @date 2023/7/6
      **/
     public List<KwfDriverVo> findPage(Map<String, Object> params) {
-        return driverDao.findPage(params);
+        /**查询分页数据**/
+        List<KwfDriverVo> drivers = driverDao.findPage(params);
+        if (CollectionUtils.isEmpty(drivers)) {
+            return drivers;
+        }
+
+        /**获取查询数据**/
+        List<Long> createBys = new ArrayList<>();
+        List<Long> entIds = new ArrayList<>();
+        for (KwfDriverVo driverVo:drivers) {
+            createBys.add(Long.parseLong(driverVo.getCreateBy()));
+            entIds.add(Long.parseLong(driverVo.getEntId()));
+        }
+        //用户数据集
+        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 (KwfDriverVo driverVo:drivers) {
+            UserCacheResDto user = users == null ? null : users.get(Long.parseLong(driverVo.getCreateBy()));
+            EntCacheResDto ent = ents == null ? null : ents.get(Long.parseLong(driverVo.getEntId()));
+            driverVo.setCreateByName(user != null ? user.getName() : null);
+            driverVo.setFirmName(ent != null ? ent.getFirmName() : null);
+        }
+        return drivers;
     }
 
     /**
@@ -79,6 +145,16 @@ public class KwfDriverService {
         return driverDao.findList(params);
     }
 
+    /**
+     * @param {}
+     * @description 导出
+     * @author zk
+     * @date 2023/07/11
+     **/
+    public HttpResult importExcel(MultipartFile file) {
+        return null;
+    }
+
     /**
      * @param params 参数
      * @desc 新增司机
@@ -89,6 +165,13 @@ public class KwfDriverService {
         /**司机信息**/
         KwfDriver driver = new KwfDriver();
         BeanUtils.copyProperties(params, driver);
+        //证件都有数据则为已认证(前端校验认证数据必填)
+        boolean bool = checkLicense(params);
+        if (bool) {
+            driver.setStatus(Global.NUMERICAL_ONE);
+        } else {
+            driver.setStatus(Global.NUMERICAL_TWO);
+        }
         HttpResult result = driverEdit(driver);
         if (result.getCode() != HttpStatus.SUCCESS_CODE) {
             return result;
@@ -138,6 +221,11 @@ public class KwfDriverService {
 
         /**司机信息**/
         BeanUtils.copyProperties(params, driver);
+        //证件都有数据则为已认证(前端校验认证数据必填)
+        boolean bool = checkLicense(params);
+        if (bool) {
+            driver.setStatus(Global.NUMERICAL_ONE);
+        }
         HttpResult result = driverEdit(driver);
         if (result.getCode() != HttpStatus.SUCCESS_CODE) {
             return result;
@@ -245,15 +333,18 @@ public class KwfDriverService {
         BeanUtils.copyProperties(params, driverCard);
 
         /**数据更新**/
+        int count = 0;
         KwfDriverCard card = KwfDriverCardDao.findByDriverId(params.getDriverId());
         if (card == null) {
-            int count = KwfDriverCardDao.insert(driverCard);
-            return count > 0 ? HttpResult.ok("身份证信息更新成功!") : HttpResult.error("身份证信息更新失败!");
+            count = KwfDriverCardDao.insert(driverCard);
         } else {
             driverCard.setId(card.getId());
-            int count = KwfDriverCardDao.updateById(driverCard);
-            return count > 0 ? HttpResult.ok("身份证信息修改成功!") : HttpResult.error("身份证信息修改失败!");
+            count = KwfDriverCardDao.updateById(driverCard);
         }
+
+        /**校验司机是否有证书并更新状态**/
+        checkLicense(driverCard.getDriverId());
+        return count > 0 ? HttpResult.ok("身份证信息修改成功!") : HttpResult.error("身份证信息修改失败!");
     }
 
     /**
@@ -278,15 +369,19 @@ public class KwfDriverService {
         BeanUtils.copyProperties(params, driverLicense);
 
         /**数据更新**/
+        int count = 0;
         KwfDriverLicense license = KwfDriverLicenseDao.findByDriverId(params.getDriverId());
         if (license == null) {
-            int count = KwfDriverLicenseDao.insert(driverLicense);
+            count = KwfDriverLicenseDao.insert(driverLicense);
             return count > 0 ? HttpResult.ok("司机驾驶证信息更新成功!") : HttpResult.error("司机驾驶证信息更新失败!");
         } else {
             driverLicense.setId(license.getId());
-            int count = KwfDriverLicenseDao.updateById(driverLicense);
-            return count > 0 ? HttpResult.ok("司机驾驶证信息修改成功!") : HttpResult.error("司机驾驶证信息修改失败!");
+            count = KwfDriverLicenseDao.updateById(driverLicense);
         }
+
+        /**校验司机是否有证书并更新状态**/
+        checkLicense(driverLicense.getDriverId());
+        return count > 0 ? HttpResult.ok("司机驾驶证信息修改成功!") : HttpResult.error("司机驾驶证信息修改失败!");
     }
 
     /**
@@ -311,15 +406,18 @@ public class KwfDriverService {
         BeanUtils.copyProperties(params, driverQual);
 
         /**数据更新**/
+        int count = 0;
         KwfDriverQualification qualification = KwfDriverQualificationDao.findByDriverId(params.getDriverId());
         if (qualification == null) {
-            int count = KwfDriverQualificationDao.insert(driverQual);
-            return count > 0 ? HttpResult.ok("司机从业资格证信息更新成功!") : HttpResult.error("司机从业资格证信息更新失败!");
+            count = KwfDriverQualificationDao.insert(driverQual);
         } else {
             driverQual.setId(qualification.getId());
-            int count = KwfDriverQualificationDao.updateById(driverQual);
-            return count > 0 ? HttpResult.ok("司机从业资格证信息修改成功!") : HttpResult.error("司机从业资格证信息修改失败!");
+            count = KwfDriverQualificationDao.updateById(driverQual);
         }
+
+        /**校验司机是否有证书并更新状态**/
+        checkLicense(driverQual.getDriverId());
+        return count > 0 ? HttpResult.ok("司机从业资格证信息修改成功!") : HttpResult.error("司机从业资格证信息修改失败!");
     }
 
     /**
@@ -345,4 +443,123 @@ public class KwfDriverService {
         driverEntDao.insert(driverEnt);
     }
 
+    /**
+     * @param params 参数
+     * @desc: 修改密码
+     * @author: zk
+     * @date: 2023/7/11
+     */
+    public HttpResult updatePassword(UpdatePasswordDto params) {
+        /**获取信息**/
+        Long driverId = null;//LoginUserHolder.getUserId(); //暂时----------------zk
+        driverId = driverId == null ? params.getDriverId() : driverId;
+        KwfDriver driver = driverDao.selectById(driverId);
+        if (driver == null) {
+            return HttpResult.error("信息不存在!");
+        }
+
+        /**原密码校验**/
+        if (!PasswordUtils.validatePassword(params.getPassword(), driver.getPassword())) {
+            return HttpResult.error("原密码不正确!");
+        }
+
+        /**新旧密码不能一只**/
+        if (PasswordUtils.validatePassword(params.getNewPassword(), driver.getPassword())) {
+            return HttpResult.error("原密码与新密码不能一致!");
+        }
+
+        /**更新数据**/
+        driver.setPassword(PasswordUtils.entryptPassword(params.getNewPassword()));
+        driver.setSalt(PasswordUtils.getSaltSubPwd(driver.getPassword()));
+        int count = driverDao.updateById(driver);
+        return count > 0 ? HttpResult.ok("密码修改成功!") : HttpResult.error("密码修改失败!");
+    }
+
+    /**
+     * @param {driverId 司机主键id/登陆后缓存中取、phone 手机号、captcha 短信验证码}
+     * @description 更换手机号
+     * @author zk
+     * @date 2023/07/11
+     **/
+    public HttpResult replacePhone(ReplacePhoneDto params) {
+        /**获取信息**/
+        Long driverId = null;//LoginUserHolder.getUserId(); //暂时----------------zk
+        driverId = driverId == null ? params.getDriverId() : driverId;
+        KwfDriver driver = driverDao.selectById(driverId);
+        if (driver == null) {
+            return HttpResult.error("信息不存在!");
+        }
+
+        /**从缓存中取出验证码/校验**/
+        String valueKey = StringUtils.getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, params.getPhone());
+        String phoneCaptcha = RedissonUtils.getString(valueKey);
+        if (StringUtils.isBlank(phoneCaptcha)) {
+            return HttpResult.error("手机验证码不正确请确认!");
+        }
+        if (!phoneCaptcha.equals(params.getCaptcha())) {
+            return HttpResult.error("手机验证码不正确请确认!");
+        }
+
+        /**唯一性交易**/
+        List<Map<String, Object>> drivers = driverDao.findList(new HashMap(){{ put("phone", params.getPhone()); }});
+        if (!CollectionUtils.isEmpty(drivers)) {
+            return HttpResult.error("电话号码已存在!");
+        }
+
+        /**更新数据**/
+        driver.setPhone(params.getPhone());
+        int count = driverDao.updateById(driver);
+        return count > 0 ? HttpResult.ok("手机号更换成功!") : HttpResult.error("手机号更换失败!");
+    }
+
+    /**
+     * @param params 参数
+     * @desc 校验司机是否有证书
+     * @author zk
+     * @date 2023/7/11
+     **/
+    public boolean checkLicense(KwfDriverDto params) {
+        //身份证
+        if (params.getDriverCard() == null || StringUtils.isBlank(params.getDriverCard().getIdcard())) {
+            return false;
+        }
+        //司机驾驶证信息
+        if (params.getDriverLicense() == null || StringUtils.isBlank(params.getDriverLicense().getDriverNo())) {
+            return false;
+        }
+        //司机从业资格证
+        if (params.getDriverQualification() == null || StringUtils.isBlank(params.getDriverQualification().getQualiNo())) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * @param driverId 司机id
+     * @desc 校验司机是否有证书并更新状态
+     * @author zk
+     * @date 2023/7/11
+     **/
+    public void checkLicense(Long driverId) {
+        //身份证
+        KwfDriverCard card = this.findCarByKey(driverId);
+        if (card == null || StringUtils.isBlank(card)) {
+            return;
+        }
+        //司机驾驶证信息
+        KwfDriverLicense license = this.findLicenseByKey(driverId);
+        if (license == null || StringUtils.isBlank(license.getDriverNo())) {
+            return;
+        }
+        //司机从业资格证
+        KwfDriverQualification quali = this.findQualificationByKey(driverId);
+        if (quali == null || StringUtils.isBlank(quali.getQualiNo())) {
+            return;
+        }
+        //更新数据
+        KwfDriver driver = new KwfDriver();
+        driver.setId(driverId);
+        driver.setStatus(Global.NUMERICAL_ONE);
+        driverDao.updateById(driver);
+    }
 }

+ 53 - 30
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml

@@ -2,19 +2,18 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.fleet.dao.KwfDriverMapper">
 
-    <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfDriverVo" parameterType="java.util.Map" >
+    <select id="statistics" resultType="com.sckw.fleet.model.vo.KwfTableTopCount" parameterType="java.util.Map" >
         SELECT
-            dr.id, dr.name, dr.phone, dr.idcard, 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,
-            dr.update_time updateTime, dr.remark, trr.truck_no truckNo
+        dr.`status` value, count(0) total
         from kwf_driver dr
         left join kwf_driver_ent dre on dre.driver_id = dr.id
-        left join kwf_driver_card drc on drc.driver_id = dr.id
-        left join kwf_driver_license drl on drl.driver_id = dr.id
-        left join kwf_driver_qualification drq on drq.driver_id = dr.id
+        left join kwf_driver_card drc on drc.driver_id = dr.id and drc.del_flag = 0
+        left join kwf_driver_license drl on drl.driver_id = dr.id and drl.del_flag = 0
+        left join kwf_driver_qualification drq on drq.driver_id = dr.id and drq.del_flag = 0
         left join kwf_truck_report trr on trr.ent_id = dre.ent_id and trr.driver_id = dr.id
-        where dr.del_flag = 0 and dre.del_flag = 0 and drc.del_flag = 0 and drl.del_flag = 0 and drq.del_flag = 0
+        left join kwf_fleet_driver flr on flr.id = dr.id and flr.del_flag = 0
+        left join kwf_fleet fl on fl.id = flr.fleet_id and fl.del_flag = 0
+        where dr.del_flag = 0 and dre.del_flag = 0
         <if test="entId != null and entId != ''">
             and dre.ent_id = #{entId, jdbcType=VARCHAR}
         </if>
@@ -27,46 +26,67 @@
         <if test="phone != null and phone != ''">
             and dr.phone = #{phone, jdbcType=VARCHAR}
         </if>
+        <if test="licenseType != null and licenseType != ''">
+            and drl.type = #{licenseType, 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="keywords != null and keywords != ''">
             and (
             dr.name like concat('%',#{keyWords},'%')
-            or dr.idcard like concat('%',#{keyWords},'%')
             or dr.phone like concat('%',#{keyWords},'%')
             )
         </if>
-        ORDER BY dr.create_time desc
+        GROUP BY dr.`status`
     </select>
 
-    <select id="findPageV1" resultType="com.sckw.fleet.model.vo.KwfDriverVo" parameterType="java.util.Map" >
+    <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfDriverVo" parameterType="java.util.Map" >
         SELECT
-        dr.id, dr.name, dr.phone, dr.idcard, drc.expire_time idcardExpireTime, drc.address, drl.driver_no driverNo,
+        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,
-        dr.update_time updateTime, dr.remark, trr.truck_no truckNo
+        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
-        left join kwf_driver_card drc on drc.driver_id = dr.id
-        left join kwf_driver_license drl on drl.driver_id = dr.id
-        left join kwf_driver_qualification drq on drq.driver_id = dr.id
+        left join kwf_driver_card drc on drc.driver_id = dr.id and drc.del_flag = 0
+        left join kwf_driver_license drl on drl.driver_id = dr.id and drl.del_flag = 0
+        left join kwf_driver_qualification drq on drq.driver_id = dr.id and drq.del_flag = 0
         left join kwf_truck_report trr on trr.ent_id = dre.ent_id and trr.driver_id = dr.id
-        where dr.del_flag = 0 and dre.del_flag = 0 and drc.del_flag = 0 and drl.del_flag = 0 and drq.del_flag = 0
-        <if test="params.entId != null and params.entId != ''">
-            and dre.ent_id = #{params.entId, jdbcType=VARCHAR}
+        left join kwf_fleet_driver flr on flr.id = dr.id and flr.del_flag = 0
+        left join kwf_fleet fl on fl.id = flr.fleet_id and fl.del_flag = 0
+        where dr.del_flag = 0 and dre.del_flag = 0
+        <if test="entId != null and entId != ''">
+            and dre.ent_id = #{entId, jdbcType=VARCHAR}
         </if>
-        <if test="params.name != null and params.name != ''">
-            and dr.name = #{params.name, jdbcType=VARCHAR}
+        <if test="name != null and name != ''">
+            and dr.name = #{name, jdbcType=VARCHAR}
         </if>
-        <if test="params.idcard != null and params.idcard != ''">
-            and dr.idcard = #{params.idcard, jdbcType=VARCHAR}
+        <if test="idcard != null and idcard != ''">
+            and dr.idcard = #{idcard, jdbcType=VARCHAR}
+        </if>
+        <if test="phone != null and phone != ''">
+            and dr.phone = #{phone, jdbcType=VARCHAR}
+        </if>
+        <if test="licenseType != null and licenseType != ''">
+            and drl.type = #{licenseType, jdbcType=VARCHAR}
         </if>
-        <if test="params.phone != null and params.phone != ''">
-            and dr.phone = #{params.phone, jdbcType=VARCHAR}
+        <if test="fleetId != null and fleetId != ''">
+            and fl.id = #{fleetId, jdbcType=VARCHAR}
         </if>
-        <if test="params.keywords != null and params.keywords != ''">
+        <if test="fleetName != null and fleetName != ''">
+            and fl.name like concat('%',#{fleetName},'%')
+        </if>
+        <if test="status != null and status != ''">
+            and dr.status = #{status, jdbcType=VARCHAR}
+        </if>
+        <if test="keywords != null and keywords != ''">
             and (
-            dr.name like concat('%',#{params.keyWords},'%')
-            or dr.idcard like concat('%',#{params.keyWords},'%')
-            or dr.phone like concat('%',#{params.keyWords},'%')
+            dr.name like concat('%',#{keyWords},'%')
+            or dr.phone like concat('%',#{keyWords},'%')
             )
         </if>
         ORDER BY dr.create_time desc
@@ -91,6 +111,9 @@
         <if test="phone != null and phone != ''">
             and dr.phone = #{phone, jdbcType=VARCHAR}
         </if>
+        <if test="status != null and status != ''">
+            and dr.status = #{status, jdbcType=VARCHAR}
+        </if>
         <if test="keywords != null and keywords != ''">
             and (
             dr.name like concat('%',#{keyWords},'%')

+ 18 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwFleetController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -51,6 +52,23 @@ public class KwFleetController {
         streamBridge.send("sckw-busSum", JSON.toJSONString(busSum));
 
 
+        for (int i =0; i<10000; i++) {
+            order.setTOrderId(System.currentTimeMillis());
+            order.setTOrderNo("D" + order.getTOrderId());
+            order.setContractName(new Date()+"");
+            order.setActualAmount(new BigDecimal(0));
+            order.setContractId(1);
+            order.setContractNo("11");
+            order.setEndTime(new Date());
+            order.setSupplyEntId(1L);
+
+            busSum.setBusSumType("tradeOrder");
+            busSum.setMethod(method);
+            busSum.setObject(order);
+            streamBridge.send("sckw-busSum", JSON.toJSONString(busSum));
+        }
+
+
         //根据条件查询所有并排序,且分页
         Pageable pageable = PageRequest.of(0, 2);
         Page<SckwTradeOrder> all3 = tradeOrderRepository.findAll(pageable);