Commit 66b9a48f authored by 18083's avatar 18083

佣金付款、月结、合同结束改造

parent bf73a135
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<!--<bm:field name="bp_vender" expression="(select bp_name from hls_bp_master where bp_id=t1.bp_id_vender and enabled_flag=&apos;Y&apos;)" forInsert="false" forUpdate="false"/>--> <!--<bm:field name="bp_vender" expression="(select bp_name from hls_bp_master where bp_id=t1.bp_id_vender and enabled_flag=&apos;Y&apos;)" forInsert="false" forUpdate="false"/>-->
<bm:field name="lease_organization_desc" expression="(select description from hls_lease_organization where lease_organization = t1.lease_organization)" forInsert="false" forUpdate="false"/> <bm:field name="lease_organization_desc" expression="(select description from hls_lease_organization where lease_organization = t1.lease_organization)" forInsert="false" forUpdate="false"/>
<!--<bm:field name="owner_user_id_n" expression="(select description from sys_user where user_id = t1.created_by)" forInsert="false" forUpdate="false"/>--> <!--<bm:field name="owner_user_id_n" expression="(select description from sys_user where user_id = t1.created_by)" forInsert="false" forUpdate="false"/>-->
<bm:field name="is_terminate" expression="(CASE WHEN ((select sum(ccc.due_amount) from con_contract_cashflow ccc where ccc.contract_id = t1.contract_id AND ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and ccc.cf_item&lt;&gt;0) - (select sum(ccc.received_amount) from con_contract_cashflow ccc where ccc.contract_id = t1.contract_id AND ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and ccc.cf_item&lt;&gt;0)) = 0 THEN &apos;是&apos; ELSE &apos;否&apos; END)" forInsert="false" forUpdate="false"/> <bm:field name="is_terminate" expression="(CASE WHEN ((select sum(ccc.due_amount) from con_contract_cashflow ccc where ccc.contract_id = t1.contract_id AND ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and ccc.cf_item not in('0','40','911')) - (select sum(ccc.received_amount) from con_contract_cashflow ccc where ccc.contract_id = t1.contract_id AND ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and ccc.cf_item not in('0','40','911') )) = 0 THEN &apos;是&apos; ELSE &apos;否&apos; END)" forInsert="false" forUpdate="false"/>
<bm:field name="amount_total" expression="(select sum(ccc.due_amount) from con_contract_cashflow ccc where ccc.contract_id=t1.contract_id and ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and ccc.cf_item=1)" forInsert="false" forUpdate="false"/> <bm:field name="amount_total" expression="(select sum(ccc.due_amount) from con_contract_cashflow ccc where ccc.contract_id=t1.contract_id and ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and ccc.cf_item=1)" forInsert="false" forUpdate="false"/>
<bm:field name="amount_principal" expression="(select sum(nvl(ccc.principal,0)) from con_contract_cashflow ccc where ccc.contract_id=t1.contract_id and ccc.cf_status&lt;&gt;&apos;BLOCK&apos;)" forInsert="false" forUpdate="false"/> <bm:field name="amount_principal" expression="(select sum(nvl(ccc.principal,0)) from con_contract_cashflow ccc where ccc.contract_id=t1.contract_id and ccc.cf_status&lt;&gt;&apos;BLOCK&apos;)" forInsert="false" forUpdate="false"/>
<bm:field name="amount_interest" expression="(select sum(nvl(ccc.interest,0)) from con_contract_cashflow ccc where ccc.contract_id=t1.contract_id and ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and cf_item=1)" forInsert="false" forUpdate="false"/> <bm:field name="amount_interest" expression="(select sum(nvl(ccc.interest,0)) from con_contract_cashflow ccc where ccc.contract_id=t1.contract_id and ccc.cf_status&lt;&gt;&apos;BLOCK&apos; and cf_item=1)" forInsert="false" forUpdate="false"/>
...@@ -83,6 +83,8 @@ ...@@ -83,6 +83,8 @@
<bm:data-filter enforceOperations="query" expression="t1.contract_status in (&apos;INCEPT&apos;,&apos;ETING&apos;,&apos;REPURING&apos;,&apos;TERMINATING&apos;) "/> <bm:data-filter enforceOperations="query" expression="t1.contract_status in (&apos;INCEPT&apos;,&apos;ETING&apos;,&apos;REPURING&apos;,&apos;TERMINATING&apos;) "/>
<!-- <bm:data-filter enforceOperations="query" expression="t1.lease_end_date &lt;= sysdate"/> --> <!-- <bm:data-filter enforceOperations="query" expression="t1.lease_end_date &lt;= sysdate"/> -->
<bm:data-filter enforceOperations="query" expression="t1.data_class = &apos;NORMAL&apos;"/> <bm:data-filter enforceOperations="query" expression="t1.data_class = &apos;NORMAL&apos;"/>
<bm:data-filter enforceOperations="query" expression="t1.division != &apos;95&apos;"/>
<!-- <bm:data-filter enforceOperations="query" expression=" not exists (select 1 from con_contract_cashflow ccw where ccw.contract_id = t1.contract_id and ccw.cf_item=1 and ccw.cf_status=&apos;RELEASE&apos; and nvl(ccw.output_tax_create_je_flag,'N')='N')"/>--> <!-- <bm:data-filter enforceOperations="query" expression=" not exists (select 1 from con_contract_cashflow ccw where ccw.contract_id = t1.contract_id and ccw.cf_item=1 and ccw.cf_status=&apos;RELEASE&apos; and nvl(ccw.output_tax_create_je_flag,'N')='N')"/>-->
<bm:data-filter enforceOperations="query" expression=" not exists (select 1 from con_contract_cashflow ccw , con_unearned_finance_income cf where ccw.contract_id = t1.contract_id and ccw.cf_item=1 and cf.cashflow_id(+)=ccw.cashflow_id and ccw.cf_status=&apos;RELEASE&apos; and nvl(cf.create_je_flag,'N')='N' and nvl(ccw.output_tax_create_je_flag,'N')='N')"/> <bm:data-filter enforceOperations="query" expression=" not exists (select 1 from con_contract_cashflow ccw , con_unearned_finance_income cf where ccw.contract_id = t1.contract_id and ccw.cf_item=1 and cf.cashflow_id(+)=ccw.cashflow_id and ccw.cf_status=&apos;RELEASE&apos; and nvl(cf.create_je_flag,'N')='N' and nvl(ccw.output_tax_create_je_flag,'N')='N')"/>
<!-- <bm:data-filter enforceOperations="query" expression="t1.contract_id = ${@contract_id}"/>--> <!-- <bm:data-filter enforceOperations="query" expression="t1.contract_id = ${@contract_id}"/>-->
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: trd
$Date: 2024-3-27 下午03:50:31
$Revision: 1.0
$Purpose:佣金付款
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1"
baseTable="CSH_PAYMENT_REQ_LN" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select t.contract_id ref_doc_id,
f.cashflow_id ref_doc_line_id,
t.document_category ref_doc_category,
hc.bp_id,
t.bp_id_agent_level1,
t.contract_id,
f.cashflow_id,
t.contract_number,
t.contract_name,
hc.bp_id bp_id_agent_level1,
(select hbm.bp_name from hls_bp_master hbm where hbm.bp_id = hc.bp_id) bp_id_agent_level1_n,
hc.finance_amount,
t.lease_start_date,
hc.overdue_max_days,
hc.comsn_amount amount_agent,
hc.comsn_amount amount,
t.currency currency_code,
(SELECT gc.currency_name
FROM gld_currency_v gc
WHERE gc.currency_code = t.currency) currency_name,
(select to_char(sysdate, 'yyyy-mm') || '-20' from dual) apply_pay_date
FROM con_contract_cashflow f
join con_contract t
on t.contract_id = f.contract_id
join hlcm_comsn_reconcilia hc
on f.cashflow_id = hc.cashflow_id
where EXISTS (SELECT 1
FROM CSH_PAYMENT_CASHFLOW_ID_TEMP tmp
WHERE tmp.session_id = ${/session/@session_id}
AND tmp.cashflow_id = f.cashflow_id)
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: trd
$Date: 2024-3-26 下午03:42:50
$Revision: 1.0
$Purpose: 对账单查询
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:f="leaf.database.features"
xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select * from(
select hb.batch_number,
hc.batch_id,
hc.policy_hd_id,
hc.bp_id,
(select cc.contract_number
from con_contract cc
where cc.contract_id = hc.contract_id) contract_number,
(select cc.contract_name
from con_contract cc
where cc.contract_id = hc.contract_id) contract_name,
hc.bp_id bp_id_agent_level1,
(select hbm.bp_name from hls_bp_master hbm where hbm.bp_id = hc.bp_id) bp_id_agent_level1_n,
(select h.description
from con_contract cc,hls_division h
where cc.division= h.division and cc.contract_id = hc.contract_id) division_n,
hc.finance_amount,
(select to_char(cc.lease_start_date,'yyyy/mm/dd')
from con_contract cc
where cc.contract_id = hc.contract_id) lease_start_date,
(select cc.business_type
from con_contract cc
where cc.contract_id = hc.contract_id) con_business_type,
(select cc.business_type
from con_contract cc,hls_division hd
where cc.division= hd.division and cc.contract_id = hc.contract_id) con_business_type_n,
hc.rental_re_times,
hc.overdue_max_days,
hc.comsn_rate*100||'%' comsn_rate,
hc.comsn_amount,
(select sum(i.unearned_finance_income)
from con_unearned_finance_income i
where i.contract_id = hc.contract_id) net_interest_amount,
(select ccc.net_due_amount from con_contract_cashflow ccc where ccc.cashflow_id= hc.cashflow_id) net_comm_amount,
hc.cashflow_id,
hc.contract_id,
(select hd.policy_name from hlcm_comsn_policy_hd hd where hd.policy_hd_id=hc.policy_hd_id) policy_name
from hlcm_comsn_reconcilia_batch hb, hlcm_comsn_reconcilia hc
where hb.batch_id = hc.batch_id
and hb.wfl_status='APPROVED'
AND NOT EXISTS (
SELECT 1
FROM csh_payment_req_ln l,csh_payment_req_hd hd
WHERE l.ref_doc_line_id=hc.cashflow_id
AND l.ref_doc_category='CONTRACT'
and l.payment_req_id=hd.payment_req_id
and hd.approval_status in ('NEW','REJECT','APPROVED','APPROVING','RETURN')
)
AND ('Y' = 'Y' AND EXISTS
(SELECT 1
FROM aut_trx_user_authorize a1, aut_owner_user_authorize a2
WHERE a1.trx_category = 'CONTRACT'
AND a1.trx_id = hc.contract_id
AND trunc(SYSDATE) BETWEEN a1.start_date AND
nvl(a1.end_date, trunc(SYSDATE))
AND a1.user_id = a2.owner_user_id
AND a1.trx_category = a2.trx_category
AND a2.authorized_user_id = ${/session/@user_id}
AND trunc(SYSDATE) BETWEEN a2.start_date AND
nvl(a2.end_date, trunc(SYSDATE))))
AND NOT EXISTS (
SELECT 1
FROM csh_payment_req_ln l,csh_payment_req_hd hd
WHERE l.ref_doc_line_id=hc.cashflow_id
AND l.ref_doc_category='CONTRACT'
and l.payment_req_id=hd.payment_req_id
and hd.approval_status in ('NEW','REJECT','APPROVED','APPROVING','RETURN')
)
AND ('Y' = 'Y' AND EXISTS
(SELECT 1
FROM aut_trx_user_authorize a1, aut_owner_user_authorize a2
WHERE a1.trx_category = 'CONTRACT'
AND a1.trx_id = hc.contract_id
AND trunc(SYSDATE) BETWEEN a1.start_date AND
nvl(a1.end_date, trunc(SYSDATE))
AND a1.user_id = a2.owner_user_id
AND a1.trx_category = a2.trx_category
AND a2.authorized_user_id = ${/session/@user_id}
AND trunc(SYSDATE) BETWEEN a2.start_date AND
nvl(a2.end_date, trunc(SYSDATE))))
order by hc.overdue_max_days desc
) t1
#WHERE_CLAUSE#
#ORDER_BY_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:query-fields>
<bm:query-field name="batch_number"
queryExpression="t1.batch_number like &apos;%&apos;||${@batch_number}||&apos;%&apos;"/>
<bm:query-field name="contract_number"
queryExpression="t1.batch_number like &apos;%&apos;||${@contract_number}||&apos;%&apos;"/>
<bm:query-field name="bp_id_agent_level1_n" queryExpression="t1.bp_id_agent_level1_n like &apos;%&apos;||${@bp_id_agent_level1_n}||&apos;%&apos;"/>
<bm:query-field name="division_n" queryExpression="t1.division_n like &apos;%&apos;||${@division_n}||&apos;%&apos;"/>
<bm:query-field name="policy_name" queryExpression="t1.policy_name=${@policy_name}"/>
<bm:query-field name="overdue_max_days_f" queryExpression="t1.overdue_max_days &gt;= ${@overdue_max_days_f}"/>
<bm:query-field name="overdue_max_days_t" queryExpression="t1.overdue_max_days &lt;= ${@overdue_max_days_t}"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: 18083
$Date:
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select
t.bank_account_id bp_bank_account_id,
t.bank_account_code bp_bank_account_code,
t.bank_account_num bp_bank_account_num,
t.bank_account_name bp_bank_account_name,
t.bank_full_name bp_bank_full_name
from hls_bp_master_bank_account_v t
where t.bp_id = ${/parameter/@bp_id_agent_level1}
and t.enabled_flag = 'Y'
and rownum = 1
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select * from(
select h.policy_hd_id,
h.policy_name,
h.policy_ext_name,
h.division,
(select d.description
from hls_division d
where d.division = h.division) division_n
from hlcm_comsn_policy_hd h
where h.wfl_status = 'APPROVED'
and h.bp_id = ${@bp_id}) t
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="policy_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="POLICY_HD_ID" prompt="佣金政策id"/>
<bm:field name="policy_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="220" forDisplay="true" forQuery="true" physicalName="POLICY_NAME" prompt="佣金政策"/>
<bm:field name="policy_ext_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="120" forDisplay="true" forQuery="true" physicalName="POLICY_NAME" prompt="佣金政策简称"/>
<bm:field name="division" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DIVISION" prompt="产品线"/>
<bm:field name="division_n" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="160" forDisplay="true" forQuery="true" physicalName="DIVISION_N" prompt="产品线"/>
</bm:fields>
<bm:query-fields>
<bm:query-field field="policy_name" queryExpression="t.policy_name like &apos;%&apos;||${@policy_name}||&apos;%&apos;"/>
<bm:query-field field="policy_ext_name" queryExpression="t.policy_ext_name like &apos;%&apos;||${@policy_ext_name}||&apos;%&apos;"/>
<bm:query-field field="division_n" queryExpression="t.division_n like &apos;%&apos;||${@division_n}||&apos;%&apos;"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: trd
$Date: 2024-1-19 上午11:15:04
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="execute">
<bm:update-sql><![CDATA[
begin
csh_payment_comm_req_pkg.payment_comm_submit
(
p_payment_req_id=>${@payment_req_id},
p_user_id=>${/session/@user_id}
);
end;]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
and l.ref_doc_category = 'CONTRACT' and l.ref_doc_category = 'CONTRACT'
and l.ref_doc_id = cc.contract_id and l.ref_doc_id = cc.contract_id
and l.ref_doc_line_id = cf.cashflow_id and l.ref_doc_line_id = cf.cashflow_id
and cf.cf_item in ('40'))) v #WHERE_CLAUSE# and cf.cf_item in ('40','911'))) v #WHERE_CLAUSE#
ORDER BY transaction_date DESC, transaction_num ORDER BY transaction_date DESC, transaction_num
]]></bm:query-sql> ]]></bm:query-sql>
......
...@@ -13,9 +13,13 @@ ...@@ -13,9 +13,13 @@
gld_period_pkg.close_period(${/session/@company_id}, gld_period_pkg.close_period(${/session/@company_id},
${@period_set_code}, ${@period_set_code},
${@period_name}, ${@period_name},
${/session/@user_id}); ${/session/@user_id},
${@p_err_msg});
end; end;
]]></update-sql> ]]></update-sql>
<parameters>
<parameter name="p_err_msg" dataType="java.lang.String" input="false" output="true" outputPath="@p_err_msg"/>
</parameters>
</operation> </operation>
</operations> </operations>
</model> </model>
remove_query_field('approval_status_n');
var override_queryfields = [ var override_queryfields = [
{ {
name : 'amount_from', name : 'amount_from',
...@@ -18,6 +19,10 @@ var override_queryfields = [ ...@@ -18,6 +19,10 @@ var override_queryfields = [
{ {
name:'payment_req_number', name:'payment_req_number',
queryexpression:"t1.payment_req_number like '%'||${@payment_req_number}||'%'" queryexpression:"t1.payment_req_number like '%'||${@payment_req_number}||'%'"
},
{
name:'approval_status',
queryexpression:"t1.approval_status = ${@approval_status}"
} }
]; ];
var add_datafilters = [ var add_datafilters = [
......
remove_query_field('approval_status_n');
var override_queryfields = [
{
name : 'req_date_from',
queryexpression : "T1.req_date>=trunc(to_date(${@req_date_from},'yyyy-mm-dd'))"
},
{
name : 'req_date_to',
queryexpression : "trunc(T1.req_date)<=to_date(${@req_date_to},'yyyy-mm-dd')"
},
{
name:'payment_req_number',
queryexpression:"t1.payment_req_number like '%'||${@payment_req_number}||'%'"
},
{
name:'approval_status',
queryexpression:"t1.approval_status = ${@approval_status}"
}
];
var add_datafilters = [
{
name : '',
expression : "exists(select 1\n" +
" from csh_payment_req_ln l,con_contract cc,con_contract_cashflow cf\n" +
" where l.payment_req_id = t1.payment_req_id\n" +
" and l.ref_doc_category = 'CONTRACT'\n" +
" and l.ref_doc_id = cc.contract_id\n" +
" and l.ref_doc_line_id = cf.cashflow_id\n" +
" and cf.cf_item in ('911'))"
} ];
add_datafilter();
override();
...@@ -349,5 +349,7 @@ var enableLayoutConfig = { ...@@ -349,5 +349,7 @@ var enableLayoutConfig = {
'modules/hls/HLS303/bp_asset_create.lview':true, 'modules/hls/HLS303/bp_asset_create.lview':true,
'modules/csh/CSH1500/csh_asset_reconciliation.lview':true, 'modules/csh/CSH1500/csh_asset_reconciliation.lview':true,
'modules/csh/CSH501C/csh_payment_asset_create_entrance.lview': true, 'modules/csh/CSH501C/csh_payment_asset_create_entrance.lview': true,
'modules/csh/CSH501C/csh_payment_asset_req.lview': true 'modules/csh/CSH501C/csh_payment_asset_req.lview': true,
'modules/csh/CSH501R/csh_payment_comm_create_entrance.lview':true,
'modules/csh/CSH501R/csh_payment_comm_req.lview':true
}; };
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
trace="true">
<a:init-procedure>
</a:init-procedure>
<a:view>
<a:link id="get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
<a:link id="csh_payment_comm_create_link" url="${/request/@context_path}/modules/csh/CSH501R/csh_payment_comm_selected.lview"/>
<a:link id="csh501_csh_comm_req_link_id"
url="${/request/@context_path}/modules/csh/CSH501R/csh_payment_comm_req.lview"/>
<script type="text/javascript"><![CDATA[
//新增
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
var url = $('csh_payment_comm_create_link').getUrl();
var win = new Leaf.Window({
url: url,
params: {
winid: 'csh_payment_req_comm_win_id',
ds_id: ds_id
},
title: '佣金付款申请页面',
id: 'csh_payment_req_comm_win_id',
fullScreen: true
});
win.on('close', function () {
$(ds_id).query();
});
};
function detail_link(id, name, query_only) {
var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
var param = {};
param['payment_req_id'] = record.get('payment_req_id');
param['bp_id'] = record.get('bp_id_agent_level1');
param['business_type'] = record.get('business_type');
param['approval_status'] = record.get('approval_status');
if (record.get('approval_status') == 'NEW' || record.get('approval_status') == 'RETURN' || record.get('approval_status') == 'REJECT') {
param['function_usage'] = 'UPDATE';
param['function_code'] = 'CSH501D_COMM';
} else{
param['function_usage'] = 'QUERY';
param['maintain_type'] = 'READONLY';
param['function_code'] = 'SAVE_COMM';
param['download'] = 'Y';
}
param['winid'] = 'csh_payment_comm_update_window';
param['url_title'] = '佣金付款申请';
hls_doc_get_layout_code('get_layout_code_link_id', param, 'csh501_csh_comm_req_link_id', ds_id, '${/parameter/@layout_code}');
}
window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
if (name == 'payment_req_number' && value) {
link_function = 'detail_link';
return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + value + '</a>';
}
return value;
};
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
</a:view>
</a:screen>
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<a:model-update model="hls.HLS811.hls_doc_file_templet_get_atm"/>
<s:server-script import="contract_print_path.js"><![CDATA[
importPackage(java.io);
importPackage(Packages.hls.plugin.docx4j);
importPackage(Packages.leaf.plugin.word2pdf);
importPackage(Packages.org.apache.commons.io);
//删除文件
function deleteFile(filePath) {
var file = new File(filePath);
if (file.exists()) {
file.delete();
}
}
//生成pdf
function wordToPdf(word_file_path,pdf_file_path) {
// word转pdf
var pdf_file_path_new = pdf_file_path + '.pdf';
var wordToPdf = new WordToPdf($instance('uncertain.ocm.IObjectRegistry'), "jacob-1.19-x64.dll");
wordToPdf.word2pdf(word_file_path, pdf_file_path_new);
//删除word文件
//deleteFile(word_file_path);
return pdf_file_path_new;
}
function copyFile(fOld, fNew) {
var fis = new java.io.FileInputStream(fOld);
var fos = new java.io.FileOutputStream(fNew);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 4);
var len = -1;
while ((len = fis.read(b)) != -1) {
fos.write(b, 0, len);
}
fis.close();
fos.close();
}
function transfer(file_path, os) {
println(file_path);
var fis = new FileInputStream(file_path);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64);
var len = -1;
while ((len = fis.read(b)) != -1) {
os.write(b, 0, len);
}
fis.close();
}
function write_os_to_file(file, os) {
var fis = new FileInputStream(file);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64);
var len = -1;
while ((len = fis.read(b)) != -1) {
os.write(b, 0, len);
}
fis.close();
}
function download_file(file_name, file_path) {
$ctx["__request_type__"] = 'file'; //to indicate this request is not a JSON_REQUEST
var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
resp.setHeader("Pragma", "No-cache");
resp.setHeader("Cache-Control", "no-cache, must-revalidate");
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(file_name, 'UTF-8'));
var os = resp.getOutputStream();
//transfer(file_path, os);
write_os_to_file(file_path, os);
os.flush();
}
//按日期创建目录
function getDatePath() {
set_parameter_file_path();
var file_path = $ctx.parameter.pdf_path; //file_path = c:/hls_test_files/content_files/
var now = new Date()
y = now.getFullYear()
m = now.getMonth() + 1
m = m < 10 ? "0" + m : m
var datePath = file_path + y + "/" + m + "/";
return datePath; //datePath = d:/hls_test_files/fileupload/2018/04/
}
function collection_create_content() {
try {
var datePath = getDatePath();
FileUtils.forceMkdir(new File(datePath)); //根据日期创建目录
var attachment_batch_dl = $bm('hls.HLS811.hls_doc_file_templet_get_atm');
var result = attachment_batch_dl.queryAsMap({
document_id: $ctx.parameter.document_id,
document_table: $ctx.parameter.document_table,
batch_flag: $ctx.parameter.batch_flag,
content_id: $ctx.parameter.content_id
});
var from_file_data = result.getChildren();
for (var i = 0;i < from_file_data.length;i++) {
if (!$ctx.parameter.file_path) {
set_parameter_file_path();
}
var to_file_path = $ctx.parameter.file_path;
var record_data = from_file_data[i];
//if (record_data.file_exists_flag != 'Y') {
var to_file_name = record_data.to_file_name;
var from_file_path = record_data.file_path;
var guid_file_name_path = $bm('cont.CON500.con_contract_get_guid_file_name').queryAsMap();
var guid_file_name_tables = guid_file_name_path.getChildren();
to_file_path = datePath + guid_file_name_tables[0].guid_file_name + 'doc' + record_data.content_id;
copyFile(from_file_path, to_file_path);
try {
$bm('csh.CSH501.csh_transaction_return_print').update({
document_id: $ctx.parameter.document_id,
document_table: $ctx.parameter.document_table
});
var brwt = new BookmarksReplaceWithText($instance('leaf.database.service.IDatabaseServiceFactory'), $instance('uncertain.ocm.IObjectRegistry'), $ctx.getData());
brwt.replaceBookmarkFromContent(to_file_path.toString(), record_data.content_id.toString(), 'COMMON');
} catch (e) {
raise_app_error(e);
}
// word转pdf
var pdf_file_path=to_file_path;
var outputfilepath = wordToPdf(to_file_path,pdf_file_path);
//var outputfilename= record_data.to_file_name +'.pdf';
var filename_str = record_data.to_file_name;
var outputfilename= filename_str.substr(0, filename_str.length - 5) +'.pdf';
var pdf_file = new File(outputfilepath);
var file_size = 0;
if (pdf_file.exists()) {
file_size = pdf_file.length();
}
$bm('hls.HLS811.hls_file_content_copy_update').update({
table_name: 'HLS_DOC_FILE_CONTENT',
content_id: record_data.content_id,
file_name: outputfilename.toString(),
file_path: outputfilepath.toString(),
source_type: $ctx.parameter.source_type
});
//var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
//HlsFileUtil.downloadFile(encodeURI(to_file_path,'utf-8'),encodeURI(to_file_name,'utf-8'),resp);
//print(outputfilepath.toString());
//print(outputfilename.toString());
download_file(outputfilename.toString(),outputfilepath.toString());
}
$ctx.parameter.return_status = 'S';
$ctx.parameter.return_message = '执行成功';
} catch (e) {
$ctx.success = "true";
$ctx.parameter.return_status = 'E';
$ctx.parameter.return_message = $ctx.get('/error/@message') || String(e);
raise_app_error(e);
}
var result = {
result: $ctx.parameter.return_status,
message: $ctx.parameter.return_message
};
$ctx.parameter.json = JSON.stringify(result);
}
if ($ctx.parameter.return_status != 'E' && $ctx.parameter.return_status != 'TIMEOUT') {
collection_create_content();
}
]]></s:server-script>
</a:init-procedure>
<a:service-output/>
</a:service>
This diff is collapsed.
...@@ -86,8 +86,13 @@ ...@@ -86,8 +86,13 @@
Leaf.request({ Leaf.request({
url: url, url: url,
para: record.data, para: record.data,
success: function() { success: function(args) {
if (args.result.p_err_msg) {
$L.showConfirm('提示', args.result.p_err_msg, function () {
record.set('period_status_code', 'C');
});
} else {
record.set('period_status_code','C'); record.set('period_status_code','C');
Leaf.SideBar.enable = true; Leaf.SideBar.enable = true;
...@@ -95,7 +100,7 @@ ...@@ -95,7 +100,7 @@
msg: '关闭成功', msg: '关闭成功',
duration: 3000 duration: 3000
}); });
}
}, },
scope: this scope: this
}); });
......
...@@ -351,8 +351,13 @@ ...@@ -351,8 +351,13 @@
Leaf.request({ Leaf.request({
url: url, url: url,
para: record.data, para: record.data,
success: function () { success: function (args) {
if (args.result.p_err_msg) {
$L.showConfirm('提示', args.result.p_err_msg, function () {
record.set('period_status_code', 'C');
});
} else {
record.set('period_status_code', 'C'); record.set('period_status_code', 'C');
Leaf.SideBar.enable = true; Leaf.SideBar.enable = true;
...@@ -360,7 +365,7 @@ ...@@ -360,7 +365,7 @@
msg: '关闭成功', msg: '关闭成功',
duration: 3000 duration: 3000
}); });
}
}, },
scope: this scope: this
}); });
......
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