haungxing
10 months ago
26 changed files with 873 additions and 59 deletions
@ -0,0 +1,54 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
import javax.validation.constraints.Size; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@TableName("hzims_car_annual_inspection") |
||||||
|
@ApiModel(value = "年检记录实体类") |
||||||
|
public class CarAnnualInspectionEntity extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("车辆id") |
||||||
|
private Long carId; |
||||||
|
|
||||||
|
@Size(max = 50, message = "编码长度不能超过50") |
||||||
|
@ApiModelProperty("编码") |
||||||
|
private String code; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||||
|
@ApiModelProperty("年检时间") |
||||||
|
private Date annualInspectionTime; |
||||||
|
|
||||||
|
@Size(max = 255, message = "年检地点长度不能超过255") |
||||||
|
@ApiModelProperty("年检地点") |
||||||
|
private String location; |
||||||
|
|
||||||
|
@ApiModelProperty("年检费用") |
||||||
|
private Long cost; |
||||||
|
|
||||||
|
@Size(max = 50, message = "年间负责人长度不能超过50") |
||||||
|
@ApiModelProperty("年检负责人") |
||||||
|
private String inspectionManager; |
||||||
|
|
||||||
|
@Size(max = 1000, message = "年间照片长度不能超过1000") |
||||||
|
@ApiModelProperty("年检照片") |
||||||
|
private String imgPath; |
||||||
|
|
||||||
|
@TableField(exist = false) |
||||||
|
@ApiModelProperty("下次年检时间") |
||||||
|
private Date nextAnnualInspectionTime; |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
import javax.validation.constraints.Size; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@TableName("hzims_car_insurance") |
||||||
|
@ApiModel(value = "车保记录实体类") |
||||||
|
public class CarInsuranceEntity extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("车辆id") |
||||||
|
private Long carId; |
||||||
|
|
||||||
|
@Size(max = 50, message = "编码长度不能超过50") |
||||||
|
@ApiModelProperty("编码") |
||||||
|
private String code; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||||
|
@ApiModelProperty("车保时间") |
||||||
|
private Date insuranceTime; |
||||||
|
|
||||||
|
@Size(max = 255, message = "车保地点长度不能超过255") |
||||||
|
@ApiModelProperty("车保地点") |
||||||
|
private String location; |
||||||
|
|
||||||
|
@ApiModelProperty("车保费用") |
||||||
|
private Long cost; |
||||||
|
|
||||||
|
@Size(max = 50, message = "车保负责人长度不能超过50") |
||||||
|
@ApiModelProperty("车保负责人") |
||||||
|
private String insuranceManager; |
||||||
|
|
||||||
|
@Size(max = 1000, message = "车保照片长度不能超过1000") |
||||||
|
@ApiModelProperty("车保照片") |
||||||
|
private String imgPath; |
||||||
|
|
||||||
|
@TableField(exist = false) |
||||||
|
@ApiModelProperty("下次车保时间") |
||||||
|
private Date nextInsuranceTime; |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.enums; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车辆年检记录状态枚举类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
public enum CarAnnualInspectionStatusEnum { |
||||||
|
|
||||||
|
FINISHED("FINISHED", "已完成"), |
||||||
|
UNFINISHED("UNFINISHED", "未完成"); |
||||||
|
|
||||||
|
private final String value; |
||||||
|
|
||||||
|
private final String desc; |
||||||
|
|
||||||
|
CarAnnualInspectionStatusEnum(String value, String desc) { |
||||||
|
this.value = value; |
||||||
|
this.desc = desc; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDesc() { |
||||||
|
return desc; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "年检记录页面VO类") |
||||||
|
public class CarAnnualInspectionPageVO { |
||||||
|
|
||||||
|
@ApiModelProperty("车辆id") |
||||||
|
private Long carId; |
||||||
|
|
||||||
|
@ApiModelProperty("单位") |
||||||
|
private String unit; |
||||||
|
|
||||||
|
@ApiModelProperty("品牌") |
||||||
|
private String carBrand; |
||||||
|
|
||||||
|
@ApiModelProperty("车牌号") |
||||||
|
private String plateNumber; |
||||||
|
|
||||||
|
@ApiModelProperty("编码") |
||||||
|
private String code; |
||||||
|
|
||||||
|
@ApiModelProperty("年检时间") |
||||||
|
private Date annualInspectionTime; |
||||||
|
|
||||||
|
@ApiModelProperty("年检地点") |
||||||
|
private String location; |
||||||
|
|
||||||
|
@ApiModelProperty("年检费用") |
||||||
|
private Long cost; |
||||||
|
|
||||||
|
@ApiModelProperty("年检负责人") |
||||||
|
private String inspectionManager; |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "年保记录页面VO类") |
||||||
|
public class CarInsurancePageVO { |
||||||
|
|
||||||
|
@ApiModelProperty("车辆id") |
||||||
|
private Long carId; |
||||||
|
|
||||||
|
@ApiModelProperty("单位") |
||||||
|
private String unit; |
||||||
|
|
||||||
|
@ApiModelProperty("品牌") |
||||||
|
private String carBrand; |
||||||
|
|
||||||
|
@ApiModelProperty("车牌号") |
||||||
|
private String plateNumber; |
||||||
|
|
||||||
|
@ApiModelProperty("编码") |
||||||
|
private String code; |
||||||
|
|
||||||
|
@ApiModelProperty("年保时间") |
||||||
|
private Date insuranceTime; |
||||||
|
|
||||||
|
@ApiModelProperty("年保地点") |
||||||
|
private String location; |
||||||
|
|
||||||
|
@ApiModelProperty("年保费用") |
||||||
|
private Long cost; |
||||||
|
|
||||||
|
@ApiModelProperty("年保负责人") |
||||||
|
private String insuranceManager; |
||||||
|
} |
Binary file not shown.
@ -0,0 +1,27 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarAnnualInspectionEntity; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarAnnualInspectionPageVO; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 年检记录Mapper类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface CarAnnualInspectionMapper extends BaseMapper<CarAnnualInspectionEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 年检记录分页 |
||||||
|
* @param param 入参 |
||||||
|
* @param page 分页类 |
||||||
|
* @return 年检记录数据 |
||||||
|
*/ |
||||||
|
IPage<CarAnnualInspectionPageVO> getCarAnnualInspectionPage(IPage<CarAnnualInspectionPageVO> page, Map<String, Object> param); |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarAnnualInspectionMapper"> |
||||||
|
|
||||||
|
<select id="getCarAnnualInspectionPage" |
||||||
|
resultType="com.hnac.hzims.safeproduct.vo.CarAnnualInspectionPageVO"> |
||||||
|
SELECT |
||||||
|
t1.code, t1.annual_inspection_time, t1.location, t1.cost, t1.inspection_manager, t2.unit, t2.car_brand, t2.plate_number |
||||||
|
FROM |
||||||
|
hzims_car_annual_inspection t1 |
||||||
|
LEFT JOIN hzims_car t2 ON t1.car_id = t2.id |
||||||
|
WHERE |
||||||
|
t1.is_deleted = 0 |
||||||
|
<if test = "param.carId != null and param.carId != ''"> |
||||||
|
AND t1.car_id = #{param.carId} |
||||||
|
</if> |
||||||
|
<if test="param.unit != null and param.unit != ''"> |
||||||
|
AND t2.unit like concat('%', #{param.unit}, '%') |
||||||
|
</if> |
||||||
|
<if test="param.annualInspectionTime != null and param.annualInspectionTime != ''"> |
||||||
|
AND t1.annualInspectionTime = #{param.annualInspectionTime} |
||||||
|
</if> |
||||||
|
ORDER BY |
||||||
|
t1.create_time DESC |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,27 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarInsuranceEntity; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarInsurancePageVO; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车保记录Mapper类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface CarInsuranceMapper extends BaseMapper<CarInsuranceEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 车保记录页面 |
||||||
|
* @param param 入参 |
||||||
|
* @param page 分页类 |
||||||
|
* @return 车保记录数据 |
||||||
|
*/ |
||||||
|
IPage<CarInsurancePageVO> getCarInsurancePage(IPage<CarInsurancePageVO> page, Map<String, Object> param); |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarInsuranceMapper"> |
||||||
|
|
||||||
|
<select id="getCarInsurancePage" resultType="com.hnac.hzims.safeproduct.vo.CarInsurancePageVO"> |
||||||
|
SELECT |
||||||
|
t1.code, t1.insurance_time, t1.location, t1.cost, t1.insurance_manager, t2.unit, t2.car_brand, t2.plate_number |
||||||
|
FROM |
||||||
|
hzims_car_insurance t1 |
||||||
|
LEFT JOIN hzims_car t2 ON t1.car_id = t2.id |
||||||
|
WHERE |
||||||
|
t1.is_deleted = 0 |
||||||
|
<if test = "param.carId != null and param.carId != ''"> |
||||||
|
AND t1.car_id = #{param.carId} |
||||||
|
</if> |
||||||
|
<if test="param.unit != null and param.unit != ''"> |
||||||
|
AND t2.unit like concat('%', #{param.unit}, '%') |
||||||
|
</if> |
||||||
|
<if test="param.insuranceTime != null and param.insuranceTime != ''"> |
||||||
|
AND t1.insuranceTime = #{param.insuranceTime} |
||||||
|
</if> |
||||||
|
ORDER BY |
||||||
|
t1.create_time DESC |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,40 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarAnnualInspectionEntity; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarAnnualInspectionPageVO; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 年检记录服务类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
public interface ICarAnnualInspectionService extends IService<CarAnnualInspectionEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增年检记录 |
||||||
|
* @param carAnnualInspectionEntity 年检记录实体类 |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean saveCarAnnualInspection(CarAnnualInspectionEntity carAnnualInspectionEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改年检记录 |
||||||
|
* @param carAnnualInspectionEntity 年检记录实体类 |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean updateCarAnnualInspection(CarAnnualInspectionEntity carAnnualInspectionEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 年检记录分页 |
||||||
|
* @param param 入参 |
||||||
|
* @param query 分页类 |
||||||
|
* @return 年检记录数据 |
||||||
|
*/ |
||||||
|
IPage<CarAnnualInspectionPageVO> getCarAnnualInspectionPage(Map<String, Object> param, Query query); |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarInsuranceEntity; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarInsurancePageVO; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车保记录服务类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
public interface ICarInsuranceService extends IService<CarInsuranceEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增车保记录 |
||||||
|
* @param carInsuranceEntity 车保记录实体类 |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean saveCarCheckRecord(CarInsuranceEntity carInsuranceEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改车保记录 |
||||||
|
* @param carInsuranceEntity 车保记录实体类 |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean updateCarCheckRecord(CarInsuranceEntity carInsuranceEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 车保记录页面 |
||||||
|
* @param param 入参 |
||||||
|
* @param query 分页类 |
||||||
|
* @return 车保记录数据 |
||||||
|
*/ |
||||||
|
IPage<CarInsurancePageVO> getCarInsurancePage(Map<String, Object> param, Query query); |
||||||
|
} |
@ -0,0 +1,119 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service.impl; |
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern; |
||||||
|
import com.alibaba.excel.util.CollectionUtils; |
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarAnnualInspectionEntity; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarEntity; |
||||||
|
import com.hnac.hzims.safeproduct.enums.CarAnnualInspectionStatusEnum; |
||||||
|
import com.hnac.hzims.safeproduct.mapper.CarAnnualInspectionMapper; |
||||||
|
import com.hnac.hzims.safeproduct.service.ICarAnnualInspectionService; |
||||||
|
import com.hnac.hzims.safeproduct.service.ICarService; |
||||||
|
import com.hnac.hzims.safeproduct.utils.BaseUtil; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarAnnualInspectionPageVO; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 年检记录服务实现类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class CarAnnualInspectionServiceImpl extends ServiceImpl<CarAnnualInspectionMapper, CarAnnualInspectionEntity> implements ICarAnnualInspectionService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
ICarService carService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增年检记录 |
||||||
|
*/ |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
@Override |
||||||
|
public boolean saveCarAnnualInspection(CarAnnualInspectionEntity carAnnualInspectionEntity) { |
||||||
|
// 编码
|
||||||
|
// 获取当月时间
|
||||||
|
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date()); |
||||||
|
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); |
||||||
|
// 查询是否存在同月编号
|
||||||
|
String lastCode = getLastCode(currentNormMonth); |
||||||
|
String code = BaseUtil.getUniqueCode("CLNJ", lastCode, currentSimpleMonth); |
||||||
|
carAnnualInspectionEntity.setCode(code); |
||||||
|
boolean save = this.save(carAnnualInspectionEntity); |
||||||
|
// 新增年检记录成功,更新车辆信息
|
||||||
|
if (save) { |
||||||
|
CarEntity carEntity = carService.getById(carAnnualInspectionEntity.getCarId()); |
||||||
|
if (carEntity != null) { |
||||||
|
carEntity.setLastAnnualInspectionTime(carAnnualInspectionEntity.getAnnualInspectionTime()); |
||||||
|
carEntity.setNextAnnualInspectionTime(carAnnualInspectionEntity.getNextAnnualInspectionTime()); |
||||||
|
// 更新年检状态
|
||||||
|
carEntity.setAnnualInspectionStatus(CarAnnualInspectionStatusEnum.FINISHED.getValue()); |
||||||
|
return carService.updateById(carEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改年检记录 |
||||||
|
*/ |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
@Override |
||||||
|
public boolean updateCarAnnualInspection(CarAnnualInspectionEntity carAnnualInspectionEntity) { |
||||||
|
boolean update = this.updateById(carAnnualInspectionEntity); |
||||||
|
// 同步更新车辆的年检时间
|
||||||
|
if (update) { |
||||||
|
CarEntity carEntity = carService.getById(carAnnualInspectionEntity.getCarId()); |
||||||
|
if (carEntity != null) { |
||||||
|
carEntity.setLastAnnualInspectionTime(carAnnualInspectionEntity.getAnnualInspectionTime()); |
||||||
|
carEntity.setNextAnnualInspectionTime(carAnnualInspectionEntity.getNextAnnualInspectionTime()); |
||||||
|
return carService.updateById(carEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 年检记录分页 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public IPage<CarAnnualInspectionPageVO> getCarAnnualInspectionPage(Map<String, Object> param, Query query) { |
||||||
|
IPage<CarAnnualInspectionPageVO> page = new Page<>(query.getCurrent(), query.getSize()); |
||||||
|
return baseMapper.getCarAnnualInspectionPage(page, param); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询是否存在同月编号 |
||||||
|
* @param currentMonth 当月 |
||||||
|
* @return 存在则返回上一编号,否则返回null |
||||||
|
*/ |
||||||
|
private String getLastCode(String currentMonth) { |
||||||
|
List<CarAnnualInspectionEntity> list = getCarAnnualInspectionByMonth(currentMonth); |
||||||
|
if (CollectionUtils.isEmpty(list)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return list.get(0).getCode(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询当月年检记录 |
||||||
|
* @param month 当月 |
||||||
|
* @return 当月年检记录数据表 |
||||||
|
*/ |
||||||
|
private List<CarAnnualInspectionEntity> getCarAnnualInspectionByMonth(String month) { |
||||||
|
QueryWrapper<CarAnnualInspectionEntity> queryWrapper = new QueryWrapper<>(); |
||||||
|
queryWrapper.lambda().like(CarAnnualInspectionEntity::getCreateTime, month) |
||||||
|
.orderByDesc(CarAnnualInspectionEntity::getCode); |
||||||
|
return this.list(queryWrapper); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,116 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service.impl; |
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern; |
||||||
|
import com.alibaba.excel.util.CollectionUtils; |
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarEntity; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarInsuranceEntity; |
||||||
|
import com.hnac.hzims.safeproduct.enums.CarInsuranceStatusEnum; |
||||||
|
import com.hnac.hzims.safeproduct.mapper.CarInsuranceMapper; |
||||||
|
import com.hnac.hzims.safeproduct.service.ICarInsuranceService; |
||||||
|
import com.hnac.hzims.safeproduct.service.ICarService; |
||||||
|
import com.hnac.hzims.safeproduct.utils.BaseUtil; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarInsurancePageVO; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车保记录服务实现类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2024-01-22 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class CarInsuranceServiceImpl extends ServiceImpl<CarInsuranceMapper, CarInsuranceEntity> implements ICarInsuranceService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
ICarService carService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增车保记录 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public boolean saveCarCheckRecord(CarInsuranceEntity carInsuranceEntity) { |
||||||
|
// 编码
|
||||||
|
// 获取当月时间
|
||||||
|
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date()); |
||||||
|
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); |
||||||
|
// 查询是否存在同月编号
|
||||||
|
String lastCode = getLastCode(currentNormMonth); |
||||||
|
String code = BaseUtil.getUniqueCode("CBJL", lastCode, currentSimpleMonth); |
||||||
|
carInsuranceEntity.setCode(code); |
||||||
|
boolean save = this.save(carInsuranceEntity); |
||||||
|
// 新增年检记录成功,更新车辆信息
|
||||||
|
if (save) { |
||||||
|
CarEntity carEntity = carService.getById(carInsuranceEntity.getCarId()); |
||||||
|
if (carEntity != null) { |
||||||
|
carEntity.setInsurancePayLastTime(carInsuranceEntity.getInsuranceTime()); |
||||||
|
carEntity.setInsurancePayNextTime(carInsuranceEntity.getNextInsuranceTime()); |
||||||
|
// 更新年检状态
|
||||||
|
carEntity.setAnnualInspectionStatus(CarInsuranceStatusEnum.INSURED.getValue()); |
||||||
|
return carService.updateById(carEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改车保记录 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public boolean updateCarCheckRecord(CarInsuranceEntity carInsuranceEntity) { |
||||||
|
boolean update = this.updateById(carInsuranceEntity); |
||||||
|
// 同步更新车辆的年检时间
|
||||||
|
if (update) { |
||||||
|
CarEntity carEntity = carService.getById(carInsuranceEntity.getCarId()); |
||||||
|
if (carEntity != null) { |
||||||
|
carEntity.setInsurancePayLastTime(carInsuranceEntity.getInsuranceTime()); |
||||||
|
carEntity.setInsurancePayNextTime(carInsuranceEntity.getNextInsuranceTime()); |
||||||
|
return carService.updateById(carEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 车保记录页面 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public IPage<CarInsurancePageVO> getCarInsurancePage(Map<String, Object> param, Query query) { |
||||||
|
IPage<CarInsurancePageVO> page = new Page<>(query.getCurrent(), query.getSize()); |
||||||
|
return baseMapper.getCarInsurancePage(page, param); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询是否存在同月编号 |
||||||
|
* @param currentMonth 当月 |
||||||
|
* @return 存在则返回上一编号,否则返回null |
||||||
|
*/ |
||||||
|
private String getLastCode(String currentMonth) { |
||||||
|
List<CarInsuranceEntity> list = getCarInsuranceByMonth(currentMonth); |
||||||
|
if (CollectionUtils.isEmpty(list)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return list.get(0).getCode(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询当月年保记录 |
||||||
|
* @param month 当月 |
||||||
|
* @return 当月年保记录数据表 |
||||||
|
*/ |
||||||
|
private List<CarInsuranceEntity> getCarInsuranceByMonth(String month) { |
||||||
|
QueryWrapper<CarInsuranceEntity> queryWrapper = new QueryWrapper<>(); |
||||||
|
queryWrapper.lambda().like(CarInsuranceEntity::getCreateTime, month) |
||||||
|
.orderByDesc(CarInsuranceEntity::getCode); |
||||||
|
return this.list(queryWrapper); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue