同一次批量申请做好标识
This commit is contained in:
parent
e43e86b30b
commit
7a15f3ad92
|
@ -88,10 +88,11 @@ public class AbilityCenterControllerV2 {
|
|||
if (page.getTotal() <= 0) { //
|
||||
return new Result().error("联系管理员添加流程");
|
||||
}
|
||||
abilityBatchApplicationDTO.setApplyFlag(UUID.randomUUID().toString()); // 同一次的申请标识
|
||||
|
||||
final Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
|
||||
final UserDetail user = SecurityUser.getUser();
|
||||
List<TAbilityApplicationDTO> tAbilityApplicationDTOList =
|
||||
abilityBatchApplicationDTO.getSystem().stream().map(index -> {
|
||||
List<TAbilityApplicationDTO> tAbilityApplicationDTOList = abilityBatchApplicationDTO.getSystem().stream().map(index -> {
|
||||
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
|
||||
logger.error("重复发起申请");
|
||||
return null;
|
||||
|
@ -120,6 +121,9 @@ public class AbilityCenterControllerV2 {
|
|||
tAbilityApplicationDTO.setApplicationSystem(abilityBatchApplicationDTO.getApplicationSystem());
|
||||
tAbilityApplicationDTO.setEffectWish(abilityBatchApplicationDTO.getEffectWish());
|
||||
|
||||
// 归为同一次申请
|
||||
tAbilityApplicationDTO.setApplyFlag(abilityBatchApplicationDTO.getApplyFlag());
|
||||
|
||||
// 仿照请求接口 /processForm/tabilityapplication
|
||||
ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class);
|
||||
tAbilityApplicationService.save(tAbilityApplicationDTO); // 写能力申请数据
|
||||
|
@ -130,8 +134,7 @@ public class AbilityCenterControllerV2 {
|
|||
return tAbilityApplicationDTO;
|
||||
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()); // 申请入库
|
||||
if (!tAbilityApplicationDTOList.isEmpty()) {
|
||||
Map<Long, List<TAbilityApplicationDTO>> temp =
|
||||
tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).collect(Collectors.groupingBy(t -> {
|
||||
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();
|
||||
|
@ -142,29 +145,27 @@ public class AbilityCenterControllerV2 {
|
|||
if (deptId == 0L) { // 部门id不存在时
|
||||
return;
|
||||
}
|
||||
if (sysDeptService.get(deptId) == null) { // 部门不存在
|
||||
final SysDeptDTO sysDeptDTO = sysDeptService.get(deptId);
|
||||
if (sysDeptDTO == null) { // 部门不存在
|
||||
return;
|
||||
}
|
||||
List<TAbilityApplicationDTO> dtoList = temp.get(deptId);
|
||||
Boolean basic_facilities =
|
||||
dtoList.stream().map(index -> {
|
||||
Optional<ResourceDTO> resourceDTOOptional =
|
||||
Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); // 从本库内查不到 视为其它平台的基础设施资源
|
||||
|
||||
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);
|
||||
}).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.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); // 首次录入
|
||||
|
@ -190,9 +191,7 @@ public class AbilityCenterControllerV2 {
|
|||
// 仿照请求接口 /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()]);
|
||||
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);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.renren.modules.processForm.dto;
|
||||
|
||||
import io.renren.common.dto.AuditingBaseDTO;
|
||||
import io.renren.modules.monitor.entity.CameraChannel;
|
||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -72,4 +72,10 @@ public class TAbilityApplicationDTO extends AuditingBaseDTO implements Serializa
|
|||
@ApiModelProperty(value = "能力应用期望效果")
|
||||
private String effectWish;
|
||||
|
||||
@ApiModelProperty(value = "申请单标识(同一次的申请标识)")
|
||||
private String applyFlag;
|
||||
|
||||
@ApiModelProperty(value = "资源所属部门信息")
|
||||
private SysDeptDTO resourceOwnerDept;
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package io.renren.modules.processForm.dto;
|
||||
|
||||
import io.renren.common.dto.AuditingBaseDTO;
|
||||
import io.renren.modules.monitor.entity.CameraChannel;
|
||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -66,4 +66,10 @@ public class TAbilityBatchApplicationDTO extends AuditingBaseDTO implements Seri
|
|||
|
||||
@ApiModelProperty(value = "能力应用期望效果")
|
||||
private String effectWish;
|
||||
|
||||
@ApiModelProperty(value = "申请单标识(同一次的申请标识)")
|
||||
private String applyFlag;
|
||||
|
||||
@ApiModelProperty(value = "资源所属部门信息")
|
||||
private SysDeptDTO resourceOwnerDept;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -126,4 +127,15 @@ public class TAbilityApplicationEntity implements Serializable {
|
|||
* 能力应用期望效果
|
||||
*/
|
||||
private String effectWish;
|
||||
|
||||
/**
|
||||
* 申请单标识(同一次的申请标识)
|
||||
*/
|
||||
private String applyFlag;
|
||||
|
||||
|
||||
/**
|
||||
* 资源所属部门信息
|
||||
*/
|
||||
private SysDeptDTO resourceOwnerDept;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
alter table `t_ability_application` ADD COLUMN `apply_flag` varchar(255) NULL comment '申请单标识';
|
||||
alter table `t_ability_application` ADD COLUMN `resource_owner_dept` json NULL comment '资源所属部门信息';
|
|
@ -23,6 +23,9 @@
|
|||
<result property="cameraList" column="camera_list"/>
|
||||
<result property="applicationScene" column="application_scene"
|
||||
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
|
||||
<result property="applyFlag" column="apply_flag"/>
|
||||
<result property="resourceOwnerDept" column="resource_owner_dept"
|
||||
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<update id="updateInstanceId">
|
||||
|
|
Loading…
Reference in New Issue