Commit 48c2efa2 authored by TIANZHI.HU's avatar TIANZHI.HU

工作流合同文本打印 add by 39135 HuTianzhi

parent 78baf8c7
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.aurora-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="update">
<bm:update-sql><![CDATA[
BEGIN
wfl_instance_pdf_pkg.create_wfl_instance_content(p_instance_id => ${@instance_id},
p_user_id => ${/session/@user_id});
commit;
END;
]]></bm:update-sql>
</bm:operation>
<bm:operation name="execute">
<bm:update-sql><![CDATA[
BEGIN
wfl_instance_pdf_pkg.insert_fnd_atm(
p_table_name =>${@table_name},
p_table_pk_value =>${@content_id},
p_file_name =>${@file_name},
p_file_path =>${@file_path},
p_user_id =>nvl(${/session/@user_id},1),
p_file_size =>${@file_size}
);
END;
]]></bm:update-sql>
</bm:operation>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT
faa.file_name,
faa.file_path,
faa.file_type_code,
'建机审批流版式文件-'||z.workflow_desc||'-'||z.instance_id||'.docx' to_file_name,
lt.pwd,
fc.document_id,
fc.content_id
FROM
fnd_atm_attachment faa,
fnd_atm_attachment_multi m,
hls_doc_file_templet lt,
con_clause_templet t,
hls_doc_file_content fc,
zj_wfl_workflow_instance_v z
WHERE
faa.attachment_id = m.attachment_id AND
m.table_name = 'HLS_DOC_FILE_TEMPLET' AND
m.table_pk_value = lt.templet_id AND
lt.templet_id = t.doc_template_id AND
t.doc_plugin_flag = 'Y' AND
t.templet_id = fc.templet_Id AND
fc.document_id = z.instance_id AND
fc.document_table = 'ZJ_WFL_WORKFLOW_INSTANCE' and
z.instance_id = ${@instance_id}
]]></bm:query-sql>
</bm:operation>
<bm:operation name="insert">
<bm:update-sql><![CDATA[
begin
HL_CONTRACT_PKG.save_prj_credit_pdf_atm(p_content_id =>${@content_id},
p_table_name =>${@table_name});
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:field name="file_type_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_TYPE_CODE"/>
<bm:field name="to_file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TO_FILE_NAME"/>
<bm:field name="pwd" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PWD"/>
<bm:field name="document_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOCUMENT_ID"/>
<bm:field name="content_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTENT_ID"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:a="http://www.aurora-framework.org/application" xmlns:s="aurora.plugin.script" trace="true">
<a:init-procedure>
<s:server-script import="con_print_path.js"><![CDATA[
set_parameter_file_path();
]]></s:server-script>
<s:server-script><![CDATA[
importPackage(Packages.hls.plugin.docx4j);
importPackage(java.io);
importPackage(Packages.hls.plugin.jacob.engine);
importPackage(Packages.aurora.plugin.mail);
importPackage(Packages.uncertain.proc);
//importPackage(Packages.leaf.plugin.script.scriptobject);
importPackage(Packages.leaf.plugin.word2pdf);
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 get_file_length(path){
var file=new File(String(path));
if(file.exists() && file.isFile()){
//println(f.length());
length=file.length();
return length;}
else{
return 0 ;}
}
var instance_id = $ctx.parameter.instance_id;
$bm('zjwfl.ZJWFL1060.wfl_instance_pdf').update({
instance_id: instance_id
});
var file_templet_get_atm_path = $bm('zjwfl.ZJWFL1060.wfl_instance_pdf').queryAsMap({
instance_id: instance_id
});
var from_file_data = file_templet_get_atm_path.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];
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 + 'wfl' + record_data.content_id;
copyFile(from_file_path, to_file_path);
//放入实例id方便表单参数取值
$ctx.current_parameter.document_id = instance_id;
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,'COMMON');
} catch (e) {
raise_app_error(e);
}
word_to_pdf_sign(record_data.content_id,to_file_path.toString());
//得到生成的pdf文件的大小
var file_size=get_file_length(to_file_path.toString() + '.pdf');
//关联附件表
$bm('zjwfl.ZJWFL1060.wfl_instance_pdf').execute({
table_name: 'ZJ_WFL_WORKFLOW_INSTANCE',
content_id: instance_id,
file_name: to_file_name.toString(),
file_path: to_file_path.toString(),
file_size: file_size
});
var attachment_update = $bm('zjwfl.ZJWFL1060.wfl_instance_pdf');
//更新转换的pdf附件,其附件表的字段
//这里的附件关联表是工作流监控表
attachment_update.insert({
content_id: instance_id,
table_name: 'ZJ_WFL_WORKFLOW_INSTANCE'
});
}
function word_to_pdf_sign(content_id,file_path) {
importPackage(Packages.com.hl.signatures);
importPackage(Packages.java.io);
importPackage(Packages.java.util);
var outputfilepath = file_path + '.pdf'; // 由于wordToPdf转换后pdf文件已经带有.pdf
var wordToPdf = new WordToPdf($instance('uncertain.ocm.IObjectRegistry'), "jacob-1.19-x64.dll");
wordToPdf.word2pdf(file_path, outputfilepath);
}
]]></s:server-script>
</a:init-procedure>
</a:service>
...@@ -9,8 +9,38 @@ ...@@ -9,8 +9,38 @@
<a:link id="pageLink_node_approve_history" url="${/request/@context_path}/modules/zjwfl/ZJWFL1060/zj_wfl_monitoring_node_approve_history.lview"/> <a:link id="pageLink_node_approve_history" url="${/request/@context_path}/modules/zjwfl/ZJWFL1060/zj_wfl_monitoring_node_approve_history.lview"/>
<a:link id="pageLink_view_graphics" url="${/request/@context_path}/modules/zjwfl/zj_wfl_graphics.lview"/> <a:link id="pageLink_view_graphics" url="${/request/@context_path}/modules/zjwfl/zj_wfl_graphics.lview"/>
<a:link id="pageLink_do_operation" url="${/request/@context_path}/modules/zjwfl/ZJWFL1060/zj_wfl_monitoring_admin_operation.lview"/> <a:link id="pageLink_do_operation" url="${/request/@context_path}/modules/zjwfl/ZJWFL1060/zj_wfl_monitoring_admin_operation.lview"/>
<a:link id="wfl_instance_pdf_link" url="${/request/@context_path}/modules/zjwfl/ZJWFL1060/wfl_instance_pdf.lsc"/>
<a:link id="attachment_downloadFile_link" url="${/request/@context_path}/downloadFile.lview"/>
<a:screen-include screen="modules/zjwfl/zj_wfl_common_javascript.lview"/> <a:screen-include screen="modules/zjwfl/zj_wfl_common_javascript.lview"/>
<script type="text/javascript"><![CDATA[ <script type="text/javascript"><![CDATA[
function get_pdf() {
var ds = $('monitorDs');
var records = ds.getSelected();
if(records.length != 1){
Leaf.showMessage('${l:PROMPT}', '请选择一条记录生成附件');
return;
}
var record = records[0];
var param = {};
param['instance_id'] = record.get('instance_id');
Leaf.Masker.mask(Ext.getBody(), '正在生成...');
Leaf.request({
url: $('wfl_instance_pdf_link').getUrl(),
para: param,
success: function() {
Leaf.Masker.unmask(Ext.getBody());
//生成之后重新查询数据
ds.query();
},
failure: function() {
Leaf.Masker.unmask(Ext.getBody());
},
error: function() {
Leaf.Masker.unmask(Ext.getBody());
},
scope: this
});
}
function query_monitorDs() { function query_monitorDs() {
$('monitorDs').query(); $('monitorDs').query();
} }
...@@ -84,6 +114,8 @@ ...@@ -84,6 +114,8 @@
else if(name=='do_operation') else if(name=='do_operation')
{ {
return '<a href=\"javascript:winOpen_do_operation(' + record.get('instance_id') + ',' + record.get('workflow_id') + ')\">操作</a>'; return '<a href=\"javascript:winOpen_do_operation(' + record.get('instance_id') + ',' + record.get('workflow_id') + ')\">操作</a>';
}else if (name == 'wlf_pdf') {
return '<a href="javascript:attachment_downFile_win(\'' + record.get('instance_id') + '\')">' + '附件查看' + '</a>';
} }
} }
function onload(ds) { function onload(ds) {
...@@ -92,6 +124,16 @@ ...@@ -92,6 +124,16 @@
grid_id.hideColumn('do_operation'); grid_id.hideColumn('do_operation');
} }
} }
function attachment_downFile_win(instance_id) {
new Leaf.Window({
id: 'open_attachment_window',
url: $('attachment_downloadFile_link').getUrl() + '?table_name=ZJ_WFL_WORKFLOW_INSTANCE&header_id=' + instance_id,
title: '工作流附件',
width: 850,
height: 200
});
}
]]></script> ]]></script>
<a:dataSets> <a:dataSets>
<a:dataSet id="instanceStatusDs"> <a:dataSet id="instanceStatusDs">
...@@ -111,7 +153,7 @@ ...@@ -111,7 +153,7 @@
<a:field name="workflow_desc" readOnly="true"/> <a:field name="workflow_desc" readOnly="true"/>
</a:fields> </a:fields>
</a:dataSet> </a:dataSet>
<a:dataSet id="monitorDs" autoPageSize="true" autoQuery="true" model="zjwfl.ZJWFL1060.zj_wfl_monitoring_query" queryDataSet="para_monitorDs"> <a:dataSet id="monitorDs" autoPageSize="true" autoQuery="true" model="zjwfl.ZJWFL1060.zj_wfl_monitoring_query" queryDataSet="para_monitorDs" selectable="true">
<a:events> <a:events>
<a:event name="load" handler="onload"/> <a:event name="load" handler="onload"/>
</a:events> </a:events>
...@@ -130,6 +172,7 @@ ...@@ -130,6 +172,7 @@
<a:hBox> <a:hBox>
<a:button click="query_monitorDs" text="HAP_QUERY"/> <a:button click="query_monitorDs" text="HAP_QUERY"/>
<a:button click="reset_para_monitorDs" text="HAP_RESET"/> <a:button click="reset_para_monitorDs" text="HAP_RESET"/>
<a:button click="get_pdf" text="生成一个工作流实例的附件"/>
</a:hBox> </a:hBox>
<a:grid id="monitorDs_grid" bindTarget="monitorDs" marginHeight="200" marginWidth="50" navBar="true"> <a:grid id="monitorDs_grid" bindTarget="monitorDs" marginHeight="200" marginWidth="50" navBar="true">
<a:columns> <a:columns>
...@@ -146,6 +189,7 @@ ...@@ -146,6 +189,7 @@
<a:column name="approve_history" align="center" prompt="明细" renderer="render_monitorDs_grid" width="50"/> <a:column name="approve_history" align="center" prompt="明细" renderer="render_monitorDs_grid" width="50"/>
<!-- <a:column name="view_graphics" align="center" prompt="流程图" renderer="render_monitorDs_grid" width="50"/> --> <!-- <a:column name="view_graphics" align="center" prompt="流程图" renderer="render_monitorDs_grid" width="50"/> -->
<a:column name="do_operation" align="center" prompt="操作" renderer="render_monitorDs_grid" width="50"/> <a:column name="do_operation" align="center" prompt="操作" renderer="render_monitorDs_grid" width="50"/>
<a:column name="wlf_pdf" align="center" prompt="附件查看" renderer="render_monitorDs_grid" width="100"/>
</a:columns> </a:columns>
</a:grid> </a:grid>
</a:screenBody> </a:screenBody>
......
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