|
@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.qs.mp.admin.domain.TicketBox;
|
|
import com.qs.mp.admin.domain.TicketBox;
|
|
import com.qs.mp.admin.mapper.TicketBoxMapper;
|
|
import com.qs.mp.admin.mapper.TicketBoxMapper;
|
|
import com.qs.mp.admin.service.ITicketBoxSerialService;
|
|
import com.qs.mp.admin.service.ITicketBoxSerialService;
|
|
|
|
+import com.qs.mp.common.annotation.Log;
|
|
import com.qs.mp.common.core.redis.RedisCache;
|
|
import com.qs.mp.common.core.redis.RedisCache;
|
|
import com.qs.mp.common.enums.TicketTypeEnum;
|
|
import com.qs.mp.common.enums.TicketTypeEnum;
|
|
|
|
+import com.qs.mp.common.utils.LogUtil;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -22,6 +26,8 @@ import org.springframework.util.CollectionUtils;
|
|
@Service
|
|
@Service
|
|
public class TicketBoxSerialServiceImpl implements ITicketBoxSerialService {
|
|
public class TicketBoxSerialServiceImpl implements ITicketBoxSerialService {
|
|
|
|
|
|
|
|
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
@@ -43,7 +49,7 @@ public class TicketBoxSerialServiceImpl implements ITicketBoxSerialService {
|
|
//否则,将日期作为Key,1作为Value重置,并设置第二年0点过期
|
|
//否则,将日期作为Key,1作为Value重置,并设置第二年0点过期
|
|
if (redisCache.hasKey(prefix)) {
|
|
if (redisCache.hasKey(prefix)) {
|
|
redisTemplate.opsForValue().increment(prefix, 1);
|
|
redisTemplate.opsForValue().increment(prefix, 1);
|
|
-
|
|
|
|
|
|
+ LogUtil.debug(logger, "缓存中存在,key:" + prefix);
|
|
} else {
|
|
} else {
|
|
int start = Integer.valueOf(strYear);
|
|
int start = Integer.valueOf(strYear);
|
|
List<TicketBox> ticketBoxList = ticketBoxMapper.selectList(new QueryWrapper<TicketBox>().orderByDesc("created_time").last("limit 1"));
|
|
List<TicketBox> ticketBoxList = ticketBoxMapper.selectList(new QueryWrapper<TicketBox>().orderByDesc("created_time").last("limit 1"));
|
|
@@ -53,14 +59,17 @@ public class TicketBoxSerialServiceImpl implements ITicketBoxSerialService {
|
|
int year = Character.codePointAt(boxNo.substring(1, 2), 0) - 50;
|
|
int year = Character.codePointAt(boxNo.substring(1, 2), 0) - 50;
|
|
// 同一年份,做累加
|
|
// 同一年份,做累加
|
|
if (year == Integer.valueOf(prefix)) {
|
|
if (year == Integer.valueOf(prefix)) {
|
|
- start = Integer.valueOf(boxNo.substring(3)) + 1;
|
|
|
|
|
|
+ start = Integer.valueOf(boxNo.substring(2)) + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
redisTemplate.opsForValue().set(prefix, start);
|
|
redisTemplate.opsForValue().set(prefix, start);
|
|
redisTemplate.expireAt(prefix, getNextYearDate());
|
|
redisTemplate.expireAt(prefix, getNextYearDate());
|
|
-
|
|
|
|
|
|
+ LogUtil.debug(logger, "缓存中不存在,key:{0}, start:{1}", new Object[]{prefix, start});
|
|
}
|
|
}
|
|
- return "T" + Character.toChars(Integer.parseInt(prefix) + 50) + String.format("%1$05d", redisTemplate.opsForValue().get(prefix));
|
|
|
|
|
|
+ String str = new String(Character.toChars(Integer.parseInt(prefix) + 50));
|
|
|
|
+ Object value = redisTemplate.opsForValue().get(prefix);
|
|
|
|
+ LogUtil.debug(logger, "生成的年份为{0},序列号为{1}", new Object[]{str, value});
|
|
|
|
+ return "T" + str + String.format("%1$05d", value);
|
|
}
|
|
}
|
|
|
|
|
|
// 获取第二年 1月 1日 00:00的时间
|
|
// 获取第二年 1月 1日 00:00的时间
|