Filenet实现报销流程二

摘要: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %><%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %><%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%><%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%><%@ page contentType="text/html; charset=UTF-8" %>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<%@ page contentType="text/html; charset=UTF-8" %>


报销登记






























报销人: 报销时间:
出差开始时间: 出差结束时间:
地点:
天数: 费用(一天):
合计: 合计金额:
出差事由:
备注:
上传报销单: 上传发票















其中a4j标签是一个Ajax实现,不了解的可以去看下.

在Bean里实现提交操作,关于附件这里还是有一点需要注意的,当我们在本地上传一个附件到CE上其实是要经过两个步骤的:先将附件上传到我们的Tomcat服务器上再推送到CE里面去,因为当用户在使用时候,Tomcat服务器是不会在用户的计算机上的,他提交的是本地的一个路径,如果我们的代码直接处理这个路径的话在服务器上是找不到这个文件的.

好了,这样我们就来实现方法:



public String submit(){
VWSession vss = this.credential.getVWSession();
//Connection connection = this.credential.getConnection();


Domain domain = Factory.Domain.fetchInstance(this.logonCE(this.CONFIG_BUNDLE), "p8domain", null);
ObjectStore objectStore = Factory.ObjectStore.fetchInstance(domain, "OStore", null);
VWStepElement launchStep;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
launchStep = vss.createWorkflow("报销流程");
//设置参数

launchStep.setParameterValue("报销人", this.bxPerson, true);
launchStep.setParameterValue("报销日期", format.parse(this.bxDate), true);
launchStep.setParameterValue("出差开始时间", format.parse(this.startDate), true);
launchStep.setParameterValue("出差结束时间", format.parse(this.endDate), true);
launchStep.setParameterValue("地点", this.address, true);
launchStep.setParameterValue("天数", this.days, true);
launchStep.setParameterValue("每天费用", this.payPerDay, true);
launchStep.setParameterValue("合计", this.totalPay, true);
launchStep.setParameterValue("金额大写", this.chineseTotal, true);
launchStep.setParameterValue("出差事由", this.reason, true);
launchStep.setParameterValue("备注", this.remark, true);

//报销单附件设置

Folder folder = Factory.Folder.fetchInstance(objectStore, "/FileNet小组/高扬/2009/9月/报销单", null);

String bxd_filePath = this.uploadFileToServer(this.bxd_path);//上传到服务器

//推送到CE里面去
this.uploadFile(folder,objectStore, this.systemClassPath+"/"+bxd_filePath, "cq_bxd","报销单");
DocumentSet documentSet = folder.get_ContainedDocuments();
Iterator it = documentSet.iterator();
while(it.hasNext()){
Document document = it.next();
if (document.getClassName().equalsIgnoreCase("cq_bxd")) {
VWAttachment attachment = new VWAttachment();
attachment.setId(document.get_VersionSeries().get_Id().toString());
attachment.setVersion("-1");
attachment.setType(3);
attachment.setLibraryName("OStore");

attachment.setLibraryType(3);
attachment.setAttachmentDescription(document.getProperties()
.getStringValue("DocumentTitle"));
attachment.setAttachmentName(document.getProperties()
.getStringValue("DocumentTitle"));
launchStep.setParameterValue("报销单", attachment, false);
}
}
//发票附件设置

Folder fp_folder = Factory.Folder.fetchInstance(objectStore, "/FileNet小组/高扬/2009/9月/发票", null);
String fp_filePath = this.uploadFileToServer(this.fp_path);
this.uploadFile(fp_folder, objectStore, this.systemClassPath+"/"+fp_filePath, "cq_fp","发票");
DocumentSet fp_documentSet = fp_folder.get_ContainedDocuments();
Iterator iterator = fp_documentSet.iterator();
while(iterator.hasNext()){
Document document = iterator.next();
//System.out.println("_____________________"+document.getClassName());

if (document.getClassName().equalsIgnoreCase("cq_fp")) {
VWAttachment attachment = new VWAttachment();
attachment.setId(document.get_VersionSeries().get_Id().toString());
attachment.setVersion("-1");
attachment.setType(3);
attachment.setLibraryName("OStore");

attachment.setLibraryType(3);
attachment.setAttachmentDescription(document.getProperties()
.getStringValue("DocumentTitle"));
attachment.setAttachmentName(document.getProperties()
.getStringValue("DocumentTitle"));
launchStep.setParameterValue("发票", attachment, false);
}
}
//启动流程

launchStep.doDispatch();
return "suc";
}catch (Exception e) {
e.printStackTrace();
return "";
}
}




将文件上传到Tomcat服务器方法很简单,这里不做描述,只写下推送到CE的方法:



* 从本地选择一个文件上传到CE目录中
* @param folder
* @param edFileuploadedFile
* @param documentClass
* @author 高扬 2009-9-17
* @param string
* @param objectStore
*/
private String uploadFile(Folder folder,ObjectStore os, String filePath,String documentClass, String flag){
Document doc = Factory.Document.createInstance(os, documentClass);
ContentElementList contentList = Factory.ContentElement.createList();
ContentTransfer transfer = Factory.ContentTransfer.createInstance();
System.out.println(filePath+"++++++++++++++++++0");
try {
transfer.setCaptureSource(new FileInputStream(filePath));
} catch (IOException e) {
e.printStackTrace();
}
String fileType = "";
if (filePath.indexOf(".jpg") != -1 || filePath.indexOf(".jpeg") != -1
|| filePath.indexOf(".JPG") != -1
|| filePath.indexOf(".JPEG") != -1) {
fileType = "image/jpeg";
} else if (filePath.indexOf(".gif") != -1
|| filePath.indexOf(".GIF") != -1) {
fileType = "image/gif";
} else if (filePath.indexOf(".bmp") != -1
|| filePath.indexOf(".BMP") != -1) {
fileType = "image/bmp";
} else if (filePath.indexOf(".dwg") != -1
|| filePath.indexOf(".DWG") != -1) {
fileType = "application/x-dwg";
} else if (filePath.indexOf(".doc") != -1) {
fileType = "application/msword";
} else if (filePath.indexOf(".mpg") != -1) {
fileType = "video/x-mpg; charset=gb2312";
}else if(filePath.indexOf(".txt")!= -1){
fileType="text/plain";
}
transfer.set_ContentType(fileType);
contentList.add(transfer);
doc.set_ContentElements(contentList);
doc.checkin(AutoClassify.AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
Properties props = doc.getProperties();
props.putValue("DocumentTitle", this.bxPerson+this.address+flag);
doc.set_MimeType("text/xml");
doc.save(RefreshMode.REFRESH);

ReferentialContainmentRelationship rcr = folder.file(doc,
AutoUniqueName.AUTO_UNIQUE, "Log4jConfigSample",
DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
rcr.save(RefreshMode.NO_REFRESH);

String id=doc.get_Id().toString();
String vsid=doc.get_VersionSeries().get_Id().toString();
String desc=doc.get_Name();//描述信息

int type=VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT;
String libraryName="OStore";
int libraryType=type;
String title=doc.get_Name().toString();
System.out.println("========="+id+"========"+vsid+"========"+title);
return vsid;
}


上一篇: Filenet实现报销流程
下一篇: WAT编程方式简单的例子
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号