Commit 7c47d916 authored by Luochenglong's avatar Luochenglong

资料导入,附件上传下载接口。工作流板式文件生成调整

parent a1ac21d0
...@@ -216,6 +216,47 @@ ...@@ -216,6 +216,47 @@
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<version>5.3.14</version> <version>5.3.14</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.14</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.23</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>hlcm</finalName> <finalName>hlcm</finalName>
......
package com.hand.att;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* description
*
* @author Administrator 2023/01/03 15:07
*/
public class HttpPostAttUtil {
public static String httpPostAttImport(String postUrl, String data,String token,String tokentype){
try {
PostMethod postMethod = null;
HttpClient httpClient = new HttpClient();
postMethod = new PostMethod(postUrl) ;
RequestEntity entity = null;
postMethod.setRequestHeader("Content-Type", "application/json") ;
postMethod.setRequestHeader("Authorization", tokentype+" "+token) ;
//参数设置,需要注意的就是里边不能传NULL,要传空字符串
entity = new StringRequestEntity(data, "application/json", "UTF-8");
// 设置请求体信息
postMethod.setRequestEntity(entity);
// 执行POST方法
int response = httpClient.executeMethod(postMethod);
String result = postMethod.getResponseBodyAsString() ;
return result;
} catch (Exception e) {
return "{\n" +
" \"error\": \"interError\",\n" +
" \"message\": \"请求接口失败\",\n" +
" \"path\": \"/oauth/token\"\n" +
"}";
}
}
public static String UploadFile(String url, Map<String, String> param, File file, String token, String tokentype ) throws Exception {
try {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append( url)
.append("?");
int i=1;
Set<Map.Entry<String, String>> set = param.entrySet();
Iterator<Map.Entry<String, String>> it = set.iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry<String, String>) it.next();
if(i==1){
stringBuffer.append(entry.getKey()+"="+entry.getValue());
i++;
}else{
stringBuffer.append("&"+entry.getKey()+"="+entry.getValue());
}
}
String post_url = stringBuffer.toString();
System.out.println(post_url);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(post_url);
MultipartEntityBuilder builder=MultipartEntityBuilder.create();
builder.addBinaryBody("file",file);
HttpEntity httpEntity=(HttpEntity)builder.build();
httpPost.setHeader("Authorization", tokentype+" "+token);
httpPost.setEntity(httpEntity);//设置请求参数
HttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
RestTemplate request = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", tokentype+" "+token);
String result = EntityUtils.toString(responseEntity, java.nio.charset.Charset.forName("UTF-8"));
return result;
} catch (Exception ex) {
return ex.getMessage() ;
}
}
public static void main(String[] args) throws Exception {
//String resPonse=httpPostAttImport("http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/import/document","[{\"companyCode\":\"0001\",\"particularYear\":\"2022\",\"documentTypeCode\":\"DT002002\",\"originalNumber\":\"1234567890\",\"primaryField\":\"SAP_TEST0000001\",\"isPaper\":\"true\",\"documentSource\":\"SAP\",\"attachmentList\":[{\"fileURL\":\"https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"fileName\":\"314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"attachmentOID\":\"\"},{\"fileURL\":\"https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"fileName\":\"314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"attachmentOID\":\"\",\"attachTypeCode\":\"0\"}],\"ruleOID\":\"684fb42f-1df4-4710-8ac7-ea0146786a05\",\"securityLevelCode\":\"CONFIDENTIAL\",\"fieldValueList\":[{\"fieldCode\":\"AMOUNT\",\"value\":\"13\"},{\"fieldCode\":\"COMPANY\",\"value\":\"阳光照明\"},{\"fieldCode\":\"DOC_NAME\",\"value\":\"日常报销单\"},{\"fieldCode\":\"CURRENCY\",\"value\":\"CNY\"},{\"fieldCode\":\"CREATED_DATE\",\"value\":\"2021-01-01 12:00:00\"},{\"fieldCode\":\"CREATION_NAME\",\"value\":\"张三\"},{\"fieldCode\":\"REMARK\",\"value\":\"去年的报销\"}]}]","4557fa35-d2da-479a-be68-323b6be619d9","Bearer");
File file=new File("D:\\aurora_reference.pdf");
HashMap mmp = new HashMap();
mmp.put("documentTypeCode", "workflow_QC01");
mmp.put("primaryField", "CF-4252CE7A665C4562BF8E8AC3AD79BF1D");
mmp.put("documentSource", "CF");
mmp.put("companyCode", "HL");
//String resPonse1=doPostFile1("http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/attachment/upload",mmp,file,"4557fa35-d2da-479a-be68-323b6be619d9","Bearer");
String resPonse2=UploadFile("http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/attachment/upload",mmp,file,"4557fa35-d2da-479a-be68-323b6be619d9","Bearer");
System.out.println(resPonse2);
}
}
package com.hand.attDownload;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class attDownload {
public static void downloadFile(HttpServletRequest request, HttpServletResponse response,String filePath,String fileName)
throws IOException {
// 本地文件地址,文件名称,我是在本机运行,如果是服务器的话,地址可能是 ../fileServer/file/deploy2.sh
// String filePath = "D:\\project\\hl_leasing\\file\\2023\\02\\8DAA574FA8714BE9B22B861A6F55AE01";
// String fileName = "8DAA574FA8714BE9B22B861A6F55AE01";
// 获取浏览器的信息
String agent = request.getHeader("USER-AGENT");
if (agent != null && agent.toLowerCase().indexOf("FIRE_FOX") > 0) {
//火狐浏览器自己会对URL进行一次URL转码所以区别处理
response.setHeader("Content-Disposition",
"attachment; filename=" + new String(fileName.getBytes("GB2312"), "ISO-8859-1"));
} else if (agent.toLowerCase().indexOf("SAFARI") > 0) {
//苹果浏览器需要用ISO 而且文件名得用UTF-8
response.setHeader("Content-Disposition",
"attachment; filename=" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1"));
} else {
//其他的浏览器
response.setHeader("Content-Disposition",
"attachment; filename=\"" + java.net.URLEncoder.encode(fileName, "UTF-8"));
}
response.setContentType("charset=utf-8");
String result = "{\"statusCode\":\"00000\",\"message\":\"success\"}";
// 返回数据
response.getWriter().print(result);
File file = new File(filePath);
FileInputStream fileInputStream = new FileInputStream(file);
byte[] fileByte = new byte[(int) file.length()];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int len;
while ((len = fileInputStream.read(bytes, 0, bytes.length)) != -1) {
byteArrayOutputStream.write(bytes, 0, len);
}
byteArrayOutputStream.close();
fileByte = byteArrayOutputStream.toByteArray();
OutputStream outputStream = null;
outputStream = response.getOutputStream();
outputStream.write(fileByte);
outputStream.flush();
outputStream.close();
}
public static void downloadUitl(HttpServletResponse response,String filePath,String fileName)
throws IOException {
// 本地文件地址,文件名称,我是在本机运行,如果是服务器的话,地址可能是 ../fileServer/file/deploy2.sh
// String filePath = "D:\\project\\hl_leasing\\file\\2023\\02\\8DAA574FA8714BE9B22B861A6F55AE01";
// String fileName = "8DAA574FA8714BE9B22B861A6F55AE01";
File file = new File(filePath);
FileInputStream fileInputStream = new FileInputStream(file);
byte[] fileByte = new byte[(int) file.length()];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int len;
while ((len = fileInputStream.read(bytes, 0, bytes.length)) != -1) {
byteArrayOutputStream.write(bytes, 0, len);
}
byteArrayOutputStream.close();
fileByte = byteArrayOutputStream.toByteArray();
OutputStream outputStream = null;
outputStream = response.getOutputStream();
outputStream.write(fileByte);
outputStream.flush();
outputStream.close();
}
public static void main(String[] args) throws Exception {
File file=new File("D:\\aurora_reference.pdf");
String filePath = "D:\\project\\hl_leasing\\file\\2023\\02\\8DAA574FA8714BE9B22B861A6F55AE01";
String fileName = "8DAA574FA8714BE9B22B861A6F55AE01";
}
}
package com.hand.hl;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
/**
* description
*
* @author lcl 2023/02/15 15:07
*/
public class HttpPostUtilNew {
public HttpPostUtilNew() {
}
public static String httpPostDocImport(String postUrl, String data, String token, String tokentype) {
try {
PostMethod postMethod = null;
HttpClient httpClient = new HttpClient();
postMethod = new PostMethod(postUrl);
RequestEntity entity = null;
postMethod.setRequestHeader("Content-Type", "application/json");
postMethod.setRequestHeader("Authorization", tokentype + " " + token);
entity = new StringRequestEntity(data, "application/json", "UTF-8");
postMethod.setRequestEntity(entity);
System.out.println(data);
httpClient.executeMethod(postMethod);
String result = postMethod.getResponseBodyAsString();
return result;
} catch (Exception var9) {
return "{\n \"error\": \"interError\",\n \"message\": \"请求接口失败\",\n \"path\": \"/oauth/token\"\n}";
}
}
public static void main(String[] args) throws Exception {
String resPonse = httpPostDocImport("http://apistage.huilianyi.com/gateway/e-archives/api/open/v1/import/document", "[{\"companyCode\":\"0001\",\"particularYear\":\"2022\",\"documentTypeCode\":\"DT002002\",\"originalNumber\":\"1234567890\",\"primaryField\":\"SAP_TEST0000001\",\"isPaper\":\"true\",\"documentSource\":\"SAP\",\"attachmentList\":[{\"fileURL\":\"https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"fileName\":\"314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"attachmentOID\":\"\"},{\"fileURL\":\"https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"fileName\":\"314e251f95cad1c8ea88af74793e6709c93d51b5.jpg\",\"attachmentOID\":\"\",\"attachTypeCode\":\"0\"}],\"ruleOID\":\"684fb42f-1df4-4710-8ac7-ea0146786a05\",\"securityLevelCode\":\"CONFIDENTIAL\",\"fieldValueList\":[{\"fieldCode\":\"AMOUNT\",\"value\":\"13\"},{\"fieldCode\":\"COMPANY\",\"value\":\"阳光照明\"},{\"fieldCode\":\"DOC_NAME\",\"value\":\"日常报销单\"},{\"fieldCode\":\"CURRENCY\",\"value\":\"CNY\"},{\"fieldCode\":\"CREATED_DATE\",\"value\":\"2021-01-01 12:00:00\"},{\"fieldCode\":\"CREATION_NAME\",\"value\":\"张三\"},{\"fieldCode\":\"REMARK\",\"value\":\"去年的报销\"}]}]", "4557fa35-d2da-479a-be68-323b6be619d9", "Bearer");
System.out.println(resPonse);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 早上 11:03:31
$Revision: 1.0
$Purpose: 电子档案池bm
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" >
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT
fam.table_name,
fam.table_pk_value,
fam.record_id,
faa.attachment_id,
faa.file_name,
faa.file_type_code,
faa.file_path
FROM
fnd_atm_attachment_multi fam,
fnd_atm_attachment faa
WHERE
fam.attachment_id = ${@attachment_id} AND
faa.rowid =${@rowid} AND
fam.attachment_id = faa.attachment_id
]]></bm:query-sql>
<bm:parameters>
<bm:parameter name="attachment_id"/>
<bm:parameter name="rowid"/>
</bm:parameters>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="table_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TABLE_NAME" required="true"/>
<bm:field name="table_pk_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TABLE_PK_VALUE" required="true"/>
<bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RECORD_ID" required="true"/>
<bm:field name="attachment_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ATTACHMENT_ID" required="true"/>
<bm:field name="file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_NAME"/>
<bm:field name="file_type_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_TYPE_CODE"/>
<bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 早上 11:03:31
$Revision: 1.0
$Purpose: 电子档案池bm
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" >
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select * from (SELECT t1.pool_id,
t1.primary_field,
t1.internal_period_num,
t1.base_archive_code,
t1.archive_type,
t1.document_id,
t1.document_number,
t1.document_info,
t1.post_status,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='DATA_CLASSIFICATION' and c.code_value = t1.archive_type) archive_type_desc,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='YES_NO' and c.code_value = 'Y') suppl_trans_flag, t1.hly_req_number as post_batch_num,
t1.post_message
FROM hl_e_archives_pool t1
where t1.creation_date>=sysdate-30)
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="pool_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="POOL_ID" />
<bm:field name="primary_field" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRIMARY_ID" />
<bm:field name="internal_period_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INTERNAL_PERIOD_NUM"/>
<bm:field name="base_archive_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BASE_ARCHIVE_CODE" />
<bm:field name="archive_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ARCHIVE_TYPE"/>
<bm:field name="document_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOCUMENT_ID"/>
<bm:field name="document_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_NUMBER"/>
<bm:field name="post_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_NUMBER"/>
<bm:field name="document_info" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_STATUS"/>
<bm:field name="post_message" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_MESSAGE"/>
</bm:fields>
</bm:model>
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<bm:operation name="query"> <bm:operation name="query">
<bm:query-sql><![CDATA[ <bm:query-sql><![CDATA[
SELECT t1.pool_id, SELECT t1.pool_id,
t1.primary_field,
t1.internal_period_num, t1.internal_period_num,
t1.base_archive_code, t1.base_archive_code,
t1.archive_type, t1.archive_type,
...@@ -17,12 +18,10 @@ ...@@ -17,12 +18,10 @@
t1.document_number, t1.document_number,
t1.document_info, t1.document_info,
t1.post_status, t1.post_status,
nvl((select gps.monthly_closed_flag from gld_periods gp,gld_period_status gps where replace(gp.period_name,'-','')=t1.internal_period_num and gps.company_id = ${/session/@company_id} and gp.internal_period_num=gps.internal_period_num and gps.period_set_code=gp.period_set_code),'N') monthly_closed_flag ,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='DATA_CLASSIFICATION' and c.code_value = t1.archive_type) archive_type_desc, (SELECT c.code_value_name FROM sys_code_values_v c where c.code='DATA_CLASSIFICATION' and c.code_value = t1.archive_type) archive_type_desc,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='YES_NO' and c.code_value = 'Y') suppl_trans_flag, (SELECT c.code_value_name FROM sys_code_values_v c where c.code='YES_NO' and c.code_value = 'Y') suppl_trans_flag,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='POST_STATUS_DESC' and c.code_value =t1.post_status) post_status_desc, t1.hly_req_number as post_batch_num,
'CM_xxxxxx' as cm_pk,
'xxxxx' as original_archive_no,
'xxxx' as post_batch_num,
t1.post_message t1.post_message
FROM hl_e_archives_pool t1 FROM hl_e_archives_pool t1
#WHERE_CLAUSE# #WHERE_CLAUSE#
...@@ -80,12 +79,12 @@ ...@@ -80,12 +79,12 @@
</bm:operation> </bm:operation>
</bm:operations> </bm:operations>
<bm:query-fields> <bm:query-fields>
<bm:query-field field="internal_period_num" queryExpression="t1.internal_period_num =${@internal_period_num}"/> <bm:query-field name="internal_period_num" queryExpression="t1.internal_period_num =${@internal_period_num}"/>
<bm:query-field field="archive_type_desc" queryExpression="t1.archive_type_desc =${@archive_type_desc}"/> <bm:query-field name="archive_type_desc" queryExpression="t1.archive_type_desc =${@archive_type_desc}"/>
<bm:query-field field="cm_pk" queryExpression="t1.cm_pk =${@cm_pk}"/> <bm:query-field name="primary_field" queryExpression="t1.primary_field =${@primary_field}"/>
<bm:query-field field="original_archive_no" queryExpression="t1.original_archive_no =${@original_archive_no}"/> <bm:query-field name="document_info" queryExpression="t1.document_info =${@document_info}"/>
<bm:query-field field="post_status_desc" queryExpression="t1.post_status_desc =${@post_status_desc}"/> <bm:query-field name="post_status" queryExpression="t1.post_status =${@post_status}"/>
<bm:query-field field="post_batch_num" queryExpression="t1.post_batch_num =${@post_batch_num}"/> <bm:query-field name="post_batch_num" queryExpression="t1.post_batch_num =${@post_batch_num}"/>
<bm:query-field field="suppl_trans_flag" queryExpression="t1.suppl_trans_flag =${@suppl_trans_flag}"/> <bm:query-field name="suppl_trans_flag" queryExpression="t1.suppl_trans_flag =${@suppl_trans_flag}"/>
</bm:query-fields> </bm:query-fields>
</bm:model> </bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 早上 11:03:31
$Revision: 1.0
$Purpose: 电子档案池bm
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" >
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select '{'||pt.atm_data_json||'}' sql_content
from hl_e_archives_pool_data pt
where pt.pool_id = ${@pool_id}
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="sql_content" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 早上 11:03:31
$Revision: 1.0
$Purpose: 电子档案池bm
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" >
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select '{'||pt.stru_data_json||'}' sql_content
from hl_e_archives_pool_data pt
where pt.pool_id = ${@pool_id}
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="sql_content" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 早上 11:03:31
$Revision: 1.0
$Purpose: 电子档案池bm
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" >
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT t1.pool_id,
t1.primary_field,
t1.internal_period_num,
t1.base_archive_code,
t1.archive_type,
t1.document_id,
t1.document_number,
t1.document_info,
t1.post_status,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='DATA_CLASSIFICATION' and c.code_value = t1.archive_type) archive_type_desc,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='YES_NO' and c.code_value = 'Y') suppl_trans_flag,
(SELECT c.code_value_name FROM sys_code_values_v c where c.code='POST_STATUS_DESC' and c.code_value =t1.post_status) post_status_desc,
t1.hly_req_number as post_batch_num,
t1.post_message
FROM hl_e_archives_pool t1
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
<bm:operation name="insert">
<bm:update-sql><![CDATA[
begin
elec_wfl_pkg.doc_import_return(
p_primary_field =>${@primary_field},
p_post_status =>${@post_status},
p_post_message =>${@post_message},
p_hly_req_number =>${@hly_req_number},
p_user_id => ${/session/@user_id});
end;
]]></bm:update-sql>
</bm:operation>
<bm:operation name="update">
<bm:update-sql><![CDATA[
begin
elec_wfl_pkg.elec_type_update(
p_sql_type => 'UPDATE',
p_base_archive_id => ${@base_archive_id},
p_base_archive_code => ${@base_archive_code},
p_archive_type => ${@archive_type},
p_post_stru_data_flag => ${@post_stru_data_flag},
p_stru_data_sql => ${@stru_data_sql},
p_is_workflow => ${@is_workflow},
p_workflow_id => ${@workflow_id},
p_post_atm_flag => ${@post_atm_flag},
p_atm_sql => ${@atm_sql},
p_je_check_flag => ${@je_check_flag},
p_je_source_sql => ${@je_source_sql},
p_user_id => ${/session/@user_id});
end;
]]></bm:update-sql>
</bm:operation>
<bm:operation name="delete">
<bm:update-sql><![CDATA[
begin
elec_wfl_pkg.elec_type_delete(
p_base_archive_id => ${@base_archive_id},
p_user_id => ${/session/@user_id});
end;
]]></bm:update-sql>
</bm:operation>
</bm:operations>
<bm:query-fields>
<bm:query-field name="internal_period_num" queryExpression="t1.internal_period_num =${@internal_period_num}"/>
<bm:query-field name="archive_type_desc" queryExpression="t1.archive_type_desc =${@archive_type_desc}"/>
<bm:query-field name="primary_field" queryExpression="t1.primary_field =${@primary_field}"/>
<bm:query-field name="document_info" queryExpression="t1.document_info like ${@document_info}"/>
<bm:query-field name="post_status_desc" queryExpression="t1.post_status_desc =${@post_status_desc}"/>
<bm:query-field name="post_batch_num" queryExpression="t1.post_batch_num =${@post_batch_num}"/>
<bm:query-field name="suppl_trans_flag" queryExpression="t1.suppl_trans_flag =${@suppl_trans_flag}"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: luochenglong
$Date: 2023-02-10 早上 11:03:31
$Revision: 1.0
$Purpose: 电子档案池bm
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" >
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select pt.atm_data_json attachmentList,pt.stru_data_json as fieldValueList
from hl_e_archives_pool_data pt
where pt.pool_id = ${@pool_id}
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="fieldValueList"/>
<bm:field name="attachmentList"/>
</bm:fields>
</bm:model>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<bm:update-sql><![CDATA[ <bm:update-sql><![CDATA[
BEGIN BEGIN
wfl_instance_pdf_pkg.create_wfl_instance_content(p_instance_id => ${@instance_id}, wfl_instance_pdf_pkg.create_wfl_instance_content(p_instance_id => ${@instance_id},
p_user_id => ${/session/@user_id}); p_user_id => nvl(${/session/@user_id},${@user_id}));
commit; commit;
END; END;
]]></bm:update-sql> ]]></bm:update-sql>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
p_table_pk_value =>${@instance_id}, p_table_pk_value =>${@instance_id},
p_file_name =>${@file_name}, p_file_name =>${@file_name},
p_file_path =>${@file_path}, p_file_path =>${@file_path},
p_user_id =>nvl(${/session/@user_id},1), p_user_id =>nvl(${/session/@user_id},${@user_id}),
p_file_size =>${@file_size} p_file_size =>${@file_size}
); );
END; END;
......
importClass(Packages.com.hand.attDownload.attDownload);
importPackage(Packages.java.io);
importPackage(Packages.java.util);
//importClass(Packages.leaf.plugin.util.Base64);
function attDownloadUtil(response,filePath,fileName) {
try {
var result = new attDownload().downloadUitl(response,filePath,fileName);
return result;
} catch (e) {
println(e);
return false;
}
}attDownload
\ No newline at end of file
importClass(Packages.com.hand.att.HttpPostAttUtil);
importPackage(Packages.java.io);
importPackage(Packages.java.util);
//importClass(Packages.leaf.plugin.util.Base64);
function httpPostAttUpload(postUrl,maplist,file,token,tokentype) {
try {
var result = new HttpPostAttUtil().UploadFile(postUrl,maplist,file,token,tokentype);
return result;
} catch (e) {
println(e);
return false;
}
}
\ No newline at end of file
importClass(Packages.com.hand.hl.HttpPostUtilNew);
importPackage(Packages.java.io);
importPackage(Packages.java.util);
//importClass(Packages.leaf.plugin.util.Base64);
function httpPostDocImport(postUrl,data,token,tokentType) {
try {
var result = new HttpPostUtilNew().httpPostDocImport(postUrl,data,token,tokentType);
return result;
} catch (e) {
println(e);
return false;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<batch-apply sourcepath="/parameter">
<a:model-insert model="efile.EFILE1020.efile_generated_selected"/>
</batch-apply>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
<?xml version="1.0" encoding="UTF-8"?>
<a:service 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 import="att_downloadUtil.js"><![CDATA[
importPackage(java.util.zip);
importPackage(java.io);
importPackage(java.net);
var logger = $logger('server-script');
$ctx["__request_type__"] = 'file';
var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
resp.setHeader("Pragma", "No-cache");
resp.setHeader("Cache-Control", "no-cache, must-revalidate");
var attachment_id = $ctx.parameter.attachment_id;
var rowid = $ctx.parameter.rowid;
var attachment_queryBm = $bm('efile.EFILE1030.att_download');
logger.info(attachment_id);
var attachment_data = attachment_queryBm.queryAsMap({
attachment_id: attachment_id,
rowid:rowid
});
if(attachment_id&&rowid){
var filename = attachment_data.getChildren()[0].file_name;
var filepath= attachment_data.getChildren()[0].file_path;
resp.setHeader("Content-Disposition",
"attachment; filename=\"" + java.net.URLEncoder.encode(filename, "UTF-8"));
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
attDownloadUtil(resp,filepath,filename);
}
]]></s:server-script>
</a:init-procedure>
</a:service>
...@@ -9,18 +9,76 @@ ...@@ -9,18 +9,76 @@
<a:view> <a:view>
<a:link id="att_link_id" url="${/request/@context_path}/modules/efile/EFILE1030/efile_att_json_lov.lview"/> <a:link id="att_link_id" url="${/request/@context_path}/modules/efile/EFILE1030/efile_att_json_lov.lview"/>
<a:link id="post_stru_link_id" url="${/request/@context_path}/modules/efile/EFILE1030/efile_post_stru_json_lov.lview"/> <a:link id="post_stru_link_id" url="${/request/@context_path}/modules/efile/EFILE1030/efile_post_stru_json_lov.lview"/>
<a:link id="doc_post_link" url="${/request/@context_path}/modules/efile/EFILE1040/efile_doc_import.svc"/>
<script type="text/javascript"><![CDATA[ <script type="text/javascript"><![CDATA[
function efile_archive_pool_batch_trans() { function efile_archive_pool_batch_trans() {
Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
Leaf.request({
url: $('doc_post_link').getUrl(),
para: {
batch_flag :'Y'
},
success: function() {
Leaf.Masker.unmask(Ext.getBody());
Leaf.showMessage('提示','传输成功',function(){
$('efile_archive_pool_ds').query();
});
},
failure: function() {
Leaf.Masker.unmask(Ext.getBody());
},
error: function() {
Leaf.Masker.unmask(Ext.getBody());
},
scope: this
});
} }
function efile_archive_pool_manual_trans() { function efile_archive_pool_manual_trans() {
var record = $('efile_archive_pool_ds').getSelected();
if (record.length==0){
Leaf.showMessage('提示','请选择传输数据!');
return;
}
for (var i = 0; i < record.length; i++) {
if(record[i].get('monthly_closed_flag')=='N'){
Leaf.showMessage('提示','资料期间对应的会计期间必须是关账状态!');
return;
}
}
var records = new Array();
for (i = 0;i < record.length;i++) {
records.push(record[i].data);
/* if (record[i].get('upload_ftp_flag') == 'Y') {
Aurora.showMessage('提示','已上传批次不能重复上传!');
return;
}*/
}
Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
Leaf.request({
url: $('doc_post_link').getUrl(),
para: records,
success: function() {
Leaf.Masker.unmask(Ext.getBody());
Leaf.showMessage('提示','传输成功',function(){
$('efile_archive_pool_ds').query();
});
},
failure: function() {
Leaf.Masker.unmask(Ext.getBody());
},
error: function() {
Leaf.Masker.unmask(Ext.getBody());
},
scope: this
});
} }
function efile_archive_pool_reset() { function efile_archive_pool_reset() {
...@@ -88,9 +146,9 @@ ...@@ -88,9 +146,9 @@
<a:dataSet id="for_query_ds" autoCreate="true"> <a:dataSet id="for_query_ds" autoCreate="true">
<a:fields> <a:fields>
<a:field name="internal_period_num" /> <a:field name="internal_period_num" />
<a:field name="psot_batch_num" /> <a:field name="post_batch_num" />
<a:field name="cm_pk" /> <a:field name="primary_field" />
<a:field name="original_archive_no" /> <a:field name="document_info" />
<a:field name="post_status" /> <a:field name="post_status" />
<a:field name="archive_type" /> <a:field name="archive_type" />
<a:field name="archive_type_desc" displayField="code_value_name" options="data_cf_ds" returnField="archive_type" valueField="code_value"/> <a:field name="archive_type_desc" displayField="code_value_name" options="data_cf_ds" returnField="archive_type" valueField="code_value"/>
...@@ -99,9 +157,8 @@ ...@@ -99,9 +157,8 @@
</a:fields> </a:fields>
</a:dataSet> </a:dataSet>
<a:dataSet id="efile_archive_pool_ds" model="efile.EFILE1030.e_archive_pool_query" queryDataSet="for_query_ds" selectable="true"> <a:dataSet id="efile_archive_pool_ds" model="efile.EFILE1030.e_archive_pool_query" queryDataSet="for_query_ds" selectable="true">
<a:fields> <a:fields>
<a:field name="cm_pk" /> <a:field name="monthly_closed_flag" />
<a:field name="pool_id" />
</a:fields> </a:fields>
</a:dataSet> </a:dataSet>
</a:dataSets> </a:dataSets>
...@@ -116,32 +173,25 @@ ...@@ -116,32 +173,25 @@
<a:form column="4" marginWidth="30" title="查询条件"> <a:form column="4" marginWidth="30" title="查询条件">
<a:textField name="internal_period_num" bindTarget="for_query_ds" prompt="资料期间"/> <a:textField name="internal_period_num" bindTarget="for_query_ds" prompt="资料期间"/>
<a:comboBox name="archive_type_desc" bindTarget="for_query_ds" prompt="资料类型"/> <a:comboBox name="archive_type_desc" bindTarget="for_query_ds" prompt="资料类型"/>
<a:textField name="cm_pk" bindTarget="for_query_ds" prompt="主键"/> <a:textField name="primary_field" bindTarget="for_query_ds" prompt="主键"/>
<a:comboBox name="suppl_trans_flag" bindTarget="for_query_ds" prompt="是否补传"/> <a:comboBox name="suppl_trans_flag" bindTarget="for_query_ds" prompt="是否补传"/>
<a:textField name="original_archive_no" bindTarget="for_query_ds" prompt="原始资料号"/> <a:textField name="document_info" bindTarget="for_query_ds" prompt="原始资料号"/>
<a:comboBox name="post_status_desc" bindTarget="for_query_ds" prompt="传输状态"/> <a:comboBox name="post_status_desc" bindTarget="for_query_ds" prompt="传输状态"/>
<a:textField name="psot_batch_num" bindTarget="for_query_ds" prompt="传输批次号"/> <a:textField name="post_batch_num" bindTarget="for_query_ds" prompt="传输批次号"/>
</a:form> </a:form>
<a:grid id="efile_archive_pool_ds_id" bindTarget="efile_archive_pool_ds" marginHeight="200" marginWidth="30" navBar="true"> <a:grid id="efile_archive_pool_ds_id" bindTarget="efile_archive_pool_ds" marginHeight="200" marginWidth="30" navBar="true">
<a:columns> <a:columns>
<a:column name="cm_pk" prompt="主键" width="140"/> <a:column name="primary_field" prompt="主键" width="320"/>
<a:column name="internal_period_num" prompt="资料期间" width="120"/> <a:column name="internal_period_num" prompt="资料期间" width="120"/>
<a:column name="archive_type_desc" prompt="资料类型" width="150"/> <a:column name="archive_type_desc" prompt="资料类型" width="120"/>
<a:column name="original_archive_no" prompt="原始资料号" width="140"/> <a:column name="document_info" prompt="原始资料号" width="300"/>
<a:column name="post_stru_data" prompt="结构化数据" renderer="att_update_renderer" /> <a:column name="post_stru_data" prompt="结构化数据" renderer="att_update_renderer" width="110"/>
<a:column name="att" align="center" prompt="附件" renderer="att_update_renderer"/> <a:column name="att" align="center" prompt="附件" renderer="att_update_renderer"/>
<a:column name="suppl_trans_flag" align="center" width="120" prompt="是否补传"/> <a:column name="suppl_trans_flag" align="center" width="120" prompt="是否补传"/>
<a:column name="post_status_desc" align="center" width="120" prompt="传输状态"/> <a:column name="post_status" align="center" width="120" prompt="传输状态"/>
<a:column name="post_message" align="center" width="180" prompt="传输结果"/> <a:column name="post_message" align="center" width="180" prompt="传输结果"/>
<a:column name="psot_batch_num" align="center" width="140" prompt="传输批次号"/> <a:column name="post_batch_num" align="center" width="120" prompt="传输批次号"/>
</a:columns> </a:columns>
<a:editors>
<a:textField id="text_ed"/>
<a:textField id="text_ed_up" typeCase="upper"/>
<a:checkBox id="checkbox_ed"/>
<a:lov id="conBasicClauseParaDs_grid_lov"/>
<a:comboBox id="efile_archive_pool_comed"/>
</a:editors>
</a:grid> </a:grid>
</a:screenBody> </a:screenBody>
</a:view> </a:view>
......
<?xml version="1.0" encoding="UTF-8"?>
<a:service 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 import="token_record.js;att_upload.js"><![CDATA[
try {
var logger = $logger('server-script');
logger.info('------');
var req_date = $ctx.parameter.getChildren();
var sys_url_bm = $bm('cont.CON4000.get_sys_url');
var parameter_code = 'TOKEN_POSTURL';
var SysposturlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var posturl = SysposturlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPID';
var SysappidQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appid = SysappidQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPSECRET';
var SysappsecretQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var parameter_code = 'ATT_UPLOAD_POSTURL';
var attUrlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var attUrl = attUrlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_TYPE';
var tokenTypeyQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_type = tokenTypeyQuery.getChildren()[0].parameter_value;
var token_appsecret = SysappsecretQuery.getChildren()[0].parameter_value;
var token_savelogs_bm = $bm('efile.EFILE1000.efile_get_token');
//token是否在有效期内,在有效期内直接获取表中的token
var check_token_valid_bm = $bm('efile.EFILE1000.check_token_valid');
var checkTokenQuery = check_token_valid_bm.queryAsMap();
var is_valid = checkTokenQuery.getChildren()[0].is_valid;
var file=new File('D:\\aurora_reference.pdf');
var map = {
"documentTypeCode" : "workflow_QC02",
"primaryField":"CF-4252CE7A665C4562BF8E8AC3AD79BF1D",
"documentSource":"CF",
"companyCode":"HL"
}
if (is_valid == 'true') {
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var data=httpPostAttUpload(attUrl,map,file,access_token,token_type);
var json = JSON.parse(data);
logger.info(data);
} else {
println("=======有效期外======");
var data = httpPostGetToken(posturl, token_appid, token_appsecret);
var json = JSON.parse(data);
var access_token = json.access_token;
var status = json.status;
if (access_token) {
var data_att=httpPostAttUpload(attUrl,map,file,access_token,token_type);
var json = JSON.parse(data_att);
logger.info(data_att);
token_savelogs_bm.insert({
'json': data,
'status': 'success'
})
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
})
}
if (status) {
var token_savelogs_bm = $bm('efile.EFILE1000.token_savelogs');
token_savelogs_bm.insert({
'json': json,
'status': 'fail'
});
}
}
} catch (e) {
println('e:' + e);
}
]]></s:server-script>
</a:init-procedure>
</a:service>
<?xml version="1.0" encoding="UTF-8"?>
<a:service 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 import="token_record.js;doc_import.js"><![CDATA[
try {
var logger = $logger('server-script');
var req_date = $ctx.parameter.getChildren();
var batch_flag=$ctx.parameter.batch_flag;
var sys_url_bm = $bm('cont.CON4000.get_sys_url');
var parameter_code = 'TOKEN_POSTURL';
var SysposturlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var batch_databm=$bm('efile.EFILE1030.e_archive_pool_batch_query');
var batch_data=batch_databm.queryAsMap().getChildren();
var posturl = SysposturlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPID';
var SysappidQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appid = SysappidQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPSECRET';
var SysappsecretQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var parameter_code = 'DOC_REQUESTURL';
var docUrlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var docUrl = docUrlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_TYPE';
var tokenTypeyQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_type = tokenTypeyQuery.getChildren()[0].parameter_value;
var token_appsecret = SysappsecretQuery.getChildren()[0].parameter_value;
var token_savelogs_bm = $bm('efile.EFILE1000.efile_get_token');
//token是否在有效期内,在有效期内直接获取表中的token
var check_token_valid_bm = $bm('efile.EFILE1000.check_token_valid');
var checkTokenQuery = check_token_valid_bm.queryAsMap();
var is_valid = checkTokenQuery.getChildren()[0].is_valid;
var fieldValueList_bm=$bm('efile.EFILE1040.efile_doc_import_query');
var record=[];
var doc_data=[];
var batch_num=0;
if(batch_flag=='Y'){
for(var i=0;i<batch_data.length;i++){
var fieldValueList_data = fieldValueList_bm.queryAsMap({
pool_id: batch_data[i].pool_id
});
var fieldValueList=fieldValueList_data.getChildren()[0].fieldValueList;
var attlist=[];
var filelist=[];
if(fieldValueList.length==8){
filelist='[]';
}else{
fieldValueList=fieldValueList.substring(17);
fieldValueList=JSON.parse(fieldValueList);
fieldValueList=JSON.stringify(fieldValueList);
filelist.push(fieldValueList);
}
var attachmentList = fieldValueList_data.getChildren()[0].attachmentList;
attachmentList=attachmentList.replace('\s+', '');
if(attachmentList.length==8){
attlist='[]';
}else{
attachmentList=attachmentList.substring(17);
logger.info(attachmentList);
attachmentList=JSON.parse(attachmentList);
attachmentList=JSON.stringify(attachmentList);
attlist.push(attachmentList);
}
var companyCode='HL';
var documentTypeCode=batch_data[i].base_archive_code;
var originalNumber=batch_data[i].document_info;
var primaryField=batch_data[i].primary_field;
var isPaper='true';
var documentSource='CF';
var ruleOID='';
var securityLevelCode='';
var fils = '{'
+'"companyCode": "'+companyCode
+'",'
+'"documentTypeCode": "'+documentTypeCode
+'",'
+'"originalNumber": "'+originalNumber
+'",'
+'"primaryField": "'+primaryField
+'",'
+'"isPaper": "'+isPaper
+'",'
+'"documentSource": "'+documentSource
+'",'
+'"ruleOID": "'+ruleOID
+'",'
+'"securityLevelCode": "'+securityLevelCode
+'",'
+'"attachmentList": '+attlist
+','
+'"fieldValueList": '+filelist
+'}';
fils=JSON.parse(fils);
doc_data.push(fils);
if(doc_data.length==100||batch_data.length==i+1){
batch_num++;
if (is_valid == 'true') {
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var doc_data=JSON.stringify(doc_data);
doc_data=doc_data.replace(/[\'\\\\/\b\f\n\r\t]/g, '');
logger.info(doc_data);
var data = httpPostDocImport(docUrl,doc_data,access_token, token_type);
var json_data = JSON.parse(data);
var statusCode =json_data.statusCode;
var message =json_data.message;
var result=json_data.result;
var doc_import_return_bm = $bm('efile.EFILE1040.doc_import_return');
for(var i=0;i<result.length;i++){
doc_import_return_bm.insert({
'primary_field': result[i].primaryField,
'post_status': message,
'post_message': result[i].failedMessage,
'hly_req_number': batch_num
})
}
logger.info(data);
} else {
println("=======有效期外======");
var data = httpPostGetToken(posturl, token_appid, token_appsecret);
var json = JSON.parse(data);
var access_token = json.access_token;
var status = json.status;
logger.info(access_token);
var doc_data=JSON.stringify(doc_data);
doc_data=doc_data.replace(/[\'\\\\/\b\f\n\r\t]/g, '');
logger.info(doc_data);
var data_result = httpPostDocImport(docUrl,doc_data,access_token, token_type);
logger.info(data_result);
var json_data = JSON.parse(data_result);
logger.info(json_data);
var statusCode =json_data.statusCode;
var message =json_data.message;
var result=json_data.result;
var doc_import_return_bm = $bm('efile.EFILE1040.doc_import_return');
for(var i=0;i<result.length;i++){
if(result[i].primaryField){
doc_import_return_bm.insert({
'primary_field': result[i].primaryField,
'post_status': message,
'post_message': result[i].failedMessage,
'hly_req_number': batch_num
})
}
}
if (access_token) {
token_savelogs_bm.insert({
'json': data,
'status': 'success'
})
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
})
}
if (status) {
var token_savelogs_bm = $bm('efile.EFILE1000.token_savelogs');
token_savelogs_bm.insert({
'json': json,
'status': 'fail'
});
}
}
doc_data=[];
}
}
}else{
for(var i=0;i<req_date.length;i++){
var fieldValueList_data = fieldValueList_bm.queryAsMap({
pool_id: req_date[i].pool_id
});
var fieldValueList=fieldValueList_data.getChildren()[0].fieldValueList;
var attlist=[];
var filelist=[];
if(fieldValueList.length==8){
filelist='[]';
}else{
fieldValueList=fieldValueList.substring(17);
fieldValueList=JSON.parse(fieldValueList);
fieldValueList=JSON.stringify(fieldValueList);
filelist.push(fieldValueList);
}
var attachmentList = fieldValueList_data.getChildren()[0].attachmentList;
attachmentList=attachmentList.replace('\s+', '');
if(attachmentList.length==8){
attlist='[]';
}else{
attachmentList=attachmentList.substring(17);
logger.info(attachmentList);
attachmentList=JSON.parse(attachmentList);
attachmentList=JSON.stringify(attachmentList);
attlist.push(attachmentList);
}
var companyCode='HL';
var documentTypeCode=req_date[i].base_archive_code;
var originalNumber=req_date[i].document_info;
var primaryField=req_date[i].primary_field;
var isPaper='true';
var documentSource='CF';
var ruleOID='';
var securityLevelCode='';
var fils = '{'
+'"companyCode": "'+companyCode
+'",'
+'"documentTypeCode": "'+documentTypeCode
+'",'
+'"originalNumber": "'+originalNumber
+'",'
+'"primaryField": "'+primaryField
+'",'
+'"isPaper": "'+isPaper
+'",'
+'"documentSource": "'+documentSource
+'",'
+'"ruleOID": "'+ruleOID
+'",'
+'"securityLevelCode": "'+securityLevelCode
+'",'
+'"attachmentList": '+attlist
+','
+'"fieldValueList": '+filelist
+'}';
fils=JSON.parse(fils);
doc_data.push(fils);
}
if (is_valid == 'true') {
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
var doc_data=JSON.stringify(doc_data);
doc_data=doc_data.replace(/[\'\\\\/\b\f\n\r\t]/g, '');
logger.info(doc_data);
var data = httpPostDocImport(docUrl,doc_data,access_token, token_type);
var json_data = JSON.parse(data);
var statusCode =json_data.statusCode;
var message =json_data.message;
var result=json_data.result;
var doc_import_return_bm = $bm('efile.EFILE1040.doc_import_return');
for(var i=0;i<result.length;i++){
doc_import_return_bm.insert({
'primary_field': result[i].primaryField,
'post_status': message,
'post_message': result[i].failedMessage,
'hly_req_number': "1"
})
}
logger.info(data);
} else {
println("=======有效期外======");
var data = httpPostGetToken(posturl, token_appid, token_appsecret);
var json = JSON.parse(data);
var access_token = json.access_token;
var status = json.status;
logger.info(access_token);
var doc_data=JSON.stringify(doc_data);
doc_data=doc_data.replace(/[\'\\\\/\b\f\n\r\t]/g, '');
logger.info(doc_data);
var data_result = httpPostDocImport(docUrl,doc_data,access_token, token_type);
logger.info(data_result);
var json_data = JSON.parse(data_result);
logger.info(json_data);
var statusCode =json_data.statusCode;
var message =json_data.message;
var result=json_data.result;
var doc_import_return_bm = $bm('efile.EFILE1040.doc_import_return');
for(var i=0;i<result.length;i++){
if(result[i].primaryField){
doc_import_return_bm.insert({
'primary_field': result[i].primaryField,
'post_status': message,
'post_message': result[i].failedMessage,
'hly_req_number': '1'
})
}
}
if (access_token) {
token_savelogs_bm.insert({
'json': data,
'status': 'success'
})
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
})
}
if (status) {
var token_savelogs_bm = $bm('efile.EFILE1000.token_savelogs');
token_savelogs_bm.insert({
'json': json,
'status': 'fail'
});
}
}
}
} catch (e) {
println('e:' + e);
}
]]></s:server-script>
</a:init-procedure>
</a:service>
...@@ -31,13 +31,17 @@ ...@@ -31,13 +31,17 @@
return 0 ;} return 0 ;}
} }
var logger = $logger('server-script');
var instance_id = $ctx.parameter.instance_id; var instance_id = $ctx.parameter.instance_id;
var user_id=$ctx.parameter.user_id;
$bm('zjwfl.ZJWFL1060.wfl_instance_pdf').update({ $bm('zjwfl.ZJWFL1060.wfl_instance_pdf').update({
instance_id: instance_id instance_id: instance_id,
user_id :user_id
}); });
var file_templet_get_atm_path = $bm('zjwfl.ZJWFL1060.wfl_instance_pdf').queryAsMap({ var file_templet_get_atm_path = $bm('zjwfl.ZJWFL1060.wfl_instance_pdf').queryAsMap({
instance_id: instance_id instance_id: instance_id,
user_id :user_id
}); });
var from_file_data = file_templet_get_atm_path.getChildren(); var from_file_data = file_templet_get_atm_path.getChildren();
...@@ -53,6 +57,7 @@ ...@@ -53,6 +57,7 @@
copyFile(from_file_path, to_file_path); copyFile(from_file_path, to_file_path);
//放入实例id方便表单参数取值 //放入实例id方便表单参数取值
$ctx.current_parameter.document_id = instance_id; $ctx.current_parameter.document_id = instance_id;
$ctx.current_parameter.user_id = user_id;
try { try {
var brwt = new BookmarksReplaceWithText($instance('leaf.database.service.IDatabaseServiceFactory'), $instance('uncertain.ocm.IObjectRegistry'), $ctx.getData()); var brwt = new BookmarksReplaceWithText($instance('leaf.database.service.IDatabaseServiceFactory'), $instance('uncertain.ocm.IObjectRegistry'), $ctx.getData());
...@@ -70,7 +75,8 @@ ...@@ -70,7 +75,8 @@
instance_id: instance_id, instance_id: instance_id,
file_name: to_file_name.toString(), file_name: to_file_name.toString(),
file_path: to_file_path.toString(), file_path: to_file_path.toString(),
file_size: file_size file_size: file_size,
user_id :user_id
}); });
var attachment_update = $bm('zjwfl.ZJWFL1060.wfl_instance_pdf'); var attachment_update = $bm('zjwfl.ZJWFL1060.wfl_instance_pdf');
......
...@@ -172,7 +172,7 @@ ...@@ -172,7 +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: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>
......
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