gaodd 1 年之前
父節點
當前提交
0c1b42570c

+ 7 - 0
src/main/java/com/chinaitop/depot/DepotMonitorApplication.java

@@ -6,6 +6,8 @@ import org.springframework.boot.SpringApplication;
6 6
 import org.springframework.boot.autoconfigure.SpringBootApplication;
7 7
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
8 8
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
9
+import org.springframework.context.annotation.Bean;
10
+import org.springframework.web.client.RestTemplate;
9 11
  
10 12
 @EnableEurekaClient
11 13
 @EnableDiscoveryClient
@@ -16,4 +18,9 @@ public class DepotMonitorApplication {
16 18
 	public static void main(String[] args) {
17 19
 		SpringApplication.run(DepotMonitorApplication.class, args);
18 20
 	}
21
+	
22
+	@Bean
23
+    public RestTemplate restTemplate() {
24
+        return new RestTemplate();
25
+    }
19 26
 }

+ 8 - 9
src/main/java/com/chinaitop/depot/supervise/service/impl/depotStyleServiceImpl.java

@@ -7,6 +7,7 @@ import com.chinaitop.depot.supervise.service.depotStyleService;
7 7
 import com.fasterxml.jackson.core.JsonProcessingException;
8 8
 import com.fasterxml.jackson.databind.ObjectMapper;
9 9
 
10
+import org.springframework.beans.factory.annotation.Value;
10 11
 import org.springframework.context.annotation.Bean;
11 12
 import org.springframework.stereotype.Service;
12 13
 import org.springframework.util.LinkedMultiValueMap;
@@ -25,12 +26,10 @@ public class depotStyleServiceImpl implements depotStyleService {
25 26
     
26 27
     @Resource
27 28
     private RestTemplate restTemplate;
28
-
29
-    @Bean
30
-    public RestTemplate restTemplate() {
31
-        return new RestTemplate();
32
-    }
33 29
     
30
+    @Value("${jsgjjsjUrl}")
31
+    private String jsgjjsjUrl;
32
+
34 33
 
35 34
     @Override
36 35
     public List<Map<String,Object>> getCameraPoint(Map<String,Object> map) {
@@ -146,7 +145,7 @@ public class depotStyleServiceImpl implements depotStyleService {
146 145
    		/**
147 146
             * restTemplate调用
148 147
             */
149
-           String url = "http://localhost:9022/recPublish/sendMessage";//
148
+          // String url = "http://localhost:9022/recPublish/sendMessage";//
150 149
            // 发送post请求,并打印结果,以String类型接收响应结果JSON字符串
151 150
            MultiValueMap<String, Object> sendMap = new LinkedMultiValueMap<>();
152 151
    		//Map<String, Object>  sendMap = new HashMap<String, Object>();
@@ -162,7 +161,7 @@ public class depotStyleServiceImpl implements depotStyleService {
162 161
    		sendMap.add("tableName", tableName);
163 162
    		sendMap.add("orgId",orgId);
164 163
 
165
-          String result = (String) restTemplate.postForObject(url, sendMap, String.class);
164
+          String result = (String) restTemplate.postForObject(jsgjjsjUrl, sendMap, String.class);
166 165
        }
167 166
 
168 167
 
@@ -198,7 +197,7 @@ public class depotStyleServiceImpl implements depotStyleService {
198 197
    		/**
199 198
             * restTemplate调用
200 199
             */
201
-           String url = "http://localhost:9022/recPublish/sendMessage";//
200
+           //String url = "http://localhost:9022/recPublish/sendMessage";//
202 201
            // 发送post请求,并打印结果,以String类型接收响应结果JSON字符串
203 202
            MultiValueMap<String, Object> sendMap = new LinkedMultiValueMap<>();
204 203
    		//Map<String, Object>  sendMap = new HashMap<String, Object>();
@@ -214,7 +213,7 @@ public class depotStyleServiceImpl implements depotStyleService {
214 213
    		sendMap.add("tableName", tableName);
215 214
    		sendMap.add("orgId",orgId);
216 215
 
217
-          String result = (String) restTemplate.postForObject(url, sendMap, String.class);
216
+          String result = (String) restTemplate.postForObject(jsgjjsjUrl, sendMap, String.class);
218 217
        }
219 218
        
220 219
 }

+ 2 - 0
src/main/resources/bootstrap-dev.yml

@@ -51,3 +51,5 @@ sendMessage:
51 51
   com: COM4
52 52
   modem: modem.com4
53 53
 windows-path: /home/depot/monitorzd/
54
+
55
+jsgjjsjUrl: http://localhost:9022/recPublish/sendMessage

+ 3 - 0
src/main/resources/bootstrap-prod.yml

@@ -51,3 +51,6 @@ sendMessage:
51 51
   com: COM4
52 52
   modem: modem.com4
53 53
 windows-path: /home/depot/monitorzd/
54
+
55
+jsgjjsjUrl: http://localhost:9022/recPublish/sendMessage
56
+