|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.aiTongueApi.service.impl;
|
|
package com.fs.aiTongueApi.service.impl;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.aiTongueApi.config.AiTongueConfig;
|
|
import com.fs.aiTongueApi.config.AiTongueConfig;
|
|
|
import com.fs.aiTongueApi.domain.AITongueResult;
|
|
import com.fs.aiTongueApi.domain.AITongueResult;
|
|
@@ -12,6 +13,8 @@ import com.fs.aiTongueApi.service.AiTongueService;
|
|
|
import com.fs.common.utils.uuid.UUID;
|
|
import com.fs.common.utils.uuid.UUID;
|
|
|
import com.fs.his.domain.FsHealthTongue;
|
|
import com.fs.his.domain.FsHealthTongue;
|
|
|
import com.fs.his.service.IFsHealthTongueService;
|
|
import com.fs.his.service.IFsHealthTongueService;
|
|
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.hc.core5.net.URIBuilder;
|
|
import org.apache.hc.core5.net.URIBuilder;
|
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpEntity;
|
|
@@ -43,10 +46,12 @@ public class AiTongueServiceImpl implements AiTongueService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsHealthTongueService tongueService;
|
|
private IFsHealthTongueService tongueService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysConfigMapper sysConfigMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public AITongueResult<TongueData> getHistoryTongue(QueryAiTongue queryAiTongue) {
|
|
public AITongueResult<TongueData> getHistoryTongue(QueryAiTongue queryAiTongue) {
|
|
|
- queryAiTongue.setAppkey(AiTongueConfig.appKey);
|
|
|
|
|
|
|
+ queryAiTongue.setAppkey(getAppKey());
|
|
|
String result = sendPost(AiTongueConfig.getFaceHistoryByIDUrl, queryAiTongue);
|
|
String result = sendPost(AiTongueConfig.getFaceHistoryByIDUrl, queryAiTongue);
|
|
|
System.out.println(result);
|
|
System.out.println(result);
|
|
|
AITongueResult<TongueData> aiTongueResult = JSON.parseObject(result, new TypeReference<AITongueResult<TongueData>>(){});
|
|
AITongueResult<TongueData> aiTongueResult = JSON.parseObject(result, new TypeReference<AITongueResult<TongueData>>(){});
|
|
@@ -65,7 +70,7 @@ public class AiTongueServiceImpl implements AiTongueService {
|
|
|
// 添加文件或表单参数
|
|
// 添加文件或表单参数
|
|
|
builder.addBinaryBody("file", inputStream, ContentType.DEFAULT_BINARY, "图片.jpg");
|
|
builder.addBinaryBody("file", inputStream, ContentType.DEFAULT_BINARY, "图片.jpg");
|
|
|
|
|
|
|
|
- builder.addTextBody("appkey", AiTongueConfig.appKey);
|
|
|
|
|
|
|
+ builder.addTextBody("appkey", getAppKey());
|
|
|
HttpEntity multipart = builder.build();
|
|
HttpEntity multipart = builder.build();
|
|
|
httpPost.setEntity(multipart);
|
|
httpPost.setEntity(multipart);
|
|
|
// 执行请求
|
|
// 执行请求
|
|
@@ -81,6 +86,12 @@ public class AiTongueServiceImpl implements AiTongueService {
|
|
|
return aiTongueResult;
|
|
return aiTongueResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String getAppKey() {
|
|
|
|
|
+ SysConfig config = sysConfigMapper.selectConfigByConfigKey("his.config");
|
|
|
|
|
+ JSONObject json = JSON.parseObject(config.getConfigValue());
|
|
|
|
|
+ return json.getString("tongueAppKey");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public AITongueResult<TongueData> quanXiTongue(QueryQuanXi queryQuanXi) {
|
|
public AITongueResult<TongueData> quanXiTongue(QueryQuanXi queryQuanXi) {
|
|
|
String s="";
|
|
String s="";
|
|
@@ -95,7 +106,7 @@ public class AiTongueServiceImpl implements AiTongueService {
|
|
|
|
|
|
|
|
builder.addTextBody("age", queryQuanXi.getAge(), ContentType.create("text/plain", Charset.forName("UTF-8")));
|
|
builder.addTextBody("age", queryQuanXi.getAge(), ContentType.create("text/plain", Charset.forName("UTF-8")));
|
|
|
builder.addTextBody("male", queryQuanXi.getMale(), ContentType.create("text/plain", Charset.forName("UTF-8")));
|
|
builder.addTextBody("male", queryQuanXi.getMale(), ContentType.create("text/plain", Charset.forName("UTF-8")));
|
|
|
- builder.addTextBody("appkey", AiTongueConfig.appKey);
|
|
|
|
|
|
|
+ builder.addTextBody("appkey", getAppKey());
|
|
|
if (queryQuanXi.getIsYuejin()!=null){
|
|
if (queryQuanXi.getIsYuejin()!=null){
|
|
|
builder.addTextBody("isYuejin", queryQuanXi.getIsYuejin(), ContentType.create("text/plain", Charset.forName("UTF-8")));
|
|
builder.addTextBody("isYuejin", queryQuanXi.getIsYuejin(), ContentType.create("text/plain", Charset.forName("UTF-8")));
|
|
|
}
|
|
}
|
|
@@ -112,7 +123,7 @@ public class AiTongueServiceImpl implements AiTongueService {
|
|
|
// 执行请求
|
|
// 执行请求
|
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
|
String responseBody = EntityUtils.toString(response.getEntity());
|
|
String responseBody = EntityUtils.toString(response.getEntity());
|
|
|
- System.out.println(responseBody);
|
|
|
|
|
|
|
+ log.info(responseBody);
|
|
|
s=responseBody;
|
|
s=responseBody;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|