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 index b4ad10a..1dd92a6 100644 --- 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 @@ -1,8 +1,6 @@ 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; @@ -21,7 +19,6 @@ public class SpecialDeviceInspectionEntity extends BaseEntity { @ApiModelProperty("设备id") private Long deviceId; - @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("检验时间") private Date inspectionTime; 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 88509db..ddacc92 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 @@ -48,15 +48,19 @@ 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); + if (specialDeviceInspectionEntity.getLastInspectionTime() != null) { + specialDeviceEntity.setInspectionLastTime(specialDeviceInspectionEntity.getLastInspectionTime()); + } else { + QueryWrapper 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());