zoukankan      html  css  js  c++  java
  • 规则:F+年+月+日+时+分+卡券类型+六位自然数(自然数增长加1)

    public class xxxGenerator {
    @Autowired
    private IRedisService redisService;

    /**
    * @desc : xxx规则:F+年+月+日+时+分+类型+六位自然数(自然数增长加1)
    **/
    public String generator(TypeEnum type){
    LocalDateTime nowTime = LocalDateTime.now();
    StringBuffer sb = new StringBuffer();
    sb.append("F");
    sb.append(String.valueOf(nowTime.getYear()).substring(2,4));
    sb.append(String.format("%02d",nowTime.getMonthValue()));
    sb.append(String.format("%02d",nowTime.getDayOfMonth()));

    sb.append(String.format("%02d",nowTime.getHour()));
    sb.append(String.format("%02d",nowTime.getMinute()));
    sb.append(Type.getValue());

    StringBuffer redisKey = new StringBuffer();
    redisKey.append("F");
    redisKey.append(nowTime.getYear());
    redisKey.append(nowTime.getMonthValue());
    redisKey.append(nowTime.getDayOfMonth());

    LocalDateTime midnight = nowTime.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
    long seconds = ChronoUnit.SECONDS.between(nowTime, midnight);
    sb.append(String.format("%06d",redisService.incr(redisKey.toString(),seconds)));
    log.info("xxx号:{}",sb.toString());
    return sb.toString();
    }

    public String next(TypeEnum type) {
    //return UuidUtil.nextAsTextWithoutHyphen();
    return generator(type);
    }

    }
  • 相关阅读:
    jquery事件优化---事件委托
    2017年7月6号,总结所遇到的问题
    js日期函数
    跨域请求所遇到的错误
    ajax设置Access-Control-Allow-Origin实现跨域访问
    php提前输出响应及注意问题
    php中的日期和时间
    跨域请求json数据
    C++ 与 Visual Studio 2019 和 WSL(四)——库组件
    fpic 和 fPIC
  • 原文地址:https://www.cnblogs.com/maohuidong/p/14005882.html
Copyright © 2011-2022 走看看