fix:新增失败节点重试 & 参数库对象创建人
This commit is contained in:
@@ -95,4 +95,17 @@ public class FlowableClientFeignClientImpl implements IFlowableFeignClient {
|
||||
}
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse retryFailedNode(String processInstanceId, String failNodeId) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = flowableFeignClient.retryFailedNode(processInstanceId, failNodeId);
|
||||
log.info("重试当前失败节点:"+ response);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("重试当前失败节点失败", e);
|
||||
return SdmResponse.failed("重试当前失败节点失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,7 @@ public interface IFlowableFeignClient {
|
||||
@PostMapping("/process/asyncCallback")
|
||||
SdmResponse asyncCallback(@RequestBody AsyncCallbackRequest request);
|
||||
|
||||
@PostMapping("/process/retryFailedNode")
|
||||
SdmResponse retryFailedNode(@RequestParam String processInstanceId, @RequestParam String failNodeId);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,4 +16,10 @@ public class SimulationParameterItem {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private Long creatorId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.sdm.common.entity.enums.SimulationParameterDataTypeEnum;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
|
||||
import com.sdm.common.service.UserNameCacheService;
|
||||
import com.sdm.common.utils.DateUtils;
|
||||
import com.sdm.data.dao.SimulationParameterLibraryMapper;
|
||||
import com.sdm.data.model.bo.ApprovalParamContentsModel;
|
||||
import com.sdm.data.model.entity.FileMetadataInfo;
|
||||
@@ -35,6 +36,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -98,7 +100,21 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse addLibraryCategoryObject(SimulationParameterLibraryCategoryObjectReq req) {
|
||||
try {
|
||||
SdmResponse<Long> integerSdmResponse = dataFileService.uploadSimulationParamFile(req.getFile());
|
||||
// 添加创建人和创建时间
|
||||
String originalJson = new String(req.getFile().getBytes(), StandardCharsets.UTF_8);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(originalJson);
|
||||
List<Map<String, Object>> parameterJsonValueFromJsonNode = parseJsonArray(jsonNode);
|
||||
if (!CollectionUtils.isEmpty(parameterJsonValueFromJsonNode)) {
|
||||
parameterJsonValueFromJsonNode.forEach(map -> {
|
||||
map.put("creatorId", ThreadLocalContext.getUserId());
|
||||
map.put("createTime", DateUtils.format(new Date(), DateUtils.PATTERN_DEFAULT));
|
||||
});
|
||||
}
|
||||
String content = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(parameterJsonValueFromJsonNode);
|
||||
MultipartFile file = new MockMultipartFile(req.getFileName(), req.getFile().getOriginalFilename(), req.getFile().getContentType(), content.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
SdmResponse<Long> integerSdmResponse = dataFileService.uploadSimulationParamFile(file);
|
||||
Long fileId = integerSdmResponse.getData();
|
||||
|
||||
SimulationParameterLibraryCategoryObject simulationParameterLibraryCategoryObject = new SimulationParameterLibraryCategoryObject();
|
||||
@@ -321,7 +337,21 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(minioInputStream);
|
||||
List<Map<String, Object>> parameterJsonValueFromJsonNode = parseJsonArray(jsonNode);
|
||||
if (!CollectionUtils.isEmpty(parameterJsonValueFromJsonNode)) {
|
||||
// 将 List<Long> userIds 转成set
|
||||
Set<Long> userIdsSet = new HashSet<>();
|
||||
for (Map<String, Object> map : parameterJsonValueFromJsonNode) {
|
||||
userIdsSet.add((Long) map.get("creatorId"));
|
||||
}
|
||||
Map<Long, String> longStringMap = userNameCacheService.batchGetUserNames(userIdsSet);
|
||||
for (Map<String, Object> map : parameterJsonValueFromJsonNode) {
|
||||
map.put("creator", longStringMap.get((Long) map.get("creatorId")));
|
||||
simulationParameterLibraryCategoryObjectResp.setCreateTime(simulationParameterLibraryCategoryObject.getCreateTime());
|
||||
}
|
||||
}
|
||||
simulationParameterLibraryCategoryObjectResp.setParameterJsonValue(parameterJsonValueFromJsonNode);
|
||||
|
||||
|
||||
} else {
|
||||
// 兜底操作,可能是清库了,或者数据被删除了,删除掉参数对象的json文件信息
|
||||
simulationParameterLibraryCategoryObject.setFileId(null);
|
||||
@@ -453,6 +483,13 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
if (fileMetadataInfo == null) {
|
||||
return SdmResponse.failed("文件元数据不存在");
|
||||
}
|
||||
// 给页面上新增的对象参数添加创建人和时间
|
||||
req.getParameterList().forEach(item -> {
|
||||
if (item.getCreatorId() == null) {
|
||||
item.setCreatorId(ThreadLocalContext.getUserId());
|
||||
item.setCreateTime(DateUtils.format(new Date(), DateUtils.PATTERN_DEFAULT));
|
||||
}
|
||||
});
|
||||
|
||||
// 将参数列表直接转换为JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@@ -257,6 +257,16 @@ public class SimulationRunController implements ISimulationRunFeignClient {
|
||||
public SdmResponse<FlowInfoDto> listFlowNodes(@RequestBody SpdmTaskRunReq req) {
|
||||
return runService.listFlowNodes(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务执行 重试失败节点
|
||||
*/
|
||||
@SysLog("任务执行 重试失败节点")
|
||||
@PostMapping("/retryFailedNode")
|
||||
public SdmResponse retryFailedNode(@RequestParam String processInstanceId, @RequestParam String failNodeId) {
|
||||
return runService.retryFailedNode(processInstanceId, failNodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程关联报告
|
||||
*
|
||||
|
||||
@@ -79,6 +79,8 @@ public interface ISimulationRunService extends IService<SimulationRun> {
|
||||
|
||||
SdmResponse<FlowInfoDto> listFlowNodes(SpdmTaskRunReq req);
|
||||
|
||||
SdmResponse retryFailedNode(String processInstanceId, String failNodeId);
|
||||
|
||||
SdmResponse flowRelateReport(SpdmReportReq req);
|
||||
|
||||
SdmResponse<List<SimulationBaseQuantities>> listQuantities();
|
||||
|
||||
@@ -1504,6 +1504,11 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse retryFailedNode(String processInstanceId, String failNodeId) {
|
||||
return flowableFeignClient.retryFailedNode(processInstanceId, failNodeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse flowRelateReport(SpdmReportReq req) {
|
||||
generateReport(req,null);
|
||||
|
||||
Reference in New Issue
Block a user