|
@@ -3,12 +3,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.KnowledgemanServiceClient;
|
|
|
import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.ConceptBaseDTO;
|
|
|
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;
|
|
@@ -20,7 +21,11 @@ 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.ListUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.ConceptSearchVO;
|
|
|
+import com.diagbot.vo.ConceptTypeVO;
|
|
|
import com.diagbot.vo.DVDetailVO;
|
|
|
import com.diagbot.vo.DeptVitalPageVO;
|
|
|
import com.diagbot.vo.DeptVitalVO;
|
|
@@ -29,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -45,12 +51,12 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
@Autowired
|
|
|
private QuestionFacade questionFacade;
|
|
|
@Autowired
|
|
|
- private DeptInfoFacade deptInfoFacade;
|
|
|
- @Autowired
|
|
|
@Qualifier("deptVitalServiceImpl")
|
|
|
private DeptVitalService deptVitalService;
|
|
|
@Autowired
|
|
|
private UserServiceClient userServiceClient;
|
|
|
+ @Autowired
|
|
|
+ private KnowledgemanServiceClient klmServiceClient;
|
|
|
|
|
|
/**
|
|
|
* 保存查体模板
|
|
@@ -59,10 +65,16 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean saveDeptVitals(DeptVitalVO deptVitalVO) {
|
|
|
- DeptInfo deptInfo = deptInfoFacade.getById(deptVitalVO.getDeptId());
|
|
|
- if (deptInfo == null) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
|
|
|
+ //科室存在性验证
|
|
|
+ isExist(deptVitalVO.getDeptId());
|
|
|
+ //验证模板是否已存在
|
|
|
+ QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ deptVitalQueryWrapper.eq("dept_id", deptVitalVO.getDeptId()).
|
|
|
+ eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ if (this.count(deptVitalQueryWrapper) > 0) {
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "该科室模板已经存在!");
|
|
|
}
|
|
|
+
|
|
|
//先删除该科室原有模板
|
|
|
UpdateWrapper<DeptVital> deptVitalUpdateWrapper = new UpdateWrapper<>();
|
|
|
deptVitalUpdateWrapper.eq("dept_id", deptVitalVO.getDeptId()).
|
|
@@ -151,14 +163,11 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public DeptVitalDTO getModuleByDeptId(Long deptId) {
|
|
|
+ //科室存在性验证
|
|
|
+ Map<Long, String> deptMap = isExist(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);
|
|
|
+ deptVitalDTO.setDeptId(deptId);
|
|
|
+ deptVitalDTO.setName(deptMap.get(deptId));
|
|
|
|
|
|
//已关联查体
|
|
|
QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
@@ -205,13 +214,24 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
public IPage<DeptVitalDTO> getDeptVitalPageByMap(DeptVitalPageVO deptVitalPageVO) {
|
|
|
IPage<DeptVitalDTO> page = this.getDeptVitalPage(deptVitalPageVO);
|
|
|
List<DeptVitalDTO> deptVitalDTOList = page.getRecords();
|
|
|
+ //操作人信息
|
|
|
List<String> userIds = deptVitalDTOList.stream().map(deptVitalDTO -> deptVitalDTO.getOperator()).collect(Collectors.toList());
|
|
|
RespDTO<Map<String, String>> data = userServiceClient.getUserInfoByIds(userIds);
|
|
|
Map<String, String> userInfos = data.data;
|
|
|
+ //科室信息
|
|
|
+ List<Long> deptIds = deptVitalDTOList.stream().map(deptVitalDTO -> deptVitalDTO.getDeptId()).collect(Collectors.toList());
|
|
|
+ ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
|
|
|
+ conceptSearchVO.setConceptIds(deptIds);
|
|
|
+ RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
|
|
|
+ Map<Long, String> depts = deptMap.data;
|
|
|
+
|
|
|
for (DeptVitalDTO deptVitalDTO : deptVitalDTOList) {
|
|
|
- if (userInfos.get(deptVitalDTO.getOperator()) != null) {
|
|
|
+ if (null != userInfos.get(deptVitalDTO.getOperator())) {
|
|
|
deptVitalDTO.setOperatorName(userInfos.get(deptVitalDTO.getOperator()));
|
|
|
}
|
|
|
+ if (null != depts.get(deptVitalDTO.getDeptId())) {
|
|
|
+ deptVitalDTO.setName(depts.get(deptVitalDTO.getDeptId()));
|
|
|
+ }
|
|
|
}
|
|
|
page.setRecords(deptVitalDTOList);
|
|
|
return page;
|
|
@@ -223,11 +243,23 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DeptShortDTO> getDeptShortList(List<Long> deptIds) {
|
|
|
- QueryWrapper<DeptInfo> deptInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- deptInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
- notIn("id", deptIds);
|
|
|
- List<DeptInfo> deptInfoList = deptInfoFacade.list(deptInfoQueryWrapper);
|
|
|
- List<DeptShortDTO> deptShortDTOList = BeanUtil.listCopyTo(deptInfoList, DeptShortDTO.class);
|
|
|
+ //获取所有科室
|
|
|
+ ConceptTypeVO conceptTypeVO = new ConceptTypeVO();
|
|
|
+ conceptTypeVO.setType(1);
|
|
|
+ RespDTO<List<ConceptBaseDTO>> deptList = klmServiceClient.getConceptListByType(conceptTypeVO);
|
|
|
+ RespDTOUtil.respNGDealCover(deptList, "科室不存在");
|
|
|
+ //去除已经存在的科室
|
|
|
+ List<DeptShortDTO> deptShortDTOList = new ArrayList<>();
|
|
|
+ if (ListUtil.isNotEmpty(deptList.data)) {
|
|
|
+ for (ConceptBaseDTO conceptBaseDTO : deptList.data) {
|
|
|
+ if (!deptIds.contains(conceptBaseDTO.getConceptId())) {
|
|
|
+ DeptShortDTO deptShortDTO = new DeptShortDTO();
|
|
|
+ deptShortDTO.setId(conceptBaseDTO.getConceptId());
|
|
|
+ deptShortDTO.setName(conceptBaseDTO.getName());
|
|
|
+ deptShortDTOList.add(deptShortDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return deptShortDTOList;
|
|
|
}
|
|
|
|
|
@@ -252,16 +284,71 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DeptShortDTO> getDeptShortLisModify(Long expId) {
|
|
|
+ List<Long> deptIds = this.getAllExist();
|
|
|
+ if (deptIds.contains(expId)) {
|
|
|
+ deptIds.remove(expId);
|
|
|
+ deptIds.size();
|
|
|
+ }
|
|
|
+ return getDeptShortList(deptIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取科室下拉列表-查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<DeptShortDTO> getDeptShortListSearch() {
|
|
|
+ List<Long> deptIds = this.getAllExist();
|
|
|
+ List<DeptShortDTO> res = ListUtil.newArrayList();
|
|
|
+ if (ListUtil.isNotEmpty(deptIds)) {
|
|
|
+ ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
|
|
|
+ List<Long> conceptIds = ListUtil.newArrayList();
|
|
|
+ conceptSearchVO.setConceptIds(deptIds);
|
|
|
+ RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
|
|
|
+ for (Long deptId : deptIds) {
|
|
|
+ if (null != deptMap.data.get(deptId)) {
|
|
|
+ DeptShortDTO deptShortDTO = new DeptShortDTO();
|
|
|
+ deptShortDTO.setId(deptId);
|
|
|
+ deptShortDTO.setName(deptMap.data.get(deptId));
|
|
|
+ res.add(deptShortDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有已经存在的科室
|
|
|
+ *
|
|
|
+ * @return 已经存在的科室的Id列表
|
|
|
+ */
|
|
|
+ private List<Long> getAllExist() {
|
|
|
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 deptIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 存在性验证
|
|
|
+ *
|
|
|
+ * @param deptId 科室id
|
|
|
+ * @return 科室信息Map
|
|
|
+ */
|
|
|
+ private Map<Long, String> isExist(Long deptId) {
|
|
|
+ ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
|
|
|
+ List<Long> conceptIds = ListUtil.newArrayList();
|
|
|
+ conceptIds.add(deptId);
|
|
|
+ conceptSearchVO.setConceptIds(conceptIds);
|
|
|
+ RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
|
|
|
+ RespDTOUtil.respNGDealCover(deptMap, "科室不存在");
|
|
|
+ if (null == deptMap.data.get(deptId)) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
|
|
|
}
|
|
|
- return getDeptShortList(deptIds);
|
|
|
+ return deptMap.data;
|
|
|
}
|
|
|
}
|