📄 ftpforys.java
字号:
package com.mdcl.mocha.jlcmcc.interfaceforWS;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.mdcl.mocha.bpm.sdk.ServiceManager;
import com.mdcl.mocha.bpm.sdk.boins.BoInsException;
import com.mdcl.mocha.bpm.sdk.boins.entity.IBoInstance;
import com.mdcl.mocha.bpm.sdk.boins.service.IBoInstanceService;
import com.mdcl.mocha.bpm.sdk.document.DocumentException;
import com.mdcl.mocha.bpm.sdk.document.entity.IDocAttachment;
import com.mdcl.mocha.bpm.sdk.document.service.IAttachmentsService;
import com.mdcl.mocha.bpm.sdk.license.ExpiryException;
import com.mdcl.mocha.bpm.sdk.license.LicenseException;
import com.mdcl.mocha.bpm.sdk.license.NotFoundModuleException;
import com.mdcl.mocha.jlcmcc.configmanager.ConfigManager;
import com.mdcl.mocha.jlcmcc.ftp.Ftpclient;
/**
* <strong>Title : FTPforYS<br></strong>
* <strong>Description : </strong>吉林移动BPM预算系统附件的FTP传送类<br>
* <strong>Create on : 2007-9-21<br></strong>
* <p>
* <strong>Copyright (C) Mocha Software Co.,Ltd.<br></strong>
* <p>
* @author liulf@mochasoft.com.cn<br>
* @version <strong>Mocha BPM v6.2</strong><br>
* <br>
* <strong>修改历史:</strong><br>
* 修改人 修改日期 修改描述<br>
* -------------------------------------------<br>
* <br>
* <br>
*/
public class FTPforYS {
/**
*
* 根据流程实例ID获得附件列表
*
* @param boInsId
* <i>流程实例ID</i>
* @return 附件列表(IDocAttachment对象的List)
*/
public List getIDocAttachment(String boInsId){
List tatlist=null;
try {
//根据流程实例ID获得文档ID
IBoInstanceService t_IBoInService=(IBoInstanceService)ServiceManager.getInstance().getService(IBoInstanceService.class);
IBoInstance t_IBoIn = t_IBoInService.getBizObjectInstance(boInsId);
String DocID=t_IBoIn.getDocumentID();
//根据文档ID获得附件列表
IAttachmentsService tAttachmentsService = (IAttachmentsService)ServiceManager.getInstance().getService(IAttachmentsService.class);
tatlist=tAttachmentsService.getAttachmentBean(DocID);
} catch (NotFoundModuleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExpiryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LicenseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BoInsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return tatlist;
}
/**
*
* 根据流程实例ID发送附件到FTP
*
* @param boInsId
* <i>流程实例ID</i>
* @return 失败的附件列表(IDocAttachment对象的List),如果没有得到附件则返回null
* @throws IOException
*/
public List sendFileToFTP(String boInsId){
List result=new ArrayList();
List attlist=this.getIDocAttachment(boInsId);
Ftpclient ftp=null;
try {
ftp=new Ftpclient(getPath("YS.ServerIP"),getPath("YS.user"),getPath("YS.passwd"));
ftp.setServerPath(getPath("YS.path"));
if(attlist!=null){
for(int i=0;i<attlist.size();i++){
IDocAttachment t_att=(IDocAttachment)attlist.get(i);
InputStream in=t_att.getInStream(t_att.getResourceID());
//System.out.println("--------------### 附件名 = "+t_att.getAttchmentName()+" ###----------------");
try {
ftp.upLoad(in, t_att.getAttchmentName()+(new Date()).toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(in!=null)in.close();
}
}
else return null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(ftp!=null)ftp.close();
}
return result;
}
/**
*
* 读取配置文件
*
* @return 值
*/
private String getPath(String path)
{
String result="";
ConfigManager cm;
try {
cm = (ConfigManager)ServiceManager.getInstance().getService(ConfigManager.class);
result = cm.getPath("jlcmcc-serviceinf.properties",path);
} catch (NotFoundModuleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExpiryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LicenseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -