Commit 45fbfc90 authored by Luochenglong's avatar Luochenglong

Merge remote-tracking branch 'origin/remote_dev' into remote_dev

parents 00a2fb9c cff95230
...@@ -6,12 +6,13 @@ import java.io.IOException; ...@@ -6,12 +6,13 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class ContractSignaturesNew public class ContractSignaturesNew
{ {
public static String hl_contract_signatures(String file_path, String sign_path, Object[] param,String server_url,String app_id,String app_security) public static String hl_contract_signatures(String file_path, String sign_path, Object[] param,String server_url,String app_id,String app_security,String datePath)
throws IOException, NoSuchAlgorithmException throws IOException, NoSuchAlgorithmException
{ {
String contractid = UUID.randomUUID().toString().replaceAll("-", ""); String contractid = UUID.randomUUID().toString().replaceAll("-", "");
...@@ -57,7 +58,7 @@ public class ContractSignaturesNew ...@@ -57,7 +58,7 @@ public class ContractSignaturesNew
{ {
ContractWithTemplate.downFiles( ContractWithTemplate.downFiles(
json.getJSONArray("record_saved_urls"), json.getJSONArray("record_saved_urls"),
file_path, datePath,
server_url, server_url,
app_id, app_id,
app_security); app_security);
......
...@@ -76,22 +76,22 @@ public class ContractWithTemplate { ...@@ -76,22 +76,22 @@ public class ContractWithTemplate {
FileOutputStream fos = null; FileOutputStream fos = null;
try{ try{
String fileName = savePath; String fileName = savePath;
if(!(savePath.endsWith("/")|| savePath.endsWith("\\"))){ if ((!savePath.endsWith("/")) && (!savePath.endsWith("\\"))) {
fileName +="/"; fileName = fileName + "/";
} }
fileName+=request.getDownFileName(); fileName = fileName + request.getDownFileName();
File file = new File(fileName); File file = new File(fileName);
//file.getParentFile().mkdirs();
fos = new FileOutputStream(file); fos = new FileOutputStream(file);
//System.out.println("保存文件至:"+fileName);
request.result(fos); request.result(fos);
}finally{ } finally {
if(fos!=null){ if (fos != null)
fos.close(); fos.close();
} }
} }
}else{ else {
System.out.println("错误信息:"+request.resultToString()); System.out.println("错误信息:" + request.resultToString());
} }
} }
......
...@@ -131,6 +131,26 @@ public class WordToPdf { ...@@ -131,6 +131,26 @@ public class WordToPdf {
activeXComponent.invoke("Quit"); activeXComponent.invoke("Quit");
return true; return true;
} }
public static boolean exceltopdf(String inFilePath, String outFilePath) {
ActiveXComponent activeXComponent = new ActiveXComponent("Excel.Application");
activeXComponent.setProperty("Visible", false);
// deletePdf(outFilePath);
Dispatch excels = activeXComponent.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.call(excels, "Open", inFilePath, false, true).toDispatch();
Dispatch currentSheet = Dispatch.get((Dispatch) excel,
"ActiveSheet").toDispatch();
Dispatch pageSetup = Dispatch.get(currentSheet, "PageSetup")
.toDispatch();
//Dispatch.put(pageSetup, "Zoom", 50);
Dispatch.put(pageSetup, "FitToPagesTall", 1);
Dispatch.put(pageSetup, "FitToPagesWide", 1);
Dispatch.call(excel, "ExportAsFixedFormat", 0, outFilePath);
Dispatch.call(excel, "Close", false);
activeXComponent.invoke("Quit");
return true;
}
/** /**
* excel to pdf Orientation excel横向转成pdf * excel to pdf Orientation excel横向转成pdf
...@@ -143,7 +163,7 @@ public class WordToPdf { ...@@ -143,7 +163,7 @@ public class WordToPdf {
ActiveXComponent activeXComponent = new ActiveXComponent("Excel.Application"); ActiveXComponent activeXComponent = new ActiveXComponent("Excel.Application");
activeXComponent.setProperty("Visible", false); activeXComponent.setProperty("Visible", false);
// deletePdf(outFilePath); //deletePdf(outFilePath);
Dispatch excels = activeXComponent.getProperty("Workbooks").toDispatch(); Dispatch excels = activeXComponent.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.call(excels, "Open", inFilePath, false, true).toDispatch(); Dispatch excel = Dispatch.call(excels, "Open", inFilePath, false, true).toDispatch();
...@@ -185,14 +205,10 @@ public class WordToPdf { ...@@ -185,14 +205,10 @@ public class WordToPdf {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String jacobDllPath = "E:\\idea_workspace\\leaf-hlcm\\src\\main\\webapp\\WEB-INF\\server-script\\jacob\\jacob-1.19-x64.dll"; String jacobDllPath = "D:\\workspace\\leaf-hlcm\\src\\main\\webapp\\WEB-INF\\server-script\\jacob\\jacob-1.19-x64.dll";
System.setProperty("jacob.dll.path", jacobDllPath); System.setProperty("jacob.dll.path", jacobDllPath);
System.setProperty("com.jacob.debug", "true"); System.setProperty("com.jacob.debug", "true");
// word2pdf("D:\\u01\\hls_file\\excel\\8F5D12B0B1504518928FDD193C67A0A5con28168",
// "D:\\hand-Prpjects\\融资租赁合同文本-4pdf.pdf"); //exceltopdf("D:\\u01\\hls_file\\excel\\2023\\03\\对账单(张武林_LZJ20010006)202303131039.xlsx", "D:\\u01\\hls_file\\excel\\2023\\01\\f.pdf");
// cutPdf("D:\\\\hand-Prpjects\\\\付款请求书打印.pdf");
excel2pdf("C:\\Users\\Administrator\\Desktop\\对账单(白云BJJ22120045).xlsx", "C:\\Users\\Administrator\\Desktop\\c.pdf",1,1);
// excel2pdfOrientation("D:\\work\\leafProjects\\YondaTl\\src\\test.xlsx",
// "D:\\work\\leafProjects\\YondaTl\\src\\付款通知书NEW.pdf");
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" needAccessControl="false">
<bm:fields>
<bm:field name="server_url" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="app_id" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="app_security" databaseType="VARCHAR2" datatype="java.lang.String"/>
</bm:fields>
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select sys_parameter_pkg.value(p_parameter_code => 'JG_SERVER_URL') server_url,
sys_parameter_pkg.value(p_parameter_code => 'JG_APP_ID') app_id,
sys_parameter_pkg.value(p_parameter_code => 'JG_APP_SECURITY') app_security
from dual
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
importPackage(Packages.com.itextpdf.text.pdf); importPackage(Packages.com.itextpdf.text.pdf);
function word_to_pdf_sign(content_id) { function word_to_pdf_sign(content_id) {
importPackage(Packages.com.hl.signatures); importPackage(Packages.com.hand.kinggrid);
importPackage(Packages.java.io); importPackage(Packages.java.io);
importPackage(Packages.java.util); importPackage(Packages.java.util);
var attachment_batch_dl = $bm('cont.CON620.con_collection_file_download'); var attachment_batch_dl = $bm('cont.CON620.con_collection_file_download');
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
} else if (file_name.substring(file_name.length - 5) == '.docx') { } else if (file_name.substring(file_name.length - 5) == '.docx') {
file_name = file_name.substring(0, file_name.length - 5); file_name = file_name.substring(0, file_name.length - 5);
} }
println('file_path =' + file_path);
var outputfilepath = file_path + '.pdf'; // 由于wordToPdf转换后pdf文件已经带有.pdf var outputfilepath = file_path + '.pdf'; // 由于wordToPdf转换后pdf文件已经带有.pdf
var wordToPdf = new WordToPdf($instance('uncertain.ocm.IObjectRegistry'), "jacob-1.19-x64.dll"); var wordToPdf = new WordToPdf($instance('uncertain.ocm.IObjectRegistry'), "jacob-1.19-x64.dll");
//wordToPdf.WordToPdf(file_path, outputfilepath); //wordToPdf.WordToPdf(file_path, outputfilepath);
...@@ -43,10 +44,8 @@ ...@@ -43,10 +44,8 @@
// 获取pdf页数,如果是只有1页,不需要骑缝章 // 获取pdf页数,如果是只有1页,不需要骑缝章
var pageNum = getPdfPageNum(outputfilepath); var pageNum = getPdfPageNum(outputfilepath);
println(pageNum); println(pageNum);
println(1);
var con_signature_info = $bm('cont.CON620.get_con_signature_info').queryAsMap(); var con_signature_info = $bm('cont.CON620.get_con_signature_info').queryAsMap();
var con_signature_data = con_signature_info.getChildren(); var con_signature_data = con_signature_info.getChildren();
println(2);
var con_signature_record; var con_signature_record;
for (var i = 0;i < con_signature_data.length;i++) { for (var i = 0;i < con_signature_data.length;i++) {
...@@ -82,26 +81,21 @@ ...@@ -82,26 +81,21 @@
} }
} }
println(param); println(param);
var sys_url_bm=$bm('cont.CON4000.get_sys_url'); var con_signature_info = $bm('cont.CON620.get_kinggrid_info').queryAsMap();
var parameter_code='JG_SERVER_URL'; var con_kinggrid_data = con_signature_info.getChildren()[0];
var SysurlQuery = sys_url_bm.queryAsMap({ var server_url = con_kinggrid_data.server_url;
parameter_code: parameter_code var app_id = con_kinggrid_data.app_id;
}); var app_security = con_kinggrid_data.app_security;
var server_url = SysurlQuery.getChildren()[0].parameter_value; <!-- var kinggrid_info=$bm('cont.CON620.get_kinggrid_info').queryAsMap();-->
<!-- var parameter_code='JG_APP_SECURITY';-->
var parameter_code='JG_APP_ID'; <!-- var SysSecurityQuery = sys_url_bm.queryAsMap({-->
var SysIdQuery = sys_url_bm.queryAsMap({ <!-- parameter_code: parameter_code-->
parameter_code: parameter_code <!-- });-->
}); <!-- var app_security = SysSecurityQuery.getChildren()[0].parameter_value;-->
var app_id = SysIdQuery.getChildren()[0].parameter_value; println(outputfilepath);
var datePath = getDate();
var parameter_code='JG_APP_ID'; println("datePath + " +datePath);
var SysSecurityQuery = sys_url_bm.queryAsMap({ var status = new ContractSignaturesNew.hl_contract_signatures(outputfilepath, 1,param.toArray(),server_url,app_id,app_security,datePath);
parameter_code: parameter_code
});
var app_security = SysSecurityQuery.getChildren()[0].parameter_value;
var status = new ContractSignaturesNew.hl_contract_signatures(outputfilepath, 1,param.toArray(),server_url,app_id,app_security);
attachment_update.update({ attachment_update.update({
content_id: content_id, content_id: content_id,
...@@ -171,6 +165,18 @@ ...@@ -171,6 +165,18 @@
return datePath; //datePath = d:/hls_test_files/fileupload/2018/04/ return datePath; //datePath = d:/hls_test_files/fileupload/2018/04/
} }
function getDate() {
set_parameter_file_path();
var file_path = $ctx.parameter.file_path;
var now = new Date()
y = now.getFullYear()
m = now.getMonth() + 1
m = m < 10 ? "0" + m : m
var path = file_path+"2023" ;
return path;
}
function write_os_to_file(file, os) { function write_os_to_file(file, os) {
var fis = new FileInputStream(file); var fis = new FileInputStream(file);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64); var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64);
...@@ -245,7 +251,9 @@ ...@@ -245,7 +251,9 @@
//word转pdf并加盖公章 //word转pdf并加盖公章
word_to_pdf_sign(record_data.content_id); word_to_pdf_sign(record_data.content_id);
to_file_name = record_data.to_file_name + '.pdf'; to_file_name = record_data.to_file_name + '.pdf';
to_file_path = to_file_path + '.pdf'; var path = getDate();
to_path = path + guid_file_name_tables[0].guid_file_name + 'con' + record_data.content_id;
to_file_path = to_path + '.pdf';
download_file(to_file_path.toString(),to_file_name.toString()); download_file(to_file_path.toString(),to_file_name.toString());
} }
} }
......
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