|
@@ -1,23 +1,19 @@
|
|
package com.diagbot.facade;
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.diagbot.dto.PartDTO;
|
|
|
|
|
|
+import com.diagbot.client.AiptServiceClient;
|
|
import com.diagbot.dto.PartSymptomDTO;
|
|
import com.diagbot.dto.PartSymptomDTO;
|
|
-import com.diagbot.entity.Part;
|
|
|
|
-import com.diagbot.entity.SymptomWrapper;
|
|
|
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
|
+import com.diagbot.enums.FixPartEnum;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonException;
|
|
import com.diagbot.exception.CommonException;
|
|
import com.diagbot.service.impl.PartServiceImpl;
|
|
import com.diagbot.service.impl.PartServiceImpl;
|
|
-import com.diagbot.util.EntityUtil;
|
|
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
import com.diagbot.vo.PartSymptomVO;
|
|
import com.diagbot.vo.PartSymptomVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 部位facade
|
|
* @Description: 部位facade
|
|
@@ -29,6 +25,8 @@ public class PartFacade extends PartServiceImpl {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
SymptomFacade symptomFacade;
|
|
SymptomFacade symptomFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ AiptServiceClient aiptServiceClient;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据已选部位返回对应的症状
|
|
* 根据已选部位返回对应的症状
|
|
@@ -36,65 +34,33 @@ public class PartFacade extends PartServiceImpl {
|
|
* @param partSymptomVO 参数
|
|
* @param partSymptomVO 参数
|
|
* @return 部位症状关联信息
|
|
* @return 部位症状关联信息
|
|
*/
|
|
*/
|
|
- public List<PartSymptomDTO> getSymptomByPartIds(PartSymptomVO partSymptomVO) {
|
|
|
|
- List<Long> partIds = partSymptomVO.getPartIds();
|
|
|
|
- if(ListUtil.isEmpty(partIds)) {
|
|
|
|
|
|
+ public List<PartSymptomDTO> getSymptomByPartName(PartSymptomVO partSymptomVO) {
|
|
|
|
+ List<String> partList = partSymptomVO.getPartList();
|
|
|
|
+ if (ListUtil.isEmpty(partList)) {
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
"请选择部位");
|
|
"请选择部位");
|
|
}
|
|
}
|
|
- if(partSymptomVO.getSexType() == null) {
|
|
|
|
|
|
+ if (partSymptomVO.getSexType() == null) {
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
"请选择性别");
|
|
"请选择性别");
|
|
}
|
|
}
|
|
- if(partSymptomVO.getAge() == null) {
|
|
|
|
|
|
+ if (partSymptomVO.getAge() == null) {
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
"请选择年龄");
|
|
"请选择年龄");
|
|
}
|
|
}
|
|
- if(partSymptomVO.getAge().intValue() < 0 || partSymptomVO.getAge().intValue() > 200) {
|
|
|
|
|
|
+ if (partSymptomVO.getAge().intValue() < 0 || partSymptomVO.getAge().intValue() > 200) {
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
"超出年龄范围【0 — 200】");
|
|
"超出年龄范围【0 — 200】");
|
|
}
|
|
}
|
|
- //添加默认部位-全身
|
|
|
|
- QueryWrapper wrapper = new QueryWrapper();
|
|
|
|
- wrapper.eq("name", "全身");
|
|
|
|
- Part part = this.getOne(wrapper);
|
|
|
|
- partIds.add(part.getId());
|
|
|
|
- Map paramMap = new HashMap<>();
|
|
|
|
- paramMap.put("ids", partIds);
|
|
|
|
- List<PartSymptomDTO> res = this.getByPartId(paramMap);
|
|
|
|
- List<PartDTO> partList = this.getByParentId(paramMap);
|
|
|
|
-
|
|
|
|
- //添加二级部位信息
|
|
|
|
- Map<Long, List<PartDTO>> keyMap = EntityUtil.makeEntityListMap(partList, "parentId");
|
|
|
|
- for(PartSymptomDTO bean : res) {
|
|
|
|
- bean.setPartDTO(keyMap.get(bean.getId()));
|
|
|
|
|
|
+ if (!partList.contains(FixPartEnum.PART.getPartName())) {
|
|
|
|
+ partList.add(FixPartEnum.PART.getPartName());
|
|
}
|
|
}
|
|
-
|
|
|
|
- //添加部位和症状的关联信息
|
|
|
|
- List<Long> idList = new ArrayList<>();
|
|
|
|
- for(PartDTO bean : partList) {
|
|
|
|
- idList.add(bean.getId());
|
|
|
|
- }
|
|
|
|
- Map paramMap1 = new HashMap<>();
|
|
|
|
- paramMap1.put("ids", idList);
|
|
|
|
- paramMap1.put("sexType", partSymptomVO.getSexType());
|
|
|
|
- paramMap1.put("age", partSymptomVO.getAge());
|
|
|
|
- List<SymptomWrapper> symptomList = symptomFacade.getByPartIdsFac(paramMap1);
|
|
|
|
- Map<Long, List<SymptomWrapper>> partSymptomMap = EntityUtil.makeEntityListMap(symptomList, "partId");
|
|
|
|
- for(PartDTO bean : partList) {
|
|
|
|
- bean.setSymptomList(partSymptomMap.get(bean.getId()));
|
|
|
|
|
|
+ RespDTO<List<PartSymptomDTO>> res = aiptServiceClient.getSymptomByPartName(partSymptomVO);
|
|
|
|
+ if (RespDTOUtil.respIsNG(res)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "远程调用部位关联的症状失败");
|
|
}
|
|
}
|
|
|
|
|
|
- // 如二级部位无关联的症状,删除二级部位
|
|
|
|
- for(int i = 0; i < res.size(); i++) {
|
|
|
|
- List<PartDTO> partDTO = res.get(i).getPartDTO();
|
|
|
|
- for(int j = 0; j < partDTO.size(); j++) {
|
|
|
|
- if(ListUtil.isEmpty(partDTO.get(j).getSymptomList())) {
|
|
|
|
- partDTO.remove(j--);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return res;
|
|
|
|
|
|
+ return res.data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|