| | |
| | | @Autowired |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | public String generateID() { |
| | | public synchronized String generateLisID() { |
| | | String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
| | | String storedDate = stringRedisTemplate.opsForValue().get(LIS_CURRENT_DATE_KEY); |
| | | String lastIdStr = stringRedisTemplate.opsForValue().get(LIS_LAST_ID_KEY); |
| | |
| | | stringRedisTemplate.opsForValue().set(LIS_LAST_ID_KEY, String.valueOf(lastId)); |
| | | } |
| | | String yyMMdd = currentDate.substring(2); |
| | | String id = String.format("%s%06d", yyMMdd, lastId); |
| | | return id; |
| | | return String.format("%s%06d", yyMMdd, lastId); |
| | | } |
| | | |
| | | } |