package com.jeeplus.modules.warehouse.code.util;

import com.jeeplus.common.utils.SpringContextHolder;
import com.jeeplus.modules.warehouse.code.service.NumSeqService;

public class NumSeqUtils {
    private static NumSeqService numSeqService = SpringContextHolder.getBean(NumSeqService.class);

    public static String getNumSeq(String module){
        Integer num = numSeqService.getNumSeq(module);
        if(num == null){
            throw new RuntimeException("numSeq生成失败");
        }

        String numStr = num.toString();
        int count = 4;
        for(int i = 0;i < count;i++){
            if(numStr.length() < count) {
                numStr = "0" + numStr;
            }else{
                break;
            }
        }
        return numStr;
    }
    public static String getNumSeqConunt(String module, int count){
        Integer num = numSeqService.getNumSeq(module);
        if(num == null){
            throw new RuntimeException("numSeq生成失败");
        }

        String numStr = num.toString();
        for(int i = 0;i < count;i++){
            if(numStr.length() < count) {
                numStr = "0" + numStr;
            }else{
                break;
            }
        }
        return numStr;
    }
}
