Commit cb54a2f1 authored by congzhao's avatar congzhao

[建机]电子合同开发 邮件发送附件问题修改

parent fc31231a
......@@ -13,12 +13,18 @@
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT *
FROM (select 'N' pilot_run_flag,
su.user_id
from sys_user su
where su.user_name not in ('HAND'))
FROM (select 'Y' pilot_run_flag,
ee.user_id
from EXP_EMPLOYEE_ASSIGNS_V ee
where ee.enabled_flag = 'Y'
and ee.unit_code in ('401', '361', '421')
union all
select 'Y' pilot_run_flag,
su.user_id
from sys_user_v su
where su.user_id in ('1'))
t1 #WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
</bm:model>
\ No newline at end of file
......@@ -2,12 +2,16 @@
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="insert">
<bm:parameters>
<bm:parameter name="mail_list_id" dataType="java.lang.Long" input="false" output="true"/>
</bm:parameters>
<bm:update-sql><![CDATA[
BEGIN
wx_ele_contract_pkg.send_email(p_user_id => nvl(${/session/@user_id},1),
p_mail_to => ${@mail_to},
p_id_no => ${@id_no},
p_contract_id => ${@contract_id});
p_contract_id => ${@contract_id},
v_mail_list_id =>${@mail_list_id});
END;
]]></bm:update-sql>
</bm:operation>
......
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT
faa.file_name,
faa.file_path
FROM
fnd_atm_attachment faa,
fnd_atm_attachment_multi faam
WHERE
faa.attachment_id = faam.attachment_id AND
faa.source_type_code = 'fnd_atm_attachment_multi' AND
faa.source_pk_value = faam.record_id AND
faam.table_name = 'ZJ_SYS_MAILING_LIST'
and faam.table_pk_value = ${@mailing_list_id}
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="file_name"/>
<bm:field name="file_path"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT
cc.contract_number
FROM
con_contract cc
WHERE
cc.contract_id = ${@contract_id}
]]></bm:query-sql>
</bm:operation>
<bm:operation name="update">
<bm:update-sql><![CDATA[
update zj_sys_mailing_list zj
set zj.attch_file_name = ${@attch_file_name},
zj.attch_file_path = ${@attch_file_url},
zj.attch_flag = 'Y'
where zj.mailing_list_id = ${@mailing_list_id}
]]></bm:update-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="contract_number"/>
</bm:fields>
</bm:model>
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -34,7 +34,7 @@
$(ds_con_id).setQueryParameter('contract_id', '${/parameter/@contract_id}');
$(ds_con_id).query();
}
if ('${/model/pilot_run_user/record/@pilot_run_flag}' == 'N'){
if ('${/model/pilot_run_user/record/@pilot_run_flag}' != 'Y'){
$('${/parameter/@layout_code}_user_button4').hide();
}
});
......
......@@ -2,30 +2,106 @@
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<s:server-script import="app/app_login_check.js"><![CDATA[
function send_email() {
try {
if($ctx.parameter.email && $ctx.parameter.contractNo && $ctx.parameter.idNo) {
var ele_file_email_bm = $bm('wx.WX100.wx_ele_file_email');
ele_file_email_bm.insert({
mail_to: $ctx.parameter.email,
contract_id:$ctx.parameter.contractNo,
id_no:$ctx.parameter.idNo
});
$ctx.parameter.return_status = '0';
$ctx.parameter.return_message = '执行成功';
importPackage(java.io);
importPackage(java.util.zip);
//系统参数获取
function info_query(parameter_code) {
var info = new Object();
var data = null;
var parameter_map = $bm('wx.WX100.sys_parameter_value').queryAsMap({
parameter_code:parameter_code
});
var data = parameter_map.getChildren();
info.code_value = data[0].code_value;
return info;
}
//打包文件路径
var file_dir = info_query('HL_ELE_PACKAGE_PATH').code_value;
function writeFile(zos, fn, fp) {
var ze = new ZipEntry(fn);
//zos.setEncoding("UTF-8");//如果是org.apache.tools.zip需要追加字符集
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);
}
} catch (e) {
$ctx.success = "true";
$ctx.parameter.return_status = '1';
$ctx.parameter.return_message = String(e);
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
}
var result = {
code: $ctx.parameter.return_status,
message: $ctx.parameter.return_message
};
$ctx.parameter.json = JSON.stringify(result);
function send_email() {
try {
if($ctx.parameter.email && $ctx.parameter.contractNo && $ctx.parameter.idNo) {
var ele_file_email_bm = $bm('wx.WX100.wx_ele_file_email');
ele_file_email_bm.insert({
mail_to: $ctx.parameter.email,
contract_id:$ctx.parameter.contractNo,
id_no:$ctx.parameter.idNo
});
var mail_list_id = $ctx.current_parameter.mail_list_id;
var email_atm_file_bm = $bm('wx.WX100.wx_email_atm_file');
var mail_file_result = email_atm_file_bm.queryAsMap({
mailing_list_id: mail_list_id
}).getChildren();
//时间戳作为压缩文件夹名称
var date_str = getdate();
var con_info_bm = $bm('wx.WX100.wx_email_attch_file');
var con_info = con_info_bm.queryAsMap({
contract_id: $ctx.parameter.contractNo
});
var contract_number = con_info.getChildren()[0].contract_number;
var doc_code = '合同签约附件';
var zip_filename = doc_code + '-'+ contract_number + '-' + date_str + ".zip";
var tranfer_dir= new File(String(file_dir));
if(!tranfer_dir.exists()){
tranfer_dir.mkdirs();//创建文件夹
}
var tranfer_file_path = file_dir + "/" + zip_filename;
var zipFile= new File(String(tranfer_file_path));
if(!zipFile.exists()){//如果文件夹不存在,创建年月文件夹
zipFile.createNewFile();
}
var zos = new ZipOutputStream(new FileOutputStream(zipFile));
for (var i = 0; i < mail_file_result.length; i++) {
var f = mail_file_result[i];
if (f.file_path ) {
writeFile(zos, f.file_name, f.file_path);
}
}
zos.close();
var file_url = tranfer_file_path.toString();
var file_name = zip_filename.toString();
con_info_bm.update({
attch_file_name: file_name,
attch_file_url:file_url,
mailing_list_id: mail_list_id
});
$ctx.parameter.return_status = '0';
$ctx.parameter.return_message = '执行成功';
}
} catch (e) {
$ctx.success = "true";
$ctx.parameter.return_status = '1';
$ctx.parameter.return_message = String(e);
}
var result = {
code: $ctx.parameter.return_status,
message: $ctx.parameter.return_message
};
$ctx.parameter.json = JSON.stringify(result);
}
}
send_email();
]]></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