model:重构TreatmentPlanRecordService.queryByProcessId接口

dev_2.0.0
xueqingkun 1 year ago
parent ef03a59de4
commit 6821cd03cb

@ -43,6 +43,7 @@ public class TreatmentPlanRecord implements Serializable {
/**
*
*/
@TableField(exist = false)
private String firstMeasures;
/**
@ -53,6 +54,7 @@ public class TreatmentPlanRecord implements Serializable {
/**
*
*/
@TableField(exist = false)
private String drugName;
/**

@ -3,6 +3,8 @@ package com.supervision.service;
import com.supervision.model.TreatmentPlanRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author Administrator
* @description vp_treatment_plan_record()Service
@ -10,4 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface TreatmentPlanRecordService extends IService<TreatmentPlanRecord> {
List<TreatmentPlanRecord> queryByProcessId(String processId);
}

@ -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;
}
}

@ -4,8 +4,7 @@ package com.supervision.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.supervision.constant.TreatmentPlanIdConstant;
import com.supervision.exception.BusinessException;
import cn.hutool.core.util.StrUtil;
import com.supervision.model.*;
import com.supervision.model.Process;
import com.supervision.pojo.vo.*;
@ -15,9 +14,7 @@ import com.supervision.vo.result.AncillaryRecordByResultDAO;
import com.supervision.vo.result.PhysicalRecordByResultDAO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
@ -81,7 +78,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService
DealPlanResVO dealPlanResVO = new DealPlanResVO();
// 1. 查询处置计划记录
List<TreatmentPlanRecord> treatmentPlanRecordList = treatmentPlanRecordService.lambdaQuery().eq(TreatmentPlanRecord::getProcessId, processId).list();
List<TreatmentPlanRecord> treatmentPlanRecordList = treatmentPlanRecordService.queryByProcessId(processId);
if (CollectionUtil.isEmpty(treatmentPlanRecordList)) {
return dealPlanResVO;
}
@ -99,10 +96,9 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService
ArrayList<DealPlanResVO.TreatmentPlanResult> otherTreatmentPlanResults = new ArrayList<>();
for (TreatmentPlanRecord treatmentPlanRecord : treatmentPlanRecordList) {
DealPlanResVO.TreatmentPlanResult bean = BeanUtil.toBean(treatmentPlanRecord, DealPlanResVO.TreatmentPlanResult.class);
//药物id 8055ef3412a69f95
boolean flag = bean.getDisposalPlan().equals(TreatmentPlanIdConstant.DRUG_ID) ? drugIds.contains(bean.getDrugId()) : planIds.contains(bean.getTreatmentPlanId());
boolean flag = StrUtil.isNotEmpty(bean.getDrugId()) ? drugIds.contains(bean.getDrugId()) : planIds.contains(bean.getTreatmentPlanId());
bean.setFlag(flag ? 1 : 0);
if (bean.getDisposalPlan().equals(TreatmentPlanIdConstant.DRUG_ID)) {
if (StrUtil.isNotEmpty(bean.getDrugId())) {
drugTreatmentPlanResults.add(bean);
} else {
otherTreatmentPlanResults.add(bean);

Loading…
Cancel
Save