TODO 流水号生成加锁

This commit is contained in:
wangliwen 2022-07-13 18:15:20 +08:00
parent 8afd024265
commit 0d61729d4a
1 changed files with 9 additions and 9 deletions

View File

@ -26,7 +26,7 @@ public class CodeGenerationUtils {
/**
* 生成流程单号
*
* <p>
* 流程单号编码规则
* 流程类型大写首字母 + 年月日 + 四位流水号
* 示例能力上架申请单号NLSJ202201010001
@ -34,7 +34,7 @@ public class CodeGenerationUtils {
* @param type 流程类型首字母大写
* @return 流程单号
*/
public String getApplyNumber(String type) {
public synchronized String getApplyNumber(String type) {
String applyNumberPattern = type + day;
@ -43,23 +43,23 @@ public class CodeGenerationUtils {
}
switch (type) {
//能力上架
case "NLSJ" :
case "NLSJ":
return getApplyNumberString("t_resource_mount_apply", applyNumberPattern);
//能力使用
case "NLSY" :
case "NLSY":
return getApplyNumberString("t_ability_application", applyNumberPattern);
//能力需求
case "NLXQ" :
case "NLXQ":
return getApplyNumberString("t_demand_data", applyNumberPattern);
//需求评论
case "XQPL" :
case "XQPL":
return getApplyNumberString("t_demand_comment", applyNumberPattern);
//能力下架
case "NLXJ" :
case "NLXJ":
return getApplyNumberString("tb_data_resource", applyNumberPattern);
default:
@ -67,7 +67,7 @@ public class CodeGenerationUtils {
}
}
private synchronized String getApplyNumberString (String tableName, String applyNumberPattern) {
private synchronized String getApplyNumberString(String tableName, String applyNumberPattern) {
String sql = "SELECT SUBSTR(apply_number, 5) FROM " + tableName +
" WHERE 1 = 1 AND apply_number IS NOT NULL " +
"AND apply_number LIKE '" + applyNumberPattern + "%' " +
@ -87,7 +87,7 @@ public class CodeGenerationUtils {
private static CodeGenerationUtils codeGenerationUtils = new CodeGenerationUtils();
public static CodeGenerationUtils getInstance(){
public static CodeGenerationUtils getInstance() {
return codeGenerationUtils;
}
}