Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-13 18:48:19 +08:00
commit 3f5934bca6
1 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.locks.ReentrantLock;
/**
* 编码生成工具类
@ -15,6 +16,8 @@ public class CodeGenerationUtils {
@Autowired
private JdbcTemplate jdbcTemplate;
ReentrantLock lock = new ReentrantLock();
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("YYYYMMdd");
private static final String day = SIMPLE_DATE_FORMAT.format(new Date());
@ -34,7 +37,7 @@ public class CodeGenerationUtils {
* @param type 流程类型首字母大写
* @return 流程单号
*/
public synchronized String getApplyNumber(String type) {
public String getApplyNumber(String type) {
String applyNumberPattern = type + day;
@ -67,7 +70,8 @@ public class CodeGenerationUtils {
}
}
private synchronized String getApplyNumberString(String tableName, String applyNumberPattern) {
private String getApplyNumberString(String tableName, String applyNumberPattern) {
lock.lock();
String sql = "SELECT SUBSTR(apply_number, 5) FROM " + tableName +
" WHERE 1 = 1 AND apply_number IS NOT NULL " +
"AND apply_number LIKE '" + applyNumberPattern + "%' " +
@ -78,6 +82,8 @@ public class CodeGenerationUtils {
return "NLSY" + (Long.parseLong(s) + 1);
} catch (Exception e) {
return applyNumberPattern + "0001";
} finally {
lock.unlock();
}
}