修改:知识库列表审批人批量查询返回

This commit is contained in:
yangyang01000846
2025-11-18 16:17:16 +08:00
parent 83e579f8ad
commit 3cc72ef110
14 changed files with 278 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
package com.sdm.common.entity.req.system;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "批量查询CID电子流状态请求参数")
@Data
public class FlowStatusParam {
// `spdm_baseline`.`simulation_approve_flow`.templateId
private String flowId;
// `spdm_baseline`.`simulation_approve_flow`.cidFlowId
private String processInstanceId;
// `spdm_baseline`.`simulation_approve_flow`.tenantId
private String tenantId;
}

View File

@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
@Slf4j
@@ -16,6 +17,7 @@ public class ApproveFeignClientImpl implements IApproveFeignClient {
@Autowired
private IApproveFeignClient approveFeignClient;
@Override
public SdmResponse launchApproval( LaunchApproveReq approveReq) {
@@ -32,4 +34,21 @@ public class ApproveFeignClientImpl implements IApproveFeignClient {
}
return response;
}
@Override
public SdmResponse queryBatchApproveFlowStatus(List<String> flowIds) {
SdmResponse response=null ;
try {
response = approveFeignClient.queryBatchApproveFlowStatus(flowIds);
if(response==null||!response.isSuccess()){
log.error("queryBatchApproveFlowStatus failed response:{}", JSONObject.toJSONString(Optional.ofNullable(response)));
return SdmResponse.failed("批量查询失败");
}
} catch (Exception e) {
log.error("queryBatchApproveFlowStatus error response:{}", JSONObject.toJSONString(Optional.ofNullable(response)));
return SdmResponse.failed("批量查询异常");
}
return response;
}
}

View File

@@ -5,8 +5,17 @@ import com.sdm.common.entity.req.system.LaunchApproveReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(name = "system",contextId = "systemApproveClient")
public interface IApproveFeignClient {
@PostMapping("/systemApprove/launchApprove")
public SdmResponse launchApproval( @RequestBody LaunchApproveReq approveReq);
// 批量查询审批电子流详情配置可配当前限制500条/次
@PostMapping("/systemApprove/queryBatchApproveFlowStatus")
public SdmResponse queryBatchApproveFlowStatus(@RequestBody List<String> flowIds);
}

View File

@@ -0,0 +1,56 @@
package com.sdm.common.utils;
import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sdm.common.log.CoreLogger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CidApproveUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
/**
* 将原始 Object 数据转换为 Map<flowId, List<Map对应电子流各节点详情的信息>>
* @param data 原始数据(格式为外层数组,内部包含一个 key-value 对象)
* @return 转换后的 Mapkey 为 uuid 字符串value 为节点信息列表
*/
public static Map<String, List<Map<String, Object>>> convertApproveFlowInfos(Object data) {
Map<String, List<Map<String, Object>>> result = new HashMap<>();
try {
// 1. 将 data 转换为最外层的 JSON 数组List<Object>
List<Object> outerList = objectMapper.convertValue(
data,new TypeReference<List<Object>>() {}
);
// 2. 取数组的第一个元素(唯一的对象),转换为 Map<String, Object>
if (outerList == null || outerList.isEmpty()) {
CoreLogger.warn("convertApproveFlowInfos param null,param:{}", JSON.toJSONString(data));
return result;
}
Object firstElement = outerList.get(0);
Map<String, Object> innerMap = objectMapper.convertValue(
firstElement,
new TypeReference<Map<String, Object>>() {}
);
// 3. 遍历 innerMap将每个 value 转换为 List<Map<String, Object>>
result = new java.util.HashMap<>();
for (Map.Entry<String, Object> entry : innerMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
// 将 value节点数组转换为 List<Map>
List<Map<String, Object>> nodeList = objectMapper.convertValue(
value,
new TypeReference<List<Map<String, Object>>>() {}
);
result.put(key, nodeList);
}
} catch (IllegalArgumentException e) {
CoreLogger.warn("convertApproveFlowInfos error,param:{},errMsg:{}",
JSON.toJSONString(data),JSON.toJSONString(e.getMessage()));
}
return result;
}
}

View File

