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 4a0beb3..4db2df7 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 @@ -88,7 +88,6 @@ public class CarEntity extends BaseEntity { @ApiModelProperty("保养状态") private String maintenanceStatus; - @NotNull @ApiModelProperty("车辆管理人id") private Long managerId; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java index 34776c9..486b76f 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java @@ -58,6 +58,9 @@ public class DeviceEntity extends BaseEntity { @ApiModelProperty("上次检验日期") private Date inspectionLastTime; + @ApiModelProperty("设备管理人id") + private Long managerId; + @Size(max = 50, message = "设备管理人长度不能超过50") @ApiModelProperty("设备管理人") private String manager; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java index da9328f..1aeae76 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java @@ -24,6 +24,9 @@ public class HygieneRecordDetailVO { @ApiModelProperty("检查人") private String checkUser; + @ApiModelProperty("检查时间") + private Date checkTime; + @ApiModelProperty("责任区id") private String hygieneZoneIds; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java index 768b523..c507455 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java @@ -43,7 +43,7 @@ public class DeviceController extends BladeController { @PostMapping("/update") @ApiOperation(value = "修改") @ApiOperationSupport(order = 2) - public R update(DeviceEntity deviceEntity) { + public R update(@Valid @RequestBody DeviceEntity deviceEntity) { return R.status(deviceService.updateById(deviceEntity)); } @@ -63,8 +63,8 @@ public class DeviceController extends BladeController { @GetMapping("/page") @ApiImplicitParams({ - @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "plateNumber", value = "车牌号", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "name", value = "设备名称", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "deviceStatus", value = "设备状态", dataType = "query", paramType = "string") }) @ApiOperation(value = "分页") @ApiOperationSupport(order = 5) 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 e386ef5..dc9baef 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 @@ -12,9 +12,13 @@ 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; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -29,6 +33,7 @@ import java.util.List; * @author liwen * @date 2024-01-11 */ +@Slf4j @Component public class CarJob { @@ -44,6 +49,9 @@ public class CarJob { @Autowired ISysClient sysClient; + @Autowired + IUserClient userClient; + /** * 车辆台账自动变更 */ @@ -92,10 +100,16 @@ public class CarJob { * @param carEntity 车辆实体类 */ private void sendUninsuredMessage(CarEntity carEntity) { + if (carEntity.getManagerId() == null) { + log.error("系统无该用户信息,推送车保过期消息失败"); + return; + } + // 查询用户 + R userRes = userClient.userInfoById(carEntity.getManagerId()); + User user = userRes.getData(); BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); - String deptId = AuthUtil.getDeptId(); - if (StringUtils.isNotEmpty(deptId)) { - Long id = Long.valueOf(deptId); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); businessMessageDTO.setDeptId(id); businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); businessMessageDTO.setBusinessKey("车保到期"); @@ -115,10 +129,16 @@ public class CarJob { * @param carEntity 车辆实体类 */ private void sendUnMaintainedMessage(CarEntity carEntity) { + if (carEntity.getManagerId() == null) { + log.error("系统无该用户信息,推送维保过期消息失败"); + return; + } + // 查询用户 + R userRes = userClient.userInfoById(carEntity.getManagerId()); + User user = userRes.getData(); BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); - String deptId = AuthUtil.getDeptId(); - if (StringUtils.isNotEmpty(deptId)) { - Long id = Long.valueOf(deptId); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); businessMessageDTO.setDeptId(id); businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); businessMessageDTO.setBusinessKey("维保到期"); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java index 2e5c414..81b4964 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java @@ -1,11 +1,20 @@ package com.hnac.hzims.safeproduct.jobs; +import com.hnac.hzims.common.constant.CommonConstant; +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.DeviceEntity; import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; import com.hnac.hzims.safeproduct.service.IDeviceService; 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.tool.api.R; import org.springblade.core.tool.utils.DateUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -19,12 +28,22 @@ import java.util.List; * @author liwen * @date 2024-01-16 */ +@Slf4j @Component public class DeviceJob { @Autowired IDeviceService deviceService; + @Autowired + IUserClient userClient; + + @Autowired + ISysClient sysClient; + + @Autowired + IMessageClient messageClient; + @XxlJob("autoChangeDeviceStatus") public ReturnT autoChangeDeviceStatus(String param) { // 获取时间范围 @@ -37,9 +56,41 @@ public class DeviceJob { if (CollectionUtils.isEmpty(list)) { return ReturnT.SUCCESS; } - list.forEach(e -> e.setDeviceStatus(DeviceStatusEnum.EXPIRED.getValue())); + list.forEach(device -> { + device.setDeviceStatus(DeviceStatusEnum.EXPIRED.getValue()); + sendExpiredMessage(device); + }); // 更新状态 boolean update = deviceService.updateBatchById(list); return update ? ReturnT.SUCCESS : ReturnT.FAIL; } + + /** + * 推送设备过期消息 + * @param deviceEntity 特种设备实体类 + */ + private void sendExpiredMessage(DeviceEntity deviceEntity) { + if (deviceEntity.getManagerId() == null) { + log.error("系统无该用户信息,推送设备过期消息失败"); + return; + } + // 查询用户 + R userRes = userClient.userInfoById(deviceEntity.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(deviceEntity.getId()); + businessMessageDTO.setSubject("设备到期通知"); + businessMessageDTO.setContent("您所管理的特种设备" + deviceEntity.getName() + "已到期,请尽快进行检验。"); + businessMessageDTO.setUserIds(String.valueOf(deviceEntity.getManagerId())); + businessMessageDTO.setCreateUser(deviceEntity.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMaintenanceMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMaintenanceMapper.xml index e9f9afc..4f71d3e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMaintenanceMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMaintenanceMapper.xml @@ -5,7 +5,7 @@ SELECT code, actual_end_time, check_user, hygiene_zone_ids, check_result,comprehensive_score, week_num, - img_path, hygiene_plan_id + img_path, hygiene_plan_id, check_time FROM hzims_hygiene_record WHERE 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 9672634..ad95b50 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 @@ -99,7 +99,7 @@ public class CarMaintenanceServiceImpl extends ServiceImpl implements queryWrapper.lambda().eq(CarEntity::getPlateNumber, carEntity.getPlateNumber()); CarEntity car = this.getOne(queryWrapper); if (car == null) { + carEntity.setMaintenanceStatus(CarMaintenanceStatusEnum.UNMAINTAINED.getValue()); return R.status(this.save(carEntity)); } return R.fail("车牌号已存在"); diff --git a/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql b/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql index 054a765..f315d37 100644 --- a/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql +++ b/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql @@ -240,7 +240,7 @@ CREATE TABLE `hzims_car` ( `maintenance_next_time` date DEFAULT NULL COMMENT '下期保养时间', `maintenance_mileage` decimal(10, 2) DEFAULT NULL COMMENT '保养里程', `maintenance_status` varchar(50) DEFAULT NULL COMMENT '保养状态', - `manager_id` bigint(20) NOT NULL COMMENT '车辆管理人id', + `manager_id` bigint(20) DEFAULT NULL COMMENT '车辆管理人id', `manager` varchar(50) NOT NULL COMMENT '车辆管理人', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '车辆图片', `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '车辆附件', @@ -345,7 +345,7 @@ CREATE TABLE `hzims_device` ( `name` varchar(50) NOT NULL COMMENT '设备名称', `type` varchar(50) NOT NULL DEFAULT '' COMMENT '规格型号', `code` varchar(50) NOT NULL COMMENT '编码', - `quality_cerfiticate_no` varchar(255) NOT NULL DEFAULT '' COMMENT '产品合格证号', + `quality_certificate_no` varchar(255) NOT NULL DEFAULT '' COMMENT '产品合格证号', `production_time` date DEFAULT NULL COMMENT '生产日期', `used_time` date DEFAULT NULL COMMENT '使用日期', `used_location` varchar(255) NOT NULL DEFAULT '' COMMENT '使用地点', @@ -353,6 +353,7 @@ CREATE TABLE `hzims_device` ( `inspection_current_time` date DEFAULT NULL COMMENT '本次检验日期', `inspection_next_time` date DEFAULT NULL COMMENT '下次检验日期', `inspection_last_time` date DEFAULT NULL COMMENT '上次检验日期', + `manager_id` bigint(20) DEFAULT NULL COMMENT '设备管理人id', `manager` varchar(50) NOT NULL DEFAULT '' COMMENT '设备管理人', `device_status` varchar(20) NOT NULL DEFAULT 'NORMAL' COMMENT '设备状态', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', diff --git a/hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx b/hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx index 07d4aa6..80ba5d7 100644 Binary files a/hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx and b/hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx differ diff --git a/hzims-service/safeproduct/src/main/resources/template/车辆维保记录单.docx b/hzims-service/safeproduct/src/main/resources/template/车辆维保记录单.docx index 68f1f4e..5d1dd59 100644 Binary files a/hzims-service/safeproduct/src/main/resources/template/车辆维保记录单.docx and b/hzims-service/safeproduct/src/main/resources/template/车辆维保记录单.docx differ