From d2a6a4d9f28407bb32ae87b403b9c129a72737c8 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 17 Apr 2024 15:20:40 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=89=B9=E7=A7=8D=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SpecialDeviceInspectionServiceImpl.java | 54 +++++++++++++++++----- 1 file changed, 43 insertions(+), 11 deletions(-) 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 index 7bfd8c2..88509db 100644 --- 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 @@ -10,11 +10,15 @@ 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 com.xxl.job.core.util.DateUtil; import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Date; +import java.util.List; import java.util.Map; /** @@ -35,16 +39,31 @@ public class SpecialDeviceInspectionServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(SpecialDeviceInspectionEntity::getDeviceId, deviceId) + .orderByDesc(SpecialDeviceInspectionEntity::getInspectionTime); + List list = this.list(queryWrapper); + if (CollectionUtil.isNotEmpty(list)) { + SpecialDeviceInspectionEntity lastDeviceInspection = list.get(0); + Date lastInspectionTime = lastDeviceInspection.getInspectionTime(); + specialDeviceInspectionEntity.setLastInspectionTime(lastInspectionTime); + specialDeviceEntity.setInspectionLastTime(lastInspectionTime); + } + // 本次检验时间 + specialDeviceEntity.setInspectionCurrentTime(specialDeviceInspectionEntity.getInspectionTime()); 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); - } + specialDeviceEntity.setDeviceStatus(DeviceStatusEnum.NORMAL.getValue()); + return deviceService.updateById(specialDeviceEntity); } return false; } @@ -55,10 +74,23 @@ public class SpecialDeviceInspectionServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(SpecialDeviceInspectionEntity::getDeviceId, deviceId) + .orderByDesc(SpecialDeviceInspectionEntity::getInspectionTime); + List list = this.list(queryWrapper); + if (CollectionUtil.isNotEmpty(list)) { + // 仅最新的检验记录对特种设备的检验时间造成影响 + if (specialDeviceInspectionEntity.getId().equals(list.get(0).getId()) && update) { specialDeviceEntity.setInspectionLastTime(specialDeviceInspectionEntity.getLastInspectionTime()); specialDeviceEntity.setInspectionCurrentTime(specialDeviceInspectionEntity.getInspectionTime()); specialDeviceEntity.setInspectionNextTime(specialDeviceInspectionEntity.getNextInspectionTime());