|
|
|
@ -0,0 +1,713 @@
|
|
|
|
|
package com.engine.workflow.biz;
|
|
|
|
|
|
|
|
|
|
import com.engine.workflow.biz.excelDesign.DoSaveFreeExcelDesignBiz;
|
|
|
|
|
import com.engine.workflow.biz.freeNode.FreeNodeBiz;
|
|
|
|
|
import com.engine.workflow.entity.newRequest.WfBean;
|
|
|
|
|
import com.engine.workflow.entity.newRequest.WfType;
|
|
|
|
|
import com.engine.workflow.entity.newRequest.WfUser;
|
|
|
|
|
import com.engine.workflow.util.CollectionUtil;
|
|
|
|
|
import net.sourceforge.pinyin4j.PinyinHelper;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Pinyin4j;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
|
|
import weaver.hrm.company.SubCompanyComInfo;
|
|
|
|
|
import weaver.hrm.job.JobTitlesComInfo;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
import weaver.ofs.bean.OfsWorkflow;
|
|
|
|
|
import weaver.ofs.util.OfsWorkflowShareUtils;
|
|
|
|
|
import weaver.share.ShareManager;
|
|
|
|
|
import weaver.soa.workflow.WorkFlowInit;
|
|
|
|
|
import weaver.workflow.request.todo.RequestUtil;
|
|
|
|
|
import weaver.workflow.workflow.WorkTypeComInfo;
|
|
|
|
|
import weaver.workflow.workflow.WorkflowAllComInfo;
|
|
|
|
|
import weaver.workflow.workflow.WorkflowConfigComInfo;
|
|
|
|
|
import weaver.workflow.workflow.WorkflowVersion;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有可新建流程数据
|
|
|
|
|
* Created by jhy on 2018/5/9.
|
|
|
|
|
*/
|
|
|
|
|
public class NewRequestBiz {
|
|
|
|
|
|
|
|
|
|
private Map<String, WfType> wftypeInfo = null;
|
|
|
|
|
private WorkTypeComInfo worktypecominfo = null;
|
|
|
|
|
private WorkflowAllComInfo workflowAllComInfo = null;
|
|
|
|
|
private ResourceComInfo resourceComInfo = null;
|
|
|
|
|
private DepartmentComInfo departmentComInfo = null;
|
|
|
|
|
private JobTitlesComInfo jobTitlesComInfo = null;
|
|
|
|
|
private SubCompanyComInfo subCompanyComInfo = null;
|
|
|
|
|
private ShareManager shareManager = null;
|
|
|
|
|
private WorkFlowInit workflowInit = null;
|
|
|
|
|
private List<String> usedtodoList = null;
|
|
|
|
|
private List<String> usedtodoAndCollWfIds = null;
|
|
|
|
|
private User user;
|
|
|
|
|
|
|
|
|
|
private String[] colors = null;
|
|
|
|
|
private String[] imgs = null;
|
|
|
|
|
|
|
|
|
|
private String isuserdefault; // 是否收藏
|
|
|
|
|
private String selectedworkflow;
|
|
|
|
|
private String currentdate;
|
|
|
|
|
private String currenttime;
|
|
|
|
|
private String commonuse = "0";
|
|
|
|
|
private String source = "";//请求来源
|
|
|
|
|
private static String specialstr = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()--+|{}【】‘;:”“’。,、?]";
|
|
|
|
|
private boolean openofs = false;
|
|
|
|
|
private String inornot = "in";//用于不同入口,拼接各自的数据范围的标识,可选值:in、not in
|
|
|
|
|
private String newRequestRange = "";//用于不同入口,拼接各自的数据范围,只接收workflowid,workflowtype需转成workflowid
|
|
|
|
|
private String customSqlWhere = "";
|
|
|
|
|
private String typeids = ""; // 限制的类型
|
|
|
|
|
private boolean ismobile = false;
|
|
|
|
|
private Map<String,List<OfsWorkflow>> ofsWorkflowDatas = new HashMap<>();//当前用户所有可创建的异构系统流程数据(如果开启主次账号统一显示,则数据包含次账号,无代理)
|
|
|
|
|
private String forceUnsupportSPAWF = "";//强制走jsp跳转至新建流程页面的路径id
|
|
|
|
|
private String ofsWorkflowids_CurrUser = "0";//当前用户所有可创建的异构系统workflowids,不包含次账号,用户常用流程计算
|
|
|
|
|
|
|
|
|
|
public NewRequestBiz(User user) {
|
|
|
|
|
this.user = user;
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NewRequestBiz(User user,String source) {
|
|
|
|
|
this.user = user;
|
|
|
|
|
this.source = source;
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void init() {
|
|
|
|
|
this.wftypeInfo = new HashMap<String, WfType>();
|
|
|
|
|
this.shareManager = new ShareManager();
|
|
|
|
|
this.workflowInit = new WorkFlowInit();
|
|
|
|
|
try {
|
|
|
|
|
this.worktypecominfo = new WorkTypeComInfo();
|
|
|
|
|
this.workflowAllComInfo = new WorkflowAllComInfo();
|
|
|
|
|
this.departmentComInfo = new DepartmentComInfo();
|
|
|
|
|
this.resourceComInfo = new ResourceComInfo();
|
|
|
|
|
this.jobTitlesComInfo = new JobTitlesComInfo();
|
|
|
|
|
this.subCompanyComInfo = new SubCompanyComInfo();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
this.usedtodoList = new ArrayList<String>();
|
|
|
|
|
this.usedtodoAndCollWfIds = new ArrayList<>();
|
|
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
|
|
this.currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
|
|
|
|
|
|
|
|
|
|
this.currenttime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + Util.add0(today.get(Calendar.SECOND), 2);
|
|
|
|
|
this.selectedworkflow = "";
|
|
|
|
|
|
|
|
|
|
this.colors = new String[]{"#55D2D4", "#B37BFA", "#FFC62E", "#8DCE36", "#37B2FF", "#FF9537", "#FF5E56", "#FFC62E"};
|
|
|
|
|
this.imgs = new String[]{
|
|
|
|
|
"icon-New-Flow-Personnel-matters",
|
|
|
|
|
"icon-New-Flow-contract",
|
|
|
|
|
"icon-New-Flow-task",
|
|
|
|
|
"icon-New-Flow-printing",
|
|
|
|
|
"icon-New-Flow-summary",
|
|
|
|
|
"icon-coms-task-list",
|
|
|
|
|
"icon-coms-Paste",
|
|
|
|
|
"icon-meeting-cycle"
|
|
|
|
|
};
|
|
|
|
|
RequestUtil requestutil = new RequestUtil();
|
|
|
|
|
openofs = requestutil.getOfsSetting().getIsuse() == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<WfType> getWfInfo(String wfids) {
|
|
|
|
|
String belongtoshow = "";
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
// 判断主次账户是否统一显示
|
|
|
|
|
rs.executeQuery("select belongtoshow from HrmUserSetting where resourceId = ?", user.getUID());
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
belongtoshow = Util.null2String(rs.getString("belongtoshow"));
|
|
|
|
|
}
|
|
|
|
|
String userIDAll = String.valueOf(user.getUID());
|
|
|
|
|
if (!"".equals(Util.null2String(user.getBelongtoids())) && "1".equals(belongtoshow) && !"wfcenter".equals(source)) {
|
|
|
|
|
userIDAll = user.getUID() + "," + user.getBelongtoids();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String logintype = user.getLogintype();
|
|
|
|
|
int usertype = 0;
|
|
|
|
|
if (logintype.equals("2")) {
|
|
|
|
|
usertype = 1;
|
|
|
|
|
}
|
|
|
|
|
if (usertype == 0) {
|
|
|
|
|
rs.executeProc("workflow_RUserDefault_Select", String.valueOf(user.getUID()));
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
selectedworkflow = rs.getString("selectedworkflow");
|
|
|
|
|
isuserdefault = rs.getString("isuserdefault");
|
|
|
|
|
commonuse = rs.getString("commonuse");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// isuserdefault = ("1".equals(needall))?"0":isuserdefault;
|
|
|
|
|
|
|
|
|
|
if (!selectedworkflow.equals(""))
|
|
|
|
|
selectedworkflow += "|";
|
|
|
|
|
|
|
|
|
|
List<String> selectedworkflowList = Util.TokenizerString(selectedworkflow,"|");
|
|
|
|
|
for(String wfid : selectedworkflowList){
|
|
|
|
|
if(wfid.contains("T")){
|
|
|
|
|
continue;
|
|
|
|
|
}else{
|
|
|
|
|
wfid = wfid.replace("W","");
|
|
|
|
|
String activeWfid = workflowAllComInfo.getActiveversionid(wfid);//收藏历史版本流程,活动版本未收藏
|
|
|
|
|
if(!usedtodoAndCollWfIds.contains(wfid)){//过滤脏数据
|
|
|
|
|
usedtodoAndCollWfIds.add(wfid);
|
|
|
|
|
}
|
|
|
|
|
if(!usedtodoAndCollWfIds.contains(activeWfid) && Util.getIntValue(activeWfid) > 0){
|
|
|
|
|
usedtodoAndCollWfIds.add(activeWfid);
|
|
|
|
|
selectedworkflow += "W"+activeWfid+"|";//收藏添加活动版本数据
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新建流程加载异构系统数据开关,默认是开启的
|
|
|
|
|
WorkflowConfigComInfo configComInfo = new WorkflowConfigComInfo();
|
|
|
|
|
boolean createRequestOpenOfs = "1".equals(configComInfo.getValue("create_request_open_ofs"));
|
|
|
|
|
//纯加载异构系统可创建流程数据
|
|
|
|
|
if(usertype == 0 && openofs && "0".equals(user.getAccount_type()) && createRequestOpenOfs){//仅主账号允许显示异构系统路径
|
|
|
|
|
loadAllWfCreateInfo4Ofs(userIDAll, usertype, wfids,ismobile);
|
|
|
|
|
}
|
|
|
|
|
// 加载常用流程 不开启显示常用流程时,不加载常用流程数据
|
|
|
|
|
if("1".equals(commonuse)){
|
|
|
|
|
loadUsedtodoWf(usertype, user);
|
|
|
|
|
}
|
|
|
|
|
// 加载所有可创建流程
|
|
|
|
|
loadAllWfCreateInfo(userIDAll, usertype, wfids);
|
|
|
|
|
// 加载可代理创建流程
|
|
|
|
|
if (usertype == 0 && !"wfcenter".equals(source)) {
|
|
|
|
|
loadWfAgentInfo(userIDAll,wfids);
|
|
|
|
|
}
|
|
|
|
|
// 加载所有异构系统可创建流程,不考虑代理--数据处理
|
|
|
|
|
if(usertype == 0 && openofs && "0".equals(user.getAccount_type())){
|
|
|
|
|
for (Map.Entry<String, List<OfsWorkflow>> entry : ofsWorkflowDatas.entrySet()) {
|
|
|
|
|
List<OfsWorkflow> ofsWorkflowList = entry.getValue();
|
|
|
|
|
int userid = Util.getIntValue(entry.getKey());
|
|
|
|
|
for(OfsWorkflow ofsWorkflow : ofsWorkflowList){
|
|
|
|
|
String typeid = ofsWorkflow.getSysid();
|
|
|
|
|
this.generateInjectData(wftypeInfo.get(typeid), typeid, ofsWorkflow.getWorkflowid(), ofsWorkflow.getShowname(),ofsWorkflow.getWorkflowname(), "", ofsWorkflow.getAppcwurl(), ofsWorkflow.getPccwurl(), userid, -1, false,true,ofsWorkflow.getWorkflowname());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 剔除数据中心流程
|
|
|
|
|
getAllInputReport();
|
|
|
|
|
|
|
|
|
|
return sortWfTypes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加载当前用户主次账号所有的可新建流程
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private void loadAllWfCreateInfo(String userIDAll, int usertype, String workflowids) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String[] arr = userIDAll.split(",");
|
|
|
|
|
int userid = 0;
|
|
|
|
|
User _User = null;
|
|
|
|
|
String typeid = "";
|
|
|
|
|
for (int i = 0; i < arr.length; i++) {
|
|
|
|
|
userid = Util.getIntValue(arr[i]);
|
|
|
|
|
_User = workflowInit.getUser(userid);
|
|
|
|
|
if(usertype==1) {
|
|
|
|
|
_User = user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String wfcrtSqlWhere = shareManager.getWfShareSqlWhere(_User, "t1");
|
|
|
|
|
String sql = "select t2.workflowtype,t1.workflowid,t2.workflowname,t2.workflowdesc,t2.isimportwf,t2.islockworkflow from ShareInnerWfCreate t1,workflow_base t2 where t1.workflowid=t2.id and t2.isvalid='1' and t1.usertype = ? ";
|
|
|
|
|
if(!"".equals(workflowids)){//拼接方法参数
|
|
|
|
|
sql += " and t2.id in (" + workflowids + ") ";
|
|
|
|
|
}
|
|
|
|
|
if(!"".equals(customSqlWhere)) {//拼接自定义条件
|
|
|
|
|
sql += customSqlWhere;
|
|
|
|
|
}
|
|
|
|
|
if(!"".equals(newRequestRange)){//拼接各入口条件
|
|
|
|
|
sql += " and " + Util.getSubINClause(newRequestRange, "t2.id", inornot);
|
|
|
|
|
}
|
|
|
|
|
if("wfcenter".equals(source)){//拼接流程模块--流程中心条件,此入口仅需要常用流程和我的收藏的流程
|
|
|
|
|
if(usedtodoAndCollWfIds.size() > 0){
|
|
|
|
|
sql += " and t2.id in(" + CollectionUtil.list2String(usedtodoAndCollWfIds,",") + ") ";
|
|
|
|
|
}else{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sql += " and " + wfcrtSqlWhere + " order by t2.dsporder asc, t2.workflowname ";// 所有可创建流程类型集合
|
|
|
|
|
rs.executeQuery(sql, usertype);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
if("1".equals(rs.getString("islockworkflow")))
|
|
|
|
|
continue;
|
|
|
|
|
typeid = rs.getString("workflowtype");
|
|
|
|
|
|
|
|
|
|
String workflowDesc = Util.null2String(rs.getString("workflowdesc"));
|
|
|
|
|
this.generateInjectData(wftypeInfo.get(typeid),typeid,rs.getString("workflowid"),Util.null2String(worktypecominfo.getWorkTypename(typeid)),Util.null2String(rs.getString("workflowname")),rs.getString("isimportwf"),"","",userid,-1,false,false,workflowDesc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 记载当前用户主次账号所有代理创建的流程
|
|
|
|
|
*
|
|
|
|
|
* @param userIDAll
|
|
|
|
|
*/
|
|
|
|
|
private void loadWfAgentInfo(String userIDAll,String wfids) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
// 创建代理增加功能
|
|
|
|
|
// 获得当前的日期和时间
|
|
|
|
|
String begindate, begintime, enddate, endtime = "";
|
|
|
|
|
String agentworkflowtype, agentworkflow = "";
|
|
|
|
|
int beagenterid = 0;
|
|
|
|
|
|
|
|
|
|
String agentUserSql = "select distinct t.bagentuid from workflow_agentConditionSet t,workflow_base t1 where t.workflowid=t1.id and t1.isvalid in ('1','3') and t.agenttype>'0' and t.iscreateagenter=1 and t.agentuid in ("
|
|
|
|
|
+ userIDAll + ") ";
|
|
|
|
|
RecordSet agentRs = new RecordSet();
|
|
|
|
|
agentRs.executeQuery(agentUserSql);
|
|
|
|
|
while (agentRs.next()) {
|
|
|
|
|
int bagentuid = Util.getIntValue(agentRs.getString(1));
|
|
|
|
|
|
|
|
|
|
String bstatus = resourceComInfo.getStatus(bagentuid + "");
|
|
|
|
|
if ("5".equals(bstatus) || "".equals(bstatus)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
User bagentUser = new User(bagentuid);
|
|
|
|
|
|
|
|
|
|
String bagentWfcrtSqlWhereMain = shareManager.getWfShareSqlWhere(bagentUser, "t3");
|
|
|
|
|
String agentUserPermissionSql = "select distinct t1.workflowtype,t.workflowid,t.bagentuid,t.begindate,t.begintime,t.enddate,t.endtime,t1.workflowname,t1.isimportwf,t1.islockworkflow "
|
|
|
|
|
+ " from workflow_agentConditionSet t,workflow_base t1, ShareInnerWfCreate t3 " + " where t.workflowid=t1.id and t1.isvalid in ('1','3') and t.agenttype>'0' and t.iscreateagenter=1 and t.agentuid in ("
|
|
|
|
|
+ userIDAll + ") " + " and t1.id=t3.workflowid and t3.usertype=0 and " + bagentWfcrtSqlWhereMain ;
|
|
|
|
|
if(!"".equals(wfids)){//拼接方法参数
|
|
|
|
|
agentUserPermissionSql += " and t1.id in (" + wfids + ") ";
|
|
|
|
|
}
|
|
|
|
|
if(!"".equals(customSqlWhere)){//拼接自定义条件
|
|
|
|
|
agentUserPermissionSql += " " + customSqlWhere.replaceAll("t2","t1");
|
|
|
|
|
}
|
|
|
|
|
if(!"".equals(newRequestRange)){//拼接各入口条件
|
|
|
|
|
agentUserPermissionSql += " and " + Util.getSubINClause(newRequestRange, "t1.id", inornot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
agentUserPermissionSql+=" order by t1.workflowtype,t.workflowid";
|
|
|
|
|
rs.executeQuery(agentUserPermissionSql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
if("1".equals(rs.getString("islockworkflow")) || !(bagentuid+"").equals(rs.getString("bagentuid")) )
|
|
|
|
|
continue;
|
|
|
|
|
begindate = Util.null2String(rs.getString("begindate"));
|
|
|
|
|
begintime = Util.null2String(rs.getString("begintime"));
|
|
|
|
|
enddate = Util.null2String(rs.getString("enddate"));
|
|
|
|
|
endtime = Util.null2String(rs.getString("endtime"));
|
|
|
|
|
agentworkflowtype = Util.null2String(rs.getString("workflowtype"));
|
|
|
|
|
agentworkflow = Util.null2String(rs.getString("workflowid"));
|
|
|
|
|
beagenterid = Util.getIntValue(rs.getString("bagentuid"), 0);
|
|
|
|
|
agentworkflow = WorkflowVersion.getActiveVersionWFID(agentworkflow);
|
|
|
|
|
// 判断代理时间是否到期
|
|
|
|
|
if (!"".equals(begindate)) {
|
|
|
|
|
if ((begindate + " " + begintime).compareTo(currentdate + " " + currenttime) > 0)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!"".equals(enddate)) {
|
|
|
|
|
if ((enddate + " " + endtime).compareTo(currentdate + " " + currenttime) < 0)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证必要数据是否为空
|
|
|
|
|
if ("".equals(agentworkflowtype) || beagenterid == 0 || "".equals(agentworkflow)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新数据到集合
|
|
|
|
|
String workflowdesc = getWorkflowDesc(agentworkflow);
|
|
|
|
|
this.generateInjectData(wftypeInfo.get(agentworkflowtype),agentworkflowtype,agentworkflow,Util.null2String(worktypecominfo.getWorkTypename(agentworkflowtype)),Util.null2String(rs.getString("workflowname")),rs.getString("isimportwf"),"","",-1,beagenterid,true,false,workflowdesc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加载当前用户所有异构系统可新建流程数据
|
|
|
|
|
* @param userIDAll
|
|
|
|
|
* @param usertype
|
|
|
|
|
* @param workflowids
|
|
|
|
|
*/
|
|
|
|
|
private void loadAllWfCreateInfo4Ofs(String userIDAll, int usertype, String workflowids,boolean ismobile){
|
|
|
|
|
if("".equals(workflowids)){//workflowids不为空的,目前只有commonservice入口调用,暂不处理其他情况
|
|
|
|
|
if("wfcenter".equals(source)){
|
|
|
|
|
workflowids = CollectionUtil.list2String(usedtodoAndCollWfIds,",");
|
|
|
|
|
}else{
|
|
|
|
|
workflowids = newRequestRange;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int currUserid = user.getUID();
|
|
|
|
|
OfsWorkflowShareUtils ofsWorkflowShareUtils = new OfsWorkflowShareUtils();
|
|
|
|
|
String[] arr = userIDAll.split(",");
|
|
|
|
|
for (int i = 0; i < arr.length; i++) {//按用户加载,包含主次账号
|
|
|
|
|
int userid = Util.getIntValue(arr[i]);
|
|
|
|
|
List<OfsWorkflow> ofsWorkflowList = ofsWorkflowShareUtils.getWorkflowDatas(userid,usertype+"",ismobile,typeids,workflowids,inornot);
|
|
|
|
|
for(OfsWorkflow ofsWorkflow : ofsWorkflowList){
|
|
|
|
|
if(currUserid == userid){//处理当前登录用户可创建异构系统流程id串,用户常用流程计算
|
|
|
|
|
ofsWorkflowids_CurrUser += ofsWorkflow.getWorkflowid() + ",";
|
|
|
|
|
}
|
|
|
|
|
forceUnsupportSPAWF += ofsWorkflow.getWorkflowid() + ",";
|
|
|
|
|
}
|
|
|
|
|
ofsWorkflowDatas.put(userid+"",ofsWorkflowList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ofsWorkflowids_CurrUser = ofsWorkflowids_CurrUser.endsWith(",") ? ofsWorkflowids_CurrUser.substring(0,ofsWorkflowids_CurrUser.length()-1) : ofsWorkflowids_CurrUser;
|
|
|
|
|
forceUnsupportSPAWF = forceUnsupportSPAWF.endsWith(",") ? forceUnsupportSPAWF.substring(0,forceUnsupportSPAWF.length()-1) : forceUnsupportSPAWF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加载当前用户使用频率最高的12条流程
|
|
|
|
|
*/
|
|
|
|
|
private void loadUsedtodoWf(int usertype, User user) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
if (usertype == 0) {
|
|
|
|
|
String agentWfcrtSqlWhere = shareManager.getWfShareSqlWhere(user, "t1");
|
|
|
|
|
// 门户sql条件
|
|
|
|
|
String portalsqlwhere = "";
|
|
|
|
|
if(customSqlWhere != null && !"".equals(customSqlWhere)){
|
|
|
|
|
portalsqlwhere = customSqlWhere.replaceAll("t2","workflow_base");
|
|
|
|
|
}
|
|
|
|
|
String selectSql = " case workflow_base.isvalid when '3' then workflow_base.activeversionid else WorkflowUseCount.wfid end as wfid,WorkflowUseCount.userid, sum(WorkflowUseCount.count) as count ";
|
|
|
|
|
String groupbySql = " group by case workflow_base.isvalid when '3' then workflow_base.activeversionid else WorkflowUseCount.wfid end,WorkflowUseCount.userid ";
|
|
|
|
|
String innerjoinSql = " left join workflow_base on workflow_base.id = WorkflowUseCount.Wfid left join ofs_workflow on ofs_workflow.workflowid = WorkflowUseCount.wfid ";
|
|
|
|
|
|
|
|
|
|
if (rs.getDBType().equals("oracle")) {
|
|
|
|
|
String sql = "SELECT * FROM (select "
|
|
|
|
|
+ selectSql
|
|
|
|
|
+ " from WorkflowUseCount "
|
|
|
|
|
+ innerjoinSql
|
|
|
|
|
+ " where WorkflowUseCount.userid ="
|
|
|
|
|
+ user.getUID()
|
|
|
|
|
//+ (!"".equals(portalsqlwhere) ? portalsqlwhere : "")
|
|
|
|
|
+ " and ("+Util.getSubINClause(ofsWorkflowids_CurrUser, "wfid", "in")+" or wfid in(select t2.id as workflowid from ShareInnerWfCreate t1,workflow_base t2 where t1.workflowid=t2.id and t2.isvalid in ('1','3') and t1.usertype = "
|
|
|
|
|
+ usertype
|
|
|
|
|
+ " and "
|
|
|
|
|
+ agentWfcrtSqlWhere
|
|
|
|
|
+ " union all select t1.id as workflowid from workflow_agentConditionSet t,workflow_base t1 where exists (select * from HrmResource b where t.bagentuid=b.id and b.status<4) and t.workflowid=t1.id and t.agenttype>'0' and t.iscreateagenter=1 and t.agentuid="
|
|
|
|
|
+ user.getUID() + " and ((t.beginDate || t.beginTime||':00'<='" + currentdate + currenttime + "' and t.endDate || t.endTime || ':00'>='" + currentdate + currenttime
|
|
|
|
|
+ "')or(t.beginDate || t.beginTime='' and t.endDate || t.endTime = '')))) " + groupbySql + " order by count desc,wfid) WHERE ROWNUM <= 12 ORDER BY ROWNUM ASC";
|
|
|
|
|
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
} else if (rs.getDBType().equals("mysql")) {
|
|
|
|
|
String sql = "select "
|
|
|
|
|
+ selectSql
|
|
|
|
|
+ " from WorkflowUseCount "
|
|
|
|
|
+ innerjoinSql
|
|
|
|
|
+ " where WorkflowUseCount.userid ="
|
|
|
|
|
+ user.getUID()
|
|
|
|
|
//+ (!"".equals(portalsqlwhere)? portalsqlwhere : "")
|
|
|
|
|
+ " and ("+Util.getSubINClause(ofsWorkflowids_CurrUser, "wfid", "in")+" or wfid in ("
|
|
|
|
|
+ "select t.workflowid from workflow_agentConditionSet t,workflow_base t1 where exists (select * from HrmResource b where t.bagentuid=b.id and b.status<4) and t.workflowid=t1.id and t.agenttype>'0' and t.iscreateagenter=1 and t.agentuid="
|
|
|
|
|
+ user.getUID() + " union all select t1.workflowid from ShareInnerWfCreate t1,workflow_base t2 where t1.workflowid=t2.id and t2.isvalid in ('1','3'))) " + groupbySql
|
|
|
|
|
+ " order by count desc,wfid LIMIT 12";
|
|
|
|
|
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
}
|
|
|
|
|
else if(rs.getDBType().equalsIgnoreCase("postgresql"))
|
|
|
|
|
{
|
|
|
|
|
String sql = "select "
|
|
|
|
|
+ selectSql
|
|
|
|
|
+ " from WorkflowUseCount "
|
|
|
|
|
+ innerjoinSql
|
|
|
|
|
+ " where WorkflowUseCount.userid ="
|
|
|
|
|
+ user.getUID()
|
|
|
|
|
//+ (!"".equals(portalsqlwhere) ? portalsqlwhere : "")
|
|
|
|
|
+ " and ("+Util.getSubINClause(ofsWorkflowids_CurrUser, "wfid", "in")+" or wfid in ("
|
|
|
|
|
+ "select t.workflowid from workflow_agentConditionSet t,workflow_base t1 where exists (select * from HrmResource b where t.bagentuid=b.id and b.status<4) and t.workflowid=t1.id and t.agenttype>'0' and t.iscreateagenter=1 and t.agentuid="
|
|
|
|
|
+ user.getUID() + " union all select t1.workflowid from ShareInnerWfCreate t1,workflow_base t2 where t1.workflowid=t2.id and t2.isvalid in ('1','3'))) " + groupbySql
|
|
|
|
|
+ " order by count desc,wfid limit 12 ";
|
|
|
|
|
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
String sql = "select top 12 "
|
|
|
|
|
+ selectSql
|
|
|
|
|
+ " from WorkflowUseCount "
|
|
|
|
|
+ innerjoinSql
|
|
|
|
|
+ " where WorkflowUseCount.userid ="
|
|
|
|
|
+ user.getUID()
|
|
|
|
|
//+ (!"".equals(portalsqlwhere) ? portalsqlwhere : "")
|
|
|
|
|
+ " and ("+Util.getSubINClause(ofsWorkflowids_CurrUser, "wfid", "in")+" or wfid in ("
|
|
|
|
|
+ "select t.workflowid from workflow_agentConditionSet t,workflow_base t1 where exists (select * from HrmResource b where t.bagentuid=b.id and b.status<4) and t.workflowid=t1.id and t.agenttype>'0' and t.iscreateagenter=1 and t.agentuid="
|
|
|
|
|
+ user.getUID() + " union all select t1.workflowid from ShareInnerWfCreate t1,workflow_base t2 where t1.workflowid=t2.id and t2.isvalid in ('1','3'))) " + groupbySql
|
|
|
|
|
+ " order by count desc,wfid ";
|
|
|
|
|
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String wfid = rs.getString("wfid");
|
|
|
|
|
usedtodoList.add(wfid);
|
|
|
|
|
if(!usedtodoAndCollWfIds.contains(wfid)){
|
|
|
|
|
usedtodoAndCollWfIds.add(wfid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 填充新建流程数据集合
|
|
|
|
|
* @param wftype
|
|
|
|
|
* @param typeid
|
|
|
|
|
* @param workflowid
|
|
|
|
|
* @param workflowname
|
|
|
|
|
* @param isimportwf
|
|
|
|
|
* @param userid
|
|
|
|
|
* @param beagenterid
|
|
|
|
|
* @param isagent
|
|
|
|
|
*/
|
|
|
|
|
private void generateInjectData(WfType wftype,String typeid,String workflowid,String typename,String workflowname,String isimportwf,String mobileurl,String pcurl,int userid,int beagenterid,boolean isagent,boolean isos,String workflowdesc){
|
|
|
|
|
if((Util.getIntValue(typeid) > 0 && Util.getIntValue(workflowid) < 0) || (Util.getIntValue(typeid) < 0 && Util.getIntValue(workflowid) > 0)){//过滤脏数据
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (wftype == null) {
|
|
|
|
|
wftype = new WfType();
|
|
|
|
|
wftype.setId(typeid);
|
|
|
|
|
wftype.setTypeName(typename);
|
|
|
|
|
// 设置该类型是否收藏
|
|
|
|
|
if (selectedworkflow.indexOf("T" + typeid + "|") > 0) {
|
|
|
|
|
wftype.setWftypeColl("1");
|
|
|
|
|
} else {
|
|
|
|
|
wftype.setWftypeColl("0");
|
|
|
|
|
}
|
|
|
|
|
wftypeInfo.put(typeid, wftype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, WfBean> wfbeanInfo = wftype.getWfbeanInfo();
|
|
|
|
|
WfBean wfbean = wfbeanInfo.get(workflowid);
|
|
|
|
|
if (wfbean == null) {
|
|
|
|
|
wfbean = new WfBean();
|
|
|
|
|
wfbean.setId(workflowid);
|
|
|
|
|
wfbean.setName(workflowname);
|
|
|
|
|
wfbean.setWorkflowdesc(StringUtils.isNotEmpty(workflowdesc) ? workflowdesc : workflowname);
|
|
|
|
|
wfbean.setTypeId(typeid);
|
|
|
|
|
wfbean.setIsImportWf(isimportwf);
|
|
|
|
|
if (selectedworkflow.indexOf("W" + workflowid + "|") > -1 && isuserdefault.equals("1")) {
|
|
|
|
|
wfbean.setWfColl("1");
|
|
|
|
|
} else {
|
|
|
|
|
wfbean.setWfColl("0");
|
|
|
|
|
}
|
|
|
|
|
if (usedtodoList.contains(workflowid)) {
|
|
|
|
|
wfbean.setUsedtodo("1");
|
|
|
|
|
wfbean.setUsedtodoorder(usedtodoList.indexOf(workflowid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wfbean.setLetter(getWfNameFirstLetter(workflowname));
|
|
|
|
|
wfbean.setSpell(Pinyin4j.spell(workflowname));
|
|
|
|
|
wfbean.setMobileurl(mobileurl);//异构系统移动端新建地址
|
|
|
|
|
wfbean.setPcurl(pcurl);//异构系统pc端新建地址
|
|
|
|
|
if(DoSaveFreeExcelDesignBiz.judgeIsFreeCustomForm(workflowid)){
|
|
|
|
|
wfbean.setIsFreeCustomeForm(1);
|
|
|
|
|
}
|
|
|
|
|
wfbeanInfo.put(workflowid, wfbean);
|
|
|
|
|
}
|
|
|
|
|
if (!isos && user.getUID() != userid && userid > 0) {//次账号身份信息--异构系统不展示
|
|
|
|
|
WfUser belonguser = getWfUser(String.valueOf(userid));
|
|
|
|
|
if (!wfbean.getBelongtoUsers().contains(belonguser)) {
|
|
|
|
|
wfbean.getBelongtoUsers().add(belonguser);
|
|
|
|
|
}
|
|
|
|
|
} else if(isagent && beagenterid > 0){//被代理人身份信息
|
|
|
|
|
WfUser beagentuser = getWfUser(String.valueOf(beagenterid));
|
|
|
|
|
if (!wfbean.getBeagenters().contains(beagentuser)) {
|
|
|
|
|
wfbean.getBeagenters().add(beagentuser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getWfNameFirstLetter(String wfname) {
|
|
|
|
|
if(wfname == null || "".equals(wfname))
|
|
|
|
|
return "";
|
|
|
|
|
String[] currentData = wfname.split("`~`");
|
|
|
|
|
String currentLan = user.getLanguage() + " ";
|
|
|
|
|
String letter = "";
|
|
|
|
|
if (specialstr.indexOf(wfname.charAt(0)) >= 0) {
|
|
|
|
|
if (currentData.length > 3) {//处理多语言
|
|
|
|
|
for (String currentStr : currentData) {
|
|
|
|
|
if (currentStr.length() > 2) {
|
|
|
|
|
if (currentStr.substring(0, 2).equals(currentLan)) {
|
|
|
|
|
wfname = currentStr.substring(2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
char chinese = wfname.charAt(0);
|
|
|
|
|
String[] py = PinyinHelper.toHanyuPinyinStringArray(chinese);
|
|
|
|
|
letter = py == null ? chinese + "" : py[0];
|
|
|
|
|
letter = (letter.charAt(0) + "").toUpperCase();
|
|
|
|
|
} else {
|
|
|
|
|
char chinese = wfname.charAt(0);
|
|
|
|
|
String[] py = PinyinHelper.toHanyuPinyinStringArray(chinese);
|
|
|
|
|
letter = (py == null) ? chinese + "" : py[0];
|
|
|
|
|
letter = (letter.charAt(0) + "").toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
return letter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WfUser getWfUser(String userId) {
|
|
|
|
|
WfUser wfUser = new WfUser();
|
|
|
|
|
wfUser.setId(userId);
|
|
|
|
|
wfUser.setLastname(resourceComInfo.getLastname(userId));
|
|
|
|
|
wfUser.setSubcompany(resourceComInfo.getSubCompanyID(userId));
|
|
|
|
|
wfUser.setDepartment(resourceComInfo.getDepartmentID(userId));
|
|
|
|
|
wfUser.setJobtitlename(jobTitlesComInfo.getJobTitlesname(resourceComInfo.getJobTitle(userId)));
|
|
|
|
|
try {
|
|
|
|
|
wfUser.setDepartmentName(departmentComInfo.getDepartmentname(wfUser.getDepartment()));
|
|
|
|
|
wfUser.setSubcompanyName(subCompanyComInfo.getSubcompanyname(wfUser.getSubcompany()));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return wfUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 剔除数据中心流程
|
|
|
|
|
*/
|
|
|
|
|
private void getAllInputReport() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String dataCenterWorkflowTypeId = "";
|
|
|
|
|
rs.executeQuery("select currentId from sequenceindex where indexDesc='dataCenterWorkflowTypeId'");
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
dataCenterWorkflowTypeId = Util.null2String(rs.getString("currentId"));
|
|
|
|
|
}
|
|
|
|
|
if ("".equals(dataCenterWorkflowTypeId)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wftypeInfo.remove(dataCenterWorkflowTypeId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 排序,并计算各个类型在前台显示的位置
|
|
|
|
|
private List<WfType> sortWfTypes() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery("select * from (select id,iconkey,dsporder,0 as sysorder,id as absid from workflow_type union select sysid as id,icon as iconkey,showorder as dsporder,1 as sysorder,abs(sysid) as absid from ofs_sysinfo) t order by dsporder,sysorder,absid ");
|
|
|
|
|
int colorIndex = 0;
|
|
|
|
|
List<WfType> result = new ArrayList<WfType>();
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String wftypeid = rs.getString(1);
|
|
|
|
|
String wfIconKey = Util.null2String(rs.getString("iconkey"));
|
|
|
|
|
WfType wftype = wftypeInfo.get(wftypeid);
|
|
|
|
|
if (wftype == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
wftype.setColor(colors[colorIndex % (colors.length)]);
|
|
|
|
|
if (!"".equals(wfIconKey)) {//如果取出来的数据不为空
|
|
|
|
|
wftype.setImg(wfIconKey);
|
|
|
|
|
} else {//如果后台没设置的,取随机
|
|
|
|
|
wftype.setImg(imgs[colorIndex % (colors.length)]);
|
|
|
|
|
}
|
|
|
|
|
colorIndex++;
|
|
|
|
|
wftype.getWfbeans().addAll(wftype.getWfbeanInfo().values());
|
|
|
|
|
wftype.setWfbeanInfo(null);
|
|
|
|
|
result.add(wftype);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户、流程ID串 获取可创建流程列表
|
|
|
|
|
* @param workflowids
|
|
|
|
|
* @param user
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<WfType> getCreateWfList(String workflowids){
|
|
|
|
|
//获取所有版本的流程
|
|
|
|
|
String __workflowids = Util.null2String(WorkflowVersion.getAllVersionStringByWFIDs(workflowids));
|
|
|
|
|
if("".equals(__workflowids)){
|
|
|
|
|
return new ArrayList<WfType>();
|
|
|
|
|
}
|
|
|
|
|
return getWfInfo(__workflowids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, WfType> getWftypeInfo() {
|
|
|
|
|
return wftypeInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getCommonuse() {
|
|
|
|
|
return commonuse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getCustomSqlWhere() {
|
|
|
|
|
return customSqlWhere;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCustomSqlWhere(String customSqlWhere) {
|
|
|
|
|
this.customSqlWhere = customSqlWhere;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getForceUnsupportSPAWF() {
|
|
|
|
|
return forceUnsupportSPAWF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getInornot() {
|
|
|
|
|
return inornot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setInornot(String inornot) {
|
|
|
|
|
this.inornot = Util.null2s(inornot,"in").trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getNewRequestRange() {
|
|
|
|
|
return newRequestRange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNewRequestRange(String newRequestRange) {
|
|
|
|
|
this.newRequestRange = newRequestRange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTypeids(){
|
|
|
|
|
return typeids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTypeids(String typeids){
|
|
|
|
|
this.typeids = typeids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isIsmobile() {
|
|
|
|
|
return ismobile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIsmobile(boolean ismobile) {
|
|
|
|
|
this.ismobile = ismobile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, List<OfsWorkflow>> getOfsWorkflowDatas() {
|
|
|
|
|
return ofsWorkflowDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<String> getUnSupportSPAWf(){
|
|
|
|
|
return getUnSupportSPAWf("");
|
|
|
|
|
}
|
|
|
|
|
//初步计算出哪些流程不支持E9模式,控制点击时跳转地址
|
|
|
|
|
public static List<String> getUnSupportSPAWf(String forceUnsupportSPAWF){
|
|
|
|
|
List<String> unSupportSPAWf = new ArrayList<String>();
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery("select workflowid from workflow_flownode a where nodetype='0' and (ismode='1' or (ismode='2' and not exists (select 1 from workflow_nodehtmllayout where nodeid=a.nodeid and version=2 and type=0 and isactive=1)))");
|
|
|
|
|
while(rs.next()){
|
|
|
|
|
unSupportSPAWf.add(Util.null2String(rs.getString("workflowid")));
|
|
|
|
|
}
|
|
|
|
|
//周工作总结、月工作总结特殊处理,走E8逻辑
|
|
|
|
|
rs.executeQuery("select id from workflow_base where isbill=1 and formid in (17,21)");
|
|
|
|
|
while(rs.next()){
|
|
|
|
|
String wfid = rs.getString("id");
|
|
|
|
|
if(unSupportSPAWf.indexOf(wfid) == -1)
|
|
|
|
|
unSupportSPAWf.add(wfid);
|
|
|
|
|
}
|
|
|
|
|
unSupportSPAWf.addAll(Util.TokenizerString(forceUnsupportSPAWF,","));
|
|
|
|
|
return unSupportSPAWf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getWorkflowDesc(String workflowid){
|
|
|
|
|
String workflowdesc = "" ;
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = " select workflowdesc from workflow_base where id = "+workflowid;
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
workflowdesc = Util.null2String(rs.getString("workflowdesc"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return workflowdesc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|