📄 statemachinehelper.java
字号:
return false;
}
public String toFlowHtmlText(String flowid, String docid, WebUser webUser)
throws Exception {
StringBuffer buffer = new StringBuffer();
BillDefiVO flowVO = null;
flowVO = (BillDefiVO) getBillDefiProcess().doView(flowid);
FlowDiagram fd = flowVO.toFlowDiagram();
NodeRT nodert = getCurrUserNodeRT(docid, flowid, webUser);
// 获取当前节点
Node currnode = null;
if (nodert != null) {
String currnodeid = nodert.getNodeid();
if (currnodeid != null) {
currnode = (Node) fd.getElementByID(currnodeid);
}
buffer.append("<input type='hidden' name='_currid' value='"
+ currnodeid + "'>");
}
buffer.append("");
if (flowState == FlowState.RUNNING && currnode != null) {// 送下一步
isDisplySubmit = true;
Collection nextNodeList = this.getNextToNodeList(docid, flowid,
currnode.id, webUser);
if (nextNodeList != null && nextNodeList.size() > 0) {
Iterator it3 = nextNodeList.iterator();
buffer
.append("<tr style='font-size:11px' align='top' valign='top'>");
buffer
.append("<td style='font-size:11px' valign='top'>Next To:");
while (it3.hasNext()) {
Node nextNode = (Node) it3.next();
Node node = this.getCurrNode(flowid, nodert.getNodeid());
boolean issplit = false;
boolean isgather = false;
if (node != null && node instanceof ManualNode) {
issplit = ((ManualNode) node).issplit;
isgather = ((ManualNode) node).isgather;
}
boolean flag = false;
if (isgather) {// 如果为聚合
Collection nodertList = getAllNodeRT(docid, flowid);
if (nodertList != null) {
for (Iterator iter = nodertList.iterator(); iter
.hasNext();) {
NodeRT nrt = (NodeRT) iter.next();
// 判断所有运行时节点是否为当前节点
if (!nrt.getNodeid().equals(nodert.getNodeid())) {
Node nd = (Node) fd.getElementByID(nrt
.getNodeid());
Node currNode = (Node) fd
.getElementByID(nodert.getNodeid());
Collection followTo = fd
.getAllFollowNodeOnPath(nd.id);
if (followTo != null
&& followTo.contains(currNode)) {
flag = true;
break;
}
}
}
}
}
if (!flag) {
boolean isOthers = false;
String id = "next";
if (!(nextNode instanceof ManualNode)) {// 下一个节点中是否存在suspend
isOthers = true;
id = "other";
}
buffer.append("<input id='" + id + "' type='"
+ (issplit ? "checkbox" : "radio")
+ "' name='_nextids' value='" + nextNode.id
+ "' onclick='ev_setFlowType(" + isOthers
+ ",this)' />" + nextNode.name);
}
}
buffer.append("</td></tr>");
}
Collection backNodeList = this.getBackToNodeList(docid, flowid,
currnode.id, webUser);
if (backNodeList != null && backNodeList.size() > 0) {
backNodeList = StateMachine.removeDuplicateNode(backNodeList,
currnode);
buffer
.append("<tr style='font-size:11px'><td style='font-size:11px'>Return To:");
buffer
.append("<select style='font-size:11px' id='back' name='_nextids' onchange='ev_setFlowType(false, this)'>");
buffer.append("<option value=''>");
buffer.append("Please Choose");
buffer.append("</option>");
for (Iterator iter = backNodeList.iterator(); iter.hasNext();) {
Node backNode = (Node) iter.next();
buffer.append("<option value='" + backNode.id + "'>");
buffer.append(backNode.name);
buffer.append("</option>");
}
buffer.append("</select>");
buffer.append("</td></tr>");
}
} else if (flowState == FlowState.SUSPEND && currnode != null
&& currnode instanceof SuspendNode) {
Collection backNodeList = this.getBackToNodeList(docid, flowid,
currnode.id, webUser, FlowState.SUSPEND);
backNodeList = StateMachine.removeDuplicateNode(backNodeList);
isDisplySubmit = true;
if (backNodeList != null) {
Iterator it4 = backNodeList.iterator();
buffer
.append("<tr style='font-size:11px'><td style='font-size:11px'>Resume Flow:");
while (it4.hasNext()) {
Node backNode = (Node) it4.next();
buffer
.append("<input id='suspend' type='radio' name='_nextids' value='"
+ backNode.id + "' />" + backNode.name);
}
buffer.append("</td></tr>");
}
} else {
isDisplySubmit = false;
if (flowState == FlowState.COMPLETE) {
buffer
.append("<tr><td style='font-size:11px;font-family: Arial, Helvetica;color:#FF0000'>Flow Complete!</td></tr>");
} else if (flowState == FlowState.TERMINAT) {
buffer
.append("<tr><td style='font-size:11px;font-family: Arial, Helvetica;color:#FF0000'>Flow Terminate!</td></tr>");
} else if (flowState == FlowState.ABORT) {
buffer
.append("<tr><td style='font-size:11px;font-family: Arial, Helvetica;color:#FF0000'>Flow Abort!</td></tr>");
} else if (flowState == FlowState.START) {
isDisplyFlow = false;
}
}
return buffer.toString();
} // 流程处理者
public String toCurrProcessorHtml(String flowid, String docid)
throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("Current Processor:");
Collection nodertList = new ArrayList();
if (flowState == FlowState.SUSPEND) {
nodertList.add(this.getSuspendNodeRT(docid, flowid));
} else {
nodertList = this.getAllNodeRT(docid, flowid);
}
for (Iterator iter = nodertList.iterator(); iter.hasNext();) {
NodeRT nodert = (NodeRT) iter.next();
Collection colls = nodert.getActorrts();
Object[] actorrtList = colls.toArray();
for (int i = 0; i < actorrtList.length; i++) {
String actorrtName = ((ActorRT) actorrtList[i]).getName();
if (actorrtList.length == 1) {
actorrtName = "(" + actorrtName + ")";
} else {
actorrtName = i != actorrtList.length - 1 ? "("
+ actorrtName + "," : actorrtName + ")";
}
buffer.append(actorrtName);
}
}
return buffer.toString();
}
// 流程历史
public String toHistoryHtml(String flowid, String docid, int columnCount)
throws Exception {
String historyHtml = "";
Collection colls = this.getAllRelationHIS(docid, flowid);
Object[] hisList = colls.toArray();
Collection tmp = new ArrayList();
int count = 1;
int index = 0;
int storeIndex = 0;
historyHtml += "<table>";
for (int i = 0; i < hisList.length; i++) {
RelationHIS relationhis = (RelationHIS) hisList[i];
if (i != 0) {
// 上一条历史记录
RelationHIS preRelationhis = (RelationHIS) hisList[i - 1];
if (relationhis.getActiontime().equals(
preRelationhis.getActiontime())) {
tmp.add(relationhis);
} else {
if (storeIndex + columnCount == index) {
historyHtml += "</tr>";
storeIndex = index;
}
if (index % columnCount == 0) {
historyHtml += "<tr>";
}
historyHtml += toHistoryHtml(tmp, count);
// 清空tmp
tmp.clear();
// 把当前历史加入tmp
tmp.add(relationhis);
count++;
index++;
}
} else {
tmp.add(relationhis);
}
}
// 生成html
if (tmp.size() > 0) {
if (index % columnCount == 0) {
historyHtml += "</tr><tr>" + toHistoryHtml(tmp, count)
+ "</tr>";
} else {
historyHtml += toHistoryHtml(tmp, count) + "</tr>";
}
}
historyHtml += "</table>";
return historyHtml;
}
public String toHistoryHtml(Collection tmp, int count) {
Object[] rhises = tmp.toArray();
StringBuffer buffer = new StringBuffer();
Date actionTime = ((RelationHIS) tmp.iterator().next()).getActiontime();
String actiontimeStr = DateUtil.getDateTimeStr(actionTime);
if (count == 1) {
buffer
.append("<td style='font-size:7px;line-height:5px' colspan='2'><table bordercolor='#cccccc' cellspacing='0' cellpadding='3' width='100%' align='left' bgcolor='#ffffff' border='1'>");
} else {
buffer
.append("<td><table ><tr><td><img src='/webapp/resource/image/nextStep.gif' width='16' height='16'></td></tr></table></td>");
buffer
.append("<td style='font-size:7px'><table bordercolor='#cccccc' cellspacing='0' cellpadding='3' width='100%' align='left' bgcolor='#ffffff' border='1'>");
}
buffer
.append("<tr bgcolor='#DDDDDD' ><td colspan='2' style='font-size:7px'>");
buffer.append("<span style='font-weight: bold;font-size:11px'>Step-"
+ count + " </span>Time:" + actiontimeStr);
buffer.append("</td></tr>");
buffer.append("<tr >");
buffer
.append("<td style='font-size:9px;line-height:8pt;white-space:nowrap' valign='top'>");
RelationHIS first = (RelationHIS) rhises[0];
Collection actorhisList = first.getActorhiss();
buffer
.append("<span style='font-weight: bold;font-size:11px'>From:</span>");
for (Iterator iterator = actorhisList.iterator(); iterator.hasNext();) {
ActorHIS actorhis = (ActorHIS) iterator.next();
String actorName = actorhis.getName();
buffer.append(actorName + "");
}
buffer.append("</td>");
buffer.append("<td style='font-size:7px;line-height:5px'>");
buffer
.append("<table cellspacing='0' style='font-size:7px;line-height:5px'>");
buffer
.append("<tr><td style='font-size:9px;line-height:8pt;white-space:nowrap'><span style='font-weight: bold;font-size:11px'>To:</span>");
buffer.append("");
for (int i = 0; i < rhises.length; i++) {
RelationHIS tmphis = (RelationHIS) rhises[i];
buffer.append("" + tmphis.getEndnodename() + "</td></tr>");
}
buffer.append("</table>");
buffer.append("</td>");
buffer.append("</tr>");
buffer
.append("<tr ><td colspan='2' style='font-size:9px'><span style='font-weight: bold;font-size:11px'>Remarks:</span>"
+ (first.getAttitude() == null ? "" : first
.getAttitude()) + "</td></tr>");
buffer.append("</table></td>");
return buffer.toString();
}
// 流程状态
public String toFlowStateHtml(String flowid, String docid) throws Exception {
StringBuffer buffer = new StringBuffer();
FlowStateRT flowStateRT = StateMachine.getFlowStateRT(docid, flowid);
if (flowStateRT != null) {
int code = flowStateRT.getState();
String flowStateName = FlowState.getName(code);
buffer.append("[FlowState:" + flowStateName + "]");
}
return buffer.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -