package com.openhis.web.externalintegration.utils;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 【BPC】终端流水号生成器
 *
 * @author Thanking
 * @date 2025-10-16
 */
public class BpcTraceNoGenerator {
    private static final AtomicInteger COUNTER = new AtomicInteger(1);
    private static final int MAX_VALUE = 999999;

    public static String nextTraceNo() {
        int nextValue = COUNTER.getAndUpdate(current -> current >= MAX_VALUE ? 1 : current + 1);
        // 补零至6位
        return String.format("%06d", nextValue);
    }
}
