package com.ruoyi.common.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class WorkTicketNoUtils {

    private static int sn = 0;

    public static String NextOrderNo(){
        if(sn == 9999)
            sn = 0;
        else
            sn++;
        DateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        return "WT"+df.format(new Date()) + padRight(String.valueOf(sn),4, '0');
    }
     public static String padRight(String src, int len, char ch) {
        int diff = len - src.length();
        if (diff <= 0) {
            return src;
        }

         char[] charr = new char[len];
         System.arraycopy(src.toCharArray(), 0, charr, diff, src.length());
         for (int i = 0; i < diff; i++) {
             charr[i] = ch;
         }
        return new String(charr);
    }

    public static void main(String[] args) {
        System.out.println(WorkTicketNoUtils.NextOrderNo());
    }
}
