同一次批量申请做好标识
This commit is contained in:
parent
e43e86b30b
commit
7a15f3ad92
|
@ -88,83 +88,84 @@ 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 -> {
|
||||
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"));
|
||||
tAbilityApplicationDTO.setTitle(abilityBatchApplicationDTO.getTitle());
|
||||
tAbilityApplicationDTO.setApplicationBackground(abilityBatchApplicationDTO.getApplicationBackground());
|
||||
tAbilityApplicationDTO.setApplicationScene(abilityBatchApplicationDTO.getApplicationScene());
|
||||
tAbilityApplicationDTO.setApplicationSystem(abilityBatchApplicationDTO.getApplicationSystem());
|
||||
tAbilityApplicationDTO.setEffectWish(abilityBatchApplicationDTO.getEffectWish());
|
||||
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"));
|
||||
tAbilityApplicationDTO.setTitle(abilityBatchApplicationDTO.getTitle());
|
||||
tAbilityApplicationDTO.setApplicationBackground(abilityBatchApplicationDTO.getApplicationBackground());
|
||||
tAbilityApplicationDTO.setApplicationScene(abilityBatchApplicationDTO.getApplicationScene());
|
||||
tAbilityApplicationDTO.setApplicationSystem(abilityBatchApplicationDTO.getApplicationSystem());
|
||||
tAbilityApplicationDTO.setEffectWish(abilityBatchApplicationDTO.getEffectWish());
|
||||
|
||||
// 仿照请求接口 /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()); // 申请入库
|
||||
// 归为同一次申请
|
||||
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()) {
|
||||
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();
|
||||
})); // 按部门分组
|
||||
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;
|
||||
}
|
||||
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()))); // 从本库内查不到 视为其它平台的基础设施资源
|
||||
return !resourceDTOOptional.isPresent() || !"基础设施".equals(resourceDTOOptional.get().getType());
|
||||
}
|
||||
)
|
||||
.filter(index -> !index).findAny().orElse(Boolean.TRUE);
|
||||
|
||||
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.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">
|
||||
|
@ -49,73 +52,73 @@
|
|||
|
||||
<select id="countApplyAll" resultType="java.lang.Long">
|
||||
SELECT
|
||||
SUM( count )
|
||||
SUM( count )
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT( 1 ) AS count
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT( id )
|
||||
FROM
|
||||
t_ability_application
|
||||
WHERE
|
||||
resource_id != 8888888880000000001
|
||||
AND instance_id != ''
|
||||
AND instance_id IS NOT NULL
|
||||
AND camera_list != ''
|
||||
AND camera_list IS NOT NULL
|
||||
GROUP BY
|
||||
instance_id
|
||||
) temp UNION
|
||||
SELECT
|
||||
COUNT( taa.id )
|
||||
FROM
|
||||
t_ability_application taa,
|
||||
tb_data_resource tdr
|
||||
WHERE
|
||||
1 = 1
|
||||
AND taa.resource_id = tdr.id
|
||||
AND tdr.type != '赋能案例'
|
||||
AND tdr.del_flag = 0
|
||||
GROUP BY
|
||||
tdr.type
|
||||
) temp2
|
||||
(
|
||||
SELECT
|
||||
COUNT( 1 ) AS count
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT( id )
|
||||
FROM
|
||||
t_ability_application
|
||||
WHERE
|
||||
resource_id != 8888888880000000001
|
||||
AND instance_id != ''
|
||||
AND instance_id IS NOT NULL
|
||||
AND camera_list != ''
|
||||
AND camera_list IS NOT NULL
|
||||
GROUP BY
|
||||
instance_id
|
||||
) temp UNION
|
||||
SELECT
|
||||
COUNT( taa.id )
|
||||
FROM
|
||||
t_ability_application taa,
|
||||
tb_data_resource tdr
|
||||
WHERE
|
||||
1 = 1
|
||||
AND taa.resource_id = tdr.id
|
||||
AND tdr.type != '赋能案例'
|
||||
AND tdr.del_flag = 0
|
||||
GROUP BY
|
||||
tdr.type
|
||||
) temp2
|
||||
</select>
|
||||
|
||||
<select id="getAmountGroupByType" resultType="java.util.Map">
|
||||
SELECT
|
||||
'基础设施' AS 'type',
|
||||
COUNT( 1 ) AS 'amount'
|
||||
'基础设施' AS 'type',
|
||||
COUNT( 1 ) AS 'amount'
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT( id )
|
||||
FROM
|
||||
t_ability_application
|
||||
WHERE
|
||||
resource_id != 8888888880000000001
|
||||
AND instance_id != ''
|
||||
AND instance_id IS NOT NULL
|
||||
AND camera_list != ''
|
||||
AND camera_list IS NOT NULL
|
||||
GROUP BY
|
||||
instance_id
|
||||
) temp UNION
|
||||
(
|
||||
SELECT
|
||||
tdr.type,
|
||||
COUNT( taa.id )
|
||||
COUNT( id )
|
||||
FROM
|
||||
t_ability_application taa,
|
||||
tb_data_resource tdr
|
||||
t_ability_application
|
||||
WHERE
|
||||
1 = 1
|
||||
AND taa.resource_id = tdr.id
|
||||
AND tdr.type != '赋能案例'
|
||||
AND tdr.del_flag = 0
|
||||
resource_id != 8888888880000000001
|
||||
AND instance_id != ''
|
||||
AND instance_id IS NOT NULL
|
||||
AND camera_list != ''
|
||||
AND camera_list IS NOT NULL
|
||||
GROUP BY
|
||||
tdr.type
|
||||
instance_id
|
||||
) temp UNION
|
||||
SELECT
|
||||
tdr.type,
|
||||
COUNT( taa.id )
|
||||
FROM
|
||||
t_ability_application taa,
|
||||
tb_data_resource tdr
|
||||
WHERE
|
||||
1 = 1
|
||||
AND taa.resource_id = tdr.id
|
||||
AND tdr.type != '赋能案例'
|
||||
AND tdr.del_flag = 0
|
||||
GROUP BY
|
||||
tdr.type
|
||||
</select>
|
||||
|
||||
<select id="selectDeptApplyCount" resultType="java.util.Map">
|
||||
|
|
Loading…
Reference in New Issue