|
|
@ -65,18 +65,7 @@ public class OrderNoMakeUtil {
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否首次生成(SerialNo初始值-1)
|
|
|
|
// 判断是否首次生成(SerialNo初始值-1)
|
|
|
|
if (orderNoRule.getSerialNo() > 0 && prefixIdx != -1) {
|
|
|
|
if (orderNoRule.getSerialNo() > 0 && prefixIdx != -1) {
|
|
|
|
String newNo = orderNoTemplate.substring(0, prefixIdx);
|
|
|
|
|
|
|
|
String oldNo = orderNoRule.getOrderNo().substring(0, prefixIdx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long serialNo = orderNoRule.getSerialNo() + orderNoRule.getSerialNoIncrement();
|
|
|
|
long serialNo = orderNoRule.getSerialNo() + orderNoRule.getSerialNoIncrement();
|
|
|
|
|
|
|
|
|
|
|
|
// 前缀(日期)不同后是否重置流水号
|
|
|
|
|
|
|
|
if (!newNo.equals(oldNo) && orderNoRule.getIsCycle() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) {
|
|
|
|
|
|
|
|
orderNoRule.setSerialNo(orderNoRule.getSerialNoSeed());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
orderNoRule.setSerialNo(serialNo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal maxSerialNo = TEN.pow(orderNoRule.getSerialNoLength()).subtract(BigDecimal.ONE);
|
|
|
|
BigDecimal maxSerialNo = TEN.pow(orderNoRule.getSerialNoLength()).subtract(BigDecimal.ONE);
|
|
|
|
if (CommonEnumUtil.TRUE_OR_FALSE.valueOfBoolean(orderNoRule.getIsFixedLength())
|
|
|
|
if (CommonEnumUtil.TRUE_OR_FALSE.valueOfBoolean(orderNoRule.getIsFixedLength())
|
|
|
|
&& serialNo > maxSerialNo.longValue()) {
|
|
|
|
&& serialNo > maxSerialNo.longValue()) {
|
|
|
@ -92,18 +81,29 @@ public class OrderNoMakeUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param orderNoRule
|
|
|
|
|
|
|
|
* @param orderNoTemplate
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static boolean isCycleByPrefix(SysOrderNoRule orderNoRule, String orderNoTemplate){
|
|
|
|
|
|
|
|
int prefixIdx = orderNoTemplate.indexOf(SERIAL_NO);
|
|
|
|
|
|
|
|
String newNo = orderNoTemplate.substring(0, prefixIdx);
|
|
|
|
|
|
|
|
String oldNo = orderNoRule.getOrderNo().substring(0, prefixIdx);
|
|
|
|
|
|
|
|
return !newNo.equals(oldNo) && CommonEnumUtil.TRUE_OR_FALSE.valueOfBoolean(orderNoRule.getIsCycle());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 替换字符串
|
|
|
|
* 替换字符串
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param no
|
|
|
|
* @param no
|
|
|
|
* @param constant
|
|
|
|
* @param constant
|
|
|
|
* @param param
|
|
|
|
* @param param
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static StringBuilder replace(StringBuilder no, String constant, Object param) {
|
|
|
|
private static void replace(StringBuilder no, String constant, Object param) {
|
|
|
|
int day = no.indexOf(constant);
|
|
|
|
int day = no.indexOf(constant);
|
|
|
|
if (day != -1) {
|
|
|
|
if (day != -1) {
|
|
|
|
no.replace(day, day + constant.length(), param.toString());
|
|
|
|
no.replace(day, day + constant.length(), param.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return no;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|