|
|
|
@ -3,6 +3,7 @@ package digital.laboratory.platform.entrustment.service.impl; |
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import digital.laboratory.platform.common.core.constant.CommonConstants; |
|
|
|
|
import digital.laboratory.platform.common.core.exception.CheckedException; |
|
|
|
|
import digital.laboratory.platform.common.core.util.R; |
|
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
@ -136,6 +137,26 @@ public class ExcelOperationServiceImpl implements ExcelOperationService { |
|
|
|
|
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// 4. 遍历Excel数据行,构建检材与检测结果
|
|
|
|
|
processExcelDataToMaterialEntity(data, entrustment, drugLiteMap, orderNo, cj, entrustmentIdentificationMaterialList); |
|
|
|
|
// entrustMaterialCheckoutResultService.saveBatch(results);
|
|
|
|
|
boolean isSave = entrustmentIdentificationMaterialService.saveBatch(entrustmentIdentificationMaterialList); |
|
|
|
|
String entrustReq = entrustmentService.buildEntrustReq(entrustmentIdentificationMaterialList); |
|
|
|
|
entrustment.setEntrustRequirement(entrustReq); |
|
|
|
|
entrustmentService.updateById(entrustment); |
|
|
|
|
// 5. 批量保存检材信息和检测结果
|
|
|
|
|
return isSave; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理Excel数据,构建检材对象并设置相关属性 |
|
|
|
|
* @param data Excel数据列表 |
|
|
|
|
* @param entrustment 委托信息对象 |
|
|
|
|
* @param drugLiteMap 毒品名称映射表 |
|
|
|
|
* @param orderNo 检材序号起始值 |
|
|
|
|
* @param cj 案件信息对象 |
|
|
|
|
* @param entrustmentIdentificationMaterialList 检材列表对象集合 |
|
|
|
|
*/ |
|
|
|
|
private void processExcelDataToMaterialEntity(List<Map<String, String>> data, Entrustment entrustment, Map<String, DrugLite> drugLiteMap, int orderNo, CaseEvent cj, List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList) { |
|
|
|
|
for (Map<String, String> datum : data) { |
|
|
|
|
// 构建检材对象
|
|
|
|
|
EntrustmentIdentificationMaterial material = new EntrustmentIdentificationMaterial(); |
|
|
|
@ -160,16 +181,23 @@ public class ExcelOperationServiceImpl implements ExcelOperationService { |
|
|
|
|
if (drugs.length == 0 || (drugs.length == 1 && drugs[0].trim().isEmpty())) { |
|
|
|
|
matchedDrugs.add(drugLiteMap.get("海洛因")); |
|
|
|
|
} else { |
|
|
|
|
boolean matched = false; |
|
|
|
|
for (String drugName : drugs) { |
|
|
|
|
if (drugLiteMap.containsKey(drugName)) { |
|
|
|
|
matchedDrugs.add(drugLiteMap.get(drugName)); |
|
|
|
|
matched = true; |
|
|
|
|
} else { |
|
|
|
|
// 未匹配到任何已知毒品,则调用接口保存
|
|
|
|
|
DrugLite newDrug = new DrugLite(); |
|
|
|
|
newDrug.setId(IdWorker.get32UUID().toUpperCase()); |
|
|
|
|
newDrug.setName(drugName); |
|
|
|
|
R<Boolean> booleanR = remoteCommDrugService.innerSaveDrug(newDrug); |
|
|
|
|
if (booleanR.getCode() == CommonConstants.FAIL) { |
|
|
|
|
throw new CheckedException("新增未知毒品失败!"); |
|
|
|
|
} |
|
|
|
|
// 更新缓存 Map,避免重复插入
|
|
|
|
|
drugLiteMap.put(drugName, newDrug); |
|
|
|
|
matchedDrugs.add(newDrug); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!matched) { |
|
|
|
|
matchedDrugs.add(drugLiteMap.get("海洛因")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
material.setCandidateDrugs(matchedDrugs); |
|
|
|
|
|
|
|
|
@ -194,13 +222,6 @@ public class ExcelOperationServiceImpl implements ExcelOperationService { |
|
|
|
|
|
|
|
|
|
entrustmentIdentificationMaterialList.add(material); |
|
|
|
|
} |
|
|
|
|
// entrustMaterialCheckoutResultService.saveBatch(results);
|
|
|
|
|
boolean isSave = entrustmentIdentificationMaterialService.saveBatch(entrustmentIdentificationMaterialList); |
|
|
|
|
String entrustReq = entrustmentService.buildEntrustReq(entrustmentIdentificationMaterialList); |
|
|
|
|
entrustment.setEntrustRequirement(entrustReq); |
|
|
|
|
entrustmentService.updateById(entrustment); |
|
|
|
|
// 5. 批量保存检材信息和检测结果
|
|
|
|
|
return isSave; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|