|
@@ -1,236 +0,0 @@
|
|
|
-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.LisMappingPageDTO;
|
|
|
-import com.diagbot.dto.RespDTO;
|
|
|
-import com.diagbot.entity.LisMapping;
|
|
|
-import com.diagbot.entity.QuestionInfo;
|
|
|
-import com.diagbot.enums.ConceptTypeEnum;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.enums.QuestionTypeEnum;
|
|
|
-import com.diagbot.enums.TagTypeEnum;
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.service.LisMappingService;
|
|
|
-import com.diagbot.service.impl.LisMappingServiceImpl;
|
|
|
-import com.diagbot.util.DateUtil;
|
|
|
-import com.diagbot.util.ListUtil;
|
|
|
-import com.diagbot.util.RespDTOUtil;
|
|
|
-import com.diagbot.util.StringUtil;
|
|
|
-import com.diagbot.util.UserUtils;
|
|
|
-import com.diagbot.vo.IdListVO;
|
|
|
-import com.diagbot.vo.IdVO;
|
|
|
-import com.diagbot.vo.IndexVO;
|
|
|
-import com.diagbot.vo.LisMappingPageVO;
|
|
|
-import com.diagbot.vo.LisMappingVO;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @Description:化验项目公表映射业务层
|
|
|
- * @Author:zhaops
|
|
|
- * @time: 2019/3/26 9:54
|
|
|
- */
|
|
|
-@Component
|
|
|
-public class LisMappingFacade extends LisMappingServiceImpl {
|
|
|
- @Autowired
|
|
|
- private UserServiceClient userServiceClient;
|
|
|
- @Autowired
|
|
|
- @Qualifier("lisMappingServiceImpl")
|
|
|
- private LisMappingService lisMappingService;
|
|
|
- @Autowired
|
|
|
- private CacheFacade cacheFacade;
|
|
|
- @Autowired
|
|
|
- private QuestionFacade questionFacade;
|
|
|
- @Autowired
|
|
|
- private KnowledgemanServiceClient knowledgemanServiceClient;
|
|
|
-
|
|
|
- /**
|
|
|
- * 化验公表映射分页信息
|
|
|
- *
|
|
|
- * @param lisMappingPageVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public IPage<LisMappingPageDTO> getLisMappingPage(LisMappingPageVO lisMappingPageVO) {
|
|
|
- IPage<LisMappingPageDTO> dtoPage = this.lisMappingPage(lisMappingPageVO);
|
|
|
- List<LisMappingPageDTO> records = dtoPage.getRecords();
|
|
|
- List<String> userIds = records.stream().map(record -> record.getModifier()).collect(Collectors.toList());
|
|
|
- RespDTO<Map<String, String>> data = userServiceClient.getUserInfoByIds(userIds);
|
|
|
- Map<String, String> userInfos = data.data;
|
|
|
- for (LisMappingPageDTO record : records) {
|
|
|
- record.setGmtOperate(record.getGmtModified());
|
|
|
- record.setOperator(record.getModifier());
|
|
|
- record.setOperatorName(userInfos.get(record.getModifier()));
|
|
|
- }
|
|
|
- dtoPage.setRecords(records);
|
|
|
- return dtoPage;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存化验公表映射关系
|
|
|
- *
|
|
|
- * @param lisMappingVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean saveLisMapping(LisMappingVO lisMappingVO) {
|
|
|
- String userId = UserUtils.getCurrentPrincipleID();
|
|
|
- Date now = DateUtil.now();
|
|
|
- LisMapping lisMapping = new LisMapping();
|
|
|
- lisMapping.setCreator(userId);
|
|
|
- lisMapping.setGmtCreate(now);
|
|
|
-
|
|
|
- QueryWrapper<LisMapping> lisMappingQueryWrapper = new QueryWrapper<>();
|
|
|
- lisMappingQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("meal_name", lisMappingVO.getMealName());
|
|
|
- if (StringUtil.isBlank(lisMappingVO.getItemName())) {
|
|
|
- /*if (!lisMappingVO.getMealName().equals(lisMappingVO.getUniqueName())) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验公表名称不匹配");
|
|
|
- }*/
|
|
|
- lisMappingQueryWrapper.and(i -> i.isNull("item_name").or(j -> j.eq("item_name", "")));
|
|
|
- } else {
|
|
|
- /*String uniqueName = lisMappingVO.getMealName() + "--" + lisMappingVO.getItemName();
|
|
|
- if (!uniqueName.equals(lisMappingVO.getUniqueName())) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验公表名称不匹配");
|
|
|
- }*/
|
|
|
- lisMappingQueryWrapper.eq("item_name", lisMappingVO.getItemName());
|
|
|
- }
|
|
|
-
|
|
|
- //验证化验大小项标签是否存在
|
|
|
- QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
- eq("type", QuestionTypeEnum.Lis.getKey()).
|
|
|
- eq("tag_type", TagTypeEnum.T7.getKey()).
|
|
|
- eq("name", lisMappingVO.getMealName());
|
|
|
- QuestionInfo lisQuestion = questionFacade.getOne(questionInfoQueryWrapper);
|
|
|
- if (lisQuestion == null) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验套餐项【" + lisMappingVO.getMealName() + "】标签不存在");
|
|
|
- }
|
|
|
- if (StringUtil.isNotBlank(lisMappingVO.getItemName())) {
|
|
|
- questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
- eq("type", QuestionTypeEnum.Lis.getKey()).
|
|
|
- eq("tag_type", TagTypeEnum.T1.getKey()).
|
|
|
- eq("name", lisMappingVO.getItemName());
|
|
|
- QuestionInfo lisDetailQuestion = questionFacade.getOne(questionInfoQueryWrapper);
|
|
|
- if (lisDetailQuestion == null) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验明细项【" + lisMappingVO.getItemName() + "】标签不存在");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //验证医学术语是否存在
|
|
|
- IndexVO indexVO = new IndexVO();
|
|
|
- indexVO.setName(lisMappingVO.getMealName());
|
|
|
- indexVO.setType(ConceptTypeEnum.Lis.getKey());
|
|
|
- RespDTO<List<ConceptBaseDTO>> listRespDTO = knowledgemanServiceClient.index(indexVO);
|
|
|
- RespDTOUtil.respNGDeal(listRespDTO, "获取医学术语失败");
|
|
|
- if (ListUtil.isEmpty(listRespDTO.data)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验套餐项【" + lisMappingVO.getMealName() + "】术语不存在");
|
|
|
- }
|
|
|
- if (StringUtil.isNotBlank(lisMappingVO.getItemName())) {
|
|
|
- indexVO.setName(lisMappingVO.getItemName());
|
|
|
- indexVO.setType(ConceptTypeEnum.LisDetail.getKey());
|
|
|
- RespDTO<List<ConceptBaseDTO>> lisDetailRespDTO = knowledgemanServiceClient.index(indexVO);
|
|
|
- RespDTOUtil.respNGDeal(lisDetailRespDTO, "获取医学术语失败");
|
|
|
- if (ListUtil.isEmpty(lisDetailRespDTO.data)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验明细项【" + lisMappingVO.getItemName() + "】术语不存在");
|
|
|
- }
|
|
|
- }
|
|
|
- indexVO.setName(lisMappingVO.getUniqueName());
|
|
|
- indexVO.setType(ConceptTypeEnum.LIS_TABLES.getKey());
|
|
|
- RespDTO<List<ConceptBaseDTO>> lisTablesRespDTO = knowledgemanServiceClient.index(indexVO);
|
|
|
- RespDTOUtil.respNGDeal(lisTablesRespDTO, "获取医学术语失败");
|
|
|
- if (ListUtil.isEmpty(lisTablesRespDTO.data)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "化验公表项项【" + lisMappingVO.getUniqueName() + "】术语不存在");
|
|
|
- }
|
|
|
-
|
|
|
- List<LisMapping> lisMappingList = this.list(lisMappingQueryWrapper);
|
|
|
- if (lisMappingList.size() > 1) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "存在多条映射关系,请删除重复映射");
|
|
|
- } else if (lisMappingList.size() == 1) {
|
|
|
- lisMapping = lisMappingList.get(0);
|
|
|
- }
|
|
|
- lisMapping.setMealName(lisMappingVO.getMealName());
|
|
|
- lisMapping.setItemName(lisMappingVO.getItemName());
|
|
|
- lisMapping.setUniqueName(lisMappingVO.getUniqueName());
|
|
|
- lisMapping.setModifier(userId);
|
|
|
- lisMapping.setGmtModified(now);
|
|
|
- lisMapping.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
- Boolean state = this.saveOrUpdate(lisMapping);
|
|
|
-
|
|
|
- //清除缓存
|
|
|
- if (lisQuestion != null) {
|
|
|
- cacheFacade.clearCache(lisQuestion.getId());
|
|
|
- }
|
|
|
- return state;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 判断映射关系是否已存在
|
|
|
- *
|
|
|
- * @param lisMappingVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean hasLisMapping(LisMappingVO lisMappingVO) {
|
|
|
- QueryWrapper<LisMapping> lisMappingQueryWrapper = new QueryWrapper<>();
|
|
|
- lisMappingQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("meal_name", lisMappingVO.getMealName());
|
|
|
- if (StringUtil.isBlank(lisMappingVO.getItemName())) {
|
|
|
- lisMappingQueryWrapper.and(i -> i.isNull("item_name").or(j -> j.eq("item_name", "")));
|
|
|
- } else {
|
|
|
- lisMappingQueryWrapper.eq("item_name", lisMappingVO.getItemName());
|
|
|
- }
|
|
|
- List<LisMapping> lisMappingList = this.list(lisMappingQueryWrapper);
|
|
|
- if (ListUtil.isNotEmpty(lisMappingList)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除单条化验公表映射关系
|
|
|
- *
|
|
|
- * @param idVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean delLisMappingById(IdVO idVO) {
|
|
|
- String userId = UserUtils.getCurrentPrincipleID();
|
|
|
- Date now = DateUtil.now();
|
|
|
- LisMapping lisMapping = this.getById(idVO.getId());
|
|
|
- if (lisMapping == null) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "映射关系不存在,不允许删除");
|
|
|
- }
|
|
|
- lisMapping.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
- lisMapping.setModifier(userId);
|
|
|
- lisMapping.setGmtModified(now);
|
|
|
- Boolean state = this.updateById(lisMapping);
|
|
|
- return state;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除化验公表映射关系
|
|
|
- *
|
|
|
- * @param idListVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean delLisMappingByIds(IdListVO idListVO) {
|
|
|
- String userId = UserUtils.getCurrentPrincipleID();
|
|
|
- Date now = DateUtil.now();
|
|
|
- UpdateWrapper<LisMapping> lisMappingUpdateWrapper = new UpdateWrapper<>();
|
|
|
- lisMappingUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("id", idListVO.getIdList()).
|
|
|
- set("is_deleted", IsDeleteEnum.Y.getKey()).set("modifier", userId).set("gmt_modified", now);
|
|
|
- Boolean state = lisMappingService.update(new LisMapping(), lisMappingUpdateWrapper);
|
|
|
- return state;
|
|
|
- }
|
|
|
-}
|