|
@@ -1,6 +1,7 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.diagbot.dto.PlanDetailDTO;
|
|
|
import com.diagbot.dto.PlanInfoDefaultDTO;
|
|
|
import com.diagbot.entity.Plan;
|
|
@@ -20,6 +21,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author wangfeng
|
|
@@ -36,11 +38,32 @@ public class PlanDefaultFacade {
|
|
|
public Boolean addDefaultPlans(PlanDefaultVO planDefaultVO) {
|
|
|
boolean res = false;
|
|
|
Date now = DateUtil.now();
|
|
|
- List<String> planCode = Arrays.asList("plan_default","patientia","info","chief","symptom","other","vital","lis","pacs","diag","doc_advice");
|
|
|
- if(ListUtil.isEmpty(planCode)){
|
|
|
+ List<String> planCode = Arrays.asList("plan_default", "patientia", "info", "chief", "symptom", "other", "vital", "lis", "pacs", "diag", "doc_advice");
|
|
|
+/* if(ListUtil.isEmpty(planCode)){
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "方案编码不能为空!");
|
|
|
+ }*/
|
|
|
+ //先删除医院默认的方案,
|
|
|
+ if (planDefaultVO.getHospitalId() == -1) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "朗通医院不能一键添加!");
|
|
|
}
|
|
|
- for (String str:planCode) {
|
|
|
+ QueryWrapper<Plan> planFandList = new QueryWrapper<>();
|
|
|
+ planFandList.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in("plan_code", planCode)
|
|
|
+ .eq("hospital_id", planDefaultVO.getHospitalId());
|
|
|
+ List<Plan> planList = planFacade.list(planFandList);
|
|
|
+ if (ListUtil.isNotEmpty(planList)) {
|
|
|
+ List<Long> planIdcancel = planList.stream().map(ac -> ac.getId()).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<PlanDetail> planDetailcancel = new UpdateWrapper<>();
|
|
|
+ planDetailcancel.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", planDefaultVO.getHospitalId())
|
|
|
+ .in("plan_id", planIdcancel);
|
|
|
+
|
|
|
+ planDetailFacade.remove(planDetailcancel);
|
|
|
+ planFacade.remove(planFandList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询默认方案
|
|
|
+ for (String str : planCode) {
|
|
|
PlanInfoDefaultDTO data = new PlanInfoDefaultDTO();
|
|
|
QueryWrapper<Plan> planFand = new QueryWrapper<>();
|
|
|
planFand.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
@@ -61,7 +84,7 @@ public class PlanDefaultFacade {
|
|
|
.eq("hospital_id", planDefaultVO.getHospitalId())
|
|
|
.eq("plan_code", str));
|
|
|
if (countTow > 0) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, str+"该方案编码已存在");
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, str + "该方案编码已存在");
|
|
|
}
|
|
|
//保存方案配置
|
|
|
if (plan != null) {
|