apzl_leasing/src_tenwa/com/tenwa/flow/util/FlowViewGraph.java
2018-06-03 22:26:41 +08:00

554 lines
24 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tenwa.flow.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import jbo.sys.FLOW_CATALOG;
import jbo.sys.FLOW_MODEL;
import jbo.sys.FLOW_TASK;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.are.util.json.JSONDecoder;
import com.amarsoft.are.util.json.JSONEncoder;
import com.amarsoft.are.util.json.JSONObject;
public class FlowViewGraph {
private String flowNo;
public String getFlowNo() {
return flowNo;
}
public void setFlowNo(String flowNo) {
this.flowNo = flowNo;
}
/**
* 获取ade工具开发的旧流程图
* @param tx
* @return
* @throws Exception
*/
public String getModel(JBOTransaction tx,String flowNo) throws Exception{
List<BizObject> fms = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME).createQuery("flowno=:flowno ")
.setParameter("flowno", flowNo).getResultList(false);
BizObjectQuery beginEndPointQuery = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME).createQuery(
"select O.phaseno from O where flowno=:flowno and postscript is not null and postscript <> '' and "+
"(postscript like :phaseno1 or postScript like :phaseno2 or postScript like :phaseno3 or postscript like :phaseno4) ")
.setParameter("flowno", flowNo);
Map<String,Object> stateMap = new HashMap<String,Object>();
Map<String,String> rectPhaseno = new HashMap<String,String>();
Map<String,Object> pathMap = new HashMap<String,Object>();
Map<String,Object> propsMap = new HashMap<String,Object>();
Map<String,Object> modelMap = new HashMap<String,Object>();
if(fms.size()>0){
for(int i=0;i<fms.size();i++){
Map<String,Object> nodeName = new HashMap<String,Object>();
Map<String,Object> attrValue = new HashMap<String,Object>();
Map<String,Object> textValue = new HashMap<String,Object>();
Map<String,Object> keyValue = new HashMap<String,Object>();
Map<String,Object> positionValue = new HashMap<String,Object>();
Map<String,Object> props = new HashMap<String,Object>();
Map<String,Object> rect = new HashMap<String,Object>();
BizObject fm = fms.get(i);
if(fm.getAttribute("phaseno").getString().equals("8000")){
rect.put("type", "reject");
}else if(fm.getAttribute("phaseno").getString().equals("0010")){
rect.put("type", "task");
}else{
rect.put("type", fm.getAttribute("nodetype").getString().toLowerCase());
}
nodeName.put("text",fm.getAttribute("phasename").getString());
rect.put("text", nodeName);
attrValue.put("x", fm.getAttribute("xcoordinate").getInt());
attrValue.put("y", fm.getAttribute("ycoordinate").getInt());
if(fm.getAttribute("nodetype").getString().equalsIgnoreCase("task")||fm.getAttribute("nodetype").getString().equalsIgnoreCase("start")){
attrValue.put("width", 100);
attrValue.put("height",50);
}else{
attrValue.put("width", 50);
attrValue.put("height", 50);
}
rect.put("attr", attrValue);
textValue.put("value",fm.getAttribute("phasename").getString());
keyValue.put("value", String.valueOf(i));
positionValue.put("value", fm.getAttribute("phaseno").getString());
props.put("text", textValue);
props.put("key", keyValue);
props.put("position", positionValue);
rect.put("props", props);
stateMap.put("rect"+String.valueOf(i+1), rect);
rectPhaseno.put(fm.getAttribute("phaseno").getString(), "rect"+String.valueOf(i+1));
}
}
modelMap.put("states", stateMap);
if(fms.size()>0){
int num = fms.size()+1;
for(int i=0;i<fms.size();i++){
BizObject fm = fms.get(i);
String phaseNo = fm.getAttribute("phaseno").getString();
List<BizObject> phases = beginEndPointQuery.setParameter("phaseno1", "%'"+phaseNo+"'%").setParameter("phaseno2", "%\""+phaseNo+"\"%")
.setParameter("phaseno3", "%;"+phaseNo+"%").setParameter("phaseno4", "%"+phaseNo+";%").getResultList(false);
if(phases.size()>0){
for(BizObject phase : phases){
String prePhaseno = phase.getAttribute("phaseno").getString();
Map<String,Object> path = new HashMap<String,Object>();//
path.put("from", rectPhaseno.get(prePhaseno));
path.put("to", rectPhaseno.get(phaseNo));
path.put("dots", new ArrayList());
Map<String,Object> toPhasename = new HashMap<String,Object>();
toPhasename.put("text", "to"+fm.getAttribute("phasename").getString());
path.put("text", toPhasename);
Map<String,Object> textPos = new HashMap<String,Object>();//
textPos.put("x", 0);
textPos.put("y", -10);
path.put("textPos", textPos);
Map<String,Object> text =new HashMap<String,Object>();
text.put("value", "");
Map<String,Object> propstext =new HashMap<String,Object>();
propstext.put("text", text);
path.put("props",propstext);
pathMap.put("path"+String.valueOf(num), path);
num++;
}
}
}
}
modelMap.put("paths", pathMap);
Map<String,Object> type = new HashMap<String,Object>();
Map<String,Object> displayName = new HashMap<String,Object>();
Map<String,Object> code = new HashMap<String,Object>();
Map<String,Object> name = new HashMap<String,Object>();
Map<String,Object> version = new HashMap<String,Object>();
Map<String,Object> jpdlVersion = new HashMap<String,Object>();
Map<String,Object> desc = new HashMap<String,Object>();
Map<String,Object> position = new HashMap<String,Object>();
Map<String,Object> props = new HashMap<String,Object>();
type.put("value", "null");
displayName.put("value", "null");
code.put("value", "null");
name.put("value", "null");
version.put("value", "null");
jpdlVersion.put("value", "4.4");
desc.put("value", "null");
position.put("value", "null");
props.put("type",type);
props.put("displayName",displayName);
props.put("code",code);
props.put("name",name);
props.put("type",version);
props.put("jpdlVersion",jpdlVersion);
props.put("desc",desc);
props.put("position",position);
propsMap.put("props", props);
modelMap.put("props", propsMap);
String graphJsonStr = JSONEncoder.encode(modelMap);
graphJsonStr = graphJsonStr.replaceAll("\"","\'");
return graphJsonStr;
}
/**
* 获取jbpm格式的json串
* @param tx,flowNo
* @return
* @throws Exception
*/
public String getGraphJson(JBOTransaction tx,String flowNo) throws Exception{
BizObject fc = JBOFactory.getBizObjectManager(FLOW_CATALOG.CLASS_NAME).createQuery("flowno=:flowno ").setParameter("flowno",flowNo).getSingleResult(false);
String graphJsonData="";
if(fc != null){
graphJsonData = fc.getAttribute("graphjsondata").getString();
if(graphJsonData ==null || graphJsonData.equals("")){
List<BizObject> fms = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME).createQuery("flowno=:flowno ")
.setParameter("flowno", flowNo).getResultList(false);
if(fms.size()>0){
graphJsonData = getModel(tx,flowNo);
}
}
}
return graphJsonData;
}
/**
* 发布流程
* @param tx
* @return
* @throws Exception
*/
public String publishFlow(JBOTransaction tx) throws Exception{
String result = "fail";
BizObjectManager fcManager = JBOFactory.getBizObjectManager(FLOW_CATALOG.CLASS_NAME);
tx.join(fcManager);
BizObject fc = fcManager.createQuery("flowno=:flowno ").setParameter("flowno",flowNo).getSingleResult(false);
BizObjectManager fmManager = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
tx.join(fmManager);
List<BizObject> fms = fmManager.createQuery("flowno=:flowno ").setParameter("flowno", flowNo).getResultList(false);
if(fms.size()==0){
String graphJson = fc.getAttribute("graphjsondata").getString();
JSONObject jsonObj = JSONDecoder.decode(graphJson);
JSONObject states = (JSONObject)jsonObj.getValue("states");
JSONObject paths = (JSONObject)jsonObj.getValue("paths");
Map<String,Map<String,String>> rect_phaseno_type = new HashMap<String,Map<String,String>>();
Map<String,Map<String,String>> rect_phaseno_specialtype = new HashMap<String,Map<String,String>>();
for(int i=0; i<states.size(); i++){
String key = states.get(i).getName();
JSONObject rect = (JSONObject)states.getValue(i);
newFlowModel(tx,rect,key,rect_phaseno_type,rect_phaseno_specialtype);
}
if(!rect_phaseno_specialtype.isEmpty()){
for(int i=0;i<paths.size(); i++){//在并行情况下改变分支前一节点的nodetype和改变合并后一节点的nodetype
JSONObject path = (JSONObject)paths.getValue(i);
String from = (String)path.getValue("from");
String to = (String)path.getValue("to");
if(rect_phaseno_specialtype.containsKey(to) && rect_phaseno_specialtype.get(to).get("nodetype").equalsIgnoreCase("fork")){
String fromPhaseNo = rect_phaseno_type.get(from).get("phaseno");
String toNodeType = rect_phaseno_specialtype.get(to).get("nodetype");
BizObjectQuery bq = fmManager.createQuery("UPDATE O SET nodetype=:nodetype WHERE phaseno=:phaseno and flowno=:flowno ");
bq.setParameter("nodetype",toNodeType.toUpperCase());
bq.setParameter("phaseno",fromPhaseNo);
bq.setParameter("flowno",flowNo);
bq.executeUpdate();
}else if(rect_phaseno_specialtype.containsKey(from) && rect_phaseno_specialtype.get(from).get("nodetype").equalsIgnoreCase("join")){
String toPhaseNo = rect_phaseno_type.get(to).get("phaseno");
String fromNodeType = rect_phaseno_specialtype.get(from).get("nodetype");
BizObjectQuery bq = fmManager.createQuery("UPDATE O SET nodetype=:nodetype WHERE phaseno=:phaseno and flowno=:flowno ");
bq.setParameter("nodetype",fromNodeType.toUpperCase());
bq.setParameter("phaseno",toPhaseNo);
bq.setParameter("flowno",flowNo);
bq.executeUpdate();
}
}
}
BizObjectQuery bq = fcManager.createQuery("UPDATE O SET flowstate=:flowstate WHERE flowno=:flowno ");
bq.setParameter("flowno", flowNo);
bq.setParameter("flowstate","publish");
bq.executeUpdate();
result = "success";
}
return result;
}
/**
* 同步流程
* @param tx
* @param flowNo
* @return
* @throws Exception
*/
public String syncFlow(JBOTransaction tx) throws Exception{
String result = "fail";
BizObjectManager fcManager = JBOFactory.getBizObjectManager(FLOW_CATALOG.CLASS_NAME);
tx.join(fcManager);
BizObject fc = fcManager.createQuery("flowno=:flowno ").setParameter("flowno",flowNo).getSingleResult(false);
BizObjectManager fmManager = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
tx.join(fmManager);
List<BizObject> oldFlowModels = fmManager.createQuery("flowno=:flowno ").setParameter("flowno",flowNo).getResultList(false);
Map<String,String> phasenos = new HashMap<String,String>();
for(BizObject oldFlowModel:oldFlowModels){
phasenos.put(oldFlowModel.getAttribute("phaseno").getString(), oldFlowModel.getAttribute("phaseno").getString());
}
String graphJson = fc.getAttribute("graphjsondata").getString();
JSONObject jsonObj = JSONDecoder.decode(graphJson);
JSONObject states = (JSONObject)jsonObj.getValue("states");
JSONObject paths = (JSONObject)jsonObj.getValue("paths");
Map<String,Map<String,String>> rect_phaseno_type = new HashMap<String,Map<String,String>>();
Map<String,Map<String,String>> rect_phaseno_specialtype = new HashMap<String,Map<String,String>>();
for(int i=0; i<states.size(); i++){
JSONObject rect = (JSONObject)states.getValue(i);
String key = states.get(i).getName();
JSONObject props = (JSONObject)rect.getValue("props");
JSONObject position = (JSONObject)props.getValue("position");
String phaseNo = (String)position.getValue("value");
BizObject fm = fmManager.createQuery("phaseno=:phaseno and flowno=:flowno ").setParameter("phaseno",phaseNo).setParameter("flowno", flowNo).getSingleResult(false);
if(fm !=null){
phasenos.remove(phaseNo);
updateFlowModel(tx,rect,key,rect_phaseno_type,rect_phaseno_specialtype,phaseNo);
}else{
newFlowModel(tx,rect,key,rect_phaseno_type,rect_phaseno_specialtype);
}
}
if(!phasenos.isEmpty()){
Iterator<String> it = phasenos.values().iterator();
while (it.hasNext()) {
String exphaseno = it.next();
fmManager.createQuery("delete from o where phaseno=:phaseno and flowno=:flowno ").setParameter("phaseno",exphaseno).setParameter("flowno", flowNo).executeUpdate();
}
}
if(!rect_phaseno_specialtype.isEmpty()){
for(int i=0;i<paths.size(); i++){//在并行情况下改变分支前一节点的nodetype和改变合并后一节点的nodetype
JSONObject path = (JSONObject)paths.getValue(i);
String from = (String)path.getValue("from");
String to = (String)path.getValue("to");
if(rect_phaseno_specialtype.containsKey(to) && rect_phaseno_specialtype.get(to).get("nodetype").equalsIgnoreCase("fork")){
String fromPhaseNo = rect_phaseno_type.get(from).get("phaseno");
String toNodeType = rect_phaseno_specialtype.get(to).get("nodetype");
BizObjectQuery bq = fmManager.createQuery("UPDATE O SET nodetype=:nodetype WHERE phaseno=:phaseno and flowno=:flowno ");
bq.setParameter("nodetype",toNodeType.toUpperCase());
bq.setParameter("phaseno",fromPhaseNo);
bq.setParameter("flowno",flowNo);
bq.executeUpdate();
}else if(rect_phaseno_specialtype.containsKey(from) && rect_phaseno_specialtype.get(from).get("nodetype").equalsIgnoreCase("join")){
String toPhaseNo = rect_phaseno_type.get(to).get("phaseno");
String fromNodeType = rect_phaseno_specialtype.get(from).get("nodetype");
BizObjectQuery bq = fmManager.createQuery("UPDATE O SET nodetype=:nodetype WHERE phaseno=:phaseno and flowno=:flowno ");
bq.setParameter("nodetype",fromNodeType.toUpperCase());
bq.setParameter("phaseno",toPhaseNo);
bq.setParameter("flowno",flowNo);
bq.executeUpdate();
}
}
}
BizObjectQuery bq = fcManager.createQuery("UPDATE O SET flowstate=:flowstate WHERE flowno=:flowno ");
bq.setParameter("flowno", flowNo);
bq.setParameter("flowstate","synchronized");
bq.executeUpdate();
result = "success";
return result;
}
/**
* 更新flowModel
* @param tx
* @param rect
* @param phaseNo
* @throws Exception
*/
public void updateFlowModel(JBOTransaction tx,JSONObject rect,String key, Map<String,Map<String,String>> rect_phaseno_type,Map<String,Map<String,String>> rect_phaseno_specialtype, String phaseNo)throws Exception{
BizObjectManager fcManager = JBOFactory.getBizObjectManager(FLOW_CATALOG.CLASS_NAME);
tx.join(fcManager);
BizObjectManager fmManager = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
tx.join(fmManager);
JSONObject text = (JSONObject)rect.getValue("text");
String type = (String)rect.getValue("type");
String phaseName = (String)text.getValue("text");
String phaseType = "";
String initScript = "";
String nodeType ="";
if(phaseNo==null) phaseNo="";
if(!type.equalsIgnoreCase("start")){//开始符号不涉及逻辑,忽略
if(type.equalsIgnoreCase("exclusive")||type.equalsIgnoreCase("join")||type.equalsIgnoreCase("fork")){//分支并行作为特殊符号不需加在flow_model
Map<String,String> rect_type = new HashMap<String,String>();
rect_type.put("nodetype", type);
rect_type.put("phaseno", phaseNo);
rect_phaseno_specialtype.put(key,rect_type);
}else{
Map<String,String> rect_type = new HashMap<String,String>();
rect_type.put("nodetype", type);
rect_type.put("phaseno", phaseNo);
rect_phaseno_type.put(key,rect_type);
if(phaseNo.equals("0010")){
phaseType = "1010";
initScript = "{#UserID}";
nodeType = "TASK";
}else if(phaseNo.equals("1000")){
phaseType = "1040";
initScript = "{\"system\"}";
nodeType = "END";
}else if(phaseNo.equals("8000")){
phaseType = "1050";
initScript = "{\"system\"}";
nodeType = "END";
}else{
phaseType = "1020";
initScript = "toStringArray(\"#PhaseAction\",\",\",\" \",1)";
nodeType = "TASK";
}
JSONObject attr = (JSONObject)rect.getValue("attr");
Integer xcoordinate =(Integer)attr.getValue(0);
Integer ycoordinate = (Integer)attr.getValue(1);
Integer width = (Integer)attr.getValue(2);
Integer height = (Integer)attr.getValue(3);
BizObjectQuery bq = fmManager.createQuery("UPDATE O SET phaseno=:phaseno, phasetype=:phasetype, phasename=:phasename, initscript=:initscript, xcoordinate=:xcoordinate, ycoordinate=:ycoordinate, width=:width, height=:height, nodetype=:nodetype WHERE phaseno=:phaseno and flowno=:flowno");
bq.setParameter("phaseno", phaseNo).setParameter("phasetype", phaseType).setParameter("phasename", phaseName).setParameter("initscript", initScript)
.setParameter("xcoordinate", xcoordinate).setParameter("ycoordinate", ycoordinate).setParameter("width", width).setParameter("height", height).setParameter("nodetype", nodeType).setParameter("flowno",flowNo);
bq.executeUpdate();
}
}
}
/**
* 新建flow_model
* @param tx
* @param rect
* @param phaseNo
* @throws Exception
*/
public void newFlowModel(JBOTransaction tx,JSONObject rect,String key, Map<String,Map<String,String>> rect_phaseno_type,Map<String,Map<String,String>> rect_phaseno_specialtype)throws Exception{
BizObjectManager fcManager = JBOFactory.getBizObjectManager(FLOW_CATALOG.CLASS_NAME);
tx.join(fcManager);
BizObjectManager fmManager = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
tx.join(fmManager);
BizObject newFm = fmManager.newObject();
String type = (String)rect.getValue("type");
JSONObject text = (JSONObject)rect.getValue("text");
String phaseName = (String)text.getValue("text");
String phaseType = "";
String initScript = "";
String nodeType ="";
JSONObject props = (JSONObject)rect.getValue("props");
JSONObject position = (JSONObject)props.getValue("position");
String phaseNo = (String)position.getValue("value");
if(phaseNo==null) phaseNo="";
if(!type.equalsIgnoreCase("start")){//开始符号不涉及逻辑,忽略
if(type.equalsIgnoreCase("exclusive")||type.equalsIgnoreCase("join")||type.equalsIgnoreCase("fork")){//分支并行作为特殊符号不需加在flow_model
Map<String,String> rect_type = new HashMap<String,String>();
rect_type.put("nodetype", type);
rect_type.put("phaseno", phaseNo);
rect_phaseno_specialtype.put(key,rect_type);
}else{
Map<String,String> rect_type = new HashMap<String,String>();
rect_type.put("nodetype", type);
rect_type.put("phaseno", phaseNo);
rect_phaseno_type.put(key,rect_type);
if(phaseNo.equals("0010")){
phaseType = "1010";
initScript = "{#UserID}";
nodeType = "TASK";
}else if(phaseNo.equals("1000")){
phaseType = "1040";
initScript = "{\"system\"}";
nodeType = "END";
}else if(phaseNo.equals("8000")){
phaseType = "1050";
initScript = "{\"system\"}";
nodeType = "END";
}else{
phaseType = "1020";
initScript = "toStringArray(\"#PhaseAction\",\",\",\" \",1)";
nodeType = "TASK";
}
JSONObject attr = (JSONObject)rect.getValue("attr");
Integer xcoordinate =(Integer)attr.getValue(0);
Integer ycoordinate = (Integer)attr.getValue(1);
Integer width = (Integer)attr.getValue(2);
Integer height = (Integer)attr.getValue(3);
int standardtime1 = 0;
int standardtime2 = 0;
if(nodeType.equals("END")){
newFm.setAttributeValue("flowno", flowNo).setAttributeValue("phaseno", phaseNo).setAttributeValue("phasetype", phaseType).setAttributeValue("phasename", phaseName)
.setAttributeValue("initscript", initScript).setAttributeValue("standardtime1", standardtime1).setAttributeValue("standardtime2", standardtime2)
.setAttributeValue("xcoordinate", xcoordinate).setAttributeValue("ycoordinate", ycoordinate).setAttributeValue("width", width).setAttributeValue("height", height).setAttributeValue("nodetype", nodeType).setAttributeValue("version", "1");
}else{
newFm.setAttributeValue("flowno", flowNo).setAttributeValue("phaseno", phaseNo).setAttributeValue("phasetype", phaseType).setAttributeValue("phasename", phaseName)
.setAttributeValue("initscript", initScript).setAttributeValue("standardtime1", standardtime1).setAttributeValue("standardtime2", standardtime2).setAttributeValue("postscript", "#PhaseOpinion1")
.setAttributeValue("xcoordinate", xcoordinate).setAttributeValue("ycoordinate", ycoordinate).setAttributeValue("width", width).setAttributeValue("height", height).setAttributeValue("nodetype", nodeType).setAttributeValue("version", "1");
}
fmManager.saveObject(newFm);
}
}
}
/**
* 获取指定阶段号的坐标
* @param tx
* @param flowNo
* @param flowunid
* @return
* @throws Exception
*/
public Map<String,String> getCoordinate(JBOTransaction tx, String flowNo, String flowunid) throws Exception{
BizObjectManager ftManager = JBOFactory.getBizObjectManager(FLOW_TASK.CLASS_NAME);
BizObjectManager fmManager = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
List<BizObject> fts = ftManager.createQuery("objectno=:objectno and (endtime='' or endtime is null) ").setParameter("objectno",flowunid).getResultList(false);
Map<String,String> results = new HashMap<String,String>();
if(fts.size()>0){
for(BizObject ft:fts){
String phaseNo = ft.getAttribute("phaseno").getString();
BizObject fm = fmManager.createQuery("flowno=:flowno and phaseno=:phaseno ").setParameter("flowno",flowNo).setParameter("phaseno",phaseNo).getSingleResult(false);
String xcoordinate = fm.getAttribute("xcoordinate").getString();
String ycoordinate = fm.getAttribute("ycoordinate").getString();
if(xcoordinate.endsWith(".0")){
xcoordinate=xcoordinate.split("\\.")[0];
}
if(ycoordinate.endsWith(".0")){
ycoordinate=ycoordinate.split("\\.")[0];
}
results.put(phaseNo,xcoordinate+'@'+ycoordinate);
}
}
return results;
}
/**
* 保存流程图校验开始下一步,结束,否决的排序号为固定值
* @param graphJson
* @return
* @throws Exception
*/
public String checkFlowGraph(String graphJson) throws Exception{
String result = "";
JSONObject jsonObj = JSONDecoder.decode(graphJson);
JSONObject states = (JSONObject)jsonObj.getValue("states");
JSONObject paths = (JSONObject)jsonObj.getValue("paths");
Map<String,String> type_rect = new HashMap<String,String>();
Map<String,String> rect_phasno = new HashMap<String,String>();
for(int i=0; i<states.size(); i++){
JSONObject rect = (JSONObject)states.getValue(i);
String name = states.get(i).getName();
String type = (String)rect.getValue("type");
JSONObject props = (JSONObject)rect.getValue("props");
JSONObject position = (JSONObject)props.getValue("position");
String phaseNo = (String)position.getValue("value");
if(type.equalsIgnoreCase("end")){
if(!phaseNo.equals("1000")){
result+="结束步骤排序必须为1000;";
}
}else if(type.equalsIgnoreCase("reject")){
if(!phaseNo.equals("8000")){
result+="否决步骤排序必须为8000;";
}
}else if(type.equalsIgnoreCase("start")){
type_rect.put(type,name);
}
rect_phasno.put(name, phaseNo);
}
for(int i=0; i<paths.size(); i++){
JSONObject path = (JSONObject)paths.getValue(i);
String startRect = type_rect.get("start");
String from = (String)path.getValue("from");
if(from.equalsIgnoreCase(startRect)){
String to = (String)path.getValue("to");
String toPhaseNo = rect_phasno.get(to);
if(!toPhaseNo.equals("0010")){
result+="开始下一步骤排序必须为0010;";
return result;
}else{
return result;
}
}
}
return result;
}
/**
* 获取所有除了开始、结束、否决的坐标
* @param tx
* @param flowNo
* @return
* @throws Exception
*/
public Map<String,String> getCoordinates(JBOTransaction tx, String flowNo) throws Exception{
BizObjectManager fmManager = JBOFactory.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
List<BizObject> fms = fmManager.createQuery("flowno=:flowno and nodetype<>'END' ").setParameter("flowno",flowNo).getResultList(false);
Map<String,String> results = new HashMap<String,String>();
if(fms.size()>0){
for(BizObject fm:fms){
String xcoordinate = fm.getAttribute("xcoordinate").getString();
String ycoordinate = fm.getAttribute("ycoordinate").getString();
if(xcoordinate.endsWith(".0")){
xcoordinate=xcoordinate.split("\\.")[0];
}
if(ycoordinate.endsWith(".0")){
ycoordinate=ycoordinate.split("\\.")[0];
}
results.put(fm.getAttribute("phaseno").getString(),xcoordinate+'@'+ycoordinate);
}
}
return results;
}
}