Commit b1b73f88 authored by congzhao's avatar congzhao

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

parent f7a1ac1f
...@@ -13,10 +13,16 @@ ...@@ -13,10 +13,16 @@
<bm:operation name="query"> <bm:operation name="query">
<bm:query-sql><![CDATA[ <bm:query-sql><![CDATA[
SELECT * SELECT *
FROM (select 'N' pilot_run_flag, 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 su.user_id
from sys_user su from sys_user_v su
where su.user_name not in ('HAND')) where su.user_id in ('1'))
t1 #WHERE_CLAUSE# t1 #WHERE_CLAUSE#
]]></bm:query-sql> ]]></bm:query-sql>
</bm:operation> </bm:operation>
......
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm"> <bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations> <bm:operations>
<bm:operation name="insert"> <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[ <bm:update-sql><![CDATA[
BEGIN BEGIN
wx_ele_contract_pkg.send_email(p_user_id => nvl(${/session/@user_id},1), wx_ele_contract_pkg.send_email(p_user_id => nvl(${/session/@user_id},1),
p_mail_to => ${@mail_to}, p_mail_to => ${@mail_to},
p_id_no => ${@id_no}, p_id_no => ${@id_no},
p_contract_id => ${@contract_id}); p_contract_id => ${@contract_id},
v_mail_list_id =>${@mail_list_id});
END; END;
]]></bm:update-sql> ]]></bm:update-sql>
</bm:operation> </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.
...@@ -2,7 +2,45 @@ ...@@ -2,7 +2,45 @@
<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: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> <a:init-procedure>
<s:server-script import="app/app_login_check.js"><![CDATA[ <s:server-script import="app/app_login_check.js"><![CDATA[
function send_email() { 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);
}
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
}
function send_email() {
try { try {
if($ctx.parameter.email && $ctx.parameter.contractNo && $ctx.parameter.idNo) { if($ctx.parameter.email && $ctx.parameter.contractNo && $ctx.parameter.idNo) {
var ele_file_email_bm = $bm('wx.WX100.wx_ele_file_email'); var ele_file_email_bm = $bm('wx.WX100.wx_ele_file_email');
...@@ -11,6 +49,44 @@ function send_email() { ...@@ -11,6 +49,44 @@ function send_email() {
contract_id:$ctx.parameter.contractNo, contract_id:$ctx.parameter.contractNo,
id_no:$ctx.parameter.idNo 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_status = '0';
$ctx.parameter.return_message = '执行成功'; $ctx.parameter.return_message = '执行成功';
} }
...@@ -25,7 +101,7 @@ function send_email() { ...@@ -25,7 +101,7 @@ function send_email() {
}; };
$ctx.parameter.json = JSON.stringify(result); $ctx.parameter.json = JSON.stringify(result);
} }
send_email(); send_email();
]]></s:server-script> ]]></s:server-script>
</a:init-procedure> </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