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/SpecialDeviceEntity.java similarity index 97% rename from hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java rename to hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceEntity.java index 486b76f..5c12f90 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/SpecialDeviceEntity.java @@ -18,7 +18,7 @@ import java.util.Date; @EqualsAndHashCode(callSuper = true) @TableName("hzims_device") @ApiModel(value = "特种设备实体类") -public class DeviceEntity extends BaseEntity { +public class SpecialDeviceEntity extends BaseEntity { @Size(max = 50, message = "设备名称长度不能超过50") @ApiModelProperty("设备名称") 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/SpecialDeviceJob.java similarity index 76% rename from hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java rename to hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java index 81b4964..e6ec1ab 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/SpecialDeviceJob.java @@ -4,9 +4,9 @@ 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.entity.SpecialDeviceEntity; import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; -import com.hnac.hzims.safeproduct.service.IDeviceService; +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; @@ -30,10 +30,10 @@ import java.util.List; */ @Slf4j @Component -public class DeviceJob { +public class SpecialDeviceJob { @Autowired - IDeviceService deviceService; + ISpecialDeviceService deviceService; @Autowired IUserClient userClient; @@ -52,7 +52,7 @@ public class DeviceJob { String today = DateUtil.format(current, DateUtil.PATTERN_DATE); String yesterday = DateUtil.format(before, DateUtil.PATTERN_DATE); // 查询昨天的过期设备 - List list = deviceService.getExpiredDeviceByTime(yesterday, today); + List list = deviceService.getExpiredDeviceByTime(yesterday, today); if (CollectionUtils.isEmpty(list)) { return ReturnT.SUCCESS; } @@ -67,15 +67,15 @@ public class DeviceJob { /** * 推送设备过期消息 - * @param deviceEntity 特种设备实体类 + * @param specialDeviceEntity 特种设备实体类 */ - private void sendExpiredMessage(DeviceEntity deviceEntity) { - if (deviceEntity.getManagerId() == null) { + private void sendExpiredMessage(SpecialDeviceEntity specialDeviceEntity) { + if (specialDeviceEntity.getManagerId() == null) { log.error("系统无该用户信息,推送设备过期消息失败"); return; } // 查询用户 - R userRes = userClient.userInfoById(deviceEntity.getManagerId()); + R userRes = userClient.userInfoById(specialDeviceEntity.getManagerId()); User user = userRes.getData(); BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); if (StringUtils.isNotEmpty(user.getDeptId())) { @@ -84,11 +84,11 @@ public class DeviceJob { businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); businessMessageDTO.setBusinessKey("设备到期"); businessMessageDTO.setBusinessClassify("system"); - businessMessageDTO.setTaskId(deviceEntity.getId()); + businessMessageDTO.setTaskId(specialDeviceEntity.getId()); businessMessageDTO.setSubject("设备到期通知"); - businessMessageDTO.setContent("您所管理的特种设备" + deviceEntity.getName() + "已到期,请尽快进行检验。"); - businessMessageDTO.setUserIds(String.valueOf(deviceEntity.getManagerId())); - businessMessageDTO.setCreateUser(deviceEntity.getCreateUser()); + 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/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/DeviceMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java similarity index 61% rename from hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java rename to hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java index c15512d..1c2ace4 100644 --- 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/SpecialDeviceMapper.java @@ -1,7 +1,7 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.safeproduct.entity.DeviceEntity; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceEntity; import org.apache.ibatis.annotations.Mapper; /** @@ -11,6 +11,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2024-01-12 */ @Mapper -public interface DeviceMapper extends BaseMapper { +public interface SpecialDeviceMapper 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/SpecialDeviceMapper.xml similarity index 56% rename from hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml rename to hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml index a863567..f9520d9 100644 --- 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/SpecialDeviceMapper.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file 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/IDeviceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java similarity index 59% rename from hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java rename to hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java index 5500bf9..ebcbe1c 100644 --- 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/ISpecialDeviceService.java @@ -1,7 +1,7 @@ package com.hnac.hzims.safeproduct.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.hnac.hzims.safeproduct.entity.DeviceEntity; +import com.hnac.hzims.safeproduct.entity.SpecialDeviceEntity; import java.util.List; @@ -11,12 +11,12 @@ import java.util.List; * @author liwen * @date 2024-01-12 */ -public interface IDeviceService extends IService { +public interface ISpecialDeviceService extends IService { /** * 查找时间范围内的过期设备 * @param startTime 开始时间 * @param endTime 结束时间 */ - List getExpiredDeviceByTime(String startTime, String 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); + } +}