From fc36c5eb799effeabebd09dbd87375efc486d3bd Mon Sep 17 00:00:00 2001 From: liwen Date: Thu, 18 Apr 2024 13:17:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=89=B9=E7=A7=8D=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=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 --- .../entity/SpecialDeviceInspectionEntity.java | 3 --- .../impl/SpecialDeviceInspectionServiceImpl.java | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) 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());