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