|
@@ -2,6 +2,13 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.DeptShortDTO;
|
|
|
+import com.diagbot.dto.DeptVitalDTO;
|
|
|
+import com.diagbot.dto.QuestionShortDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.DeptInfo;
|
|
|
import com.diagbot.entity.DeptVital;
|
|
|
import com.diagbot.entity.QuestionInfo;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
@@ -10,9 +17,11 @@ import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.DeptVitalService;
|
|
|
import com.diagbot.service.impl.DeptVitalServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.DeptVitalPageVO;
|
|
|
import com.diagbot.vo.DeptVitalVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -35,8 +44,12 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
@Autowired
|
|
|
private QuestionInfoFacade questionInfoFacade;
|
|
|
@Autowired
|
|
|
+ private DeptInfoFacade deptInfoFacade;
|
|
|
+ @Autowired
|
|
|
@Qualifier("deptVitalServiceImpl")
|
|
|
private DeptVitalService deptVitalService;
|
|
|
+ @Autowired
|
|
|
+ private UserServiceClient userServiceClient;
|
|
|
|
|
|
/**
|
|
|
* 保存查体模板
|
|
@@ -128,7 +141,17 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
* @param deptId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<QuestionInfo> getVitalsByDeptId(Long deptId) {
|
|
|
+ public DeptVitalDTO getModuleByDeptId(Long deptId) {
|
|
|
+ DeptVitalDTO deptVitalDTO = new DeptVitalDTO();
|
|
|
+ DeptInfo deptInfo = deptInfoFacade.getById(deptId);
|
|
|
+ if (deptInfo == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
|
|
|
+ } else if (deptInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "科室已删除");
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(deptInfo, deptVitalDTO);
|
|
|
+
|
|
|
+ //已关联查体
|
|
|
QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
deptVitalQueryWrapper.eq("dept_id", deptId).
|
|
|
eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
@@ -137,6 +160,132 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
.map(deptVitals -> deptVitals.getVitalId())
|
|
|
.collect(Collectors.toList());
|
|
|
List<QuestionInfo> vitalList = Lists.newArrayList(questionInfoFacade.listByIds(vitalIds));
|
|
|
- return vitalList;
|
|
|
+ List<QuestionShortDTO> vitals = Lists.newArrayList();
|
|
|
+ for (QuestionInfo questionInfo : vitalList) {
|
|
|
+ QuestionShortDTO questionShortDTO = new QuestionShortDTO();
|
|
|
+ BeanUtil.copyProperties(questionInfo, questionShortDTO);
|
|
|
+ vitals.add(questionShortDTO);
|
|
|
+ }
|
|
|
+ deptVitalDTO.setVitals(vitals);
|
|
|
+
|
|
|
+ //未关联查体
|
|
|
+ QueryWrapper<QuestionInfo> unSelectedVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ unSelectedVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("sub_type", 0).
|
|
|
+ notIn("id", vitalIds).
|
|
|
+ eq("type", QuestionTypeEnum.Vital.getKey());
|
|
|
+ List<QuestionInfo> unSelectedVitalList = questionInfoFacade.list(unSelectedVitalQueryWrapper);
|
|
|
+ List<QuestionShortDTO> unSelectedVitals = Lists.newArrayList();
|
|
|
+ for (QuestionInfo questionInfo : unSelectedVitalList) {
|
|
|
+ QuestionShortDTO questionShortDTO = new QuestionShortDTO();
|
|
|
+ BeanUtil.copyProperties(questionInfo, questionShortDTO);
|
|
|
+ unSelectedVitals.add(questionShortDTO);
|
|
|
+ }
|
|
|
+ deptVitalDTO.setUnSelectedVitals(unSelectedVitals);
|
|
|
+ return deptVitalDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取科室模板分页信息
|
|
|
+ *
|
|
|
+ * @param deptVitalPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<DeptVitalDTO> getDeptVitalPage(DeptVitalPageVO deptVitalPageVO) {
|
|
|
+ QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ deptVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ select("dept_id", "gmt_create", "creator", "gmt_modified", "modifier").
|
|
|
+ groupBy("dept_id", "gmt_create", "creator", "gmt_modified", "modifier");
|
|
|
+ List<DeptVital> deptVitalList = this.list(deptVitalQueryWrapper);
|
|
|
+ Map<Long, DeptVital> deptVitalMap = EntityUtil.makeEntityMap(deptVitalList, "deptId");
|
|
|
+ List<Long> deptIds = deptVitalList.stream().map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ QueryWrapper<DeptInfo> deptInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ deptInfoQueryWrapper.like("name", deptVitalPageVO.getDeptName()).
|
|
|
+ eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ in("id", deptIds);
|
|
|
+ IPage<DeptVitalDTO> page = deptInfoFacade.page(deptVitalPageVO, deptInfoQueryWrapper);
|
|
|
+
|
|
|
+ List<DeptVitalDTO> deptVitalDTOListRet = Lists.newLinkedList();
|
|
|
+ List<DeptVitalDTO> deptVitalDTOList = page.getRecords();
|
|
|
+ for (DeptInfo deptInfo : deptVitalDTOList) {
|
|
|
+ DeptVitalDTO deptVitalDTO = new DeptVitalDTO();
|
|
|
+ BeanUtil.copyProperties(deptInfo, deptVitalDTO);
|
|
|
+ //取映射关系维护时间,不取科室维护时间
|
|
|
+ if (deptVitalMap.get(deptInfo.getId()) != null) {
|
|
|
+ DeptVital deptVital = deptVitalMap.get(deptInfo.getId());
|
|
|
+ deptVitalDTO.setGmtCreate(deptVital.getGmtCreate());
|
|
|
+ deptVitalDTO.setGmtModified(deptVital.getGmtModified());
|
|
|
+ deptVitalDTO.setCreator(deptVital.getCreator());
|
|
|
+ deptVitalDTO.setModifier(deptVital.getModifier());
|
|
|
+ deptVitalDTO.setGmtOperate(deptVitalDTO.getGmtModified());
|
|
|
+ deptVitalDTO.setOperator(deptVitalDTO.getModifier());
|
|
|
+ }
|
|
|
+ deptVitalDTOListRet.add(deptVitalDTO);
|
|
|
+ }
|
|
|
+ List<String> userIds = deptVitalDTOListRet.stream().map(deptVitalDTO -> deptVitalDTO.getModifier()).collect(Collectors.toList());
|
|
|
+ RespDTO<Map<String, String>> data = userServiceClient.getUserInfoByIds(userIds);
|
|
|
+ Map<String, String> userInfos = data.data;
|
|
|
+ for (DeptVitalDTO deptVitalDTO : deptVitalDTOListRet) {
|
|
|
+ if (userInfos.get(deptVitalDTO.getOperator()) != null) {
|
|
|
+ deptVitalDTO.setOperatorName(userInfos.get(deptVitalDTO.getOperator()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ page.setRecords(deptVitalDTOListRet);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取科室下拉列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<DeptShortDTO> getDeptShortList(List<Long> deptIds) {
|
|
|
+ List<DeptShortDTO> deptShortDTOList = Lists.newLinkedList();
|
|
|
+ QueryWrapper<DeptInfo> deptInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ deptInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ notIn("id", deptIds);
|
|
|
+ List<DeptInfo> deptInfoList = deptInfoFacade.list(deptInfoQueryWrapper);
|
|
|
+ for (DeptInfo deptInfo : deptInfoList) {
|
|
|
+ DeptShortDTO deptShortDTO = new DeptShortDTO();
|
|
|
+ BeanUtil.copyProperties(deptInfo, deptShortDTO);
|
|
|
+ deptShortDTOList.add(deptShortDTO);
|
|
|
+ }
|
|
|
+ return deptShortDTOList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取科室下拉列表-新增
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<DeptShortDTO> getDeptShortLisCreate() {
|
|
|
+ QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ deptVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ select("dept_id").
|
|
|
+ groupBy("dept_id");
|
|
|
+ List<DeptVital> deptVitalList = this.list(deptVitalQueryWrapper);
|
|
|
+ List<Long> deptIds = deptVitalList.stream().map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
|
|
|
+ return getDeptShortList(deptIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取科室下拉列表-修改
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<DeptShortDTO> getDeptShortLisModify(Long expId) {
|
|
|
+ QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ deptVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ select("dept_id").
|
|
|
+ groupBy("dept_id");
|
|
|
+ List<DeptVital> deptVitalList = this.list(deptVitalQueryWrapper);
|
|
|
+ List<Long> deptIds = deptVitalList.stream().map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
|
|
|
+ if (deptIds.contains(expId)) {
|
|
|
+ deptIds.remove(expId);
|
|
|
+ deptIds.size();
|
|
|
+ }
|
|
|
+ return getDeptShortList(deptIds);
|
|
|
}
|
|
|
-}
|
|
|
+}
|