Authored by qinchao

项目列表挪到后台

  1 +package com.ui.cloud.task;
  2 +
  3 +import com.ui.contants.HttpUriContants;
  4 +import com.ui.http.HttpRestClient;
  5 +import com.ui.model.BaseResponse;
  6 +import com.ui.project.Project;
  7 +import com.ui.project.ProjectOnlineResponse;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.core.ParameterizedTypeReference;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.Map;
  13 +import java.util.stream.Collectors;
  14 +
  15 +/**
  16 + * Created by craig.qin on 2018/6/14.
  17 + * 从后台load出项目列表(java)
  18 + */
  19 +@Component
  20 +public class ProjectsLoader {
  21 + @Autowired
  22 + private HttpRestClient httpClient;
  23 +
  24 + private ProjectOnlineResponse projectOnline;
  25 +
  26 + public ProjectOnlineResponse getProjectOnline(){
  27 + if(projectOnline==null){
  28 + reload();
  29 + }
  30 + return projectOnline;
  31 + }
  32 +
  33 + public ProjectOnlineResponse getProjectOnline(boolean refreshForce){
  34 + if(refreshForce){
  35 + reload();
  36 + }
  37 + return getProjectOnline();
  38 + }
  39 +
  40 + public void reload(){
  41 + ProjectOnlineResponse pro=null;
  42 + BaseResponse<ProjectOnlineResponse> response = httpClient.exchangeForpost(HttpUriContants.LOAD_JAVA_PROJECT_ONLINE, new ParameterizedTypeReference<BaseResponse<ProjectOnlineResponse>>() {
  43 + }, null);
  44 + if(response!=null&&response.getCode()==200){
  45 + pro=response.getData();
  46 + //把list转成map,放到最后
  47 + Map<String,Project> map =pro.getJavaList().stream().collect(Collectors.toMap(Project::getName, Project->Project));
  48 + pro.setJavaMap(map);
  49 + }
  50 + projectOnline=pro;
  51 + }
  52 +}
@@ -236,6 +236,7 @@ public class HttpUriContants { @@ -236,6 +236,7 @@ public class HttpUriContants {
236 /** 236 /**
237 * 工单系统 237 * 工单系统
238 */ 238 */
  239 + public static final String LOAD_JAVA_PROJECT_ONLINE = "/releaseWork/loadJavaProjectOnline";
239 public static final String GET_RELEASEWORKJOBS = "/releaseWork/getReleaseWorkJobs"; 240 public static final String GET_RELEASEWORKJOBS = "/releaseWork/getReleaseWorkJobs";
240 public static final String GET_RELEASEWORKJOB_ID = "/releaseWork/getReleaseWorkJob"; 241 public static final String GET_RELEASEWORKJOB_ID = "/releaseWork/getReleaseWorkJob";
241 public static final String CREATE_RELEASEWORKJOB = "/releaseWork/createReleaseWorkJob"; 242 public static final String CREATE_RELEASEWORKJOB = "/releaseWork/createReleaseWorkJob";
@@ -28,9 +28,6 @@ public class ProjectEnvironment { @@ -28,9 +28,6 @@ public class ProjectEnvironment {
28 28
29 } 29 }
30 30
31 - public static List<String> getJavaEnvList(String project) {  
32 - return ProjectOnline.getJavaProjectByName(project).getSupportEnvList();  
33 - }  
34 31
35 public static String getUrl(String envi){ 32 public static String getUrl(String envi){
36 if(map.containsKey(envi)){ 33 if(map.containsKey(envi)){
1 -package com.ui.project;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.HashMap;  
5 -import java.util.List;  
6 -import java.util.Map;  
7 -import java.util.stream.Collectors;  
8 -  
9 -public class ProjectOnline {  
10 - private final static String JAVA_ENV_QCLOUD_AZ1="qcloud";  
11 - private final static String JAVA_ENV_QCLOUD_AZ2="qcloudaz2";  
12 - private final static String JAVA_ENV_QCLOUD_AZ3="qcloudaz3";  
13 - public final static String JAVA_ENV_ALL=JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_AZ2+","+JAVA_ENV_QCLOUD_AZ3;  
14 -  
15 - ///// 暂时只有media有  
16 - private final static String JAVA_ENV_QCLOUD_ENV_GRAY="qcloud_gray";  
17 -  
18 - private static List<Project> JAVA_LIST = new ArrayList<>();  
19 - private static Map<String,Project> JAVA_MAP = new HashMap<>();  
20 -  
21 - static{  
22 - // java 核心服务  
23 - JAVA_LIST.add(new Project("1","yohobuy-activity","129","yoho30",JAVA_ENV_ALL, "java 核心服务",true));  
24 - JAVA_LIST.add(new Project("1","yohobuy-wechat","248","yoho30",JAVA_ENV_ALL, "java 核心服务",true));  
25 - JAVA_LIST.add(new Project("1","yoho-sns","125","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
26 - JAVA_LIST.add(new Project("1","yoho-erp-gateway","977","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
27 - JAVA_LIST.add(new Project("1","yoho-message","123","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
28 - JAVA_LIST.add(new Project("1","uic","439","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
29 - JAVA_LIST.add(new Project("1","yoho-users","134","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
30 - JAVA_LIST.add(new Project("1","yohobuy-resources","122","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
31 - JAVA_LIST.add(new Project("1","yohobuy-promotion","140","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
32 - JAVA_LIST.add(new Project("1","yohobuy-product","143","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
33 - JAVA_LIST.add(new Project("1","yohobuy-order","124","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
34 - JAVA_LIST.add(new Project("1","yohobuy-brower","131","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
35 - JAVA_LIST.add(new Project("1","yohobuy-bigdata","144","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
36 - JAVA_LIST.add(new Project("1","yoho-gateway","126","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
37 - JAVA_LIST.add(new Project("1","yohobuy-risk","932","yoho30",JAVA_ENV_ALL,"java 核心服务",true));  
38 -  
39 - //只有qcloud : java服务-单中心  
40 - JAVA_LIST.add(new Project("1","yoho-push","137","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
41 - JAVA_LIST.add(new Project("1","cms_push","514","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
42 - JAVA_LIST.add(new Project("1","yoho-social","353","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
43 - JAVA_LIST.add(new Project("1","yohobuy-union","133","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
44 - JAVA_LIST.add(new Project("1","yohobuy-crm","275","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
45 - JAVA_LIST.add(new Project("1","yohobuy-task","138","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
46 - JAVA_LIST.add(new Project("1","yoho-message-controller","684","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
47 - JAVA_LIST.add(new Project("1","yoho-message-sender","685","yoho30",JAVA_ENV_QCLOUD_AZ1,"java服务-单中心",true));  
48 -  
49 -  
50 - //只有灰度环境: 媒体java (灰度)  
51 - JAVA_LIST.add(new Project("1", "yoho-now", "690", "YOHONow",JAVA_ENV_QCLOUD_ENV_GRAY,"媒体java (灰度)",false));  
52 - JAVA_LIST.add(new Project("1","yoho-mars","737","media",JAVA_ENV_QCLOUD_ENV_GRAY,"媒体java (灰度)",false));  
53 - JAVA_LIST.add(new Project("1","yohomars-platform","764","media",JAVA_ENV_QCLOUD_ENV_GRAY,"媒体java (灰度)",false));  
54 - JAVA_LIST.add(new Project("1","yohonow-platform","775","media",JAVA_ENV_QCLOUD_ENV_GRAY,"媒体java (灰度)",false));  
55 -  
56 -  
57 - //JAVA_LIST.add(new Project("1","yoho-cobar","461","yoho30"));  
58 - //JAVA_LIST.add(new Project("1","yohobuy-global","679","yoho30"));  
59 - //JAVA_LIST.add(new Project("1","mars_push","494","yoho30"));  
60 - //JAVA_LIST.add(new Project("1","yoho-union-recomand","789","yoho30"));  
61 -  
62 - //只有qcloud、 qcloud灰度。 线下店java服务  
63 - JAVA_LIST.add(new Project("1","yohobuy-shops","490","yoho30",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_ENV_GRAY,"线下店java服务",false));  
64 - JAVA_LIST.add(new Project("1","yohobuy-portal-gateway","557","yoho30",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_ENV_GRAY,"线下店java服务",false));  
65 - JAVA_LIST.add(new Project("1","yohobuy-extendstore","852","yoho30",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_ENV_GRAY,"线下店java服务",false));  
66 -  
67 -  
68 -  
69 - JAVA_LIST.add(new Project("2","yoho-search-service","12","yoho-search",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_AZ2,"",true));  
70 - JAVA_LIST.add(new Project("2","yoho-search-consumer","8","yoho-search",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_AZ2,"",true));  
71 - JAVA_LIST.add(new Project("2","yoho-search-producer","7","yoho-search",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_AZ2,"",true));  
72 - JAVA_LIST.add(new Project("2","yoho-search-adaptor","13","yoho-search",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_AZ2,"",true));  
73 - JAVA_LIST.add(new Project("2","yohomars-search-service","554","yoho-search",JAVA_ENV_QCLOUD_AZ1,"",true));  
74 -  
75 -  
76 - JAVA_LIST.add(new Project("3","yohobuy-platform","110","platform",JAVA_ENV_QCLOUD_AZ1+","+JAVA_ENV_QCLOUD_ENV_GRAY,"",true));  
77 -  
78 - //把list转成map,放到最后  
79 - JAVA_MAP=JAVA_LIST.stream().collect(Collectors.toMap(Project::getName,Project->Project));  
80 -  
81 - }  
82 -  
83 - public static List<Project> getJavaList() {  
84 - return JAVA_LIST;  
85 - }  
86 -  
87 - public static Project getJavaProjectByName(String projectName) {  
88 - return JAVA_MAP.get(projectName);  
89 - }  
90 -  
91 - /**  
92 - * 中心切换之后,需要  
93 - */  
94 - public static List<Project> getNeedRestartJavaList() {  
95 - return JAVA_LIST.stream().filter(p->p.isNeedRestartAfterSwitch()).collect(Collectors.toList());  
96 - }  
97 -  
98 -}  
  1 +package com.ui.project;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +@Data
  9 +public class ProjectOnlineResponse {
  10 + //java 环境列表串
  11 + private String javaEnvAll;
  12 +
  13 + private List<Project> javaList;
  14 +
  15 + private Map<String,Project> javaMap;
  16 +}
@@ -5,25 +5,28 @@ import com.alibaba.fastjson.JSONArray; @@ -5,25 +5,28 @@ import com.alibaba.fastjson.JSONArray;
5 import com.ui.contants.HttpUriContants; 5 import com.ui.contants.HttpUriContants;
6 import com.ui.http.HttpRestClient; 6 import com.ui.http.HttpRestClient;
7 import com.ui.model.BaseResponse; 7 import com.ui.model.BaseResponse;
8 -import com.ui.model.domain.BuildMessage;  
9 import com.ui.model.domain.DockerProjectModel; 8 import com.ui.model.domain.DockerProjectModel;
10 -import com.ui.model.req.BuildRequest; 9 +import com.ui.model.req.DockerInfoReq;
11 import com.ui.model.req.DockerJenkinsReq; 10 import com.ui.model.req.DockerJenkinsReq;
12 import com.ui.model.req.User; 11 import com.ui.model.req.User;
13 -import com.ui.model.req.*;  
14 import com.ui.project.ProjectEnvironment; 12 import com.ui.project.ProjectEnvironment;
15 -import com.ui.project.ProjectOnline;  
16 import org.apache.commons.lang.StringUtils; 13 import org.apache.commons.lang.StringUtils;
17 import org.slf4j.Logger; 14 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory; 15 import org.slf4j.LoggerFactory;
19 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.ui.Model; 17 import org.springframework.ui.Model;
21 -import org.springframework.web.bind.annotation.*; 18 +import org.springframework.web.bind.annotation.RequestBody;
  19 +import org.springframework.web.bind.annotation.RequestMapping;
  20 +import org.springframework.web.bind.annotation.ResponseBody;
  21 +import org.springframework.web.bind.annotation.RestController;
22 import org.springframework.web.servlet.ModelAndView; 22 import org.springframework.web.servlet.ModelAndView;
23 23
24 import javax.annotation.PostConstruct; 24 import javax.annotation.PostConstruct;
25 import javax.servlet.http.HttpSession; 25 import javax.servlet.http.HttpSession;
26 -import java.util.*; 26 +import java.util.ArrayList;
  27 +import java.util.HashMap;
  28 +import java.util.List;
  29 +import java.util.Map;
27 30
28 31
29 @RestController 32 @RestController
@@ -3,6 +3,7 @@ package com.ui.ctrl; @@ -3,6 +3,7 @@ package com.ui.ctrl;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
  6 +import com.ui.cloud.task.ProjectsLoader;
6 import com.ui.contants.AlarmGroupContants; 7 import com.ui.contants.AlarmGroupContants;
7 import com.ui.contants.HttpUriContants; 8 import com.ui.contants.HttpUriContants;
8 import com.ui.ctrl.util.ReleaseCheck; 9 import com.ui.ctrl.util.ReleaseCheck;
@@ -10,9 +11,10 @@ import com.ui.http.HttpRestClient; @@ -10,9 +11,10 @@ import com.ui.http.HttpRestClient;
10 import com.ui.model.BaseResponse; 11 import com.ui.model.BaseResponse;
11 import com.ui.model.domain.BuildMessage; 12 import com.ui.model.domain.BuildMessage;
12 import com.ui.model.req.*; 13 import com.ui.model.req.*;
  14 +import com.ui.project.Project;
13 import com.ui.project.ProjectEnvironment; 15 import com.ui.project.ProjectEnvironment;
14 import com.ui.project.ProjectMutex; 16 import com.ui.project.ProjectMutex;
15 -import com.ui.project.ProjectOnline; 17 +import com.ui.project.ProjectOnlineResponse;
16 import lombok.Data; 18 import lombok.Data;
17 import org.apache.commons.lang.RandomStringUtils; 19 import org.apache.commons.lang.RandomStringUtils;
18 import org.apache.commons.lang.StringUtils; 20 import org.apache.commons.lang.StringUtils;
@@ -35,11 +37,15 @@ import java.util.*; @@ -35,11 +37,15 @@ import java.util.*;
35 public class ProjectBuildCtrl { 37 public class ProjectBuildCtrl {
36 Logger log = LoggerFactory.getLogger(ProjectBuildCtrl.class); 38 Logger log = LoggerFactory.getLogger(ProjectBuildCtrl.class);
37 //需要特殊处理的项目 39 //需要特殊处理的项目
38 - //private final String PROJECT_NAME_YOHO_SEARCH_SERVICE="yoho-search-service";  
39 private final List<String> lb_proejct_list=new ArrayList<String>() {{ 40 private final List<String> lb_proejct_list=new ArrayList<String>() {{
40 //add("yoho-search-service"); 41 //add("yoho-search-service");
41 //add("uic"); 42 //add("uic");
42 }}; 43 }};
  44 +
  45 +
  46 + @Autowired
  47 + private ProjectsLoader projectsLoader;
  48 +
43 @Autowired 49 @Autowired
44 private HttpRestClient httpRestClient; 50 private HttpRestClient httpRestClient;
45 51
@@ -93,16 +99,17 @@ public class ProjectBuildCtrl { @@ -93,16 +99,17 @@ public class ProjectBuildCtrl {
93 } 99 }
94 100
95 } 101 }
96 - model.addAttribute("environments", Arrays.asList(ProjectOnline.JAVA_ENV_ALL.split(","))); 102 + model.addAttribute("environments", Arrays.asList(projectsLoader.getProjectOnline().getJavaEnvAll().split(",")));
97 ModelAndView mv=new ModelAndView("project/project"); 103 ModelAndView mv=new ModelAndView("project/project");
98 return mv; 104 return mv;
99 } 105 }
100 106
101 @RequestMapping("/toHistory") 107 @RequestMapping("/toHistory")
102 public ModelAndView toHistory(Model model) { 108 public ModelAndView toHistory(Model model) {
103 - model.addAttribute("environments", Arrays.asList(ProjectOnline.JAVA_ENV_ALL.split(","))); 109 + ProjectOnlineResponse projectOnline=projectsLoader.getProjectOnline(true);
  110 + model.addAttribute("environments", Arrays.asList(projectOnline.getJavaEnvAll().split(",")));
104 111
105 - model.addAttribute("projects", ProjectOnline.getJavaList()); 112 + model.addAttribute("projects", projectOnline.getJavaList());
106 113
107 return new ModelAndView("project/history"); 114 return new ModelAndView("project/history");
108 } 115 }
@@ -116,7 +123,7 @@ public class ProjectBuildCtrl { @@ -116,7 +123,7 @@ public class ProjectBuildCtrl {
116 @ResponseBody 123 @ResponseBody
117 public String getProjects() { 124 public String getProjects() {
118 try { 125 try {
119 - return JSONArray.toJSON(ProjectOnline.getJavaList()).toString(); 126 + return JSONArray.toJSON(projectsLoader.getProjectOnline().getJavaList()).toString();
120 } catch (Exception ex) { 127 } catch (Exception ex) {
121 return "failed"; 128 return "failed";
122 } 129 }
@@ -141,9 +148,10 @@ public class ProjectBuildCtrl { @@ -141,9 +148,10 @@ public class ProjectBuildCtrl {
141 } 148 }
142 149
143 public List<String> getJavaProjectEnvList(List<String> projArray) { 150 public List<String> getJavaProjectEnvList(List<String> projArray) {
  151 + Map<String,Project> javaMap=projectsLoader.getProjectOnline().getJavaMap();
144 List<String> envs=new ArrayList<>(); 152 List<String> envs=new ArrayList<>();
145 for(int i=0;i<projArray.size();i++){ 153 for(int i=0;i<projArray.size();i++){
146 - List<String> ls= ProjectEnvironment.getJavaEnvList(projArray.get(i)); 154 + List<String> ls= javaMap.get(projArray.get(i)).getSupportEnvList();
147 if(i==0){ 155 if(i==0){
148 envs.addAll(ls); 156 envs.addAll(ls);
149 }else{ 157 }else{
1 package com.ui.ctrl; 1 package com.ui.ctrl;
2 2
3 -import com.alibaba.fastjson.JSONArray;  
4 import com.google.common.collect.Lists; 3 import com.google.common.collect.Lists;
5 import com.ui.contants.HttpUriContants; 4 import com.ui.contants.HttpUriContants;
6 import com.ui.http.HttpRestClient; 5 import com.ui.http.HttpRestClient;
7 import com.ui.model.BaseResponse; 6 import com.ui.model.BaseResponse;
8 -import com.ui.project.ProjectOnline;  
9 import org.apache.commons.collections.CollectionUtils; 7 import org.apache.commons.collections.CollectionUtils;
10 import org.apache.commons.lang.StringUtils; 8 import org.apache.commons.lang.StringUtils;
11 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -18,7 +16,10 @@ import org.springframework.web.bind.annotation.RequestMethod; @@ -18,7 +16,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
18 import org.springframework.web.bind.annotation.ResponseBody; 16 import org.springframework.web.bind.annotation.ResponseBody;
19 import org.springframework.web.servlet.ModelAndView; 17 import org.springframework.web.servlet.ModelAndView;
20 18
21 -import java.util.*; 19 +import java.util.ArrayList;
  20 +import java.util.HashMap;
  21 +import java.util.List;
  22 +import java.util.Map;
22 23
23 /** 24 /**
24 * 限流调整 25 * 限流调整
@@ -3,13 +3,17 @@ package com.ui.ctrl; @@ -3,13 +3,17 @@ package com.ui.ctrl;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
  6 +import com.ui.cloud.task.ProjectsLoader;
6 import com.ui.contants.HttpUriContants; 7 import com.ui.contants.HttpUriContants;
7 import com.ui.contants.ProjectConstant; 8 import com.ui.contants.ProjectConstant;
8 import com.ui.http.HttpRestClient; 9 import com.ui.http.HttpRestClient;
9 import com.ui.model.BaseResponse; 10 import com.ui.model.BaseResponse;
10 import com.ui.model.domain.DockerProjectModel; 11 import com.ui.model.domain.DockerProjectModel;
11 import com.ui.model.req.*; 12 import com.ui.model.req.*;
12 -import com.ui.project.*; 13 +import com.ui.project.Platform;
  14 +import com.ui.project.Project;
  15 +import com.ui.project.ProjectEnvironment;
  16 +import com.ui.project.ProjectMutex;
13 import org.apache.commons.lang.StringUtils; 17 import org.apache.commons.lang.StringUtils;
14 import org.slf4j.Logger; 18 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory; 19 import org.slf4j.LoggerFactory;
@@ -19,7 +23,6 @@ import org.springframework.stereotype.Controller; @@ -19,7 +23,6 @@ import org.springframework.stereotype.Controller;
19 import org.springframework.ui.Model; 23 import org.springframework.ui.Model;
20 import org.springframework.web.bind.annotation.RequestBody; 24 import org.springframework.web.bind.annotation.RequestBody;
21 import org.springframework.web.bind.annotation.RequestMapping; 25 import org.springframework.web.bind.annotation.RequestMapping;
22 -import org.springframework.web.bind.annotation.RequestMethod;  
23 import org.springframework.web.bind.annotation.ResponseBody; 26 import org.springframework.web.bind.annotation.ResponseBody;
24 import org.springframework.web.servlet.ModelAndView; 27 import org.springframework.web.servlet.ModelAndView;
25 28
@@ -46,6 +49,9 @@ public class WorkSystemCtrl { @@ -46,6 +49,9 @@ public class WorkSystemCtrl {
46 ProjectBuildCtrl projectBuildCtrl; 49 ProjectBuildCtrl projectBuildCtrl;
47 50
48 @Autowired 51 @Autowired
  52 + private ProjectsLoader projectsLoader;
  53 +
  54 + @Autowired
49 HttpRestClient httpRestClient; 55 HttpRestClient httpRestClient;
50 56
51 @RequestMapping("/toAddWork") 57 @RequestMapping("/toAddWork")
@@ -110,7 +116,7 @@ public class WorkSystemCtrl { @@ -110,7 +116,7 @@ public class WorkSystemCtrl {
110 @ResponseBody 116 @ResponseBody
111 public List<Project> getProjectsByPlatform(String platform,String projectType) { 117 public List<Project> getProjectsByPlatform(String platform,String projectType) {
112 if (Platform.JAVA.equals(platform)) { 118 if (Platform.JAVA.equals(platform)) {
113 - return ProjectOnline.getJavaList(); 119 + return projectsLoader.getProjectOnline().getJavaList();
114 } else if (Platform.PHP.equals(platform)) { 120 } else if (Platform.PHP.equals(platform)) {
115 String result = httpRestClient.get("http://"+ ProjectConstant.DEPLOY_IP+":8883/php/getProjects", String.class, null); 121 String result = httpRestClient.get("http://"+ ProjectConstant.DEPLOY_IP+":8883/php/getProjects", String.class, null);
116 return JSON.parseObject(result,List.class); 122 return JSON.parseObject(result,List.class);
@@ -3,22 +3,20 @@ package com.ui.ctrl.app; @@ -3,22 +3,20 @@ package com.ui.ctrl.app;
3 import com.alibaba.fastjson.JSONArray; 3 import com.alibaba.fastjson.JSONArray;
4 import com.ui.app.common.ErrorCode; 4 import com.ui.app.common.ErrorCode;
5 import com.ui.app.req.*; 5 import com.ui.app.req.*;
6 -import com.ui.app.resp.NodeBuildResp;  
7 -import com.ui.app.resp.NodeBuildState;  
8 -import com.ui.contants.HttpUriContants; 6 +import com.ui.cloud.task.ProjectsLoader;
9 import com.ui.http.HttpRestClient; 7 import com.ui.http.HttpRestClient;
10 import com.ui.model.BaseResponse; 8 import com.ui.model.BaseResponse;
11 import com.ui.model.domain.BuildMessage; 9 import com.ui.model.domain.BuildMessage;
12 import com.ui.model.req.BuildRequest; 10 import com.ui.model.req.BuildRequest;
13 import com.ui.project.Project; 11 import com.ui.project.Project;
14 import com.ui.project.ProjectEnvironment; 12 import com.ui.project.ProjectEnvironment;
15 -import com.ui.project.ProjectOnline;  
16 import org.apache.commons.lang.StringUtils; 13 import org.apache.commons.lang.StringUtils;
17 -import org.slf4j.Logger;  
18 -import org.slf4j.LoggerFactory;  
19 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.core.ParameterizedTypeReference; 15 import org.springframework.core.ParameterizedTypeReference;
21 -import org.springframework.web.bind.annotation.*; 16 +import org.springframework.web.bind.annotation.RequestBody;
  17 +import org.springframework.web.bind.annotation.RequestMapping;
  18 +import org.springframework.web.bind.annotation.RequestMethod;
  19 +import org.springframework.web.bind.annotation.RestController;
22 20
23 import java.util.HashMap; 21 import java.util.HashMap;
24 import java.util.LinkedList; 22 import java.util.LinkedList;
@@ -38,6 +36,9 @@ public class AppProjectBuildCtrl { @@ -38,6 +36,9 @@ public class AppProjectBuildCtrl {
38 @Autowired 36 @Autowired
39 private HttpRestClient httpClient; 37 private HttpRestClient httpClient;
40 38
  39 + @Autowired
  40 + private ProjectsLoader projectsLoader;
  41 +
41 /** 42 /**
42 * 获取所有项目 43 * 获取所有项目
43 * 44 *
@@ -46,9 +47,9 @@ public class AppProjectBuildCtrl { @@ -46,9 +47,9 @@ public class AppProjectBuildCtrl {
46 @RequestMapping(value = "app_getbuildprojectlist", method = RequestMethod.POST) 47 @RequestMapping(value = "app_getbuildprojectlist", method = RequestMethod.POST)
47 public BaseResponse getProjects(@RequestBody AppBaseReq appBaseReq) { 48 public BaseResponse getProjects(@RequestBody AppBaseReq appBaseReq) {
48 BaseResponse baseResponse = new BaseResponse(); 49 BaseResponse baseResponse = new BaseResponse();
49 - baseResponse.setData(ProjectOnline.getJavaList()); 50 + //baseResponse.setData(projectsLoader.getProjectOnline().getJavaList());
50 List<String> stringList = new LinkedList<>(); 51 List<String> stringList = new LinkedList<>();
51 - for (Project project : ProjectOnline.getJavaList()) { 52 + for (Project project : projectsLoader.getProjectOnline().getJavaList()) {
52 stringList.add(project.getName()); 53 stringList.add(project.getName());
53 } 54 }
54 baseResponse.setData(stringList); 55 baseResponse.setData(stringList);
1 package com.ui.ctrl.app; 1 package com.ui.ctrl.app;
2 2
3 -import com.alibaba.fastjson.JSONArray;  
4 import com.ui.User.UserAuthLocal; 3 import com.ui.User.UserAuthLocal;
5 import com.ui.app.common.ErrorCode; 4 import com.ui.app.common.ErrorCode;
6 -import com.ui.app.req.*; 5 +import com.ui.app.req.AppBaseReq;
  6 +import com.ui.app.req.HandleWorkJob;
  7 +import com.ui.app.req.WorkJob;
7 import com.ui.contants.HttpUriContants; 8 import com.ui.contants.HttpUriContants;
8 import com.ui.http.HttpRestClient; 9 import com.ui.http.HttpRestClient;
9 import com.ui.model.BaseResponse; 10 import com.ui.model.BaseResponse;
10 -import com.ui.model.domain.BuildMessage;  
11 import com.ui.model.rep.PageResponse; 11 import com.ui.model.rep.PageResponse;
12 -import com.ui.model.req.*;  
13 -import com.ui.project.Project;  
14 -import com.ui.project.ProjectEnvironment;  
15 -import com.ui.project.ProjectOnline; 12 +import com.ui.model.req.HandledJob;
  13 +import com.ui.model.req.PendingJob;
  14 +import com.ui.model.req.User;
  15 +import com.ui.model.req.WorkSystemReq;
16 import org.apache.commons.lang.StringUtils; 16 import org.apache.commons.lang.StringUtils;
17 import org.apache.commons.lang.math.NumberUtils; 17 import org.apache.commons.lang.math.NumberUtils;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,12 +21,6 @@ import org.springframework.web.bind.annotation.RequestBody; @@ -21,12 +21,6 @@ import org.springframework.web.bind.annotation.RequestBody;
21 import org.springframework.web.bind.annotation.RequestMapping; 21 import org.springframework.web.bind.annotation.RequestMapping;
22 import org.springframework.web.bind.annotation.RequestMethod; 22 import org.springframework.web.bind.annotation.RequestMethod;
23 import org.springframework.web.bind.annotation.RestController; 23 import org.springframework.web.bind.annotation.RestController;
24 -import org.springframework.web.servlet.ModelAndView;  
25 -  
26 -import java.util.HashMap;  
27 -import java.util.LinkedList;  
28 -import java.util.List;  
29 -import java.util.Map;  
30 24
31 25
32 /** 26 /**