List<Map<String,String>> 结构 拓扑图 点 线 去重

package com.yonyougov.dep.server.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yonyougov.bd.framework.annotation.AddOrModify;
import com.yonyougov.bd.framework.cron.CronModel;
import com.yonyougov.bd.framework.utils.UtilTools;
import com.yonyougov.dep.common.bean.ExchangeParam;
import com.yonyougov.dep.common.bean.ExchangeParam.Consumer;
import com.yonyougov.dep.common.bean.ExchangeParam.Exchange;
import com.yonyougov.dep.common.constants.DepConstant;
import com.yonyougov.dep.common.enums.AppIdentityTypeEnum;
import com.yonyougov.dep.common.enums.ExchangeStatusEnum;
import com.yonyougov.dep.common.enums.NodeTypeEnum;
import com.yonyougov.dep.common.service.IDepAgentService;
import com.yonyougov.dep.common.service.IDepApplicationService;
import com.yonyougov.dep.common.service.IDepConHistoryService;
import com.yonyougov.dep.common.service.IDepConsumerService;
import com.yonyougov.dep.common.service.IDepExchangeService;
import com.yonyougov.dep.common.service.IDepLocationService;
import com.yonyougov.dep.common.service.IDepProHistoryService;
import com.yonyougov.dep.common.service.IDepRulesService;
import com.yonyougov.dep.common.service.IDepTopologyService;
import com.yonyougov.dep.common.vo.DepAgentVO;
import com.yonyougov.dep.common.vo.DepApplicationVO;
import com.yonyougov.dep.common.vo.DepConHistoryVO;
import com.yonyougov.dep.common.vo.DepConsumerVO;
import com.yonyougov.dep.common.vo.DepExchangeVO;
import com.yonyougov.dep.common.vo.DepLocationVO;
import com.yonyougov.dep.common.vo.DepRulesVO;
import com.yonyougov.dep.common.vo.DepTopologyVO;
import com.yonyougov.dep.server.bean.NodeLocation;
import com.yonyougov.dep.server.bean.TopologyParamList;
import com.yonyougov.dep.server.service.IDepManagerService;
import com.yonyougov.dep.server.utils.PropertiesContext;

import lombok.Data;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 *
 * @author wenxing
 *
 */
@RestController
@RequestMapping(value="/api/v1/exchange")
public class ExchangeController {
    
    @Autowired
    private IDepConsumerService consumerService;
    
    @Autowired
    private IDepExchangeService exchangeService;
    
    @Autowired
    private IDepAgentService agentService;
    
    @Autowired
    private IDepApplicationService appService;
    
    @Autowired
    private IDepRulesService ruleService;
    
    @Autowired
    private IDepProHistoryService proHistoryService;
    
    @Autowired
    private IDepConHistoryService conHistoryService;
    
    @Autowired
    private IDepManagerService managerService;
    
    @Autowired
    private IDepTopologyService topologyService;
    
    @Autowired
    private IDepLocationService locationService;
    
    @RequestMapping(path="consumerInfo",method=RequestMethod.GET)
    public void consumerInfo() {
        DepConsumerVO con1 = new DepConsumerVO();
        con1.setStatus("ok11");
        //con1.setPk("a613caaa-e5f3-4de1-b26c-49446730defd");
        con1.setPkExchange("a613caaa-e5f3-4de1-b26c-49446730defd");
        con1.setPkApp("a613caaa-e5f3-4de1-b26c-49446730defd");
        con1.setPkAgent("a613caaa-e5f3-4de1-b26c-49446730defd");
        con1.setTopic("test11");
        DepConsumerVO con2 = new DepConsumerVO();
        //con2.setPk("a613caaa-e5f3-4de1-b26c-49446730deff");
        con2.setStatus("ok22");
        con2.setPkExchange("a613caaa-e5f3-4de1-b26c-49446730defd");
        con2.setPkApp("a613caaa-e5f3-4de1-b26c-49446730defd");
        con2.setPkAgent("a613caaa-e5f3-4de1-b26c-49446730defd");
        con2.setTopic("test22");
        DepConsumerVO con3 = new DepConsumerVO();
        //con3.setPk("a613caaa-we23-4de1-b26c-49446730defe");
        con3.setStatus("ok11");
        con3.setPkExchange("a613caaa-e5f3-4de1-b26c-49446730defd");
        con3.setPkApp("a613caaa-e5f3-4de1-b26c-49446730defd");
        con3.setPkAgent("a613caaa-e5f3-4de1-b26c-49446730defd");
        con3.setTopic("test11");
        
        DepExchangeVO exchangeVO = new DepExchangeVO();
        //exchangeVO.setPk("a613caaa-e5f3-4de1-b26c-49446730defd");
        exchangeVO.setStatus("test1");
        exchangeVO.setName("jeowf");
        //exchangeVO.setPkProapp("a613caaa-e5f3-4de1-b26c-49446730defd");
        exchangeVO.setPkProagent("a613caaa-e5f3-4de1-b26c-49446730defd");
//        DepConsumerVO[] cons = new DepConsumerVO[3];
//        cons[0] = con1;
//        cons[1] = con2;
//        cons[2] = con3;        
//        consumerService.addBatchConsumers(cons,true);
//        consumerService.addConsumer(con1);
//        exchangeService.addExchange(exchangeVO);
        //exchangeService.test();
    }
    
    /**
     * 获取所有流程
     * @return
     */
    @RequestMapping(path="getAllExchanges",method=RequestMethod.GET)
    public Object getAllExchanges() {
        return exchangeService.getAllExchanges();
    }
    
    /**
     * 获取所有流程拓扑图
     * @return
     */
    @RequestMapping(path="getAllExchangeGraph",method=RequestMethod.GET)
    public Object getAllExchangeGraph(String type) {
        return getExchangeGraphsByExchangeList("a0a1a1d2-4578-477a-ae6a-5c9f4f66a95c",exchangeService.getAllExchanges(),"0");
    }
    
    /**
     * 根据节点获取流程拓扑图
     * @return
     */
    @RequestMapping(path="getAllExchangeGraphByPkAgent",method=RequestMethod.GET)
    public Object getAllExchangeGraphByPkAgent(String pkAgent,String type) {
        List<DepExchangeVO> exchangeList = exchangeService.getExchangesByPkAgent(pkAgent);
        return getExchangeGraphsByExchangeList(pkAgent,exchangeList,"2");
    }
    
    //获得多个流程图
    public Map<String,Object> getExchangeGraphsByExchangeList(String pkGraph,List<DepExchangeVO> exchangeList,String type){
        Map<String,Object> resultMap = new HashMap<String,Object>();
        Map<String,Object> nodeMap = new HashMap<String,Object>();
        
        List<Object> finalNodeList = new ArrayList<Object>();
        List<Map<String,String>> finalLineList = new ArrayList<Map<String,String>>();
        for(DepExchangeVO exchangeVo : exchangeList){
            
            if(type.equals("0")){
                //合并节点map
                nodeMap.putAll(getNodeListByPkExchange("a0a1a1d2-4578-477a-ae6a-5c9f4f66a95c",exchangeVo.getPkExchange(),type));
            }
            if(type.equals("2")){
                //合并节点map
                nodeMap.putAll(getNodeListByPkExchange(pkGraph,exchangeVo.getPkExchange(),t
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值