1、新增合并查询节点信息接口
This commit is contained in:
@@ -32,6 +32,16 @@ public class TagMapService {
|
|||||||
return tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName));
|
return tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getTagMapValue() {
|
||||||
|
SdmResponse<List<DataDictionary>> tagMapList = sysConfigFeignClient.getDictionaryData(TagConstant.DICTIONARY_TAG_KEY);
|
||||||
|
if (!tagMapList.isSuccess() || ObjectUtils.isEmpty(tagMapList.getData())) {
|
||||||
|
log.error("字典信息查询失败");
|
||||||
|
return emptyMap();
|
||||||
|
}
|
||||||
|
// project-->tag1 phase-->tag2
|
||||||
|
return tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictName, DataDictionary::getDictValue));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否节点类型
|
* 是否节点类型
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -303,4 +303,10 @@ public class SimulationTaskController implements ISimulationTaskFeignClient {
|
|||||||
return taskService.importSimulationPerformance(file,columns,taskId,taskName,runId);
|
return taskService.importSimulationPerformance(file,columns,taskId,taskName,runId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/mergeQueryNode")
|
||||||
|
@Operation(summary = "合并查询节点信息", description = "合并查询节点信息")
|
||||||
|
public SdmResponse mergeQueryNode(@RequestBody SpdmMergeQueryNodeReq req) {
|
||||||
|
return taskService.mergeQueryNode(req);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.sdm.project.model.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpdmMergeQueryNodeReq {
|
||||||
|
|
||||||
|
// 如果是任务或算例就传:task或run,其他的传tag1到tag10
|
||||||
|
@Schema(description = "查询类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.sdm.project.model.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class NodeMergeQueryResp {
|
||||||
|
|
||||||
|
// 具体的节点(任务、算例)名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 合并后的id集合
|
||||||
|
private List<String> value;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -108,4 +108,6 @@ public interface ITaskService {
|
|||||||
|
|
||||||
SdmResponse importSimulationPerformance(MultipartFile file, String columns,String taskId,String taskName,String runId);
|
SdmResponse importSimulationPerformance(MultipartFile file, String columns,String taskId,String taskName,String runId);
|
||||||
|
|
||||||
|
SdmResponse mergeQueryNode(SpdmMergeQueryNodeReq req);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.sdm.common.feign.inter.system.ISysLogFeignClient;
|
|||||||
import com.sdm.common.log.constants.ModuleConstants;
|
import com.sdm.common.log.constants.ModuleConstants;
|
||||||
import com.sdm.common.log.constants.OperateTypeConstants;
|
import com.sdm.common.log.constants.OperateTypeConstants;
|
||||||
import com.sdm.common.log.dto.SysLogDTO;
|
import com.sdm.common.log.dto.SysLogDTO;
|
||||||
|
import com.sdm.common.service.TagMapService;
|
||||||
import com.sdm.common.utils.RandomUtil;
|
import com.sdm.common.utils.RandomUtil;
|
||||||
import com.sdm.common.utils.SystemOperate;
|
import com.sdm.common.utils.SystemOperate;
|
||||||
import com.sdm.common.utils.excel.ExcelUtil;
|
import com.sdm.common.utils.excel.ExcelUtil;
|
||||||
@@ -46,6 +47,7 @@ import com.sdm.outbridge.service.lyric.LyricVProjectResourcePlanDMService;
|
|||||||
import com.sdm.project.bo.ExportOperate;
|
import com.sdm.project.bo.ExportOperate;
|
||||||
import com.sdm.project.common.MemberTypeEnum;
|
import com.sdm.project.common.MemberTypeEnum;
|
||||||
import com.sdm.project.common.TaskExeStatusEnum;
|
import com.sdm.project.common.TaskExeStatusEnum;
|
||||||
|
import com.sdm.project.common.TaskQryTypeEnum;
|
||||||
import com.sdm.project.dao.SimulationDemandMapper;
|
import com.sdm.project.dao.SimulationDemandMapper;
|
||||||
import com.sdm.project.dao.SimulationNodeMapper;
|
import com.sdm.project.dao.SimulationNodeMapper;
|
||||||
import com.sdm.project.dao.SimulationProjectMapper;
|
import com.sdm.project.dao.SimulationProjectMapper;
|
||||||
@@ -161,6 +163,9 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DataClientFeignClientImpl dataFeignClient;
|
private DataClientFeignClientImpl dataFeignClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TagMapService tagMapService;
|
||||||
|
|
||||||
// 通过标识判断是否走查询现场视图逻辑(0不查询,1查询)
|
// 通过标识判断是否走查询现场视图逻辑(0不查询,1查询)
|
||||||
@Value("${lyricFlag:1}")
|
@Value("${lyricFlag:1}")
|
||||||
private int lyricFlag;
|
private int lyricFlag;
|
||||||
@@ -174,6 +179,12 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
|
|
||||||
private static final float EPSILON = 1e-6f;
|
private static final float EPSILON = 1e-6f;
|
||||||
|
|
||||||
|
// 合并查询接口中查询任务时的参数值
|
||||||
|
public static final String MERGE_QUERY_TASK = "task";
|
||||||
|
|
||||||
|
// 合并查询接口中查询算例时的参数值
|
||||||
|
public static final String MERGE_QUERY_RUN = "run";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预处理请求参数
|
* 预处理请求参数
|
||||||
@@ -778,7 +789,7 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
// 之前同步创建的需求、任务时,创建人用的工号,这里先兼容处理下
|
// 之前同步创建的需求、任务时,创建人用的工号,这里先兼容处理下
|
||||||
Long creator = newTaskVo.getCreator();
|
Long creator = newTaskVo.getCreator();
|
||||||
Long userId;
|
Long userId;
|
||||||
if (getDigitCount(creator) < LYRIC_JOB_NUMBER_LENGTH) {
|
if (creator != null && getDigitCount(creator) < LYRIC_JOB_NUMBER_LENGTH) {
|
||||||
// 不足五位的前面补0
|
// 不足五位的前面补0
|
||||||
userId = usernameToUserIdMap.get(formatUserId(creator));
|
userId = usernameToUserIdMap.get(formatUserId(creator));
|
||||||
}else {
|
}else {
|
||||||
@@ -4337,6 +4348,80 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
return SdmResponse.success();
|
return SdmResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse mergeQueryNode(SpdmMergeQueryNodeReq req) {
|
||||||
|
if (ObjectUtils.isEmpty(req) || StringUtils.isBlank(req.getType())) {
|
||||||
|
return SdmResponse.failed("参数不能为空");
|
||||||
|
}
|
||||||
|
Map<String, String> tagMap = tagMapService.getTagMapValue();
|
||||||
|
if (MapUtils.isEmpty(tagMap)) {
|
||||||
|
return SdmResponse.failed("未查询到节点标签的配置");
|
||||||
|
}
|
||||||
|
List<NodeMergeQueryResp> mergeQueryRespList = new ArrayList<>();
|
||||||
|
// 如果是任务或算例就传:task或run,其他的传tag1到tag10
|
||||||
|
String type = req.getType();
|
||||||
|
if (MERGE_QUERY_TASK.equals(type) || MERGE_QUERY_RUN.equals(type)) {
|
||||||
|
SpdmTaskListReq taskListReq = new SpdmTaskListReq();
|
||||||
|
taskListReq.setType(TaskQryTypeEnum.ALL.getCode());
|
||||||
|
taskListReq.setCurrent(1);
|
||||||
|
taskListReq.setSize(10000);
|
||||||
|
TaskNodeTag taskNodeTag = new TaskNodeTag();
|
||||||
|
taskNodeTag.setKey(null);
|
||||||
|
taskNodeTag.setValue("tag1");
|
||||||
|
taskListReq.setIdMap(Collections.singletonList(taskNodeTag));
|
||||||
|
SdmResponse response = list(taskListReq);
|
||||||
|
if (!response.isSuccess()) {
|
||||||
|
return SdmResponse.success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
JSONObject dataObj = (JSONObject) response.getData();
|
||||||
|
List<SpdmNewTaskVo> taskVoList = (List<SpdmNewTaskVo>) dataObj.get("data");
|
||||||
|
if (CollectionUtils.isEmpty(taskVoList)) {
|
||||||
|
return SdmResponse.success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
if (MERGE_QUERY_TASK.equals(type)) {
|
||||||
|
// 查询任务
|
||||||
|
Map<String, List<SpdmNewTaskVo>> taskMap = taskVoList.stream().collect(Collectors.groupingBy(SpdmNewTaskVo::getTaskName));
|
||||||
|
for (Map.Entry<String, List<SpdmNewTaskVo>> taskEntry : taskMap.entrySet()) {
|
||||||
|
NodeMergeQueryResp taskMergeQueryResp = new NodeMergeQueryResp();
|
||||||
|
taskMergeQueryResp.setName(taskEntry.getKey());
|
||||||
|
taskMergeQueryResp.setValue(taskEntry.getValue().stream().map(SpdmNewTaskVo::getUuid).toList());
|
||||||
|
mergeQueryRespList.add(taskMergeQueryResp);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
// 查询算例
|
||||||
|
SpdmAnalysisRunListReq runListReq = new SpdmAnalysisRunListReq();
|
||||||
|
List<TaskRunPo> runPoList = projectMapper.queryRunListByNodeIdList(taskVoList.stream().map(SpdmNewTaskVo::getUuid).toList(), runListReq);
|
||||||
|
if (CollectionUtils.isEmpty(runPoList)) {
|
||||||
|
return SdmResponse.success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
Map<String, List<TaskRunPo>> runMap = runPoList.stream().collect(Collectors.groupingBy(TaskRunPo::getRunName));
|
||||||
|
for (Map.Entry<String, List<TaskRunPo>> runEntry : runMap.entrySet()) {
|
||||||
|
NodeMergeQueryResp runMergeQueryResp = new NodeMergeQueryResp();
|
||||||
|
runMergeQueryResp.setName(runEntry.getKey());
|
||||||
|
runMergeQueryResp.setValue(runEntry.getValue().stream().map(TaskRunPo::getUuid).toList());
|
||||||
|
mergeQueryRespList.add(runMergeQueryResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
// 除了项目以外的节点都要合并查询(阶段、机台、工位)
|
||||||
|
String nodeType = tagMap.get(type);
|
||||||
|
if (StringUtils.isBlank(nodeType)) {
|
||||||
|
return SdmResponse.failed("系统中没有当前节点类型:{}",type);
|
||||||
|
}
|
||||||
|
List<SimulationNode> nodeList = nodeService.lambdaQuery().eq(SimulationNode::getNodeType, nodeType).list();
|
||||||
|
if (CollectionUtils.isEmpty(nodeList)) {
|
||||||
|
return SdmResponse.success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
Map<String, List<SimulationNode>> nodeMap = nodeList.stream().collect(Collectors.groupingBy(SimulationNode::getNodeName));
|
||||||
|
for (Map.Entry<String, List<SimulationNode>> nodeEntry : nodeMap.entrySet()) {
|
||||||
|
NodeMergeQueryResp nodeMergeQueryResp = new NodeMergeQueryResp();
|
||||||
|
nodeMergeQueryResp.setName(nodeEntry.getKey());
|
||||||
|
nodeMergeQueryResp.setValue(nodeEntry.getValue().stream().map(SimulationNode::getUuid).toList());
|
||||||
|
mergeQueryRespList.add(nodeMergeQueryResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SdmResponse.success(mergeQueryRespList.stream().sorted(Comparator.comparing(NodeMergeQueryResp::getName)).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getMaxNonEmptyTagForTask(SimulationTask req) {
|
public static String getMaxNonEmptyTagForTask(SimulationTask req) {
|
||||||
|
|||||||
Reference in New Issue
Block a user