Commit e00ca296 authored by 18083's avatar 18083

批量下载催收函补充缺少文件

(cherry picked from commit 051ce0c1)
parent 61c1173d
......@@ -21,7 +21,11 @@
url="${/request/@context_path}/modules/cont/CON620/con_contract_account_detail.lview"/>
<a:link id="con_contract_query_link_id"
url="${/request/@context_path}/modules/cont/CON3200/con_re_incept_modify.lview"/>
<a:link id="con_contract_op_query_link_id"
url="${/request/@context_path}/modules/cont/CON3200/con_re_incept_op_modify.lview"/>
<a:link id="con601_send_dun_msg" model="cont.CON620.con620_send_dun_msg" modelaction="execute"/>
<a:link id="contract_rent_download_link_id"
url="${/request/@context_path}/modules/cont/CON620/con_contract_rent_download.lview"/>
<script type="text/javascript"><![CDATA[
function CON601_con_contract_query() {
$('CON620_contract_result_ds').query();
......@@ -35,11 +39,15 @@
function CON620_render_contract_dun_grid(value, record, name) {
if (name == 'contract_number') {
if(record.get('division')!='95'){
if (record.get('overdue_times') > 1) {
return '<u><a style="color:red" href="javascript:contract_detail_link(' + record.id + ',\'' + record.ds.id + '\');">' + value + '</a></u>';
} else {
return '<a href="javascript:contract_detail_link(' + record.id + ',\'' + record.ds.id + '\');">' + value + '</a>';
}
}else {
return '<a href="javascript:contract_op_detail_link(' + record.id + ',\'' + record.ds.id + '\');">' + value + '</a>';
}
} else if (name == 'bp_id_tenant_desc') {
//商业伙伴查询页面要做好,然后在此处关联。
if (record.get('overdue_times') > 1) {
......@@ -151,6 +159,7 @@
param['document_id'] = current_record.get('contract_id');
// con601_param_set_value(param);
param['document_category'] = 'CONTRACT';
param['repurchase_types'] = current_record.get('repurchase_types');
if (current_record.get('contract_status') == 'REPURING') {
param['function_code'] = 'CON620QRP';
} else {
......@@ -189,7 +198,6 @@
}
function contract_business_link(record_id, ds_id) {
debugger;
var current_record = $(ds_id).findById(record_id);
var record = current_record;
var saveData = [];
......@@ -203,6 +211,7 @@
param['document_id'] = current_record.get('contract_id');
// con601_param_set_value(param);
param['document_category'] = 'CONTRACT';
param['repurchase_types'] = current_record.get('repurchase_types');
if (current_record.get('contract_status') == 'REPURING') {
param['function_code'] = 'CON620RP';
} else {
......@@ -239,6 +248,29 @@
hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_query_link_id');
}
//经租合同明细
function contract_op_detail_link(record_id, ds_id) {
var current_record = $(ds_id).findById(record_id);
var record = current_record;
var saveData = [];
for (var k in record.data) {
var item = record.data[k];
if (item && item.xtype == 'dataset') {
delete record.data[k];
}
}
var param = record.data;
param['contract_id'] = current_record.get('contract_id');
param['document_category'] = 'CONTRACT';
param['function_code'] = 'CON3200Q_OP';
param['function_usage'] = 'QUERY';
param['maintain_type'] = 'QUERY';
param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
param['company_id'] = '${/session/@company_id}';
//
hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_op_query_link_id');
}
function summaryRenderer(datas, name) {
var sum = 0;
var sum2 = 0;
......@@ -365,6 +397,10 @@
var no_send_message = '';
//判断单据的状态
for (var i = 0; i < records.length; i++) {
if(records[i].get('division') == '95'){
$L.showInfoMessage('提示','经营性租赁业务不支持发送催收短信!');
return;
}
if (contract_ids == '') {
contract_ids = records[i].get('contract_id');
} else {
......@@ -444,6 +480,10 @@
var no_send_message = '';
for (var i = 0; i < records.length; i++) {
if(records[i].get('division') == '95'){
$L.showInfoMessage('提示','经营性租赁业务不支持发送催收短信!');
return;
}
if (contract_ids == '') {
contract_ids = records[i].get('contract_id');
} else {
......@@ -515,6 +555,60 @@
}
}
function MapTOJson(m) {
var str = '{';
var i = 1;
m.forEach(function (item, key, mapObj) {
if (mapObj.size == i) {
str += '"' + key + '":"' + item + '"';
} else {
str += '"' + key + '":"' + item + '",';
}
i++;
});
str += '}';
return str;
}
//批量下载催收函
function CON601_con_contract_download(){
var records = $('CON620_contract_result_ds').getSelected();
var records_repur = $('CON620_contract_repur_result_ds').getSelected();
if (records_repur.length > 0) {
$L.showInfoMessage('提示', '解约回购合同不在批量下载范围!');
return;
}
if (records.length == 0) {
$L.showInfoMessage('提示', '请选择需下载催收函对应的合同!');
return;
}
if (records.length > 10) {
$L.showInfoMessage('提示', '批量下载催收函最多可勾选10个合同,请重新选择!');
return;
}
var r_map = new Map();
for (var i = 0; i < records.length; i++) {
if(!r_map.has(records[i].get('contract_id'))){
var arr = new Array();
arr.add(records[i].get('contract_id'));
r_map.set(records[i].get('contract_id'),arr);
}
}
var result_map = MapTOJson(r_map);
var win = new Leaf.Window({
id: 'contract_rent_download',
url: $('contract_rent_download_link_id').getUrl(),
params: {
result_map : result_map,
winid : 'contract_rent_download_winid'
},
title: '催款函批量打印',
height: 150,
width: 360
});
}
]]></script>
......@@ -525,8 +619,10 @@
<a:datas>
<a:record code_value="LEASE" code_value_name="直租"/>
<a:record code_value="LEASEBACK" code_value_name="售后回租"/>
<a:record code_value="LEASEOPERAT" code_value_name="经营性租赁"/>
</a:datas>
</a:dataSet>
<a:dataSet id="repurchase_types_ds" lookupCode="REPURCHASE_TYPES"/>
<a:dataSet id="CON601_lease_organization_name_ds" loadData="true"
model="basic.hls_lease_organization_for_lov"/>
<a:dataSet id="con620_send_message_ds" lookupCode="SEND_MESSAGE"/>
......@@ -563,6 +659,8 @@
<a:field name="send_message"/>
<a:field name="send_message_n" displayField="code_value_name" options="con620_send_message_ds"
returnField="send_message" valueField="code_value"/>
<a:field name="repurchase_types_n" displayField="code_value_name" options="repurchase_types_ds"
returnField="repurchase_types" valueField="code_value"/>
</a:fields>
</a:dataSet>
<a:dataSet id="CON620_contract_result_ds" autoPageSize="true" autoQuery="true"
......@@ -591,6 +689,7 @@
<a:gridButton click="CON601_con_contract_query" text="HLS.QUERY"/>
<a:gridButton id="msg_money_id" click="CON601_dun_msg_money" text="催收短信发送(含金额)"/>
<a:gridButton id="msg_no_money_id" click="CON601_dun_msg_no_money" text="催收短信发送(无金额)"/>
<a:gridButton id="CON601_con_contract_download_btn" click="CON601_con_contract_download" text="下载催收函"/>
<!--<a:gridButton id="CON601_con_contract_print_btn" click="CON601_con_contract_print" text="打印催收函"/>-->
</a:screenTopToolbar>
......@@ -605,6 +704,7 @@
<a:textField name="bp_id_tenant_desc" bindTarget="CON620_contract_query_ds"
prompt="HLS.TENANT_CODE"/>
<a:textField name="bp_id_agent_desc" bindTarget="CON620_contract_query_ds" prompt="代理店"/>
<a:comboBox name="repurchase_types_n" bindTarget="CON620_contract_query_ds" prompt="回购类型"/>
<a:comboBox name="business_type_n" bindTarget="CON620_contract_query_ds" prompt="业务类型"/>
<a:comboBox name="division_n" bindTarget="CON620_contract_query_ds" prompt="租赁物"/>
<a:numberField name="business_due_days_from" bindTarget="CON620_contract_query_ds"
......@@ -740,7 +840,7 @@
</a:columns>
</a:grid>
</a:tab>
<a:tab prompt="分期回购逾期租金" width="130" id="repur_select_id" tabClassName="repur_class" >
<a:tab prompt="解约回购逾期租金" width="130" id="repur_select_id" tabClassName="repur_class" >
<a:grid id="CON620_contract_repur_result_grid_ds" bindTarget="CON620_contract_repur_result_ds"
marginHeight="215"
marginWidth="50" navBar="true" >
......@@ -754,6 +854,7 @@
<a:column name="bp_id_tenant_desc" lock="true" prompt="承租人名称" showTitle="true"
width="100"
align="center"/>
<a:column name="repurchase_types_n" align="center" prompt="回购类型" width="100"/>
<a:column name="min_overdue_date" align="center" prompt="预定支付日" width="100"
renderer="render_formatDate"/>
<a:column name="min_overdue_times" align="center" prompt="预定支付期数" width="100"/>
......
<?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);
importPackage(Packages.com.hand.hl);
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_pdf_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 get_file_length(path){
var file=new File(String(path));
if(file.exists() && file.isFile()){
length=file.length();
return length;
}else{
return 0 ;
}
}
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 {
//第一步生成合同文本
if($ctx.parameter.templet_code == 'CON_LEASE_GUA'){
$bm('cont.CON620.create_content_for_collection').execute({
contract_id: $ctx.parameter.contract_id,
templet_code: $ctx.parameter.templet_code,
bp_code: $ctx.parameter.bp_code
});
}else {
$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.CON620.con_doc_file_templet_get_atm_batch').queryAsMap({
contract_id: $ctx.parameter.contract_id,
batch_flag:$ctx.parameter.batch_flag,
templet_code: $ctx.parameter.templet_code
});
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());-->
var file_size=get_file_length(to_file_path);
if($ctx.parameter.templet_code == 'CON_LEASE_GUA'){
var lease_type='03';
}else {
lease_type='02'
}
var business_daily_email=$bm('cont.CON301N.insert_into_attachment_bmp').update({
p_file_path :(to_file_path).toString(),
p_file_name :(record_data.file_name+'.docx').toString(),
p_file_size :file_size,
p_user_id :$ctx.session.user_id,
p_contract_id :$ctx.parameter.contract_id,
p_file_type :'WORD',
p_lease_type :lease_type
});
}
}
$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