|
@@ -20,12 +20,15 @@ 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;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
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.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author wangfeng
|
|
* @author wangfeng
|
|
@@ -40,13 +43,33 @@ public class PlanDetailFacade extends PlanDetailServiceImpl {
|
|
|
|
|
|
public List<PlanDetailDTO> getSysSetInfoData(HospitalSetVO hospitalSetVO) {
|
|
public List<PlanDetailDTO> getSysSetInfoData(HospitalSetVO hospitalSetVO) {
|
|
QueryWrapper<PlanDetail> sysSetInfo = new QueryWrapper<>();
|
|
QueryWrapper<PlanDetail> sysSetInfo = new QueryWrapper<>();
|
|
- sysSetInfo.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
- sysSetInfo.eq("hospital_id", hospitalSetVO.getHospitalId());
|
|
|
|
- sysSetInfo.eq("plan_id", hospitalSetVO.getPlanId());
|
|
|
|
- sysSetInfo.eq(StringUtil.isNotBlank(hospitalSetVO.getCode()), "code", hospitalSetVO.getCode());
|
|
|
|
|
|
+ sysSetInfo.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", hospitalSetVO.getHospitalId())
|
|
|
|
+ .eq(StringUtil.isNotBlank(hospitalSetVO.getCode()), "code", hospitalSetVO.getCode())
|
|
|
|
+ .in("plan_id", hospitalSetVO.getPlanId())
|
|
|
|
+ .orderByAsc("plan_id", "order_no");
|
|
List<PlanDetail> sysSetData = list(sysSetInfo);
|
|
List<PlanDetail> sysSetData = list(sysSetInfo);
|
|
- List<PlanDetailDTO> data = BeanUtil.listCopyTo(sysSetData, PlanDetailDTO.class);
|
|
|
|
- return data;
|
|
|
|
|
|
+ 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>> 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 planDetailParent;
|
|
}
|
|
}
|
|
|
|
|
|
public List<PlanDetailDTO> getByPlanIds(List<Long> planIds) {
|
|
public List<PlanDetailDTO> getByPlanIds(List<Long> planIds) {
|
|
@@ -66,31 +89,44 @@ public class PlanDetailFacade extends PlanDetailServiceImpl {
|
|
}
|
|
}
|
|
|
|
|
|
public boolean savePlanDetail(PlanDetailSaveVO planDetailSaveVO) {
|
|
public boolean savePlanDetail(PlanDetailSaveVO planDetailSaveVO) {
|
|
|
|
+ boolean res = false;
|
|
Date now = DateUtil.now();
|
|
Date now = DateUtil.now();
|
|
- UpdateWrapper<PlanDetail> planDetailUpdate = new UpdateWrapper<>();
|
|
|
|
- planDetailUpdate.eq("plan_id", planDetailSaveVO.getPlanId())
|
|
|
|
|
|
+ QueryWrapper<PlanDetail> planDetailQuery = new QueryWrapper<>();
|
|
|
|
+ planDetailQuery.eq("plan_id", planDetailSaveVO.getPlanId())
|
|
.eq("hospital_id", planDetailSaveVO.getHospitalId())//医院id
|
|
.eq("hospital_id", planDetailSaveVO.getHospitalId())//医院id
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
- .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
|
- .set("gmt_modified",now)
|
|
|
|
- .set("gmt_create", now)
|
|
|
|
- .set("creator",UserUtils.getCurrentPrincipleID())
|
|
|
|
- .set("modifier",UserUtils.getCurrentPrincipleID());
|
|
|
|
- update(new PlanDetail(), planDetailUpdate);
|
|
|
|
- List<PlanDetail> planDetailList = new ArrayList<>();
|
|
|
|
- List<HospitalPlanDetailSaveVO> planDetailData = planDetailSaveVO.getPlanDetail();
|
|
|
|
- Long planId = planDetailSaveVO.getPlanId();
|
|
|
|
- for (HospitalPlanDetailSaveVO planDetailVO : planDetailData) {
|
|
|
|
- PlanDetail planDetail = new PlanDetail();
|
|
|
|
- BeanUtil.copyProperties(planDetailVO, planDetail);
|
|
|
|
- planDetail.setPlanId(planId);
|
|
|
|
- planDetail.setGmtCreate(now);
|
|
|
|
- planDetail.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
|
- planDetail.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
- planDetail.setGmtModified(now);
|
|
|
|
- planDetailList.add(planDetail);
|
|
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ // 删除所有的配置
|
|
|
|
+ res = remove(planDetailQuery);
|
|
|
|
+ //先保存父类
|
|
|
|
+ List<PlanDetail> planDetailParentNew = new ArrayList<>();
|
|
|
|
+ List<HospitalPlanDetailSaveVO> planDetailParent = planDetailSaveVO.getPlanDetailParent();
|
|
|
|
+ for (HospitalPlanDetailSaveVO planDetailSave : planDetailParent) {
|
|
|
|
+ PlanDetail planDetails = new PlanDetail();
|
|
|
|
+ BeanUtil.copyProperties(planDetailSave, planDetails);
|
|
|
|
+ planDetails.setParentId(-1L);
|
|
|
|
+ planDetails.setGmtCreate(now);
|
|
|
|
+ planDetails.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ planDetails.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ planDetails.setGmtModified(now);
|
|
|
|
+ List<PlanDetailSubSaveVO> data = planDetailSave.getPlanDetailSub();
|
|
|
|
+ planDetailService.save(planDetails);
|
|
|
|
+ List<PlanDetail> planDetailList = new ArrayList<>();
|
|
|
|
+ //再保存子类
|
|
|
|
+ for (PlanDetailSubSaveVO planDetailVO : data) {
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ res = planDetailService.saveBatch(planDetailList);
|
|
}
|
|
}
|
|
- return planDetailService.saveBatch(planDetailList);
|
|
|
|
|
|
+
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
|
|
public boolean cancelPlanDetail(PlanDetailCancelVO planDetailCancelVO) {
|
|
public boolean cancelPlanDetail(PlanDetailCancelVO planDetailCancelVO) {
|