|
|
|
@ -58,27 +58,6 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPrevailCloudLogService prevailCloudLogService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拉取图片信息
|
|
|
|
|
*/
|
|
|
|
|
private String pictureSourceUrl = "/pangu/jingwei/ocr/query/pb/task/pageList";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拉取图片信息
|
|
|
|
|
*/
|
|
|
|
|
private String sendResultUrl = "/pangu/jingwei/thirdclient/command/pb/approval/result";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拉取项目信息
|
|
|
|
|
*/
|
|
|
|
|
private String projectSourceUrl = "/pangu/jingwei/ocr/query/pb/project/pageList";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拉取租户信息
|
|
|
|
|
*/
|
|
|
|
|
private String tenantSourceUrl = "/pangu/jingwei/ocr/query/pb/tenant/info";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApiPage<PictureSourceResult> pullPictureSource(PictureSourceParameter pictureSourceParameter) throws Exception {
|
|
|
|
|
//1.检查api配置是否正常
|
|
|
|
@ -106,18 +85,16 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
RequestData requestData = ApiHelper.buildRequest(tenantNo, apiConfig.getAccessKey(), apiConfig.getAccessCode(), json);
|
|
|
|
|
|
|
|
|
|
//组装请求参数
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + pictureSourceUrl;
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + apiConfig.getPictureSourceUrl();
|
|
|
|
|
String requestBodyJson = JSONObject.toJSONString(requestData);
|
|
|
|
|
// String requestBodyJson = "{\"accessKey\":\"7390F0221A1A73D8E13F8C8BB96F33B0\",\"data\":\"gzUtN5Mt24_fbDDMK3wLop8Tgu68xLCVy3Wzp9BcXnkxnCiPg_D2TNEXnQ68-Y-GhGYYcD7Iwg8juZTx1m5v4NkDvKvEwdvjQvZnMDTRYbqtHrwgVLAvUGotIMTckDY67yo2Ku52vWedjYpzzDseHwiIGVcIl-u1CljEbyjLzJzIf6oXfD7qKjOYnxKjfjp11k0IlvsPdS-mgNXTHcBei5jOFrYmZrE2y4v9bI5n1QE\",\"signature\":\"0bmIbhhybDcGeyX4ao5gSPZQeaY8G2JRh3nRt7NC7qw\",\"tenantCode\":\"1673196576094806016\",\"timestamp\":1711971774448}";
|
|
|
|
|
//入参
|
|
|
|
|
System.out.println("入参数据:" + requestBodyJson);
|
|
|
|
|
HttpParamers httpParamers = new HttpParamers(HttpMethod.POST);
|
|
|
|
|
httpParamers.setJsonParamer(requestBodyJson);
|
|
|
|
|
//发起请求
|
|
|
|
|
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.setResponseParam("msg:"+resultData.getMessage()+",status:"+resultData.getStatus());
|
|
|
|
|
prevailCloudLog.setStatus(resultData.getStatus());
|
|
|
|
|
|
|
|
|
|
//解密请求数据
|
|
|
|
@ -125,7 +102,10 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
//解析基础数据
|
|
|
|
|
String data = ApiHelper.decryptResponse(apiConfig.getAccessCode(), resultData);
|
|
|
|
|
ApiPage<String> apiPage = JSONUtil.toBean(data, ApiPage.class);
|
|
|
|
|
//日志增加拉取数量
|
|
|
|
|
prevailCloudLog.setResponseParam(prevailCloudLog.getResponseParam()+",拉取数量:"+apiPage.getTotal());
|
|
|
|
|
if(apiPage.getTotal()==0){
|
|
|
|
|
prevailCloudLogService.save(prevailCloudLog);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
//解析数据结果为List
|
|
|
|
@ -135,6 +115,7 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
resultApiPage.setPageSize(apiPage.getPageSize());
|
|
|
|
|
resultApiPage.setTotal(apiPage.getTotal());
|
|
|
|
|
resultApiPage.setRecords(listResult);
|
|
|
|
|
prevailCloudLogService.save(prevailCloudLog);
|
|
|
|
|
return resultApiPage;
|
|
|
|
|
} else {
|
|
|
|
|
logger.debug("请求图片接口数据失败,参数:{},返回值:{}", json, responseJsonStr);
|
|
|
|
@ -143,6 +124,67 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApiPage<PictureSourceResult> pullPictureSourceAll(PictureSourceParameter pictureSourceParameter) throws Exception {
|
|
|
|
|
//1.检查api配置是否正常
|
|
|
|
|
if (!apiConfig.checkConfig()) {
|
|
|
|
|
throw new Exception("api config 配置错误!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OcrPrevailCloudLog prevailCloudLog = new OcrPrevailCloudLog();
|
|
|
|
|
prevailCloudLog.setType(PrevailCloudConstant.PULL_PICTURE_SOURCE_All);
|
|
|
|
|
prevailCloudLog.setRequestParam(JSONUtil.toJsonStr(pictureSourceParameter));
|
|
|
|
|
|
|
|
|
|
//2.对象转map
|
|
|
|
|
Map<String, Object> queryParam = BeanUtil.beanToMap(pictureSourceParameter);
|
|
|
|
|
Map<String, String> queryParamStr = new HashMap<>();
|
|
|
|
|
//map值转string 注意对日期类型进行操作,加密包要求值全部为string
|
|
|
|
|
for (String key : queryParam.keySet()) {
|
|
|
|
|
if (queryParam.get(key) != null) {
|
|
|
|
|
queryParamStr.put(key, queryParam.get(key).toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//加密请求参数
|
|
|
|
|
String tenantNo = pictureSourceParameter.getTenantNo().toString();
|
|
|
|
|
String json = JSONObject.toJSONString(queryParam);
|
|
|
|
|
RequestData requestData = ApiHelper.buildRequest(tenantNo, apiConfig.getAccessKey(), apiConfig.getAccessCode(), json);
|
|
|
|
|
//组装请求参数
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + apiConfig.getPictureSourceAllUrl();
|
|
|
|
|
String requestBodyJson = JSONObject.toJSONString(requestData);
|
|
|
|
|
//入参
|
|
|
|
|
HttpParamers httpParamers = new HttpParamers(HttpMethod.POST);
|
|
|
|
|
httpParamers.setJsonParamer(requestBodyJson);
|
|
|
|
|
//发起请求
|
|
|
|
|
String responseJsonStr = HttpClient.doPost(url, httpParamers, null, apiConfig.getConnectTimeout(), apiConfig.getReadTimeout());
|
|
|
|
|
ResultData<String> resultData = JSONUtil.toBean(responseJsonStr, ResultData.class);
|
|
|
|
|
prevailCloudLog.setResponseParam("msg:"+resultData.getMessage()+",status:"+resultData.getStatus());
|
|
|
|
|
prevailCloudLog.setStatus(resultData.getStatus());
|
|
|
|
|
//定义返回对象
|
|
|
|
|
ApiPage<PictureSourceResult> resultApiPage = null;
|
|
|
|
|
//解密请求数据
|
|
|
|
|
if (resultData.getStatus() == 100) {
|
|
|
|
|
//解析基础数据
|
|
|
|
|
String data = ApiHelper.decryptResponse(apiConfig.getAccessCode(), resultData);
|
|
|
|
|
ApiPage<String> apiPage = JSONUtil.toBean(data, ApiPage.class);
|
|
|
|
|
//日志增加拉取数量
|
|
|
|
|
prevailCloudLog.setResponseParam(prevailCloudLog.getResponseParam()+",拉取数量:"+apiPage.getTotal());
|
|
|
|
|
if(apiPage.getTotal()!=0){
|
|
|
|
|
//解析数据结果为List
|
|
|
|
|
List<PictureSourceResult> listResult = JSONUtil.toList(JSONObject.toJSONString(apiPage.getRecords()), PictureSourceResult.class);
|
|
|
|
|
resultApiPage = new ApiPage<>();
|
|
|
|
|
resultApiPage.setPageNo(apiPage.getPageNo());
|
|
|
|
|
resultApiPage.setPageSize(apiPage.getPageSize());
|
|
|
|
|
resultApiPage.setTotal(apiPage.getTotal());
|
|
|
|
|
resultApiPage.setRecords(listResult);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("请求图片接口数据失败,参数:{},返回值:{}", json, responseJsonStr);
|
|
|
|
|
}
|
|
|
|
|
prevailCloudLogService.save(prevailCloudLog);
|
|
|
|
|
return resultApiPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean sendFlowTaskResult(String formId, String data, Long pictureId, String remark) throws Exception {
|
|
|
|
|
OcrPrevailCloudLog prevailCloudLog = new OcrPrevailCloudLog();
|
|
|
|
@ -153,7 +195,7 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
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;
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + apiConfig.getSendResultUrl();
|
|
|
|
|
String requestBodyJson = JSONObject.toJSONString(stringResultData);
|
|
|
|
|
//入参
|
|
|
|
|
System.out.println("入参数据:" + requestBodyJson);
|
|
|
|
@ -180,7 +222,7 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
queryParam.put("tenantNo", tenantNo);
|
|
|
|
|
String json = JSONObject.toJSONString(queryParam);
|
|
|
|
|
RequestData requestData = ApiHelper.buildRequest(tenantNo + "", apiConfig.getAccessKey(), apiConfig.getAccessCode(), json);
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + tenantSourceUrl;
|
|
|
|
|
String url = apiConfig.getInterfaceDomain() + apiConfig.getTenantSourceUrl();
|
|
|
|
|
String requestBodyJson = JSONObject.toJSONString(requestData);
|
|
|
|
|
//入参
|
|
|
|
|
HttpParamers httpParamers = new HttpParamers(HttpMethod.POST);
|
|
|
|
@ -292,4 +334,6 @@ public class PrevailCloudApiImpl implements PrevailCloudApi {
|
|
|
|
|
|
|
|
|
|
return apiPage == null ? Lists.newArrayList() : apiPage.getRecords();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|