Commit b38828ab authored by 陆正友's avatar 陆正友

农行LSC代码格式化

parent 5c45ca00
<?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">
trace="true">
<a:init-procedure>
<s:server-script import="token_record.js"><![CDATA[
importPackage(java.io);
importPackage(java.util);
importPackage(Packages.com.hand.hlcm);
importPackage(Packages.com.hand.hl);
var logger = $logger('server-script');
function query_next_query(batch_id){
send_query(batch_id);
}
function send_query (batch_id){
// 获取当前日期
var currentDate = new Date();
// 设置开始时间为明天的凌晨整点
var startdate_n = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()
, 0, 0, 0));
// 设置结束时间为后天的凌晨整点
var enddate_n = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() +
1, 0, 0, 0));
// 格式化日期为字符串
var startdate = startdate_n.toISOString().slice(0, 19).replace('T', ' ');
var enddate = enddate_n.toISOString().slice(0, 19).replace('T', ' ');
//var startdate = '2023-12-13 00:00:00';
//var enddate = '2023-12-20 00:00:00';
// 提取开始时间的日期部分
var starttime = startdate_n.toISOString().slice(0, 10);
//var starttime = '2023-12-13';
var att_import_bank_bm=$bm('efile.EFILE1100.att_import_bank');
var att_import_bank_trx_bm=$bm('efile.EFILE1100.att_import_bank_trx');
var init_page_number=100; //每次请求当前页条数
try {
var sys_url_bm = $bm('cont.CON4000.get_sys_url');
var parameter_code = 'TOKEN_POSTURL';
var SysposturlQuery = sys_url_bm.queryAsMap({
<s:server-script import="token_record.js"><![CDATA[
importPackage(java.io);
importPackage(java.util);
importPackage(Packages.com.hand.hlcm);
importPackage(Packages.com.hand.hl);
var logger = $logger('server-script');
function query_next_query(batch_id) {
send_query(batch_id);
}
function send_query(batch_id) {
// 获取当前日期
var currentDate = new Date();
// 设置开始时间为明天的凌晨整点
var startdate_n = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()
, 0, 0, 0));
// 设置结束时间为后天的凌晨整点
var enddate_n = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() +
1, 0, 0, 0));
// 格式化日期为字符串
var startdate = startdate_n.toISOString().slice(0, 19).replace('T', ' ');
var enddate = enddate_n.toISOString().slice(0, 19).replace('T', ' ');
//var startdate = '2023-12-13 00:00:00';
//var enddate = '2023-12-20 00:00:00';
// 提取开始时间的日期部分
var starttime = startdate_n.toISOString().slice(0, 10);
//var starttime = '2023-12-13';
var att_import_bank_bm = $bm('efile.EFILE1100.att_import_bank');
var att_import_bank_trx_bm = $bm('efile.EFILE1100.att_import_bank_trx');
var init_page_number = 100; //每次请求当前页条数
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 posturl = SysposturlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPID';
var SysappidQuery = sys_url_bm.queryAsMap({
var parameter_code = 'TOKEN_APPID';
var SysappidQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appid = SysappidQuery.getChildren()[0].parameter_value;
});
var token_appid = SysappidQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPSECRET';
var SysappsecretQuery = sys_url_bm.queryAsMap({
var parameter_code = 'TOKEN_APPSECRET';
var SysappsecretQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appsecret = SysappsecretQuery.getChildren()[0].parameter_value;
});
var token_appsecret = SysappsecretQuery.getChildren()[0].parameter_value;
var parameter_code = 'OCR_AGRICULTURAL_BANK';
var FileQuery = sys_url_bm.queryAsMap({
var parameter_code = 'OCR_AGRICULTURAL_BANK';
var FileQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var docUrl = FileQuery.getChildren()[0].parameter_value;
});
var docUrl = FileQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_TYPE';
var tokenTypeyQuery = sys_url_bm.queryAsMap({
var parameter_code = 'TOKEN_TYPE';
var tokenTypeyQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_type = tokenTypeyQuery.getChildren()[0].parameter_value;
});
var token_type = tokenTypeyQuery.getChildren()[0].parameter_value;
var bank_list_bm = $bm('efile.EFILE1100.att_import_bank');
var parameter_code = starttime;
var response_json_list = bank_list_bm.queryAsMap({
var bank_list_bm = $bm('efile.EFILE1100.att_import_bank');
var parameter_code = starttime;
var response_json_list = bank_list_bm.queryAsMap({
parameter_code: parameter_code,
batch_id : batch_id
});
var list =response_json_list.getChildren().length;
var record = response_json_list.getChildren();
logger.info(typeof (record));
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;
println('is_valid = ' + is_valid);
if (is_valid == 'true') {
batch_id: batch_id
});
var list = response_json_list.getChildren().length;
var record = response_json_list.getChildren();
logger.info(typeof (record));
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;
println('is_valid = ' + is_valid);
if (is_valid == 'true') {
println("=======有效期内======");
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var files = '{"startCreatedDate": ' + '"' +startdate +'"'
+ ',"endCreatedDate":'+ '"' +enddate + '"'
+',"documentTypeCodeList": '+'["receiptD"]}';
var files = '{"startCreatedDate": ' + '"' + startdate + '"'
+ ',"endCreatedDate":' + '"' + enddate + '"'
+ ',"documentTypeCodeList": ' + '["receiptD"]}';
access_token = access_token;
var request_files_n = files + access_token + token_type ;
var request_files_n = files + access_token + token_type;
var request_files = JSON.stringify(request_files_n);
var token_type = token_type;
var page_number = 1;
if(list==0){
// 说明当前没有发起查询,从第一页开始查
page_number=1;
} else{
if(record[0].RETURN_PAGE_SIZE>=record[0].PAGE_SIZE){
page_number=record[0].PAGE_NUMBER+1;
}
else{
page_number=record[0].PAGE_NUMBER;
if (list == 0) {
// 说明当前没有发起查询,从第一页开始查
page_number = 1;
} else {
if (record[0].RETURN_PAGE_SIZE >= record[0].PAGE_SIZE) {
page_number = record[0].PAGE_NUMBER + 1;
} else {
page_number = record[0].PAGE_NUMBER;
}
}
};
;
var page = page_number;
var size = init_page_number;
var doc = "http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/documents/query?page=" + page +
"&size="+size;
"&size=" + size;
var docUrl = doc.toString();
att_import_bank_bm.insert({
'start_date' : startdate,
'end_date' : enddate,
'request_json' : request_files,
'page_number' : page_number,
'request_url' : docUrl
'start_date': startdate,
'end_date': enddate,
'request_json': request_files,
'page_number': page_number,
'request_url': docUrl
})
var bank_list_bm = $bm('efile.EFILE1100.get_bank_list');
var parameter_code = starttime;
var response_json_list = bank_list_bm.queryAsMap({
parameter_code: parameter_code
parameter_code: parameter_code
});
var list =response_json_list.getChildren().length;
var list = response_json_list.getChildren().length;
var record = response_json_list.getChildren();
logger.info(typeof (record));
var doc_import=new com.hand.hlcm.HttpPostDocQuery();
var data_result_n = doc_import.httpPostDocImport(docUrl,files,access_token,token_type);
var doc_import = new com.hand.hlcm.HttpPostDocQuery();
var data_result_n = doc_import.httpPostDocImport(docUrl, files, access_token, token_type);
var json_data = JSON.parse(data_result_n);
var statusCode = json_data.statusCode;
var message = json_data.message;
......@@ -145,51 +145,51 @@
$ctx.parameter.page_number = page_number;
$ctx.parameter.total = total;
var result=json_data.result;
var result = json_data.result;
// var result_list=JSON.stringify(result);
var result_list = result.length;
var return_page_size = JSON.stringify(result_list);
att_import_bank_bm.update({
'code' : statusCode,
'message' : message,
'response_json' : data_result_n,
'return_page_size' : return_page_size,
'page_size' : size,
'slip_batch_id' : record[0].SLIP_BATCH_ID
'code': statusCode,
'message': message,
'response_json': data_result_n,
'return_page_size': return_page_size,
'page_size': size,
'slip_batch_id': record[0].SLIP_BATCH_ID
})
for (var i = 0; i < result_list; i++) {
var docFormFieldValueVOList = result[i].docFormFieldValueVOList;
var fieldValueMap = {};
// 构建字段映射
for (var j = 0; j < docFormFieldValueVOList.length; j++) {
var fieldCode = docFormFieldValueVOList[j].fieldCode;
var fieldValue = docFormFieldValueVOList[j].fieldValue;
fieldValueMap[fieldCode] = fieldValue;
var docFormFieldValueVOList = result[i].docFormFieldValueVOList;
var fieldValueMap = {};
// 构建字段映射
for (var j = 0; j < docFormFieldValueVOList.length; j++) {
var fieldCode = docFormFieldValueVOList[j].fieldCode;
var fieldValue = docFormFieldValueVOList[j].fieldValue;
fieldValueMap[fieldCode] = fieldValue;
}
if (fieldValueMap['BENEFICIARY_ACCOUNT'] == '216084872610001') {
att_import_bank_trx_bm.insert({
'bank_receipt_date': fieldValueMap['BANK_RECEIPT_DATE'],//回单时间
'total_amount': fieldValueMap['TOTAL_AMOUNT'],//收入金额
'payer_bank': fieldValueMap['PAYER_BANK'],//付款方银行
'payer_number': fieldValueMap['PAYER_ACCOUNT'],//付款方账户
'payer_name': fieldValueMap['PAYER_NAME'],//付款方户名
'zy': fieldValueMap['ZY'],//摘要
'receipt_no': fieldValueMap['DOC_CODE'].substring(4, 13),//回单编号
'beneficiary_bank': fieldValueMap['BENEFICIARY_BANK'],//收款方银行
'bank_num': fieldValueMap['BENEFICIARY_ACCOUNT'],//收款方账户
'beneficiary_name': fieldValueMap['BENEFICIARY_NAME'],//收款方户名
//'receipt_no': fieldValueMap['RECEIPT_NO'].substring(4, 13),
'slip_batch_id': record[0].SLIP_BATCH_ID,
});
}
}
if (fieldValueMap['BENEFICIARY_ACCOUNT'] == '216084872610001') {
att_import_bank_trx_bm.insert({
'bank_receipt_date': fieldValueMap['BANK_RECEIPT_DATE'],//回单时间
'total_amount': fieldValueMap['TOTAL_AMOUNT'],//收入金额
'payer_bank': fieldValueMap['PAYER_BANK'],//付款方银行
'payer_number': fieldValueMap['PAYER_ACCOUNT'],//付款方账户
'payer_name': fieldValueMap['PAYER_NAME'],//付款方户名
'zy': fieldValueMap['ZY'],//摘要
'receipt_no': fieldValueMap['DOC_CODE'].substring(4, 13),//回单编号
'beneficiary_bank': fieldValueMap['BENEFICIARY_BANK'],//收款方银行
'bank_num': fieldValueMap['BENEFICIARY_ACCOUNT'],//收款方账户
'beneficiary_name': fieldValueMap['BENEFICIARY_NAME'],//收款方户名
//'receipt_no': fieldValueMap['RECEIPT_NO'].substring(4, 13),
'slip_batch_id': record[0].SLIP_BATCH_ID,
});
}
}
} else {
} else {
println("=======有效期外======");
var token_get=new com.hand.hlcm.HttpPostUtil();
var token_get = new com.hand.hlcm.HttpPostUtil();
var data = token_get.httpPostGetToken(posturl, token_appid, token_appsecret);
println('data = ' + data);
var json = JSON.parse(data);
......@@ -199,77 +199,77 @@
var status = json.status;
println('status = ' + status);
if (access_token) {
token_savelogs_bm.insert({
'json': data,
'status': 'success'
});
// 这个 expires_in 是从 access_token 接口获取过来的数据 有效持续时间
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
});
token_savelogs_bm.insert({
'json': data,
'status': 'success'
});
// 这个 expires_in 是从 access_token 接口获取过来的数据 有效持续时间
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
});
}
if (status) {
//这里为什么一个 json,一个传 data,可能是一样的
var token_savelogs_bm = $bm('efile.EFILE1000.efile_get_token');
token_savelogs_bm.insert({
'json': data,
'status': 'fail'
});
//这里为什么一个 json,一个传 data,可能是一样的
var token_savelogs_bm = $bm('efile.EFILE1000.efile_get_token');
token_savelogs_bm.insert({
'json': data,
'status': 'fail'
});
}
logger.info('--------------------------------------------------------------------------------------------');
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var files = '{"startCreatedDate": ' + '"' +startdate +'"'
+ ',"endCreatedDate":'+ '"' +enddate + '"'
+',"documentTypeCodeList": '+'["receiptD"]}';
var files = '{"startCreatedDate": ' + '"' + startdate + '"'
+ ',"endCreatedDate":' + '"' + enddate + '"'
+ ',"documentTypeCodeList": ' + '["receiptD"]}';
access_token = access_token;
var request_files_n = files + access_token + token_type ;
var request_files_n = files + access_token + token_type;
var request_files = JSON.stringify(request_files_n);
var token_type = token_type;
var page_number = 1;
if(list==0){
// 说明当前没有发起查询,从第一页开始查
page_number=1;
} else{
if(record[0].RETURN_PAGE_SIZE>=record[0].PAGE_SIZE){
page_number=record[0].PAGE_NUMBER+1;
}
else{
page_number=record[0].PAGE_NUMBER;
if (list == 0) {
// 说明当前没有发起查询,从第一页开始查
page_number = 1;
} else {
if (record[0].RETURN_PAGE_SIZE >= record[0].PAGE_SIZE) {
page_number = record[0].PAGE_NUMBER + 1;
} else {
page_number = record[0].PAGE_NUMBER;
}
}
};
;
var page = page_number;
var size = init_page_number;
var doc = "http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/documents/query?page=" + page +
"&size="+size;
"&size=" + size;
var docUrl = doc.toString();
att_import_bank_bm.insert({
'start_date' : startdate,
'end_date' : enddate,
'request_json' : request_files,
'page_number' : page_number,
'request_url' : docUrl
'start_date': startdate,
'end_date': enddate,
'request_json': request_files,
'page_number': page_number,
'request_url': docUrl
})
var bank_list_bm = $bm('efile.EFILE1100.get_bank_list');
var parameter_code = starttime;
var response_json_list = bank_list_bm.queryAsMap({
parameter_code: parameter_code
parameter_code: parameter_code
});
var list =response_json_list.getChildren().length;
var list = response_json_list.getChildren().length;
var record = response_json_list.getChildren();
logger.info(typeof (record));
var doc_import=new com.hand.hlcm.HttpPostDocQuery();
var data_result_n = doc_import.httpPostDocImport(docUrl,files,access_token,token_type);
var doc_import = new com.hand.hlcm.HttpPostDocQuery();
var data_result_n = doc_import.httpPostDocImport(docUrl, files, access_token, token_type);
var json_data = JSON.parse(data_result_n);
var statusCode = json_data.statusCode;
var message = json_data.message;
......@@ -278,71 +278,71 @@
$ctx.parameter.page_number = page_number;
$ctx.parameter.total = total;
var result=json_data.result;
var result = json_data.result;
var result_list = result.length;
var return_page_size = JSON.stringify(result_list);
att_import_bank_bm.update({
'code' : statusCode,
'message' : message,
'response_json' : data_result_n,
'return_page_size' : return_page_size,
'page_size' : size,
'slip_batch_id' : record[0].SLIP_BATCH_ID,
'code': statusCode,
'message': message,
'response_json': data_result_n,
'return_page_size': return_page_size,
'page_size': size,
'slip_batch_id': record[0].SLIP_BATCH_ID,
})
for (var i = 0; i < result_list;i++) {
var docFormFieldValueVOList = result[i].docFormFieldValueVOList;
var fieldValueMap = {};
logger.info(docFormFieldValueVOList);
// 构建字段映射
for (var j = 0; j < docFormFieldValueVOList.length; j++) {
var fieldCode = docFormFieldValueVOList[j].fieldCode;
var fieldValue = docFormFieldValueVOList[j].fieldValue;
fieldValueMap[fieldCode] = fieldValue;
}
if (fieldValueMap['BENEFICIARY_ACCOUNT'] == '216084872610001') {
att_import_bank_trx_bm.insert({
'bank_receipt_date': fieldValueMap['BANK_RECEIPT_DATE'],//回单时间
'total_amount': fieldValueMap['TOTAL_AMOUNT'],//收入金额
'payer_bank': fieldValueMap['PAYER_BANK'],//付款方银行
'payer_number': fieldValueMap['PAYER_ACCOUNT'],//付款方账户
'payer_name': fieldValueMap['PAYER_NAME'],//付款方户名
'zy': fieldValueMap['ZY'],//摘要
'receipt_no': fieldValueMap['DOC_CODE'].substring(4, 13),//回单编号
'beneficiary_bank': fieldValueMap['BENEFICIARY_BANK'],//收款方银行
'bank_num': fieldValueMap['BENEFICIARY_ACCOUNT'],//收款方账户
'beneficiary_name': fieldValueMap['BENEFICIARY_NAME'],//收款方户名
//'receipt_no': fieldValueMap['RECEIPT_NO'].substring(4, 13),
'slip_batch_id': record[0].SLIP_BATCH_ID,
});
}
}
}
}catch (e) {
println('e:' + e);
}
if (total/100>page_number){
var batch_id = record[0].SLIP_BATCH_ID;
logger.info('19981988');
logger.info(batch_id);
logger.info('19981988');
query_next_query(batch_id);
}
}
function main(){
send_query();
for (var i = 0; i < result_list; i++) {
var docFormFieldValueVOList = result[i].docFormFieldValueVOList;
var fieldValueMap = {};
logger.info(docFormFieldValueVOList);
// 构建字段映射
for (var j = 0; j < docFormFieldValueVOList.length; j++) {
var fieldCode = docFormFieldValueVOList[j].fieldCode;
var fieldValue = docFormFieldValueVOList[j].fieldValue;
fieldValueMap[fieldCode] = fieldValue;
}
if (fieldValueMap['BENEFICIARY_ACCOUNT'] == '216084872610001') {
att_import_bank_trx_bm.insert({
'bank_receipt_date': fieldValueMap['BANK_RECEIPT_DATE'],//回单时间
'total_amount': fieldValueMap['TOTAL_AMOUNT'],//收入金额
'payer_bank': fieldValueMap['PAYER_BANK'],//付款方银行
'payer_number': fieldValueMap['PAYER_ACCOUNT'],//付款方账户
'payer_name': fieldValueMap['PAYER_NAME'],//付款方户名
'zy': fieldValueMap['ZY'],//摘要
'receipt_no': fieldValueMap['DOC_CODE'].substring(4, 13),//回单编号
'beneficiary_bank': fieldValueMap['BENEFICIARY_BANK'],//收款方银行
'bank_num': fieldValueMap['BENEFICIARY_ACCOUNT'],//收款方账户
'beneficiary_name': fieldValueMap['BENEFICIARY_NAME'],//收款方户名
//'receipt_no': fieldValueMap['RECEIPT_NO'].substring(4, 13),
'slip_batch_id': record[0].SLIP_BATCH_ID,
});
}
}
main();
]]>
</s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
}
} catch (e) {
println('e:' + e);
}
if (total / 100 > page_number) {
var batch_id = record[0].SLIP_BATCH_ID;
logger.info('19981988');
logger.info(batch_id);
logger.info('19981988');
query_next_query(batch_id);
}
}
function main() {
send_query();
}
main();
]]>
</s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</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