|
@@ -3,24 +3,28 @@ 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.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.UserUtils;
|
|
|
import com.diagbot.vo.AddDisScaleInfoVO;
|
|
|
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.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -31,6 +35,8 @@ import java.util.List;
|
|
|
public class DisScaleFacade extends DisScaleServiceImpl{
|
|
|
@Autowired
|
|
|
private QuestionFacade questionFacade;
|
|
|
+ @Autowired
|
|
|
+ private UserServiceClient userServiceClient;
|
|
|
|
|
|
/**
|
|
|
* 添加诊断量表关联信息
|
|
@@ -87,6 +93,50 @@ public class DisScaleFacade extends DisScaleServiceImpl{
|
|
|
*/
|
|
|
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());
|
|
|
+ }
|
|
|
+ RespDTO<Map<String, String>> userMap = userServiceClient.getUserInfoByIds(userIds);
|
|
|
+ if (userMap == null || !CommonErrorCode.OK.getCode().equals(userMap.code)) {
|
|
|
+ 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<GetDisScaleAllInfoDTO> 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);
|
|
|
+ List<Long> questionIds = new ArrayList<>();
|
|
|
+ List<GetDisScaleAllInfoDTO> getDisScaleAllInfoDTOS = BeanUtil.listCopyTo(disScales,GetDisScaleAllInfoDTO.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 (GetDisScaleAllInfoDTO getDisScaleAllInfoDTO: getDisScaleAllInfoDTOS) {
|
|
|
+ getDisScaleAllInfoDTO.setDisName(questionInfoMap.get(getDisScaleAllInfoDTO.getDisId()).getName());
|
|
|
+ getDisScaleAllInfoDTO.setScaleName(questionInfoMap.get(getDisScaleAllInfoDTO.getScaleId()).getName());
|
|
|
+ }
|
|
|
+ return getDisScaleAllInfoDTOS;
|
|
|
+ }
|
|
|
}
|