diff --git a/hzims-service-api/safeproduct-api/pom.xml b/hzims-service-api/safeproduct-api/pom.xml index 1d2c5b7..7543bda 100644 --- a/hzims-service-api/safeproduct-api/pom.xml +++ b/hzims-service-api/safeproduct-api/pom.xml @@ -32,6 +32,12 @@ org.springblade blade-dict-api + + + cn.afterturn + easypoi-spring-boot-starter + ${easpoi.version} + jar diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarAnnualInspectionEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarAnnualInspectionEntity.java new file mode 100644 index 0000000..8f64585 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarAnnualInspectionEntity.java @@ -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; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java index 4db2df7..0a2b7c0 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java @@ -58,10 +58,14 @@ public class CarEntity extends BaseEntity { @ApiModelProperty("下期缴车保时间") private Date insurancePayNextTime; + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("上期年检时间") + private Date lastAnnualInspectionTime; + @NotNull @JsonFormat(pattern = "yyyy-MM-dd") - @ApiModelProperty("年检时间") - private Date annualInspectionTime; + @ApiModelProperty("下期年检时间") + private Date nextAnnualInspectionTime; @NotNull @Size(max = 50, message = "年检状态长度不能超过50") diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarInsuranceEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarInsuranceEntity.java new file mode 100644 index 0000000..b7172c4 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarInsuranceEntity.java @@ -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; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/CarAnnualInspectionStatusEnum.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/CarAnnualInspectionStatusEnum.java new file mode 100644 index 0000000..1338ecf --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/CarAnnualInspectionStatusEnum.java @@ -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; + } +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarAnnualInspectionPageVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarAnnualInspectionPageVO.java new file mode 100644 index 0000000..708dafc --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarAnnualInspectionPageVO.java @@ -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; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarInsurancePageVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarInsurancePageVO.java new file mode 100644 index 0000000..5035121 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarInsurancePageVO.java @@ -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; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java index 5eeaf3b..d83c0c7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java @@ -102,7 +102,7 @@ public class OperAccessLibraryController extends BladeController { @ApiOperation(value = "检修库导入") @ApiOperationSupport(order = 7) @PostMapping(value = "/import") - public void libraryImport(@RequestParam("library") MultipartFile multipartFile) { + public void libraryImport(@RequestParam MultipartFile multipartFile) { service.libraryImport(multipartFile); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx index 6c76782..db66ce3 100644 Binary files a/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx and b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx differ diff --git a/hzims-service/safeproduct/pom.xml b/hzims-service/safeproduct/pom.xml index ac33427..43b1806 100644 --- a/hzims-service/safeproduct/pom.xml +++ b/hzims-service/safeproduct/pom.xml @@ -151,6 +151,12 @@ system ${project.basedir}/lib/aspose-words-15.8.0-jdk16.jar + + + cn.afterturn + easypoi-spring-boot-starter + ${easpoi.version} + diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java index e977e2b..5a1aa23 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java @@ -6,13 +6,8 @@ import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.dto.CarCheckRecordDTO; import com.hnac.hzims.safeproduct.dto.CarMaintenanceConfirmationDTO; import com.hnac.hzims.safeproduct.dto.CarUsedRecordConfirmationDTO; -import com.hnac.hzims.safeproduct.entity.CarEntity; -import com.hnac.hzims.safeproduct.entity.CarMaintenanceEntity; -import com.hnac.hzims.safeproduct.entity.CarUsedRecordEntity; -import com.hnac.hzims.safeproduct.service.ICarCheckRecordService; -import com.hnac.hzims.safeproduct.service.ICarMaintenanceService; -import com.hnac.hzims.safeproduct.service.ICarService; -import com.hnac.hzims.safeproduct.service.ICarUsedRecordService; +import com.hnac.hzims.safeproduct.entity.*; +import com.hnac.hzims.safeproduct.service.*; import com.hnac.hzims.safeproduct.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -49,6 +44,10 @@ public class CarController extends BladeController { private final ICarCheckRecordService carCheckRecordService; + private final ICarAnnualInspectionService carAnnualInspectionService; + + private final ICarInsuranceService carInsuranceService; + @PostMapping("/saveCar") @ApiOperation(value = "新增车辆") @ApiOperationSupport(order = 1) @@ -263,4 +262,85 @@ public class CarController extends BladeController { public void exportCarMilesData(@ApiIgnore @RequestParam Map param, Query query, HttpServletResponse response) { carService.exportCarMilesData(param, query, response); } + + @PostMapping("/saveCarAnnualInspection") + @ApiOperation(value = "新增年检记录") + @ApiOperationSupport(order = 28) + public R saveCarAnnualInspection(@Valid @RequestBody CarAnnualInspectionEntity carAnnualInspectionEntity) { + return R.status(carAnnualInspectionService.saveCarAnnualInspection(carAnnualInspectionEntity)); + } + + @PostMapping("/updateCarAnnualInspection") + @ApiOperation(value = "修改年检记录") + @ApiOperationSupport(order = 29) + public R updateCarAnnualInspection(@Valid @RequestBody CarAnnualInspectionEntity carAnnualInspectionEntity) { + return R.status(carAnnualInspectionService.updateCarAnnualInspection(carAnnualInspectionEntity)); + } + + @PostMapping("/removeCarAnnualInspection") + @ApiOperation(value = "删除年检记录") + @ApiOperationSupport(order = 30) + public R removeCarAnnualInspection(@RequestParam Long id) { + return R.status(carAnnualInspectionService.removeById(id)); + } + + @GetMapping("/carAnnualInspectionDetail") + @ApiOperation(value = "年检记录详情") + @ApiOperationSupport(order = 31) + public R carAnnualInspectionDetail(@RequestParam Long id) { + return R.data(carAnnualInspectionService.getById(id)); + } + + @GetMapping("/carAnnualInspectionPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "carId", value = "车辆id", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "annualInspectionTime", value = "年检时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "年检记录分页") + @ApiOperationSupport(order = 32) + public R> carAnnualInspectionPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = carAnnualInspectionService.getCarAnnualInspectionPage(param, query); + return R.data(page); + } + + @PostMapping("/saveCarInsurance") + @ApiOperation(value = "新增车保记录") + @ApiOperationSupport(order = 33) + public R saveCarInsurance(@Valid @RequestBody CarInsuranceEntity carInsuranceEntity) { + return R.status(carInsuranceService.saveCarCheckRecord(carInsuranceEntity)); + } + + @PostMapping("/updateCarInsurance") + @ApiOperation(value = "修改车保记录") + @ApiOperationSupport(order = 34) + public R updateCarInsurance(@Valid @RequestBody CarInsuranceEntity carInsuranceEntity) { + return R.status(carInsuranceService.updateCarCheckRecord(carInsuranceEntity)); + } + + @PostMapping("/removeCarInsurance") + @ApiOperation(value = "删除车保记录") + @ApiOperationSupport(order = 35) + public R removeCarInsurance(@RequestParam Long id) { + return R.status(carInsuranceService.removeById(id)); + } + + @GetMapping("/carInsuranceDetail") + @ApiOperation(value = "车保记录详情") + @ApiOperationSupport(order = 36) + public R carInsuranceDetail(@RequestParam Long id) { + return R.data(carInsuranceService.getById(id)); + } + + @GetMapping("/carInsurancePage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "carId", value = "车辆id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "车保记录分页") + @ApiOperationSupport(order = 37) + public R> carInsurancePage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = carInsuranceService.getCarInsurancePage(param, query); + return R.data(page); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java index dc9baef..aaa9416 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java @@ -5,15 +5,15 @@ import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.safeproduct.entity.CarEntity; -import com.hnac.hzims.safeproduct.entity.CarMaintenanceEntity; +import com.hnac.hzims.safeproduct.enums.CarAnnualInspectionStatusEnum; import com.hnac.hzims.safeproduct.enums.CarInsuranceStatusEnum; import com.hnac.hzims.safeproduct.enums.CarMaintenanceStatusEnum; +import com.hnac.hzims.safeproduct.service.ICarInsuranceService; import com.hnac.hzims.safeproduct.service.ICarMaintenanceService; import com.hnac.hzims.safeproduct.service.ICarService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.system.feign.ISysClient; @@ -52,6 +52,9 @@ public class CarJob { @Autowired IUserClient userClient; + @Autowired + ICarInsuranceService carInsuranceService; + /** * 车辆台账自动变更 */ @@ -66,33 +69,37 @@ public class CarJob { // 车保状态变更 List uninsuredCarList = carService.getCarListByInsuranceTime(today, yesterday); if (!CollectionUtils.isEmpty(uninsuredCarList)) { - uninsuredCarList.forEach(car -> { - car.setInsuranceStatus(CarInsuranceStatusEnum.UNINSURED.getValue()); - sendUninsuredMessage(car); - }); + uninsuredCarList.forEach(car -> car.setInsuranceStatus(CarInsuranceStatusEnum.UNINSURED.getValue())); boolean insuranceUpdate = carService.updateBatchById(uninsuredCarList); if (!insuranceUpdate) { return ReturnT.FAIL; } + // 变更成功则推送消息 + uninsuredCarList.forEach(this::sendUninsuredMessage); } // 维保状态变更 - List unMaintainedCarList = carService.getCarListByMaintenanceTime(today, yesterday); - if (CollectionUtils.isEmpty(unMaintainedCarList)) { - return ReturnT.SUCCESS; + List unmaintainedCarList = carService.getCarListByMaintenanceTime(today, yesterday); + if (!CollectionUtils.isEmpty(unmaintainedCarList)) { + unmaintainedCarList.forEach(car -> car.setMaintenanceStatus(CarMaintenanceStatusEnum.UNMAINTAINED.getValue())); + boolean maintenanceUpdate = carService.updateBatchById(unmaintainedCarList); + if (!maintenanceUpdate) { + return ReturnT.FAIL; + } + // 变更成功则推送消息 + unmaintainedCarList.forEach(this::sendUnmaintainedMessage); } - unMaintainedCarList.forEach(car -> { - // 查询车辆在两次维保时间内是否有确认过的维保记录 - String lastMaintenanceTime = DateUtil.format(car.getMaintenanceLastTime(), DateUtil.PATTERN_DATE); - String nextMaintenanceTime = DateUtil.format(car.getMaintenanceNextTime(), DateUtil.PATTERN_DATE); - List carMaintenanceList = carMaintenanceService.getCarMaintenanceByCarIdAndTime(car.getId(), - lastMaintenanceTime, nextMaintenanceTime); - // 若无维保记录,说明在规定范围内未进行有效维保 - if (CollectionUtils.isEmpty(carMaintenanceList)) { - car.setMaintenanceStatus(CarMaintenanceStatusEnum.UNMAINTAINED.getValue()); - sendUnMaintainedMessage(car); + // 年检状态变更 + List uninspectedCarList = carService.getCarListByAnnualInspectionTime(today, yesterday); + if (!CollectionUtils.isEmpty(uninspectedCarList)) { + uninspectedCarList.forEach(car -> car.setAnnualInspectionStatus(CarAnnualInspectionStatusEnum.UNFINISHED.getValue())); + boolean inspectionUpdate = carService.updateBatchById(uninspectedCarList); + if (!inspectionUpdate) { + return ReturnT.FAIL; } - }); - return carService.updateBatchById(unMaintainedCarList) ? ReturnT.SUCCESS : ReturnT.FAIL; + // 变更成功则推送消息 + uninspectedCarList.forEach(this::sendUninspectedMessage); + } + return ReturnT.SUCCESS; } /** @@ -128,7 +135,7 @@ public class CarJob { * 推送维保过期消息 * @param carEntity 车辆实体类 */ - private void sendUnMaintainedMessage(CarEntity carEntity) { + private void sendUnmaintainedMessage(CarEntity carEntity) { if (carEntity.getManagerId() == null) { log.error("系统无该用户信息,推送维保过期消息失败"); return; @@ -152,4 +159,33 @@ public class CarJob { } messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); } + + /** + * 推送年检过期消息 + * @param carEntity 车辆实体类 + */ + private void sendUninspectedMessage(CarEntity carEntity) { + if (carEntity.getManagerId() == null) { + log.error("系统无该用户信息,推送年检过期消息失败"); + return; + } + // 查询用户 + R userRes = userClient.userInfoById(carEntity.getManagerId()); + User user = userRes.getData(); + BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); + businessMessageDTO.setDeptId(id); + businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); + businessMessageDTO.setBusinessKey("年检到期"); + businessMessageDTO.setBusinessClassify("system"); + businessMessageDTO.setTaskId(carEntity.getId()); + businessMessageDTO.setSubject("年检到期通知"); + businessMessageDTO.setContent("您所管理的车辆" + carEntity.getPlateNumber() + "年检已过期,请及时进行年检。"); + businessMessageDTO.setUserIds(String.valueOf(carEntity.getManagerId())); + businessMessageDTO.setCreateUser(carEntity.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarAnnualInspectionMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarAnnualInspectionMapper.java new file mode 100644 index 0000000..9c60d16 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarAnnualInspectionMapper.java @@ -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 { + + /** + * 年检记录分页 + * @param param 入参 + * @param page 分页类 + * @return 年检记录数据 + */ + IPage getCarAnnualInspectionPage(IPage page, Map param); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarAnnualInspectionMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarAnnualInspectionMapper.xml new file mode 100644 index 0000000..7af47db --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarAnnualInspectionMapper.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarInsuranceMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarInsuranceMapper.java new file mode 100644 index 0000000..d5c8995 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarInsuranceMapper.java @@ -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 { + + /** + * 车保记录页面 + * @param param 入参 + * @param page 分页类 + * @return 车保记录数据 + */ + IPage getCarInsurancePage(IPage page, Map param); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarInsuranceMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarInsuranceMapper.xml new file mode 100644 index 0000000..1e3835d --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarInsuranceMapper.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java new file mode 100644 index 0000000..0ed28d1 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java @@ -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 { + + /** + * 新增年检记录 + * @param carAnnualInspectionEntity 年检记录实体类 + * @return true-成功,false-失败 + */ + boolean saveCarAnnualInspection(CarAnnualInspectionEntity carAnnualInspectionEntity); + + /** + * 修改年检记录 + * @param carAnnualInspectionEntity 年检记录实体类 + * @return true-成功,false-失败 + */ + boolean updateCarAnnualInspection(CarAnnualInspectionEntity carAnnualInspectionEntity); + + /** + * 年检记录分页 + * @param param 入参 + * @param query 分页类 + * @return 年检记录数据 + */ + IPage getCarAnnualInspectionPage(Map param, Query query); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java new file mode 100644 index 0000000..d2be60e --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java @@ -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 { + + /** + * 新增车保记录 + * @param carInsuranceEntity 车保记录实体类 + * @return true-成功,false-失败 + */ + boolean saveCarCheckRecord(CarInsuranceEntity carInsuranceEntity); + + /** + * 修改车保记录 + * @param carInsuranceEntity 车保记录实体类 + * @return true-成功,false-失败 + */ + boolean updateCarCheckRecord(CarInsuranceEntity carInsuranceEntity); + + /** + * 车保记录页面 + * @param param 入参 + * @param query 分页类 + * @return 车保记录数据 + */ + IPage getCarInsurancePage(Map param, Query query); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java index 2c6f46e..7f6531a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java @@ -58,15 +58,6 @@ public interface ICarMaintenanceService extends IService { void exportCarMaintenanceData(Long id, HttpServletResponse response); /** - * 根据车辆id和时间查询相关维保记录 - * @param carId 车辆id - * @param lastTime 上次维保时间 - * @param nextTime 下次维保时间 - * @return 车辆维保记录列表 - */ - List getCarMaintenanceByCarIdAndTime(Long carId, String lastTime, String nextTime); - - /** * 更新车辆维保记录 * @param carMaintenanceEntity 车辆维保记录实体类 * @return 结果封装类 diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java index 21679b1..3ea3522 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java @@ -72,4 +72,12 @@ public interface ICarService extends IService { * @param response 响应类 */ void exportCarMilesData(Map param, Query query, HttpServletResponse response); + + /** + * 根据年检时间查询车辆列表 + * @param today 当天 + * @param yesterday 昨天 + * @return 车辆列表数据 + */ + List getCarListByAnnualInspectionTime(String today, String yesterday); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java new file mode 100644 index 0000000..10be8b6 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java @@ -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 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 getCarAnnualInspectionPage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + return baseMapper.getCarAnnualInspectionPage(page, param); + } + + /** + * 查询是否存在同月编号 + * @param currentMonth 当月 + * @return 存在则返回上一编号,否则返回null + */ + private String getLastCode(String currentMonth) { + List list = getCarAnnualInspectionByMonth(currentMonth); + if (CollectionUtils.isEmpty(list)) { + return null; + } + return list.get(0).getCode(); + } + + /** + * 查询当月年检记录 + * @param month 当月 + * @return 当月年检记录数据表 + */ + private List getCarAnnualInspectionByMonth(String month) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().like(CarAnnualInspectionEntity::getCreateTime, month) + .orderByDesc(CarAnnualInspectionEntity::getCode); + return this.list(queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java new file mode 100644 index 0000000..cd132ef --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java @@ -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 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 getCarInsurancePage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + return baseMapper.getCarInsurancePage(page, param); + } + + /** + * 查询是否存在同月编号 + * @param currentMonth 当月 + * @return 存在则返回上一编号,否则返回null + */ + private String getLastCode(String currentMonth) { + List list = getCarInsuranceByMonth(currentMonth); + if (CollectionUtils.isEmpty(list)) { + return null; + } + return list.get(0).getCode(); + } + + /** + * 查询当月年保记录 + * @param month 当月 + * @return 当月年保记录数据表 + */ + private List getCarInsuranceByMonth(String month) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().like(CarInsuranceEntity::getCreateTime, month) + .orderByDesc(CarInsuranceEntity::getCode); + return this.list(queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java index ad95b50..a2e3a32 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java @@ -52,6 +52,8 @@ public class CarMaintenanceServiceImpl extends ServiceImpl getCarMaintenanceByCarIdAndTime(Long carId, String lastTime, String nextTime) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(CarMaintenanceEntity::getCarId, carId) - .ge(CarMaintenanceEntity::getEndTime, lastTime) - .le(CarMaintenanceEntity::getEndTime, nextTime) - .eq(CarMaintenanceEntity::getMaintenanceStatus, CarMaintenanceStatusEnum.MAINTAINED.getValue()) - .orderByDesc(CarMaintenanceEntity::getCreateTime); - return this.list(queryWrapper); - } - - /** * 更新车辆维保记录 */ @Override public R updateCarMaintenance(CarMaintenanceEntity carMaintenanceEntity) { String maintenanceStatus = carMaintenanceEntity.getMaintenanceStatus(); - if (maintenanceStatus.equals(CarMaintenanceStatusEnum.MAINTAINED.getValue())) { + if (maintenanceStatus != null && maintenanceStatus.equals(CarMaintenanceStatusEnum.MAINTAINED.getValue())) { return R.fail("已确认的维保记录无法被修改"); } return R.status(this.updateById(carMaintenanceEntity)); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index 6c2512e..9e95a23 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -253,4 +253,15 @@ public class CarServiceImpl extends ServiceImpl implements } } } + + /** + * 根据年检时间查询车辆列表 + */ + @Override + public List getCarListByAnnualInspectionTime(String today, String yesterday) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().lt(CarEntity::getNextAnnualInspectionTime, today) + .ge(CarEntity::getNextAnnualInspectionTime, yesterday); + return this.list(queryWrapper); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java index 0fbfb74..0de32ed 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java @@ -101,7 +101,7 @@ public class CarUsedRecordServiceImpl extends ServiceImpl