Commit 425af951 authored by 25484's avatar 25484

Merge branch 'feature/con_contract_rent_detail' into develop

parents dbc770bb 94f7333e
......@@ -9,203 +9,65 @@
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT
*
FROM
(SELECT
cc.contract_id,
cc.contract_status,
cc.contract_name,
(SELECT
pp.project_number
FROM
prj_project pp
WHERE
pp.project_id = cc.project_id
) project_number,
--(select ppb.bp_name from prj_project_bp ppb where ppb.project_id = cc.project_id)bp_name,
cc.bp_id_tenant,
TO_CHAR(cc.inception_of_lease, 'yyyy-mm-dd') inception_of_lease,
(SELECT
COUNT(*)
FROM
con_contract_cashflow ccc
WHERE
ccc.contract_id = cc.contract_id AND
ccc.write_off_flag = 'FULL' AND
ccc.cf_item = 1
) received_times,
(SELECT
hb.bp_name
FROM
hls_bp_master hb,
con_contract_bp ccb
WHERE
hb.bp_category = 'AGENT' AND
ccb.bp_category = 'AGENT' AND
hb.bp_id = ccb.bp_id AND
ccb.contract_id = cc.contract_id
) agent_id_n,
(SELECT
bp_name
FROM
hls_bp_master
WHERE
bp_id = cc.bp_id_tenant AND
enabled_flag = 'Y'
) bp_id_tenant_desc,
cc.contract_number,
cc.bp_id_agent_level1,
(SELECT
bp_name
FROM
hls_bp_master
WHERE
bp_id = cc.bp_id_agent_level1 AND
enabled_flag = 'Y'
) bp_id_agent_desc,
(SELECT
bp_class
FROM
hls_bp_master
WHERE
bp_id = cc.bp_id_agent_level1 AND
enabled_flag = 'Y'
) bp_id_agent_class,
cc.owner_user_id,
(SELECT description FROM sys_user WHERE user_id = cc.owner_user_id
) owner_user_id_desc,
cc.lease_organization,
cc.lease_times,
(SELECT
TO_CHAR(extract(DAY FROM cf.due_date), 'fm09')
FROM
con_contract_cashflow cf
WHERE
cf.cf_item = 1 AND
cf.times = 2 AND
cf.contract_id = cc.contract_id
)
|| '日' AS due_day,
(SELECT
COUNT(*)
FROM
con_contract_cashflow ccc
WHERE
ccc.contract_id = cc.contract_id AND
ccc.write_off_flag = 'FULL' AND
cf_item = 1 AND
cf_direction = 'INFLOW'
) recieved_times,
(SELECT
description
FROM
hls_lease_organization
WHERE
lease_organization = cc.lease_organization AND
enabled_flag = 'Y'
) lease_organization_desc,
(SELECT
phone
--||'|'
--|| phone_extra
FROM
hls_bp_master
WHERE
bp_id = cc.bp_id_tenant AND
enabled_flag = 'Y'
) tenant_phone_number,
NVL(cc.overdue_max_days, 0) overdue_days,
(SELECT
COUNT(*)
FROM
con_contract_cashflow
WHERE
contract_id = cc.contract_id AND
write_off_flag <> 'FULL' AND
cf_item = 1 AND
cf_direction = 'INFLOW' AND
due_date <= SYSDATE
) overdue_times,
(SELECT
SUM(NVL(c.due_amount, 0))
FROM
con_contract_cashflow c
WHERE
c.contract_id = cc.contract_id AND
c.cf_item = 51
) deposit,
(SELECT
SUM(NVL(due_amount, 0) - NVL(received_amount, 0))
FROM
con_contract_cashflow
WHERE
contract_id = cc.contract_id AND
due_date <= SYSDATE AND
cf_item = 1 AND
cf_direction = 'INFLOW'
) overdue_amount,
(SELECT
SUM(NVL(due_amount, 0) - NVL(received_amount, 0))
FROM
con_contract_cashflow
WHERE
contract_id = cc.contract_id AND
cf_item = 9 AND
cf_direction = 'INFLOW'
) penalty,
(SELECT
SUM(NVL(principal, 0) - NVL(received_principal, 0))
FROM
con_contract_cashflow
WHERE
contract_id = cc.contract_id AND
cf_item = 1 AND
cf_direction = 'INFLOW'
) remain_principal,
cc.data_class,
cc.pmt,
(SELECT
promised_return_date
FROM
con_dun_record
WHERE
contract_id = cc.contract_id AND
con_dun_id =
(SELECT MAX(con_dun_id) FROM con_dun_record
)
) promised_return_date,
(SELECT
promised_return_amount
FROM
con_dun_record
WHERE
contract_id = cc.contract_id AND
con_dun_id =
(SELECT MAX(con_dun_id) FROM con_dun_record
)
) promised_return_amount,
(SELECT
b.code_value_name
FROM
con_dun_record a,
sys_code_values_v b
WHERE
contract_id = cc.contract_id AND
b.code = 'CELLECTION_STATUS' AND
b.code_value = a.status AND
con_dun_id =
(SELECT MAX(con_dun_id) FROM con_dun_record
)
) status_desc
FROM
con_contract cc
) t1 #WHERE_CLAUSE#
]]></bm:query-sql>
SELECT *
FROM (SELECT cc.contract_id,
cc.contract_status,
cc.contract_name,
(SELECT pp.project_number
FROM prj_project pp
WHERE pp.project_id = cc.project_id) project_number,
cc.bp_id_tenant,
TO_CHAR(cc.inception_of_lease, 'yyyy-mm-dd') inception_of_lease,
(SELECT hb.bp_name
FROM hls_bp_master hb, con_contract_bp ccb
WHERE hb.bp_category = 'AGENT'
AND ccb.bp_category = 'AGENT'
AND hb.bp_id = ccb.bp_id
AND ccb.contract_id = cc.contract_id) agent_id_n,
(SELECT bp_name
FROM hls_bp_master
WHERE bp_id = cc.bp_id_tenant
AND enabled_flag = 'Y') bp_id_tenant_desc,
cc.contract_number,
cc.bp_id_agent_level1,
(SELECT bp_name
FROM hls_bp_master
WHERE bp_id = cc.bp_id_agent_level1
AND enabled_flag = 'Y') bp_id_agent_desc,
cc.owner_user_id,
(SELECT description
FROM sys_user
WHERE user_id = cc.owner_user_id) owner_user_id_desc,
cc.lease_organization,
cc.lease_times,
(SELECT description
FROM hls_lease_organization
WHERE lease_organization = cc.lease_organization
AND enabled_flag = 'Y') lease_organization_desc,
(SELECT a.description value_name
FROM HLS_BUSINESS_TYPE_V a
WHERE A.enabled_flag = 'Y'
AND A.business_type = cc.business_type) business_type_n,
cc.data_class,
(select hd.description
from hls_division hd
where hd.enabled_flag = 'Y'
and hd.division = cc.division) division_n,
cc.division
FROM con_contract cc
where exists (select 1
from con_contract_cashflow ccw
where ccw.contract_id = cc.contract_id
and ccw.overdue_status = 'Y'
and ccw.write_off_flag <> 'FULL')) t1 #WHERE_CLAUSE#
]]>
</bm:query-sql>
</bm:operation>
</bm:operations>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="contract_number like upper(&apos;%&apos;||${@contract_number}||&apos;%&apos;)"/>
<bm:query-field name="contract_number"
queryExpression="contract_number like upper(&apos;%&apos;||${@contract_number}||&apos;%&apos;)"/>
<bm:query-field name="bp_id_tenant" queryExpression="t1.bp_id_tenant = ${@bp_id_tenant}"/>
<bm:query-field name="contract_name" queryExpression="t1.contract_name = ${@contract_name}"/>
<bm:query-field name="project_number" queryExpression="t1.project_number = ${@project_number}"/>
......@@ -213,15 +75,19 @@
<!-- <bm:query-field name="lease_start_date_from" queryExpression="t1.inception_of_lease &gt;=to_date(${@lease_start_date_from},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="lease_start_date_to" queryExpression="t1.inception_of_lease &lt;=to_date(${@lease_start_date_to},&apos;yyyy-mm-dd&apos;)"/>
-->
<bm:query-field name="lease_start_date_from" queryExpression="t1.inception_of_lease &gt;=${@lease_start_date_from}"/>
<bm:query-field name="lease_start_date_to" queryExpression="t1.inception_of_lease &lt;=${@lease_start_date_to}"/>
<bm:query-field name="lease_start_date_from"
queryExpression="t1.inception_of_lease &gt;=${@lease_start_date_from}"/>
<bm:query-field name="lease_start_date_to"
queryExpression="t1.inception_of_lease &lt;=${@lease_start_date_to}"/>
<bm:query-field name="lease_times_from" queryExpression="t1.lease_times &gt;=${@lease_times_from}"/>
<bm:query-field name="lease_times_to" queryExpression="t1.lease_times &lt;=${@lease_times_to}"/>
<bm:query-field name="received_times_from" queryExpression="t1.received_times &gt;=${@received_times_from}"/>
<bm:query-field name="received_times_to" queryExpression="t1.received_times &lt;=${@received_times_to}"/>
<bm:query-field name="agent_id_n" queryExpression="t1.agent_id_n = ${@agent_id_n}"/>
<bm:query-field name="promised_return_date_from" queryExpression="t1.promised_return_date &gt;= to_date(${@promised_return_date_from},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="promised_return_date_to" queryExpression="t1.promised_return_date &lt;= to_date(${@promised_return_date_to},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="promised_return_date_from"
queryExpression="t1.promised_return_date &gt;= to_date(${@promised_return_date_from},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="promised_return_date_to"
queryExpression="t1.promised_return_date &lt;= to_date(${@promised_return_date_to},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="overdue_times" queryExpression="t1.overdue_times = ${@overdue_times}"/>
<bm:query-field name="overdue_days_from" queryExpression="overdue_days &gt;= ${@overdue_days_from}"/>
<bm:query-field name="overdue_days_to" queryExpression="overdue_days &lt;= ${@overdue_days_to}"/>
......@@ -229,11 +95,10 @@
<bm:query-field name="due_amount_to" queryExpression="t1.pmt &lt;= ${@due_amount_to}"/>
<bm:query-field name="owner_user_id" queryExpression="t1.owner_user_id = ${@owner_user_id}"/>
<bm:query-field name="lease_organization" queryExpression="t1.lease_organization = ${@lease_organization}"/>
<bm:query-field name="phone" queryExpression="exists (select 1 from hls_Bp_master tt1,con_contract_bp tt2 where tt1.bp_id = tt2.bp_id and tt2.contract_id = t1.contract_id and (phone_extra like &apos;%&apos; || ${@phone} || &apos;%&apos; or phone like &apos;%&apos; || ${@phone} || &apos;%&apos; or phone_2 like &apos;%&apos; || ${@phone} || &apos;%&apos;))"/>
<bm:query-field name="due_days" queryExpression="exists (select 1 from con_contract_cashflow cf where cf.cf_item = 1 and cf.times = 2 and cf.contract_id = t1.contract_id and extract(day from cf.due_date) = ${@due_days})"/>
</bm:query-fields>
<bm:data-filters>
<bm:data-filter name="contract_status" enforceOperations="query" expression="t1.contract_status = &apos;INCEPT&apos;"/>
<bm:data-filter name="contract_status" enforceOperations="query"
expression="t1.contract_status = &apos;INCEPT&apos;"/>
<!-- <bm:data-filter name="overdue_days" enforceOperations="query" expression="t1.overdue_days &gt; 0"/> -->
<!-- <bm:data-filter enforceOperations="query" expression="exists (select 1 from con_contract_cashflow where contract_id = t1.contract_id and cf_type = 9 and due_amount != nvl(received_amount,0) and generated_source not in (&apos;CREATE&apos;))"/> -->
<bm:data-filter enforceOperations="query" expression="t1.data_class = &apos;NORMAL&apos;"/>
......
......@@ -27,8 +27,14 @@
modelaction="update"/>
<a:link id="con_contract_rent_dun_print_link"
url="${/request/@context_path}/modules/cont/CON620/con_contract_rent_dun_print_excel.lsc"/>
<a:link id="con_create_content_print_link"
<a:link id="con_lease_org_print_link"
url="${/request/@context_path}/modules/cont/CON620/create_content_for_collection.lsc"/>
<a:link id="con_lease_confirm_print_link"
url="${/request/@context_path}/modules/cont/CON620/create_content_con_lease_confirm.lsc"/>
<a:link id="con_lease_print_link"
url="${/request/@context_path}/modules/cont/CON620/create_content_con_lease.lsc"/>
<a:link id="lease_return_print_link"
url="${/request/@context_path}/modules/cont/CON620/create_content_lease_return.lsc"/>
<script type="text/javascript"><![CDATA[
Ext.ux.Lightbox.register('a[ref=img]', true);
......@@ -41,26 +47,28 @@
$('CONTRACT_LEGAL_MODIFY_G_CASHFLOW_con_contract_cashflow_ds').query();
};
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {debugger;
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
var contract_id = '${/parameter/@document_id}';
var templet_code = 'CON_LEASE_ORG';
var url=$('con_create_content_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code;
var url=$('con_lease_org_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code;
window.open(url, '_self');
};
window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function () {
var contract_id = '${/parameter/@document_id}';
var templet_code = 'CON_LEASE';
window.open($('con_create_content_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code, "_self");
var templet_code = 'CON_LEASE_CONFIRM';
var url=$('con_lease_confirm_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code;
window.open(url, '_self');
};
window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function () {
var contract_id = '${/parameter/@document_id}';
var templet_code = 'CON_LEASE_CONFIRM';
window.open($('con_create_content_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code, "_self");
var templet_code = 'CON_LEASE';
var url=$('con_lease_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code;
window.open(url, '_self');
};
window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function () {
var contract_id = '${/parameter/@document_id}';
var templet_code = 'LEASE_RETURN';
window.open($('con_create_content_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code, "_self");
window.open($('lease_return_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code, "_self");
};
function view_pdf(attachment_id) {
......
<?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>
<s:server-script import="con_print_path.js"><![CDATA[
importPackage(java.io);
importPackage(Packages.hls.plugin.docx4j)
importPackage(Packages.org.apache.commons.io);
function RandomString(length) {   
var str = '';   
for (;str.length < length;str += Math.random().toString(36).substr(2));   
return str.substr(0, length); 
}
//删除文件
function deleteFile(filePath) {
var file = new File(filePath);
if (file.exists()) {
file.delete();
}
}
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 getDatePath() {
set_parameter_file_path();
var file_path = $ctx.parameter.file_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 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_path, file_name) {
$ctx["__request_type__"] = 'file';
var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
resp.setHeader("Pragma", "No-cache");
resp.setHeader("Cache-Control", "no-cache, must-revalidate");
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(file_name, 'utf-8'));
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
try {
var os = resp.getOutputStream();
write_os_to_file(file_path, os);
//write_os_to_file(file_path+file_name, os);
os.flush();
} catch (e) {
$logger("server-script").severe(e.message);
}
}
function collection_create_content() {
try {
//第一步生成合同文本
$bm('cont.CON620.create_content_for_collection').update({
contract_id: $ctx.parameter.contract_id,
templet_code: $ctx.parameter.templet_code
});
//获取日期目录
set_parameter_file_path();
var datePath = getDatePath();
$ctx.parameter.batch_flag='Y';
FileUtils.forceMkdir(new File(datePath)); //根据日期创建目录
var from_file_data_map = $bm('cont.CON500.con_doc_file_templet_get_atm').queryAsMap({
contract_id: $ctx.parameter.contract_id,
batch_flag:$ctx.parameter.batch_flag,
});
var from_file_data = from_file_data_map.getChildren();
for (var i = 0;i < from_file_data.length;i++) {
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 + '.' + record_data.file_type_code || 'doc';
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 + 'con' + record_data.content_id;
copyFile(from_file_path, to_file_path);
try {
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);
} catch (e) {
raise_app_error(e);
}
$bm('cont.CON500.con_file_content_copy_update').update({
table_name: 'CON_CONTRACT_CONTENT',
content_id: record_data.content_id,
file_name: to_file_name.toString(),
file_path: to_file_path.toString()
});
var test=new File(to_file_path);
var test1=new File('D:'+to_file_path);
download_file(to_file_path.toString(),to_file_name.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>
<?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>
<s:server-script import="con_print_path.js"><![CDATA[
importPackage(java.io);
importPackage(Packages.hls.plugin.docx4j)
importPackage(Packages.org.apache.commons.io);
function RandomString(length) {   
var str = '';   
for (;str.length < length;str += Math.random().toString(36).substr(2));   
return str.substr(0, length); 
}
//删除文件
function deleteFile(filePath) {
var file = new File(filePath);
if (file.exists()) {
file.delete();
}
}
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 getDatePath() {
set_parameter_file_path();
var file_path = $ctx.parameter.file_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 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_path, file_name) {
$ctx["__request_type__"] = 'file';
var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
resp.setHeader("Pragma", "No-cache");
resp.setHeader("Cache-Control", "no-cache, must-revalidate");
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(file_name, 'utf-8'));
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
try {
var os = resp.getOutputStream();
write_os_to_file(file_path, os);
//write_os_to_file(file_path+file_name, os);
os.flush();
} catch (e) {
$logger("server-script").severe(e.message);
}
}
function collection_create_content() {
try {
//第一步生成合同文本
$bm('cont.CON620.create_content_for_collection').update({
contract_id: $ctx.parameter.contract_id,
templet_code: $ctx.parameter.templet_code
});
//获取日期目录
set_parameter_file_path();
var datePath = getDatePath();
$ctx.parameter.batch_flag='Y';
FileUtils.forceMkdir(new File(datePath)); //根据日期创建目录
var from_file_data_map = $bm('cont.CON500.con_doc_file_templet_get_atm').queryAsMap({
contract_id: $ctx.parameter.contract_id,
batch_flag:$ctx.parameter.batch_flag,
});
var from_file_data = from_file_data_map.getChildren();
for (var i = 0;i < from_file_data.length;i++) {
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 + '.' + record_data.file_type_code || 'doc';
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 + 'con' + record_data.content_id;
copyFile(from_file_path, to_file_path);
try {
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);
} catch (e) {
raise_app_error(e);
}
$bm('cont.CON500.con_file_content_copy_update').update({
table_name: 'CON_CONTRACT_CONTENT',
content_id: record_data.content_id,
file_name: to_file_name.toString(),
file_path: to_file_path.toString()
});
var test=new File(to_file_path);
var test1=new File('D:'+to_file_path);
download_file(to_file_path.toString(),to_file_name.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>
<?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>
<s:server-script import="con_print_path.js"><![CDATA[
importPackage(java.io);
importPackage(Packages.hls.plugin.docx4j)
importPackage(Packages.org.apache.commons.io);
function RandomString(length) {   
var str = '';   
for (;str.length < length;str += Math.random().toString(36).substr(2));   
return str.substr(0, length); 
}
//删除文件
function deleteFile(filePath) {
var file = new File(filePath);
if (file.exists()) {
file.delete();
}
}
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 getDatePath() {
set_parameter_file_path();
var file_path = $ctx.parameter.file_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 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_path, file_name) {
$ctx["__request_type__"] = 'file';
var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
resp.setHeader("Pragma", "No-cache");
resp.setHeader("Cache-Control", "no-cache, must-revalidate");
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(file_name, 'utf-8'));
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
try {
var os = resp.getOutputStream();
write_os_to_file(file_path, os);
//write_os_to_file(file_path+file_name, os);
os.flush();
} catch (e) {
$logger("server-script").severe(e.message);
}
}
function collection_create_content() {
try {
//第一步生成合同文本
$bm('cont.CON620.create_content_for_collection').update({
contract_id: $ctx.parameter.contract_id,
templet_code: $ctx.parameter.templet_code
});
//获取日期目录
set_parameter_file_path();
var datePath = getDatePath();
$ctx.parameter.batch_flag='Y';
FileUtils.forceMkdir(new File(datePath)); //根据日期创建目录
var from_file_data_map = $bm('cont.CON500.con_doc_file_templet_get_atm').queryAsMap({
contract_id: $ctx.parameter.contract_id,
batch_flag:$ctx.parameter.batch_flag,
});
var from_file_data = from_file_data_map.getChildren();
for (var i = 0;i < from_file_data.length;i++) {
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 + '.' + record_data.file_type_code || 'doc';
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 + 'con' + record_data.content_id;
copyFile(from_file_path, to_file_path);
try {
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);
} catch (e) {
raise_app_error(e);
}
$bm('cont.CON500.con_file_content_copy_update').update({
table_name: 'CON_CONTRACT_CONTENT',
content_id: record_data.content_id,
file_name: to_file_name.toString(),
file_path: to_file_path.toString()
});
var test=new File(to_file_path);
var test1=new File('D:'+to_file_path);
download_file(to_file_path.toString(),to_file_name.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>
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