Commit 0a863b7e authored by gzj34291's avatar gzj34291

资料增量查询

parent 1b28b100
package com.hand.hlcm;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
public class HttpPostDocQuery {
public static String httpPostDocImport(String postUrl, String data, String token) {
try {
PostMethod postMethod = null;
HttpClient httpClient = new HttpClient();
postMethod = new PostMethod(postUrl);
RequestEntity entity = null;
postMethod.setRequestHeader("Content-Type", "application/json");
postMethod.setRequestHeader("Authorization", token);
entity = new StringRequestEntity(data, "application/json", "UTF-8");
postMethod.setRequestEntity(entity);
System.out.println(data);
httpClient.executeMethod(postMethod);
String result = postMethod.getResponseBodyAsString();
return result;
} catch (Exception var9) {
return "{\n \"error\": \"interError\",\n \"message\": \"请求接口失败\",\n \"path\": \"/oauth/token\"\n}";
}
}
public static void main(String[] args) throws Exception {
String data="{\n" +
" \"startCreatedDate\":\"2022-04-01 12:30:00\",\n" +
" \"endCreatedDate\":\"2022-07-01 12:30:00\",\n" +
" \"documentTypeCodeList\":[\"3\",\"3\",\"3\"]\n" +
"}";
String resPonse = httpPostDocImport("http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/documents/query?page=1&size=20", data, "Bearer4557fa35-d2da-479a-be68-323b6be619d9");
System.out.println(resPonse);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<s:server-script import="token_record.js;file_query.js"><![CDATA[
importPackage(java.io);
importPackage(java.util);
importPackage(Packages.com.hand.hlcm);
try {
var sys_url_bm = $bm('cont.CON4000.get_sys_url');
var parameter_code = 'TOKEN_POSTURL';
var SysposturlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var posturl = SysposturlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPID';
var SysappidQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appid = SysappidQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPSECRET';
var SysappsecretQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appsecret = SysappsecretQuery.getChildren()[0].parameter_value;
var parameter_code = 'FILE_QUERY_URL';
var FileQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var docUrl = FileQuery.getChildren()[0].parameter_value;
var token_savelogs_bm = $bm('efile.EFILE1000.efile_get_token');
//token是否在有效期内,在有效期内直接获取表中的token
var check_token_valid_bm = $bm('efile.EFILE1000.check_token_valid');
var checkTokenQuery = check_token_valid_bm.queryAsMap();
var is_valid = checkTokenQuery.getChildren()[0].is_valid;
if (is_valid == 'true') {
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var doc_data=[];
var startdate = '2022-04-01 12:30:00';
var enddate = '2022-07-01 12:30:00';
var files = '{"startCreatedDate": ' + '"' +startdate +'"'
+ ',"endCreatedDate":'+ '"' +enddate + '"'
+',"documentTypeCodeList": '+'["类型code1","类型code2","类型code3"]}';
access_token_n = 'Bearer'+ access_token;
println('access_token_n' + access_token_n);
var data_result_n = HttpPostDocQuery.httpPostDocImport(docUrl,files,access_token_n);
println(22333333);
var json_data = JSON.parse(data_result_n);
var statusCode =json_data.statusCode;
var message =json_data.message;
} else {
println("=======有效期外======");
var data = httpPostGetToken(posturl, token_appid, token_appsecret);
println(data);
var json = JSON.parse(data);
var access_token = json.access_token;
var status = json.status;
if (access_token) {
token_savelogs_bm.insert({
'json': data,
'status': 'success'
})
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
})
}
if (status) {
var token_savelogs_bm = $bm('efile.EFILE1000.token_savelogs');
token_savelogs_bm.insert({
'json': json,
'status': 'fail'
});
}
var doc_data=[];
var startdate = '2022-04-01 12:30:00';
var enddate = '2022-07-01 12:30:00';
var files = '{"startCreatedDate": ' + '"' +startdate +'"'
+ ',"endCreatedDate":'+ '"' +enddate + '"'
+',"documentTypeCodeList": '+'["类型code1","类型code2","类型code3"]}';
access_token_n = 'Bearer'+ access_token;
println('access_token_n' + access_token_n);
var data_result_n = HttpPostDocQuery.httpPostDocImport(docUrl,files,access_token_n);
println(22333333);
var json_data = JSON.parse(data_result_n);
var statusCode =json_data.statusCode;
var message =json_data.message;
println('data_result_n = ' + data_result_n);
println('data_result_n = ' + data_result_n);
}
} catch (e) {
println('e:' + e);
}
]]></s:server-script>
</a:init-procedure>
</a:service>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment