影像平台开发(2)
This commit is contained in:
parent
b41242fd31
commit
afa0e6ffc0
@ -184,7 +184,7 @@
|
||||
return url;
|
||||
}
|
||||
function getRequestParam(){
|
||||
let appCode = 'BQCW-000010';
|
||||
let appCode = 'BQCWHZ36_7';
|
||||
let appName = '业务申请';
|
||||
let code = 'ECM0002';
|
||||
if(("<%=sPhaseNo%>"=="0010") && ("<%=FlowNo%>"=="BusinessApplyFlow" || "<%=FlowNo%>" == "BusinessChangeFlow")){
|
||||
|
||||
@ -5,4 +5,7 @@ useful_life=360
|
||||
#业务系统授权密钥
|
||||
secret_id=anpeng
|
||||
secret_key=IU2VHdejDpUFzhoeT7tUSII3
|
||||
#影像第三方上传时打包临时文件路径
|
||||
fileSavePathTemp=D:/data/files/icmsFileTemp
|
||||
|
||||
|
||||
|
||||
171
src/com/ample/icms/scan/ImageDownload.java
Normal file
171
src/com/ample/icms/scan/ImageDownload.java
Normal file
@ -0,0 +1,171 @@
|
||||
package com.ample.icms.scan;
|
||||
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.BizObjectManager;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.ample.icms.service.ImageService;
|
||||
import com.ample.icms.util.PropertiesUtil;
|
||||
import com.sunyard.insurance.ecm.socket.client.AutoScanApi;
|
||||
import com.sunyard.insurance.encode.client.EncodeAccessParam;
|
||||
import com.tenwa.officetempalte.exportcallback.impl.ZipUtils;
|
||||
import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.SimpleHttpConnectionManager;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImageDownload extends ImageService {
|
||||
private String zipPath ;
|
||||
private String projectId;
|
||||
private String flowUnid;
|
||||
private String fileSavePath;
|
||||
public static String testBatchDownload () throws Exception {
|
||||
//准备参数
|
||||
StringBuilder sb = new StringBuilder("xml=交互参数xml字符串&code=ECM0009&format=xml");
|
||||
String param = EncodeAccessParam.getEncodeParam(sb.toString(),300, PropertiesUtil.get("secret_key"));
|
||||
String result="";
|
||||
PostMethod postMethod = null;
|
||||
HttpClient httpClient = null;
|
||||
try{
|
||||
postMethod = new PostMethod(PropertiesUtil.get("url"));
|
||||
// 设置格式
|
||||
postMethod.getParams().setContentCharset("UTF-8");
|
||||
postMethod.setParameter("data", param);
|
||||
postMethod.setRequestHeader("Referer", "http://172.16.20.212/imaging");
|
||||
httpClient = new HttpClient();
|
||||
// 执行postMethod
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
if(statusCode== HttpStatus.SC_OK){
|
||||
byte[] bodydata = postMethod.getResponseBody();
|
||||
//取得返回值
|
||||
result = new String(bodydata, "UTF-8");
|
||||
}else{
|
||||
}
|
||||
}catch (HttpException e) {
|
||||
//协议发生异常,URL不合法请检查URL!
|
||||
} catch (IOException e) {
|
||||
//请检查网络是否通畅,检查网线是否插好!
|
||||
} catch(Exception e){
|
||||
|
||||
}finally {
|
||||
if (postMethod != null) {
|
||||
try {
|
||||
postMethod.releaseConnection();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (httpClient != null) {
|
||||
try {
|
||||
((SimpleHttpConnectionManager) httpClient.getHttpConnectionManager()).shutdown();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
httpClient = null;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void doUpload(){
|
||||
// String zipPath = "C:/Users/ivanl/Desktop/影像系统/ECM4.0Demo/ECM4.0Demo/第三方上传/1111.zip";
|
||||
String zipPath = PropertiesUtil.get("fileSavePathTemp")+"/"+flowUnid+".zip";
|
||||
try {
|
||||
AutoScanApi autoScanApi = new AutoScanApi(PropertiesUtil.get("service_ip"),8088,PropertiesUtil.get("secret_id")+"#"+PropertiesUtil.get("secret_key"));
|
||||
String result = autoScanApi.ScanImageFile(appCode, zipPath);
|
||||
String returnCode = result.substring(0,result.indexOf("@"));
|
||||
String returnMsg = result.substring(result.indexOf("@")+1,result.length()+1);
|
||||
intoLog(returnCode,returnMsg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void intoLog(String code ,String msg) {
|
||||
Transaction transaction = null;
|
||||
Transaction.createTransaction("als");
|
||||
SqlObject so = null;
|
||||
try {
|
||||
so = new SqlObject("insert into icms_upload_log (id,flowunid,path,code,msg,inputtime) values ()");
|
||||
transaction.executeSQL(so);
|
||||
transaction.commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void upload() throws JBOException, FileNotFoundException {
|
||||
/**
|
||||
* 1.找出需要上传的影像
|
||||
* 3.在指定路径添加对应xml文件
|
||||
* 4.打包上传
|
||||
* 5.删除复制文件和打包文件
|
||||
*/
|
||||
FileOutputStream fos = new FileOutputStream(new File(PropertiesUtil.get("fileSavePathTemp")+"/"+flowUnid+".zip"));
|
||||
ZipUtils zdo = new ZipUtils();
|
||||
zdo.toZip(copyFile(),fos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传成功后再删除
|
||||
*/
|
||||
public void deleteTemp(){
|
||||
File f = new File(PropertiesUtil.get("fileSavePathTemp"));
|
||||
if(f.length()!=0){
|
||||
ZipUtils zdo = new ZipUtils();
|
||||
zdo.deleteFile(f,false);
|
||||
}
|
||||
}
|
||||
public List<File> copyFile() throws JBOException {
|
||||
List<File> files = new ArrayList<>();
|
||||
BizObjectManager bom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME);
|
||||
List<BizObject> bos = bom.createQuery("sign_type='COMPLETE' and file_flag='yes' and project_id=:projectId and flow_unid=:flowUnid")
|
||||
.setParameter("projectId",projectId).setParameter("flowUnid",flowUnid).getResultList(false);
|
||||
for(BizObject bo : bos){
|
||||
String filePath = bo.getAttribute("fullpath").toString();
|
||||
File file = new File(filePath);
|
||||
files.add(file);
|
||||
}
|
||||
//todo 加上xml文件
|
||||
createXMl();
|
||||
File fileXML = new File("xmlpath");
|
||||
files.add(fileXML);
|
||||
return files;
|
||||
}
|
||||
public void createXMl() {
|
||||
String appCode = "BQCW-000010";
|
||||
String appName = "签约文件";
|
||||
this.setAppCode(appCode);
|
||||
this.setAppName(appName);
|
||||
this.setBusiNo(flowUnid);
|
||||
String xml = getRequestXML();
|
||||
SAXReader saxReader = new SAXReader();
|
||||
Document document;
|
||||
try {
|
||||
document = saxReader.read(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
|
||||
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
format.setEncoding("UTF-8");
|
||||
XMLWriter writer = new XMLWriter(new FileWriter(new File(PropertiesUtil.get("fileSavePathTemp")+"/"+flowUnid+".xml")),format);
|
||||
writer.write(document);
|
||||
writer.close();
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,16 +1,35 @@
|
||||
package com.ample.icms.scan;
|
||||
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.BizObjectManager;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.ample.icms.service.ImageService;
|
||||
import com.ample.icms.util.PropertiesUtil;
|
||||
import com.sunyard.insurance.ecm.socket.client.AutoScanApi;
|
||||
import com.tenwa.officetempalte.exportcallback.impl.ZipUtils;
|
||||
import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImageUpload extends ImageService {
|
||||
private String zipPath ;
|
||||
|
||||
private String projectId;
|
||||
private String flowUnid;
|
||||
private String fileSavePath;
|
||||
public void doUpload(){
|
||||
String zipPath = "C:/Users/ivanl/Desktop/影像系统/ECM4.0Demo/ECM4.0Demo/第三方上传/1111.zip";
|
||||
// String zipPath = "C:/Users/ivanl/Desktop/影像系统/ECM4.0Demo/ECM4.0Demo/第三方上传/1111.zip";
|
||||
String zipPath = PropertiesUtil.get("fileSavePathTemp")+"/"+flowUnid+".zip";
|
||||
try {
|
||||
AutoScanApi autoScanApi = new AutoScanApi(PropertiesUtil.get("service_ip"),8088,PropertiesUtil.get("secret_id")+"#"+PropertiesUtil.get("secret_key"));
|
||||
String result = autoScanApi.ScanImageFile(appCode, zipPath);
|
||||
@ -35,16 +54,66 @@ public class ImageUpload extends ImageService {
|
||||
|
||||
}
|
||||
|
||||
public void upload(){
|
||||
public void upload() throws JBOException, FileNotFoundException {
|
||||
/**
|
||||
* 1.找出需要上传的影像
|
||||
* 2.复制到指定路径
|
||||
* 3.在指定路径添加对应xml文件
|
||||
* 4.打包上传
|
||||
* 5.删除复制文件和打包文件
|
||||
*/
|
||||
FileOutputStream fos = new FileOutputStream(new File(PropertiesUtil.get("fileSavePathTemp")+"/"+flowUnid+".zip"));
|
||||
ZipUtils zdo = new ZipUtils();
|
||||
zdo.toZip(copyFile(),fos);
|
||||
}
|
||||
public void copyFile(){
|
||||
|
||||
/**
|
||||
* 上传成功后再删除
|
||||
*/
|
||||
public void deleteTemp(){
|
||||
File f = new File(PropertiesUtil.get("fileSavePathTemp"));
|
||||
if(f.length()!=0){
|
||||
ZipUtils zdo = new ZipUtils();
|
||||
zdo.deleteFile(f,false);
|
||||
}
|
||||
}
|
||||
public List<File> copyFile() throws JBOException {
|
||||
List<File> files = new ArrayList<>();
|
||||
BizObjectManager bom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME);
|
||||
List<BizObject> bos = bom.createQuery("sign_type='COMPLETE' and file_flag='yes' and project_id=:projectId and flow_unid=:flowUnid")
|
||||
.setParameter("projectId",projectId).setParameter("flowUnid",flowUnid).getResultList(false);
|
||||
for(BizObject bo : bos){
|
||||
String filePath = bo.getAttribute("fullpath").toString();
|
||||
File file = new File(filePath);
|
||||
files.add(file);
|
||||
}
|
||||
//todo 加上xml文件
|
||||
createXMl();
|
||||
File fileXML = new File("xmlpath");
|
||||
files.add(fileXML);
|
||||
return files;
|
||||
}
|
||||
public void createXMl() {
|
||||
String appCode = "BQCW-000010";
|
||||
String appName = "签约文件";
|
||||
this.setAppCode(appCode);
|
||||
this.setAppName(appName);
|
||||
this.setBusiNo(flowUnid);
|
||||
String xml = getRequestXML();
|
||||
SAXReader saxReader = new SAXReader();
|
||||
Document document;
|
||||
try {
|
||||
document = saxReader.read(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
|
||||
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
format.setEncoding("UTF-8");
|
||||
XMLWriter writer = new XMLWriter(new FileWriter(new File(PropertiesUtil.get("fileSavePathTemp")+"/"+flowUnid+".xml")),format);
|
||||
writer.write(document);
|
||||
writer.close();
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public class FlowTaskViewTab {
|
||||
BizObjectManager bm = null;
|
||||
BizObjectQuery bq = null;
|
||||
bm = JBOFactory.getFactory().getManager(OBJECTTYPE_RELA.CLASS_NAME);
|
||||
bq = bm.createQuery("O.OBJECTTYPE=:OBJECTTYPE order by O.sortno ").setParameter("OBJECTTYPE", this.getObjectType());
|
||||
bq = bm.createQuery("O.OBJECTTYPE=:OBJECTTYPE and isinuse='Y' order by O.sortno ").setParameter("OBJECTTYPE", this.getObjectType());
|
||||
this.viewTabItemList=bq.getResultList(true);
|
||||
|
||||
|
||||
|
||||
@ -154,5 +154,24 @@ public class ZipUtils {
|
||||
}
|
||||
f.delete();//最后删除该目录中所有文件后就删除该目录
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param f
|
||||
* @param deleteRoot true连当前目录一块删除,false,只删除当前目录下面的文件
|
||||
*/
|
||||
public void deleteFile(File f ,boolean deleteRoot){
|
||||
File [] b = f.listFiles();//获取包含file对象对应的子目录或者文件
|
||||
for(int i =0;i<b.length;i++){
|
||||
if(b[i].isFile()){//判断是否为文件
|
||||
b[i].delete();//如果是就删除
|
||||
}else{
|
||||
deleteFile(b[i]);//否则重新递归到方法中
|
||||
}
|
||||
}
|
||||
if(deleteRoot){
|
||||
f.delete();//最后删除该目录中所有文件后就删除该目录
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user