|
|
|
@ -11,8 +11,11 @@ import cn.jyjz.xiaoyao.ocr.api.utils.ApiHelper;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.api.utils.ApiPage;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.api.utils.RequestData;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.api.utils.ResultData;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.common.PrevailCloudConstant;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPrevailCloudLog;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.OcrPrevailCloudLogService;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.TaskQueue;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpClient;
|
|
|
|
@ -28,6 +31,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -51,6 +55,9 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ApiConfig apiConfig;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPrevailCloudLogService prevailCloudLogService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拉取图片信息
|
|
|
|
|
*/
|
|
|
|
@ -78,7 +85,9 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
if (!apiConfig.checkConfig()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OcrPrevailCloudLog prevailCloudLog = new OcrPrevailCloudLog();
|
|
|
|
|
prevailCloudLog.setType(PrevailCloudConstant.PULL_PICTURE_SOURCE);
|
|
|
|
|
prevailCloudLog.setRequestParam(JSONUtil.toJsonStr(pictureSourceParameter));
|
|
|
|
|
//2.对象转map
|
|
|
|
|
Map<String, Object> queryParam = BeanUtil.beanToMap(pictureSourceParameter);
|
|
|
|
|
Map<String, String> queryParamStr = new HashMap<>();
|
|
|
|
@ -108,6 +117,8 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
String responseJsonStr = HttpClient.doPost(url, httpParamers, null, apiConfig.getConnectTimeout(), apiConfig.getReadTimeout());
|
|
|
|
|
System.out.println(responseJsonStr);
|
|
|
|
|
ResultData<String> resultData = JSONUtil.toBean(responseJsonStr, ResultData.class);
|
|
|
|
|
prevailCloudLog.setResponseParam(responseJsonStr);
|
|
|
|
|
prevailCloudLog.setStatus(resultData.getStatus());
|
|
|
|
|
|
|
|
|
|
//解密请求数据
|
|
|
|
|
if (resultData.getStatus() == 100) {
|
|
|
|
@ -126,11 +137,18 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
logger.debug("请求图片接口数据失败,参数:{},返回值:{}", json, responseJsonStr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
prevailCloudLogService.save(prevailCloudLog);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendFlowTaskResult(String tenantId, String data) throws Exception {
|
|
|
|
|
public Boolean sendFlowTaskResult(String formId, String data, Long pictureId, String remark) throws Exception {
|
|
|
|
|
OcrPrevailCloudLog prevailCloudLog = new OcrPrevailCloudLog();
|
|
|
|
|
prevailCloudLog.setType(PrevailCloudConstant.SEND_FLOW_RESULT);
|
|
|
|
|
prevailCloudLog.setRequestParam(data);
|
|
|
|
|
prevailCloudLog.setFormId(Long.parseLong(formId));
|
|
|
|
|
prevailCloudLog.setTaskId(remark);
|
|
|
|
|
prevailCloudLog.setPictureId(pictureId);
|
|
|
|
|
ResultData<String> stringResultData = ApiHelper.buildResponse(apiConfig.getAccessCode(), data);
|
|
|
|
|
// RequestData requestData = ApiHelper.buildRequest(tenantId, apiConfig.getAccessKey(), apiConfig.getAccessCode(),data);//组装请求参数
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + sendResultUrl;
|
|
|
|
@ -141,11 +159,21 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
httpParamers.setJsonParamer(requestBodyJson);
|
|
|
|
|
//发起请求
|
|
|
|
|
String responseJsonStr = HttpClient.doPost(url, httpParamers, null, apiConfig.getConnectTimeout(), apiConfig.getReadTimeout());
|
|
|
|
|
System.out.println(responseJsonStr);
|
|
|
|
|
prevailCloudLog.setResponseParam(responseJsonStr);
|
|
|
|
|
ResultData<String> resultData = JSONUtil.toBean(responseJsonStr, ResultData.class);
|
|
|
|
|
prevailCloudLog.setStatus(resultData.getStatus());
|
|
|
|
|
prevailCloudLogService.save(prevailCloudLog);
|
|
|
|
|
if (resultData.getStatus() == 100) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void pullAccountInfo(long tenantNo) throws Exception {
|
|
|
|
|
OcrPrevailCloudLog prevailCloudLog = new OcrPrevailCloudLog();
|
|
|
|
|
prevailCloudLog.setType(PrevailCloudConstant.PULL_ACCOUNT_INFO);
|
|
|
|
|
prevailCloudLog.setRequestParam(String.valueOf(tenantNo));
|
|
|
|
|
Map<String, Object> queryParam = new HashMap<>();
|
|
|
|
|
queryParam.put("tenantNo", tenantNo);
|
|
|
|
|
String json = JSONObject.toJSONString(queryParam);
|
|
|
|
@ -159,8 +187,9 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
String responseJsonStr = HttpClient.doPost(url, httpParamers, null, apiConfig.getConnectTimeout(), apiConfig.getReadTimeout());
|
|
|
|
|
System.out.println(responseJsonStr);
|
|
|
|
|
ResultData<String> resultData = JSONUtil.toBean(responseJsonStr, ResultData.class);
|
|
|
|
|
prevailCloudLog.setResponseParam(responseJsonStr);
|
|
|
|
|
prevailCloudLog.setStatus(resultData.getStatus());
|
|
|
|
|
if (resultData.getStatus() == 100) {
|
|
|
|
|
;
|
|
|
|
|
//解析基础数据
|
|
|
|
|
String data = ApiHelper.decryptResponse(apiConfig.getAccessCode(), resultData);
|
|
|
|
|
ApiPage<String> apiPage = JSONUtil.toBean(data, ApiPage.class);
|
|
|
|
@ -174,6 +203,8 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
// resultApiPage.setRecords(listResult);
|
|
|
|
|
// return resultApiPage;
|
|
|
|
|
}
|
|
|
|
|
prevailCloudLogService.save(prevailCloudLog);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|