@@ -2,8 +2,6 @@ package com.sdm.data.model.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -188,4 +186,9 @@ public class FileMetadataInfo implements Serializable {
@TableField(value = "cidFlowId")
private String cidFlowId;
@Schema(description= "cidFlowReviewer:cid审核电子流程里面的评审人,只有列表展示使用")
@TableField(value = "cidFlowReviewer", insertStrategy = FieldStrategy.NEVER,select = false,updateStrategy = FieldStrategy.NEVER)
private String cidFlowReviewer;
}

View File

@@ -22,6 +22,8 @@ import com.sdm.common.entity.resp.system.CIDUserResp;
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
import com.sdm.common.feign.inter.system.IApproveFeignClient;
import com.sdm.common.log.CoreLogger;
import com.sdm.common.utils.CidApproveUtil;
import com.sdm.common.utils.CidSysUserUtil;
import com.sdm.common.utils.PageUtils;
import com.sdm.data.model.bo.ApprovalFileDataContentsModel;
@@ -38,6 +40,7 @@ import com.sdm.data.service.impl.dataFileHandle.ApproveStrategyFactory;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.assertj.core.util.DateUtil;
@@ -95,7 +98,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
private IFielPermissionDictService filePermissionDictService;
@Autowired
SysUserFeignClientImpl sysUserFeignClient;
private SysUserFeignClientImpl sysUserFeignClient;
@Autowired
private IMinioService minioService;
@@ -646,6 +649,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
.in(FileMetadataInfo::getApproveType,fileDatdList)
.list();
setCreatorNames(files);
setCidInfos(files);
PageDataResp<List<FileMetadataInfo>> page = new PageDataResp<>();
page.setData(files);
page.setTotal(pageDataResp.getTotal());
@@ -697,6 +701,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
.list();
// 创建人赋值
setCreatorNames(list);
setCidInfos(list);
PageInfo<FileMetadataInfo> page = new PageInfo<>(list);
return PageUtils.getJsonObjectSdmResponse(list, page);
}
@@ -1771,7 +1776,6 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
SdmResponse<List<CIDUserResp>> userListSdmRsp = sysUserFeignClient.listUserByIds(
UserQueryReq.builder().userIds(creatorIds).build()
);
// 批量设置 creatorName
if (userListSdmRsp.isSuccess() && CollectionUtils.isNotEmpty(userListSdmRsp.getData())) {
Map<Long, CIDUserResp> cidUserMap = CidSysUserUtil.getCidUserToMap(userListSdmRsp.getData());
@@ -1792,6 +1796,58 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
}
}
private void setCidInfos(List<FileMetadataInfo> list) {
try {
if (ObjectUtils.isNotEmpty(list)) {
// 提取评审的cidFlowId,当前不可能超过500无需分批
List<String> cidFlowIds = list.stream()
.map(FileMetadataInfo::getCidFlowId)
.filter(Objects::nonNull)
.distinct()
.toList();
// 查询电子流详情
SdmResponse sdmResponse = approveFeignClient.queryBatchApproveFlowStatus(cidFlowIds);
// JSONArray array
Object data = sdmResponse.getData();
// 批量设置
if (sdmResponse.isSuccess() && !Objects.isNull(data)) {
Map<String, List<Map<String, Object>>> flowInfosMap = CidApproveUtil.convertApproveFlowInfos(data);
if(MapUtils.isNotEmpty(flowInfosMap)){
list.forEach(fileMetadataInfo -> {
String cidFlowId = fileMetadataInfo.getCidFlowId();
List<Map<String, Object>> flowInfos = flowInfosMap.get(cidFlowId);
fileMetadataInfo.setCidFlowReviewer(getCidFlowReviewer(flowInfos));
});
}
}
}
} catch (Exception e) {
log.error("setCreatorNames error:{}",e.getMessage());
}
}
// 从审批详情里拼接审批人
private String getCidFlowReviewer(List<Map<String, Object>> flowInfos) {
try {
if (CollectionUtils.isEmpty(flowInfos)) {
CoreLogger.warn("getCidFlowReviewer flowInfos null");
return "";
}
StringBuilder sb = new StringBuilder();
flowInfos.forEach(flowInfo -> {
// flowInfo非空nodeType非空且非0发起人nodeUserName非空
if (!Objects.isNull(flowInfo) && !Objects.isNull(flowInfo.get("nodeType")) &&
!Objects.equals(NumberConstants.ZERO, flowInfo.get("nodeType")) && !Objects.isNull(flowInfo.get("nodeUserName"))) {
sb.append(flowInfo.get("nodeUserName")).append(",");
}
});
String resultStr = sb.toString();
resultStr.substring(0, resultStr.length() - 1);
return resultStr;
} catch (Exception e) {
CoreLogger.error("getCidFlowReviewer error,param:{},errMsg:{}", JSONObject.toJSONString(flowInfos), e.getMessage());
return "";
}
}
}

