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()+"任务为多步骤任务且第一步为清洗,不生成洗炉炉号."); } } /**