Merge branch 'main' of http://carsafe.uicp.cn/toolchaintechnologycenter/spdm-backend
This commit is contained in:
@@ -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