|
@@ -12,6 +12,7 @@ import com.diagbot.service.PlanDetailService;
|
|
import com.diagbot.service.impl.PlanDetailServiceImpl;
|
|
import com.diagbot.service.impl.PlanDetailServiceImpl;
|
|
import com.diagbot.util.BeanUtil;
|
|
import com.diagbot.util.BeanUtil;
|
|
import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.DateUtil;
|
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.StringUtil;
|
|
import com.diagbot.util.StringUtil;
|
|
import com.diagbot.util.UserUtils;
|
|
import com.diagbot.util.UserUtils;
|
|
@@ -20,7 +21,6 @@ import com.diagbot.vo.HospitalSetVO;
|
|
import com.diagbot.vo.PlanDetailCancelVO;
|
|
import com.diagbot.vo.PlanDetailCancelVO;
|
|
import com.diagbot.vo.PlanDetailRevStopVO;
|
|
import com.diagbot.vo.PlanDetailRevStopVO;
|
|
import com.diagbot.vo.PlanDetailSaveVO;
|
|
import com.diagbot.vo.PlanDetailSaveVO;
|
|
-import com.diagbot.vo.PlanDetailSubSaveVO;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -28,7 +28,6 @@ import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author wangfeng
|
|
* @author wangfeng
|
|
@@ -47,29 +46,38 @@ public class PlanDetailFacade extends PlanDetailServiceImpl {
|
|
.eq("hospital_id", hospitalSetVO.getHospitalId())
|
|
.eq("hospital_id", hospitalSetVO.getHospitalId())
|
|
.eq(StringUtil.isNotBlank(hospitalSetVO.getCode()), "code", hospitalSetVO.getCode())
|
|
.eq(StringUtil.isNotBlank(hospitalSetVO.getCode()), "code", hospitalSetVO.getCode())
|
|
.in("plan_id", hospitalSetVO.getPlanId())
|
|
.in("plan_id", hospitalSetVO.getPlanId())
|
|
- .orderByAsc("plan_id", "order_no","id");
|
|
|
|
|
|
+ .orderByAsc("plan_id", "order_no", "id");
|
|
List<PlanDetail> sysSetData = list(sysSetInfo);
|
|
List<PlanDetail> sysSetData = list(sysSetInfo);
|
|
List<PlanDetailDTO> sysSetInfoData = BeanUtil.listCopyTo(sysSetData, PlanDetailDTO.class);
|
|
List<PlanDetailDTO> sysSetInfoData = BeanUtil.listCopyTo(sysSetData, PlanDetailDTO.class);
|
|
- List<PlanDetailDTO> planDetailParent = new ArrayList<>();//父级数据
|
|
|
|
- List<PlanDetailDTO> planDetailSub = new ArrayList<>();//子级数据
|
|
|
|
- //分离数据,-1分父级菜单
|
|
|
|
- for (PlanDetailDTO dataDeta : sysSetInfoData) {
|
|
|
|
- if (dataDeta.getParentId() == (-1)) {
|
|
|
|
- planDetailParent.add(dataDeta);
|
|
|
|
- } else {
|
|
|
|
- planDetailSub.add(dataDeta);
|
|
|
|
|
|
+ //添加菜单信息
|
|
|
|
+ Map<Long, List<PlanDetailDTO>> menuMap = EntityUtil.makeEntityListMap(sysSetInfoData, "parentId");
|
|
|
|
+ List<PlanDetailDTO> menuRes = menuMap.get(-1L);
|
|
|
|
+ if (ListUtil.isNotEmpty(menuRes)) {
|
|
|
|
+ for (PlanDetailDTO bean : menuRes) {
|
|
|
|
+ getSonMenu(bean, menuMap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //把子级数据,放在父级下
|
|
|
|
- Map<Long, List<PlanDetailDTO>> mapParentId = planDetailSub.stream().collect(Collectors.groupingBy(PlanDetailDTO::getParentId));
|
|
|
|
- for (Long key : mapParentId.keySet()) {
|
|
|
|
- for (PlanDetailDTO sysPlanInfos : planDetailParent) {
|
|
|
|
- if (sysPlanInfos.getId().equals(key)) {
|
|
|
|
- sysPlanInfos.setPlanDetails(mapParentId.get(key));
|
|
|
|
- }
|
|
|
|
|
|
+ return menuRes;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 递归获取菜单结构
|
|
|
|
+ *
|
|
|
|
+ * @param menu 当前菜单
|
|
|
|
+ * @param menuMap 菜单集
|
|
|
|
+ * @return 菜单结构
|
|
|
|
+ */
|
|
|
|
+ public List<PlanDetailDTO> getSonMenu(PlanDetailDTO menu,
|
|
|
|
+ Map<Long, List<PlanDetailDTO>> menuMap) {
|
|
|
|
+ List<PlanDetailDTO> res = new ArrayList<>();
|
|
|
|
+ List<PlanDetailDTO> list = menuMap.get(menu.getId());
|
|
|
|
+ if (ListUtil.isNotEmpty(list)) {
|
|
|
|
+ menu.setPlanDetails(list);
|
|
|
|
+ for (PlanDetailDTO bean : list) {
|
|
|
|
+ getSonMenu(bean, menuMap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return planDetailParent;
|
|
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
|
|
public List<PlanDetailDTO> getByPlanIds(List<Long> planIds) {
|
|
public List<PlanDetailDTO> getByPlanIds(List<Long> planIds) {
|
|
@@ -109,24 +117,43 @@ public class PlanDetailFacade extends PlanDetailServiceImpl {
|
|
planDetails.setModifier(UserUtils.getCurrentPrincipleID());
|
|
planDetails.setModifier(UserUtils.getCurrentPrincipleID());
|
|
planDetails.setGmtModified(now);
|
|
planDetails.setGmtModified(now);
|
|
planDetailService.save(planDetails);
|
|
planDetailService.save(planDetails);
|
|
- List<PlanDetailSubSaveVO> data = planDetailSave.getPlanDetailSub();
|
|
|
|
- if(ListUtil.isNotEmpty(data)){
|
|
|
|
- List<PlanDetail> planDetailList = new ArrayList<>();
|
|
|
|
- //再保存子类
|
|
|
|
- for (PlanDetailSubSaveVO planDetailVO : data) {
|
|
|
|
- if(planDetailVO.getCode()!=null){
|
|
|
|
- PlanDetail planDetail = new PlanDetail();
|
|
|
|
- BeanUtil.copyProperties(planDetailVO, planDetail);
|
|
|
|
- planDetail.setPlanId(planDetailSaveVO.getPlanId());
|
|
|
|
- planDetail.setParentId(planDetails.getId());
|
|
|
|
- planDetail.setGmtCreate(now);
|
|
|
|
- planDetail.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
|
- planDetail.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
- planDetail.setGmtModified(now);
|
|
|
|
- planDetailList.add(planDetail);
|
|
|
|
|
|
+ List<HospitalPlanDetailSaveVO> data = planDetailSave.getPlanDetailSub();
|
|
|
|
+ if (ListUtil.isNotEmpty(data)) {
|
|
|
|
+ // List<PlanDetail> planDetailList = new ArrayList<>();
|
|
|
|
+ //再保存子类第二层
|
|
|
|
+ for (HospitalPlanDetailSaveVO planDetailVO : data) {
|
|
|
|
+ if (planDetailVO.getCode() != null) {
|
|
|
|
+ PlanDetail planDetail2 = new PlanDetail();
|
|
|
|
+ BeanUtil.copyProperties(planDetailVO, planDetail2);
|
|
|
|
+ planDetail2.setPlanId(planDetailSaveVO.getPlanId());
|
|
|
|
+ planDetail2.setParentId(planDetails.getId());
|
|
|
|
+ planDetail2.setGmtCreate(now);
|
|
|
|
+ planDetail2.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ planDetail2.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ planDetail2.setGmtModified(now);
|
|
|
|
+ planDetailService.save(planDetail2);
|
|
|
|
+ List<HospitalPlanDetailSaveVO> data3 = planDetailVO.getPlanDetailSub();
|
|
|
|
+ if (ListUtil.isNotEmpty(data3)) {
|
|
|
|
+ List<PlanDetail> planDetailList = new ArrayList<>();
|
|
|
|
+ //最后保存子类第三层
|
|
|
|
+ for (HospitalPlanDetailSaveVO planDetail : data3) {
|
|
|
|
+ if (planDetail.getCode() != null) {
|
|
|
|
+ PlanDetail planDetailVO3 = new PlanDetail();
|
|
|
|
+ BeanUtil.copyProperties(planDetail, planDetailVO3);
|
|
|
|
+ planDetailVO3.setPlanId(planDetailSaveVO.getPlanId());
|
|
|
|
+ planDetailVO3.setParentId(planDetail2.getId());
|
|
|
|
+ planDetailVO3.setGmtCreate(now);
|
|
|
|
+ planDetailVO3.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ planDetailVO3.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ planDetailVO3.setGmtModified(now);
|
|
|
|
+ planDetailList.add(planDetailVO3);
|
|
|
|
+ }
|
|
|
|
+ res = planDetailService.saveBatch(planDetailList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- res = planDetailService.saveBatch(planDetailList);
|
|
|
|
|
|
+ // res = planDetailService.saveBatch(planDetailList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|