20250325 更新
This commit is contained in:
@@ -6,9 +6,13 @@ import digital.laboratory.platform.common.swagger.annotation.EnableDLPSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
@EnableDLPSwagger2
|
||||
@EnableDLPFeignClients
|
||||
|
||||
@@ -31,8 +31,10 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.security.Principal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
@@ -142,25 +144,19 @@ public class TestRecordSampleDataController {
|
||||
|
||||
@PutMapping("/updateEntrustTestData")
|
||||
@ApiOperation(value = "修改导入的实验数据", notes = "修改导入的实验数据")
|
||||
private R updateEntrustTestData(@RequestBody UpdateEntrustTestDataDTO dto) {
|
||||
public R<List<TestRecordSampleData>> updateEntrustTestData(@RequestBody UpdateEntrustTestDataDTO dto) {
|
||||
try {
|
||||
testRecordSampleDataService.validateTestStatus(dto.getTestId());
|
||||
List<UpdateEntrustTestDataDTO> list = dto.getList();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
for (UpdateEntrustTestDataDTO updateEntrustTestDataDTO : list) {
|
||||
testRecordSampleDataService.updateEntrustTestData(updateEntrustTestDataDTO);
|
||||
}
|
||||
return R.ok("实验数据保存成功");
|
||||
return R.ok(list.stream().map(testRecordSampleDataService::updateEntrustTestData).collect(Collectors.toList()),"实验数据保存成功");
|
||||
} else {
|
||||
return R.ok(testRecordSampleDataService.updateEntrustTestData(dto));
|
||||
return R.ok(Collections.singletonList(testRecordSampleDataService.updateEntrustTestData(dto)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof RuntimeException) {
|
||||
return R.failed("实验数据保存失败!" + e.getMessage());
|
||||
}
|
||||
return R.failed("实验数据保存失败!");
|
||||
}
|
||||
}
|
||||
|
||||
//分析获取检验结果
|
||||
@@ -298,13 +294,4 @@ 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("修改失败!");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import digital.laboratory.platform.common.mybatis.base.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -15,95 +16,57 @@ import lombok.Data;
|
||||
@TableName(value ="b_test_record_sampledata", autoResultMap = true)
|
||||
@ApiModel(value = "实验中样本检测结果数据", description = "实验中样本检测结果数据")
|
||||
public class TestRecordSampleData extends BaseEntity {
|
||||
/**
|
||||
* 主键标识
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "主键标识", example = "123456789")
|
||||
@TableId(value = "ID", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 数据从机器中导出的唯一标识
|
||||
*/
|
||||
@ApiModelProperty(value = "数据从机器中导出的唯一标识", example = "Sample123")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 样本编号
|
||||
*/
|
||||
@ApiModelProperty(value = "样本编号", example = "SMP001")
|
||||
private String sampleNo;
|
||||
|
||||
/**
|
||||
* 实验ID
|
||||
*/
|
||||
@ApiModelProperty(value = "实验ID", example = "TEST001")
|
||||
private String testId;
|
||||
|
||||
/**
|
||||
* 标准品浓度
|
||||
*/
|
||||
@ApiModelProperty(value = "标准品浓度", example = "10.5")
|
||||
private String stdConcentration;
|
||||
|
||||
/**
|
||||
* 样品浓度
|
||||
*/
|
||||
@ApiModelProperty(value = "样品浓度", example = "8.9")
|
||||
private String sampleConcentration;
|
||||
|
||||
/**
|
||||
* 化合物名称
|
||||
*/
|
||||
@ApiModelProperty(value = "化合物名称", example = "Heroin")
|
||||
private String compoundName;
|
||||
|
||||
/**
|
||||
* 保留时间是否在误差范围内,缴获物(-1~1), 生物样本(-2.5~2.5)
|
||||
*/
|
||||
@ApiModelProperty(value = "保留时间是否在误差范围内,缴获物(-1~1), 生物样本(-2.5~2.5)", example = "0.5")
|
||||
private String rtTimeWithinError;
|
||||
|
||||
/**
|
||||
* 保留时间相对误差(%)
|
||||
*/
|
||||
@ApiModelProperty(value = "保留时间相对误差(%)", example = "1.2")
|
||||
private Double rtTimeError;
|
||||
|
||||
/**
|
||||
* 检材保留时间(min)
|
||||
*/
|
||||
@ApiModelProperty(value = "检材保留时间(min)", example = "2.5")
|
||||
private Double targetRtTime;
|
||||
|
||||
/**
|
||||
* 标准品保留时间(min)
|
||||
*/
|
||||
@ApiModelProperty(value = "标准品保留时间(min)", example = "2.6")
|
||||
private Double stdRtTime;
|
||||
|
||||
/**
|
||||
* 是否检出该物质 1检出 0 未检出
|
||||
*/
|
||||
@ApiModelProperty(value = "是否检出该物质 1 检出, 0 未检出", example = "1")
|
||||
private Integer isDetected;
|
||||
|
||||
/**
|
||||
* 样本类型- QC(质控) STD(标准品) Analyte(待测样品)
|
||||
*/
|
||||
@ApiModelProperty(value = "样本类型 - QC(质控), STD(标准品), Analyte(待测样品)", example = "QC")
|
||||
private String sampleType;
|
||||
|
||||
/**
|
||||
* 检验数据json
|
||||
*/
|
||||
@ApiModelProperty(value = "检验数据 JSON", example = "{\"mass\": 146, \"intensity\": 200}")
|
||||
private String dataJson;
|
||||
|
||||
/**
|
||||
* 检验结果数据json
|
||||
*/
|
||||
@ApiModelProperty(value = "检验结果数据 JSON", example = "{\"result\": \"Positive\"}")
|
||||
private String dataResultJson;
|
||||
|
||||
/**
|
||||
* 状态:
|
||||
* 0 待审核,
|
||||
* 1 已审核,
|
||||
* 2 已审批,
|
||||
* 3 已上传
|
||||
* 上传到大数据平台(仅针对任务数据, 其他业务类型的数据默认0)
|
||||
*/
|
||||
@ApiModelProperty(value = "状态:0-待审核, 1-已审核, 2-已审批, 3-已上传", example = "1")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 检测的化合物的中文名字
|
||||
*/
|
||||
@ApiModelProperty(value = "检测的化合物的中文名字", example = "海洛因")
|
||||
private String compoundCnName;
|
||||
|
||||
public TestRecordSampleData() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package digital.laboratory.platform.inspection.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -97,7 +96,7 @@ public interface TestRecordSampleDataService extends IService<TestRecordSampleD
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
JSONObject updateEntrustTestData(UpdateEntrustTestDataDTO dto);
|
||||
TestRecordSampleData updateEntrustTestData(UpdateEntrustTestDataDTO dto);
|
||||
|
||||
/**
|
||||
* 获取任务实验结果数据
|
||||
@@ -161,8 +160,6 @@ public interface TestRecordSampleDataService extends IService<TestRecordSampleD
|
||||
|
||||
boolean autoDelData(String testId, String reagentId);
|
||||
|
||||
TestRecordSampleData updateData(TestRecordSampleData data);
|
||||
|
||||
/**
|
||||
* 删除检验数据
|
||||
* @param testId
|
||||
@@ -171,7 +168,4 @@ public interface TestRecordSampleDataService extends IService<TestRecordSampleD
|
||||
|
||||
Comparator getSortBySampleNo();
|
||||
|
||||
|
||||
//获取标准品样品信息数据
|
||||
// List<NPSCaseTestDataDto> getStdSampleTestDataByTestId(String testId);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
@@ -202,18 +203,18 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
&& testRecordSampleSolutionsNoList.contains(item.getSampleNo())
|
||||
);
|
||||
}).collect(Collectors.toList());
|
||||
ESTBusinessInfoVO estBusinessInfoVO = estBusinessInfoVOS.get(0);
|
||||
// 封装的结果集
|
||||
List<Object> retList = new ArrayList<>();
|
||||
if (estBusinessInfoVO.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
||||
extractedSampleTestData(testRecordSampleDataList, retList, HairSewageDataDto.class);
|
||||
} else if (estBusinessInfoVO.getBusinessType().equals(BusinessType.NPS_CASE.getBusinessType()) || estBusinessInfoVO.getBusinessType().equals(BusinessType.SCREENING_EVENT.getBusinessType())) {
|
||||
extractedSampleTestData(testRecordSampleDataList, retList, NPSCaseTestDataDto.class);
|
||||
} else {
|
||||
extractedSampleTestData(testRecordSampleDataList, retList, HairSewageDataDto.class);
|
||||
}
|
||||
// List<?> collect = TypeCasting(retList);
|
||||
return typeCasting(retList);
|
||||
// ESTBusinessInfoVO estBusinessInfoVO = estBusinessInfoVOS.get(0);
|
||||
// // 封装的结果集
|
||||
// List<Object> retList = new ArrayList<>();
|
||||
// if (estBusinessInfoVO.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
||||
// extractedSampleTestData(testRecordSampleDataList, retList, HairSewageDataDto.class);
|
||||
// } else if (estBusinessInfoVO.getBusinessType().equals(BusinessType.NPS_CASE.getBusinessType()) || estBusinessInfoVO.getBusinessType().equals(BusinessType.SCREENING_EVENT.getBusinessType())) {
|
||||
// extractedSampleTestData(testRecordSampleDataList, retList, NPSCaseTestDataDto.class);
|
||||
// } else {
|
||||
// extractedSampleTestData(testRecordSampleDataList, retList, HairSewageDataDto.class);
|
||||
// }
|
||||
//// List<?> collect = TypeCasting(retList);
|
||||
return testRecordSampleDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,21 +249,21 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
List<TestRecordSampleData> list = this.list(Wrappers.<TestRecordSampleData>lambdaQuery()
|
||||
.eq(TestRecordSampleData::getTestId, testId)
|
||||
.last("ORDER BY SUBSTRING_INDEX(name, '-', -1) + 0"));
|
||||
List<Object> retList = new ArrayList<>();
|
||||
switch (BusinessType.getBusinessTypeByType(type)) {
|
||||
case SCREENING_EVENT:
|
||||
case NPS_CASE:
|
||||
// NPS的数据分析
|
||||
extractedSampleTestData(list, retList, NPSCaseTestDataDto.class);
|
||||
break;
|
||||
case BOINT_CASE:
|
||||
extractedSampleTestData(list, retList, HairSewageDataDto.class);
|
||||
break;
|
||||
}
|
||||
// List<Object> retList = new ArrayList<>();
|
||||
// switch (BusinessType.getBusinessTypeByType(type)) {
|
||||
// case SCREENING_EVENT:
|
||||
// case NPS_CASE:
|
||||
// // NPS的数据分析
|
||||
// extractedSampleTestData(list, retList, NPSCaseTestDataDto.class);
|
||||
// break;
|
||||
// case BOINT_CASE:
|
||||
// extractedSampleTestData(list, retList, HairSewageDataDto.class);
|
||||
// break;
|
||||
// }
|
||||
|
||||
// z最后转换类型
|
||||
// TypeCasting(retList);
|
||||
return typeCasting(retList);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,7 +423,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject updateEntrustTestData(UpdateEntrustTestDataDTO dto) {
|
||||
public TestRecordSampleData updateEntrustTestData(UpdateEntrustTestDataDTO dto) {
|
||||
JSONObject dtoParam = dto.getParam();
|
||||
TestRecordSampleData oldInfo = this.getById(dtoParam.getString("testSampleDataId")); // 取实验数据id
|
||||
// 取出老数据,进行更改
|
||||
@@ -442,34 +443,40 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
/*dtoParam.put("testSampleDataList", null);*/
|
||||
NPSCaseTestDataDto param = JSONObject.toJavaObject(dtoParam, NPSCaseTestDataDto.class);
|
||||
|
||||
saved = saveOrUpdateTestData(
|
||||
return saveOrUpdateTestData(
|
||||
oldInfo,
|
||||
param.getCompoundName(),
|
||||
JSONUtil.toJsonStr(param),
|
||||
param.getSampleNo(),
|
||||
param.getTestId(),
|
||||
param.getSampleName(),
|
||||
param.getCompoundCnName());
|
||||
param.getCompoundCnName(),
|
||||
param.getTargetRtTime(),
|
||||
param.getRtTimeError(),
|
||||
param.getTargetConcentration());
|
||||
|
||||
} else if (dto.getType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
||||
} else {
|
||||
HairSewageDataDto param = JSONObject.toJavaObject(dtoParam, HairSewageDataDto.class);
|
||||
saved = saveOrUpdateTestData(
|
||||
return saveOrUpdateTestData(
|
||||
oldInfo,
|
||||
param.getCompoundName(),
|
||||
JSONUtil.toJsonStr(param),
|
||||
param.getSampleNo(),
|
||||
param.getTestId(),
|
||||
param.getSampleName(),
|
||||
param.getCompoundCnName());
|
||||
}
|
||||
// 根据成功标识返回
|
||||
if (saved) {
|
||||
// 保存成功, 返回成功的json对象
|
||||
return dtoParam;
|
||||
} else {
|
||||
// 保存失败, 返回之前的json对象
|
||||
return oldObject;
|
||||
param.getCompoundCnName(),
|
||||
param.getTargetRtTime(),
|
||||
param.getRtTimeError(),
|
||||
param.getTargetConcentration());
|
||||
}
|
||||
// // 根据成功标识返回
|
||||
// if (saved) {
|
||||
// // 保存成功, 返回成功的json对象
|
||||
// return dtoParam;
|
||||
// } else {
|
||||
// // 保存失败, 返回之前的json对象
|
||||
// return oldObject;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,49 +851,6 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新或者保存实验数据
|
||||
*
|
||||
* @param oldInfo 未更新前的数据
|
||||
* @param compoundName
|
||||
* @param jsonStr DTO 转 json String
|
||||
* @param sampleNo
|
||||
* @param testId
|
||||
* @param sampleName
|
||||
* @return
|
||||
*/
|
||||
private boolean saveOrUpdateTestData(TestRecordSampleData oldInfo,
|
||||
String compoundName,
|
||||
String jsonStr,
|
||||
String sampleNo,
|
||||
String testId, String sampleName, String compoundCnName) {
|
||||
// TestRecordSampleData one = this.getById(testSampleDataId);
|
||||
if (oldInfo != null) {
|
||||
return this.update(Wrappers.<TestRecordSampleData>lambdaUpdate()
|
||||
.eq(TestRecordSampleData::getId, oldInfo.getId())
|
||||
.set(!oldInfo.getCompoundName().equals(compoundName), TestRecordSampleData::getCompoundName, compoundName)
|
||||
.set(sampleName != null && !sampleName.equals(oldInfo.getName()), TestRecordSampleData::getName, sampleName)
|
||||
.set(TestRecordSampleData::getDataResultJson, jsonStr)
|
||||
.set(StringUtils.isNotBlank(compoundCnName), TestRecordSampleData::getCompoundCnName, compoundCnName));
|
||||
} else {
|
||||
TestRecordSampleData testRecordSampleData = new TestRecordSampleData();
|
||||
testRecordSampleData.setId(IdWorker.get32UUID());
|
||||
testRecordSampleData.setSampleNo(sampleNo);
|
||||
testRecordSampleData.setCompoundName(compoundName);
|
||||
testRecordSampleData.setTestId(testId);
|
||||
testRecordSampleData.setDataResultJson(jsonStr);
|
||||
if (sampleNo.startsWith(StdSolutionNum.QC_SOLUTION.getPrefix())) {
|
||||
testRecordSampleData.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_QC);
|
||||
} else if (sampleNo.startsWith(StdSolutionNum.MIXED_SOLUTION.getPrefix()) || sampleNo.startsWith(StdSolutionNum.SIMPLE_SOLUTION.getPrefix())) {
|
||||
testRecordSampleData.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_STD);
|
||||
} else {
|
||||
testRecordSampleData.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_ANALYTE);
|
||||
}
|
||||
return this.save(testRecordSampleData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 毛发案件检验数据持久化到数据库
|
||||
*
|
||||
@@ -1651,15 +1615,15 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
|
||||
List<TestRecordSampleData> sampleDataList = new ArrayList<>();
|
||||
|
||||
TestRecordSampleData stdSampleData = createSampleData(compoundName, TestRecordSampleDataConstant.SAMPLE_TYPE_STD, TestRecordSampleDataConstant.SAMPLE_TYPE_STD + "-" + compoundName);
|
||||
TestRecordSampleData stdSampleData = createSampleData(compoundName, TestRecordSampleDataConstant.SAMPLE_TYPE_STD, TestRecordSampleDataConstant.SAMPLE_TYPE_STD + "-" + compoundName, testId);
|
||||
sampleDataList.add(stdSampleData);
|
||||
|
||||
sampleInfos.forEach(item -> {
|
||||
TestRecordSampleData sampleData = createSampleData(compoundName, TestRecordSampleDataConstant.SAMPLE_TYPE_ANALYTE, item.getAcceptNo());
|
||||
TestRecordSampleData sampleData = createSampleData(compoundName, TestRecordSampleDataConstant.SAMPLE_TYPE_ANALYTE, item.getAcceptNo(), testId);
|
||||
sampleDataList.add(sampleData);
|
||||
});
|
||||
|
||||
if (drug != null && StrUtil.isAllNotBlank(drug.getMainProductIon(), drug.getMinorProductIon(), drug.getCharacteristicIons())) {
|
||||
if (drug != null && StrUtil.isNotBlank(drug.getCharacteristicIons())) {
|
||||
// 当对应的毒品信息不为空,添加扩展数据
|
||||
List<TestRecordSampleDataExpand> testRecordSampleDataExpandList = sampleDataList.stream().flatMap(sampleData -> {
|
||||
List<TestRecordSampleDataExpand> testRecordSampleDataExpand = testRecordSampledataExpandService.saveExpDataByBusinessType(sampleData.getId(), drug, testRecord.getBusinessType());
|
||||
@@ -1676,15 +1640,17 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
* @param compoundName 化合物名称
|
||||
* @param sampleType 样本类型
|
||||
* @param sampleNo 样本编号
|
||||
* @param testId 实验id
|
||||
* @return 返回创建的测试记录样本数据对象
|
||||
*/
|
||||
private TestRecordSampleData createSampleData(String compoundName, String sampleType, String sampleNo) {
|
||||
private TestRecordSampleData createSampleData(String compoundName, String sampleType, String sampleNo, String testId) {
|
||||
TestRecordSampleData data = new TestRecordSampleData();
|
||||
data.setCompoundName(compoundName);
|
||||
data.setSampleNo(sampleNo);
|
||||
data.setSampleType(sampleType);
|
||||
data.setName(sampleNo);
|
||||
data.setStatus(TaskTestDataStatus.WAIT_REVIEW.getCode());
|
||||
data.setTestId(testId);
|
||||
data.setId(IdWorker.getIdStr());
|
||||
return data;
|
||||
}
|
||||
@@ -1707,44 +1673,47 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
.eq(TestRecordSampleData::getTestId, testId)
|
||||
.eq(TestRecordSampleData::getCompoundName, compoundName));
|
||||
List<String> removeIds = removeDataList.stream().map(TestRecordSampleData::getId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(removeIds)) {
|
||||
// 根据测试记录ID和化合物名称删除对应的测试记录样本数据
|
||||
testRecordSampledataExpandService.remove(Wrappers.<TestRecordSampleDataExpand>lambdaQuery().in(TestRecordSampleDataExpand::getTestDataId, removeIds));
|
||||
}
|
||||
return this.removeBatchByIds(removeIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestRecordSampleData updateData(TestRecordSampleData data) {
|
||||
if (this.getById(data.getId()) == null) {
|
||||
throw new RuntimeException("数据不存在");
|
||||
}
|
||||
String compoundName = data.getCompoundName();
|
||||
/**
|
||||
* 更新计算数据,计算保留时间和保留时间误差
|
||||
* @param dataId 检验数据id
|
||||
* @return
|
||||
*/
|
||||
public Boolean calculateInspectData(String dataId) {
|
||||
TestRecordSampleData testRecordSampleData = super.getById(dataId);
|
||||
String compoundName = testRecordSampleData.getCompoundName();
|
||||
|
||||
TestRecordSampleData std = this.getOne(Wrappers.<TestRecordSampleData>lambdaQuery()
|
||||
.eq(TestRecordSampleData::getCompoundName, compoundName)
|
||||
.eq(TestRecordSampleData::getTestId, data.getTestId())
|
||||
.eq(TestRecordSampleData::getTestId, testRecordSampleData.getTestId())
|
||||
.eq(TestRecordSampleData::getSampleType, "STD"));
|
||||
|
||||
if ( data.getTargetRtTime() != null && std.getTargetRtTime() != null ) {
|
||||
TestRecord testRecord = testRecordService.getById(data.getTestId());
|
||||
if ( testRecordSampleData.getTargetRtTime() != null && std.getTargetRtTime() != null ) {
|
||||
TestRecord testRecord = testRecordService.getById(testRecordSampleData.getTestId());
|
||||
if (testRecord.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
||||
data.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(data.getTargetRtTime(), std.getStdRtTime()));
|
||||
data.setRtTimeWithinError(
|
||||
testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getStdRtTime()));
|
||||
testRecordSampleData.setRtTimeWithinError(
|
||||
processInspectDataService.setHairCaseRtTimeWithinError(
|
||||
data.getRtTimeError()
|
||||
testRecordSampleData.getRtTimeError()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
data.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(data.getTargetRtTime(), std.getStdRtTime()));
|
||||
data.setRtTimeWithinError(
|
||||
testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getStdRtTime()));
|
||||
testRecordSampleData.setRtTimeWithinError(
|
||||
processInspectDataService.getRtWithinErrorText(
|
||||
Math.abs(data.getRtTimeError()),
|
||||
Math.abs(testRecordSampleData.getRtTimeError()),
|
||||
1
|
||||
)
|
||||
);
|
||||
}
|
||||
System.out.println("所有属性都不为 null");
|
||||
}
|
||||
return this.updateById(data) ? data : null;
|
||||
return this.updateById(testRecordSampleData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1762,4 +1731,62 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新或者保存实验数据
|
||||
*
|
||||
* @param oldInfo 未更新前的数据
|
||||
* @param compoundName
|
||||
* @param jsonStr DTO 转 json String
|
||||
* @param sampleNo
|
||||
* @param testId
|
||||
* @param sampleName
|
||||
* @param targetRtTime
|
||||
* @param rtTimeError
|
||||
* @param targetConcentration
|
||||
* @return
|
||||
*/
|
||||
private TestRecordSampleData saveOrUpdateTestData(TestRecordSampleData oldInfo,
|
||||
String compoundName,
|
||||
String jsonStr,
|
||||
String sampleNo,
|
||||
String testId, String sampleName, String compoundCnName, double targetRtTime, double rtTimeError, String targetConcentration) {
|
||||
boolean success = false;
|
||||
if (oldInfo != null) {
|
||||
success = this.update(Wrappers.<TestRecordSampleData>lambdaUpdate()
|
||||
.eq(TestRecordSampleData::getId, oldInfo.getId())
|
||||
.set(!oldInfo.getCompoundName().equals(compoundName), TestRecordSampleData::getCompoundName, compoundName)
|
||||
.set(sampleName != null && !sampleName.equals(oldInfo.getName()), TestRecordSampleData::getName, sampleName)
|
||||
.set(TestRecordSampleData::getTargetRtTime, targetRtTime)
|
||||
.set(TestRecordSampleData::getRtTimeError, rtTimeError)
|
||||
.set(TestRecordSampleData::getSampleConcentration, targetConcentration)
|
||||
// .set(TestRecordSampleData::getDataResultJson, jsonStr) // 现在数据提取到了表字段,不在处理json数据
|
||||
.set(StringUtils.isNotBlank(compoundCnName), TestRecordSampleData::getCompoundCnName, compoundCnName));
|
||||
} else {
|
||||
oldInfo = new TestRecordSampleData();
|
||||
oldInfo.setId(IdWorker.get32UUID());
|
||||
oldInfo.setSampleNo(sampleNo);
|
||||
oldInfo.setCompoundName(compoundName);
|
||||
oldInfo.setSampleConcentration(targetConcentration);
|
||||
oldInfo.setRtTimeError(rtTimeError);
|
||||
oldInfo.setTargetRtTime(targetRtTime);
|
||||
oldInfo.setTestId(testId);
|
||||
// oldInfo.setDataResultJson(jsonStr); // 现在数据提取到了表字段,不在处理json数据
|
||||
if (sampleNo.startsWith(StdSolutionNum.QC_SOLUTION.getPrefix())) {
|
||||
oldInfo.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_QC);
|
||||
} else if (sampleNo.startsWith(StdSolutionNum.MIXED_SOLUTION.getPrefix()) || sampleNo.startsWith(StdSolutionNum.SIMPLE_SOLUTION.getPrefix())) {
|
||||
oldInfo.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_STD);
|
||||
} else {
|
||||
oldInfo.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_ANALYTE);
|
||||
}
|
||||
|
||||
success = this.save(oldInfo);
|
||||
}
|
||||
if (success) {
|
||||
String dataId = oldInfo.getId();
|
||||
CompletableFuture.runAsync(() -> calculateInspectData(dataId));
|
||||
return super.getById(dataId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user