修改附件预览加载和上传逻辑 区分流程相关附件还是项目或合同相关附件

This commit is contained in:
jianghongdong 2018-08-04 16:43:41 +08:00
parent 8441ef5850
commit 72aca1f89e

View File

@ -1,14 +1,18 @@
package com.tenwa.doc.action;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import com.amarsoft.awe.Configure;
import com.amarsoft.awe.util.ASResultSet;
import jbo.app.tenwa.doc.LB_DOCATTRIBUTE;
import jbo.app.tenwa.doc.LB_DOCCONFIG;
@ -20,6 +24,7 @@ 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.mysql.jdbc.ResultSet;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.officetempalte.util.FileOperatorUtil;
@ -111,9 +116,9 @@ public class DocListInitAction {
* @param param
* @param docno
* @return
* @throws JBOException
* @throws Exception
*/
public static String getDocSQL(Map<String,String> param,String docno) throws JBOException{
public static String getDocSQL(Map<String,String> param,String docno) throws Exception{
String sql="select id from O left join jbo.app.tenwa.doc.LB_DOCLIBRARY lib on O.id=lib.Relative_Id where lib.doc_Class_Itemno in ("+docno+") ";
if("Customer".equals(param.get("ObjectType"))){
sql+=" and O.cust_id='"+param.get("cust_id")+"' and O.objecttype='Customer' ";
@ -199,13 +204,14 @@ public class DocListInitAction {
}
}
public static String getFlowWhere(BizObject flow,String idlst,String value) throws JBOException{
public static String getFlowWhere(BizObject flow,String idlst,String value) throws Exception{
String table="";
if(value.length()>0){
table=value+".";
}
String FlowName=flow.getAttribute("flow_name").getString();
String proj_id=flow.getAttribute("proj_id").getString();
String contract_id=flow.getAttribute("contract_id").getString();
@ -216,9 +222,9 @@ public class DocListInitAction {
if(idlst.length()>0){
//otherWhere=" and "+table+"flow_unid='"+flowunid+"'";
otherWhere=" and O.id in("+idlst+")";
}else if(contract_id.length()>0){
}else if(contract_id.length()>0&&"".equals(getDocType(FlowName))){
otherWhere=" and "+table+"proj_id='"+proj_id+"' and ("+table+"contract_id='' or "+table+"contract_id is null or "+table+"contract_id='"+contract_id+"') ";
}else if(proj_id.length()>0){
}else if(proj_id.length()>0&&"".equals(getDocType(FlowName))){
otherWhere=" and "+table+"proj_id='"+proj_id+"'";
}else{
otherWhere=" and "+table+"flow_unid='"+flowunid+"'";
@ -226,4 +232,39 @@ public class DocListInitAction {
return otherWhere;
}
/**
* 校验附件一览类型
* 附件一览分2种可上传类型
* 1与项目或合同绑定的附件多次发起流程将会累计附件
* 2与流程本身绑定仅在本次流程中可见
* 3与流程与项目合同都绑定在流程中只能看见本次上传的附件其它次附件在别处根据项目编号可查看
* @return
* @throws Exception
* @throws JBOException
*/
public static String getDocType(String flowName) throws Exception{
String sql ="SELECT FLOWNO FROM flow_catalog WHERE flowname='"+flowName+"'";
List<Map<String,String>> ds = DataOperatorUtil.getDataBySql(JBOFactory.createJBOTransaction(), sql, null);
String flowno = GetValueByKey("docpreview.properties",ds.get(0).get("FLOWNO"));
//根据要求拖车申请是
if(flowno!=null){
return "flow";
}
return "";
}
//根据Key读取Value
public static String GetValueByKey(String filePath, String key) {
Properties pps = new Properties();
try {
InputStream in = DocListInitAction.class.getClassLoader().getResourceAsStream(filePath);
pps.load(in);
String value = pps.getProperty(key);
System.out.println(key + " = " + value);
return value;
}catch (IOException e) {
e.printStackTrace();
return null;
}
}
}