Commit ca6cd7a2 authored by 李贺贺's avatar 李贺贺

发票认领申请、发票认领确认电子发票邮件发送

parent 1b019a8b
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT t.file_name,t.file_path
FROM (SELECT fa.file_name, fa.file_path
FROM fnd_atm_attachment fa, fnd_atm_attachment_multi m
WHERE m.attachment_id = fa.attachment_id
AND fa.source_type_code = 'fnd_atm_attachment_multi'
AND fa.source_pk_value = m.record_id
AND m.table_name = 'ACR_INVOICE_HD'
AND m.table_pk_value = ${@invoice_hd_id}) t
WHERE rownum = 1
]]></bm:query-sql>
</bm:operation>
<bm:operation name="update">
<bm:update-sql><![CDATA[
begin
acr_invoice_pkg.send_invoice_mail(
p_file_name => ${@file_name},
p_file_path => ${@file_path} ,
p_file_size => ${@file_size},
p_user_id => ${/session/@user_id},
p_bp_id => ${@bp_id}
);
end;
]]></bm:update-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_NAME"/>
<bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH"/>
</bm:fields>
</bm:model>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select hb.bp_name from hls_bp_master hb where hb.bp_id = ${@bp_id}
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME"/>
</bm:fields>
</bm:model>
\ No newline at end of file
......@@ -132,6 +132,7 @@
invoice_apply_num,
( ACR_INVOICE_WFL_PKG.get_invoice_transaction_flag(t.invoice_hd_id))csh_transaction_flag,
decode(ACR_INVOICE_WFL_PKG.get_invoice_transaction_flag(t.invoice_hd_id),'NOT','未收款','PARTIAL','部分收款','FULL','完全收款')csh_transaction_flag_desc,
invoice_type,
invoice_kind_type,
invoice_kind_type_n
FROM acr_invoice_hd_v t) t1
......
......@@ -131,6 +131,7 @@
invoice_apply_num,
ACR_INVOICE_WFL_PKG.get_invoice_transaction_flag(t.invoice_hd_id)csh_transaction_flag,
decode(ACR_INVOICE_WFL_PKG.get_invoice_transaction_flag(t.invoice_hd_id),'NOT','未收款','PARTIAL','部分收款','FULL','完全收款')csh_transaction_flag_desc,
invoice_type,
invoice_kind_type,
invoice_kind_type_n
......
......@@ -8,6 +8,7 @@
url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
<a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
modelaction="update"/>
<a:link id="acr516_invoice_send_to_email_link" url="${/request/@context_path}/modules/acr/ACR516/import_invoice_to_email.lsc"/>
<script type="text/javascript"><![CDATA[
......@@ -76,7 +77,65 @@
function submit_success_btn(ds) {
$('acr516_invoice_result_ds').query();
}
//add by lihh 202104262 电子发票发送
function acr516_invoice_send(){
//debugger;
var ds = $('acr516_invoice_result_ds');
var records = ds.getSelected();
if (records.length == 0) {
Leaf.showMessage('提示', '请至少勾选一条记录!', null, 350);
return;
}
var r_map = new Map();
for(var i = 0;i <records.length;i++){
if(records[i].get('claim_status') != 'CONFIRMED'){
Leaf.showMessage('提示','请勾选认领状态为已确认的单据');
return;
}
if(records[i].get('invoice_type') != 'ECT'){
Leaf.showMessage('提示','请勾选电子发票进行发送');
return;
}
if(!r_map.has(records[i].get('invoice_bp_id'))){
var arr = new Array();
arr.add(records[i].get('invoice_hd_id'));
r_map.set(records[i].get('invoice_bp_id'),arr);
}else{
r_map.get(records[i].get('invoice_bp_id')).add(records[i].get('invoice_hd_id'));
}
}
var result_map = MapTOJson(r_map);
Leaf.showConfirm('提示', '是否确认发送电子发票邮件?', function() {
Leaf.request({
url: $('acr516_invoice_send_to_email_link').getUrl(),
para: {
result_map : result_map
},
success: function(){
Leaf.SideBar.show({
msg: '发送成功',
duration: 2000
});
}
});
},null);
}
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 += '}';
//console.log(str);
return str;
}
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
<a:dataSets>
......@@ -141,6 +200,7 @@
<a:toolbarButton click="acr516_invoice_query" text="HLS.QUERY"/>
<a:toolbarButton click="acr516_invoice_reset" text="HLS.RESET"/>
<a:toolbarButton click="acr516_invoice_apply" text="申请"/>
<a:toolbarButton click="acr516_invoice_send" text="发送电子发票"/>
</a:screenTopToolbar>
<a:form marginWidth="30" padding="0" title="查询条件" column="4">
<a:textField name="document_number" bindTarget="acr516_invoice_query_ds" prompt="单据编号" width="120"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:a="http://www.leaf-framework.org/application" xmlns:dr="leaf.plugin.excelreport" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<s:server-script><![CDATA[
importPackage(java.util.zip);
importPackage(java.io);
//系统参数获取
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('ELE_ACR_DIR').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 getBpName(str){
var bp_map = $bm('acr.ACR516.acr_bpname_for_bpmster').queryAsMap({
bp_id: str
});
var bp_att = bp_map.getChildren();
var bp_name = bp_att[0].bp_name;
return bp_name;
}
try {
var resultStr = $ctx.parameter.result_map;
//println(resultStr);
var jm = JSON.parse(resultStr);
//println(typeof jm);
//压缩次数
for(var key in jm){
var fileP = [];
var fileN = [];
//转为数字
var bp_id = parseInt(key);
var bp_name = getBpName(bp_id);
//println(key);
var hds = jm[key];
println(hds);
//转为数组
var hdsArr = hds.split(',');
//println(typeof hdsArr);
//println(hdsArr.length);
//压缩文件夹
var zip_filename = '['+bp_name+']'+bp_id+'电子发票.zip';
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< hdsArr.length; i++){
var hd_id = hdsArr[i];
var file_list = $bm('acr.ACR516.acr_atm_update').queryAsMap({
invoice_hd_id : hd_id
});
var files = file_list.getChildren();
var file_name = files[0].file_name;
var file_path = files[0].file_path;
//println(files[0].file_name);
//println(files[0].file_path);
if (file_path) {
writeFile(zos, file_name,file_path);
}
}
zos.close();
//插入到邮件表
var file = new File(tranfer_file_path);
var file_size = 0;
if(file.exists()){
file_size = file.length().toString();
}
// 往邮箱插入待发送的数据,插附件表
//println(zip_filename);
//println(tranfer_file_path);
//println( file_size);
var filename =zip_filename.toString();
var filepath =tranfer_file_path.toString();
var bpid = bp_id.toString();
var atm_bm = $bm('acr.ACR516.acr_atm_update');
atm_bm.update({
file_name :filename,
file_path :filepath,//文件名
file_size :file_size,
bp_id : bp_id
});
}
$ctx.success = "true";
$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);
//$bm('rollback').update({});
}
var result = {
result: $ctx.parameter.return_status,
message: $ctx.parameter.return_message
};
println(result);
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
......@@ -9,6 +9,7 @@
<a:link id="acr_invoice_refuse_link_id" model="acr.ACR605.acr_invoice_claim_return" modelaction="batch_update"/>
<a:link id="con_contract_modify_link" url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
<a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
<a:link id="acr517_invoice_send_to_email_link" url="${/request/@context_path}/modules/acr/ACR516/import_invoice_to_email.lsc"/>
<script type="text/javascript"><![CDATA[
......@@ -43,18 +44,34 @@
// $('acr517_invoice_result_ds').setSubmitUrl('${/request/@context_path}/autocrud/acr.ACR605.acr_invoice_claim_confirm_new/batch_update');
var records=$('acr517_invoice_result_ds').getSelected();
var datas = [];
var r_map = new Map();
for (var i = 0;i < records.length;i++) {
datas.push({
'invoice_hd_id':records[i].get('invoice_hd_id'),
'_status': 'update'
})
if(records[i].get('invoice_type') == 'ECT'){
if(!r_map.has(records[i].get('invoice_bp_id'))){
var arr = new Array();
arr.add(records[i].get('invoice_hd_id'));
r_map.set(records[i].get('invoice_bp_id'),arr);
}else{
r_map.get(records[i].get('invoice_bp_id')).add(records[i].get('invoice_hd_id'));
}
}
}
var result_map = MapTOJson(r_map);
$L.showConfirm("提示",'确认执行该操作?',function(){
Leaf.request({
url: '${/request/@context_path}/autocrud/acr.ACR605.acr_invoice_claim_confirm_new/batch_update',
para: datas,
success: function () {
Leaf.request({
url: $('acr517_invoice_send_to_email_link').getUrl(),
para: {
result_map : result_map
}
});
Leaf.SideBar.show({
msg: '操作成功',
duration: 2000
......@@ -130,7 +147,21 @@
function submit_success_btn(){
$('acr517_invoice_result_ds').query();
}
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 += '}';
//console.log(str);
return str;
}
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
<a:dataSets>
......
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