同一次批量申请做好标识

This commit is contained in:
wangliwen 2022-07-11 14:32:25 +08:00
parent e43e86b30b
commit 7a15f3ad92
6 changed files with 152 additions and 124 deletions

View File

@ -88,10 +88,11 @@ public class AbilityCenterControllerV2 {
if (page.getTotal() <= 0) { // if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程"); return new Result().error("联系管理员添加流程");
} }
abilityBatchApplicationDTO.setApplyFlag(UUID.randomUUID().toString()); // 同一次的申请标识
final Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName)); final Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
final UserDetail user = SecurityUser.getUser(); final UserDetail user = SecurityUser.getUser();
List<TAbilityApplicationDTO> tAbilityApplicationDTOList = List<TAbilityApplicationDTO> tAbilityApplicationDTOList = abilityBatchApplicationDTO.getSystem().stream().map(index -> {
abilityBatchApplicationDTO.getSystem().stream().map(index -> {
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请 if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
logger.error("重复发起申请"); logger.error("重复发起申请");
return null; return null;
@ -120,6 +121,9 @@ public class AbilityCenterControllerV2 {
tAbilityApplicationDTO.setApplicationSystem(abilityBatchApplicationDTO.getApplicationSystem()); tAbilityApplicationDTO.setApplicationSystem(abilityBatchApplicationDTO.getApplicationSystem());
tAbilityApplicationDTO.setEffectWish(abilityBatchApplicationDTO.getEffectWish()); tAbilityApplicationDTO.setEffectWish(abilityBatchApplicationDTO.getEffectWish());
// 归为同一次申请
tAbilityApplicationDTO.setApplyFlag(abilityBatchApplicationDTO.getApplyFlag());
// 仿照请求接口 /processForm/tabilityapplication // 仿照请求接口 /processForm/tabilityapplication
ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class);
tAbilityApplicationService.save(tAbilityApplicationDTO); // 写能力申请数据 tAbilityApplicationService.save(tAbilityApplicationDTO); // 写能力申请数据
@ -130,8 +134,7 @@ public class AbilityCenterControllerV2 {
return tAbilityApplicationDTO; return tAbilityApplicationDTO;
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()); // 申请入库 }).filter(ObjectUtil::isNotNull).collect(Collectors.toList()); // 申请入库
if (!tAbilityApplicationDTOList.isEmpty()) { if (!tAbilityApplicationDTOList.isEmpty()) {
Map<Long, List<TAbilityApplicationDTO>> temp = Map<Long, List<TAbilityApplicationDTO>> temp = tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).collect(Collectors.groupingBy(t -> {
tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).collect(Collectors.groupingBy(t -> {
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(t.getResourceId())); ResourceDTO resourceDTO = resourceService.get(Long.valueOf(t.getResourceId()));
if (resourceDTO == null && deptDTO.isPresent()) { // 资源不存在时 if (resourceDTO == null && deptDTO.isPresent()) { // 资源不存在时
return deptDTO.get().getId(); return deptDTO.get().getId();
@ -142,29 +145,27 @@ public class AbilityCenterControllerV2 {
if (deptId == 0L) { // 部门id不存在时 if (deptId == 0L) { // 部门id不存在时
return; return;
} }
if (sysDeptService.get(deptId) == null) { // 部门不存在 final SysDeptDTO sysDeptDTO = sysDeptService.get(deptId);
if (sysDeptDTO == null) { // 部门不存在
return; return;
} }
List<TAbilityApplicationDTO> dtoList = temp.get(deptId); List<TAbilityApplicationDTO> dtoList = temp.get(deptId);
Boolean basic_facilities =
dtoList.stream().map(index -> { CompletableFuture.runAsync(() -> {
Optional<ResourceDTO> resourceDTOOptional = 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()]);
Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); // 从本库内查不到 视为其它平台的基础设施资源 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()); 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); logger.error("--------------------是否全是基础设施{}----------------------------------------------", basic_facilities);
final List<Long> ids = dtoList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()); // 发起申请的表单id final List<Long> ids = dtoList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()); // 发起申请的表单id
// 仿照请求接口 /act/running/startOfBusinessKey // 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO(); ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(basic_facilities ? processStartDTO.setBusinessKey(basic_facilities ? tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).map(TAbilityApplicationDTO::getResourceId).findFirst().orElse(null) : JSON.toJSONString(ids)); // 申请的id列表 json字符 做businesskey
tAbilityApplicationDTOList.stream()
.filter(index -> StringUtils.isNotEmpty(index.getResourceId()))
.map(TAbilityApplicationDTO::getResourceId)
.findFirst()
.orElse(null)
: JSON.toJSONString(ids)); // 申请的id列表 json字符 做businesskey
processStartDTO.setProcessDefinitionKey(key); //限定 processStartDTO.setProcessDefinitionKey(key); //限定
AuditingBaseDTO auditingBaseDTO = new AuditingBaseDTO(); AuditingBaseDTO auditingBaseDTO = new AuditingBaseDTO();
auditingBaseDTO.setCompleteEntry(Boolean.TRUE); // 首次录入 auditingBaseDTO.setCompleteEntry(Boolean.TRUE); // 首次录入
@ -190,9 +191,7 @@ public class AbilityCenterControllerV2 {
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
if (dto.getBusinessKey() != null) { if (dto.getBusinessKey() != null) {
String[] sqls = 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()]);
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); jdbcTemplate.batchUpdate(sqls);
} }
}, executor); }, executor);

View File

@ -1,7 +1,7 @@
package io.renren.modules.processForm.dto; package io.renren.modules.processForm.dto;
import io.renren.common.dto.AuditingBaseDTO; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -72,4 +72,10 @@ public class TAbilityApplicationDTO extends AuditingBaseDTO implements Serializa
@ApiModelProperty(value = "能力应用期望效果") @ApiModelProperty(value = "能力应用期望效果")
private String effectWish; private String effectWish;
@ApiModelProperty(value = "申请单标识(同一次的申请标识)")
private String applyFlag;
@ApiModelProperty(value = "资源所属部门信息")
private SysDeptDTO resourceOwnerDept;
} }

View File

@ -1,7 +1,7 @@
package io.renren.modules.processForm.dto; package io.renren.modules.processForm.dto;
import io.renren.common.dto.AuditingBaseDTO; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -66,4 +66,10 @@ public class TAbilityBatchApplicationDTO extends AuditingBaseDTO implements Seri
@ApiModelProperty(value = "能力应用期望效果") @ApiModelProperty(value = "能力应用期望效果")
private String effectWish; private String effectWish;
@ApiModelProperty(value = "申请单标识(同一次的申请标识)")
private String applyFlag;
@ApiModelProperty(value = "资源所属部门信息")
private SysDeptDTO resourceOwnerDept;
} }

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import io.renren.modules.sys.dto.SysDeptDTO;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -126,4 +127,15 @@ public class TAbilityApplicationEntity implements Serializable {
* 能力应用期望效果 * 能力应用期望效果
*/ */
private String effectWish; private String effectWish;
/**
* 申请单标识(同一次的申请标识)
*/
private String applyFlag;
/**
* 资源所属部门信息
*/
private SysDeptDTO resourceOwnerDept;
} }

View File

@ -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 '资源所属部门信息';

View File

@ -23,6 +23,9 @@
<result property="cameraList" column="camera_list"/> <result property="cameraList" column="camera_list"/>
<result property="applicationScene" column="application_scene" <result property="applicationScene" column="application_scene"
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/> 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> </resultMap>
<update id="updateInstanceId"> <update id="updateInstanceId">