|
|
|
@ -16,7 +16,9 @@ import cn.jyjz.xiaoyao.ocr.dataobject.*;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.*;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.TaskQueue;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.tasks.PictureImgToLocalTask;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.*;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
@ -26,6 +28,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.http.HttpEntity;
|
|
|
|
|
import org.apache.http.HttpResponse;
|
|
|
|
|
import org.apache.http.client.ClientProtocolException;
|
|
|
|
|
import org.apache.http.client.HttpClient;
|
|
|
|
|
import org.apache.http.client.config.RequestConfig;
|
|
|
|
|
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.HttpClientBuilder;
|
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -41,6 +54,8 @@ import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -318,6 +333,69 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
return pictureMybatisDao.getPackagePictureInfo(checkDuplicateId,pictureId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public Long getPhotoDateTime(OcrPicture picture) {
|
|
|
|
|
// long timestamp = 0L;
|
|
|
|
|
// JSONObject requestBody = new JSONObject();
|
|
|
|
|
// requestBody.put("task_id", "1111");
|
|
|
|
|
// requestBody.put("img_path", picture.getLocalpictrueurl());
|
|
|
|
|
// requestBody.put("scenes", 0);
|
|
|
|
|
// System.out.println("img_path===============>>>>>>>>>" + picture.getLocalpictrueurl());
|
|
|
|
|
// // 创建自定义的HttpClientBuilder,设置连接超时和套接字超时
|
|
|
|
|
// HttpClientBuilder httpClientBuilder = HttpClients.custom()
|
|
|
|
|
// .setDefaultRequestConfig(RequestConfig.custom()
|
|
|
|
|
// .setConnectTimeout(30 * 1000) // 设置连接超时时间为30秒
|
|
|
|
|
// .setSocketTimeout(30 * 1000) // 设置套接字超时时间为30秒
|
|
|
|
|
// .build());
|
|
|
|
|
//
|
|
|
|
|
// // 使用自定义的HttpClientBuilder创建HttpClient
|
|
|
|
|
// HttpClient httpClient = httpClientBuilder.build();
|
|
|
|
|
// 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);
|
|
|
|
|
// System.out.println("response===========>>>>" + response);
|
|
|
|
|
// 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());
|
|
|
|
|
// 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();
|
|
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// try {
|
|
|
|
|
// Date date = sdf.parse(dateTimeString);
|
|
|
|
|
// timestamp = date.getTime();
|
|
|
|
|
// } catch (ParseException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ClientProtocolException e) {
|
|
|
|
|
// log.error("HTTP请求发生客户端协议异常: " + e.getMessage());
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// log.error("HTTP请求发生IO异常: " + e.getMessage());
|
|
|
|
|
// }
|
|
|
|
|
// return timestamp;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OcrTaskchildPicture updateTaskChild(OcrPicture ocrPicture, Long packageid, String buessinessno) {
|
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = ocrTaskchildPictureService.getOne(new LambdaQueryWrapper<OcrTaskchildPicture>().eq(OcrTaskchildPicture::getPictureid, ocrPicture.getId()));
|
|
|
|
|
ocrTaskchildPicture.setBuessinessno(buessinessno);
|
|
|
|
|