Merge branch 'main' of http://192.168.65.198:3000/toolchaintechnologycenter/spdm-backend
This commit is contained in:
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/YiAnData/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/approve/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/capability/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
|
||||
|
||||
@@ -12,7 +12,7 @@ public interface FlowMapper {
|
||||
@Insert("INSERT INTO simulation_flow_template(uuid,templateName,templateVersion,templateContent,viewContent,parentUuid,templateStatus,templateType,approveType,comment,templateCode,tenantId,createName,creator) VALUES(#{template.uuid},#{template.templateName},#{template.templateVersion},#{template.templateContent},#{template.viewContent},#{template.parentUuid},#{template.templateStatus},#{template.templateType},#{template.approveType},#{template.comment},#{template.templateCode},#{template.tenantId},#{template.createName},#{template.creator})")
|
||||
int addFlowTemplate(@Param("template") SimulationFlowTemplate template);
|
||||
|
||||
@Update("UPDATE simulation_flow_template SET templateContent=#{template.templateContent},viewContent=#{template.viewContent},approveType=#{template.approveType},templateType=#{template.templateType},templateStatus=#{template.templateStatus},comment=#{template.comment} WHERE uuid=#{template.uuid}")
|
||||
@Update("UPDATE simulation_flow_template SET templateContent=#{template.templateContent},viewContent=#{template.viewContent},approveType=#{template.approveType},templateType=#{template.templateType},templateStatus=#{template.templateStatus},comment=#{template.comment},approveFlowId=#{template.approveFlowId} WHERE uuid=#{template.uuid}")
|
||||
int updateFlowTemplate(@Param("template") SimulationFlowTemplate template);
|
||||
|
||||
@Delete("DELETE FROM simulation_flow_template WHERE uuid=#{uuid}")
|
||||
|
||||
@@ -36,6 +36,9 @@ public class SimulationFlowTemplate extends BaseEntity {
|
||||
@Schema(description = "模版状态")
|
||||
public int templateStatus = 1;
|
||||
|
||||
@Schema(description = "评审流ID")
|
||||
public String approveFlowId;
|
||||
|
||||
@Schema(description = "模版类型")
|
||||
public String templateType;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
long tenantId = ThreadLocalContext.getTenantId();
|
||||
long creator = ThreadLocalContext.getUserId();
|
||||
String condition = "templateName='"+templateName+"' AND tenantId="+tenantId+" ORDER BY createTime DESC LIMIT 1" ;
|
||||
String createName = ThreadLocalContext.getUserName();
|
||||
//String createName = ThreadLocalContext.getUserName();
|
||||
List<SimulationFlowTemplate> templates = flowMapper.queryFlowTemplateByCondition(condition);
|
||||
if (templates.isEmpty()) {
|
||||
flowTemplate.setTemplateVersion("V1.0");
|
||||
@@ -90,7 +90,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
response.setData(uuid);
|
||||
flowTemplate.setCreator(creator);
|
||||
flowTemplate.setTenantId(tenantId);
|
||||
flowTemplate.setCreateName(createName);
|
||||
flowTemplate.setCreateName("");
|
||||
if(flowMapper.addFlowTemplate(flowTemplate) <=0)
|
||||
{
|
||||
response = SdmResponse.failed("添加流程模版草稿失败");
|
||||
@@ -163,12 +163,19 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
}
|
||||
else //发起评审
|
||||
{
|
||||
if(!launchApprove(templateDraft))
|
||||
SdmResponse approveRespond = launchApprove(templateDraft);
|
||||
if(!approveRespond.isSuccess())
|
||||
{
|
||||
response = SdmResponse.failed("发起评审失败");
|
||||
templateDraft.setApproveType(0);
|
||||
flowMapper.updateFlowTemplate(templateDraft);
|
||||
}
|
||||
else
|
||||
{
|
||||
String approveFlowId = (String)approveRespond.getData();
|
||||
templateDraft.setApproveFlowId(approveFlowId);
|
||||
response.setData(approveFlowId);
|
||||
}
|
||||
flowMapper.updateFlowTemplate(templateDraft);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
@@ -179,7 +186,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
* @param flowTemplate
|
||||
* @return
|
||||
*/
|
||||
private boolean launchApprove(SimulationFlowTemplate flowTemplate) {
|
||||
private SdmResponse launchApprove(SimulationFlowTemplate flowTemplate) {
|
||||
LaunchApproveReq approveReq = new LaunchApproveReq();
|
||||
approveReq.approveTitle = "仿真流程评审";
|
||||
approveReq.approveStatus = 1;
|
||||
@@ -195,8 +202,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
flowTemplateJson.put("flowContents", flowTemplate.templateContent);
|
||||
flowTemplateJson.put("viewContents", flowTemplate.viewContent);
|
||||
approveReq.approveContents = flowTemplateJson.toJSONString();
|
||||
SdmResponse response = approveFeignClient.launchApproval(approveReq);
|
||||
return response.isSuccess();
|
||||
return approveFeignClient.launchApproval(approveReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,4 +12,10 @@ public class HpcConstants {
|
||||
// 结果类型 table
|
||||
public static final String FORMAT_TABLE = "table";
|
||||
|
||||
// HPC NODE 节点状态
|
||||
public static final String NODE_STATE_ONLINE = "Online";
|
||||
// 取消任务的方式 force 强制、graceful 优雅,默认graceful
|
||||
public static final String CANCEL_JOB_FORCE = "force";
|
||||
public static final String CANCEL_JOB_GRACEFUL = "graceful";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.sdm.common.entity.req.pbs;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class SubmitHpcTaskRemoteReq {
|
||||
|
||||
@Schema(description = "计算任务名称")
|
||||
public String jobName;
|
||||
|
||||
@Schema(description = "计算所需要核数")
|
||||
public int coreNum;
|
||||
|
||||
@Schema(description = "计算软件")
|
||||
public String software;
|
||||
|
||||
@Schema(description = "计算任务类型")
|
||||
public String jobType;
|
||||
|
||||
@Schema(description = "计算任务是否独立存在 0:非独立任务 1:独立任务")
|
||||
public int independence;
|
||||
|
||||
@Schema(description = "求解文件")
|
||||
public List<String> inputFiles = new ArrayList<>();
|
||||
|
||||
@Schema(description = "计算主文件")
|
||||
public String masterFile;
|
||||
|
||||
@Schema(description = "计算任务所属任务ID")
|
||||
public String taskId;
|
||||
|
||||
@Schema(description = "计算任务所属任务名称")
|
||||
public String taskName;
|
||||
|
||||
@Schema(description = "计算任务所属算力ID")
|
||||
public String runId;
|
||||
|
||||
@Schema(description = "计算任务所属算力名称")
|
||||
public String runName;
|
||||
|
||||
@Schema(description = "执行的命令")
|
||||
public String command;
|
||||
|
||||
@Schema(description = "任务所属项目")
|
||||
public String projectname;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.sdm.common.feign.impl.pbs;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
|
||||
import com.sdm.common.feign.inter.pbs.ITaskFeignClient;
|
||||
import com.sdm.common.log.CoreLogger;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -16,7 +16,7 @@ public class TaskClientFeignClientImpl implements ITaskFeignClient {
|
||||
private ITaskFeignClient taskFeignClient;
|
||||
|
||||
@Override
|
||||
public SdmResponse<String> submitHpcJob(SubmitHpcTaskReq req) {
|
||||
public SdmResponse<String> submitHpcJob(SubmitHpcTaskRemoteReq req) {
|
||||
SdmResponse<String> response;
|
||||
try {
|
||||
response = taskFeignClient.submitHpcJob(req);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.sdm.common.feign.inter.pbs;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.config.LongTimeRespFeignConfig;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -16,6 +16,6 @@ public interface ITaskFeignClient {
|
||||
|
||||
// "作业提交"
|
||||
@PostMapping("/pbs/submitHpcJob")
|
||||
SdmResponse<String> submitHpcJob(@RequestBody SubmitHpcTaskReq req);
|
||||
SdmResponse<String> submitHpcJob(@RequestBody SubmitHpcTaskRemoteReq req);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
|
||||
import com.sdm.common.feign.inter.pbs.ITaskFeignClient;
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.flowable.service.IAsyncTaskRecordService;
|
||||
@@ -34,7 +34,7 @@ public class HpcHandler implements ExecutionHandler {
|
||||
// INIT(初始化)/RUNNING(执行中)/SUCCESS(执行成功)/FAIL(执行失败)
|
||||
String status = "INIT";
|
||||
// 1. 调用 HPC 平台提交任务
|
||||
SubmitHpcTaskReq mockReq = mockSubmitHpcTaskReq();
|
||||
SubmitHpcTaskRemoteReq mockReq = mockSubmitHpcTaskReq();
|
||||
SdmResponse<String> submitResp = taskFeignClient.submitHpcJob(mockReq);
|
||||
if(!submitResp.isSuccess()|| StringUtils.isBlank(submitResp.getData())){
|
||||
log.error("HpcHandler submit failed,jobName:{}",mockReq.getJobName());
|
||||
@@ -56,7 +56,7 @@ public class HpcHandler implements ExecutionHandler {
|
||||
|
||||
|
||||
public String mockinit(){
|
||||
SubmitHpcTaskReq mockReq = mockSubmitHpcTaskReq();
|
||||
SubmitHpcTaskRemoteReq mockReq = mockSubmitHpcTaskReq();
|
||||
SdmResponse<String> submitResp = taskFeignClient.submitHpcJob(mockReq);
|
||||
if(!submitResp.isSuccess()|| StringUtils.isBlank(submitResp.getData())){
|
||||
log.error("HpcHandler submit failed,jobName:{}",mockReq.getJobName());
|
||||
@@ -67,8 +67,8 @@ public class HpcHandler implements ExecutionHandler {
|
||||
return hpcTaskId;
|
||||
}
|
||||
|
||||
private SubmitHpcTaskReq mockSubmitHpcTaskReq() {
|
||||
SubmitHpcTaskReq req = new SubmitHpcTaskReq();
|
||||
private SubmitHpcTaskRemoteReq mockSubmitHpcTaskReq() {
|
||||
SubmitHpcTaskRemoteReq req = new SubmitHpcTaskRemoteReq();
|
||||
// 生成任务名称:年月日-时分秒,如 20251127-145120
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
||||
String timestamp = sdf.format(new Date());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.sdm.pbs.controller;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
|
||||
import com.sdm.common.entity.req.pbs.hpc.*;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.*;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.listjobs.ListJobResp;
|
||||
@@ -11,11 +11,14 @@ import com.sdm.common.entity.resp.pbs.hpc.nodelist.NodeListResp;
|
||||
import com.sdm.common.feign.inter.pbs.ITaskFeignClient;
|
||||
import com.sdm.common.utils.HpcCommandExcuteUtil;
|
||||
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
|
||||
import com.sdm.pbs.model.bo.HpcResouceInfo;
|
||||
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
|
||||
import com.sdm.pbs.service.HpcInstructionService;
|
||||
import com.sdm.pbs.service.IPbsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -51,10 +54,24 @@ public class TaskController implements ITaskFeignClient {
|
||||
return hpcCommandExcuteUtil.excuteCmd(command,"remote");
|
||||
}
|
||||
|
||||
@GetMapping ("/queryHpcResource")
|
||||
@Operation(summary = "HPC资源查询")
|
||||
public SdmResponse<HpcResouceInfo> queryHpcResource() {
|
||||
return pbsService.queryHpcResource();
|
||||
}
|
||||
|
||||
@PostMapping("/submitHpcJob")
|
||||
@Operation(summary = "作业提交")
|
||||
public SdmResponse<String> submitHpcJob(@RequestBody SubmitHpcTaskReq req) {
|
||||
return pbsService.submitHpcJob(req);
|
||||
public SdmResponse<String> submitHpcJob(@RequestBody SubmitHpcTaskRemoteReq req) {
|
||||
SubmitHpcTaskReq submitHpcTaskReq = new SubmitHpcTaskReq();
|
||||
BeanUtils.copyProperties(req,submitHpcTaskReq);
|
||||
return pbsService.submitHpcJob(submitHpcTaskReq);
|
||||
}
|
||||
|
||||
@PostMapping("/stopHpcJob")
|
||||
@Operation(summary = "作业停止")
|
||||
public SdmResponse<Boolean> stopHpcJob(@RequestParam String jobId) {
|
||||
return pbsService.stopHpcJob(jobId);
|
||||
}
|
||||
|
||||
@PostMapping("/getJobStatus")
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.sdm.pbs.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HpcNodeInfo {
|
||||
|
||||
@Schema(description = "计算节点名称")
|
||||
public String nodeName;
|
||||
|
||||
@Schema(description = "计算节点状态 0:down 1:running 2:suspend")
|
||||
public int nodeStatus;
|
||||
@Schema(description = "计算节点状态 Online, Offline, Draining,Unreachable")
|
||||
public String nodeStatus;
|
||||
|
||||
@Schema(description = "节点总核数")
|
||||
public int totalCores;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.sdm.pbs.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HpcResouceInfo {
|
||||
|
||||
@Schema(description = "资源总核数")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.common.entity.req.pbs;
|
||||
package com.sdm.pbs.model.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.sdm.pbs.service;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.pbs.model.bo.FileBaseInfo;
|
||||
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
|
||||
import com.sdm.pbs.model.bo.HpcResouceInfo;
|
||||
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -2,17 +2,25 @@ package com.sdm.pbs.service.impl;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.constants.HpcConstants;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.common.entity.constants.NumberConstants;
|
||||
import com.sdm.common.entity.req.pbs.hpc.*;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.JobCancelResp;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.SubmitHpcJobResp;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.listjobs.ListJobResp;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.listjobs.ListJobs;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.listtasks.ListTasks;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.listtasks.ListTasksResp;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.nodelist.NodeList;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.nodelist.NodeListResp;
|
||||
import com.sdm.common.log.CoreLogger;
|
||||
import com.sdm.pbs.model.bo.FileBaseInfo;
|
||||
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
|
||||
import com.sdm.pbs.model.bo.HpcNodeInfo;
|
||||
import com.sdm.pbs.model.bo.HpcResouceInfo;
|
||||
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
|
||||
import com.sdm.pbs.service.HpcInstructionService;
|
||||
import com.sdm.pbs.service.IPbsService;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -21,6 +29,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -35,11 +45,15 @@ public class IPbsHpcServiceImpl implements IPbsService {
|
||||
|
||||
@Override
|
||||
public SdmResponse<HpcResouceInfo> queryHpcResource() {
|
||||
ListJobReq listJobReq = new ListJobReq();
|
||||
listJobReq.setFormat(HpcConstants.FORMAT_LIST);
|
||||
SdmResponse<ListJobResp> hpcResp = hpcInstructionService.jobList(listJobReq);
|
||||
// todo
|
||||
return null;
|
||||
NodeListReq nodeReq = new NodeListReq();
|
||||
nodeReq.setFormat(HpcConstants.FORMAT_LIST);
|
||||
SdmResponse<NodeListResp> hpcResp = hpcInstructionService.nodeList(nodeReq);
|
||||
if(!hpcResp.isSuccess()){
|
||||
return SdmResponse.failed("HPC节点信息查询失败");
|
||||
}
|
||||
HpcResouceInfo resourceInfo =
|
||||
buildHpcResourceInfo(hpcResp.getData().getNodes());
|
||||
return SdmResponse.success(resourceInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,7 +85,14 @@ public class IPbsHpcServiceImpl implements IPbsService {
|
||||
|
||||
@Override
|
||||
public SdmResponse<Boolean> stopHpcJob(String jobId) {
|
||||
return null;
|
||||
CancelJobReq req = new CancelJobReq();
|
||||
req.setJobId(jobId);
|
||||
req.setCancelWay(HpcConstants.CANCEL_JOB_FORCE);
|
||||
SdmResponse<JobCancelResp> stopResp = hpcInstructionService.jobCancel(req);
|
||||
if(!stopResp.isSuccess()){
|
||||
return SdmResponse.failed(false);
|
||||
}
|
||||
return SdmResponse.success(stopResp.getData().getCanceled());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,11 +136,61 @@ public class IPbsHpcServiceImpl implements IPbsService {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Value("${file.rootPath}")
|
||||
// private String rootPath;
|
||||
//
|
||||
// @Resource
|
||||
// private RedisUtil redisUtil;
|
||||
|
||||
private HpcResouceInfo buildHpcResourceInfo(List<NodeList> nodes) {
|
||||
|
||||
HpcResouceInfo result = new HpcResouceInfo();
|
||||
result.setNodeList(Collections.emptyList());
|
||||
if (nodes == null || nodes.isEmpty()) {
|
||||
result.setFreeCores(0);
|
||||
result.setTotalCores(0);
|
||||
result.setUsedCores(0);
|
||||
return result;
|
||||
}
|
||||
int totalCores = 0;
|
||||
int usedCores = 0;
|
||||
int freeCoresSum = 0;
|
||||
List<HpcNodeInfo> nodeInfos = new ArrayList<>(nodes.size());
|
||||
|
||||
for (NodeList node : nodes) {
|
||||
if (node == null) {
|
||||
continue;
|
||||
}
|
||||
int max = safeParseInt(node.getMax());
|
||||
int run = safeParseInt(node.getRun());
|
||||
int free = Math.max(max - run, 0);
|
||||
HpcNodeInfo info = new HpcNodeInfo();
|
||||
info.setNodeName(node.getNodeName());
|
||||
info.setTotalCores(max);
|
||||
info.setUsedCores(run);
|
||||
info.setFreeCores(free);
|
||||
info.setNodeStatus(node.getState());
|
||||
if (HpcConstants.NODE_STATE_ONLINE.equals(node.getState())) {
|
||||
totalCores += max;
|
||||
usedCores += run;
|
||||
freeCoresSum += free;
|
||||
}
|
||||
nodeInfos.add(info);
|
||||
}
|
||||
result.setTotalCores(totalCores);
|
||||
result.setUsedCores(usedCores);
|
||||
result.setFreeCores(freeCoresSum);
|
||||
result.setNodeList(nodeInfos);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int safeParseInt(String value) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return NumberConstants.ZERO;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(value.trim());
|
||||
} catch (Exception e) {
|
||||
CoreLogger.error("safeParseInt error:{},value:{}", e.getMessage(), value);
|
||||
return NumberConstants.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.sdm.pbs.service.impl;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskReq;
|
||||
import com.sdm.pbs.model.bo.FileBaseInfo;
|
||||
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
|
||||
import com.sdm.pbs.model.bo.HpcResouceInfo;
|
||||
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
|
||||
import com.sdm.pbs.service.IPbsService;
|
||||
import com.sdm.pbs.service.IPbsServiceDecorator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -34,7 +34,7 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
|
||||
|
||||
@Override
|
||||
public SdmResponse<HpcResouceInfo> queryHpcResource() {
|
||||
return null;
|
||||
return pbsService.queryHpcResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +45,7 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
|
||||
|
||||
@Override
|
||||
public SdmResponse<Boolean> stopHpcJob(String jobId) {
|
||||
return null;
|
||||
return pbsService.stopHpcJob(jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.sdm.project.controller;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.data.UploadFilesReq;
|
||||
|
||||
import com.sdm.project.model.req.YA.GetModelNodeInfoReq;
|
||||
import com.sdm.project.model.req.YA.SaveModelNodeInfoReq;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dataManager/tree/node")
|
||||
@Tag(name = "宜安项目数据归档", description = "宜安项目模型数据关了")
|
||||
public class YAModelController {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建文件夹
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/SaveModelNodeInfo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(
|
||||
summary = "上传模型",
|
||||
description = "仿真模型归档,支持同时上传文件和附加参数",
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "模型文件上传请求",
|
||||
required = true,
|
||||
content = @Content(
|
||||
mediaType = MediaType.MULTIPART_FORM_DATA_VALUE,
|
||||
schema = @Schema(implementation = SaveModelNodeInfoReq.class)
|
||||
)
|
||||
)
|
||||
)
|
||||
public SdmResponse saveModelNodeInfo(@RequestBody @Validated SaveModelNodeInfoReq req)
|
||||
{
|
||||
|
||||
UploadFilesReq fileReq = new UploadFilesReq();
|
||||
fileReq.setFileName(req.getName());
|
||||
fileReq.setProjectId(req.getProject());
|
||||
fileReq.setFileType(1);
|
||||
fileReq.setFile(req.getFile());
|
||||
fileReq.setUuid(req.getScenario());
|
||||
fileReq.setAnalysisDirectionId(req.getScenario());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping("GetModelNodeInfoByIdAndType")
|
||||
public void getModelNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("DeleteModelNodeByObjectIds")
|
||||
public void DeleteModelNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("SyncProject")
|
||||
public void syncCidProject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("SyncCidTask")
|
||||
public void syncCidTask()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "仿真模型删除参数")
|
||||
public class DeleteModelNodeInfoReq {
|
||||
|
||||
@Schema(description = "数据类型名称")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "需要删除数据ObjectId")
|
||||
private String objectId;
|
||||
|
||||
@Schema(description = "需要删除数据id")
|
||||
private String id;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "获取仿真模型参数")
|
||||
public class GetModelNodeInfoReq {
|
||||
|
||||
@Schema(description = "数据类型名称")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "需要删除数据ObjectId")
|
||||
private String objectId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public class ProjectTaskInfo {
|
||||
|
||||
@Schema(description = "任务名称")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "taskId")
|
||||
private String taskId;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
@Schema(description = "仿真关键结果上传参数")
|
||||
public class SaveKeyResultNodeInfoReq {
|
||||
|
||||
@Schema(description = "数据类型名称")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "数据名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据类型编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "仿真分析项")
|
||||
private String scenario;
|
||||
|
||||
@Schema(description = "数据访问控制级别")
|
||||
private String dataLevel;
|
||||
|
||||
@Schema(description = "所属项目ID")
|
||||
private String project;
|
||||
|
||||
@Schema(description = "父级节点ID")
|
||||
private String parent;
|
||||
|
||||
@Schema(description = "任务ID")
|
||||
private String workRequest;
|
||||
|
||||
@Schema(description = "分析对象")
|
||||
private String item;
|
||||
|
||||
@Schema(description = "轮次")
|
||||
private String round;
|
||||
|
||||
@Schema(description = "方案Id")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "数值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "单位")
|
||||
private String units;
|
||||
|
||||
@Schema(description = "状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "物理量")
|
||||
private String quantityType;
|
||||
|
||||
@Schema(description = "文件传输对象")
|
||||
@JSONField(serialize = false)
|
||||
private MultipartFile file;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "仿真模型上传参数")
|
||||
public class SaveModelNodeInfoReq {
|
||||
|
||||
@Schema(description = "数据类型名称")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "数据名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据类型编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "所属项目ID")
|
||||
private String project;
|
||||
|
||||
@Schema(description = "父级节点ID")
|
||||
private String parent;
|
||||
|
||||
@Schema(description = "仿真分析项")
|
||||
private String scenario;
|
||||
|
||||
@Schema(description = "主负责人")
|
||||
private String firstOwner;
|
||||
|
||||
@Schema(description = "从负责人")
|
||||
private List<String> secondOwner;
|
||||
|
||||
@Schema(description = "起止日期")
|
||||
private String startEndData;
|
||||
|
||||
@Schema(description = "学科")
|
||||
private String disciplineClassification;
|
||||
|
||||
@Schema(description = "格式")
|
||||
private String format;
|
||||
|
||||
@Schema(description = "分析对象")
|
||||
private String item;
|
||||
|
||||
@Schema(description = "文件传输对象")
|
||||
@JSONField(serialize = false)
|
||||
private MultipartFile file;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
@Schema(description = "仿真报告上传参数")
|
||||
public class SaveReportNodeInfoReq {
|
||||
|
||||
@Schema(description = "数据类型名称")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "数据名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String discription;
|
||||
|
||||
@Schema(description = "数据类型编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "所属项目ID")
|
||||
private String project;
|
||||
|
||||
@Schema(description = "父级节点ID")
|
||||
private String parent;
|
||||
|
||||
@Schema(description = "仿真分析项")
|
||||
private String scenario;
|
||||
|
||||
@Schema(description = "文件传输对象")
|
||||
@JSONField(serialize = false)
|
||||
private MultipartFile file;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SyncCidProjectReq {
|
||||
|
||||
@Schema(description = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@Schema(description = "项目Id")
|
||||
private String projectId;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sdm.project.model.req.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SyncCidTaskReq {
|
||||
|
||||
@Schema(description = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@Schema(description = "项目Id")
|
||||
private String projectId;
|
||||
|
||||
@Schema(description = "")
|
||||
private List<ProjectTaskInfo> taskInfoList = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sdm.project.model.resp.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public class BosimErrorRespond {
|
||||
|
||||
@Schema(description = "错误码")
|
||||
private int errorCode;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sdm.project.model.resp.YA;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BosimSaveModelNodeRsp {
|
||||
|
||||
@Schema(description = "返回码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "返回信息")
|
||||
private String message;
|
||||
|
||||
private List<String> workRequest = new ArrayList<>();
|
||||
}
|
||||
@@ -14,14 +14,14 @@ public interface SimulationSystemMapper {
|
||||
@Insert("INSERT INTO simulation_data_dictionary(uuid,dictName,dictValue,dictOrder,valueType,aliasName,dictClass,comment,tenantId,creator) VALUES (#{dict.uuid},#{dict.dictName},#{dict.dictValue},#{dict.dictOrder},#{dict.valueType},#{dict.aliasName},#{dict.dictClass},#{dict.comment},#{dict.tenantId},#{dict.creator})")
|
||||
int addDataDictionary(@Param("dict") DataDictionary dict);
|
||||
|
||||
@Select("SELECT * FROM simulation_data_dictionary WHERE dictClass=#{dictClass} ORDER BY dictOrder ASC")
|
||||
List<DataDictionary> queryDictionaryClassData(@Param("dictClass")String dictClass);
|
||||
@Select("SELECT * FROM simulation_data_dictionary WHERE dictClass=#{dictClass} AND tenantId=#{tenantId} ORDER BY dictOrder ASC")
|
||||
List<DataDictionary> queryDictionaryClassData(@Param("dictClass")String dictClass,@Param("tenantId") long tenantId);
|
||||
|
||||
@Select("SELECT * FROM simulation_data_dictionary")
|
||||
List<DataDictionary> getAllDictionaryData();
|
||||
@Select("SELECT * FROM simulation_data_dictionary WHERE tenantId=#{tenantId}")
|
||||
List<DataDictionary> getAllDictionaryData(@Param("tenantId") long tenantId);
|
||||
|
||||
@Delete("DELETE FROM simulation_data_dictionary WHERE dictClass=#{dictClass}")
|
||||
int deleteDictionaryClassItems(@Param("dictClass")String dictClass);
|
||||
@Delete("DELETE FROM simulation_data_dictionary WHERE dictClass=#{dictClass} AND tenantId=#{tenantId}")
|
||||
int deleteDictionaryClassItems(@Param("dictClass")String dictClass,@Param("tenantId") long tenantId);
|
||||
|
||||
@Select("SELECT * FROM simulation_data_dictionary WHERE dictName=#{dictName} AND dictClass=#{dictClass} AND tenantId=#{tenantId} LIMIT 1")
|
||||
DataDictionary queryDataDictionary(@Param("dictName")String dictName,@Param("dictClass")String dictClass,@Param("tenantId")long tenantId);
|
||||
|
||||
@@ -100,7 +100,8 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
|
||||
public SdmResponse deleteDataDictionaryClass(String className)
|
||||
{
|
||||
SdmResponse response = SdmResponse.success();
|
||||
if(mapper.deleteDictionaryClassItems(className) <= 0)
|
||||
long tenantId = ThreadLocalContext.getTenantId();
|
||||
if(mapper.deleteDictionaryClassItems(className,tenantId) <= 0)
|
||||
{
|
||||
response = SdmResponse.failed("删除数据字典分类下所有字典信息失败");
|
||||
}
|
||||
@@ -114,7 +115,8 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
|
||||
*/
|
||||
public SdmResponse<List<DataDictionary>> queryDictionaryData(String className)
|
||||
{
|
||||
List<DataDictionary> dictionaries = mapper.queryDictionaryClassData(className);
|
||||
long tenantId = ThreadLocalContext.getTenantId();
|
||||
List<DataDictionary> dictionaries = mapper.queryDictionaryClassData(className,tenantId);
|
||||
return SdmResponse.success(dictionaries);
|
||||
}
|
||||
|
||||
@@ -123,7 +125,8 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse<Map<String, List<SimuDictionaryResp>> > getAllDictionaryData() {
|
||||
List<DataDictionary> dictionaries = mapper.getAllDictionaryData();
|
||||
long tenantId = ThreadLocalContext.getTenantId();
|
||||
List<DataDictionary> dictionaries = mapper.getAllDictionaryData(tenantId);
|
||||
List<SimuDictionaryResp> newDictionaries = dictionaries.stream().filter(i -> StringUtils.isNotBlank(i.dictClass)).map(i -> new SimuDictionaryResp(i.dictValue, i.dictClass, i.dictName)).collect(Collectors.toList());
|
||||
Map<String, List<SimuDictionaryResp>> dictionMap = newDictionaries.stream().collect(Collectors.groupingBy(SimuDictionaryResp::getDictClass));
|
||||
return SdmResponse.success(dictionMap);
|
||||
|
||||
Reference in New Issue
Block a user