Merge branch 'master' into docker_package
This commit is contained in:
commit
3f5934bca6
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue