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

+ 0 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/base/BaseModel.java

@@ -60,7 +60,6 @@ public class BaseModel implements Serializable {
 	/**
 	 * 删除标识(0正常/-1删除)
 	 */
-    @TableLogic
 	private Integer delFlag = 0;
 
 }

+ 3 - 2
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java

@@ -18,6 +18,7 @@ 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.vo.KwfDriverVo;
 import com.sckw.fleet.service.KwfDriverService;
 import jakarta.validation.Valid;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,7 +76,7 @@ public class KwfDriverController {
     public HttpResult findPage(@RequestBody HashMap params) throws SystemException {
         // 设置分页参数
         PageHelper.startPage(PageResult.getPage(params), PageResult.getPageSize(params));
-        List<KwfDriver> list = driverService.findPage(params);
+        List<KwfDriverVo> list = driverService.findPage(params);
         PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));
         return HttpResult.ok(pageResult);
     }
@@ -120,7 +121,7 @@ public class KwfDriverController {
      * @author zk
      * @date 2023/7/7
      **/
-    @PostMapping("/dels")
+    @DeleteMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws SystemException {
         return driverService.del(ids);
     }

+ 2 - 2
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfFleetController.java

@@ -95,8 +95,8 @@ public class KwfFleetController {
      * @author zk
      * @date 2023/7/6
      **/
-    @PostMapping("/dels")
+    @DeleteMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws SystemException {
-        return HttpResult.ok(HttpStatus.MSG_008);
+        return fleetService.del(ids);
     }
 }

+ 6 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverEntMapper.java

@@ -11,5 +11,10 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface KwfDriverEntMapper extends BaseMapper<KwfDriverEnt> {
-
+    /**
+     * 查询
+     * @param params 参数
+     * @return
+     */
+    KwfDriverEnt findByDriverEnt(KwfDriverEnt params);
 }

+ 6 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverMapper.java

@@ -1,9 +1,13 @@
 package com.sckw.fleet.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+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 org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
 import java.util.List;
 import java.util.Map;
 
@@ -22,6 +26,8 @@ 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

+ 6 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckEntMapper.java

@@ -12,4 +12,10 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface KwfTruckEntMapper extends BaseMapper<KwfTruckEnt> {
 
+    /**
+     * 查询
+     * @param params 参数
+     * @return
+     */
+    KwfTruckEnt findByTruckEnt(KwfTruckEnt params);
 }

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

@@ -1,5 +1,6 @@
 package com.sckw.fleet.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import jakarta.validation.constraints.Pattern;
 import jakarta.validation.constraints.Size;
 import lombok.Data;
@@ -32,6 +33,7 @@ public class KwfDriverCardDto {
     /**
      * 有效日期
      */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date expireTime;
 
     /**

+ 2 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfDriverLicenseDto.java

@@ -1,5 +1,6 @@
 package com.sckw.fleet.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import jakarta.validation.constraints.Size;
 import lombok.Data;
 import java.util.Date;
@@ -36,6 +37,7 @@ public class KwfDriverLicenseDto {
     /**
      * 有效日期
      */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date expireTime;
 
     /**

+ 2 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/dto/KwfDriverQualificationDto.java

@@ -1,5 +1,6 @@
 package com.sckw.fleet.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import jakarta.validation.constraints.Size;
 import lombok.Data;
 import java.util.Date;
@@ -36,6 +37,7 @@ public class KwfDriverQualificationDto {
     /**
      * 有效日期
      */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date expireTime;
 
     /**

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

@@ -1,9 +1,11 @@
 package com.sckw.fleet.model.vo;
 
+import com.sckw.fleet.model.KwfDriver;
+
 /**
  * @author zk
  * @desc TODO
  * @date 2023/7/7 0007
  */
-public class KwfDriverVo {
+public class KwfDriverVo extends KwfDriver {
 }

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

@@ -1,8 +1,13 @@
 package com.sckw.fleet.service;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.SystemException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.page.PageHelperUtil;
+import com.sckw.core.model.page.PageResult;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.PasswordUtils;
@@ -19,6 +24,7 @@ import com.sckw.fleet.model.dto.KwfDriverQualificationDto;
 import com.sckw.fleet.model.vo.KwfDriverVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +35,7 @@ import java.util.Map;
  * @date 2023/7/6 0006
  */
 @Service
+@Transactional(rollbackFor = Exception.class)
 public class KwfDriverService {
 
     @Autowired
@@ -68,8 +75,8 @@ public class KwfDriverService {
      * @author zk
      * @date 2023/7/6
      **/
-    public List<KwfDriver> findList(Map<String, Object> params) {
-        return driverDao.selectPage(null, null);
+    public List<Map<String, Object>> findList(Map<String, Object> params) {
+        return driverDao.findList(params);
     }
 
     /**
@@ -83,21 +90,30 @@ public class KwfDriverService {
         KwfDriver driver = new KwfDriver();
         BeanUtils.copyProperties(params, driver);
         HttpResult result = driverEdit(driver);
-        if (result != null) {
+        if (result.getCode() != HttpStatus.SUCCESS_CODE) {
             return result;
         }
 
         /**身份证信息**/
-        params.getDriverCard().setDriverId(params.getId());
-        driverCardEdit(params.getDriverCard());
+        KwfDriverCardDto driverCardDto = params.getDriverCard();
+        if (driverCardDto != null) {
+            driverCardDto.setDriverId(String.valueOf(driver.getId()));
+            driverCardEdit(driverCardDto);
+        }
 
         /**司机驾驶证信息**/
-        params.getDriverLicense().setDriverId(params.getId());
-        driverLicenseEdit(params.getDriverLicense());
+        KwfDriverLicenseDto driverLicenseDto = params.getDriverLicense();
+        if (driverLicenseDto != null) {
+            driverLicenseDto.setDriverId(String.valueOf(driver.getId()));
+            driverLicenseEdit(driverLicenseDto);
+        }
 
         /**司机从业资格证**/
-        params.getDriverQualification().setDriverId(params.getId());
-        driverQualificationEdit(params.getDriverQualification());
+        KwfDriverQualificationDto driverQualificationDto = params.getDriverQualification();
+        if (driverQualificationDto != null) {
+            driverQualificationDto.setDriverId(String.valueOf(driver.getId()));
+            driverQualificationEdit(driverQualificationDto);
+        }
 
         /**司机信息与企业关联信息**/
         driverEntEdit(driver);
@@ -123,22 +139,31 @@ public class KwfDriverService {
         /**司机信息**/
         BeanUtils.copyProperties(params, driver);
         HttpResult result = driverEdit(driver);
-        if (result != null) {
+        if (result.getCode() != HttpStatus.SUCCESS_CODE) {
             return result;
         }
 
         /**身份证信息**/
-        params.getDriverCard().setDriverId(params.getId());
-        driverCardEdit(params.getDriverCard());
+        KwfDriverCardDto driverCardDto = params.getDriverCard();
+        if (driverCardDto != null) {
+            driverCardDto.setDriverId(String.valueOf(driver.getId()));
+            driverCardEdit(driverCardDto);
+        }
 
         /**司机驾驶证信息**/
-        params.getDriverLicense().setDriverId(params.getId());
-        driverLicenseEdit(params.getDriverLicense());
+        KwfDriverLicenseDto driverLicenseDto = params.getDriverLicense();
+        if (driverLicenseDto != null) {
+            driverLicenseDto.setDriverId(String.valueOf(driver.getId()));
+            driverLicenseEdit(driverLicenseDto);
+        }
 
         /**司机从业资格证**/
-        params.getDriverQualification().setDriverId(params.getId());
-        driverQualificationEdit(params.getDriverQualification());
-        return HttpResult.ok("司机信息新增成功!");
+        KwfDriverQualificationDto driverQualificationDto = params.getDriverQualification();
+        if (driverQualificationDto != null) {
+            driverQualificationDto.setDriverId(String.valueOf(driver.getId()));
+            driverQualificationEdit(driverQualificationDto);
+        }
+        return HttpResult.ok("司机信息修改成功!");
     }
 
     /**
@@ -155,14 +180,14 @@ public class KwfDriverService {
 
         /**数据组装**/
         String[] idArray = ids.split(",");
-        KwfDriver driverQuery = new KwfDriver();
-        driverQuery.setEntId(LoginUserHolder.getEntId());
+        KwfDriverEnt driverEntQuery = new KwfDriverEnt();
+        driverEntQuery.setEntId(LoginUserHolder.getEntId());
         for (String id : idArray) {
-            driverQuery.setId(Long.parseLong(id));
-            KwfDriver driver = driverDao.findEntDriver(driverQuery);
-            if (driver != null) {
-                driver.setDelFlag(Global.YES);
-                if (driverDao.updateById(driver) <= 0) {
+            driverEntQuery.setDriverId(Long.parseLong(id));
+            KwfDriverEnt driverEnt = driverEntDao.findByDriverEnt(driverEntQuery);
+            if (driverEnt != null) {
+                driverEnt.setDelFlag(Global.YES);
+                if (driverEntDao.updateById(driverEnt) <= 0) {
                     throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
                 }
             }
@@ -190,8 +215,9 @@ public class KwfDriverService {
             params.setSalt(PasswordUtils.getSaltSubPwd(password));
             params.setPassword(password);
             params.setEntId(LoginUserHolder.getEntId());
+            params.setEntId(params.getEntId() == null ? 1 : params.getEntId());// 暂时处理---------------zk
             int count = driverDao.insert(params);
-            return count > 0 ? null : HttpResult.error("司机信息新增失败!");
+            return count > 0 ? HttpResult.ok() : HttpResult.error("司机信息新增失败!");
         } else {
             /**唯一性交易**/
             List<Map<String, Object>> drivers = driverDao.findList(new HashMap(){{ put("phone", params.getPhone()); }});
@@ -203,7 +229,7 @@ public class KwfDriverService {
 
             /**更新**/
             int count = driverDao.updateById(params);
-            return count > 0 ? null : HttpResult.error("司机信息修改失败!");
+            return count > 0 ? HttpResult.ok() : HttpResult.error("司机信息修改失败!");
         }
     }
 
@@ -222,11 +248,12 @@ public class KwfDriverService {
         KwfDriverCard card = KwfDriverCardDao.findByDriverId(params.getDriverId());
         if (card == null) {
             int count = KwfDriverCardDao.insert(driverCard);
+            return count > 0 ? HttpResult.ok("身份证信息更新成功!") : HttpResult.error("身份证信息更新失败!");
         } else {
             driverCard.setId(card.getId());
             int count = KwfDriverCardDao.updateById(driverCard);
+            return count > 0 ? HttpResult.ok("身份证信息修改成功!") : HttpResult.error("身份证信息修改失败!");
         }
-        return null;
     }
 
     /**
@@ -254,11 +281,12 @@ public class KwfDriverService {
         KwfDriverLicense license = KwfDriverLicenseDao.findByDriverId(params.getDriverId());
         if (license == null) {
             int 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("司机驾驶证信息修改失败!");
         }
-        return null;
     }
 
     /**
@@ -286,11 +314,12 @@ public class KwfDriverService {
         KwfDriverQualification qualification = KwfDriverQualificationDao.findByDriverId(params.getDriverId());
         if (qualification == null) {
             int count = KwfDriverQualificationDao.insert(driverQual);
+            return count > 0 ? HttpResult.ok("司机从业资格证信息更新成功!") : HttpResult.error("司机从业资格证信息更新失败!");
         } else {
             driverQual.setId(qualification.getId());
             int count = KwfDriverQualificationDao.updateById(driverQual);
+            return count > 0 ? HttpResult.ok("司机从业资格证信息修改成功!") : HttpResult.error("司机从业资格证信息修改失败!");
         }
-        return null;
     }
 
     /**
@@ -310,12 +339,10 @@ public class KwfDriverService {
      * @date 2023/7/7
      **/
     public void driverEntEdit(KwfDriver params) {
-        if (StringUtils.isBlank(params.getId())) {
-            KwfDriverEnt driverEnt = new KwfDriverEnt();
-            driverEnt.setDriverId(params.getId());
-            driverEnt.setEntId(params.getEntId());
-            driverEntDao.insert(driverEnt);
-        }
+        KwfDriverEnt driverEnt = new KwfDriverEnt();
+        driverEnt.setDriverId(params.getId());
+        driverEnt.setEntId(params.getEntId());
+        driverEntDao.insert(driverEnt);
     }
 
 }

+ 7 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverEntMapper.xml

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.fleet.dao.KwfDriverEntMapper">
 
+    <select id="findByDriverEnt" resultType="com.sckw.fleet.model.KwfDriverEnt" parameterType="com.sckw.fleet.model.KwfDriverEnt" >
+        SELECT
+            id, ent_id entId, driver_id driverId, remark, status, create_by createBy,
+            create_time createTime, update_by updateBy, update_time updateTime from kwf_driver_ent
+        where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR} and driver_id = #{driverId, jdbcType=VARCHAR}
+    </select>
+
 </mapper>

+ 35 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml

@@ -37,6 +37,41 @@
         ORDER BY dr.create_time desc
     </select>
 
+    <select id="findPageV1" 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,
+        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
+        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_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}
+        </if>
+        <if test="params.name != null and params.name != ''">
+            and dr.name = #{params.name, jdbcType=VARCHAR}
+        </if>
+        <if test="params.idcard != null and params.idcard != ''">
+            and dr.idcard = #{params.idcard, jdbcType=VARCHAR}
+        </if>
+        <if test="params.phone != null and params.phone != ''">
+            and dr.phone = #{params.phone, jdbcType=VARCHAR}
+        </if>
+        <if test="params.keywords != null and params.keywords != ''">
+            and (
+            dr.name like concat('%',#{params.keyWords},'%')
+            or dr.idcard like concat('%',#{params.keyWords},'%')
+            or dr.phone like concat('%',#{params.keyWords},'%')
+            )
+        </if>
+        ORDER BY dr.create_time desc
+    </select>
+
     <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
         SELECT
             dr.id, name, phone, salt, password, idcard, total_complete totalComplete,

+ 8 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckEntMapper.xml

@@ -2,4 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.fleet.dao.KwfTruckEntMapper">
 
+    <select id="findByTruckEnt" resultType="com.sckw.fleet.model.KwfTruckEnt" parameterType="com.sckw.fleet.model.KwfTruckEnt" >
+        SELECT
+        id, ent_id entId, driver_id driverId, remark, status, create_by createBy,
+        create_time createTime, update_by updateBy, update_time updateTime from kwf_driver_ent
+        where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR} and driver_id = #{driverId, jdbcType=VARCHAR}
+    </select>
+
+
 </mapper>

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

@@ -55,6 +55,9 @@ public class KwFleetController {
         Pageable pageable = PageRequest.of(0, 2);
         Page<SckwTradeOrder> all3 = tradeOrderRepository.findAll(pageable);
         List<SckwTradeOrder> content = all3.getContent();
+        for (SckwTradeOrder stu : content) {
+            System.out.println(stu);
+        }
 
         return HttpResult.ok(content);
     }