View File

@@ -10,6 +10,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 系统评审
@@ -48,6 +50,16 @@ public class SystemApproveController implements IApproveFeignClient {
return approveServer.queryApproveFlowStatus(flowId);
}
/**
* 根据flowId批量查询审批详情
* @param flowIds
* @return
*/
@PostMapping("queryBatchApproveFlowStatus")
public SdmResponse queryBatchApproveFlowStatus(@RequestBody List<String> flowIds) {
return approveServer.queryBatchApproveFlowStatus(flowIds);
}
@PostMapping("/stopApprove")
public SdmResponse stopApproval(@RequestParam ("flowId") String flowId) {
return approveServer.stopCidApprovalFlow(flowId);

View File

@@ -1,8 +1,11 @@
package com.sdm.system.dao;
import com.sdm.common.entity.req.system.FlowStatusParam;
import com.sdm.common.entity.req.system.LaunchApproveReq;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface SimulationApproveMapper {
@@ -19,4 +22,16 @@ public interface SimulationApproveMapper {
@Select("SELECT * FROM simulation_approve_flow WHERE cidFlowId=#{flowId} LIMIT 1")
LaunchApproveReq querySimulationApproveFlowByCidFlowId(@Param("flowId") String flowId);
@Select({
"<script>",
"SELECT templateId AS flowId, cidFlowId AS processInstanceId, tenantId AS tenantId",
"FROM simulation_approve_flow",
"WHERE cidFlowId IN",
"<foreach collection='flowIds' item='flowId' open='(' close=')' separator=','>",
" #{flowId}",
"</foreach>",
"</script>"
})
List<FlowStatusParam> queryBatchFlowStatusFromSpdmDb(@Param("flowIds")List<String> flowIds);
}

View File

@@ -4,6 +4,8 @@ package com.sdm.system.service;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.req.system.LaunchApproveReq;
import java.util.List;
/**
* <p>
* 系统提交评审服务
@@ -56,6 +58,8 @@ public interface ISimulatinoApprovalService {
*/
SdmResponse queryApproveFlowStatus(String flowId);
SdmResponse queryBatchApproveFlowStatus(List<String> flowIds);
/**
* 查询流程实例详情
* @param flowId

View File

@@ -5,7 +5,9 @@ import com.alibaba.fastjson2.JSONObject;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.constants.NumberConstants;
import com.sdm.common.entity.req.system.FlowStatusParam;
import com.sdm.common.entity.req.system.LaunchApproveReq;
import com.sdm.common.log.CoreLogger;
import com.sdm.common.utils.HttpClientUtil;
import com.sdm.system.dao.SimulationApproveMapper;
import com.sdm.system.model.entity.ApproveTemplateBean;
@@ -13,6 +15,7 @@ import com.sdm.system.service.ISimulatinoApprovalService;
import com.sdm.system.service.impl.approvalNotice.ApproveNoticeStrategy;
import com.sdm.system.service.impl.approvalNotice.ApproveNoticeStrategyFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -29,7 +32,6 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
@Autowired
private HttpClientUtil httpClientUtil;
@Autowired
private SimulationApproveMapper approveMapper;
@@ -51,6 +53,13 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
@Value("${cid.flow.group}")
private String groupName;
// 单次批量查询cid流程的条数,默认500
@Value("${cid.flow.batchCount:500}")
private Integer cidBatchCounts;
@Value("${cid.flow.batchInterfacePath:/spdm-flow/listFlowNodeDetail}")
private String batchInterfacePath;
@Autowired
private ApproveNoticeStrategyFactory approveNoticeStrategyFactory;
@@ -118,6 +127,37 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
return array;
}
/**
* 批量获取Cid评审流程状态
* @param url
* @param flowParamDtoList
* @return
*/
private JSONArray queryBatchCidApproveFlowStatus( String url,List<FlowStatusParam> flowParamDtoList)
{
JSONObject paramJson = new JSONObject();
paramJson.put("flowParamDtoList",flowParamDtoList);
JSONArray array = null;
try {
String resultString = httpClientUtil.doPostJson(url, paramJson.toJSONString());
if (resultString != null && !resultString.isEmpty()) {
JSONObject resultJson = JSONObject.parseObject(resultString);
if (resultJson != null && resultJson.containsKey("success")) {
boolean success = resultJson.getBoolean("success");
if (success) {
array = resultJson.getJSONArray("data");
}
}
}
}
catch (Exception e)
{
CoreLogger.error("queryBatchCidApproveFlowStatus error,params:{},errMsg:{}",JSONObject.toJSONString(flowParamDtoList),e.getMessage());
e.printStackTrace();
}
return array;
}
/**
* 停止CID评审流程
* @param cidFlowId
@@ -242,6 +282,30 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
return sdmResponse;
}
@Override
public SdmResponse queryBatchApproveFlowStatus(List<String> flowIds) {
SdmResponse sdmResponse ;
if(CollectionUtils.isEmpty(flowIds)){
sdmResponse= SdmResponse.failed("参数null非法");
return sdmResponse;
}
if(flowIds.size()>cidBatchCounts){
sdmResponse= SdmResponse.failed("单次查询数据不允许超过"+cidBatchCounts+"");
return sdmResponse;
}
List<FlowStatusParam> flowStatusParamList= approveMapper.queryBatchFlowStatusFromSpdmDb(flowIds);
String url = cidUrl+batchInterfacePath;
JSONArray array = queryBatchCidApproveFlowStatus(url, flowStatusParamList);
if(array != null){
sdmResponse = SdmResponse.success();
sdmResponse.setData(array);
}
else{
sdmResponse = SdmResponse.failed("获取评审流程状态信息失败");
}
return sdmResponse;
}
/**
* 接收CID审批流状态
* @param cidFlowId

View File

@@ -158,4 +158,7 @@ cid:
queryApproveDetail: /spdm-flow/queryFlowNodeDetail
stopApproveFlow: /spdm-flow/stopFlow
group: SPDM
# 单次批量查询cid审批流详情的条数
batchCount: 500
# 批量查询的cid 接口配合上面url使用
batchInterfacePath: /spdm-flow/listFlowNodeDetail

View File

@@ -158,6 +158,10 @@ cid:
queryApproveDetail: /spdm-flow/queryFlowNodeDetail
stopApproveFlow: /spdm-flow/stopFlow
group: SPDM
# 单次批量查询cid审批流详情的条数
batchCount: 500
# 批量查询的cid 接口配合上面url使用
batchInterfacePath: /spdm-flow/listFlowNodeDetail
# 0单机处理可以指向本地1负载均衡轮询
serverType: 0

View File

@@ -169,4 +169,8 @@ cid:
queryFlowTemplate: /spdm-flow/listProcessByGroup
queryApproveDetail: /spdm-flow/queryFlowNodeDetail
stopApproveFlow: /spdm-flow/stopFlow
group: SPDM
group: SPDM
# 单次批量查询cid审批流详情的条数
batchCount: 500
# 批量查询的cid 接口配合上面url使用
batchInterfacePath: /spdm-flow/listFlowNodeDetail

View File

@@ -160,4 +160,9 @@ cid:
listRoles: /spdm-role/listRoles
tenant:
getTenantDetailById: /spdm-tenant/getTenantDetailById
listTenant: /spdm-tenant/listTenant
listTenant: /spdm-tenant/listTenant
flow:
# 单次批量查询cid审批流详情的条数
batchCount: 500
# 批量查询的cid 接口配合上面url使用
batchInterfacePath: /spdm-flow/listFlowNodeDetail