Commit bd016526 authored by 18083's avatar 18083

新业务厂商及非银企直连流程经租追加调整

parent 435cacb8
<?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_num vender_bank_account_number,
t.bank_account_name vender_bank_account_name,
bank_account_id vender_bank_account_id,
t.bank_full_name vender_bank_full_name,
(select bp_name from hls_bp_master hbm where hbm.bp_id=t.bp_id) vender_name
from hls_bp_master_bank_account_v t
where t.bp_id = (
select hli.vender_id
from hls_lease_item hli,con_contract_lease_item ccli
where hli.lease_item_id=ccli.lease_item_id
and ccli.contract_id=${/parameter/@contract_id}
)
and t.enabled_flag = 'Y'
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
......@@ -63,7 +63,7 @@
param['req_status'] = req_status;
param['url_title'] = '合同回购';
if (req_status == 'APPROVED' || req_status == 'APPROVING' || req_status == 'CANCEL') {
if (req_status == 'APPROVED' || req_status == 'APPROVING' || req_status == 'CANCEL'|| req_status == 'REJECT') {
param['maintain_type'] = 'READONLY';
param['function_code'] = 'CON_REPO001D_Q';
} else {
......
<?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><![CDATA[
importPackage(java.util.zip);
importPackage(java.io); /*可以传入参数*/
function writeFile(zos, fn, fp) {
var ze = new ZipEntry(fn);
zos.putNextEntry(ze);
var fis = new FileInputStream(fp);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64);
var len = -1;
while ((len = fis.read(b)) != -1) {
zos.write(b, 0, len);
}
fis.close();
}
function transfer(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 getdate() {
var now = new Date()
y = now.getFullYear()
m = now.getMonth() + 1
d = now.getDate()
m = m < 10 ? "0" + m : m
d = d < 10 ? "0" + d : d
return y + "" + m + "" + d
}
$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");
var date_str = getdate();
var doc_code = '付款请求书'
var zip_filename = doc_code + '-' + date_str + ".zip";
var file_path;
var fnd_atm_flag = $ctx.parameter.fnd_atm_flag;
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
try {
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 arr = result.getChildren();
if (arr.length == 1) {
//单个下载
file_name = arr[0].download_file_name;
if (fnd_atm_flag == 'Y') {
file_path = arr[0].download_file_path;
} else {
file_path = arr[0].download_file_path + file_name;
}
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(file_name, 'utf-8'));
var os = resp.getOutputStream();
transfer(file_path, os);
os.flush();
} else if (arr.length > 1) {
//打包下载
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(zip_filename));
var zos = new ZipOutputStream(resp.getOutputStream());
var file_exist_list = {};
for (var i = 0;i < arr.length;i++) {
var f = arr[i];
if (f.download_file_path && !file_exist_list[f.download_file_name]) {
writeFile(zos, f.download_file_name, f.download_file_path);
file_exist_list[f.download_file_name] = 1;
} else {
file_exist_list[f.download_file_name] = file_exist_list[f.download_file_name] * 1 + 1;
var last_index = f.download_file_name.lastIndexOf(".");
var temp_exists_file_name = f.download_file_name.substr(0, last_index);
var temp_exists_file_type = f.download_file_name.substr(last_index, f.download_file_name.length);
temp_exists_file_name = temp_exists_file_name + '-' + file_exist_list[f.download_file_name] + temp_exists_file_type;
writeFile(zos, temp_exists_file_name, f.download_file_name);
}
}
zos.close();
}
} catch (e) {
println(e);
var logger = $logger("server-script");
logger.severe(e.message);
}
]]></s:server-script>
</a:init-procedure>
</a:service>
......@@ -36,6 +36,8 @@
<!-- 生成Excel文件-->
<a:link id="tre_loan_con_print_excel_link_id"
url="${/request/@context_path}/modules/csh/CSH501/csh_payment_contract_export.lsc"/>
<a:link id="csh_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
<a:link id="csh_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
<script type="text/javascript"><![CDATA[
jQuery.noConflict();
......@@ -359,7 +361,7 @@
var payment_req_id = hd_record.get('payment_req_id');
//获得相应的行信息
var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
var cdd_file_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hl_cm_cdd_file_list');
$(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_op_query_after_save/query');
......@@ -388,6 +390,10 @@
$(lnds_id).setQueryParameter('payment_req_id', payment_req_id);
$(lnds_id).query();
//保存成功,刷新附件数据 18083 2024/4/22
$(cdd_file_id).setQueryParameter('payment_req_id', payment_req_id);
$(cdd_file_id).query();
} else {
Leaf.showMessage('${l:PROMPT}', '请先保存数据');
......@@ -411,11 +417,56 @@
hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'con_rd_wfl_link', '', '${/parameter/@layout_code}');
}
function upload_csh_file(id,name,record_id,item_code) {
var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
if (item_code=='INVOICE') {
var url = $('csh_uploadFile_id').getUrl() + '?table_name=INVOICE&header_id=' + record_id;
}else if(item_code=='PAYMENT_REQUEST_LETTER'){
var url = $('csh_uploadFile_id').getUrl() + '?table_name=PAYMENT_REQUEST_LETTER&header_id=' + record_id;
}else if(item_code=='OTHERS'){
var url = $('csh_uploadFile_id').getUrl() + '?table_name=OTHERS&header_id=' + record_id;
}
var win = new Leaf.Window({
url: url,
title: '${l:HLS.SUPPORTING_DOCUMENT}',
id: 'csh_attachment_uploadFile_id',
width: 850,
height: 400
});
win.on('close', function () {
record.ds.query();
});
}
window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record, bp_seq) {
var link_function = '';
window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
if (name == 'project_number' && value) {
return '<a href="javascript:open_pur_project_readonly_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
}else if (name == 'attachment'){
return '<a href=javascript:upload_csh_file(\''+record.id+'\',\''+ name + '\',\'' +record.get('payment_req_id')+'\',\'' + record.get('item_code')+'\')>附件上传</a>';
} else if (name == 'attach_file_name') {
if (value != null) {
var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
var str = value.split(';;');
var url = '';
for (var i = 0; i < str.length; i++) {
var temp = str[i].split('--');
if (!Leaf.isEmpty(temp[0])) {
var file_name = temp[0].toUpperCase();
var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
url = url + '<a href=' + link + temp[1] + ' ref="img">' + temp[0] + '</a>' + ',';
} else {
url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
}
}
}
return url;
}
}
};
window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function (ds, qpara, bp_seq) {
......
......@@ -21,10 +21,14 @@
defaultWhereClause=" document_category=&apos;PAYMENT_REQ&apos; and document_type=&apos;STD_PAYMENT_REQ&apos;"
fetchAll="true" model="hls.HLS003.hls_document_type" rootPath="default_payment_document_type"/>
<a:model-query fetchAll="true" model="csh.CSH501.get_loan_flag" rootPath="loan_flag_path"/>
<a:model-query fetchAll="true" model="csh.CSH501.get_vender_bank_info" rootPath="vender_account_path"/>
</a:init-procedure>
<a:view>
<a:link id="csh_payment_req_word_print_link_id"
url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_word_print.lsc"/>
<a:link id="csh_payment_req_bo_pdf_print_link_id"
url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_bo_pdf_print.lsc"/>
<a:link id="csh_batch_pdf_dl_link_id" url="${/request/@context_path}/modules/csh/CSH501/csh_atm_batch_dl.lsc"/>
<a:link id="csh501d_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
modelaction="update"/>
<a:link id="update_csh_payment_hd_info_link" model="csh.CSH501.csh_payment_req_get_num" modelaction="execute"/>
......@@ -231,16 +235,8 @@
}
}
var lnds_records = $(ds_id).getAll();
if (ds.id == ds_id) {
for (var i = 0; i < lnds_records.length; i++) {
if (lnds_records[i].get('division') == '70' || lnds_records[i].get('division') == '92') {
lnds_records[i].getField('tenant_bank_account_number').setRequired(false);
lnds_records[i].getField('tenant_bank_account_number_n').setRequired(false);
}
}
}
if (con_business_type == 'LEASEBACK'){
if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'){
if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'||'${/parameter/@division}' ==93||'${/parameter/@division}' =='新业务-厂商担保'){
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
var records = $(ds_id).getAll();
for (i = 0; i < records.length; i++) {
......@@ -278,11 +274,25 @@
records[i].getField('amount_tenant').setRequired(false);
records[i].getField('amount_tenant').setReadOnly(true);
if(con_business_type == 'LEASEBACK'){
if (records[i].get('division') =='91'||records[i].get('division') =='93'){
records[i].getField('tenant_bank_account_number').setRequired(false);
records[i].getField('tenant_bank_account_number_n').setRequired(false);
}else{
records[i].getField('tenant_bank_account_number').setRequired(true);
records[i].getField('tenant_bank_account_number_n').setRequired(true);
}
}
}
}
var lnds_records = $(ds_id).getAll();
if (ds.id == ds_id) {
for (var i = 0; i < lnds_records.length; i++) {
if (lnds_records[i].get('division') == '70' || lnds_records[i].get('division') == '92') {
lnds_records[i].getField('tenant_bank_account_number').setRequired(false);
lnds_records[i].getField('tenant_bank_account_number_n').setRequired(false);
}
}
}
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
};
......@@ -299,6 +309,16 @@
var pre_date = [new Date().getFullYear(), new Date().getMonth() + 1, 20].join('-');
record.set('apply_pay_date', pre_date);
}
if (record.get('division') == '93'){
if (!record.get('vender_bank_account_number')||!record.get('vender_bank_account_name')) {
records[i].set('vender_bank_account_number', '${/model/vender_account_path/record/@vender_bank_account_number}');
records[i].set('vender_bank_account_number_n', '${/model/vender_account_path/record/@vender_bank_account_number}');
records[i].set('vender_bank_full_name', '${/model/vender_account_path/record/@vender_bank_full_name}');
records[i].set('vender_bank_account_name','${/model/vender_account_path/record/@vender_bank_account_name}');
records[i].set('vender_bank_account_id', '${/model/vender_account_path/record/@vender_bank_account_id}');
}
}
$(lnds_id).create(Ext.apply({}, record.data));
if (con_business_type == 'LEASE') {
var ln_record = $(lnds_id).getCurrentRecord();
......@@ -345,10 +365,12 @@
//买断机 应付承租人金额为必填项 应付我司金额为只读项且默认为0 承租人账号必填
records[i].getField('amount_tenant').setRequired(true);
records[i].getField('amount_agent').setReadOnly(true);
}else{
//非买断机 应付承租人金额为只读项,默认为0,承租人账号为非必填 应付我司金额为只读项且默认为0 委托付款金额为必填项(界面已配置)
records[i].getField('amount_tenant').setReadOnly(true);
records[i].getField('amount_agent').setReadOnly(true);
}
if(records[i].get('amount_tenant') > 0){
records[i].getField('tenant_bank_account_number').setRequired(true);
......@@ -364,23 +386,37 @@
records[i].getField('amount_tenant').setRequired(false);
records[i].getField('amount_tenant').setReadOnly(true);
if(con_business_type == 'LEASEBACK'){
if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'||'${/parameter/@division}' ==93||'${/parameter/@division}' =='新业务-厂商担保'){
records[i].getField('tenant_bank_account_number').setRequired(false);
records[i].getField('tenant_bank_account_number_n').setRequired(false);
}else{
records[i].getField('tenant_bank_account_number').setRequired(true);
records[i].getField('tenant_bank_account_number_n').setRequired(true);
}
}
}
}
//end
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}
function csh_payment_req_submit_finally() {
Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function okFun() {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
var hd_record = $(ds_id).getCurrentRecord();
var payment_req_id = hd_record.get('payment_req_id');
var line_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
var line_record = $(line_ds_id).getAt(0);
var line_record_all = $(line_ds_id).getAll();
var flag = false;
for (var j = 0; j < line_record_all.length; j++) {
if( line_record_all[j].get('division')=='93' && line_record_all[j].get('amount_vender') == 0 && line_record_all[j].get('is_buyout')=='N'){
flag = true;
break;
}
}
if(flag){
Leaf.showConfirm('${l:HLS.PROMPT}', '是否买断机为否,请确认全部支付代理店!', function okFun() {
Leaf.request({
url: '${/request/@context_path}/autocrud/csh.CSH501.upd_csh_payment_sub_flag/execute',
para: {
......@@ -411,17 +447,75 @@
Leaf.SideBar.enable = true;
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
});
}else{
Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function okFun() {
Leaf.request({
url: '${/request/@context_path}/autocrud/csh.CSH501.upd_csh_payment_sub_flag/execute',
para: {
payment_req_id: payment_req_id,
_status: 'execute'
},
success: function (res) {
Leaf.SideBar.enable = true;
Leaf.SideBar.show({
msg: '${l:HLS.SUBMIT_SUCCESS}',
duration: 2000
});
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
$('${/parameter/@winid}').close();
},
failure: function () {
Leaf.SideBar.enable = true;
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
error: function () {
Leaf.SideBar.enable = true;
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
scope: this
});
// }
}, function cancelFun() {
Leaf.SideBar.enable = true;
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
});
}
}
//打印
function csh501_print() {
var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
var hd_record = $(hdds_id).getCurrentRecord();
if(hd_record.get('con_division')=='93'){
//新业务-厂商付款请求书打印
// 锁屏
Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
Leaf.request({
url: $('csh_payment_req_bo_pdf_print_link_id').getUrl() + '?document_id=' + hd_record.get('payment_req_id') + '&document_table=CSH_PAYMENT_REQ&file_path=${/parameter/@file_path}&batch_flag=Y&source_type=COMMON',
success: function() {
// 下载
var doc_code = '付款请求书';
var url_l = $('csh_batch_pdf_dl_link_id').getUrl() + '?document_id=' + hd_record.get('payment_req_id') + '&document_table=CSH_PAYMENT_REQ&batch_flag=Y&doc_code=' + encodeURI(doc_code) + '&fnd_atm_flag=Y';
window.open(href = url_l, target = "_self");
Leaf.Masker.unmask(Ext.getBody());
},
error: function() {
Leaf.Masker.unmask(Ext.getBody());
},
failure: function() {
Leaf.Masker.unmask(Ext.getBody());
},
scope: this
});
}else{
var url_l = $('csh_payment_req_word_print_link_id').getUrl() + '?document_id=' + hd_record.get('payment_req_id') + '&document_table=CSH_PAYMENT_REQ&file_path=${/parameter/@file_path}&batch_flag=Y&source_type=COMMON';
window.open(href = url_l, target = "_self");
}
}
window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function () {
Leaf.SideBar.enable = false;
window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK'](csh_payment_req_submit_finally);
......@@ -525,12 +619,16 @@
}
} else if (con_business_type == 'LEASEBACK') {
var entrusted_amount = get_current_amount(line_data.get('entrusted_amount'));
if (plus(plus(amount_agent, amount_vender),repur_con_ddct_amt) != entrusted_amount && is_constru_unit != 'Y') {
$L.showErrorMessage("提示", '应付代理店金额、应付厂商金额、回购租金抵冲金额合计不等于合同签约时承租人所填写委托付款金额,请重新填写!',null,500,300);
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return false;
}
if (plus(plus(plus(plus(amount_agent, amount_vender), other_payment2), repur_con_ddct_amt), amount_tenant) != due_amount) {
$L.showErrorMessage("提示", '应付我司金额,委托付款金额,应付承租人金额,首付款抵冲金额和回购租金抵冲金额之和应等于应付金额!',null,500,300);
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return false;
}
//add by 18938
if(is_constru_unit == 'Y'){
if(plus(plus(plus(other_payment2, amount_tenant), amount_vender), repur_con_ddct_amt) != lease_item_amount){
......@@ -541,6 +639,14 @@
}
//end
}
//新业务厂商全部支付给代理店且买断机为否,增加弱校验 18083
/*if (amount_vender == 0 && line_data.get('division') == '93' && line_data.get('is_buyout')=='N') {
$L.showConfirm('提示','是否买断机为否,请确认全部支付代理店!', function () {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return true;
});
$L.showInfoMessage('提示', '是否买断机为否,请确认全部支付代理店!');
}*/
//本次申请金额等于委托加我司加应付承租人金额
var this_apply_amount = plus(plus(amount_agent, amount_vender),amount_tenant);
......@@ -674,13 +780,11 @@
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME_prompt').style.display = 'none';
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME').style.display = 'none';
}
if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_BRANCH_NAME')){
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_BRANCH_NAME_prompt').style.display = 'none';
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_BRANCH_NAME').style.display = 'none';
}
}
//add by 18938
if(is_constru_unit == 'Y'){
if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID')){
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID_prompt').style.display = 'block';
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID').style.display = 'block';
......@@ -697,8 +801,10 @@
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME_prompt').style.display = 'block';
document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME').style.display = 'block';
}
}
//end
}
};
//保存submitsuccess调用
......@@ -836,7 +942,6 @@
}
]]></script>
<a:link id="${/parameter/@layout_code}csh511_csh_payment_req_hd_query" model="csh.CSH511.csh_payment_req_hd"
modelaction="query"/>
......
<?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="con_print_path.js"><![CDATA[
importPackage(Packages.hls.plugin.docx4j);
importPackage(java.io);
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 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);
os.flush();
}
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];
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 = to_file_path + guid_file_name_tables[0].guid_file_name + 'doc' + record_data.content_id;
copyFile(from_file_path, to_file_path);
$bm('hls.HLS811.hls_file_content_copy_update').update({
table_name: 'HLS_DOC_FILE_CONTENT',
content_id: record_data.content_id,
file_name: to_file_name.toString(),
file_path: to_file_path.toString(),
source_type: $ctx.parameter.source_type
});
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.toString(), 'COMMON');
//download_file(to_file_name, to_file_path);
} catch (e) {
raise_app_error(e);
}
}
]]></s:server-script>
</a:init-procedure>
</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