From 85299bb26a2cd53ba717f4fbedbf3e8619649405 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Wed, 9 Nov 2022 13:58:23 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=BC=96=E7=A0=81=E7=94=9F=E6=88=90r?= =?UTF-8?q?edis=E8=AE=BE=E7=BD=AEkey=E6=9C=89=E6=95=88=E6=9C=9F=E4=B8=BA?= =?UTF-8?q?=E5=BD=93=E5=A4=A9,=E6=AC=A1=E6=97=A5=E5=87=8C=E6=99=A8?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=87=8D=E6=96=B0=E5=BC=80=E5=A7=8B=E8=AE=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mt/wms/core/utils/IDGenerator.java | 12 ++++++++---- .../com/mt/wms/empty/task/AsynRunTaskService.java | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java index 8855792..cdda0c9 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java @@ -11,10 +11,8 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import java.text.DecimalFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.TimeUnit; /** * id生成器,使用redis自增接口实现 @@ -153,6 +151,12 @@ public class IDGenerator { } if (!isEmpty(sequenceName)) { long sequence = gen(sequenceName); + //设置key有效期为当天,次日凌晨失效 + Calendar curDate = Calendar.getInstance(); + Calendar tomorrowDate = new GregorianCalendar(curDate.get(Calendar.YEAR), curDate.get(Calendar.MONTH), curDate.get(Calendar.DATE) + 1, 0, 0, 0); + int second = (int)(tomorrowDate.getTimeInMillis() - curDate.getTimeInMillis()) / 1000; + idGenerator.redisTemplate.opsForValue().set(KEY_PREFIX_SEQUENCE + sequenceName, sequence, second, TimeUnit.SECONDS); + idGenerator.redisTemplate.opsForValue().getOperations(); if (sequenceLength > 0) { if (sequenceLength > MAX_SEQUENCE_LENGTH) { sequenceLength = MAX_SEQUENCE_LENGTH; diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 6ff1857..603fa2b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -1221,7 +1221,7 @@ public class AsynRunTaskService extends BaseService { currTask.setStoveCode(stoveCode); currTaskServiceBiz.updateById(currTask); }else { - logger.info(currTask.getId()+"任务为多步骤任务且第一步为清洗,不生产清洗炉炉号."); + logger.info(currTask.getId()+"任务为多步骤任务且第一步为清洗,不生成洗炉炉号."); } } /**