From fcc5554456b25398247dfed911be362c0807f46d Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 23 Jan 2024 18:53:04 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=89=B9=E7=A7=8D=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/DeviceEntity.java | 71 ------------ .../safeproduct/entity/SpecialDeviceEntity.java | 71 ++++++++++++ .../entity/SpecialDeviceInspectionEntity.java | 43 ++++++++ .../safeproduct/controller/DeviceController.java | 76 ------------- .../controller/SpecialDeviceController.java | 121 +++++++++++++++++++++ .../com/hnac/hzims/safeproduct/jobs/DeviceJob.java | 96 ---------------- .../hzims/safeproduct/jobs/SpecialDeviceJob.java | 96 ++++++++++++++++ .../hzims/safeproduct/mapper/DeviceMapper.java | 16 --- .../hnac/hzims/safeproduct/mapper/DeviceMapper.xml | 4 - .../mapper/SpecialDeviceInspectionMapper.java | 26 +++++ .../mapper/SpecialDeviceInspectionMapper.xml | 24 ++++ .../safeproduct/mapper/SpecialDeviceMapper.java | 16 +++ .../safeproduct/mapper/SpecialDeviceMapper.xml | 4 + .../hzims/safeproduct/service/IDeviceService.java | 22 ---- .../service/ISpecialDeviceInspectionService.java | 39 +++++++ .../safeproduct/service/ISpecialDeviceService.java | 22 ++++ .../service/impl/DeviceServiceImpl.java | 33 ------ .../impl/SpecialDeviceInspectionServiceImpl.java | 79 ++++++++++++++ .../service/impl/SpecialDeviceServiceImpl.java | 33 ++++++ 19 files changed, 574 insertions(+), 318 deletions(-) delete mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SpecialDeviceController.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceInspectionService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceServiceImpl.java 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 deleted file mode 100644 index 486b76f..0000000 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.hnac.hzims.safeproduct.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -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-12 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@TableName("hzims_device") -@ApiModel(value = "特种设备实体类") -public class DeviceEntity extends BaseEntity { - - @Size(max = 50, message = "设备名称长度不能超过50") - @ApiModelProperty("设备名称") - private String name; - - @Size(max = 50, message = "规格型号长度不能超过50") - @ApiModelProperty("规格型号") - private String type; - - @Size(max = 50, message = "设备编码长度不能超过50") - @ApiModelProperty("设备编码") - private String code; - - @Size(max = 255, message = "产品合格证号长度不能超过255") - @ApiModelProperty("产品合格证号") - private String qualityCertificateNo; - - @ApiModelProperty("生产日期") - private Date productionTime; - - @ApiModelProperty("使用时间") - private Date usedTime; - - @Size(max = 255, message = "使用地点长度不能超过255") - @ApiModelProperty("使用地点") - private String usedLocation; - - @ApiModelProperty("检验周期") - private Integer inspectionPeriod; - - @ApiModelProperty("本次检验日期") - private Date inspectionCurrentTime; - - @ApiModelProperty("下次检验日期") - private Date inspectionNextTime; - - @ApiModelProperty("上次检验日期") - private Date inspectionLastTime; - - @ApiModelProperty("设备管理人id") - private Long managerId; - - @Size(max = 50, message = "设备管理人长度不能超过50") - @ApiModelProperty("设备管理人") - private String manager; - - @Size(max = 20, message = "设备状态长度不能超过20") - @ApiModelProperty("设备状态") - private String deviceStatus; -} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceEntity.java new file mode 100644 index 0000000..5c12f90 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceEntity.java @@ -0,0 +1,71 @@ +package com.hnac.hzims.safeproduct.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +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-12 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_device") +@ApiModel(value = "特种设备实体类") +public class SpecialDeviceEntity extends BaseEntity { + + @Size(max = 50, message = "设备名称长度不能超过50") + @ApiModelProperty("设备名称") + private String name; + + @Size(max = 50, message = "规格型号长度不能超过50") + @ApiModelProperty("规格型号") + private String type; + + @Size(max = 50, message = "设备编码长度不能超过50") + @ApiModelProperty("设备编码") + private String code; + + @Size(max = 255, message = "产品合格证号长度不能超过255") + @ApiModelProperty("产品合格证号") + private String qualityCertificateNo; + + @ApiModelProperty("生产日期") + private Date productionTime; + + @ApiModelProperty("使用时间") + private Date usedTime; + + @Size(max = 255, message = "使用地点长度不能超过255") + @ApiModelProperty("使用地点") + private String usedLocation; + + @ApiModelProperty("检验周期") + private Integer inspectionPeriod; + + @ApiModelProperty("本次检验日期") + private Date inspectionCurrentTime; + + @ApiModelProperty("下次检验日期") + private Date inspectionNextTime; + + @ApiModelProperty("上次检验日期") + private Date inspectionLastTime; + + @ApiModelProperty("设备管理人id") + private Long managerId; + + @Size(max = 50, message = "设备管理人长度不能超过50") + @ApiModelProperty("设备管理人") + private String manager; + + @Size(max = 20, message = "设备状态长度不能超过20") + @ApiModelProperty("设备状态") + private String deviceStatus; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java new file mode 100644 index 0000000..697de96 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java @@ -0,0 +1,43 @@ +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; + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_device_inspection") +@ApiModel(value = "特种设备检验记录实体类") +public class SpecialDeviceInspectionEntity extends BaseEntity { + + @ApiModelProperty("设备id") + private Long deviceId; + + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("检验时间") + private Date inspectionTime; + + @Size(max = 255, message = "检验地点长度不能超过255") + @ApiModelProperty("检验地点") + private String location; + + @Size(max = 1000, message = "检验照片长度不能超过1000") + @ApiModelProperty("检验照片") + private String imgPath; + + @TableField(exist = false) + @ApiModelProperty("下次检验时间") + private Date nextInspectionTime; + + @TableField(exist = false) + @ApiModelProperty("上次检验时间") + private Date lastInspectionTime; +} 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 deleted file mode 100644 index c507455..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.hnac.hzims.safeproduct.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.common.utils.Condition; -import com.hnac.hzims.safeproduct.entity.DeviceEntity; -import com.hnac.hzims.safeproduct.service.IDeviceService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; - -import javax.validation.Valid; -import java.util.Map; - -/** - * 特种设备管理接口类 - * - * @author liwen - * @date 2024-01-12 - */ -@RequestMapping("/device") -@AllArgsConstructor -@RestController -@Api(value = "特种设备", tags = "特种设备接口") -public class DeviceController extends BladeController { - - private final IDeviceService deviceService; - - @PostMapping("/save") - @ApiOperation(value = "新增") - @ApiOperationSupport(order = 1) - public R save(@Valid @RequestBody DeviceEntity deviceEntity) { - return R.status(deviceService.save(deviceEntity)); - } - - @PostMapping("/update") - @ApiOperation(value = "修改") - @ApiOperationSupport(order = 2) - public R update(@Valid @RequestBody DeviceEntity deviceEntity) { - return R.status(deviceService.updateById(deviceEntity)); - } - - @PostMapping("/remove") - @ApiOperation(value = "删除") - @ApiOperationSupport(order = 3) - public R remove(@RequestParam Long id) { - return R.status(deviceService.removeById(id)); - } - - @GetMapping("/detail") - @ApiOperation(value = "详情") - @ApiOperationSupport(order = 4) - public R detail(@RequestParam Long id) { - return R.data(deviceService.getById(id)); - } - - @GetMapping("/page") - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "设备名称", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "deviceStatus", value = "设备状态", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "分页") - @ApiOperationSupport(order = 5) - public R> page(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = deviceService.page(Condition.getPage(query), Condition.getQueryWrapper(param, DeviceEntity.class) - .lambda().orderByDesc(DeviceEntity::getCreateTime)); - return R.data(page); - } -} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SpecialDeviceController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SpecialDeviceController.java new file mode 100644 index 0000000..4013e52 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SpecialDeviceController.java @@ -0,0 +1,121 @@ +package com.hnac.hzims.safeproduct.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceEntity; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceInspectionEntity; +import com.hnac.hzims.safeproduct.service.ISpecialDeviceInspectionService; +import com.hnac.hzims.safeproduct.service.ISpecialDeviceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.validation.Valid; +import java.util.Map; + +/** + * 特种设备管理接口类 + * + * @author liwen + * @date 2024-01-12 + */ +@RequestMapping("/specialDevice") +@AllArgsConstructor +@RestController +@Api(value = "特种设备", tags = "特种设备接口") +public class SpecialDeviceController extends BladeController { + + private final ISpecialDeviceService specialDeviceService; + + private final ISpecialDeviceInspectionService specialDeviceInspectionService; + + @PostMapping("/save") + @ApiOperation(value = "新增设备") + @ApiOperationSupport(order = 1) + public R save(@Valid @RequestBody SpecialDeviceEntity specialDeviceEntity) { + return R.status(specialDeviceService.save(specialDeviceEntity)); + } + + @PostMapping("/update") + @ApiOperation(value = "修改设备") + @ApiOperationSupport(order = 2) + public R update(@Valid @RequestBody SpecialDeviceEntity specialDeviceEntity) { + return R.status(specialDeviceService.updateById(specialDeviceEntity)); + } + + @PostMapping("/remove") + @ApiOperation(value = "删除设备") + @ApiOperationSupport(order = 3) + public R remove(@RequestParam Long id) { + return R.status(specialDeviceService.removeById(id)); + } + + @GetMapping("/detail") + @ApiOperation(value = "设备详情") + @ApiOperationSupport(order = 4) + public R detail(@RequestParam Long id) { + return R.data(specialDeviceService.getById(id)); + } + + @GetMapping("/page") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "设备名称", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "deviceStatus", value = "设备状态", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "设备分页") + @ApiOperationSupport(order = 5) + public R> page(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = specialDeviceService.page(Condition.getPage(query), Condition.getQueryWrapper(param, SpecialDeviceEntity.class) + .lambda().orderByDesc(SpecialDeviceEntity::getCreateTime)); + return R.data(page); + } + + @PostMapping("/saveInspection") + @ApiOperation(value = "新增设备检验记录") + @ApiOperationSupport(order = 6) + public R saveInspection(@Valid @RequestBody SpecialDeviceInspectionEntity specialDeviceInspectionEntity) { + return R.status(specialDeviceInspectionService.saveInspection(specialDeviceInspectionEntity)); + } + + @PostMapping("/updateInspection") + @ApiOperation(value = "修改设备检验记录") + @ApiOperationSupport(order = 7) + public R updateInspection(@Valid @RequestBody SpecialDeviceInspectionEntity specialDeviceInspectionEntity) { + return R.status(specialDeviceInspectionService.updateInspection(specialDeviceInspectionEntity)); + } + + @PostMapping("/removeInspection") + @ApiOperation(value = "删除设备检验记录") + @ApiOperationSupport(order = 8) + public R removeInspection(@RequestParam Long id) { + return R.status(specialDeviceInspectionService.removeById(id)); + } + + @GetMapping("/inspectionDetail") + @ApiOperation(value = "设备检验记录详情") + @ApiOperationSupport(order = 9) + public R inspectionDetail(@RequestParam Long id) { + return R.data(specialDeviceInspectionService.getById(id)); + } + + @GetMapping("/inspectionPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "设备id", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "设备检验记录分页") + @ApiOperationSupport(order = 10) + public R> inspectionPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = specialDeviceInspectionService.getInspectionPage(param, query); + return R.data(page); + } +} 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 deleted file mode 100644 index 81b4964..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java +++ /dev/null @@ -1,96 +0,0 @@ -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; - -import java.util.Date; -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) { - // 获取时间范围 - Date current = DateUtil.now(); - Date before = DateUtil.minusDays(current, 1); - String today = DateUtil.format(current, DateUtil.PATTERN_DATE); - String yesterday = DateUtil.format(before, DateUtil.PATTERN_DATE); - // 查询昨天的过期设备 - List list = deviceService.getExpiredDeviceByTime(yesterday, today); - if (CollectionUtils.isEmpty(list)) { - return ReturnT.SUCCESS; - } - 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/jobs/SpecialDeviceJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java new file mode 100644 index 0000000..e6ec1ab --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java @@ -0,0 +1,96 @@ +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.SpecialDeviceEntity; +import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; +import com.hnac.hzims.safeproduct.service.ISpecialDeviceService; +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; + +import java.util.Date; +import java.util.List; + +/** + * 特种设备模块定时任务 + * + * @author liwen + * @date 2024-01-16 + */ +@Slf4j +@Component +public class SpecialDeviceJob { + + @Autowired + ISpecialDeviceService deviceService; + + @Autowired + IUserClient userClient; + + @Autowired + ISysClient sysClient; + + @Autowired + IMessageClient messageClient; + + @XxlJob("autoChangeDeviceStatus") + public ReturnT autoChangeDeviceStatus(String param) { + // 获取时间范围 + Date current = DateUtil.now(); + Date before = DateUtil.minusDays(current, 1); + String today = DateUtil.format(current, DateUtil.PATTERN_DATE); + String yesterday = DateUtil.format(before, DateUtil.PATTERN_DATE); + // 查询昨天的过期设备 + List list = deviceService.getExpiredDeviceByTime(yesterday, today); + if (CollectionUtils.isEmpty(list)) { + return ReturnT.SUCCESS; + } + list.forEach(device -> { + device.setDeviceStatus(DeviceStatusEnum.EXPIRED.getValue()); + sendExpiredMessage(device); + }); + // 更新状态 + boolean update = deviceService.updateBatchById(list); + return update ? ReturnT.SUCCESS : ReturnT.FAIL; + } + + /** + * 推送设备过期消息 + * @param specialDeviceEntity 特种设备实体类 + */ + private void sendExpiredMessage(SpecialDeviceEntity specialDeviceEntity) { + if (specialDeviceEntity.getManagerId() == null) { + log.error("系统无该用户信息,推送设备过期消息失败"); + return; + } + // 查询用户 + R userRes = userClient.userInfoById(specialDeviceEntity.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(specialDeviceEntity.getId()); + businessMessageDTO.setSubject("设备到期通知"); + businessMessageDTO.setContent("您所管理的特种设备" + specialDeviceEntity.getName() + "已到期,请尽快进行检验。"); + businessMessageDTO.setUserIds(String.valueOf(specialDeviceEntity.getManagerId())); + businessMessageDTO.setCreateUser(specialDeviceEntity.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java deleted file mode 100644 index c15512d..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.safeproduct.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.safeproduct.entity.DeviceEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * 特种设备Mapper类 - * - * @author liwen - * @date 2024-01-12 - */ -@Mapper -public interface DeviceMapper extends BaseMapper { - -} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml deleted file mode 100644 index a863567..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.java new file mode 100644 index 0000000..fec09d7 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.java @@ -0,0 +1,26 @@ +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.SpecialDeviceInspectionEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +/** + * 特种设备检验记录Mapper类 + * + * @author liwen + * @date 2024-01-22 + */ +@Mapper +public interface SpecialDeviceInspectionMapper extends BaseMapper { + + /** + * 设备检验记录分页 + * @param param 入参 + * @param page 分页类 + * @return 设备检验记录数据 + */ + IPage getInspectionPage(IPage page, Map param); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.xml new file mode 100644 index 0000000..adf843b --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java new file mode 100644 index 0000000..1c2ace4 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 特种设备Mapper类 + * + * @author liwen + * @date 2024-01-12 + */ +@Mapper +public interface SpecialDeviceMapper extends BaseMapper { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml new file mode 100644 index 0000000..f9520d9 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java deleted file mode 100644 index 5500bf9..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.safeproduct.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.hnac.hzims.safeproduct.entity.DeviceEntity; - -import java.util.List; - -/** - * 特种设备服务类 - * - * @author liwen - * @date 2024-01-12 - */ -public interface IDeviceService extends IService { - - /** - * 查找时间范围内的过期设备 - * @param startTime 开始时间 - * @param endTime 结束时间 - */ - List getExpiredDeviceByTime(String startTime, String endTime); -} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceInspectionService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceInspectionService.java new file mode 100644 index 0000000..c751eda --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceInspectionService.java @@ -0,0 +1,39 @@ +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.SpecialDeviceInspectionEntity; +import org.springblade.core.mp.support.Query; + +import java.util.Map; + +/** + * 特种设备检验记录服务类 + * + * @author liwen + * @date 2024-01-22 + */ +public interface ISpecialDeviceInspectionService extends IService { + + /** + * 新增设备检验记录 + * @param specialDeviceInspectionEntity 特种设备检验记录实体类 + * @return true-成功,false-失败 + */ + boolean saveInspection(SpecialDeviceInspectionEntity specialDeviceInspectionEntity); + + /** + * 修改设备检验记录 + * @param specialDeviceInspectionEntity 特种设备检验记录实体类 + * @return true-成功,false-失败 + */ + boolean updateInspection(SpecialDeviceInspectionEntity specialDeviceInspectionEntity); + + /** + * 设备检验记录分页 + * @param param 入参 + * @param query 分页类 + * @return 设备检验记录数据 + */ + IPage getInspectionPage(Map param, Query query); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java new file mode 100644 index 0000000..ebcbe1c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceEntity; + +import java.util.List; + +/** + * 特种设备服务类 + * + * @author liwen + * @date 2024-01-12 + */ +public interface ISpecialDeviceService extends IService { + + /** + * 查找时间范围内的过期设备 + * @param startTime 开始时间 + * @param endTime 结束时间 + */ + List getExpiredDeviceByTime(String startTime, String endTime); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java deleted file mode 100644 index bee1994..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hnac.hzims.safeproduct.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.safeproduct.entity.DeviceEntity; -import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; -import com.hnac.hzims.safeproduct.mapper.DeviceMapper; -import com.hnac.hzims.safeproduct.service.IDeviceService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 特种设备服务实现类 - * - * @author liwen - * @date 2024-01-12 - */ -@Service -public class DeviceServiceImpl extends ServiceImpl implements IDeviceService { - - /** - * 查找时间范围内的过期设备 - */ - @Override - public List getExpiredDeviceByTime(String startTime, String endTime) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(DeviceEntity::getDeviceStatus, DeviceStatusEnum.NORMAL.getValue()) - .ge(DeviceEntity::getInspectionNextTime, startTime) - .le(DeviceEntity::getInspectionNextTime, endTime); - return this.list(queryWrapper); - } -} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java new file mode 100644 index 0000000..7bfd8c2 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java @@ -0,0 +1,79 @@ +package com.hnac.hzims.safeproduct.service.impl; + +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.SpecialDeviceEntity; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceInspectionEntity; +import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; +import com.hnac.hzims.safeproduct.mapper.SpecialDeviceInspectionMapper; +import com.hnac.hzims.safeproduct.service.ISpecialDeviceInspectionService; +import com.hnac.hzims.safeproduct.service.ISpecialDeviceService; +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.Map; + +/** + * 特种设备检验记录服务实现类 + * + * @author liwen + * @date 2024-01-22 + */ +@Service +public class SpecialDeviceInspectionServiceImpl extends ServiceImpl implements ISpecialDeviceInspectionService { + + @Autowired + ISpecialDeviceService deviceService; + + /** + * 新增设备检验记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean saveInspection(SpecialDeviceInspectionEntity specialDeviceInspectionEntity) { + boolean save = this.save(specialDeviceInspectionEntity); + if (save) { + SpecialDeviceEntity specialDeviceEntity = deviceService.getById(specialDeviceInspectionEntity.getDeviceId()); + if (specialDeviceEntity != null) { + specialDeviceEntity.setInspectionLastTime(specialDeviceInspectionEntity.getLastInspectionTime()); + specialDeviceEntity.setInspectionCurrentTime(specialDeviceInspectionEntity.getInspectionTime()); + specialDeviceEntity.setInspectionNextTime(specialDeviceInspectionEntity.getNextInspectionTime()); + specialDeviceEntity.setDeviceStatus(DeviceStatusEnum.NORMAL.getValue()); + return deviceService.updateById(specialDeviceEntity); + } + } + return false; + } + + /** + * 修改设备检验记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateInspection(SpecialDeviceInspectionEntity specialDeviceInspectionEntity) { + boolean update = this.updateById(specialDeviceInspectionEntity); + if (update) { + SpecialDeviceEntity specialDeviceEntity = deviceService.getById(specialDeviceInspectionEntity.getDeviceId()); + if (specialDeviceEntity != null) { + specialDeviceEntity.setInspectionLastTime(specialDeviceInspectionEntity.getLastInspectionTime()); + specialDeviceEntity.setInspectionCurrentTime(specialDeviceInspectionEntity.getInspectionTime()); + specialDeviceEntity.setInspectionNextTime(specialDeviceInspectionEntity.getNextInspectionTime()); + return deviceService.updateById(specialDeviceEntity); + } + } + return false; + } + + /** + * 设备检验记录分页 + */ + @Override + public IPage getInspectionPage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + return baseMapper.getInspectionPage(page, param); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceServiceImpl.java new file mode 100644 index 0000000..179568e --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceServiceImpl.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceEntity; +import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; +import com.hnac.hzims.safeproduct.mapper.SpecialDeviceMapper; +import com.hnac.hzims.safeproduct.service.ISpecialDeviceService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 特种设备服务实现类 + * + * @author liwen + * @date 2024-01-12 + */ +@Service +public class SpecialDeviceServiceImpl extends ServiceImpl implements ISpecialDeviceService { + + /** + * 查找时间范围内的过期设备 + */ + @Override + public List getExpiredDeviceByTime(String startTime, String endTime) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(SpecialDeviceEntity::getDeviceStatus, DeviceStatusEnum.NORMAL.getValue()) + .ge(SpecialDeviceEntity::getInspectionNextTime, startTime) + .le(SpecialDeviceEntity::getInspectionNextTime, endTime); + return this.list(queryWrapper); + } +}