|
|
@ -1,28 +1,34 @@
|
|
|
|
package cn.jyjz.xiaoyao.ocr.thread.tasks;
|
|
|
|
package cn.jyjz.xiaoyao.ocr.thread.tasks;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.ObjectUtils;
|
|
|
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.SpringUtils;
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.SpringUtils;
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
|
|
|
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
|
|
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.DownloadImgUtil;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.DownloadImgUtil;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil;
|
|
|
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.ImageUtils;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.ImageUtils;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.apache.http.client.ClientProtocolException;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.http.HttpEntity;
|
|
|
|
|
|
|
|
import org.apache.http.HttpResponse;
|
|
|
|
|
|
|
|
import org.apache.http.client.HttpClient;
|
|
|
|
|
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
|
|
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
|
|
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
|
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
|
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 无量云接口 数据处理队列
|
|
|
|
* 无量云接口 数据处理队列
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -30,6 +36,7 @@ import java.util.Map;
|
|
|
|
* @version 1.0
|
|
|
|
* @version 1.0
|
|
|
|
* @date 2024/3/14 11:15
|
|
|
|
* @date 2024/3/14 11:15
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
public class PictureImgToLocalTask implements Runnable {
|
|
|
|
public class PictureImgToLocalTask implements Runnable {
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +48,8 @@ public class PictureImgToLocalTask implements Runnable {
|
|
|
|
this.pictureImgToLocal = pictureImgToLocal;
|
|
|
|
this.pictureImgToLocal = pictureImgToLocal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String api_test2_identify_url="http://127.0.0.1:7003/semantic";
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
OcrPictureService ocrPictureService = SpringUtils.getBean("ocrPictureService");
|
|
|
|
OcrPictureService ocrPictureService = SpringUtils.getBean("ocrPictureService");
|
|
|
@ -62,6 +71,46 @@ public class PictureImgToLocalTask implements Runnable {
|
|
|
|
picture.setImgHash(ocrPictureClassifyAndHash.get("hash"));
|
|
|
|
picture.setImgHash(ocrPictureClassifyAndHash.get("hash"));
|
|
|
|
picture.setClassificationid(ocrPictureClassifyAndHash.get("classId"));
|
|
|
|
picture.setClassificationid(ocrPictureClassifyAndHash.get("classId"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取拍照时间
|
|
|
|
|
|
|
|
// JSONObject requestBody = new JSONObject();
|
|
|
|
|
|
|
|
// requestBody.put("task_id", "123");
|
|
|
|
|
|
|
|
// requestBody.put("img_path", picture.getLocalpictrueurl());
|
|
|
|
|
|
|
|
// System.out.println("img_path===============>>>>>>>>>"+picture.getLocalpictrueurl());
|
|
|
|
|
|
|
|
// HttpClient httpClient = HttpClients.createDefault();
|
|
|
|
|
|
|
|
// HttpPost httpPost = new HttpPost(PictureImgToLocalTask.api_test2_identify_url);
|
|
|
|
|
|
|
|
// StringEntity requestEntity = new StringEntity(requestBody.toString(), ContentType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
// httpPost.setEntity(requestEntity);
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// HttpResponse response = httpClient.execute(httpPost);
|
|
|
|
|
|
|
|
// HttpEntity responseEntity = response.getEntity();
|
|
|
|
|
|
|
|
// if (responseEntity != null) {
|
|
|
|
|
|
|
|
// String responseString = EntityUtils.toString(responseEntity);
|
|
|
|
|
|
|
|
// JSONObject semanticResponseJson = JSONObject.parseObject(responseString);
|
|
|
|
|
|
|
|
// System.out.println("semanticResponseJson===========>>>>>>>>"+semanticResponseJson.toString());
|
|
|
|
|
|
|
|
// JSONObject semanticResult = semanticResponseJson.getJSONObject("semantic_result");
|
|
|
|
|
|
|
|
// System.out.println("semanticResult===========>>>>>>>>"+semanticResult.toString());
|
|
|
|
|
|
|
|
// // 获取键为"时间"的值
|
|
|
|
|
|
|
|
// String timeValue = semanticResult.getString("时间");
|
|
|
|
|
|
|
|
// System.out.println("timeValue===========>>>>>>>>"+timeValue);
|
|
|
|
|
|
|
|
// // 假设时间值的格式为"yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// // 解析时间字符串并转换为时间戳
|
|
|
|
|
|
|
|
// Date date = sdf.parse(timeValue);
|
|
|
|
|
|
|
|
// long timestamp = date.getTime();
|
|
|
|
|
|
|
|
// // 将时间戳赋值给picture.setTime
|
|
|
|
|
|
|
|
// picture.setPhotoDateTimestamp(timestamp);
|
|
|
|
|
|
|
|
// System.out.println("picture.setPhotoDateTimestamp===========>>>>>>>>"+picture.getPhotoDateTimestamp());
|
|
|
|
|
|
|
|
// } catch (ParseException e) {
|
|
|
|
|
|
|
|
// // 如果解析失败,处理异常
|
|
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (ClientProtocolException e) {
|
|
|
|
|
|
|
|
// log.error("HTTP请求发生客户端协议异常: " + e.getMessage());
|
|
|
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
|
|
|
// log.error("HTTP请求发生IO异常: " + e.getMessage());
|
|
|
|
|
|
|
|
// }
|
|
|
|
ocrPictureService.updateById(picture);
|
|
|
|
ocrPictureService.updateById(picture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|