Merge branch 'dev' into docker_package
This commit is contained in:
commit
fe612f5901
|
@ -23,6 +23,7 @@ import org.codehaus.jackson.map.ObjectMapper;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -58,6 +59,8 @@ public class AbilityCenterController {
|
|||
private TAbilityApplicationService tAbilityApplicationService;
|
||||
@Autowired
|
||||
private ActRunningService actRunningService;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private final CodeGenerationUtils codeGenerationUtils = CodeGenerationUtils.getInstance();
|
||||
|
||||
|
@ -120,7 +123,7 @@ public class AbilityCenterController {
|
|||
if (tAbilityApplicationDTO.getId() == null) {
|
||||
return null;
|
||||
}
|
||||
codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTO.getId().toString());
|
||||
codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTO.getId().toString(), jdbcTemplate);
|
||||
tAbilityApplicationDTO.setCompleteEntry(Boolean.TRUE);
|
||||
|
||||
// 仿照请求接口 /act/running/startOfBusinessKey
|
||||
|
|
|
@ -141,7 +141,7 @@ public class AbilityCenterControllerV2 {
|
|||
if (tAbilityApplicationDTO.getId() == null) {
|
||||
return null;
|
||||
}
|
||||
codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTO.getId().toString());
|
||||
codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTO.getId().toString(), jdbcTemplate);
|
||||
tAbilityApplicationDTO.setCompleteEntry(Boolean.TRUE);
|
||||
return tAbilityApplicationDTO;
|
||||
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()); // 申请入库
|
||||
|
|
|
@ -88,7 +88,7 @@ public class CommentController {
|
|||
tDemandCommentDTO.setDelFlag(2); // 待审核
|
||||
tDemandCommentDTO.setCompleteEntry(Boolean.TRUE);
|
||||
tDemandCommentService.update(tDemandCommentDTO);
|
||||
codeGenerationUtils.setApplyNumber("XQPL", tDemandCommentDTO.getId().toString());
|
||||
codeGenerationUtils.setApplyNumber("XQPL", tDemandCommentDTO.getId().toString(), jdbcTemplate);
|
||||
|
||||
// 仿照请求接口 /act/running/startOfBusinessKey
|
||||
ProcessStartDTO processStartDTO = new ProcessStartDTO();
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.codehaus.jackson.map.ObjectMapper;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -44,6 +45,8 @@ public class DemandDataController {
|
|||
private ActRunningService actRunningService;
|
||||
@Autowired
|
||||
private TDemandDataService tDemandDataService;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
private final CodeGenerationUtils codeGenerationUtils = CodeGenerationUtils.getInstance();
|
||||
|
||||
|
||||
|
@ -76,7 +79,7 @@ public class DemandDataController {
|
|||
if (tDemandDataDTO.getId() == null) {
|
||||
return null;
|
||||
}
|
||||
codeGenerationUtils.setApplyNumber("NLXQ", tDemandDataDTO.getId().toString());
|
||||
codeGenerationUtils.setApplyNumber("NLXQ", tDemandDataDTO.getId().toString(), jdbcTemplate);
|
||||
tDemandDataDTO.setCompleteEntry(Boolean.TRUE);
|
||||
logger.info("-------------------1.保存申请表单成功--------------------------");
|
||||
// 仿照请求接口 /act/running/startOfBusinessKey
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.codehaus.jackson.map.ObjectMapper;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -62,6 +63,8 @@ public class ResourceMountController {
|
|||
|
||||
@Autowired
|
||||
protected TaskService taskService;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private static final String apply_key = "resourcemountapply"; // 资源上架
|
||||
|
||||
|
@ -116,7 +119,7 @@ public class ResourceMountController {
|
|||
if (tResourceMountApplyDTO.getId() == null) {
|
||||
return null;
|
||||
}
|
||||
codeGenerationUtils.setApplyNumber("NLSJ", tResourceMountApplyDTO.getId().toString());
|
||||
codeGenerationUtils.setApplyNumber("NLSJ", tResourceMountApplyDTO.getId().toString(), jdbcTemplate);
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
Task task = taskQuery.active().processInstanceBusinessKey(tResourceMountApplyDTO.getId().toString()).singleResult();
|
||||
if (task != null) {
|
||||
|
@ -194,7 +197,7 @@ public class ResourceMountController {
|
|||
userDTO.ifPresent(user -> {
|
||||
dto.setUndercarriageUserName(user.getRealName());
|
||||
});
|
||||
codeGenerationUtils.setApplyNumber("NLXJ", dto.getId().toString());
|
||||
codeGenerationUtils.setApplyNumber("NLXJ", dto.getId().toString(), jdbcTemplate);
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
resourceService.update(dto);
|
||||
logger.error(resourceDTO.get().toString());
|
||||
|
|
|
@ -3,7 +3,6 @@ package io.renren.common.utils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -16,8 +15,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
public class CodeGenerationUtils {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CodeGenerationUtils.class);
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
|
@ -27,7 +24,6 @@ public class CodeGenerationUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用单例枚举保证全局单例
|
||||
*/
|
||||
|
@ -55,59 +51,58 @@ 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) {
|
||||
// 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)) {
|
||||
return;
|
||||
|
@ -153,7 +148,7 @@ public class CodeGenerationUtils {
|
|||
logger.error("流水号生成失败", e);
|
||||
no = applyNumberPattern + "0001";
|
||||
} finally {
|
||||
String sql_ = String.format("UPDATE %s SET apply_number = '%s' WHERE id = %s", tableName, no, id);
|
||||
String sql_ = String.format("UPDATE %s SET apply_number = '%s' WHERE id = %s;", tableName, no, id);
|
||||
logger.info(sql_);
|
||||
jdbcTemplate.update(sql_);
|
||||
lock.unlock();
|
||||
|
|
Loading…
Reference in New Issue