Browse Source

update: 特种设备逻辑优化

zhongwei
liwen 10 months ago
parent
commit
fcc5554456
  1. 2
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceEntity.java
  2. 43
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java
  3. 76
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java
  4. 121
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SpecialDeviceController.java
  5. 26
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java
  6. 26
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.java
  7. 24
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.xml
  8. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.java
  9. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml
  10. 39
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceInspectionService.java
  11. 6
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISpecialDeviceService.java
  12. 33
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java
  13. 79
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java
  14. 33
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceServiceImpl.java

2
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java → 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("设备名称")

43
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;
}

76
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java

@ -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<DeviceEntity> 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<IPage<DeviceEntity>> page(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<DeviceEntity> page = deviceService.page(Condition.getPage(query), Condition.getQueryWrapper(param, DeviceEntity.class)
.lambda().orderByDesc(DeviceEntity::getCreateTime));
return R.data(page);
}
}

121
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<SpecialDeviceEntity> 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<IPage<SpecialDeviceEntity>> page(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<SpecialDeviceEntity> 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<SpecialDeviceInspectionEntity> 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<IPage<SpecialDeviceInspectionEntity>> inspectionPage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<SpecialDeviceInspectionEntity> page = specialDeviceInspectionService.getInspectionPage(param, query);
return R.data(page);
}
}

26
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java → 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<DeviceEntity> list = deviceService.getExpiredDeviceByTime(yesterday, today);
List<SpecialDeviceEntity> 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<User> userRes = userClient.userInfoById(deviceEntity.getManagerId());
R<User> 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);

26
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<SpecialDeviceInspectionEntity> {
/**
* 设备检验记录分页
* @param param 入参
* @param page 分页类
* @return 设备检验记录数据
*/
IPage<SpecialDeviceInspectionEntity> getInspectionPage(IPage<SpecialDeviceInspectionEntity> page, Map<String, Object> param);
}

24
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceInspectionMapper.xml

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.SpecialDeviceInspectionMapper">
<select id="getInspectionPage" resultType="com.hnac.hzims.safeproduct.entity.SpecialDeviceInspectionEntity">
SELECT
*
FROM
hzims_device_inspection
WHERE
is_deleted = 0
<if test="param.deviceId != null and param.deviceId != ''">
AND device_id = #{param.deviceId}
</if>
<if test="param.startTime != null and param.startTime != ''">
AND inspectionTime >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND inspectionTime &lt;= #{param.endTime}
</if>
ORDER BY
create_time DESC
</select>
</mapper>

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java → 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<DeviceEntity> {
public interface SpecialDeviceMapper extends BaseMapper<SpecialDeviceEntity> {
}

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml → hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/SpecialDeviceMapper.xml

@ -1,4 +1,4 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.DeviceMapper">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.SpecialDeviceMapper">
</mapper>

39
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<SpecialDeviceInspectionEntity> {
/**
* 新增设备检验记录
* @param specialDeviceInspectionEntity 特种设备检验记录实体类
* @return true-成功false-失败
*/
boolean saveInspection(SpecialDeviceInspectionEntity specialDeviceInspectionEntity);
/**
* 修改设备检验记录
* @param specialDeviceInspectionEntity 特种设备检验记录实体类
* @return true-成功false-失败
*/
boolean updateInspection(SpecialDeviceInspectionEntity specialDeviceInspectionEntity);
/**
* 设备检验记录分页
* @param param 入参
* @param query 分页类
* @return 设备检验记录数据
*/
IPage<SpecialDeviceInspectionEntity> getInspectionPage(Map<String, Object> param, Query query);
}

6
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java → 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<DeviceEntity> {
public interface ISpecialDeviceService extends IService<SpecialDeviceEntity> {
/**
* 查找时间范围内的过期设备
* @param startTime 开始时间
* @param endTime 结束时间
*/
List<DeviceEntity> getExpiredDeviceByTime(String startTime, String endTime);
List<SpecialDeviceEntity> getExpiredDeviceByTime(String startTime, String endTime);
}

33
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java

@ -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<DeviceMapper, DeviceEntity> implements IDeviceService {
/**
* 查找时间范围内的过期设备
*/
@Override
public List<DeviceEntity> getExpiredDeviceByTime(String startTime, String endTime) {
QueryWrapper<DeviceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DeviceEntity::getDeviceStatus, DeviceStatusEnum.NORMAL.getValue())
.ge(DeviceEntity::getInspectionNextTime, startTime)
.le(DeviceEntity::getInspectionNextTime, endTime);
return this.list(queryWrapper);
}
}

79
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<SpecialDeviceInspectionMapper, SpecialDeviceInspectionEntity> 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<SpecialDeviceInspectionEntity> getInspectionPage(Map<String, Object> param, Query query) {
IPage<SpecialDeviceInspectionEntity> page = new Page<>(query.getCurrent(), query.getSize());
return baseMapper.getInspectionPage(page, param);
}
}

33
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<SpecialDeviceMapper, SpecialDeviceEntity> implements ISpecialDeviceService {
/**
* 查找时间范围内的过期设备
*/
@Override
public List<SpecialDeviceEntity> getExpiredDeviceByTime(String startTime, String endTime) {
QueryWrapper<SpecialDeviceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SpecialDeviceEntity::getDeviceStatus, DeviceStatusEnum.NORMAL.getValue())
.ge(SpecialDeviceEntity::getInspectionNextTime, startTime)
.le(SpecialDeviceEntity::getInspectionNextTime, endTime);
return this.list(queryWrapper);
}
}
Loading…
Cancel
Save