|
|
|
@ -1,13 +1,17 @@
|
|
|
|
|
package com.supervision.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.supervision.constant.TreatmentPlanIdConstant;
|
|
|
|
|
import com.supervision.controller.TreatmentPlanController;
|
|
|
|
|
import com.supervision.model.ConfigDrug;
|
|
|
|
|
import com.supervision.model.ConfigTreatmentPlan;
|
|
|
|
|
import com.supervision.model.Process;
|
|
|
|
|
import com.supervision.model.TreatmentPlanRecord;
|
|
|
|
|
import com.supervision.pojo.vo.DealPlanResVO;
|
|
|
|
|
import com.supervision.service.*;
|
|
|
|
|
import com.supervision.vo.manage.TreatmentPlanTreeNode;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@ -15,8 +19,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.sql.Struct;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
@ -47,7 +51,7 @@ public class TreatmentPlanServiceImpl implements TreatmentPlanService {
|
|
|
|
|
return treatmentPlanRecordService.lambdaQuery().eq(TreatmentPlanRecord::getProcessId, processId)
|
|
|
|
|
.eq("0".equals(disposalPlanType), TreatmentPlanRecord::getDisposalPlan, "2")
|
|
|
|
|
.in("1".equals(disposalPlanType), TreatmentPlanRecord::getDisposalPlan,
|
|
|
|
|
CollUtil.newArrayList("1","3","4","5","6","7")).list();
|
|
|
|
|
CollUtil.newArrayList("80fbb83669f39773")).list();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -94,10 +98,62 @@ public class TreatmentPlanServiceImpl implements TreatmentPlanService {
|
|
|
|
|
return configTreatmentPlanService.queryTree(disposalMethod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public DealPlanResVO queryTreatmentPlanDetails(String processId) {
|
|
|
|
|
// 1. 查询处置计划记录
|
|
|
|
|
List<TreatmentPlanRecord> treatmentPlanRecordList = treatmentPlanRecordService.lambdaQuery().eq(TreatmentPlanRecord::getProcessId, processId).list();
|
|
|
|
|
DealPlanResVO dealPlanResVO = new DealPlanResVO();
|
|
|
|
|
if (CollUtil.isEmpty(treatmentPlanRecordList)){
|
|
|
|
|
dealPlanResVO.setOtherTreatmentPlan(CollectionUtil.newArrayList());
|
|
|
|
|
dealPlanResVO.setDrugTreatmentPlan(CollectionUtil.newArrayList());
|
|
|
|
|
return dealPlanResVO;
|
|
|
|
|
}
|
|
|
|
|
dealPlanResVO.setUserTreatmentPlanType(CollUtil.getFirst(treatmentPlanRecordList).getDisposalMethod());
|
|
|
|
|
|
|
|
|
|
// 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> drugIds = treatmentPlanRecordList.stream().map(TreatmentPlanRecord::getDrugId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
|
|
List<ConfigDrug> configDrugs =new ArrayList<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(drugIds)){
|
|
|
|
|
configDrugs = configDrugService.listByIds(drugIds);
|
|
|
|
|
}
|
|
|
|
|
Map<String, ConfigDrug> configDrugMap = configDrugs.stream().collect(Collectors.toMap(ConfigDrug::getId, v -> v));
|
|
|
|
|
|
|
|
|
|
Map<String, List<TreatmentPlanRecord>> treatmentPlanIdMap = treatmentPlanRecordList.stream().map(item->BeanUtil.toBean(item,DealPlanResVO.TreatmentPlanResult.class))
|
|
|
|
|
.peek(item->{
|
|
|
|
|
if (StrUtil.isEmpty(item.getTreatmentPlanId())){
|
|
|
|
|
item.setDisposalPlanName("药物");
|
|
|
|
|
ConfigDrug configDrug = configDrugMap.get(item.getDrugId());
|
|
|
|
|
if (Objects.nonNull(configDrug)){
|
|
|
|
|
item.setDrugName(configDrug.getDrugName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
ConfigTreatmentPlan configTreatmentPlan = configTreatmentPlanMap.get(item.getTreatmentPlanId());
|
|
|
|
|
if (Objects.nonNull(configTreatmentPlan)){
|
|
|
|
|
item.setDisposalPlanName(configTreatmentPlan.getDisposalPlan());
|
|
|
|
|
item.setFirstMeasures(configTreatmentPlan.getFirstMeasures());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.groupingBy(v ->
|
|
|
|
|
Objects.isNull(v.getTreatmentPlanId()) ? "DRUG" :"OTHER"));
|
|
|
|
|
|
|
|
|
|
dealPlanResVO.setDrugTreatmentPlan(treatmentPlanIdMap.getOrDefault("DRUG", CollUtil.newArrayList()));
|
|
|
|
|
dealPlanResVO.setOtherTreatmentPlan(treatmentPlanIdMap.getOrDefault("OTHER", CollUtil.newArrayList()));
|
|
|
|
|
return dealPlanResVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assertSaveTreatmentPlanRecord(TreatmentPlanRecord record){
|
|
|
|
|
Assert.notEmpty(record.getProcessId(),"流程id不能为空");
|
|
|
|
|
Assert.notNull(record.getDisposalMethod(),"处置方式不能为为空");
|
|
|
|
|
Assert.notNull(record.getDisposalPlan(),"处置计划不能为空");
|
|
|
|
|
//Assert.notNull(record.getDisposalPlan(),"处置计划不能为空");
|
|
|
|
|
if (StrUtil.isEmpty(record.getTreatmentPlanId())){
|
|
|
|
|
Assert.notEmpty(record.getDrugId(),"药物id不能为空");
|
|
|
|
|
}
|
|
|
|
|