Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-15 12:00:46 +08:00
commit ad93b162ec
1 changed files with 12 additions and 56 deletions

View File

@ -42,7 +42,7 @@ public class CodeGenerationUtils {
/**
* 生成流程单号
* 设置流程单号
* <p>
* 流程单号编码规则
* 流程类型大写首字母 + 年月日 + 四位流水号
@ -51,57 +51,6 @@ public class CodeGenerationUtils {
* @param type 流程类型首字母大写
* @return 流程单号
*/
// public String getApplyNumber(String type) {
//
// String applyNumberPattern = type + SIMPLE_DATE_FORMAT.format(new Date());
//
// if (StringUtils.isBlank(type)) {
// return "";
// }
// switch (type) {
// //能力上架
// case "NLSJ":
// return getApplyNumberString("t_resource_mount_apply", applyNumberPattern);
//
// //能力使用
// case "NLSY":
// return getApplyNumberString("t_ability_application", applyNumberPattern);
//
// //能力需求
// case "NLXQ":
// return getApplyNumberString("t_demand_data", applyNumberPattern);
//
// //需求评论
// case "XQPL":
// return getApplyNumberString("t_demand_comment", applyNumberPattern);
//
// //能力下架
// case "NLXJ":
// return getApplyNumberString("tb_data_resource", applyNumberPattern);
//
// default:
// return "";
// }
// }
//
// 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 + "%' " +
// "ORDER BY apply_number DESC " +
// "LIMIT 1";
// logger.info(sql);
// try {
// String s = jdbcTemplate.queryForObject(sql, String.class);
// return applyNumberPattern.substring(0, 3) + (Long.parseLong(s) + 1);
// } catch (Exception e) {
// logger.error("流水号生成失败", e);
// return applyNumberPattern + "0001";
// } finally {
// lock.unlock();
// }
// }
public void setApplyNumber(String type, final String id, final JdbcTemplate jdbcTemplate) {
String applyNumberPattern = type + SIMPLE_DATE_FORMAT.format(new Date());
if (StringUtils.isBlank(type)) {
@ -110,6 +59,9 @@ public class CodeGenerationUtils {
if (StringUtils.isEmpty(id)) {
return;
}
if (jdbcTemplate == null) {
return;
}
String tableName = null;
switch (type) {
//能力上架
@ -143,14 +95,18 @@ public class CodeGenerationUtils {
String no = null;
try {
String s = jdbcTemplate.queryForObject(sql, String.class);
no = applyNumberPattern.substring(0, 3) + (Long.parseLong(s) + 1);
no = applyNumberPattern.substring(0, 4) + (Long.parseLong(s) + 1);
} catch (Exception e) {
logger.error("流水号生成失败", e);
no = applyNumberPattern + "0001";
} finally {
String sql_ = String.format("UPDATE %s SET apply_number = '%s' WHERE id = %s;", tableName, no, id);
logger.info(sql_);
jdbcTemplate.update(sql_);
try {
String sql_ = String.format("UPDATE %s SET apply_number = '%s' WHERE id = %s;", tableName, no, id);
logger.info(sql_);
jdbcTemplate.update(sql_);
} catch (Exception exception) {
logger.error("流水号写入失败", exception);
}
lock.unlock();
}
}