fix:数据总览删除关键结果和试验结果删除对应记录
This commit is contained in:
@@ -61,4 +61,14 @@ public class SimulationRunFeignClientImpl implements ISimulationRunFeignClient {
|
||||
return SdmResponse.failed("更新算例状态失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse deleteFileForData(List<Long> fileIds) {
|
||||
try {
|
||||
return simulationRunFeignClient.deleteFileForData(fileIds);
|
||||
} catch (Exception e) {
|
||||
log.error("删除试验结果或关键结果失败", e);
|
||||
return SdmResponse.failed("删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.sdm.common.feign.inter.project;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.project.SpdmReportReq;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -36,4 +38,7 @@ public interface ISimulationRunFeignClient {
|
||||
@PostMapping("/run/updateStatusByProcessInstanceId")
|
||||
SdmResponse updateStatusByProcessInstanceId(@RequestParam String processInstanceId, @RequestParam Integer statusCode);
|
||||
|
||||
@PostMapping("/run/deleteFileForData")
|
||||
SdmResponse deleteFileForData(@RequestParam(value = "fileIds") @Validated List<Long> fileIds);
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.sdm.common.entity.resp.project.SimulationRunResp;
|
||||
import com.sdm.common.entity.resp.project.SpdmTaskVo;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.project.SimulationRunFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.project.ISimulationTaskFeignClient;
|
||||
import com.sdm.common.service.TagMapService;
|
||||
@@ -71,6 +72,9 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
@Autowired
|
||||
SimulationNodeFeignClientImpl simuluationNodeFeignClient;
|
||||
|
||||
@Autowired
|
||||
SimulationRunFeignClientImpl simulationRunFeignClient;
|
||||
|
||||
@Autowired
|
||||
private IDataFileService dataFileService;
|
||||
|
||||
@@ -717,6 +721,8 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
DelFileReq delFileReq = new DelFileReq();
|
||||
delFileReq.setDelFileId(req.getDeleteId());
|
||||
dataFileService.delFile(delFileReq);
|
||||
// 删除文件的时候判断一下是否是关键结果和试验结果 是的话删除相关记录
|
||||
return simulationRunFeignClient.deleteFileForData(Collections.singletonList(req.getDeleteId()));
|
||||
}
|
||||
|
||||
if (DataTypeEnum.DIRECTORY.getValue() == req.getDataType() && ObjectUtils.isNotEmpty(req.getDeleteId())) {
|
||||
|
||||
@@ -412,4 +412,14 @@ public class SimulationRunController implements ISimulationRunFeignClient {
|
||||
return runService.batchAddFileInfoForTask(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供给数据总览删除文件使用,如果是试验结果和关键结果需要删除相应记录
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/deleteFileForData")
|
||||
@Operation(summary = "数据总览删除文件")
|
||||
public SdmResponse deleteFileForData(@RequestParam(value = "fileIds") @Validated List<Long> fileIds) {
|
||||
return runService.deleteFileForData(fileIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,8 @@ import com.sdm.project.model.resp.FlowInfoDto;
|
||||
import com.sdm.project.model.resp.KeyResultAndTaskInfoResp;
|
||||
import com.sdm.project.model.resp.RunVersionInfoResp;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -120,4 +122,6 @@ public interface ISimulationRunService extends IService<SimulationRun> {
|
||||
SdmResponse updateStatusByProcessInstanceId(String processInstanceId, Integer statusCode);
|
||||
|
||||
SdmResponse<List<BatchAddFileInfoResp>> batchAddFileInfoForTask(UploadFilesReq req);
|
||||
|
||||
SdmResponse deleteFileForData(List<Long> fileIds);
|
||||
}
|
||||
@@ -2977,4 +2977,43 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
}
|
||||
return batchAddFileInfoResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse deleteFileForData(List<Long> fileIds) {
|
||||
List<SimulationRunKeyResult> keyResultList = simulationKeyResultService.lambdaQuery().in(SimulationRunKeyResult::getFileId, fileIds).list();
|
||||
if (CollectionUtils.isNotEmpty(keyResultList)) {
|
||||
return SdmResponse.success(simulationKeyResultService.lambdaUpdate().in(SimulationRunKeyResult::getFileId, fileIds).remove());
|
||||
}
|
||||
for (Long fileId : fileIds) {
|
||||
// 图片试验结果
|
||||
SimulationExperimentResult imageExp = simulationExpResultService.lambdaQuery().eq(SimulationExperimentResult::getImageId, fileId).one();
|
||||
if (imageExp != null) {
|
||||
if (imageExp.getFileId() == null) {
|
||||
simulationExpResultService.removeById(imageExp.getId());
|
||||
} else {
|
||||
imageExp.setImageId(null);
|
||||
simulationExpResultService.updateById(imageExp);
|
||||
}
|
||||
} else {
|
||||
// 附件试验结果
|
||||
SimulationExperimentResult fileExp = simulationExpResultService.lambdaQuery().like(SimulationExperimentResult::getFileId, fileId).one();
|
||||
if (fileExp != null) {
|
||||
List<Long> oldFileIds = new ArrayList<>(Arrays.stream(fileExp.getFileId().split(",")).mapToLong(Long::parseLong).boxed().toList());
|
||||
oldFileIds.remove(fileId);
|
||||
if (oldFileIds.isEmpty()) {
|
||||
if (fileExp.getImageId() == null) {
|
||||
simulationExpResultService.removeById(fileExp.getId());
|
||||
} else {
|
||||
fileExp.setFileId(null);
|
||||
simulationExpResultService.updateById(fileExp);
|
||||
}
|
||||
} else {
|
||||
fileExp.setFileId(oldFileIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
simulationExpResultService.updateById(fileExp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SdmResponse.success();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user