|
|
|
@ -7,6 +7,7 @@ import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.DownloadImgUtil;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.ImageUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.http.client.ClientProtocolException;
|
|
|
|
@ -48,7 +49,8 @@ public class PictureImgToLocalTask implements Runnable {
|
|
|
|
|
this.pictureImgToLocal = pictureImgToLocal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String api_test2_identify_url="http://127.0.0.1:7003/semantic";
|
|
|
|
|
// public static String api_test2_identify_url="http://127.0.0.1:7003/semantic";
|
|
|
|
|
public static String api_test2_identify_url="http://47.93.59.251/semantic/semantic";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
@ -73,8 +75,10 @@ public class PictureImgToLocalTask implements Runnable {
|
|
|
|
|
}
|
|
|
|
|
//获取拍照时间
|
|
|
|
|
// JSONObject requestBody = new JSONObject();
|
|
|
|
|
// requestBody.put("task_id", "123");
|
|
|
|
|
// requestBody.put("img_path", picture.getLocalpictrueurl());
|
|
|
|
|
// requestBody.put("task_id", "1111");
|
|
|
|
|
//// requestBody.put("img_path", picture.getLocalpictrueurl());
|
|
|
|
|
// requestBody.put("img_path", "https://b-dr.prevailcloud.com/pangu/changen/attachment/query/pb/attachment/1754054888247390208.jpg");
|
|
|
|
|
// requestBody.put("scenes", 0);
|
|
|
|
|
// System.out.println("img_path===============>>>>>>>>>"+picture.getLocalpictrueurl());
|
|
|
|
|
// HttpClient httpClient = HttpClients.createDefault();
|
|
|
|
|
// HttpPost httpPost = new HttpPost(PictureImgToLocalTask.api_test2_identify_url);
|
|
|
|
@ -82,6 +86,7 @@ public class PictureImgToLocalTask implements Runnable {
|
|
|
|
|
// httpPost.setEntity(requestEntity);
|
|
|
|
|
// try {
|
|
|
|
|
// HttpResponse response = httpClient.execute(httpPost);
|
|
|
|
|
// System.out.println("response===========>>>>"+response);
|
|
|
|
|
// HttpEntity responseEntity = response.getEntity();
|
|
|
|
|
// if (responseEntity != null) {
|
|
|
|
|
// String responseString = EntityUtils.toString(responseEntity);
|
|
|
|
@ -90,13 +95,27 @@ public class PictureImgToLocalTask implements Runnable {
|
|
|
|
|
// JSONObject semanticResult = semanticResponseJson.getJSONObject("semantic_result");
|
|
|
|
|
// System.out.println("semanticResult===========>>>>>>>>"+semanticResult.toString());
|
|
|
|
|
// // 获取键为"时间"的值
|
|
|
|
|
// String timeValue = semanticResult.getString("时间");
|
|
|
|
|
// System.out.println("timeValue===========>>>>>>>>"+timeValue);
|
|
|
|
|
// JSONArray timeArray = semanticResult.getJSONArray("时间");
|
|
|
|
|
// StringBuilder dateTimeBuilder = new StringBuilder(); // 用于拼接日期时间字符串
|
|
|
|
|
// for (int i = 0; i < Math.min(2, timeArray.size()); i++) {
|
|
|
|
|
// JSONObject timeObject = timeArray.getJSONObject(i);
|
|
|
|
|
// String timeValue = timeObject.getString("ocrText");
|
|
|
|
|
// // 第一个元素是日期,第二个元素是时间
|
|
|
|
|
// if (i == 0) {
|
|
|
|
|
// dateTimeBuilder.append(timeValue); // 拼接日期
|
|
|
|
|
// dateTimeBuilder.append(" "); // 添加一个空格分隔符
|
|
|
|
|
// } else {
|
|
|
|
|
// dateTimeBuilder.append(timeValue); // 拼接时间
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// String dateTimeString = dateTimeBuilder.toString(); // 获取拼接后的日期时间字符串
|
|
|
|
|
// System.out.println("dateTimeString===========>>>>>>>>"+dateTimeString);
|
|
|
|
|
// // 假设时间值的格式为"yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// try {
|
|
|
|
|
// // 解析时间字符串并转换为时间戳
|
|
|
|
|
// Date date = sdf.parse(timeValue);
|
|
|
|
|
// Date date = sdf.parse(dateTimeString);
|
|
|
|
|
// long timestamp = date.getTime();
|
|
|
|
|
// // 将时间戳赋值给picture.setTime
|
|
|
|
|
// picture.setPhotoDateTimestamp(timestamp);
|
|
|
|
|