Merge branch 'dev' into docker_package

This commit is contained in:
wangliwen 2022-07-12 14:38:30 +08:00
commit 923bf8b1ca
2 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,79 @@
package io.renren.common.utils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 编码生成工具类
*/
public class CodeGenerationUtils {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("YYYYMMdd");
private static final String day = SIMPLE_DATE_FORMAT.format(new Date());
public String getResourceNumber(String type) {
return null;
}
/**
* 生成流程单号
*
* 流程单号编码规则
* 流程类型大写首字母 + 年月日 + 四位流水号
* 示例能力上架申请单号NLSJ202201010001
*
* @param type 流程类型首字母大写
* @return 流程单号
*/
public String getApplyNumber(String type) {
String applyNumberPattern = type + day;
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) {
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";
String s = jdbcTemplate.queryForObject(sql, String.class);
return StringUtils.isNotBlank(s) ? applyNumberPattern + "0001" : String.valueOf(Long.parseLong(s) + 1);
}
}

View File

@ -0,0 +1,12 @@
alter table `t_ability_application` ADD COLUMN `apply_number` varchar(16) NULL comment '能力使用申请单号';
alter table `t_resource_mount_apply` ADD COLUMN `apply_number` varchar(16) NULL comment '能力上架申请单号';
alter table `t_demand_data` ADD COLUMN `apply_number` varchar(16) NULL comment '能力需求申请单号';
alter table `t_demand_comment` ADD COLUMN `apply_number` varchar(16) NULL comment '需求评论申请单号';
alter table `tb_data_resource` ADD COLUMN `apply_number` varchar(16) NULL comment '能力下架申请单号';
alter table `sys_log_operation` ADD COLUMN `operation_table` varchar(500) NULL comment '操作数据库表';