|
@@ -330,19 +330,21 @@ public class AIQuestionServiceImpl extends ServiceImpl<AIQuestionMapper, AIQuest
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+ System.out.println("dataMsg=="+dataMsg.toJSONStr());
|
|
|
if(dataMsg.getCode().equals("error")){
|
|
|
return dataMsg;
|
|
|
}
|
|
|
|
|
|
- String filePath = dataMsg.getMsg();
|
|
|
-
|
|
|
+ String filePath = (String)dataMsg.getData();
|
|
|
+ //处理地址,获取最后一个斜杠后面的文件名
|
|
|
+ String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
|
|
+ System.out.println("文件名称:" + fileName);
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
//转换为MultipartFile 准备表单数据
|
|
|
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
|
|
|
body.add("question", questionBO.getContent());
|
|
|
ByteArrayResource byteArrayResource = null;
|
|
|
- File f = new File(path,filePath);
|
|
|
+ File f = new File(path,fileName);
|
|
|
try {
|
|
|
MultipartFile multipartFileFromPath = getMultipartFileFromPath(f.getAbsolutePath());
|
|
|
byteArrayResource = new ByteArrayResource(multipartFileFromPath.getBytes()) {
|
|
@@ -351,28 +353,28 @@ public class AIQuestionServiceImpl extends ServiceImpl<AIQuestionMapper, AIQuest
|
|
|
return multipartFileFromPath.getOriginalFilename();
|
|
|
}
|
|
|
};
|
|
|
+ body.add("file",byteArrayResource);
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
|
|
+
|
|
|
+ HttpEntity<MultiValueMap<String, Object>> requestEntity =
|
|
|
+ new HttpEntity<>(body, headers);
|
|
|
+ ResponseEntity<String> response = restTemplate.exchange(
|
|
|
+ aiFileAskUrl,
|
|
|
+ HttpMethod.POST,
|
|
|
+ requestEntity,
|
|
|
+ String.class);
|
|
|
+ if(response.getStatusCode().is2xxSuccessful()){
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(response.getBody());
|
|
|
+ System.out.println("jsonObject=== "+jsonObject);
|
|
|
+ queryRes = jsonObject.getString("data");
|
|
|
+ }else{
|
|
|
+ queryRes = "AI分析有误,稍后再试";
|
|
|
+ }
|
|
|
}catch (IOException e){
|
|
|
e.printStackTrace();
|
|
|
+ queryRes = "数据处理有误,稍后再试";
|
|
|
}
|
|
|
- body.add("file",byteArrayResource);
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
|
|
-
|
|
|
- HttpEntity<MultiValueMap<String, Object>> requestEntity =
|
|
|
- new HttpEntity<>(body, headers);
|
|
|
- ResponseEntity<String> response = restTemplate.exchange(
|
|
|
- aiFileAskUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- String.class);
|
|
|
- if(response.getStatusCode().is2xxSuccessful()){
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(response.getBody());
|
|
|
- System.out.println("jsonObject=== "+jsonObject);
|
|
|
- queryRes = jsonObject.getString("data");
|
|
|
- }else{
|
|
|
- queryRes = "AI分析有误,稍后再试";
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
//排除relation表中的关联字段
|
|
|
// List<BusObjRelation> busObjRelations = busObjRelationMapper.selectList(new LambdaQueryWrapper<BusObjRelation>()
|