zoukankan      html  css  js  c++  java
  • 去哪网实习总结:递归构建“流程运行顺序”的XML文件(JavaWeb)

    本来是以做数据挖掘的目的进去哪网的,结构却成了系统开发。。。

    只是还是比較认真的做了三个月,老师非常认同我的工作态度和成果。。

    实习立即就要结束了,总结一下几点之前没有注意过的变成习惯和问题。分享给大家。


    同一时候打个广告:去哪网内审部招JavaWeb开发实习生,时间很自由。每周一天、周六周日甚至都能够,时间充裕的小伙伴给我留言啊,挣个零花钱,还能长点经验。

    。。。(保研的、想工作的大四狗最合适只是了。。。



    map的结构为(thisProcessID, thisProcessType;nextProcessID1,nextProcessType1;...;nextProcessIDk,nextProcessTypek;),假设processType部位start、end、split、join,则type和id同样。。。。


    跑一下代码就知道是怎么回事了。直接上代码:

    <span style="white-space:pre">	</span>public String XMLhead = "";	
    	
    	@SuppressWarnings({ "rawtypes", "unchecked" })
    	public void formXMLfile(Map nodeMap){
    		/*穿行没问题
    		nodeMap.put("1", "start;2,2");
    		nodeMap.put("2", "2;3,3");
    		nodeMap.put("3", "3;4,end");
    		nodeMap.put("4", "end");
    		*/
    		/* 简单并行没问题,但须要去重处理
    		nodeMap.put("1", "start;2,split");
    		nodeMap.put("2", "split;3,3;4,4");
    		nodeMap.put("3", "3;5,join");
    		nodeMap.put("4", "4;5,join");
    		nodeMap.put("5", "join;6,end");
    		nodeMap.put("6", "end");
    		*/
    		
    		nodeMap.put("1", "start;2,split");
    		nodeMap.put("2", "split;3,3;4,split;5,5");
    		nodeMap.put("3", "3;6,6");
    		nodeMap.put("4", "split;7,7;8,8");
    		nodeMap.put("5", "5;9,join");
    		nodeMap.put("6", "6;9,join");
    		nodeMap.put("7", "7;10,join");
    		nodeMap.put("8", "8;10,join");
    		nodeMap.put("9", "join;11,end");
    		nodeMap.put("10", "join;9,join");
    		nodeMap.put("11", "end");
    		/*简单并行没问题。但须要去重处理
    		nodeMap.put("1", "start;2,split");
    		nodeMap.put("2", "split;3,3;4,4");
    		nodeMap.put("3", "3;5,join");
    		nodeMap.put("4", "4;5,join");
    		nodeMap.put("5", "join;6,split");
    		nodeMap.put("6", "split;7,7;8,8");
    		nodeMap.put("7", "7;9,join");
    		nodeMap.put("8", "8;9,join");
    		nodeMap.put("9", "join;10,end");
    		nodeMap.put("10", "end");
    		*/
    		XMLhead = "<?xml version="1.0" encoding="UTF-8"?>"+"
    ";
    		XMLhead += "<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">"+"
    ";
    		String XMLtail = "</definitions>";
    		XMLhead += "<process id="processID" name="processNAME" isExecutable="true">"+"
    ";
    		XMLtail = "</process>
    "+XMLtail;
    		
    		String this_id = "1";//start
    		String this_type = "start";
    		RECUformXMLfile(nodeMap, this_id, this_type);
    		String XMLfile = XMLhead + XMLtail;
    		
    		//去重
    		String[] temp = XMLfile.split("
    ");
    		List<String> list = new LinkedList<String>();  
            for(int i = 0; i < temp.length; i++) {  
                if(!list.contains(temp[i])) {
                    list.add(temp[i]);//改为写文件
                    System.out.println(temp[i]);
                }
            }
    	}
    	
    	@SuppressWarnings("rawtypes")
    	public void RECUformXMLfile(Map nodeMap, String this_id, String this_type){
    		if(this_type.equals("start")){//start
    			String[] toNodes = nodeMap.get(this_id).toString().split(";");
    			String next_id = toNodes[1].split(",")[0];
    			String next_type = toNodes[1].split(",")[1];
    			if(next_type.equals("split")){
    				XMLhead += "<startEvent id="startevent1" name="Start"></startEvent>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="startevent1" targetRef="gateway_"+next_id+""></sequenceFlow>"+"
    ";
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			} else if(next_type.equals("end_start_join")){//不可能
    				
    			} else{//task
    				XMLhead += "<startEvent id="startevent1" name="Start"></startEvent>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="startevent1" targetRef="task_"+next_id+""></sequenceFlow>"+"
    ";
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			}
    		} else if(this_type.equals("split")){//split
    			XMLhead += "<parallelGateway id="gateway_"+this_id+"" name="Parallel Gateway"></parallelGateway>"+"
    ";
    			String[] toNodes = nodeMap.get(this_id).toString().split(";");
    			for(int i=1;i<toNodes.length;i++){
    				String next_id = toNodes[i].split(",")[0];
    				String next_type = toNodes[i].split(",")[1];
    				if(next_type.equals("split")){
    					XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="gateway_"+this_id+"" targetRef="gateway_"+next_id+""></sequenceFlow>"+"
    ";
    					RECUformXMLfile(nodeMap, next_id, next_type);
    				} else if(next_type.equals("end_start_join")){//不可能
    					
    				} else{//task
    					XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="gateway_"+this_id+"" targetRef="task_"+next_id+""></sequenceFlow>"+"
    ";
    					RECUformXMLfile(nodeMap, next_id, next_type);
    				}
    			}
    		} else if(this_type.equals("end")){//不会出现,接下来的两个推断分支可能的next_type==end时,都已经处理
    			
    		} else if(this_type.equals("join")){//join,join和task,两者处理逻辑一样,除了一个用gateWay。一个用task
    			String[] toNodes = nodeMap.get(this_id).toString().split(";");
    			String next_id = toNodes[1].split(",")[0];
    			String next_type = toNodes[1].split(",")[1];
    			if(next_type.equals("end")){
    				XMLhead += "<parallelGateway id="gateway_"+this_id+"" name="Parallel Gateway"></parallelGateway>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="gateway_"+this_id+"" targetRef="endevent1"></sequenceFlow>"+"
    ";
    				XMLhead += "<endEvent id="endevent1" name="End"></endEvent>"+"
    ";
    				return ;
    			} else if(next_type.equals("start")){//不可能
    				
    			} else if(next_type.equals("split")){
    				XMLhead += "<parallelGateway id="gateway_"+this_id+"" name="Parallel Gateway"></parallelGateway>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="gateway_"+this_id+"" targetRef="gateway_"+next_id+""></sequenceFlow>"+"
    ";
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			} else if(next_type.equals("join")){
    				XMLhead += "<parallelGateway id="gateway_"+this_id+"" name="Parallel Gateway"></parallelGateway>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="gateway_"+this_id+"" targetRef="gateway_"+next_id+""></sequenceFlow>"+"
    ";
    				return ;
    			} else{//task
    				XMLhead += "<parallelGateway id="gateway_"+this_id+"" name="Parallel Gateway"></parallelGateway>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="gateway_"+this_id+"" targetRef="task_"+next_id+""></sequenceFlow>"+"
    ";
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			}
    		} else{//task,task和join。两者处理逻辑一样。除了一个用gateWay。一个用task
    			String[] toNodes = nodeMap.get(this_id).toString().split(";");
    			String next_id = toNodes[1].split(",")[0];
    			String next_type = toNodes[1].split(",")[1];
    			if(next_type.equals("end")){
    				XMLhead += "<userTask id="task_"+this_id+"" name=""+this_id+""></userTask>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="task_"+this_id+"" targetRef="endevent1"></sequenceFlow>"+"
    ";
    				XMLhead += "<endEvent id="endevent1" name="End"></endEvent>"+"
    ";
    				return ;
    			} else if(next_type.equals("start")){//不可能
    				
    			} else if(next_type.equals("split")){
    				XMLhead += "<userTask id="task_"+this_id+"" name=""+this_id+""></userTask>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="task_"+this_id+"" targetRef="gateway_"+next_id+""></sequenceFlow>"+"
    ";
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			} else if(next_type.equals("join")){
    				XMLhead += "<userTask id="task_"+this_id+"" name=""+this_id+""></userTask>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="task_"+this_id+"" targetRef="gateway_"+next_id+""></sequenceFlow>"+"
    ";
    				//return ;
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			} else{//task
    				XMLhead += "<userTask id="task_"+this_id+"" name=""+this_id+""></userTask>"+"
    ";
    				XMLhead += "<sequenceFlow id="flow_"+this_id+"" sourceRef="task_"+this_id+"" targetRef="task_"+next_id+""></sequenceFlow>"+"
    ";
    				RECUformXMLfile(nodeMap, next_id, next_type);
    			}
    		}
    	}


  • 相关阅读:
    ES6扩展
    javascript当中prototype用法
    三列浮动中间宽度自适应
    介绍axios和promise
    JS高级---实例对象和构造函数之间的关系
    JS-数组常用方法整理
    原生JS轮播图
    JavaScript 开胃菜
    JS高级---遍历DOM树
    JS高级---正则表达式练习身份证号码
  • 原文地址:https://www.cnblogs.com/lytwajue/p/7289979.html
Copyright © 2011-2022 走看看