Commit 0c8f9040 authored by 18083's avatar 18083

电子档案传输优化及代码补充

parent 4de04feb
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 下午3:03:31
$Revision: 1.0
$Purpose:电子档案池bm
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select * from (SELECT t1.pool_id,
t1.primary_field,
t1.internal_period_num,
t1.base_archive_code,
t1.archive_type,
t1.document_id,
t1.document_number,
t1.document_info,
t1.post_status,
t1.e_archives_id,
(SELECT hl.workflow_id FROM hl_e_archives_post_list hl
WHERE hl.e_archives_id = t1.e_archives_id) workflow_id,
(SELECT e.je_check_flag
FROM e_archives_define e
WHERE e.base_archive_code = t1.base_archive_code
AND nvl(e.workflow_id,'-1') = nvl((SELECT hl.workflow_id
FROM hl_e_archives_post_list hl
WHERE hl.e_archives_id = t1.e_archives_id),'-1')
and nvl(e.func_type,'-1')=nvl((select hl.func_type from hl_e_archives_post_list hl where hl.e_archives_id=t1.e_archives_id),'-1')) je_check_flag,
(SELECT e.post_stru_data_flag
FROM e_archives_define e
WHERE e.base_archive_code = t1.base_archive_code
AND nvl(e.workflow_id,'-1') = nvl((SELECT hl.workflow_id
FROM hl_e_archives_post_list hl
WHERE hl.e_archives_id = t1.e_archives_id),'-1')
and nvl(e.func_type,'-1')=nvl((select hl.func_type from hl_e_archives_post_list hl where hl.e_archives_id=t1.e_archives_id),'-1')) post_stru_data_flag,
(SELECT e.post_atm_flag
FROM e_archives_define e
WHERE e.base_archive_code = t1.base_archive_code
AND nvl(e.workflow_id,'-1') = nvl((SELECT hl.workflow_id
FROM hl_e_archives_post_list hl
WHERE hl.e_archives_id = t1.e_archives_id),'-1')
and nvl(e.func_type,'-1')=nvl((select hl.func_type from hl_e_archives_post_list hl where hl.e_archives_id=t1.e_archives_id),'-1')) post_atm_flag,
(SELECT e.base_archive_id
FROM e_archives_define e
WHERE e.base_archive_code = t1.base_archive_code
AND nvl(e.workflow_id,'-1') = nvl((SELECT hl.workflow_id
FROM hl_e_archives_post_list hl
WHERE hl.e_archives_id = t1.e_archives_id),'-1')
and nvl(e.func_type,'-1')=nvl((select hl.func_type from hl_e_archives_post_list hl where hl.e_archives_id=t1.e_archives_id),'-1')) base_archive_id,
(SELECT c.code_value_name
FROM sys_code_values_v c
WHERE c.code = 'DATA_CLASSIFICATION'
AND c.code_value = t1.archive_type) archive_type_desc,
(SELECT c.code_value_name
FROM sys_code_values_v c
WHERE c.code = 'YES_NO'
AND c.code_value = 'Y') suppl_trans_flag,
t1.hly_req_number ,
t1.post_message
FROM hl_e_archives_pool t1
where to_number(t1.internal_period_num) >=
nvl(to_number(${@period_num_from}),
to_number(t1.internal_period_num))
AND to_number(t1.internal_period_num) <=
nvl(to_number(${@period_num_to}),
to_number(t1.internal_period_num))
AND t1.archive_type =
nvl(${@archive_type}, t1.archive_type)
AND t1.post_status <>'POST_SUCCESS'
AND t1.pool_id IN
(SELECT tmp.document_id FROM hls_archive_pool_tmp tmp WHERE tmp.session_id = ${@session_id}))
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="e_archives_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="E_ARCHIVES_ID" />
<bm:field name="workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_ID" />
<bm:field name="je_check_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_CHECK_FLAG"/>
<bm:field name="base_archive_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BASE_ARCHIVE_ID" />
<bm:field name="pool_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="POOL_ID" />
<bm:field name="primary_field" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRIMARY_ID" />
<bm:field name="internal_period_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INTERNAL_PERIOD_NUM"/>
<bm:field name="base_archive_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BASE_ARCHIVE_CODE" />
<bm:field name="archive_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ARCHIVE_TYPE"/>
<bm:field name="document_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOCUMENT_ID"/>
<bm:field name="document_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_NUMBER"/>
<bm:field name="post_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_NUMBER"/>
<bm:field name="document_info" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_STATUS"/>
<bm:field name="post_message" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_MESSAGE"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="insert">
<bm:update-sql><![CDATA[
BEGIN
insert into hl_e_archives_pool_temp
(primary_field,
pool_id
)
values
(
${@primary_field},
${@pool_id}
);
END;
]]></bm:update-sql>
</bm:operation>
<bm:operation name="delete">
<bm:update-sql><![CDATA[
begin
delete from hl_e_archives_pool_temp t;
end;
]]></bm:update-sql>
</bm:operation>
<bm:operation name="update">
<bm:update-sql><![CDATA[
begin
update hl_e_archives_pool t set t.post_status='POST_FAILED' where t.pool_id=${@pool_id};
end;
]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
......@@ -13,10 +13,10 @@
var period_num_to=$ctx.parameter.period_num_to;
var archive_type=$ctx.parameter.archive_type;
logger.info(session_id);
var batch_id_bm = $bm('efile.EFILE1030.get_tran_batch');
var batch_id_bm = $bm('efile.EFILE1030.get_tran_batch');
var batch_id=batch_id_bm.queryAsMap().getChildren()[0].batch_id;
logger.info(batch_id);
var batch_databm=$bm('efile.EFILE1030.e_archive_pool_temp_import_his');
var batch_databm=$bm('efile.EFILE1030.e_archive_pool_temp_import_his');
var batch_dataMap=batch_databm.queryAsMap({
session_id : session_id,
period_num_from : period_num_from,
......@@ -62,7 +62,11 @@
var record=[];
var doc_data=[];
var batch_num=0;
if(batch_flag=='Y'){
//首次点击按钮,清除临时表中数据
var data_post_fail_bm = $bm('efile.EFILE1030.efile_pool_data_post');
data_post_fail_bm.delete({
});
if(batch_flag=='Y'){
logger.info(batch_data.length);
for(var i=0;i<batch_data.length;i++){
logger.info(batch_data[i].pool_id);
......@@ -70,14 +74,11 @@
pool_id: batch_data[i].pool_id
});
try{
var companyCode='HL';
var documentTypeCode=batch_data[i].base_archive_code;
var documentTypeCode=batch_data[i].base_archive_code;
var originalNumber=batch_data[i].document_info;
originalNumber= originalNumber.substr(0,100);
originalNumber=originalNumber.replace('"','');
originalNumber=originalNumber.replace('"','');
var primaryField=batch_data[i].primary_field;
var primaryField=batch_data[i].primary_field;
var isPaper='true';
var documentSource='CM';
var ruleOID='';
......@@ -87,7 +88,7 @@
var attlist=[];
var filelist=[];
if(typeof(fieldValueList)=="undefined"){
if(typeof(fieldValueList)=="undefined"){
fieldValueList=[];
// if(batch_data[i].je_check_flag=='Y'){
// fieldValueList.push(je_json_data1);
......@@ -111,15 +112,12 @@
fieldValueList=JSON.stringify(fieldValueList);
filelist.push(fieldValueList);
}
var attachmentList = fieldValueList_data.getChildren()[0].attachmentList;
if(typeof(attachmentList)!="undefined"){
var attachmentList = fieldValueList_data.getChildren()[0].attachmentList;
if(typeof(attachmentList)!="undefined"){
attachmentList=attachmentList.replace('\s+', '');
}
if(typeof(attachmentList)=="undefined"){
var fils = '{'
if(typeof(attachmentList)=="undefined"){
var fils = '{'
+'"companyCode": "'+companyCode
+'",'
+'"documentTypeCode": "'+documentTypeCode
......@@ -138,14 +136,16 @@
+'",'
+'"fieldValueList": '+filelist
+'}';
fils=JSON.parse(fils);
fils=JSON.parse(fils);
doc_data.push(fils);
}else{
attachmentList=attachmentList.substring(17);
logger.info('2222222');
attachmentList=attachmentList.substring(17);
attachmentList=JSON.parse(attachmentList);
attachmentList=JSON.stringify(attachmentList);
attlist.push(attachmentList);
//logger.info(attachmentList);
attlist.push(attachmentList);
logger.info('333333');
var fils = '{'
+'"companyCode": "'+companyCode
+'",'
......@@ -167,22 +167,45 @@
+','
+'"fieldValueList": '+filelist
+'}';
//logger.info(fils);
fils=JSON.parse(fils);
doc_data.push(fils);
logger.info('4444444');
fils=JSON.parse(fils);
logger.severe(fils);
doc_data.push(fils);
logger.severe(JSON.stringify(doc_data))
println(JSON.stringify(doc_data));
logger.info(JSON.stringify(doc_data));
logger.info('55555');
}
}catch(e) {
//捕捉错误数据,将错误数据插入临时表并更新档案池传输状态为失败
data_post_fail_bm.insert({
pool_id:batch_data[i].pool_id,
primary_field:batch_data[i].primary_field
});
data_post_fail_bm.update({
pool_id:batch_data[i].pool_id
});
continue;
}
}
if (is_valid =='true') {
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var doc_data=JSON.stringify(doc_data);
//doc_data=doc_data.replace(/[\'\\\\/\b\f\n\r\t]/g, '');
//logger.info(doc_data);
logger.info(doc_data);
println(doc_data);
var doc_import=new com.hand.hl.HttpPostUtilNew();
var data = doc_import.httpPostDocImport(docUrl,doc_data,access_token, token_type);
logger.info('data:'+data);
var json_data = JSON.parse(data);
var statusCode =json_data.statusCode;
var message =json_data.message;
......@@ -241,6 +264,7 @@
var access_token = json.access_token;
var status = json.status;
var doc_data=JSON.stringify(doc_data);
println(doc_data);
//doc_data=doc_data.replace(/[\'\\\\/\b\f\n\r\t]/g, '');
var doc_import=new com.hand.hl.HttpPostUtilNew();
var data_result = doc_import.httpPostDocImport(docUrl,doc_data,access_token, token_type);
......@@ -348,12 +372,11 @@
// je_json_data2=je_json_data_result[1];
// }
logger.info('----2222222-----');
try{
var companyCode='HL';
var documentTypeCode=req_date[i].base_archive_code;
var documentTypeCode=req_date[i].base_archive_code;
var originalNumber=req_date[i].document_info;
originalNumber= originalNumber.substr(0,100);
originalNumber=originalNumber.replace('"','');
originalNumber=originalNumber.replace('"','');
logger.info(originalNumber);
var primaryField=req_date[i].primary_field;
var isPaper='true';
......@@ -402,10 +425,9 @@
if(typeof(attachmentList)!="undefined"){
attachmentList=attachmentList.replace('\s+', '');
}
if(typeof(attachmentList)=="undefined"){
if(typeof(attachmentList)=="undefined"){
logger.info('----33333333-----');
var fils = '{'
var fils = '{'
+'"companyCode": "'+companyCode
+'",'
+'"documentTypeCode": "'+documentTypeCode
......@@ -424,15 +446,15 @@
+'",'
+'"fieldValueList": '+filelist
+'}';
fils=JSON.parse(fils);
fils=JSON.parse(fils);
doc_data.push(fils);
}else{
attachmentList=attachmentList.substring(17);
attachmentList=JSON.parse(attachmentList);
attachmentList=JSON.stringify(attachmentList);
attlist.push(attachmentList);
var fils = '{'
var fils = '{'
+'"companyCode": "'+companyCode
+'",'
+'"documentTypeCode": "'+documentTypeCode
......@@ -453,10 +475,22 @@
+','
+'"fieldValueList": '+filelist
+'}';
fils=JSON.parse(fils);
doc_data.push(fils);
}
}catch(e) {
//捕捉错误数据,将错误数据插入临时表并更新档案池传输状态为失败
data_post_fail_bm.insert({
pool_id:req_date[i].pool_id,
primary_field:req_date[i].primary_field
});
var data_post_fail_bm = $bm('efile.EFILE1030.efile_pool_data_post');
data_post_fail_bm.update({
pool_id:req_date[i].pool_id
});
continue;
}
}
......@@ -611,8 +645,6 @@
} catch (e) {
println('e:' + e);
logger.info(e);
logger.info(batch_data[i].pool_id);
}
]]></s:server-script>
</a:init-procedure>
......
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