Commit 18dceb94 authored by gzj34291's avatar gzj34291

合同对账单打印以及租金催收催收函盖公章

parent f25966f9
package com.hand.kinggrid;
import java.util.Formatter;
/**
* <p>
* 字节 16进制字串转换工具类
* </p>
*
* @author hubin
* @Date 2016-01-20
*/
public class Byte2Hex {
/**
*
* 字节转换为 16 进制字符串
*
* @param b
* 字节
* @return
*/
public static String byte2Hex( byte b ) {
String hex = Integer.toHexString(b);
if ( hex.length() > 2 ) {
hex = hex.substring(hex.length() - 2);
}
while ( hex.length() < 2 ) {
hex = "0" + hex;
}
return hex;
}
/**
*
* 字节数组转换为 16 进制字符串
*
* @param bytes
* 字节数组
* @return
*/
public static String byte2Hex( byte[] bytes ) {
Formatter formatter = new Formatter();
for ( byte b : bytes ) {
formatter.format("%02x", b);
}
String hash = formatter.toString();
formatter.close();
return hash;
}
}
package com.hand.kinggrid;
import com.alibaba.fastjson.JSONObject;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
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)
throws IOException, NoSuchAlgorithmException
{
String contractid = UUID.randomUUID().toString().replaceAll("-", "");
HttpRequest request = MainRequest.createHttpRequest("/api/cnt/sign",server_url,app_id,app_security);
InputStream is = null;
String status;
String signer_info;
try
{
File file = new File(file_path);
request.addFile("pdf_file", file);
request.addParam("contract_name", "合同名称");
request.addParam("contract_id", contractid);
request.addParam("biz_id",
UUID.randomUUID().toString().replaceAll("-", ""));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
request.addParam("biz_time", sdf.format(new Date()));
for(int i=0;i<param.length;i++){
signer_info = param[i].toString();
request.addParam("signer_info", signer_info);
}
/*
* if (qf_flag.equalsIgnoreCase("Y")) { request.addParam( "signer_info",
* "[{code:\"hlrzzl\",seal_code:\"9295f56b09124d508079b85f4a1e7e19\",seal_width:151,fontname:\"����\",fontsize:\"50\",fontcolor:\"#FF00FF\",pageno:\"0\",text:\"��ͬӡ��λ��\",qfzstart:\"1\",qfzdistance:\"200\"}]"
* ); } else { request.addParam( "signer_info",
* "[{code:\"hlrzzl\",seal_code:\"9295f56b09124d508079b85f4a1e7e19\",seal_width:151,fontname:\"����\",fontsize:\"50\",fontcolor:\"#FF00FF\",pageno:\"0\",text:\"��ͬӡ��λ��\"}]"
* ); }
*
* if (org_flag.equalsIgnoreCase("Y")) { request.addParam( "signer_info",
* "[{code:\"hlrzzl\",seal_code:\"fdd2f48507cb460fb372be3af2551a71\",seal_width:151,fontname:\"����\",fontsize:\"50\",fontcolor:\"#FF00FF\",pageno:\"0\",text:\"����ӡ��λ��\"}]"
* ); }
*/
request.send();
JSONObject json = JSONObject.parseObject(request.resultToString());
if (json.getInteger("code").intValue() == 1)
{
ContractWithTemplate.downFiles(
json.getJSONArray("record_saved_urls"),
file_path,
server_url,
app_id,
app_security);
status = "SUCCESS";
} else {
status = "FAILURE";
}
}
finally
{
if (is != null) {
is.close();
}
}
return status;
}
}
\ No newline at end of file
package com.hand.kinggrid;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* 合同相关测试(使用模板)接口
* @author Administrator
*
*/
public class ContractWithTemplate {
//public static final String SERVER_URL = "http://10.203.0.11:8989/tosignserver";
/**
* 信签服务器对接应用ID
*/
//public static final String APP_ID = "ac4a3bd1bf6f44fa86477ac251933259";
/**
* 信签服务器对接应用密钥
*/
// public static final String APP_SECURITY = "7lQ7GC1HSviWAFG6";
public static void main(String[] args) throws IOException {
//String contractid = "testte222211";
String contractid = UUID.randomUUID().toString().replaceAll("-", "");//合同编号,随机生成
JSONObject json = generateContract(contractid , null);
//System.out.println(json);
if(json.getInteger("code") == 1){//创建成功
downFiles(json.getJSONArray("doc_last_urls"), "d:/"+contractid,null,null,null);
json = signContract(contractid,null);
json = signContract2(contractid,null);
if(json.getInteger("code") == 1){//签署成功
downFiles(json.getJSONArray("record_saved_urls"), "d:/"+contractid,null,null,null);
System.out.println("record_saved_urls:"+json.getJSONArray("record_saved_urls"));
}else{
System.out.println(json);
}
}
}
/**
* 下载多个文件保存在文件夹
* @param urls
* @param savePath
* @throws IOException
*/
public static final void downFiles(JSONArray urls , String savePath,String server_url,String app_id,String app_security) throws IOException{
for (Object url : urls) {
downFile((String)url, savePath,server_url,app_id,app_security);
}
}
/**
* 下载文件保存
* @param url
* @param savePath
* @throws IOException
*/
public static final void downFile(String url , String savePath,String server_url,String app_id,String app_security) throws IOException{
HttpRequest request = MainRequest.createHttpRequest(url,server_url,app_id,app_security);
//HttpRequest request = new HttpRequest(url);
request.send();
int code = request.getResponseCode();
if(code==200){
FileOutputStream fos = null;
try{
String fileName = savePath;
if(!(savePath.endsWith("/")|| savePath.endsWith("\\"))){
fileName +="/";
}
fileName+=request.getDownFileName();
File file = new File(fileName);
//file.getParentFile().mkdirs();
fos = new FileOutputStream(file);
//System.out.println("保存文件至:"+fileName);
request.result(fos);
}finally{
if(fos!=null){
fos.close();
}
}
}else{
System.out.println("错误信息:"+request.resultToString());
}
}
/**
* 使用模板创建合同
* @throws IOException
*/
public static JSONObject generateContract(String contractid , String contract_tpl_code) throws IOException{
HttpRequest request = MainRequest.createHttpRequest("/api/contract/start",null,null,null);
//{"姓名":"李东长","cardname_ID":"360111198708080899","year":"2018","month":"01","day":"01"}
JSONObject docx_metadata = new JSONObject(true);
docx_metadata.put("INSURANCE_COMPANY", "信签售后");
docx_metadata.put("INSURANCE_MAN", "龚琪");
docx_metadata.put("PLATE_NUM", "京A88888");
docx_metadata.put("INSURANCE_YEAR", "2018");
docx_metadata.put("INSURANCE_MONTH", "05");
docx_metadata.put("INSURANCE_DAY", "21");
docx_metadata.put("INSURANCE_MONEY", "50000");
docx_metadata.put("SIGN_YEAR", "2018");
docx_metadata.put("SIGN_MONTH", "05");
docx_metadata.put("SIGN_DAY", "21");
//quest.addFile("attach_file", new File("d:/t1.pdf"));
//request.addFile("attach_file", new File("d:/t2.gif"));
//request.addFile("attach_file_2", new File("d:/test.docx"));
//request.addParam("contract_tlp_code",contract_tpl_code);
request.addParam("contract_tlp_code","nxs001");
request.addParam("doc_metadata",docx_metadata.toJSONString());
//设置合同ID
request.addParam("contract_id", contractid);
//设置合同名称参数
request.addParam("contract_name", "测试");
//设置业务编码参数
request.addParam("biz_id", UUID.randomUUID().toString().replaceAll("-", ""));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//设置业务时间参数
request.addParam("biz_time", sdf.format(new Date()));
request.send();
return JSONObject.parseObject(request.resultToString());
}
/**
* 签署合同
* @throws IOException
*/
public static JSONObject signContract(String contractid , String signer_code ) throws IOException{
HttpRequest request = MainRequest.createHttpRequest("/api/contract/sign",null,null,null);
request.addParam("contract_id", contractid);
request.addParam("biz_id", UUID.randomUUID().toString().replaceAll("-", ""));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//设置业务时间参数
request.addParam("biz_time", sdf.format(new Date()));
//设置签署人的编码
request.addParam("signer_code", signer_code);
//设置签署位置信息
//request.addParam("signatures", "[{ y:680,x:200,pageno:\"1\"}]");
request.send();
return JSONObject.parseObject(request.resultToString());
}
public static JSONObject signContract2(String contractid , String signer_code ) throws IOException{
HttpRequest request = MainRequest.createHttpRequest("/api/contract/sign",null,null,null);
request.addParam("contract_id", contractid);
request.addParam("biz_id", UUID.randomUUID().toString().replaceAll("-", ""));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//设置业务时间参数
request.addParam("biz_time", sdf.format(new Date()));
//设置签署人的编码
request.addParam("signer_code", "xurong");
//设置签署位置信息
//request.addParam("signatures", "[{ y:680,x:200,pageno:\"1\"}]");
request.send();
return JSONObject.parseObject(request.resultToString());
}
}
package com.hand.kinggrid;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public
class FileHolder {
private String filename;
private File file;
private InputStream is ;
public FileHolder(File file) {
this.filename = file.getName();
this.file = file;
}
public FileHolder(String filename , InputStream is) {
this.filename = filename;
this.is = is;
}
public InputStream getInputStream() throws FileNotFoundException{
if(is == null){
return new FileInputStream(file);
}
return is;
}
public String getFilename() {
return filename;
}
}
This diff is collapsed.
package com.hand.kinggrid;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Logger;
public class MD5 {
private static final Logger logger = Logger.getLogger("MD5");
/**
* @Description 字符串加密为MD5 中文加密一致通用,必须转码处理: plainText.getBytes("UTF-8")
* @param plainText
* 需要加密的字符串
* @return
*/
public static String toMD5(String plainText) {
StringBuffer rlt = new StringBuffer();
try {
rlt.append(md5String(plainText.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
logger.severe(" CipherHelper toMD5 exception.");
e.printStackTrace();
}
return rlt.toString();
}
/**
* MD5 参数签名生成算法
*
* @param HashMap<String,String>
* params 请求参数集,所有参数必须已转换为字符串类型
* @param String
* secret 签名密钥
* @return 签名
* @throws IOException
*/
public static String getSignature(HashMap<String, String> params, String secret) {
Map<String, String> sortedParams = new TreeMap<String, String>(params);
Set<Entry<String, String>> entrys = sortedParams.entrySet();
StringBuilder basestring = new StringBuilder();
for (Entry<String, String> param : entrys) {
basestring.append(param.getKey()).append("=").append(param.getValue());
}
return getSignature(basestring.toString(), secret);
}
/**
* MD5 参数签名生成算法
*
* @param String
* sigstr 签名字符串
* @param String
* secret 签名密钥
* @return 签名
* @throws IOException
*/
public static String getSignature(String sigstr, String secret) {
StringBuilder basestring = new StringBuilder(sigstr);
basestring.append("#");
basestring.append(toMD5(secret));
return toMD5(basestring.toString());
}
public static byte[] md5Raw(byte[] data) {
byte[] md5buf = null;
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5buf = md5.digest(data);
} catch (Exception e) {
md5buf = null;
logger.severe("md5Raw error.");
e.printStackTrace();
}
return md5buf;
}
public static String md5String(byte[] data) {
String md5Str = "";
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] buf = md5.digest(data);
for (int i = 0; i < buf.length; i++) {
md5Str += Byte2Hex.byte2Hex(buf[i]);
}
} catch (Exception e) {
md5Str = null;
logger.severe("md5String error.");
e.printStackTrace();
}
return md5Str;
}
}
\ No newline at end of file
package com.hand.kinggrid;
public class MainRequest {
/**
* 信签服务器地址
*/
//public static final String SERVER_URL = "http://171.34.78.70:8081:8081/tosignserver";
//public static final String SERVER_URL = "http://10.203.0.11:8989/tosignserver";
// public static final String SERVER_URL = "http://171.34.78.70:8081/tosignpub";
/**
* 信签服务器对接应用ID
*/
//public static final String APP_ID = "king";
// public static final String APP_ID = "ac4a3bd1bf6f44fa86477ac251933259";
//public static final String APP_ID = "f12a2c19e72348998b159df903b9b379";
/**
* 信签服务器对接应用密钥
*/
//public static final String APP_SECURITY = "e3f55030d473095d";
// public static final String APP_SECURITY = "7lQ7GC1HSviWAFG6";
//public static final String APP_SECURITY = "SK60MXsN7dzv1iIM";
//public static final String APP_ID = "f12a2c19e72348998b159df903b9b379";
/**
* 测试签署用户编码
*/
//public static final String SIGNER_CODE= "hlzlUser";
//public static final String SIGNER_CODE= "lidongzhang";
/**
* 模板创建合同使用的模板编码
*/
//public static final String CONTRACT_TPL_CODE= "testTemplate";
public static void main(String[] args) {
}
/**
* 生成信签请求操作对象
* @param url
* @return
*/
public static HttpRequest createHttpRequest(String url,String server_url,String app_id,String app_security){
String requestUrl = url;
if(!url.toUpperCase().startsWith("HTTP")){
if(server_url.endsWith("/")){
requestUrl = server_url.substring(0, server_url.length()-1)+url;
}else{
requestUrl = server_url+url;
}
}
HttpRequest httpRequest = new HttpRequest(requestUrl);
/**
* 如果是云服务,需要添加应用id到header
* 如果是私有云,可以不用设置
*/
httpRequest.addHeader("app_id", app_id);
String time = System.currentTimeMillis()+"";
httpRequest.addHeader("time", time);
httpRequest.addHeader("sign", MD5.toMD5(app_id+"."+time+'.'+app_security));
return httpRequest;
}
}
package com.hand.kinggrid;
public class StrKit {
public static boolean notBlank(String str) {
return !isBlank(str);
}
public static boolean isBlank(String str) {
if (str == null) {
return true;
}
int len = str.length();
if (len == 0) {
return true;
}
for (int i = 0; i < len; i++) {
switch (str.charAt(i)) {
case ' ':
case '\t':
case '\n':
case '\r':
// case '\b':
// case '\f':
break;
default:
return false;
}
}
return true;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: gzj
$Date: 2022年12月8日 17:13:08
$Revision: 1.0
$Purpose:
-->
<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,
to_char(t.print_date,'yyyy-mm-dd hh24:mi:ss') print_date,
t.print_id
from cux_contract_print t
where (((SELECT e.role_code
FROM sys_role_vl e
WHERE e.role_id = ${/session/@role_id}) in ('0018', '0019') and
t.file_type = 'EXCEL')
or (SELECT e.role_code
FROM sys_role_vl e
WHERE e.role_id = ${/session/@role_id}) not in
('0018', '0019'))
and t.contract_id = ${@contract_id}
order by t.print_date
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:ns2="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="update">
<bm:update-sql><![CDATA[
BEGIN
hl_contract_pkg.insert_into_attachment_bmp(
p_file_path =>${@p_file_path},
p_file_name =>${@p_file_name},
p_file_size =>${@p_file_size},
p_user_id =>${@p_user_id},
p_contract_id =>${@p_contract_id},
p_file_type =>${@p_file_type}
);
END;
]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: gaoyang
$Date: 2014-11-26 下午04:24:11
$Revision: 1.0
$Purpose:
-->
<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,
faa.attachment_id
FROM
fnd_atm_attachment_multi fam,
fnd_atm_attachment faa
WHERE fam.table_name = 'CON_CONTRACT_CONTENT' AND
fam.attachment_id = faa.attachment_id AND
fam.table_pk_value = ${@content_id}
]]></bm:query-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_name2" databaseType="VARCHAR2" datatype="java.lang.String"/>-->
<bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH"/>
<bm:field name="attachment_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ATTACHMENT_ID"/>
<!-- <bm:field name="templet_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TEMPLET_CODE"/>-->
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: Yenick
$Date: 2018-06-06 下午04:24:11
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="update">
<bm:update-sql><![CDATA[
begin
HL_CONTRACT_PKG.save_pdf_atm(p_content_id =>${@content_id});
end;
]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: wxm
$Date: 2020-6-08 下午04:24:11
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select s.signature_code,
s.code,
s.seal_code,
s.seal_width,
s.fontname,
s.fontsize,
s.fontcolor,
s.pageno,
s.word_code,
s.qfzstart,
s.qfzdistance
from CON_CONTRACT_SIGNATURE_CM s
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="signature_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SIGNATURE_CODE"/>
<bm:field name="code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CODE"/>
<bm:field name="seal_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SEAL_CODE"/>
<bm:field name="seal_width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEAL_WIDTH"/>
<bm:field name="fontname" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FONTNAME"/>
<bm:field name="fontsize" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FONTSIZE"/>
<bm:field name="fontcolor" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FONTCOLOR"/>
<bm:field name="pageno" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PAGENO"/>
<bm:field name="word_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WORD_CODE"/>
<bm:field name="qfzstart" databaseType="NUMBER" datatype="java.lang.Long" physicalName="QFZSTART"/>
<bm:field name="qfzdistance" databaseType="NUMBER" datatype="java.lang.Long" physicalName="QFZDISTANCE"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--<a:service 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>
<s:server-script ><![CDATA[
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importPackage(Packages.com.hand.hl);
importPackage(Packages.java.io);
importPackage(java.io);
try{
var sys_url_bm=$bm('cont.CON4000.get_sys_url');
var parameter_code='HLS_SYSTEM_URL';
var SysurlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var sys_url = SysurlQuery.getChildren()[0].parameter_value;
var down_url =sys_url+'con/contract/conExportExcel?contractId=' +$ctx.parameter.contract_id;
println(down_url);
var now = new Date();
y = now.getFullYear();
m = now.getMonth() + 1;
m = m < 10 ? "0" + m : m;
d = now.getDate();
d = d < 10 ? "0" + d : d;
h = now.getHours();
h = h < 10 ? "0" + h : h;
mi = now.getMinutes();
mi = mi < 10 ? "0" + mi : mi;
var f_fileDir = $ctx.parameter.file_path;
var filePath = (f_fileDir + y + "//" + m + "//").toString();
var tranfer_dir= new File(String(filePath));
if(!tranfer_dir.exists()){//如果文件夹不存在,创建文件夹
tranfer_dir.mkdirs();//创建文件夹
}
var contract_number = $ctx.parameter.contract_number;
var file_name = $ctx.parameter.file_name + y + m + d + h + mi + ".xlsx";
var f_fileName = file_name.toString();
var result_flag=DoloadFileByUrl.downloadFile(down_url, filePath, f_fileName);
file_size=get_file_length(filePath+f_fileName);
if(result_flag=true){
var business_daily_email=$bm('cont.CON301N.insert_into_attachment_bmp').update({
p_file_path :(filePath+f_fileName).toString(),
p_file_name :f_fileName,
p_file_size :file_size,
p_user_id :$ctx.session.user_id,
p_contract_id :$ctx.parameter.contract_id,
p_file_type :'EXCEL'
});
}
}catch(e){
raise_app_error(e.message);
}
function get_file_length(path){
var file=new File(String(path));
if(file.exists() && file.isFile()){
length=file.length();
return length;
}else{
return 0 ;
}
}
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--<a:service 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>
<s:server-script ><![CDATA[
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importPackage(Packages.com.hand.hl);
importPackage(Packages.leaf.plugin.word2pdf);
importPackage(Packages.java.io);
importPackage(java.io);
try{
var sys_url_bm=$bm('cont.CON4000.get_sys_url');
var parameter_code='HLS_SYSTEM_URL';
var SysurlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var sys_url = SysurlQuery.getChildren()[0].parameter_value;
var down_url =sys_url+'con/contract/conExportExcel?contractId=' +$ctx.parameter.contract_id;
var now = new Date();
y = now.getFullYear();
m = now.getMonth() + 1;
m = m < 10 ? "0" + m : m;
d = now.getDate();
d = d < 10 ? "0" + d : d;
h = now.getHours();
h = h < 10 ? "0" + h : h;
mi = now.getMinutes();
mi = mi < 10 ? "0" + mi : mi;
var f_fileDir = $ctx.parameter.file_path;
var filePath = (f_fileDir + y + "\/" + m + "\/").toString();
//var filePath = (f_fileDir + y + "//" + m + "//").toString();
var tranfer_dir= new File(String(filePath));
if(!tranfer_dir.exists()){//如果文件夹不存在,创建文件夹
tranfer_dir.mkdirs();//创建文件夹
}
var contract_number = $ctx.parameter.contract_number;
var file_name = $ctx.parameter.file_name + y + m + d + h + mi + ".xlsx";
var f_fileName = file_name.toString();
var result_flag=DoloadFileByUrl.downloadFile(down_url, filePath, f_fileName);
//excel 转pdf
var to_file_path = filePath + file_name;
var pdf_file_path= filePath + $ctx.parameter.file_name + y + m + d + h + mi + ".pdf";
println('to_file_path = ' + to_file_path);
println('pdf_file_path = ' + pdf_file_path);
var outputfilepath = wordToPdf(to_file_path,pdf_file_path);
file_size=get_file_length(outputfilepath);
pdf_path =(pdf_file_path).toString()
println('p_file_name = '+ $ctx.parameter.file_name + y + m + d + h + mi + ".pdf");
if(result_flag=true){
var business_daily_email=$bm('cont.CON301N.insert_into_attachment_bmp').update({
p_file_path :(pdf_file_path).toString(),
p_file_name :($ctx.parameter.file_name + y + m + d + h + mi + ".pdf").toString(),
p_file_size :file_size,
p_user_id :$ctx.session.user_id,
p_contract_id :$ctx.parameter.contract_id,
p_file_type :'PDF'
});
}
}catch(e){
raise_app_error(e.message);
}
function get_file_length(path){
var file=new File(String(path));
if(file.exists() && file.isFile()){
length=file.length();
return length;
}else{
return 0 ;
}
}
function wordToPdf(word_file_path,pdf_file_path) {
// excel转pdf
//var pdf_file_path_new = pdf_file_path + '.pdf';
var pdf_file_path_new = pdf_file_path;
var wordToPdf = new WordToPdf($instance('uncertain.ocm.IObjectRegistry'), "jacob-1.19-x64.dll");
wordToPdf.exceltopdf(word_file_path, pdf_file_path_new);
//删除word文件
//deleteFile(word_file_path);
return pdf_file_path_new;
}
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: ZLF
$Date: 2014-11-20 下午8:50:38
$Revision: 1.0
$Purpose:
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" customizationEnabled="true"
trace="true">
<a:init-procedure>
<s:server-script import="con_print_path.js"><![CDATA[
set_parameter_file_path();
]]></s:server-script>
<a:model-query model="cont.CON620.get_sys_role" rootPath="role_info"/>
</a:init-procedure>
<a:view>
<a:link id="con_contract_content_asset_detail_link_id"
url="${/request/@context_path}/modules/cont/CON505/con_contract_content_asset_detail.lview"/>
<a:link id="con_doc_batch_create_link_id"
url="${/request/@context_path}/modules/cont/CON500/con_doc_batch_create.lsc"/>
<a:link id="con301n_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
<a:link id="con301n_print_excel_link"
url="${/request/@context_path}/modules/cont/CON301N/con_contract_print_atm.lsc"/>
<a:link id="con301n_print_pdf_link"
url="${/request/@context_path}/modules/cont/CON301N/con_contract_print_pdf.lsc"/>
<script type="text/javascript"><![CDATA[
function lock_current_window() {
Leaf.Masker.mask($('${/parameter/@winid}').wrap, '${l:HLS.EXECUTING}');
}
function unlock_current_window() {
Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
}
function con_print_excel_create() {
Leaf.Masker.mask(Ext.getBody(), '请稍等......');
// var file_name = '对账单(' +'${/parameter/@tenant_name}'+'+'+'${/parameter/@contract_number}'+').doc';
// var file_dir = '$ctx.parameter.file_path';
// var contract_id = '${/parameter/@contract_id}';
// var url;
// url ='${/request/@context_path}/con/contract/conExportExcel?contractId=' + contract_id;
// window.open(href = url);
var contract_id = '${/parameter/@contract_id}';
var contract_number = '${/parameter/@contract_number}';
var tenant_name = '${/parameter/@tenant_name}';
var file_path = '${/parameter/@file_path}';
//var file_name = '对账单('+ tenant_name + '_'+contract_number+').xlsx';
var file_name = '对账单('+ tenant_name + '_'+contract_number+')';
Leaf.request({
url: $('con301n_print_excel_link').getUrl(),
para: {
contract_id : contract_id,
contract_number : contract_number,
file_path : file_path,
file_name : file_name
},
success: function(res) {
Leaf.Masker.unmask(Ext.getBody());
$('con_contract_print_detail_line_ds').query();
},
failure: function() {
Leaf.Masker.unmask(Ext.getBody());
$('con_contract_print_detail_line_ds').query();
},
error: function() {
Leaf.Masker.unmask(Ext.getBody());
$('con_contract_print_detail_line_ds').query();
}
});
}
function con_print_signatures_create() {
Leaf.Masker.mask(Ext.getBody(), '请稍等......');
var contract_id = '${/parameter/@contract_id}';
var contract_number = '${/parameter/@contract_number}';
var tenant_name = '${/parameter/@tenant_name}';
var file_path = '${/parameter/@file_path}';
//var file_name = '对账单('+ tenant_name + '_'+contract_number+').xlsx';
var file_name = '对账单('+ tenant_name + '_'+contract_number+')';
Leaf.request({
url: $('con301n_print_pdf_link').getUrl(),
para: {
contract_id : contract_id,
contract_number : contract_number,
file_path : file_path,
file_name : file_name
},
success: function(res) {
Leaf.Masker.unmask(Ext.getBody());
$('con_contract_print_detail_line_ds').query();
},
failure: function() {
Leaf.Masker.unmask(Ext.getBody());
$('con_contract_print_detail_line_ds').query();
},
error: function() {
Leaf.Masker.unmask(Ext.getBody());
$('con_contract_print_detail_line_ds').query();
}
});
}
function update_attachment_renderer(value, record, name) {
var content_id = record.get('content_id');
return '<a href="javascript:open_uploadfile_win(' + content_id + ')">附件</a>';
}
function attachment_download(val,rec,name) {
return '<a href=javascript:detail_download_window('+rec.get('print_id')+')>下载</a>';}
function detail_download_window(record_id) {
var url = $('con301n_downloadFile_id').getUrl() + '?table_name=CUX_CONTRACT_PRINT&header_id=' + record_id;
var win = new Leaf.Window({
url: url,
title: '${l:HLS.SUPPORTING_DOCUMENT}',
id: 'con301n_records_uploadFile_id',
width: 850,
height: 400
});
win.on('close', function() {
});
}
]]></script>
<a:dataSets>
<a:dataSet id="con_contract_update_print_detail_header_ds" autoCreate="true">
<a:fields>
<a:field name="contract_number" defaultValue="${/parameter/@contract_number}" readOnly="true"/>
<a:field name="contract_name" defaultValue="${/parameter/@contract_name}" readOnly="true"/>
</a:fields>
</a:dataSet>
<a:dataSet id="con_contract_print_detail_line_ds" autoQuery="true" fetchAll="true" pageSize="100"
queryUrl="${/request/@context_path}/autocrud/cont.CON301N.con_statement_of_account_print/query?contract_id=${/parameter/@contract_id}">
<a:fields>
<a:field name="contract_id"/>
<a:field name="content_number" readOnly="true"/>
</a:fields>
</a:dataSet>
</a:dataSets>
<a:screenBody>
<div id="screenTopToolbardiv">
<a:screenTopToolbar style="width:700px">
<a:gridButton id="con_print_id" click="con_print_excel_create" text="生成对账单excel"/>
<a:gridButton id="con_print_signatures_id" click="con_print_signatures_create" text="生成对账单PDF"/>
</a:screenTopToolbar>
<a:form column="2" width="700">
<a:textField name="contract_number" bindTarget="con_contract_update_print_detail_header_ds"
prompt="HLS.CONTRACT_NUMBER"/>
<a:textField name="contract_name" bindTarget="con_contract_update_print_detail_header_ds"
prompt="HLS.CONTRACT_NAME" width="330"/>
</a:form>
</div>
<a:grid id="con_contract_update_print_detail_grid_id" bindTarget="con_contract_print_detail_line_ds"
height="350" navBar="true" width="700">
<a:toolBar>
<a:button prompt="PROMPT.EXPORT_EXCEL" type="excel"/>
</a:toolBar>
<a:columns>
<a:column name="file_name" prompt="文本名称" width="260"/>
<a:column name="print_date" prompt="生成日期" width="180"/>
<a:column name="download" align="center" prompt="下载" renderer="attachment_download" width="50"/>
</a:columns>
</a:grid>
</a:screenBody>
<script type="text/javascript"><![CDATA[
Leaf.onReady(function() {
if("${/model/role_info/record/@role_code}"!="0018"&&"${/model/role_info/record/@role_code}"!="0019") {
document.getElementById("con_print_signatures_id").style.display = "";
} else {
document.getElementById("con_print_signatures_id").style.display = "none";
}
});
]]></script>
</a:view>
</a:screen>
......@@ -35,9 +35,9 @@
url="${/request/@context_path}/modules/cont/CON3200/con_re_incept_modify.lview"/>
<a:link id="${/parameter/@layout_code}_contract_seal_link_id" url="${/request/@context_path}/modules/cont/CON301N/con_contract_finish_seal_info.lview"/>
<a:link id="con_contract_finish_print_link_id" url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_history_pdf_print.lsc"/>
<script src="${/request/@context_path}/javascripts/hap/dynamicStopAutoQuery.js" type="text/javascript"/>
<a:link id="rl_notice_print_link"
url="${/request/@context_path}/modules/cont/CON301N/rl_notice_print.lsc"/>
<!-- <script src="${/request/@context_path}/javascripts/hap/dynamicStopAutoQuery.js" type="text/javascript"/>-->
<a:link id="${/parameter/@layout_code}_contract_print_signatures_link_id"
url="${/request/@context_path}/modules/cont/CON301N/con_contract_print_signatures.lview"/>
<script type="text/javascript"><![CDATA[
// stopDymanicAutoQuery('${/parameter/@layout_code}', 'G_CONTRACT_RESULT', 'con_contract');
......@@ -53,13 +53,13 @@
document.getElementById("CONTRACT_QUERY_ENTRANCE_F_QUERY_NULL_BP_ID_AGENT_LEVEL1_prompt").style.display = "none";
document.getElementById("CONTRACT_QUERY_ENTRANCE_F_QUERY_NULL_BP_ID_AGENT_LEVEL1").style.display = "none";
}
//深圳美鹏和hcs显示分公司,其他隐藏
//深圳美鹏和hcs显示分公司,其他隐藏
var bp_code = '${/model/user_agent_description/record/@bp_code}';
if (!Ext.isEmpty(bp_code) && bp_code !== 'D00010001' && bp_code !== 'D00000009') {
$('${/parameter/@layout_code}_G_CONTRACT_RESULT_con_contract_layout_grid_id').hideColumn('branch_code');
$('${/parameter/@layout_code}_G_CONTRACT_RESULT_con_contract_layout_grid_id').hideColumn('branch_code_n');
}
//dev---环境得code
//dev---环境得code
// if (!Ext.isEmpty(bp_code)&&bp_code!== 'C00010168') {
// $('CONTRACT_QUERY_ENTRANCE_G_CONTRACT_RESULT_con_contract_layout_grid_id').hideColumn('branch_code_n');
// $('CONTRACT_QUERY_ENTRANCE_G_CONTRACT_RESULT_con_contract_layout_grid_id').hideColumn('branch_code');
......@@ -90,14 +90,8 @@
}
}
var role_code = '${/model/role_info/record/@role_code}';
if(role_code!="0008"&&role_code!="0017"&&role_code!="HAND") {
document.getElementById("CONTRACT_QUERY_ENTRANCE_user_button9").style.display = "none";
} else {
document.getElementById("CONTRACT_QUERY_ENTRANCE_user_button9").style.display = "";
}
});
function open_contract_win(ds_id, record_id) {
var record = $(ds_id).findById(record_id);
var param = record.data;
......@@ -116,7 +110,7 @@
//项目类layout_code
maintain_type = 'READONLY';
param = record.data;
param['hide_flag'] = 'Y';
param['hide_flag'] = 'Y';
param['document_id'] = record.get('project_id');
param['function_code'] = 'PRJ501_WFL';
param['function_usage'] = 'QUERY';
......@@ -186,7 +180,7 @@
if (name == 'bs_link') {
return '<a href="javascript:open_bs_Window(\'' + record.id + '\',\'' + record.ds.id + '\')">明细</a>';
}
//modify by lihh 显示字段调整
//modify by lihh 显示字段调整
if(record.get('contract_status') == 'TERMINATE' || record.get('contract_status') == 'INCEPT' || record.get('contract_status') == 'TERMINATING' || record.get('contract_status') == 'ET'
|| record.get('contract_status') == 'ETING' || record.get('contract_status') == 'REPURING' || record.get('contract_status') == 'REPUR'){
if(name == 'con_seal_link'){
......@@ -277,6 +271,7 @@
url ='${/request/@context_path}/con/contract/conExportExcel?contractId=' + record.get('contract_id');
window.open(href = url);
//window.location.href='${/request/@context_path}/con/contract/conExportExcel?contractId='+record.get('contract_id');
};
//返还金通知打印
......@@ -308,6 +303,41 @@
}
//对账单打印加盖公章
window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function () {
debugger;
// var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
// var record = $(ds_id).getSelected()[0];
// var url;
// url ='${/request/@context_path}/con/contract/conExportExcel?contractId=' + record.get('contract_id');
// window.open(href = url);
var ds = $('CONTRACT_QUERY_ENTRANCE_G_CONTRACT_RESULT_con_contract_ds');
var records = ds.getSelected();
if (records.length != 1) {
Leaf.showMessage('提示', '请选择一条数据!');
return;
}
var contract_id = records[0].get('contract_id');
var contract_number = records[0].get('contract_number');
var contract_name = records[0].get('contract_name');
var tenant_name = records[0].get('bp_id_tenant_n');
var win = new Leaf.Window({
id: 'contract_print_signatures',
url: $('${/parameter/@layout_code}_contract_print_signatures_link_id').getUrl(),
params: {
contract_id: contract_id,
contract_number: contract_number,
contract_name: contract_name,
tenant_name: tenant_name,
winid : 'contract_print_signatures_winid'
},
title: '对账单打印',
height: 500,
width: 800
});
};
]]></script>
<a:screen-include
screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON501"/>
......
......@@ -38,7 +38,8 @@
url="${/request/@context_path}/modules/cont/CON620/create_content_lease_return.lsc"/>
<a:link id="${/parameter/@layout_code}_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
<a:link id="con_collection_message_create_link_id" model="cont.CON620.con_collection_message_create" modelaction="update"/>
<a:link id="con_lease_org_print_signatures_link"
url="${/request/@context_path}/modules/cont/CON620/create_content_for_collection_signatures.lsc"/>
<script type="text/javascript"><![CDATA[
Ext.ux.Lightbox.register('a[ref=img]', true);
......@@ -171,7 +172,7 @@
if (!Leaf.isEmpty(temp[0])) {
var file_name = temp[0].toUpperCase();
var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
url = url + '<a href=' + link + temp[1] + ' ref="img">' + temp[0] + '</a>' + ',';
} else {
url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
......@@ -186,7 +187,6 @@
//add by lihh 20210318 发送函件类型为只读
//加载时调用(grid,table,gridBox)
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, record, config_records, bp_seq) {
debugger;
var col_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_collection');
var records = $(col_ds).getAll();
if(ds.id == col_ds && col_ds){
......@@ -200,7 +200,7 @@
records[i].getField('col_person').setReadOnly(true);
records[i].getField('col_object').setReadOnly(true);
records[i].getField('col_detail').setReadOnly(true);
}
}
}
}
};
......@@ -209,13 +209,25 @@
if("${/model/role_info/record/@role_code}"!="0018"&&"${/model/role_info/record/@role_code}"!="0019") {
document.getElementById("CON_DUE_DETAIL_user_button4").style.display = "";
document.getElementById("CON_DUE_DETAIL_user_button3").style.display = "";
document.getElementById("CON_DUE_DETAIL_user_button5").style.display = "";
} else {
document.getElementById("CON_DUE_DETAIL_user_button4").style.display = "none";
document.getElementById("CON_DUE_DETAIL_user_button3").style.display = "none";
document.getElementById("CON_DUE_DETAIL_user_button5").style.display = "none";
}
}
});
//新增催款函pdf打印(盖章)
window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function () {
var contract_id = '${/parameter/@document_id}';
var templet_code = 'CON_LEASE_ORG';
var url=$('con_lease_org_print_signatures_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code;
window.open(url, '_self');
create_message(contract_id,templet_code);
};
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
</a:view>
......
......@@ -7,10 +7,10 @@
importPackage(Packages.org.apache.commons.io);
function RandomString(length) {   
var str = '';   
for (;str.length < length;str += Math.random().toString(36).substr(2));   
return str.substr(0, length); 
function RandomString(length) {
var str = '';
for (;str.length < length;str += Math.random().toString(36).substr(2));
return str.substr(0, length);
}
//删除文件
......@@ -122,7 +122,6 @@
}
}
$ctx.parameter.return_status = 'S';
$ctx.parameter.return_message = '执行成功';
} catch (e) {
......
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