优化分析项库绑定流程模版和知识库
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.sdm.capability.model.entity;
|
||||
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SimulationFlowTaskBindInfo {
|
||||
|
||||
public String simulationPoolId;
|
||||
|
||||
public String simulationPoolName;
|
||||
|
||||
public String simulationPoolVersion;
|
||||
|
||||
public List<String> simulationPoolTaskIds = new ArrayList<>();
|
||||
|
||||
public List<TaskBaseInfo> taskBaseInfoList = new ArrayList();
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SimulationFlowTemplate extends BaseEntity {
|
||||
|
||||
@@ -60,4 +63,6 @@ public class SimulationFlowTemplate extends BaseEntity {
|
||||
@Schema(description = "评审流程模版Id")
|
||||
public String approveFlowTemplateId;
|
||||
|
||||
public List<SimulationFlowTaskBindInfo> simulationPoolInfoList = new ArrayList();
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sdm.capability.dao.FlowMapper;
|
||||
import com.sdm.capability.model.entity.SimulationFlowTaskBindInfo;
|
||||
import com.sdm.capability.model.entity.SimulationFlowTemplate;
|
||||
import com.sdm.capability.model.entity.SimulationFlowTemplateBrief;
|
||||
import com.sdm.capability.service.IFlowService;
|
||||
@@ -12,11 +13,17 @@ import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.bo.DataPageInfo;
|
||||
import com.sdm.common.entity.constants.NumberConstants;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.task.BindTaskAndFlowTemplateReq;
|
||||
import com.sdm.common.entity.resp.capability.FlowTemplateResp;
|
||||
import com.sdm.common.entity.resp.flowable.DeployFlowableResp;
|
||||
import com.sdm.common.feign.impl.capability.SimulationFlowFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.flowable.FlowableClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.task.SimuluationTaskPoolFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationFlowFeignClient;
|
||||
import com.sdm.common.service.BaseService;
|
||||
import com.sdm.common.utils.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -45,6 +52,9 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Autowired
|
||||
private SimuluationTaskPoolFeignClientImpl simuluationTaskPoolFeignClient;
|
||||
|
||||
@Override
|
||||
public SdmResponse createFlowTemplateDraft(SimulationFlowTemplate flowTemplate)
|
||||
{
|
||||
@@ -74,11 +84,44 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
else
|
||||
{
|
||||
response.setData(flowTemplate);
|
||||
bindFLowTemplateAndTask(flowTemplate.templateCode,flowTemplate.simulationPoolInfoList);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定流程模版与分析库中的分析项
|
||||
* @param flowCode
|
||||
* @param simulationPoolInfoList
|
||||
*/
|
||||
private void bindFLowTemplateAndTask(String flowCode, List<SimulationFlowTaskBindInfo> simulationPoolInfoList)
|
||||
{
|
||||
if(simulationPoolInfoList == null || simulationPoolInfoList.isEmpty())
|
||||
return;
|
||||
BindTaskAndFlowTemplateReq req = new BindTaskAndFlowTemplateReq();
|
||||
req.flowCode = flowCode;
|
||||
req.bindTaskkPoolItem = new ArrayList<>();
|
||||
for(SimulationFlowTaskBindInfo bindInfo : simulationPoolInfoList)
|
||||
{
|
||||
FlowBindTaskPoolItem bindTaskPoolItem = new FlowBindTaskPoolItem();
|
||||
bindTaskPoolItem.flowCode = flowCode;
|
||||
bindTaskPoolItem.poolName = bindInfo.simulationPoolName;
|
||||
bindTaskPoolItem.version = bindInfo.simulationPoolVersion;
|
||||
for(String taskId : bindInfo.simulationPoolTaskIds)
|
||||
{
|
||||
TaskBaseInfo taskBaseInfo = new TaskBaseInfo();
|
||||
taskBaseInfo.poolName = bindInfo.simulationPoolName;
|
||||
taskBaseInfo.version = bindInfo.simulationPoolVersion;
|
||||
taskBaseInfo.uuid = taskId;
|
||||
bindTaskPoolItem.taskList.add(taskBaseInfo);
|
||||
}
|
||||
req.bindTaskkPoolItem.add(bindTaskPoolItem);
|
||||
}
|
||||
|
||||
simuluationTaskPoolFeignClient.updateTaskAndFlowTemplate(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse upgradeFlowTemplateDraft(SimulationFlowTemplate flowTemplate) {
|
||||
|
||||
@@ -141,6 +184,10 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
{
|
||||
response = SdmResponse.failed("更新路程模版草稿失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
bindFLowTemplateAndTask(flowTemplate.templateCode,flowTemplate.simulationPoolInfoList);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -273,13 +320,30 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
{
|
||||
if(latestVersions.size() > endPos)
|
||||
{
|
||||
queryTemplate = latestVersions.subList(beginPos,endPos+1);
|
||||
queryTemplate = latestVersions.subList(beginPos,endPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
queryTemplate = latestVersions.subList(beginPos,latestVersions.size());
|
||||
}
|
||||
}
|
||||
for(SimulationFlowTemplate flowTemplate : queryTemplate)
|
||||
{
|
||||
SdmResponse bindResponse = simuluationTaskPoolFeignClient.getFlowTemplateBindTaskRelate(flowTemplate.templateCode);
|
||||
if(bindResponse.isSuccess())
|
||||
{
|
||||
List<FlowBindTaskPoolItem> flowBindTaskPoolItems = (List<FlowBindTaskPoolItem>)bindResponse.getData();
|
||||
for(FlowBindTaskPoolItem flowBindTaskPoolItem : flowBindTaskPoolItems)
|
||||
{
|
||||
SimulationFlowTaskBindInfo flowTaskBindInfo = new SimulationFlowTaskBindInfo();
|
||||
flowTaskBindInfo.simulationPoolName = flowBindTaskPoolItem.poolName;
|
||||
flowTaskBindInfo.simulationPoolVersion = flowBindTaskPoolItem.version;
|
||||
flowTaskBindInfo.taskBaseInfoList = flowBindTaskPoolItem.taskList;
|
||||
flowTemplate.simulationPoolInfoList.add(flowTaskBindInfo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
DataPageInfo<List<SimulationFlowTemplate>> pageInfo = new DataPageInfo<>();
|
||||
pageInfo.data = queryTemplate;
|
||||
pageInfo.total = total;
|
||||
|
||||
@@ -4,6 +4,28 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class BaseBean {
|
||||
|
||||
public void handleNull()
|
||||
{
|
||||
Class cls = this.getClass();
|
||||
Field[] fields = cls.getDeclaredFields();
|
||||
try {
|
||||
for (Field field : fields) {
|
||||
Class typeClass = field.getType();
|
||||
if (typeClass.equals(String.class))
|
||||
{
|
||||
Object object = field.get(this);
|
||||
if (object == null)
|
||||
{
|
||||
field.set(this, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
Class cls = this.getClass();
|
||||
|
||||
58
common/src/main/java/com/sdm/common/entity/bo/JwtToken.java
Normal file
58
common/src/main/java/com/sdm/common/entity/bo/JwtToken.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.sdm.common.entity.bo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class JwtToken {
|
||||
private String keyId;
|
||||
private String issuer;
|
||||
private String subject;
|
||||
private String userName;
|
||||
private final long EXPIRE_TIME = 100*60*60*1000;
|
||||
public JwtToken(String keyId,String userId,String userName,String appName)
|
||||
{
|
||||
this.keyId = keyId;
|
||||
this.issuer = userId;
|
||||
this.subject = appName;
|
||||
this.userName = userName;
|
||||
}
|
||||
public String getKeyId()
|
||||
{
|
||||
return keyId;
|
||||
}
|
||||
|
||||
public String getIssuer()
|
||||
{
|
||||
return issuer;
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getSubject()
|
||||
{
|
||||
return subject;
|
||||
}
|
||||
|
||||
public String getJwtId()
|
||||
{
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public long getExpirationTime()
|
||||
{
|
||||
return EXPIRE_TIME;
|
||||
}
|
||||
|
||||
public Map<String,?> getClaimMap()
|
||||
{
|
||||
Map<String,String> claimMap = new HashMap<>();
|
||||
claimMap.put("userid",issuer);
|
||||
claimMap.put("username",userName);
|
||||
claimMap.put("account",userName);
|
||||
return claimMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.sdm.common.entity.pojo.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FlowBindTaskPoolItem {
|
||||
|
||||
public String poolName;
|
||||
|
||||
public String version;
|
||||
|
||||
public String flowCode;
|
||||
|
||||
public List<TaskBaseInfo> taskList = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sdm.common.entity.pojo.task;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
|
||||
public class TaskBaseInfo {
|
||||
|
||||
public String taskName;
|
||||
|
||||
public String taskCode;
|
||||
|
||||
public String uuid;
|
||||
|
||||
public String poolName;
|
||||
|
||||
public String version;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.sdm.common.entity.req.task;
|
||||
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BindTaskAndFlowTemplateReq {
|
||||
|
||||
@Schema(description = "流程模版编号")
|
||||
@NotBlank(message = "流程模版编号不能为空")
|
||||
public String flowCode;
|
||||
|
||||
@Schema(description = "分析项库中绑定到执行流程的分析项信息")
|
||||
public List<FlowBindTaskPoolItem> bindTaskkPoolItem = new ArrayList<>();
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.sdm.common.feign.impl.task;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.task.BindTaskAndFlowTemplateReq;
|
||||
import com.sdm.common.feign.inter.task.ISimuluationTaskPoolFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -30,4 +37,54 @@ public class SimuluationTaskPoolFeignClientImpl implements ISimuluationTaskPoolF
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SdmResponse updateTaskAndFlowTemplate(BindTaskAndFlowTemplateReq req) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = simuluationTaskPoolFeignClient.updateTaskAndFlowTemplate(req);
|
||||
if (!response.isSuccess()) {
|
||||
response = SdmResponse.failed("绑定分析项和流程模版失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("绑定分析项和流程模版异常");
|
||||
response = SdmResponse.failed(("绑定分析项和流程模版异常"));
|
||||
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<List<FlowBindTaskPoolItem>> getFlowTemplateBindTaskRelate(String flowCode) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = simuluationTaskPoolFeignClient.getFlowTemplateBindTaskRelate(flowCode);
|
||||
if (!response.isSuccess()) {
|
||||
response = SdmResponse.failed("获取流程模版与分析项的绑定关系失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("获取流程模版与分析项的绑定关系异常");
|
||||
response = SdmResponse.failed(("获取流程模版与分析项的绑定关系异常"));
|
||||
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Map<String, TaskBaseInfo>> getTaskPoolTaskMap( long poolId, String version)
|
||||
{
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = simuluationTaskPoolFeignClient.getTaskPoolTaskMap(poolId, version);
|
||||
if (!response.isSuccess()) {
|
||||
response = SdmResponse.failed("获取分析项库");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("获取分析项库异常");
|
||||
response = SdmResponse.failed(("获取分析项库异常"));
|
||||
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ public interface IFileSimulationMappingFeignClient {
|
||||
@PostMapping("/getFileSimulationMappingBySimulationPoolIdAndVersionAndTaskId")
|
||||
SdmResponse<List<FileMetadataInfoResp>> getFileSimulationMappingBySimulationPoolIdAndVersionAndTaskId(@RequestBody GetFileSimulationMappingReq getFileSimulationMappingReq);
|
||||
|
||||
@PostMapping("/batchGetFileSimulationMappingBySimulationPoolIdAndVersion")
|
||||
@PostMapping("/fileSimulationMapping/batchGetFileSimulationMappingBySimulationPoolIdAndVersion")
|
||||
SdmResponse<Map<String, List<FileMetadataInfoResp>>> batchGetFileSimulationMappingBySimulationPoolIdAndVersion(@RequestBody GetFileSimulationMappingReq getFileSimulationMappingReq);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.sdm.common.feign.inter.task;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.task.BindTaskAndFlowTemplateReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,4 +19,18 @@ public interface ISimuluationTaskPoolFeignClient {
|
||||
@PostMapping("/taskpool/approveHandleNotice")
|
||||
SdmResponse receiveApproveNotice(@RequestBody LaunchApproveReq req);
|
||||
|
||||
|
||||
@PostMapping(value = "/taskpool/updateTaskAndFlowTemplate")
|
||||
@ResponseBody
|
||||
SdmResponse updateTaskAndFlowTemplate(@RequestBody BindTaskAndFlowTemplateReq req);
|
||||
|
||||
|
||||
@GetMapping(value = "/taskpool/getFlowTaskRelate")
|
||||
SdmResponse<List<FlowBindTaskPoolItem>> getFlowTemplateBindTaskRelate(@RequestParam("flowCode")String flowCode);
|
||||
|
||||
@GetMapping(value = "/taskpool/getTaskPoolTaskMap")
|
||||
@ResponseBody
|
||||
SdmResponse<Map<String, TaskBaseInfo>> getTaskPoolTaskMap(@RequestParam("poolName") long poolId, @RequestParam("version")String version);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
package com.sdm.common.utils;
|
||||
|
||||
|
||||
import com.sdm.common.entity.bo.JwtToken;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class SystemOperate {
|
||||
@@ -157,4 +173,90 @@ public class SystemOperate {
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
|
||||
public static PrivateKey getPrivateKey(String key) throws Exception
|
||||
{
|
||||
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(key.getBytes()));
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
return keyFactory.generatePrivate(spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成JWT
|
||||
* @param jwtToken
|
||||
* @param key
|
||||
* @param isUnique
|
||||
* @return
|
||||
*/
|
||||
public static String generateToken(JwtToken jwtToken, String key, boolean isUnique) {
|
||||
|
||||
String token = "";
|
||||
try
|
||||
{
|
||||
PrivateKey privateKey = getPrivateKey(key);
|
||||
Algorithm algorithm = Algorithm.RSA256(null, (RSAPrivateKey) privateKey);
|
||||
|
||||
Date issuedAt = new Date();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(issuedAt);
|
||||
issuedAt = calendar.getTime();
|
||||
// 未设置过期时间,则默认签发时间后10分钟内有效
|
||||
Date expiresAt = new Date(issuedAt.getTime() + (jwtToken.getExpirationTime() <= 0 ? 600000 : jwtToken.getExpirationTime()));
|
||||
token = JWT.create()
|
||||
.withKeyId(jwtToken.getKeyId()) //密钥ID
|
||||
.withIssuer(jwtToken.getUserName()+":"+jwtToken.getIssuer()+":1") //用户名:用户ID:租户
|
||||
.withSubject(jwtToken.getSubject()) //appName
|
||||
.withExpiresAt(expiresAt)
|
||||
.withIssuedAt(issuedAt)
|
||||
.withJWTId(jwtToken.getJwtId()) //随机UUID
|
||||
.withClaim("claimsMap", jwtToken.getClaimMap()) //保持默认值
|
||||
.sign(algorithm);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
private static PublicKey getPublicKey(String publicKeyStr) {
|
||||
byte[] keyBytes = Base64.getDecoder().decode(publicKeyStr);
|
||||
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory;
|
||||
try {
|
||||
keyFactory = KeyFactory.getInstance("RSA");
|
||||
return keyFactory.generatePublic(x509EncodedKeySpec);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean verify( String pubKey, String token) {
|
||||
// 从公钥缓存中获取对应的密钥编号的公钥
|
||||
PublicKey publicKey =getPublicKey(pubKey);
|
||||
try {
|
||||
Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null);
|
||||
DecodedJWT decodedJwt = JWT.require(algorithm).ignoreIssuedAt().build().verify(token);
|
||||
Date expiresAt = decodedJwt.getExpiresAt();
|
||||
// 验证token是否过期
|
||||
if (expiresAt.before(new Date())) {
|
||||
return false;
|
||||
}
|
||||
// 验证自己是否为接收方
|
||||
List<String> audience = decodedJwt.getAudience();
|
||||
if (audience != null && !audience.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class SimulationAppCenterServiceImpl extends BaseService implements ISimu
|
||||
appBean.uuid = generateUuid("app_center_");
|
||||
appBean.tenantId = ThreadLocalContext.getTenantId();
|
||||
appBean.creator = ThreadLocalContext.getUserId();
|
||||
appBean.handleNull();
|
||||
if(bHasSameNameSimulationApp(appBean))
|
||||
{
|
||||
response = SdmResponse.failed("应用名称已存在");
|
||||
@@ -75,6 +76,7 @@ public class SimulationAppCenterServiceImpl extends BaseService implements ISimu
|
||||
else
|
||||
{
|
||||
AppCenterItemBean orgBean = appList.get(0);
|
||||
appBean.handleNull();
|
||||
if((!orgBean.appName.equals(appBean.appName) || orgBean.appType != appBean.appType) && bHasSameNameSimulationApp(appBean)) //app名称有修改或者应用类型修改,需要判定是否有重名
|
||||
{
|
||||
response = SdmResponse.failed("应用名称已存在");
|
||||
|
||||
@@ -2,7 +2,10 @@ package com.sdm.task.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.task.BindTaskAndFlowTemplateReq;
|
||||
import com.sdm.common.feign.inter.task.ISimuluationTaskPoolFeignClient;
|
||||
import com.sdm.task.model.entity.TaskPoolUpdateBean;
|
||||
import com.sdm.task.model.req.ExportTaskPoolReq;
|
||||
@@ -12,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/taskpool")
|
||||
public class SimuluationTaskPoolController implements ISimuluationTaskPoolFeignClient {
|
||||
@@ -33,6 +39,14 @@ public class SimuluationTaskPoolController implements ISimuluationTaskPoolFeignC
|
||||
return service.getPoolTreeByVersion(poolName,version);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/getAllTaskPoolCurrentVersion")
|
||||
@ResponseBody
|
||||
SdmResponse getSimulationAllTaskPoolCurrentVersion()
|
||||
{
|
||||
return service.getAllTaslPoolCurrentVersion();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/exportTaskPoolToExcel")
|
||||
@ResponseBody
|
||||
void exportSimulationTaskPool(@RequestBody ExportTaskPoolReq req,HttpServletResponse response)
|
||||
@@ -96,11 +110,31 @@ public class SimuluationTaskPoolController implements ISimuluationTaskPoolFeignC
|
||||
return service.getSimulationPoolTasks(poolName,version);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getTaskPoolTaskMap")
|
||||
@ResponseBody
|
||||
public SdmResponse<Map<String, TaskBaseInfo>> getTaskPoolTaskMap(@RequestParam("poolId") long poolId, @RequestParam("version")String version)
|
||||
{
|
||||
return service.getSimulationTasksByPoolId(poolId);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/approveHandleNotice")
|
||||
@ResponseBody
|
||||
public SdmResponse receiveApproveNotice(@RequestBody LaunchApproveReq req)
|
||||
{
|
||||
return service.handleApproveNotice(req);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/updateTaskAndFlowTemplate")
|
||||
@ResponseBody
|
||||
public SdmResponse updateTaskAndFlowTemplate(@RequestBody BindTaskAndFlowTemplateReq req)
|
||||
{
|
||||
return service.updateFlowTaskRelate(req);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getFlowTaskRelate")
|
||||
public SdmResponse<List<FlowBindTaskPoolItem>> getFlowTemplateBindTaskRelate(@RequestParam("flowCode")String flowCode)
|
||||
{
|
||||
return service.getTaskAndFlowTemplateRelateByFlowCode(flowCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ public interface SimulationPoolMapper {
|
||||
@Delete("DELETE FROM simulation_pool WHERE poolName=#{poolName}")
|
||||
int deleteTaskPoolBrief(@Param("poolName")String poolName);
|
||||
|
||||
@Insert("INSERT INTO simulation_pool_versions(poolName,poolVersion,parentVersion,versionContents,creator) VALUES (#{version.poolName},#{version.poolVersion},#{version.parentVersion},#{version.versionContents},#{version.creator})")
|
||||
@Insert("INSERT INTO simulation_pool_versions(poolName,poolVersion,parentVersion,versionContents,poolId,creator) VALUES (#{version.poolName},#{version.poolVersion},#{version.parentVersion},#{version.versionContents},#{version.poolId},#{version.creator})")
|
||||
@Options(useGeneratedKeys=true,keyProperty="id")
|
||||
int addTaskPoolVersion(@Param("version") TaskPoolVersion version);
|
||||
|
||||
@Update("UPDATE simulation_pool_versions SET versionContents=#{versionContents} WHERE poolName=#{poolName} AND poolVersion=#{version}")
|
||||
@@ -40,6 +41,9 @@ public interface SimulationPoolMapper {
|
||||
@Select("SELECT versionContents FROM simulation_pool_versions WHERE poolName=#{poolName} AND poolVersion=#{version}")
|
||||
String queryTaskPoolVersionContent(@Param("poolName")String poolName,@Param("version")String version);
|
||||
|
||||
@Select("SELECT * FROM simulation_pool_versions WHERE poolId=#{poolId} LIMIT 1")
|
||||
TaskPoolVersion queryTaskPoolVersionByPoolId(@Param("poolId")long poolId);
|
||||
|
||||
@Select("SELECT * FROM simulation_pool WHERE poolName=#{poolName} LIMIT 1")
|
||||
TaskPoolBrief queryTaskPoolBrief(@Param("poolName")String poolName);
|
||||
|
||||
@@ -129,9 +133,13 @@ public interface SimulationPoolMapper {
|
||||
@Select("SELECT * FROM simulation_pool_node WHERE poolName=#{poolName}")
|
||||
List<TaskPoolNode> queryTaskPoolNodes(@Param("poolName")String poolName);
|
||||
|
||||
|
||||
@Select("SELECT * FROM simulation_pool_task WHERE poolName=#{poolName}")
|
||||
List<TaskPoolItem> queryTaskPoolItems(@Param("poolName")String poolName);
|
||||
|
||||
@Select("SELECT * FROM simulation_pool_task WHERE ${condition}")
|
||||
List<TaskPoolItem> queryTaskPoolItemsByCondition(@Param("condition")String condition);
|
||||
|
||||
@Select("SELECT * FROM simulation_pool_performance WHERE poolName=#{poolName}")
|
||||
List<TaskPoolPerformance> queryTaskPoolPerformances(@Param("poolName")String poolName);
|
||||
|
||||
@@ -208,4 +216,39 @@ public interface SimulationPoolMapper {
|
||||
@Delete("DELETE FROM simulation_pool_performance_extra WHERE poolName=#{poolName}")
|
||||
int deleteTaskPoolAllPerformanceExtra(@Param("poolName")String poolName);
|
||||
|
||||
@Insert({
|
||||
"<script>",
|
||||
"INSERT INTO simulation_taskpool_flowtemplate_relate(poolName,version,taskUuid,flowCode) VALUES ",
|
||||
"<foreach collection ='list' item='it' index='index' separator =','>",
|
||||
"(#{it.poolName},#{it.version},#{it.taskUuid},#{it.flowCode}) ",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int batchAddTaskFlowRelate(@Param("list") List<SimulatePoolTaskFlowTemplateRelate> list);
|
||||
|
||||
@Insert("INSERT INTO simulation_taskpool_flowtemplate_relate(poolName,version,taskUuid,flowCode) VALUES (#{relate.poolName},#{relate.version},#{relate.taskUuid},#{relate.flowCode})")
|
||||
int addTaskFlowRelate(@Param("relate") SimulatePoolTaskFlowTemplateRelate relate);
|
||||
|
||||
@Select("SELECT * FROM simulation_taskpool_flowtemplate_relate WHERE flowCode=#{flowCode} AND poolName=#{poolName} AND version=#{version} AND taskUuid=#{taskUuid}")
|
||||
List<SimulatePoolTaskFlowTemplateRelate> queryTaskFlowRelate(@Param("flowCode")String flowCode,@Param("poolName")String poolName,@Param("version")String version,@Param("taskUuid")String taskUuid);
|
||||
|
||||
|
||||
@Select("SELECT * FROM simulation_taskpool_flowtemplate_relate WHERE flowCode=#{flowCode}")
|
||||
List<SimulatePoolTaskFlowTemplateRelate> queryTaskFlowRelateByFlowCode(@Param("flowCode")String flowCode);
|
||||
|
||||
@Delete("DELETE FROM simulation_taskpool_flowtemplate_relate WHERE flowCode=#{flowCode}")
|
||||
int deleteTaskFlowRelateByFlowCode(@Param("flowCode")String flowCode);
|
||||
|
||||
@Delete("DELETE FROM simulation_taskpool_flowtemplate_relate WHERE taskUuid=#{taskUuid} AND poolName=#{poolName} AND poolVersion=#{version}")
|
||||
int deleteTaskFlowRelateByTaskUuid(@Param("taskUuid")String taskUuid,@Param("poolName")String poolName,@Param("version")String version);
|
||||
|
||||
@Select("SELECT * FROM simulation_taskpool_flowtemplate_relate WHERE poolName=#{poolName}")
|
||||
List<SimulatePoolTaskFlowTemplateRelate> queryTaskFlowRelateByTaskPool(@Param("poolName") String poolName);
|
||||
|
||||
@Insert("INSERT INTO simulation_taskpool_flowtemplate_relate(poolName,flowCode,taskUuid,`version`) SELECT poolName,flowCode,taskUuid,${newVersion} WHERE poolName=#{poolName} AND `version`=#{oldVersion}")
|
||||
int copyTaskRelateToNewVersion(@Param("poolName")String poolName,@Param("oldVersion")String oldVersion,@Param("newVersion")String newVersion);
|
||||
|
||||
@Select("SELECT * FROM simulation_taskpool_flowtemplate_relate WHERE poolName=#{poolName} AND version=#{version}")
|
||||
List<SimulatePoolTaskFlowTemplateRelate> queryTaskFlowRelateByPoolVersion(@Param("poolName")String poolName,@Param("version")String version);
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class TaskPoolOperate {
|
||||
//脚本解析分析项库文件
|
||||
String shellPath = scriptPath+File.separator+"excelToJson.py";
|
||||
String poolJsonFileName = System.currentTimeMillis()+"taskPool.json";
|
||||
String pythonCmd = "python "+shellPath+" "+poolJsonFileName+" "+poolFileName+" "+dictFileName;
|
||||
String pythonCmd = "python "+shellPath+" "+poolJsonFileName+" '"+poolFileName+"' "+dictFileName;
|
||||
try
|
||||
{
|
||||
log.info("shell begin time:"+System.currentTimeMillis());
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sdm.task.model.entity;
|
||||
|
||||
public class SimulatePoolTaskFlowTemplateRelate {
|
||||
|
||||
public long id;
|
||||
|
||||
public String poolName;
|
||||
|
||||
public String version;
|
||||
|
||||
public String taskUuid;
|
||||
|
||||
public String flowCode;
|
||||
|
||||
public long tenantId;
|
||||
|
||||
public long creator;
|
||||
|
||||
public String createTime;
|
||||
}
|
||||
@@ -49,7 +49,15 @@ public class TaskPoolUpdateBean extends ApproveBaseBean{
|
||||
public List<TaskPoolPerformanceExtra> performanceExtras;
|
||||
}
|
||||
|
||||
|
||||
public List<TaskPoolItem> getAddTaskPoolItem()
|
||||
{
|
||||
List<TaskPoolItem> list = new ArrayList<>();
|
||||
for(TaskPoolItemAdd addTask : addTasks)
|
||||
{
|
||||
list.addAll(addTask.tasks);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean bNewVersion = false;
|
||||
public int versionType = 0; //0:生成小版本 1:生成大版本
|
||||
|
||||
@@ -12,6 +12,7 @@ public class TaskPoolVersion extends BaseBean {
|
||||
public String parentVersion;
|
||||
public String childVersion;
|
||||
public String versionContents;
|
||||
public long poolId;
|
||||
public long creator;
|
||||
public String createTime;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,20 @@ package com.sdm.task.service;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.task.BindTaskAndFlowTemplateReq;
|
||||
import com.sdm.task.model.entity.SimulatePoolTaskFlowTemplateRelate;
|
||||
import com.sdm.task.model.entity.TaskPoolUpdateBean;
|
||||
import com.sdm.task.model.req.ExportTaskPoolReq;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ISimulationTaskPoolService {
|
||||
|
||||
|
||||
@@ -17,12 +25,18 @@ public interface ISimulationTaskPoolService {
|
||||
|
||||
SdmResponse getPoolTreeByVersion(String poolName,String version);
|
||||
|
||||
SdmResponse getAllTaslPoolCurrentVersion();
|
||||
|
||||
SdmResponse updateTaskPoolTree(TaskPoolUpdateBean updateBean);
|
||||
|
||||
SdmResponse getSimulationPoolPerformance(String poolName);
|
||||
|
||||
SdmResponse getSimulationPoolTasks(String poolName,String version);
|
||||
|
||||
SdmResponse<Map<String, TaskBaseInfo>> getSimulationTasksByPoolId(long poolId);
|
||||
|
||||
SdmResponse getSimulationPoolTasksByUuids(String poolName, String version, List<String> uuids);
|
||||
|
||||
SdmResponse getTaskPoolVersions(String poolName);
|
||||
|
||||
SdmResponse cleanTaskPool(String poolName);
|
||||
@@ -36,4 +50,11 @@ public interface ISimulationTaskPoolService {
|
||||
void exportTaskPoolToExcel(ExportTaskPoolReq req,HttpServletResponse httpServletResponse);
|
||||
|
||||
SdmResponse handleApproveNotice(LaunchApproveReq req);
|
||||
|
||||
SdmResponse batchBindpoolTaskAndFlowTemplate(String flowCode,String poolName,String version,List<String> taskUuids);
|
||||
|
||||
SdmResponse<List<FlowBindTaskPoolItem>> getTaskAndFlowTemplateRelateByFlowCode(String flowCode);
|
||||
|
||||
SdmResponse updateFlowTaskRelate(BindTaskAndFlowTemplateReq req);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
package com.sdm.task.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.hash.Hash;
|
||||
import cn.hutool.cron.task.Task;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import com.sdm.common.common.ResultCode;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.pojo.task.FlowBindTaskPoolItem;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.data.GetFileSimulationMappingReq;
|
||||
import com.sdm.common.entity.req.data.SaveFileSimulationMappingReq;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.task.BindTaskAndFlowTemplateReq;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.data.IFileSimulationMappingFeignClient;
|
||||
import com.sdm.common.service.BaseService;
|
||||
import com.sdm.common.utils.SystemOperate;
|
||||
import com.sdm.common.utils.excel.ExcelUtil;
|
||||
@@ -26,10 +36,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SimulationTaskPoolServiceImpl extends BaseService implements ISimulationTaskPoolService {
|
||||
@@ -42,9 +50,133 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
@Autowired
|
||||
private ApproveFeignClientImpl approveFeignClient;
|
||||
|
||||
@Autowired
|
||||
private IFileSimulationMappingFeignClient simulationMappingFeignClient;
|
||||
|
||||
@Value("${approve.replyUrl}")
|
||||
private String approveReplyUrl;
|
||||
|
||||
/**
|
||||
* 处理绑定仿真分析项流程模版
|
||||
* @param taskPoolItemList
|
||||
*/
|
||||
private void handleCreateTaskBindRelation(List<TaskPoolItem> taskPoolItemList,String poolName,String version,int poolId)
|
||||
{
|
||||
//为分析项库绑定流程模版,知识库
|
||||
List<SimulatePoolTaskFlowTemplateRelate> flowRelationList = new ArrayList<>();
|
||||
List<SaveFileSimulationMappingReq> standardRelationReqs = new ArrayList<>();
|
||||
for(TaskPoolItem taskPoolItem:taskPoolItemList)
|
||||
{
|
||||
//绑定流程模版
|
||||
String flowTemplate = taskPoolItem.flowTemplate;
|
||||
if(flowTemplate != null && !flowTemplate.isEmpty())
|
||||
{
|
||||
String[] flowTemplates = flowTemplate.split(";");
|
||||
for (String template : flowTemplates) {
|
||||
SimulatePoolTaskFlowTemplateRelate relate = new SimulatePoolTaskFlowTemplateRelate();
|
||||
relate.poolName = poolName;
|
||||
relate.version = version;
|
||||
relate.taskUuid = taskPoolItem.uuid;
|
||||
relate.flowCode = template;
|
||||
flowRelationList.add(relate);
|
||||
}
|
||||
}
|
||||
//绑定标准库模版
|
||||
String standard = taskPoolItem.standard;
|
||||
if(standard != null && !standard.isEmpty())
|
||||
{
|
||||
String[] standardItem = standard.split(";");
|
||||
List<Long> fileIdList = new ArrayList<>();
|
||||
for (String item : standardItem)
|
||||
{
|
||||
String[] standardIds = item.split(",");
|
||||
if(standardIds.length == 2)
|
||||
{
|
||||
String fileId = standardIds[1].trim();
|
||||
fileIdList.add(Long.valueOf(fileId));
|
||||
}
|
||||
}
|
||||
SaveFileSimulationMappingReq req = new SaveFileSimulationMappingReq();
|
||||
req.setSimulationPoolTaskId(taskPoolItem.uuid);
|
||||
req.setSimulationPoolVersion(version);
|
||||
req.setSimulationPoolId(poolId);
|
||||
req.setFileIds(fileIdList);
|
||||
standardRelationReqs.add(req);
|
||||
|
||||
}
|
||||
}
|
||||
if(!flowRelationList.isEmpty()) {
|
||||
mapper.batchAddTaskFlowRelate(flowRelationList);
|
||||
}
|
||||
if(!standardRelationReqs.isEmpty())
|
||||
{
|
||||
simulationMappingFeignClient.batchSaveFileSimulationMapping(standardRelationReqs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加仿真分析项关联关系检查是否重复添加
|
||||
* @param poolName
|
||||
* @param version
|
||||
* @param taskPoolItemList
|
||||
*/
|
||||
private void addTaskRelationCheckRepeat(String poolName,String version,List<TaskPoolItem> taskPoolItemList)
|
||||
{
|
||||
for(TaskPoolItem taskPoolItem:taskPoolItemList) {
|
||||
String flowTemplate = taskPoolItem.flowTemplate;
|
||||
if (flowTemplate == null || flowTemplate.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String[] flowTemplates = flowTemplate.split(";");
|
||||
for (String template : flowTemplates) {
|
||||
SimulatePoolTaskFlowTemplateRelate relate = new SimulatePoolTaskFlowTemplateRelate();
|
||||
if(mapper.queryTaskFlowRelate(template,poolName,version,taskPoolItem.uuid).isEmpty())
|
||||
{
|
||||
SimulatePoolTaskFlowTemplateRelate templateRelate = new SimulatePoolTaskFlowTemplateRelate();
|
||||
templateRelate.poolName = poolName;
|
||||
templateRelate.version = version;
|
||||
templateRelate.taskUuid = taskPoolItem.uuid;
|
||||
templateRelate.flowCode = template;
|
||||
mapper.addTaskFlowRelate(templateRelate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理分析项库知识库修改后绑定关系
|
||||
* @param updateBean
|
||||
* @param currentBrief
|
||||
*/
|
||||
private void handleUpdateTaskBindRelation(TaskPoolUpdateBean updateBean,TaskPoolBrief currentBrief)
|
||||
{
|
||||
String currentVersion = currentBrief.currentVersion;
|
||||
String poolName = currentBrief.poolName;
|
||||
List<TaskPoolItem> updateTasks = updateBean.updateTasks;
|
||||
List<String> deleteTaskUuids = updateBean.deleteTasks;
|
||||
List<TaskPoolItem> addTasks = updateBean.getAddTaskPoolItem();
|
||||
//更新分两种情况:
|
||||
// 1.不升版更新
|
||||
// 2.升版更新
|
||||
if(updateBean.bNewVersion)
|
||||
{
|
||||
mapper.copyTaskRelateToNewVersion(poolName,currentBrief.parentVersion,currentVersion);
|
||||
}
|
||||
for(TaskPoolItem taskPoolItem:updateTasks) //删除更新分析项的关联关系
|
||||
{
|
||||
mapper.deleteTaskFlowRelateByTaskUuid(taskPoolItem.uuid, poolName, currentVersion);
|
||||
}
|
||||
for(String taskUuid:deleteTaskUuids) //删除已删除分析项的关联关系
|
||||
{
|
||||
mapper.deleteTaskFlowRelateByTaskUuid(taskUuid,poolName,currentVersion);
|
||||
}
|
||||
//将添加和更新task合并一起后一起添加关联关系,需要检查关系是否重复绑定
|
||||
addTasks.addAll(updateTasks);
|
||||
addTaskRelationCheckRepeat(poolName,currentVersion,addTasks);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加仿真分析库节点以及分析项
|
||||
* @param poolTree
|
||||
@@ -93,7 +225,12 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
{
|
||||
response = SdmResponse.failed("添加分析项库分析项性能指标附加信息失败!");
|
||||
}
|
||||
if(response.isSuccess())
|
||||
{
|
||||
response.setData(taskItems);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -209,6 +346,141 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定分析库与流程模版,知识关系
|
||||
* @param poolName
|
||||
* @param version
|
||||
* @param contents
|
||||
* @return
|
||||
*/
|
||||
private String bindTaskpoolRelate(String poolName,String version,String contents)
|
||||
{
|
||||
//获取分析项与流程模版关系
|
||||
JSONObject poolJson = JSONObject.parseObject(contents);
|
||||
List<SimulatePoolTaskFlowTemplateRelate> templateRelates = mapper.queryTaskFlowRelateByPoolVersion(poolName,version);
|
||||
Map<String,String> taskFlowMap = new HashMap<>();
|
||||
for(SimulatePoolTaskFlowTemplateRelate relate : templateRelates)
|
||||
{
|
||||
String flowTemplates = taskFlowMap.get(relate.taskUuid);
|
||||
if(flowTemplates == null)
|
||||
{
|
||||
taskFlowMap.put(relate.taskUuid,relate.flowCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowTemplates += ";"+relate.flowCode;
|
||||
taskFlowMap.put(relate.taskUuid,flowTemplates);
|
||||
}
|
||||
}
|
||||
//获取分析项与知识库关系
|
||||
JSONObject poolBrief = poolJson.getJSONObject("poolBrief");
|
||||
Map<String, List<FileMetadataInfoResp>> stardardMap = new HashMap<>();
|
||||
if(poolBrief != null) {
|
||||
GetFileSimulationMappingReq req = new GetFileSimulationMappingReq();
|
||||
req.setSimulationPoolId(poolBrief.getInteger("id"));
|
||||
req.setSimulationPoolVersion(version);
|
||||
SdmResponse feignRsp = simulationMappingFeignClient.batchGetFileSimulationMappingBySimulationPoolIdAndVersion(req);
|
||||
if (feignRsp.isSuccess())
|
||||
stardardMap = (Map<String, List<FileMetadataInfoResp>>) feignRsp.getData();
|
||||
}
|
||||
|
||||
JSONArray nodeArray = poolJson.getJSONArray("nodes");
|
||||
if(nodeArray == null || nodeArray.isEmpty())
|
||||
return contents;
|
||||
for(int i=0;i<nodeArray.size();i++)
|
||||
{
|
||||
JSONObject node = nodeArray.getJSONObject(i);
|
||||
searchNodeAndBindTasks(node, stardardMap, taskFlowMap);
|
||||
}
|
||||
return poolJson.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索节点并绑定分析项下流程模版和标准库
|
||||
* @param nodeObject
|
||||
* @param stardardMap
|
||||
* @param taskFlowMap
|
||||
*/
|
||||
private void searchNodeAndBindTasks(JSONObject nodeObject,Map<String, List<FileMetadataInfoResp>> stardardMap,Map<String,String> taskFlowMap)
|
||||
{
|
||||
JSONArray children = nodeObject.getJSONArray("children");
|
||||
if(children == null || children.isEmpty())
|
||||
return;
|
||||
for(int i=0;i<children.size();i++)
|
||||
{
|
||||
JSONObject child = children.getJSONObject(i);
|
||||
String levelType = child.getString("levelType");
|
||||
if(levelType == null)
|
||||
continue;
|
||||
if(levelType.equalsIgnoreCase("node"))
|
||||
{
|
||||
searchNodeAndBindTasks(child,stardardMap,taskFlowMap);
|
||||
}
|
||||
else if(levelType.equalsIgnoreCase("task"))
|
||||
{
|
||||
bindTaskRelate(child,stardardMap,taskFlowMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定分析项库与流程模版和标准库
|
||||
* @param taskObject
|
||||
* @param stardardMap
|
||||
* @param taskFlowMap
|
||||
*/
|
||||
private void bindTaskRelate(JSONObject taskObject,Map<String, List<FileMetadataInfoResp>> stardardMap,Map<String,String> taskFlowMap)
|
||||
{
|
||||
String taskUuid = taskObject.getString("uuid");
|
||||
if(taskUuid == null)
|
||||
return;
|
||||
String flowTemplate = taskFlowMap.get(taskUuid);
|
||||
if(flowTemplate != null)
|
||||
{
|
||||
taskObject.put("flowTemplate",flowTemplate);
|
||||
}
|
||||
List<FileMetadataInfoResp> fileMetas = stardardMap.get(taskUuid);
|
||||
if(fileMetas != null && !fileMetas.isEmpty())
|
||||
{
|
||||
String standard = "";
|
||||
for(FileMetadataInfoResp fileMetadataInfoResp : fileMetas)
|
||||
{
|
||||
long parentId = fileMetadataInfoResp.getParentId();
|
||||
long fileId = fileMetadataInfoResp.getId();
|
||||
String fileName = fileMetadataInfoResp.getOriginalName();
|
||||
if(!standard.isEmpty())
|
||||
{
|
||||
standard += ";";
|
||||
}
|
||||
standard += parentId+","+fileId+","+fileName;
|
||||
taskObject.put("standard",standard);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有分析项库当前版本
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse getAllTaslPoolCurrentVersion()
|
||||
{
|
||||
SdmResponse response = SdmResponse.success();
|
||||
List<TaskPoolBrief> taskPoolBriefs = mapper.queryAllTaskPool();
|
||||
JSONArray taskPoolArray = new JSONArray();
|
||||
for(TaskPoolBrief taskPoolBrief : taskPoolBriefs)
|
||||
{
|
||||
SdmResponse taskPoolRsponse = getPoolTreeByVersion(taskPoolBrief.poolName,taskPoolBrief.currentVersion);
|
||||
if(taskPoolRsponse.isSuccess())
|
||||
{
|
||||
JSONObject poolTreeObj = (JSONObject) taskPoolRsponse.getData();
|
||||
taskPoolArray.add(poolTreeObj);
|
||||
}
|
||||
}
|
||||
response.setData(taskPoolArray);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据版本号获取分析库版本信息
|
||||
* @param poolName
|
||||
@@ -227,6 +499,7 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
}
|
||||
else
|
||||
{
|
||||
contents = bindTaskpoolRelate(poolName,version,contents);
|
||||
response.setData(JSONObject.parse(contents));
|
||||
}
|
||||
return response;
|
||||
@@ -250,7 +523,7 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
else
|
||||
{
|
||||
JSONObject taskPool = (JSONObject) taskPoolResp.getData();
|
||||
ExcelUtil.exportExcelWithMerge(taskPool.getJSONArray("nodes"),req.excelHeaders,new ArrayList<>(),httpServletResponse);
|
||||
ExcelUtil.exportExcelWithMerge(taskPool.getJSONArray("nodes"),req.excelHeaders,null,httpServletResponse);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
@@ -490,6 +763,9 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int poolId = 0;
|
||||
|
||||
if(response.getCode() == ResultCode.SUCCESS.getCode())
|
||||
{
|
||||
SdmResponse treeRespond = getCurrentPoolTree(poolName);
|
||||
@@ -504,7 +780,7 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
{
|
||||
response = SdmResponse.failed("分析项库版本号已存在");
|
||||
}
|
||||
else if(mapper.addTaskPoolVersion(poolVersion) <= 0)
|
||||
else if((poolId = mapper.addTaskPoolVersion(poolVersion)) <= 0)
|
||||
{
|
||||
response = SdmResponse.failed("插入分析项库版本信息失败");
|
||||
}
|
||||
@@ -518,6 +794,12 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
{
|
||||
cleanTaskPool(poolName);
|
||||
}
|
||||
else
|
||||
{
|
||||
poolTree.poolBrief.id = poolId;
|
||||
List<TaskPoolItem> taskItems = (List<TaskPoolItem>)response.getData();
|
||||
handleCreateTaskBindRelation(taskItems,poolTree.poolBrief.poolName,poolTree.poolBrief.currentVersion,poolId);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -1103,6 +1385,7 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
poolVersion.poolVersion = generateVersion(currPoolBrief.currentVersion,updateBean.versionType);
|
||||
poolVersion.poolName = currPoolBrief.poolName;
|
||||
poolVersion.parentVersion = currPoolBrief.currentVersion;
|
||||
poolVersion.poolId = currPoolBrief.id;
|
||||
SdmResponse updateResponse = updateCurrentTaskPoolTree(updateBean);
|
||||
if(updateResponse.getCode() == ResultCode.SUCCESS.getCode())
|
||||
{
|
||||
@@ -1150,7 +1433,10 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(response.isSuccess())
|
||||
{
|
||||
handleUpdateTaskBindRelation(updateBean,currPoolBrief);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -1383,6 +1669,63 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
return tasks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse getSimulationPoolTasksByUuids(String poolName,String version,List<String> uuids)
|
||||
{
|
||||
SdmResponse taskResponse = getSimulationPoolTasks(poolName,version);
|
||||
if(!taskResponse.isSuccess())
|
||||
return taskResponse;
|
||||
SdmResponse response = SdmResponse.success();
|
||||
List<TaskPoolItem> tasks = (List<TaskPoolItem>) taskResponse.getData();
|
||||
Iterator<TaskPoolItem> iterator = tasks.iterator();
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
TaskPoolItem taskPoolItem = iterator.next();
|
||||
if(!uuids.contains(taskPoolItem.uuid))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
response.setData(tasks);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过分析项库ID获取分析项信息
|
||||
* @param poolId
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse<Map<String,TaskBaseInfo>> getSimulationTasksByPoolId(long poolId)
|
||||
{
|
||||
SdmResponse response = SdmResponse.success();
|
||||
TaskPoolVersion poolVersion = mapper.queryTaskPoolVersionByPoolId(poolId);
|
||||
if(poolVersion == null)
|
||||
{
|
||||
response = SdmResponse.failed("分析项库不存在");
|
||||
}
|
||||
else
|
||||
{
|
||||
SdmResponse taskResponse = getSimulationPoolTasks(poolVersion.poolName,poolVersion.poolVersion);
|
||||
if(taskResponse.isSuccess())
|
||||
{
|
||||
List<TaskPoolItem> tasks = (List<TaskPoolItem>)taskResponse.getData();
|
||||
Map<String,TaskBaseInfo> mapTaskBaseInfo = new HashMap<>();
|
||||
for(TaskPoolItem taskPoolItem : tasks)
|
||||
{
|
||||
TaskBaseInfo baseInfo = new TaskBaseInfo();
|
||||
baseInfo.uuid = taskPoolItem.uuid;
|
||||
baseInfo.poolName = poolVersion.poolName;
|
||||
baseInfo.version = poolVersion.poolVersion;
|
||||
baseInfo.taskName = taskPoolItem.nodeName;
|
||||
baseInfo.taskCode = taskPoolItem.nodeCode;
|
||||
mapTaskBaseInfo.put(taskPoolItem.uuid,baseInfo);
|
||||
}
|
||||
response.setData(mapTaskBaseInfo);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse getSimulationPoolTasks(String poolName,String version)
|
||||
{
|
||||
@@ -1592,6 +1935,105 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定仿真任务和仿真流程
|
||||
* @param poolName
|
||||
* @param version
|
||||
* @param taskUuids
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse batchBindpoolTaskAndFlowTemplate(String flowCode,String poolName,String version,List<String> taskUuids)
|
||||
{
|
||||
SdmResponse response = SdmResponse.success();
|
||||
List<SimulatePoolTaskFlowTemplateRelate> relates = new ArrayList<>();
|
||||
for(String taskUuid:taskUuids)
|
||||
{
|
||||
SimulatePoolTaskFlowTemplateRelate relate = new SimulatePoolTaskFlowTemplateRelate();
|
||||
relate.taskUuid = taskUuid;
|
||||
relate.flowCode = flowCode;
|
||||
relate.poolName = poolName;
|
||||
relates.add(relate);
|
||||
}
|
||||
mapper.batchAddTaskFlowRelate(relates);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新流程模版与分析项绑定关系
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse updateFlowTaskRelate(BindTaskAndFlowTemplateReq req)
|
||||
{
|
||||
if(mapper.deleteTaskFlowRelateByFlowCode(req.flowCode) < 0)
|
||||
return SdmResponse.failed("删除流程模版与分析项绑定关系失败");
|
||||
List<SimulatePoolTaskFlowTemplateRelate> relations = new ArrayList<>();
|
||||
String flowCode = req.flowCode;
|
||||
for(FlowBindTaskPoolItem taskPoolItem : req.bindTaskkPoolItem)
|
||||
{
|
||||
for(TaskBaseInfo taskBaseInfo : taskPoolItem.taskList)
|
||||
{
|
||||
SimulatePoolTaskFlowTemplateRelate templateRelate = new SimulatePoolTaskFlowTemplateRelate();
|
||||
templateRelate.flowCode = flowCode;
|
||||
templateRelate.poolName = taskPoolItem.poolName;
|
||||
templateRelate.version = taskPoolItem.version;
|
||||
templateRelate.taskUuid = taskBaseInfo.uuid;
|
||||
relations.add(templateRelate);
|
||||
}
|
||||
}
|
||||
mapper.batchAddTaskFlowRelate(relations);
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程模版绑定的分析项信息
|
||||
* @param flowCode
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse<List<FlowBindTaskPoolItem>> getTaskAndFlowTemplateRelateByFlowCode(String flowCode)
|
||||
{
|
||||
SdmResponse response = SdmResponse.success();
|
||||
List<SimulatePoolTaskFlowTemplateRelate> templateRelates = mapper.queryTaskFlowRelateByFlowCode(flowCode);
|
||||
List<FlowBindTaskPoolItem> flowBindTaskPoolItems = new ArrayList<>();
|
||||
Map<String,List<String>> taskPoolItemMap = new HashMap<>();
|
||||
for(SimulatePoolTaskFlowTemplateRelate templateRelate : templateRelates)
|
||||
{
|
||||
String key = templateRelate.poolName+"_"+templateRelate.version;
|
||||
List<String> taskUuids = taskPoolItemMap.get(key);
|
||||
if(taskUuids == null)
|
||||
{
|
||||
taskUuids = new ArrayList<>();
|
||||
taskPoolItemMap.put(key,taskUuids);
|
||||
}
|
||||
taskUuids.add(templateRelate.taskUuid);
|
||||
}
|
||||
for(String key : taskPoolItemMap.keySet())
|
||||
{
|
||||
FlowBindTaskPoolItem taskPoolRelate = new FlowBindTaskPoolItem();
|
||||
String[] poolInfos = key.split("_");
|
||||
taskPoolRelate.flowCode = flowCode;
|
||||
taskPoolRelate.poolName = poolInfos[0];
|
||||
taskPoolRelate.version = poolInfos[1];
|
||||
SdmResponse taskResponse = getSimulationPoolTasksByUuids(poolInfos[0],poolInfos[1],taskPoolItemMap.get(key));
|
||||
if(taskResponse.isSuccess())
|
||||
{
|
||||
List<TaskPoolItem> taskPoolItems = (List<TaskPoolItem>)taskResponse.getData();
|
||||
for(TaskPoolItem taskPoolItem : taskPoolItems)
|
||||
{
|
||||
TaskBaseInfo taskBaseInfo = new TaskBaseInfo();
|
||||
taskBaseInfo.taskCode = taskPoolItem.nodeCode;
|
||||
taskBaseInfo.taskName = taskPoolItem.nodeName;
|
||||
taskBaseInfo.uuid = taskPoolItem.uuid;
|
||||
taskPoolRelate.taskList.add(taskBaseInfo);
|
||||
}
|
||||
flowBindTaskPoolItems.add(taskPoolRelate);
|
||||
}
|
||||
}
|
||||
response.setData(flowBindTaskPoolItems);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user