|
@@ -0,0 +1,138 @@
|
|
|
+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.entity.PlanDetail;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.StatusEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.PlanDetailService;
|
|
|
+import com.diagbot.service.impl.PlanDetailServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.HospitalPlanDetailSaveVO;
|
|
|
+import com.diagbot.vo.HospitalSetVO;
|
|
|
+import com.diagbot.vo.PlanDetailCancelVO;
|
|
|
+import com.diagbot.vo.PlanDetailRevStopVO;
|
|
|
+import com.diagbot.vo.PlanDetailSaveVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wangfeng
|
|
|
+ * @Description:
|
|
|
+ * @date 2020-08-07 10:38
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class PlanDetailFacade extends PlanDetailServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ PlanDetailService planDetailService;
|
|
|
+
|
|
|
+
|
|
|
+ public List<PlanDetailDTO> getSysSetInfoData(HospitalSetVO hospitalSetVO) {
|
|
|
+ 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());
|
|
|
+ List<PlanDetail> sysSetData = list(sysSetInfo);
|
|
|
+ List<PlanDetailDTO> data = BeanUtil.listCopyTo(sysSetData, PlanDetailDTO.class);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<PlanDetailDTO> getByPlanIds(List<Long> planIds) {
|
|
|
+ List<PlanDetailDTO> dataNew = new ArrayList<PlanDetailDTO>();
|
|
|
+ if (ListUtil.isNotEmpty(planIds)) {
|
|
|
+ QueryWrapper<PlanDetail> planDetailQuery = new QueryWrapper<>();
|
|
|
+ planDetailQuery
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("STATUS", StatusEnum.Enable.getKey())
|
|
|
+ .in("plan_id", planIds)
|
|
|
+ .orderByDesc("gmt_create")
|
|
|
+ .orderByAsc("order_no");
|
|
|
+ List<PlanDetail> datas = list(planDetailQuery);
|
|
|
+ dataNew = BeanUtil.listCopyTo(datas, PlanDetailDTO.class);
|
|
|
+ }
|
|
|
+ return dataNew;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean savePlanDetail(PlanDetailSaveVO planDetailSaveVO) {
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ UpdateWrapper<PlanDetail> planDetailUpdate = new UpdateWrapper<>();
|
|
|
+ planDetailUpdate.eq("plan_id", planDetailSaveVO.getPlanId())
|
|
|
+ .eq("hospital_id", planDetailSaveVO.getHospitalId())//医院id
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .set("modifier", UserUtils.getCurrentPrincipleID())
|
|
|
+ .set("gmt_modified", DateUtil.now());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return planDetailService.saveBatch(planDetailList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean cancelPlanDetail(PlanDetailCancelVO planDetailCancelVO) {
|
|
|
+ boolean res = false;
|
|
|
+ // 1.先判断数据是否存在有效
|
|
|
+ UpdateWrapper<PlanDetail> planDetailNew = new UpdateWrapper<>();
|
|
|
+ planDetailNew
|
|
|
+ .eq("hospital_id", planDetailCancelVO.getHospitalId())
|
|
|
+ .eq("plan_id", planDetailCancelVO.getPlanId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .set("modifier", UserUtils.getCurrentPrincipleID())
|
|
|
+ .set("gmt_modified", DateUtil.now());
|
|
|
+ res = update(new PlanDetail(), planDetailNew);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean revStopPlanDetail(PlanDetailRevStopVO planDetailRevStopVO) {
|
|
|
+ checkPlan(planDetailRevStopVO.getId());
|
|
|
+ UpdateWrapper<PlanDetail> planNew = new UpdateWrapper<>();
|
|
|
+ planNew
|
|
|
+ .eq("id", planDetailRevStopVO.getId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .set("status", planDetailRevStopVO.getStatus())
|
|
|
+ .set("modifier", UserUtils.getCurrentPrincipleID())
|
|
|
+ .set("gmt_modified", DateUtil.now());
|
|
|
+ return update(new PlanDetail(), planNew);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断数据是否存在有效
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ private PlanDetail checkPlan(Long id) {
|
|
|
+ // 1.先判断数据是否存在有效
|
|
|
+ QueryWrapper<PlanDetail> PlanFand = new QueryWrapper<>();
|
|
|
+ PlanFand.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("id", id);
|
|
|
+ PlanDetail planDetail = getOne(PlanFand, false);
|
|
|
+ if (null == planDetail) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该数据不存在");
|
|
|
+ }
|
|
|
+ return planDetail;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|