diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java index a58d8b7..01f4f23 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java @@ -299,4 +299,14 @@ public class TestRecordSampleDataController { }); return R.ok("更新成功!"); } + + @PutMapping("/updateData") + public R updateData(@RequestBody TestRecordSampleData data) { + + TestRecordSampleData sampleData = testRecordSampleDataService.updateData(data); + + return sampleData != null ? R.ok(sampleData, "修改成功!") : R.failed("修改失败!"); + + } + } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java index 96cd573..b38001a 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java @@ -48,6 +48,10 @@ public class TestRecordSampleData extends BaseEntity { private String compoundCnName;//检测的化合物的中文名字 + private double mainArea;//主要产物峰面积 + + private double minorArea;//次要产物峰面积 + @ApiModelProperty("任务数据审核状态, 状态:\n" + "0 待审核,\n" + "1 已审核,\n" + diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java index e7d21a8..b1fb9d0 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java @@ -11,6 +11,7 @@ import digital.laboratory.platform.inspection.entity.TestRecordSampleData; import digital.laboratory.platform.inspection.utils.datafile.hair.HairSewageCompoundData; import digital.laboratory.platform.inspection.utils.datafile.nps.NPSDataFileStruct; import digital.laboratory.platform.inspection.vo.TestResultBusinessVO; +import digital.laboratory.platform.inspetion.api.entity.TestRecord; import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -156,6 +157,12 @@ public interface TestRecordSampleDataService extends IService getStdSampleTestDataByTestId(String testId); diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordReagentServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordReagentServiceImpl.java index df22b8c..52c1e67 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordReagentServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordReagentServiceImpl.java @@ -9,10 +9,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import digital.laboratory.platform.inspection.dto.TestRecordArgumentDto; import digital.laboratory.platform.inspection.entity.TestRecordReagent; import digital.laboratory.platform.inspection.constant.TestRecordArgumentType; +import digital.laboratory.platform.inspection.entity.TestRecordSampleData; import digital.laboratory.platform.inspection.mapper.TestRecordMapper; import digital.laboratory.platform.inspection.mapper.TestRecordReagentMapper; import digital.laboratory.platform.inspection.mapper.TestTemplateMapper; import digital.laboratory.platform.inspection.service.TestRecordReagentService; +import digital.laboratory.platform.inspection.service.TestRecordSampleDataService; import digital.laboratory.platform.inspection.service.TestRecordService; import digital.laboratory.platform.inspection.service.TestTemplateService; import digital.laboratory.platform.inspetion.api.vo.TestRecordVo; @@ -48,13 +50,16 @@ public class TestRecordReagentServiceImpl extends ServiceImpl reagentConsumablesList = testRecordVo.getReagentConsumablesList(); + List reagentConsumablesList = testRecordVo.getReagentConsumablesList(); if (reagentConsumablesList == null || reagentConsumablesList.size() == 0) { //下面两步是为了能使参数正常查询 reagentConsumablesList = new ArrayList<>(); @@ -237,6 +246,7 @@ public class TestRecordReagentServiceImpl extends ServiceImpl 1) { - stringBuilder.append("至").append(value.get(value.size() - 1).getOrderNo()).append("号"); - } - stringBuilder.append("检材") - .append(first.getIsDetected() == 1 ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT) - .append(first.getCompoundName()) - .append("\n"); + if (value.size() > 1) { + stringBuilder.append("至").append(value.get(value.size() - 1).getOrderNo()).append("号"); + } + stringBuilder.append("检材") + .append(first.getIsDetected() == 1 ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT) + .append(first.getCompoundName()) + .append("\n"); }); } else { dataMap.forEach((key, value) -> { @@ -927,7 +926,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl testRecordSampleDataList = buildSampleDataFromNps(npsDataFileStructList, testId);//构造实验数据 testRecordService.update(Wrappers.lambdaUpdate().eq(TestRecord::getId, testId).set(TestRecord::getStatus, 2)); - return true; + return true; // } catch (Exception err) { // log.info("程序执行异常{}", err.getMessage()); // err.printStackTrace(); @@ -1562,6 +1561,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl sampleIdList = testRecord.getSampleTestList(); + + // 根据样本ID列表查询样本信息列表 + List sampleInfos = sampleInfoService.list(Wrappers.lambdaQuery() + .in(SampleInfo::getId, sampleIdList)); + + // 用于存储生成的测试记录样本数据的列表 + ArrayList sampleDataList = new ArrayList<>(); + + // 创建一个标准样本数据对象 + TestRecordSampleData data = new TestRecordSampleData(); + // 设置化合物名称 + data.setCompoundName(compoundName); + // 设置样本编号,格式为 "STD-" 加上化合物名称 + data.setSampleNo("STD-" + compoundName); + // 设置样本类型为 "STD" + data.setSampleType("STD"); + // 设置样本名称,格式为 "STD-" 加上化合物名称 + data.setName("STD-" + compoundName); + // 设置样本状态为 0 + data.setStatus(0); + // 生成一个32位的大写UUID作为样本数据ID + data.setId(IdWorker.get32UUID().toUpperCase()); + + // 将标准样本数据添加到样本数据列表中 + sampleDataList.add(data); + + // 遍历样本信息列表,为每个样本创建对应的测试记录样本数据 + sampleInfos.forEach(item -> { + TestRecordSampleData sampleData = new TestRecordSampleData(); + // 设置化合物名称 + data.setCompoundName(compoundName); + // 设置样本编号为样本的受理编号 + data.setSampleNo(item.getAcceptNo()); + // 设置样本类型为 "Analyte" + data.setSampleType("Analyte"); + // 设置样本名称为样本的受理编号 + data.setName(item.getAcceptNo()); + // 设置样本状态为 0 + data.setStatus(0); + // 生成一个32位的大写UUID作为样本数据ID + data.setId(IdWorker.get32UUID().toUpperCase()); + // 将样本数据添加到样本数据列表中 + sampleDataList.add(data); + }); + } + + /** + * 自动删除指定测试记录和化合物名称对应的测试记录样本数据 + * + * @param testId 测试记录的ID + * @param compoundName 化合物名称 + * @return 如果删除成功返回 true,否则返回 false + */ + @Override + public boolean autoDelData(String testId, String compoundName) { + // 根据测试记录ID和化合物名称删除对应的测试记录样本数据 + return this.remove(Wrappers.lambdaQuery() + .eq(TestRecordSampleData::getTestId, testId) + .eq(TestRecordSampleData::getCompoundName, compoundName)); + } + + @Override + public TestRecordSampleData updateData(TestRecordSampleData data) { + if (this.getById(data.getId()) == null) { + throw new RuntimeException("数据不存在"); + } + String compoundName = data.getCompoundName(); + + TestRecordSampleData std = this.getOne(Wrappers.lambdaQuery() + .eq(TestRecordSampleData::getCompoundName, compoundName) + .eq(TestRecordSampleData::getTestId, data.getTestId()) + .eq(TestRecordSampleData::getSampleType, "STD")); + + if (data.getMainArea() != 0.0 && + data.getMinorArea() != 0.0 && + data.getTargetRtTime() != 0.0 && + std.getMainArea() != 0.0 && + std.getMinorArea() != 0.0 && + std.getTargetRtTime() != 0.0) { + } + return this.updateById(data) ? data : null; + } } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java index faefc52..8965b8a 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java @@ -1336,12 +1336,12 @@ public class TestRecordServiceImpl extends ServiceImpl 0) { - // 删除之前上传的 - JSONObject oldObject = testAtlas.getJSONObject(0); - ossFile.fileDelete(oldObject.getString("path")); - testAtlas = new JSONArray(); - } +// if (testAtlas.size() > 0) { +// // 删除之前上传的 +// JSONObject oldObject = testAtlas.getJSONObject(0); +// ossFile.fileDelete(oldObject.getString("path")); +// testAtlas = new JSONArray(); +// } JSONObject jsonObject = new JSONObject(); jsonObject.put("fileId", fileId); jsonObject.put("fileName", fileName);