Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-18 16:12:30 +08:00
commit 6a2a13aa20
3 changed files with 142 additions and 2 deletions

View File

@ -310,6 +310,8 @@
<excludes>
<!-- 排除生产环境配置 -->
<exclude>application-prod.yml</exclude>
<exclude>application-bt.yml</exclude>
<exclude>application-xha.yml</exclude>
<!-- 排除flyway管理的sql -->
<exclude>db/*.sql</exclude>
<exclude>domain/**</exclude>

View File

@ -85,6 +85,142 @@ public class AbilityCenterControllerV2 {
}
};
@PostMapping(value = "/applyAllApplication")
@ApiOperation("批量进行能力申请")
@LogOperation("批量进行能力申请")
public Result<List<ProcessInstanceDTO>> applyV2AllApplication(@RequestBody TAbilityBatchApplicationDTO abilityBatchApplicationDTO) {
// 仿照请求接口 /act/process/lastestPage
PageData<Map<String, Object>> page = actProcessService.page(params);
if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程");
}
List<Map<String, Object>> system_ = jdbcTemplate.queryForList("SELECT `name` AS resourceName,id AS resourceId FROM tb_data_resource WHERE type = '应用资源' AND del_flag = 0;");
if (system_.isEmpty()) {
return new Result().error("无应用资源");
}
List<Map<String, String>> system = system_.stream().map(index ->
index.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> (String) e.getValue()))
).collect(Collectors.toList());
abilityBatchApplicationDTO.setSystem(system); // 申请所有的正常的应用资源
final String applyFlag = UUID.randomUUID().toString();
abilityBatchApplicationDTO.setApplyFlag(applyFlag); // 同一次的申请标识
final Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
final UserDetail user = SecurityUser.getUser();
List<TAbilityApplicationDTO> tAbilityApplicationDTOList = abilityBatchApplicationDTO.getSystem().stream().map(index -> {
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
logger.error("重复发起申请");
return null;
}
TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO();
tAbilityApplicationDTO.setArea(abilityBatchApplicationDTO.getArea());
tAbilityApplicationDTO.setAttachment(abilityBatchApplicationDTO.getAttachment());
tAbilityApplicationDTO.setBasis(abilityBatchApplicationDTO.getBasis());
tAbilityApplicationDTO.setPhone(abilityBatchApplicationDTO.getPhone());
tAbilityApplicationDTO.setScene(abilityBatchApplicationDTO.getScene());
tAbilityApplicationDTO.setInstanceId(abilityBatchApplicationDTO.getInstanceId());
tAbilityApplicationDTO.setUnit(abilityBatchApplicationDTO.getUnit());
tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser());
tAbilityApplicationDTO.setResourceId(index.get("resourceId"));
tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser());
tAbilityApplicationDTO.setSystem(index.get("resourceName"));
tAbilityApplicationDTO.setEnclosure(abilityBatchApplicationDTO.getEnclosure()); // 附件
tAbilityApplicationDTO.setUserId(abilityBatchApplicationDTO.getUserId());
tAbilityApplicationDTO.setApproveStatus("审核中");
tAbilityApplicationDTO.setDelFlag(0);
// v2 新增字段
tAbilityApplicationDTO.setCameraList(index.get("cameraId") == null ? null : JSON.toJSONString(index.get("cameraId")));
tAbilityApplicationDTO.setTitle(abilityBatchApplicationDTO.getTitle());
tAbilityApplicationDTO.setApplicationBackground(abilityBatchApplicationDTO.getApplicationBackground());
tAbilityApplicationDTO.setApplicationScene(abilityBatchApplicationDTO.getApplicationScene());
tAbilityApplicationDTO.setApplicationSystem(abilityBatchApplicationDTO.getApplicationSystem());
tAbilityApplicationDTO.setEffectWish(abilityBatchApplicationDTO.getEffectWish());
tAbilityApplicationDTO.setEnclosureName(abilityBatchApplicationDTO.getEnclosureName());
tAbilityApplicationDTO.setCreateDate(new Date());
// 归为同一次申请
tAbilityApplicationDTO.setApplyFlag(abilityBatchApplicationDTO.getApplyFlag());
// 仿照请求接口 /processForm/tabilityapplication
ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class);
tAbilityApplicationService.save(tAbilityApplicationDTO); // 写能力申请数据
if (tAbilityApplicationDTO.getId() == null) {
return null;
}
tAbilityApplicationDTO.setCompleteEntry(Boolean.TRUE);
return tAbilityApplicationDTO;
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()); // 申请入库
if (!tAbilityApplicationDTOList.isEmpty()) {
codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTOList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()), jdbcTemplate);
Map<Long, List<TAbilityApplicationDTO>> temp = tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).collect(Collectors.groupingBy(t -> {
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(t.getResourceId()));
if (resourceDTO == null && deptDTO.isPresent()) { // 资源不存在时
return deptDTO.get().getId();
}
return resourceDTO.getDeptId();
})); // 按部门分组
temp.keySet().stream().distinct().forEach(deptId -> {
if (deptId == 0L) { // 部门id不存在时
return;
}
final SysDeptDTO sysDeptDTO = sysDeptService.get(deptId);
if (sysDeptDTO == null) { // 部门不存在
return;
}
List<TAbilityApplicationDTO> dtoList = temp.get(deptId);
CompletableFuture.runAsync(() -> {
String[] sqls_ = dtoList.stream().map(index -> String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(sysDeptDTO), index.getId())).collect(Collectors.toList()).toArray(new String[dtoList.size()]);
jdbcTemplate.batchUpdate(sqls_); // 批量更新资源所属部门信息
logger.info("批量更新申请的资源的部门信息完成");
}, executor);
Boolean basic_facilities = dtoList.stream().map(index -> {
Optional<ResourceDTO> resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); // 从本库内查不到 视为其它平台的基础设施资源
return !resourceDTOOptional.isPresent() || !"基础设施".equals(resourceDTOOptional.get().getType());
}).filter(index -> !index).findAny().orElse(Boolean.TRUE);
logger.error("--------------------是否全是基础设施{}----------------------------------------------", basic_facilities);
final List<Long> ids = dtoList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()); // 发起申请的表单id
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(basic_facilities ? tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).map(TAbilityApplicationDTO::getResourceId).findFirst().orElse(null) : JSON.toJSONString(ids)); // 申请的id列表 json字符 做businesskey
processStartDTO.setProcessDefinitionKey(key); //限定
AuditingBaseDTO auditingBaseDTO = new AuditingBaseDTO();
auditingBaseDTO.setCompleteEntry(Boolean.TRUE); // 首次录入
Map<String, Object> variables = oMapper.convertValue(auditingBaseDTO, Map.class);
variables.putAll(new HashMap<String, Object>() { // 流程内携带属性值
{
put("tAbilityApplicationDTOList", dtoList); // 归属该部门的申请
put("key", processStartDTO.getBusinessKey()); // 归属该部门申请的表单id
put("deptId", deptId); // 归属部门
put("id", applyFlag); //申请id
put("creator", user == null ? null : user.getId().toString()); // 创建人
put("userId", user == null ? null : user.getId().toString()); // 创建人
put("basic_facilities", basic_facilities); // 是否为基础设施
}
});
processStartDTO.setVariables(variables);
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
CompletableFuture.runAsync(() -> {
if (dto.getBusinessKey() != null) {
String[] sqls = dtoList.stream().map(i -> String.format("UPDATE t_ability_application SET instance_id = %s WHERE id = %s", dto.getProcessInstanceId(), i.getId())).collect(Collectors.toList()).toArray(new String[dtoList.size()]);
jdbcTemplate.batchUpdate(sqls);
}
}, executor);
});
}
return new Result().ok(LocalDateTime.now().toString());
}
/**
* 批量进行批量能力申请(按资源所属部门分配审核人)
*/
@ -116,9 +252,9 @@ public class AbilityCenterControllerV2 {
tAbilityApplicationDTO.setInstanceId(abilityBatchApplicationDTO.getInstanceId());
tAbilityApplicationDTO.setUnit(abilityBatchApplicationDTO.getUnit());
tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser());
tAbilityApplicationDTO.setResourceId(index.get("resourceId").toString());
tAbilityApplicationDTO.setResourceId(index.get("resourceId"));
tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser());
tAbilityApplicationDTO.setSystem(index.get("resourceName").toString());
tAbilityApplicationDTO.setSystem(index.get("resourceName"));
tAbilityApplicationDTO.setEnclosure(abilityBatchApplicationDTO.getEnclosure()); // 附件
tAbilityApplicationDTO.setUserId(abilityBatchApplicationDTO.getUserId());
tAbilityApplicationDTO.setApproveStatus("审核中");

View File

@ -55,6 +55,8 @@
</includes>
<excludes>
<exclude>application-prod.yml</exclude>
<exclude>application-bt.yml</exclude>
<exclude>application-xha.yml</exclude>
</excludes>
<filtered>true</filtered>
<outputDirectory>${file.separator}config</outputDirectory>