From a293b1a45c115bc26ef58f3571e1b1fd6e04ac9b Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 11 Jan 2024 16:47:33 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E5=AE=89=E5=85=A8=E5=B7=A5=E5=99=A8?= =?UTF-8?q?=E5=85=B7=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/constants/RedisConstants.java | 6 ++++++ .../hzims/safeproduct/entity/SafetyToolEntity.java | 3 ++- .../safeproduct/dto/SafetyToolBatchRecheckDTO.java | 5 +++++ .../service/impl/SafetyToolServiceImpl.java | 25 +++++++++++----------- 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/RedisConstants.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/RedisConstants.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/RedisConstants.java new file mode 100644 index 0000000..bcbf815 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/RedisConstants.java @@ -0,0 +1,6 @@ +package com.hnac.hzims.safeproduct.constants; + +public interface RedisConstants { + /**安全工器具提醒记录**/ + String TOOLS_REMIND_MSG = "200000:hzims:safeproduct:tools:remind"; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolEntity.java index 1ac5e07..d57c115 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolEntity.java @@ -9,6 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import java.io.Serializable; import java.util.Date; @@ -21,7 +22,7 @@ import java.util.Date; @TableName("hzims_safe_safety_tool") @EqualsAndHashCode(callSuper = true) @ApiModel(value = "SafetyTool对象", description = "") -public class SafetyToolEntity extends TenantEntity { +public class SafetyToolEntity extends TenantEntity implements Serializable { private static final long serialVersionUID = 1L; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/dto/SafetyToolBatchRecheckDTO.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/dto/SafetyToolBatchRecheckDTO.java index 2f26f6f..d952ab3 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/dto/SafetyToolBatchRecheckDTO.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/dto/SafetyToolBatchRecheckDTO.java @@ -1,8 +1,11 @@ package com.hnac.hzims.safeproduct.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; @@ -27,6 +30,8 @@ public class SafetyToolBatchRecheckDTO implements Serializable { private Set toolIds; @ApiModelProperty(value = "复核时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) private Date checkTime; @ApiModelProperty(value = "备注") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java index 3255a0d..1e9e002 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.zxing.BarcodeFormat; import com.hnac.hzims.message.dto.PlanMsgRecordDto; +import com.hnac.hzims.safeproduct.constants.RedisConstants; import com.hnac.hzims.safeproduct.dto.SafetyToolBatchRecheckDTO; import com.hnac.hzims.safeproduct.dto.SafetyToolDTO; import com.hnac.hzims.safeproduct.entity.SafeProductPdf; @@ -44,6 +45,7 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; @@ -126,7 +128,6 @@ public class SafetyToolServiceImpl extends BaseServiceImpl safetyToolRechecks = new ArrayList<>(safetyTools.size()); - for (SafetyToolEntity item : safetyTools) { + super.updateById(item); SafetyToolRecheckEntity entity = new SafetyToolRecheckEntity(); entity.setCheckUserName(userName); entity.setCheckUserId(userId); entity.setToolId(item.getId()); entity.setCheckTime(checkTime); entity.setRemark(req.getRemark()); - safetyToolRechecks.add(entity); - } - if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) { - throw new ServiceException("数据库insert操作失败!"); + safetyToolRecheckMapper.insert(entity); + // 计算下次推送时间 + Date noticeDate = DateUtil.minusDays(item.getNextCheckTime(), item.getAdvanceNoticeDays()); + String redisKey = RedisConstants.TOOLS_REMIND_MSG + ":" + item.getId(); + // 删除提醒记录 + redisTemplate.delete(redisKey); + // 创建新的提醒记录 + redisTemplate.opsForZSet().add(redisKey,item,noticeDate.getTime()); + log.info("key为:"+redisTemplate.keys(RedisConstants.TOOLS_REMIND_MSG+"*")); } }