|
@@ -1,14 +1,15 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import com.diagbot.client.AIServiceClient;
|
|
|
+import com.diagbot.client.AiptServiceClient;
|
|
|
import com.diagbot.client.bean.FeatureRate;
|
|
|
-import com.diagbot.client.bean.Response;
|
|
|
import com.diagbot.client.bean.ResponseData;
|
|
|
import com.diagbot.client.bean.SearchData;
|
|
|
import com.diagbot.dto.AIDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.AIVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -29,7 +30,7 @@ import java.util.Map;
|
|
|
@Component
|
|
|
public class AIFacade {
|
|
|
@Autowired
|
|
|
- private AIServiceClient aiServiceClient;
|
|
|
+ private AiptServiceClient aiptServiceClient;
|
|
|
|
|
|
/**
|
|
|
* 调用ai接口业务逻辑
|
|
@@ -61,24 +62,22 @@ public class AIFacade {
|
|
|
searchData.setLength(10);
|
|
|
break;
|
|
|
}
|
|
|
- Response<ResponseData> res = aiServiceClient.bayesPageData(searchData);
|
|
|
- if (null == res || null == res.getData()) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "AI没有返回结果");
|
|
|
- }
|
|
|
+ RespDTO<ResponseData> res = aiptServiceClient.aiptData(searchData);
|
|
|
+ RespDTOUtil.respNGDealCover(res, "中间层没有结果返回");
|
|
|
AIDTO aidto = new AIDTO();
|
|
|
switch (type) {
|
|
|
case "1":
|
|
|
- aidto.setItems(res.getData().getSymptom());
|
|
|
+ aidto.setItems(res.data.getSymptom());
|
|
|
break;
|
|
|
case "7":
|
|
|
List<FeatureRate> items = new ArrayList<>();
|
|
|
- if (ListUtil.isNotEmpty(res.getData().getDis())){
|
|
|
+ if (ListUtil.isNotEmpty(res.data.getDis())) {
|
|
|
Double rate;
|
|
|
Map<String, Double> map = new HashMap<>();
|
|
|
- for (FeatureRate featureRate: res.getData().getDis()){
|
|
|
- if (Double.valueOf(featureRate.getRate()) > 0.1d){
|
|
|
- if (StringUtil.isNotBlank(featureRate.getExtraProperty())){
|
|
|
- if (null != map.get(featureRate.getExtraProperty())){
|
|
|
+ for (FeatureRate featureRate : res.data.getDis()) {
|
|
|
+ if (Double.valueOf(featureRate.getRate()) > 0.1d) {
|
|
|
+ if (StringUtil.isNotBlank(featureRate.getExtraProperty())) {
|
|
|
+ if (null != map.get(featureRate.getExtraProperty())) {
|
|
|
rate = map.get(featureRate.getExtraProperty())
|
|
|
+ Double.valueOf(featureRate.getRate());
|
|
|
map.replace(featureRate.getExtraProperty(), rate);
|
|
@@ -89,31 +88,31 @@ public class AIFacade {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<Map.Entry<String,Double>> list = new ArrayList<Map.Entry<String,Double>>(map.entrySet());
|
|
|
- Collections.sort(list,new Comparator<Map.Entry<String,Double>>() {
|
|
|
- //降序排序
|
|
|
- public int compare(Map.Entry<String, Double> o1,
|
|
|
- Map.Entry<String, Double> o2) {
|
|
|
- return o2.getValue().compareTo(o1.getValue());
|
|
|
- }
|
|
|
+ List<Map.Entry<String, Double>> list = new ArrayList<Map.Entry<String, Double>>(map.entrySet());
|
|
|
+ Collections.sort(list, new Comparator<Map.Entry<String, Double>>() {
|
|
|
+ //降序排序
|
|
|
+ public int compare(Map.Entry<String, Double> o1,
|
|
|
+ Map.Entry<String, Double> o2) {
|
|
|
+ return o2.getValue().compareTo(o1.getValue());
|
|
|
+ }
|
|
|
});
|
|
|
FeatureRate item;
|
|
|
- for (Map.Entry<String,Double> entry: list){
|
|
|
- if (items.size() < 2){
|
|
|
+ for (Map.Entry<String, Double> entry : list) {
|
|
|
+ if (items.size() < 2) {
|
|
|
item = new FeatureRate();
|
|
|
item.setExtraProperty(entry.getKey());
|
|
|
items.add(item);
|
|
|
}
|
|
|
}
|
|
|
- if (ListUtil.isEmpty(items)){
|
|
|
+ if (ListUtil.isEmpty(items)) {
|
|
|
item = new FeatureRate();
|
|
|
- item.setExtraProperty(res.getData().getDis().get(0).getExtraProperty());
|
|
|
+ item.setExtraProperty(res.data.getDis().get(0).getExtraProperty());
|
|
|
items.add(item);
|
|
|
}
|
|
|
}
|
|
|
-// if (ListUtil.isEmpty(items)){
|
|
|
-// throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "暂时无法推理出结果");
|
|
|
-// }
|
|
|
+ // if (ListUtil.isEmpty(items)){
|
|
|
+ // throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "暂时无法推理出结果");
|
|
|
+ // }
|
|
|
aidto.setItems(items);
|
|
|
break;
|
|
|
}
|