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

农行回单匹配规则调整 及git完善

parent e1a98242
......@@ -19,6 +19,7 @@
<bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS"/>
<bm:field name="bp_class_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS_NAME"/>
<bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG"/>
<bm:field name="extra_nam" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXTRA_NAM"/>
<!--<bm:field name="id_card_no" displayWidth="200" forDisplay="true" prompt="身份证"/>-->
</bm:fields>
<bm:features>
......
......@@ -16,6 +16,7 @@
p_payer_number =>${@payer_number},
p_bank_name =>${@bank_name},
p_beneficiary_name =>${@beneficiary_name},
p_bp_id =>${@bp_id},
p_total_amount =>${@total_amount},
p_import_itfc_id =>${@import_itfc_id});
......
......@@ -28,7 +28,8 @@
p_response_json => ${@response_json},
p_return_page_size => ${@return_page_size},
p_page_size => ${@page_size},
p_user_id =>${/session/@user_id}
p_user_id =>${/session/@user_id},
p_slip_batch_id => ${@slip_batch_id}
);
END;
]]>
......
......@@ -6,6 +6,7 @@
SELECT *
FROM hlcm_ele_abc_bank_slip_bacth b
WHERE b.start_date = TO_DATE('${:@parameter_code}', 'YYYY-MM-DD')
ORDER BY b.slip_batch_id desc
]]></bm:query-sql>
</bm:operation>
</bm:operations>
......
......@@ -15,7 +15,6 @@
<a:link id="csh_abc_import_transaction_link"
url="${/request/@context_path}/modules/csh/CSH1400/csh_abc_import_transaction.lsc"/>
<script type="text/javascript"><![CDATA[
Leaf.onReady(function () {
//只开放按钮权限给债权内勤
var role_code = '${/model/role_code/record/@role_code}';
......@@ -30,7 +29,6 @@
}
});
function returnAbc() {
// 刷新页面
$("OcrQueryDs").query();
......@@ -48,13 +46,15 @@
$("AbcBankDs").query();
}
// 背景渲染农行回单
// var record = $('OcrQueryDs').getSelected();
// var record = $('AbcBankDs').getSelected();
function change_background_color(record) {
if (record.get('re_flag') == 'Y') {
return 'background-color:#DC143C;'
}
}
// 字段渲染农行回单
function checkOcrRender(value, record, name) {
if (record.get('re_flag') == 'Y' && !Ext.isEmpty(value)) {
......@@ -87,18 +87,14 @@
return '<font color="black">' + value + '</font>'
}
}
}
}
// 保存按钮
function agricultural_bank_save() {
var orc_save = $('AbcBankDs').getSelected();
var orc_save = $('AbcBankDs').getAll();
var param = {};
var saveOrc = [];
if (orc_save.length <= 0) {
Leaf.showMessage('提示', '请至少选择一条数据!');
} else {
for (var i = 0; i < orc_save.length; i++) {
var lineOrc = {};
lineOrc['receipt_no'] = orc_save[i].get('receipt_no');
......@@ -113,6 +109,7 @@
lineOrc['bank_name'] = orc_save[i].get('bank_name');
lineOrc['beneficiary_name'] = orc_save[i].get('beneficiary_name');
lineOrc['total_amount'] = orc_save[i].get('total_amount');
lineOrc['bp_id'] = orc_save[i].get('bp_id');
saveOrc.push(lineOrc);
}
param['AbcOrc'] = saveOrc;
......@@ -130,17 +127,12 @@
},
scope: this
});
}
// }
}
// function btn001_renderer_button_authority_detail(value, record, name) {
// if (record.isNew==true){
// return Leaf.showMessage('提示', '请至少选择一条数据!');
// }
// }
// 提交按钮
function agricultural_bank_submit(ro) {
function agricultural_bank_submit() {
var orc_save = $('AbcBankDs').getSelected();
var abc_save = $('OcrQueryDs').getSelected();
var param = {};
......@@ -176,8 +168,8 @@
recode = orc_save[i];
}
param['AbcOrc'] = saveOrc;
if (recode.get('re_flag') == 'N') {
Leaf.showConfirm('特别注意', '日志号, <font color="red">' + recode.get('receipt_no') + '</font>,的单据未匹配到对应回单数据,是否确认提交?', function () {
if(recode.get('re_flag')=='N'){
Leaf.showConfirm('特别注意', '日志号, <font color="red">'+recode.get('receipt_no')+'</font>,的单据未匹配到对应回单数据,是否确认提交?', function () {
Leaf.request({
url: $('csh_abc_import_transaction_link').getUrl(),
para: {
......@@ -195,7 +187,7 @@
scope: this
});
});
} else {
}else {
Leaf.request({
url: $('csh_abc_import_transaction_link').getUrl(),
para: {
......@@ -208,12 +200,14 @@
});
$('AbcBankDs').query();
$("OcrQueryDs").query();
// returnBack();
//returnBack();
},
scope: this
});
}
}
if (abc_save.length > 0) {
Leaf.showMessage('提示', '农行回单OCR页面的单据无法提交!');
}
......@@ -231,7 +225,12 @@
width: 430,
height: 390
});
// win.on('close', function () {
// debugger
// var createWin = $('agricultural_bank_import');
// createWin.close();
// returnAbc();
// });
}
......@@ -270,13 +269,16 @@
displayField="code_value_name" returnField="collection_classes" valueField="code_value"/>
<a:field name="collection_classes"/>
<a:field name="beneficiary_name" lovGridHeight="350" lovHeight="500" lovLabelWidth="90"
<a:field name="beneficiary_name" lovGridHeight="350" lovHeight="500" lovLabelWidth="90"
lovService="basic.hls_bp_master_v_for_agent_lov" lovWidth="550" title="HLS.BP_TITLE">
<a:mapping>
<a:map from="bp_name" to="beneficiary_name"/>
<a:map from="bp_id" to="bp_id"/>
<a:map from="extra_nam" to="extra_nam"/>
</a:mapping>
</a:field>
</a:fields>
</a:dataSet>
......@@ -307,24 +309,18 @@
<a:tabs>
<a:tab prompt="OCR数据" width="110">
<a:grid id="ocr" bindTarget="OcrQueryDs" marginHeight="200" marginWidth="80" navBar="true"
rowRenderer="change_background_color">
<a:grid id="ocr" bindTarget="OcrQueryDs" marginHeight="200" marginWidth="80" navBar="true" rowRenderer="change_background_color">
<a:columns>
<a:column name="bank_num" prompt="收款账号" width="150" align="center"
renderer="checkOcrRender"/>
<a:column name="bank_num" prompt="收款账号" width="150" align="center" renderer="checkOcrRender"/>
<a:column name="bank_receipt_date" prompt="交易时间" width="100" align="center"
renderer="checkOcrRender"/>
<a:column name="receipt_no" prompt="回单编号" width="80" align="left"/>
<a:column name="payer_number" prompt="付款方账号" width="100" align="center"
renderer="checkOcrRender"/>
<a:column name="payer_name" prompt="付款方户名" width="100" align="left"
renderer="checkOcrRender"/>
<a:column name="payer_bank" prompt="付款方开户行" width="100" align="left"
renderer="checkOcrRender"/>
<a:column name="payer_number" prompt="付款方账号" width="100" align="center" renderer="checkOcrRender"/>
<a:column name="payer_name" prompt="付款方户名" width="100" align="left" renderer="checkOcrRender"/>
<a:column name="payer_bank" prompt="付款方开户行" width="100" align="left" renderer="checkOcrRender"/>
<a:column name="bp_name" prompt="收款对象" width="100" align="left"/>
<a:column name="paid_byother_flag_desc" prompt="是否代付" width="70" align="center"/>
<a:column name="total_amount" prompt="金额" width="100" align="right"
renderer="checkOcrRender"/>
<a:column name="total_amount" prompt="金额" width="100" align="right" renderer="checkOcrRender"/>
<a:column name="zy" prompt="摘要" width="80" align="center"/>
<a:column name="collection_classes_desc" prompt="款项分类" width="90" align="center"/>
<a:column name="remark" prompt="附言" width="80" align="center"/>
......@@ -334,30 +330,28 @@
</a:columns>
</a:grid>
</a:tab>
<a:tab prompt="农行回单" width="110">
<a:tab prompt="农行导入" width="110">
<a:grid id="abc_bank" bindTarget="AbcBankDs" marginHeight="200" marginWidth="80"
rowRenderer="change_background_color" navBar="true">
<a:columns>
<a:column name="bank_num" prompt="账号" width="150" align="center"
<a:column name="bank_num" prompt="账号" width="150" align="center"
renderer="checkOcrRender"/>
<a:column name="bank_receipt_date" prompt="交易时间" width="100"
renderer="checkOcrRender" align="center"/>
<a:column name="receipt_no" prompt="日志号" width="80" align="left"/>
<a:column name="payer_number" prompt="对方账号" width="100" align="center"
<a:column name="receipt_no" prompt="日志号" width="80" align="left"/>
<a:column name="payer_number" prompt="对方账号" width="100" align="center" renderer="checkOcrRender"/>
<a:column name="payer_name" prompt="对方账号户名" width="100" align="left"
renderer="checkOcrRender"/>
<a:column name="payer_name" prompt="对方账号户名" width="100" align="left"
renderer="checkOcrRender"
required="true"/>
<a:column name="bank_name" prompt="对方银行名称" width="100" align="left"
<a:column name="bank_name" prompt="对方银行名称" width="100" align="left"
renderer="checkOcrRender"/>
<a:column name="beneficiary_name" prompt="收款对象" width="100" editor="grid_lov"
align="left"/>
<a:column name="beneficiary_name" prompt="收款对象" width="100" editor="grid_lov" align="left" required="true"/>
<a:column name="bp_id" prompt="收款对象" />
<a:column name="paid_byother_flag_desc" prompt="是否代付" width="70" editor="grid_cb"
required="true"
align="center"/>
<a:column name="total_amount" prompt="收款金额" width="100" align="right"
<a:column name="total_amount" prompt="收款金额" width="100" align="right"
renderer="checkOcrRender"/>
<a:column name="zy" prompt="摘要" width="80" align="center"/>
<a:column name="zy" prompt="摘要" width="80" align="center"/>
<a:column name="collection_classes_desc" prompt="款项分类" width="90" editor="grid_cb"
required="true"
align="center"/>
......
<?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;bank_import.js"><![CDATA[
importPackage(java.io);
importPackage(java.util);
importPackage(Packages.com.hand.hlcm);
var logger = $logger('server-script');
// 获取当前日期
var currentDate = new Date();
// 设置开始时间为明天的凌晨整点(目标时区为UTC)
var startdate_n = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()
, 0, 0, 0));
// 设置结束时间为后天的凌晨整点(目标时区为UTC)
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 starttime = startdate_n.toISOString().slice(0, 10);
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=20; //每次请求当前页条数
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 = 'OCR_AGRICULTURAL_BANK';
var FileQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var docUrl = FileQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_TYPE';
var tokenTypeyQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_type = tokenTypeyQuery.getChildren()[0].parameter_value;
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
});
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 +'"'
<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');
// 获取当前日期
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=20; //每次请求当前页条数
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 = 'OCR_AGRICULTURAL_BANK';
var FileQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var docUrl = FileQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_TYPE';
var tokenTypeyQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_type = tokenTypeyQuery.getChildren()[0].parameter_value;
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
});
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"]}';
access_token = access_token;
var request_files_n = files + access_token + token_type ;
var request_files = JSON.stringify(request_files_n);
var token_type = token_type;
access_token = access_token;
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){
var page_number = 1;
if(list==0){
// 说明当前没有发起查询,从第一页开始查
page_number=1;
} else{
} else{
if(record[0].RETURN_PAGE_SIZE>=record[0].PAGE_SIZE){
page_number=record[0].PAGE_NUMBER+1;
page_number=record[0].PAGE_NUMBER+1;
}
else{
page_number=record[0].PAGE_NUMBER;
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 +
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;
var docUrl = doc.toString();
let p_user_id;
var userid = p_user_id;
att_import_bank_bm.insert({
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,
'p_user_id': userid
})
'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({
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
});
var list =response_json_list.getChildren().length;
var record = response_json_list.getChildren();
logger.info(typeof (record));
// var data = new com.hand.hlcm.HttpPostDocQuery();
var data_result_n = httpPostDocImportBank(docUrl,files,access_token,token_type);
var json_data = JSON.parse(data_result_n);
var statusCode = json_data.statusCode;
var message = json_data.message;
var total = json_data.total;
var result=json_data.result;
var result_list = result.length;
var return_page_size = JSON.stringify(result_list);
att_import_bank_bm.update({
});
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 json_data = JSON.parse(data_result_n);
var statusCode = json_data.statusCode;
var message = json_data.message;
var total = json_data.total;
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
})
'page_size' : size,
'slip_batch_id' : record[0].SLIP_BATCH_ID
})
for (var i = 0; i < result_list;i++) {
for (var i = 0; i < result_list; i++) {
var docFormFieldValueVOList = result[i].docFormFieldValueVOList;
if(result[i].docFormFieldValueVOList[2].fieldValue=='中国农业银行'
&& result[i].docFormFieldValueVOList[2].fieldValue != null){
var receipt_no = docFormFieldValueVOList[0].fieldValue;
var modified_receipt_no = receipt_no.substring(4, 13);
att_import_bank_trx_bm.insert({
'doc_code' : docFormFieldValueVOList[0].fieldValue,//单据编号
'receipt_no' : modified_receipt_no,//银行流水号
'bank_name' : docFormFieldValueVOList[2].fieldValue,//回单银行名称
'beneficiary_name' : docFormFieldValueVOList[3].fieldValue,//收款方户名
'bank_num' : docFormFieldValueVOList[4].fieldValue,//收款方账号
'beneficiary_bank' : docFormFieldValueVOList[5].fieldValue,//收款方银行
'payer_name' : docFormFieldValueVOList[6].fieldValue,//付款方户名
'payer_number' : docFormFieldValueVOList[7].fieldValue,//付款方账号
'payer_bank' : docFormFieldValueVOList[8].fieldValue,//付款方银行
'bank_receipt_date' : docFormFieldValueVOList[9].fieldValue,//回单日期
'total_amount' : docFormFieldValueVOList[10].fieldValue,//金额
'purpose' : docFormFieldValueVOList[11].fieldValue,//用途
'remark' : docFormFieldValueVOList[12].fieldValue,//备注
'zy' : docFormFieldValueVOList[13].fieldValue,//摘要
'business_type' :docFormFieldValueVOList[14].fieldValue,//业务类型
'contract1' : docFormFieldValueVOList[15].fieldValue,//合同号
'gl_code' : docFormFieldValueVOList[16].fieldValue,//营业系统凭证号
'agencycode' : docFormFieldValueVOList[17].fieldValue,//代理店编号
'client' : docFormFieldValueVOList[18].fieldValue,//客户
'preprocess_code' :docFormFieldValueVOList[19].fieldValue,//SBO凭证号
'agency' : docFormFieldValueVOList[20].fieldValue,//代理店
'blcode' : docFormFieldValueVOList[21].fieldValue,//保理号
'slip_batch_id' : record[0].SLIP_BATCH_ID,
})
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,
});
}
} else {
println("=======有效期外======");
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);
var access_token = json.access_token;
println('access_token = ' + access_token);
//如果获取 access_token 成功,则 不会返回 status,即 status = undefined
var status = json.status;
println('status = ' + status);
if (access_token) {
}
} else {
println("=======有效期外======");
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);
var access_token = json.access_token;
println('access_token = ' + access_token);
//如果获取 access_token 成功,则 不会返回 status,即 status = undefined
var status = json.status;
println('status = ' + status);
if (access_token) {
token_savelogs_bm.insert({
'json': data,
'status': 'success'
'json': data,
'status': 'success'
});
// 这个 expires_in 是从 access_token 接口获取过来的数据 有效持续时间
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
});
}
}
if (status) {
if (status) {
//这里为什么一个 json,一个传 data,可能是一样的
var token_savelogs_bm = $bm('efile.EFILE1000.efile_get_token');
token_savelogs_bm.insert({
'json': data,
'status': 'fail'
'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"]}';
access_token = access_token;
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;
}
logger.info('--------------------------------------------------------------------------------------------');
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var files = '{"startCreatedDate": ' + '"' +startdate +'"'
+ ',"endCreatedDate":'+ '"' +enddate + '"'
+',"documentTypeCodeList": '+'["receiptD"]}';
access_token = access_token;
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;
}
};
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;
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
})
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
});
var list =response_json_list.getChildren().length;
var record = response_json_list.getChildren();
logger.info(typeof (record));
// var data = new com.hand.hlcm.HttpPostDocQuery();
var data_result_n = httpPostDocImportBank(docUrl,files,access_token,token_type);
var json_data = JSON.parse(data_result_n);
var statusCode = json_data.statusCode;
var message = json_data.message;
var total = json_data.total;
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
})
for (var i = 0; i < result_list;i++) {
var docFormFieldValueVOList = result[i].docFormFieldValueVOList;
if(result[i].docFormFieldValueVOList[2].fieldValue=='中国农业银行'
&& result[i].docFormFieldValueVOList[2].fieldValue != null){
var receipt_no = docFormFieldValueVOList[0].fieldValue;
var modified_receipt_no = receipt_no.substring(4, 13);
att_import_bank_trx_bm.insert({
'doc_code' : docFormFieldValueVOList[0].fieldValue,//单据编号
'receipt_no' : modified_receipt_no,//银行流水号
'bank_name' : docFormFieldValueVOList[2].fieldValue,//回单银行名称
'beneficiary_name' : docFormFieldValueVOList[3].fieldValue,//收款方户名
'bank_num' : docFormFieldValueVOList[4].fieldValue,//收款方账号
'beneficiary_bank' : docFormFieldValueVOList[5].fieldValue,//收款方银行
'payer_name' : docFormFieldValueVOList[6].fieldValue,//付款方户名
'payer_number' : docFormFieldValueVOList[7].fieldValue,//付款方账号
'payer_bank' : docFormFieldValueVOList[8].fieldValue,//付款方银行
'bank_receipt_date' : docFormFieldValueVOList[9].fieldValue,//回单日期
'total_amount' : docFormFieldValueVOList[10].fieldValue,//金额
'purpose' : docFormFieldValueVOList[11].fieldValue,//用途
'remark' : docFormFieldValueVOList[12].fieldValue,//备注
'zy' : docFormFieldValueVOList[13].fieldValue,//摘要
'business_type' :docFormFieldValueVOList[14].fieldValue,//业务类型
'contract1' : docFormFieldValueVOList[15].fieldValue,//合同号
'gl_code' : docFormFieldValueVOList[16].fieldValue,//营业系统凭证号
'agencycode' : docFormFieldValueVOList[17].fieldValue,//代理店编号
'client' : docFormFieldValueVOList[18].fieldValue,//客户
'preprocess_code' :docFormFieldValueVOList[19].fieldValue,//SBO凭证号
'agency' : docFormFieldValueVOList[20].fieldValue,//代理店
'blcode' : docFormFieldValueVOList[21].fieldValue,//保理号
'slip_batch_id' : record[0].SLIP_BATCH_ID,
})
}
}
else{
page_number=record[0].PAGE_NUMBER;
}
} catch (e) {
println('e:' + e);
};
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;
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
})
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
});
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 json_data = JSON.parse(data_result_n);
var statusCode = json_data.statusCode;
var message = json_data.message;
var total = json_data.total;
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,
})
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,
});
}
]]>
</s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
}
}
}catch (e) {
println('e:' + e);
}
]]>
</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