|
|
|
@ -1,20 +1,71 @@
|
|
|
|
|
package com.supervision.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.model.ConfigDrug;
|
|
|
|
|
import com.supervision.model.ConfigTreatmentPlan;
|
|
|
|
|
import com.supervision.model.TreatmentPlanRecord;
|
|
|
|
|
import com.supervision.service.ConfigDrugService;
|
|
|
|
|
import com.supervision.service.ConfigTreatmentPlanService;
|
|
|
|
|
import com.supervision.service.TreatmentPlanRecordService;
|
|
|
|
|
import com.supervision.mapper.TreatmentPlanRecordMapper;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Administrator
|
|
|
|
|
* @description 针对表【vp_treatment_plan_record(处置计划记录表)】的数据库操作Service实现
|
|
|
|
|
* @createDate 2023-12-06 16:43:24
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class TreatmentPlanRecordServiceImpl extends ServiceImpl<TreatmentPlanRecordMapper, TreatmentPlanRecord>
|
|
|
|
|
implements TreatmentPlanRecordService{
|
|
|
|
|
|
|
|
|
|
private final ConfigTreatmentPlanService configTreatmentPlanService;
|
|
|
|
|
|
|
|
|
|
private final ConfigDrugService configDrugService;
|
|
|
|
|
@Override
|
|
|
|
|
public List<TreatmentPlanRecord> queryByProcessId(String processId) {
|
|
|
|
|
|
|
|
|
|
// 1. 查询处置计划记录
|
|
|
|
|
List<TreatmentPlanRecord> treatmentPlanRecordList = super.lambdaQuery().eq(TreatmentPlanRecord::getProcessId, processId).list();
|
|
|
|
|
if (CollUtil.isEmpty(treatmentPlanRecordList)){
|
|
|
|
|
return treatmentPlanRecordList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 填充处置计划属性名字段(处置计划名、一级措施)
|
|
|
|
|
List<String> treatmentPlanIds = treatmentPlanRecordList.stream().map(TreatmentPlanRecord::getTreatmentPlanId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
|
|
List<ConfigTreatmentPlan> configTreatmentPlans = new ArrayList<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(treatmentPlanIds)){
|
|
|
|
|
configTreatmentPlans = configTreatmentPlanService.listByIds(treatmentPlanIds);
|
|
|
|
|
}
|
|
|
|
|
Map<String, ConfigTreatmentPlan> configTreatmentPlanMap = configTreatmentPlans.stream().collect(Collectors.toMap(ConfigTreatmentPlan::getId, v -> v));
|
|
|
|
|
// 3.填充药物名
|
|
|
|
|
List<String> recordDrugIds = treatmentPlanRecordList.stream().map(TreatmentPlanRecord::getDrugId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
|
|
List<ConfigDrug> configDrugs =new ArrayList<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(recordDrugIds)){
|
|
|
|
|
configDrugs = configDrugService.listByIds(recordDrugIds);
|
|
|
|
|
}
|
|
|
|
|
Map<String, ConfigDrug> configDrugMap = configDrugs.stream().collect(Collectors.toMap(ConfigDrug::getId, v -> v));
|
|
|
|
|
|
|
|
|
|
for (TreatmentPlanRecord treatmentPlan : treatmentPlanRecordList) {
|
|
|
|
|
ConfigTreatmentPlan configTreatmentPlan = configTreatmentPlanMap.get(treatmentPlan.getTreatmentPlanId());
|
|
|
|
|
if (null != configTreatmentPlan){
|
|
|
|
|
treatmentPlan.setDisposalPlan(configTreatmentPlan.getDisposalPlan());
|
|
|
|
|
treatmentPlan.setFirstMeasures(configTreatmentPlan.getFirstMeasures());
|
|
|
|
|
}
|
|
|
|
|
ConfigDrug configDrug = configDrugMap.get(treatmentPlan.getDrugId());
|
|
|
|
|
if (null != configDrug){
|
|
|
|
|
treatmentPlan.setDisposalPlan("药物");
|
|
|
|
|
treatmentPlan.setDrugName(configDrug.getDrugName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return treatmentPlanRecordList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|