|
|
|
|
@ -797,13 +797,21 @@ public class ExamineResultServiceImpl extends BaseServiceImpl<ExamineResultMappe |
|
|
|
|
// 仪器设备记录表,试剂使用记录表入库
|
|
|
|
|
private void saves(ExamineResult examineResult) { |
|
|
|
|
Examine examine = examineService.getById(examineResult.getExamineId()); |
|
|
|
|
String[] split = examineResult.getInstrumentId().split(","); |
|
|
|
|
String[] split1 = examineResult.getReagentId().split(","); |
|
|
|
|
// 修复1:仪器ID拆分前判空,避免空指针
|
|
|
|
|
String[] split = examineResult.getInstrumentId() != null && !examineResult.getInstrumentId().trim().isEmpty() |
|
|
|
|
? examineResult.getInstrumentId().split(",") |
|
|
|
|
: new String[0]; |
|
|
|
|
// 修复2:试剂ID拆分前判空,避免空指针
|
|
|
|
|
String[] split1 = examineResult.getReagentId() != null && !examineResult.getReagentId().trim().isEmpty() |
|
|
|
|
? examineResult.getReagentId().split(",") |
|
|
|
|
: new String[0]; |
|
|
|
|
|
|
|
|
|
List<InstrumentUseLog> list1 = new ArrayList<>(); |
|
|
|
|
List<ReagentUseLog> list2 = new ArrayList<>(); |
|
|
|
|
ExamineItem examineItem = examineItemService.getById(examine.getExamineItemId()); |
|
|
|
|
ExamineWay examineWay = examineWayService.getById(examine.getExamineWayId()); |
|
|
|
|
ExamineBasis examineBasis = examineBasisService.getById(examine.getExamineBasisId()); |
|
|
|
|
|
|
|
|
|
String s1 = ""; |
|
|
|
|
if (examineItem != null) { |
|
|
|
|
s1 = examineItem.getName(); |
|
|
|
|
@ -817,35 +825,84 @@ public class ExamineResultServiceImpl extends BaseServiceImpl<ExamineResultMappe |
|
|
|
|
s3 = examineBasis.getName(); |
|
|
|
|
} |
|
|
|
|
String workContent = s1 + s2 + s3; |
|
|
|
|
|
|
|
|
|
// 处理仪器使用记录
|
|
|
|
|
for (String s : split) { |
|
|
|
|
// 修复3:仪器ID为空则跳过,避免无效查询
|
|
|
|
|
if (s == null || s.trim().isEmpty()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Instrument instrument = instrumentService.getById(s); |
|
|
|
|
// 修复4:仪器查询结果为空则跳过,避免空指针
|
|
|
|
|
if (instrument == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
InstrumentUseLog instrumentUseLog = new InstrumentUseLog(); |
|
|
|
|
instrumentUseLog.setCode(instrument.getCode()); |
|
|
|
|
instrumentUseLog.setName(instrument.getName()); |
|
|
|
|
instrumentUseLog.setUsedLaboratory(sysClient.getDeptName(Long.valueOf(examine.getExamineBy())).getData()); |
|
|
|
|
instrumentUseLog.setUsedBy(userClient.userInfoById(Long.valueOf(examine.getExamineBy())).getData().getName()); |
|
|
|
|
|
|
|
|
|
// 修复5:Long转换前判空,避免NumberFormatException
|
|
|
|
|
Long examineBy = Long.valueOf(examine.getExamineBy()); |
|
|
|
|
if (examineBy != null) { |
|
|
|
|
instrumentUseLog.setUsedLaboratory(sysClient.getDeptName(examineBy).getData()); |
|
|
|
|
instrumentUseLog.setUsedBy(userClient.userInfoById(examineBy).getData().getName()); |
|
|
|
|
} else { |
|
|
|
|
instrumentUseLog.setUsedLaboratory(""); |
|
|
|
|
instrumentUseLog.setUsedBy(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
instrumentUseLog.setExperieNum(examine.getExperieNum()); |
|
|
|
|
instrumentUseLog.setUsedTime(examineResult.getInspectionTime()); |
|
|
|
|
instrumentUseLog.setWorkContent(workContent); |
|
|
|
|
list1.add(instrumentUseLog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 处理试剂使用记录
|
|
|
|
|
for (String s : split1) { |
|
|
|
|
// 修复6:试剂ID为空则跳过,避免无效查询
|
|
|
|
|
if (s == null || s.trim().isEmpty()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Reagent reagent = reagentService.getById(s); |
|
|
|
|
// 修复7:试剂查询结果为空则跳过,避免空指针
|
|
|
|
|
if (reagent == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
ReagentUseLog reagentUseLog = new ReagentUseLog(); |
|
|
|
|
reagentUseLog.setManufacturer(reagent.getManufacturer()); |
|
|
|
|
reagentUseLog.setBatchNo(reagent.getBatchNo()); |
|
|
|
|
reagentUseLog.setName(reagent.getName()); |
|
|
|
|
|
|
|
|
|
if (examineItem != null) { |
|
|
|
|
reagentUseLog.setForExamine(examineItem.getName()); |
|
|
|
|
} |
|
|
|
|
reagentUseLog.setType(Integer.parseInt(reagent.getType())); |
|
|
|
|
|
|
|
|
|
// 修复8:核心修复——试剂类型转换防null/非数字(不改变量名)
|
|
|
|
|
int type = 0; // 默认值,可根据业务调整
|
|
|
|
|
String reagentType = reagent.getType(); |
|
|
|
|
if (reagentType != null && !reagentType.trim().isEmpty()) { |
|
|
|
|
try { |
|
|
|
|
type = Integer.parseInt(reagentType.trim()); |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
// 转换失败用默认值,可选加日志
|
|
|
|
|
type = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
reagentUseLog.setType(type); |
|
|
|
|
|
|
|
|
|
reagentUseLog.setApplicant(examine.getExamineBy()); |
|
|
|
|
reagentUseLog.setApplicationDate(new Date()); |
|
|
|
|
list2.add(reagentUseLog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 修复9:空集合不保存,避免无效数据库操作
|
|
|
|
|
if (!list1.isEmpty()) { |
|
|
|
|
iInstrumentUseLogService.saveBatch(list1); |
|
|
|
|
} |
|
|
|
|
if (!list2.isEmpty()) { |
|
|
|
|
reagentUseLogService.saveBatch(list2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 判断当前用户有没有电子签名
|
|
|
|
|
private void electronicSignature() throws Exception { |
|
|
|
|
|