|
@@ -7,7 +7,7 @@ public class BusinessIdGenerator {
|
|
|
|
|
|
private static final String PREFIX = "EPD";
|
|
private static final String PREFIX = "EPD";
|
|
private static final String FIXED_MIDDLE_PART = "000";
|
|
private static final String FIXED_MIDDLE_PART = "000";
|
|
- private static final int SERIAL_NUMBER_LENGTH = 5;
|
|
|
|
|
|
+ private static final int SERIAL_NUMBER_LENGTH = 1;
|
|
|
|
|
|
private static final String PREFIX_ = "LHTWL";
|
|
private static final String PREFIX_ = "LHTWL";
|
|
|
|
|
|
@@ -23,23 +23,25 @@ public class BusinessIdGenerator {
|
|
businessId.append(getDatePart());
|
|
businessId.append(getDatePart());
|
|
businessId.append(FIXED_MIDDLE_PART);
|
|
businessId.append(FIXED_MIDDLE_PART);
|
|
businessId.append(getSerialNumberPart(currentSerialNumber));
|
|
businessId.append(getSerialNumberPart(currentSerialNumber));
|
|
-
|
|
|
|
|
|
+ System.out.println(businessId);
|
|
return businessId.toString();
|
|
return businessId.toString();
|
|
}
|
|
}
|
|
|
|
|
|
private static String getDatePart() {
|
|
private static String getDatePart() {
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
|
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
|
|
return sdf.format(new Date());
|
|
return sdf.format(new Date());
|
|
}
|
|
}
|
|
|
|
|
|
private static String getSerialNumberPart(int currentSerialNumber) {
|
|
private static String getSerialNumberPart(int currentSerialNumber) {
|
|
// 如果序列号不足长度,前面补0
|
|
// 如果序列号不足长度,前面补0
|
|
- return String.format("%0" + SERIAL_NUMBER_LENGTH + "d", currentSerialNumber);
|
|
|
|
|
|
+ String format = String.format("%0" + SERIAL_NUMBER_LENGTH + "d", currentSerialNumber);
|
|
|
|
+ System.out.println(format);
|
|
|
|
+ return format;
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
for (int i = 0; i < 10; i++) {
|
|
for (int i = 0; i < 10; i++) {
|
|
- String code = generateCode(i);
|
|
|
|
|
|
+ String code = generateBusinessId(i);
|
|
System.out.println("Generated Code: " + code);
|
|
System.out.println("Generated Code: " + code);
|
|
}
|
|
}
|
|
}
|
|
}
|