|
@@ -1,188 +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.UserServiceClient;
|
|
|
-import com.diagbot.dto.GetDisScaleAllInfoDTO;
|
|
|
-import com.diagbot.dto.GetDisScaleByDisIdDTO;
|
|
|
-import com.diagbot.dto.RespDTO;
|
|
|
-import com.diagbot.entity.DisScale;
|
|
|
-import com.diagbot.entity.QuestionInfo;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.service.DisScaleService;
|
|
|
-import com.diagbot.service.impl.DisScaleServiceImpl;
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
-import com.diagbot.util.DateUtil;
|
|
|
-import com.diagbot.util.ListUtil;
|
|
|
-import com.diagbot.util.RespDTOUtil;
|
|
|
-import com.diagbot.util.UserUtils;
|
|
|
-import com.diagbot.vo.AddDisScaleInfoVO;
|
|
|
-import com.diagbot.vo.DelDisScaleInfoVO;
|
|
|
-import com.diagbot.vo.GetDisScaleAllInfoVO;
|
|
|
-import com.diagbot.vo.GetDisScaleByDisIdVO;
|
|
|
-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.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @Description:
|
|
|
- * @author: wangyu
|
|
|
- * @time: 2019/4/1 13:29
|
|
|
- */
|
|
|
-@Component
|
|
|
-public class DisScaleFacade extends DisScaleServiceImpl {
|
|
|
- @Autowired
|
|
|
- private QuestionFacade questionFacade;
|
|
|
- @Autowired
|
|
|
- @Qualifier("disScaleServiceImpl")
|
|
|
- private DisScaleService disScaleService;
|
|
|
- @Autowired
|
|
|
- private UserServiceClient userServiceClient;
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加诊断量表关联信息
|
|
|
- *
|
|
|
- * @param addDisScaleInfoVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean addDisScaleInfo(AddDisScaleInfoVO addDisScaleInfoVO) {
|
|
|
- String userId = UserUtils.getCurrentPrincipleID();
|
|
|
- Date now = DateUtil.now();
|
|
|
- //判断诊断是否已被删除
|
|
|
- QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("id", addDisScaleInfoVO.getDisId());
|
|
|
- if (questionFacade.count(questionInfoQueryWrapper) == 0) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
- "关联诊断标签已删除");
|
|
|
- }
|
|
|
- //判断该诊断是否关联过量表
|
|
|
- QueryWrapper<DisScale> disScaleQueryWrapper = new QueryWrapper<>();
|
|
|
- disScaleQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("dis_id", addDisScaleInfoVO.getDisId());
|
|
|
- //如果添加过将原来的标签删除
|
|
|
- if (this.count(disScaleQueryWrapper) != 0) {
|
|
|
- UpdateWrapper<DisScale> updateWrapper = new UpdateWrapper();
|
|
|
- updateWrapper.eq("dis_id", addDisScaleInfoVO.getDisId())
|
|
|
- .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
- .set("modifier", userId)
|
|
|
- .set("gmt_modified", now);
|
|
|
- this.update(new DisScale(), updateWrapper);
|
|
|
- }
|
|
|
- //重新添加标签
|
|
|
- DisScale disScale = new DisScale();
|
|
|
- List<DisScale> addList = new ArrayList<>();
|
|
|
- for (int i = 0; i < addDisScaleInfoVO.getScaleId().size(); i++) {
|
|
|
- disScale = new DisScale();
|
|
|
- disScale.setCreator(userId);
|
|
|
- disScale.setModifier(userId);
|
|
|
- disScale.setGmtCreate(now);
|
|
|
- disScale.setGmtModified(now);
|
|
|
- disScale.setScaleId(addDisScaleInfoVO.getScaleId().get(i));
|
|
|
- disScale.setDisId(addDisScaleInfoVO.getDisId());
|
|
|
- disScale.setOrderNo(i + 1);
|
|
|
- addList.add(disScale);
|
|
|
- }
|
|
|
- disScaleService.saveBatch(addList);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页获取诊断关联量表信息
|
|
|
- *
|
|
|
- * @param getDisScaleAllInfoVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public IPage<GetDisScaleAllInfoDTO> getDisScaleAllInfo(GetDisScaleAllInfoVO getDisScaleAllInfoVO) {
|
|
|
- IPage<GetDisScaleAllInfoDTO> data = this.getDisScaleInfo(getDisScaleAllInfoVO);
|
|
|
- List<String> userIds = new ArrayList<>();
|
|
|
- for (GetDisScaleAllInfoDTO getDisScaleAllInfoDTO : data.getRecords()) {
|
|
|
- userIds.add(getDisScaleAllInfoDTO.getModifier());
|
|
|
- }
|
|
|
- if(ListUtil.isNotEmpty(userIds)){
|
|
|
- RespDTO<Map<String, String>> userMap = userServiceClient.getUserInfoByIds(userIds);
|
|
|
- if (RespDTOUtil.respIsNG(userMap)) {
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
- "获取用户信息失败");
|
|
|
- }
|
|
|
- for (GetDisScaleAllInfoDTO getDisScaleAllInfoDTO : data.getRecords()) {
|
|
|
- getDisScaleAllInfoDTO.setUserName(userMap.data.get(getDisScaleAllInfoDTO.getModifier()));
|
|
|
- }
|
|
|
- }
|
|
|
- return data;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改时获取已经添加过得诊断量表关联信息
|
|
|
- *
|
|
|
- * @param getDisScaleByDisIdVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<GetDisScaleByDisIdDTO> getDisScaleByDisId(GetDisScaleByDisIdVO getDisScaleByDisIdVO) {
|
|
|
- //查询诊断量表关联信息
|
|
|
- QueryWrapper<DisScale> disScaleQueryWrapper = new QueryWrapper<>();
|
|
|
- disScaleQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("dis_id", getDisScaleByDisIdVO.getDisId());
|
|
|
- List<DisScale> disScales = this.list(disScaleQueryWrapper);
|
|
|
- //如果查不到则关联信息已被删除
|
|
|
- if(ListUtil.isEmpty(disScales)){
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
- "关联信息系不存在,请添加关联");
|
|
|
- }
|
|
|
- List<Long> questionIds = new ArrayList<>();
|
|
|
- List<GetDisScaleByDisIdDTO> getDisScaleAllInfoDTOS = BeanUtil.listCopyTo(disScales, GetDisScaleByDisIdDTO.class);
|
|
|
- for (DisScale disScale : disScales) {
|
|
|
- questionIds.add(disScale.getDisId());
|
|
|
- questionIds.add(disScale.getScaleId());
|
|
|
- }
|
|
|
- //查询相关标签名称
|
|
|
- QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("id", questionIds);
|
|
|
- List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
|
|
|
- Map<Long, QuestionInfo> questionInfoMap
|
|
|
- = questionInfoList.stream().collect(Collectors.toMap(QuestionInfo::getId, questionInfo -> questionInfo));
|
|
|
- //将标签名称放入出参
|
|
|
- for (GetDisScaleByDisIdDTO getDisScaleByDisIdDTO : getDisScaleAllInfoDTOS) {
|
|
|
- getDisScaleByDisIdDTO.setDisName(questionInfoMap.get(getDisScaleByDisIdDTO.getDisId()).getName());
|
|
|
- getDisScaleByDisIdDTO.setScaleName(questionInfoMap.get(getDisScaleByDisIdDTO.getScaleId()).getName());
|
|
|
- }
|
|
|
- return getDisScaleAllInfoDTOS;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除诊断关联量表信息
|
|
|
- *
|
|
|
- * @param delDisScaleInfoVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean delDisScaleInfo(DelDisScaleInfoVO delDisScaleInfoVO){
|
|
|
- //判断关联信息是否已经被删除
|
|
|
- List<String> delIds = Arrays.asList(delDisScaleInfoVO.getDelId().split(","));
|
|
|
- QueryWrapper<DisScale> disScaleQueryWrapper = new QueryWrapper<>();
|
|
|
- disScaleQueryWrapper.in("id",delIds)
|
|
|
- .eq("is_deleted",IsDeleteEnum.Y.getKey());
|
|
|
- if(this.count(disScaleQueryWrapper) > 0){
|
|
|
- throw new CommonException(CommonErrorCode.IS_EXISTS,
|
|
|
- "此条关联已删除");
|
|
|
- }
|
|
|
- //如果没有则执行删除
|
|
|
- UpdateWrapper<DisScale> disScaleUpdateWrapper = new UpdateWrapper<>();
|
|
|
- disScaleUpdateWrapper.in("id",delIds)
|
|
|
- .set("is_deleted",IsDeleteEnum.Y.getKey())
|
|
|
- .set("modifier",UserUtils.getCurrentPrincipleID())
|
|
|
- .set("gmt_modified",DateUtil.now());
|
|
|
- this.update(new DisScale(),disScaleUpdateWrapper);
|
|
|
- return true;
|
|
|
- }
|
|
|
-}
|