|
|
|
|
@@ -3,6 +3,7 @@ package com.sdm.task.service.impl;
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
|
|
|
|
import com.sdm.common.common.ResultCode;
|
|
|
|
|
import com.sdm.common.common.SdmResponse;
|
|
|
|
|
import com.sdm.common.service.BaseService;
|
|
|
|
|
@@ -13,10 +14,14 @@ import com.sdm.task.model.entity.*;
|
|
|
|
|
import com.sdm.task.service.ISimulationTaskPoolService;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -1238,6 +1243,157 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取节点下分析项
|
|
|
|
|
* @param nodeObject
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<TaskPoolItem> getTaskPoolNodeItem(JSONObject nodeObject)
|
|
|
|
|
{
|
|
|
|
|
List<TaskPoolItem> tasks = new ArrayList<>();
|
|
|
|
|
JSONArray children = nodeObject.getJSONArray("children");
|
|
|
|
|
if(children != null)
|
|
|
|
|
{
|
|
|
|
|
for(int index=0; index<children.size(); index++)
|
|
|
|
|
{
|
|
|
|
|
JSONObject childObj = children.getJSONObject(index);
|
|
|
|
|
String childType = childObj.getString("levelType");
|
|
|
|
|
if(childType.equals("node"))
|
|
|
|
|
{
|
|
|
|
|
List<TaskPoolItem> childNodeTasks = getTaskPoolNodeItem(childObj);
|
|
|
|
|
tasks.addAll(childNodeTasks);
|
|
|
|
|
}
|
|
|
|
|
else if(childType.equals("task"))
|
|
|
|
|
{
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
try {
|
|
|
|
|
TaskPoolItem poolItem = objectMapper.readValue(childObj.toJSONString(),TaskPoolItem.class);
|
|
|
|
|
tasks.add(poolItem);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tasks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SdmResponse getSimulationPoolTasks(String poolName,String version)
|
|
|
|
|
{
|
|
|
|
|
SdmResponse response = SdmResponse.success();
|
|
|
|
|
JSONObject poolJson = null;
|
|
|
|
|
if(version==null || version.length()==0)
|
|
|
|
|
{
|
|
|
|
|
SdmResponse poolTreeResponse = getCurrentPoolTree(poolName);
|
|
|
|
|
if(poolTreeResponse.getCode() != ResultCode.SUCCESS.getCode())
|
|
|
|
|
{
|
|
|
|
|
response = SdmResponse.failed("获取分析项库失败");
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TaskPoolTree poolTree = (TaskPoolTree) poolTreeResponse.getData();
|
|
|
|
|
poolJson = JSONObject.from(poolTree);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
String versionContents = mapper.queryTaskPoolVersionContent(poolName,version);
|
|
|
|
|
if(versionContents == null || versionContents.length() == 0)
|
|
|
|
|
{
|
|
|
|
|
response = SdmResponse.failed("分析项库版本不存在");
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
poolJson = JSONObject.parseObject(versionContents);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<TaskPoolItem> tasks = new ArrayList<>();
|
|
|
|
|
JSONArray nodeArray = poolJson.getJSONArray("nodes");
|
|
|
|
|
if(nodeArray != null)
|
|
|
|
|
{
|
|
|
|
|
for(int index=0; index<nodeArray.size(); index++)
|
|
|
|
|
{
|
|
|
|
|
JSONObject nodeObj = nodeArray.getJSONObject(index);
|
|
|
|
|
List<TaskPoolItem> nodeTasks = getTaskPoolNodeItem(nodeObj);
|
|
|
|
|
tasks.addAll(nodeTasks);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
/*List<TaskPoolItem> taskPoolItems = mapper.queryTaskPoolItems(poolName);
|
|
|
|
|
List<TaskPoolPerformance> poolPerformances = mapper.queryTaskPoolPerformances(poolName);
|
|
|
|
|
List<TaskPoolItemExtra> taskPoolItemExtras = mapper.queryTaskPoolItemExtras(poolName);
|
|
|
|
|
List<TaskPoolPerformanceExtra> taskPoolPerformanceExtras = mapper.queryTaskPoolPerformanceExtras(poolName);
|
|
|
|
|
Map<String,List<TaskPoolPerformance>> taskPoolPerformanceMap = new HashMap<>();
|
|
|
|
|
Map<String,List<TaskPoolItemExtra>> taskPoolItemExtraMap = new HashMap<>();
|
|
|
|
|
Map<String,List<TaskPoolPerformanceExtra>> taskPoolPerformanceExtraMap = new HashMap<>();
|
|
|
|
|
//整理性能指标附加属性
|
|
|
|
|
for(TaskPoolPerformanceExtra performanceExtra : taskPoolPerformanceExtras)
|
|
|
|
|
{
|
|
|
|
|
String performanceUuid = performanceExtra.performanceId;
|
|
|
|
|
List<TaskPoolPerformanceExtra> extras = taskPoolPerformanceExtraMap.get(performanceUuid);
|
|
|
|
|
if(extras == null)
|
|
|
|
|
{
|
|
|
|
|
extras = new ArrayList<>();
|
|
|
|
|
taskPoolPerformanceExtraMap.put(performanceUuid,extras);
|
|
|
|
|
}
|
|
|
|
|
extras.add(performanceExtra);
|
|
|
|
|
}
|
|
|
|
|
//整理分析项附加属性
|
|
|
|
|
for(TaskPoolItemExtra itemExtra : taskPoolItemExtras)
|
|
|
|
|
{
|
|
|
|
|
String taskUUid = itemExtra.taskId;
|
|
|
|
|
List<TaskPoolItemExtra> extras = taskPoolItemExtraMap.get(taskUUid);
|
|
|
|
|
if(extras == null)
|
|
|
|
|
{
|
|
|
|
|
extras = new ArrayList<>();
|
|
|
|
|
taskPoolItemExtraMap.put(taskUUid,extras);
|
|
|
|
|
}
|
|
|
|
|
extras.add(itemExtra);
|
|
|
|
|
}
|
|
|
|
|
//整理性能指标
|
|
|
|
|
for(TaskPoolPerformance performance : poolPerformances)
|
|
|
|
|
{
|
|
|
|
|
//获取附加属性
|
|
|
|
|
List<TaskPoolPerformanceExtra> performanceExtras = taskPoolPerformanceExtraMap.get(performance.uuid);
|
|
|
|
|
if(performanceExtras != null)
|
|
|
|
|
{
|
|
|
|
|
performance.extras = performanceExtras;
|
|
|
|
|
}
|
|
|
|
|
String taskUuid = performance.taskId;
|
|
|
|
|
List<TaskPoolPerformance> performances = taskPoolPerformanceMap.get(taskUuid);
|
|
|
|
|
if(performances == null)
|
|
|
|
|
{
|
|
|
|
|
performances = new ArrayList<>();
|
|
|
|
|
taskPoolPerformanceMap.put(taskUuid,performances);
|
|
|
|
|
}
|
|
|
|
|
performances.add(performance);
|
|
|
|
|
}
|
|
|
|
|
//整理分析项
|
|
|
|
|
for(TaskPoolItem poolItem : taskPoolItems)
|
|
|
|
|
{
|
|
|
|
|
//获取分析项附加属性
|
|
|
|
|
List<TaskPoolItemExtra> itemExtras = taskPoolItemExtraMap.get(poolItem.uuid);
|
|
|
|
|
if(itemExtras != null)
|
|
|
|
|
{
|
|
|
|
|
poolItem.extras = itemExtras;
|
|
|
|
|
}
|
|
|
|
|
//获取分析项性能指标
|
|
|
|
|
List<TaskPoolPerformance> performances = taskPoolPerformanceMap.get(poolItem.uuid);
|
|
|
|
|
if(performances != null)
|
|
|
|
|
{
|
|
|
|
|
poolItem.performances = performances;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
response.setData(tasks);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SdmResponse exportTaskPool(HttpServletResponse httpServletResponse,JSONObject paramObject) {
|
|
|
|
|
String poolName = paramObject.getString("poolName");
|
|
|
|
|
|