Przeglądaj źródła

云南配置修改

gaodandan 6 lat temu
rodzic
commit
b7d6969607

+ 144 - 0
src/main/java/com/chinaitop/depot/utils/DataSynchronization.java

@@ -0,0 +1,144 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import java.text.SimpleDateFormat;
4
+/*import java.util.Date;
5
+import java.util.HashMap;
6
+import java.util.List;
7
+import java.util.Map;
8
+
9
+import org.apache.commons.lang.ObjectUtils;
10
+
11
+import com.chinaitop.depot.business.model.BusinessContract;
12
+import com.google.gson.Gson;*/
13
+
14
+public class DataSynchronization {
15
+	private static String urls = "http://192.168.123.123:14100";
16
+	private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
17
+	
18
+	/**
19
+	 * 查询合同信息
20
+	 *//*
21
+	public static List queryContractInfo() {
22
+		Gson gson = new Gson();
23
+		Map<String,Object> params = new HashMap<String,Object>();
24
+		//json对象转换成json字符串
25
+		String jsonStr = gson.toJson(params);
26
+		String result = HttpClientUtil.doPostJson(urls+"/contractList", jsonStr);
27
+		System.out.print(result);
28
+		params = gson.fromJson(result, Map.class);
29
+		List list = (List)params.get("data");
30
+		return list;
31
+	}
32
+	
33
+	*//**
34
+	 * 合同信息同步---插入
35
+	 *//*
36
+	public static void businessContractSynchronizationInsert(BusinessContract contract) {
37
+		Gson gson = new Gson();
38
+		Map<String,Object> params = new HashMap<String,Object>();
39
+		params.put("createDate",contract.getCreateTime()==null?"":format.format(contract.getCreateTime()));
40
+		params.put("creator",contract.getCreater());
41
+		params.put("creatorCode","");
42
+		params.put("htbh",contract.getContractNumber());
43
+		params.put("htbzje",0);
44
+		params.put("htbzxx",contract.getRemark());
45
+		params.put("htjctj",contract.getDissolutionConditions());
46
+		params.put("htmc",contract.getContractTitle());
47
+		params.put("htqsdd","");
48
+		params.put("htqssj",contract.getSigningTime()==null?"":format.format(contract.getSigningTime()));
49
+		params.put("htsxjzsj",contract.getDisableDate()==null?"":format.format(contract.getDisableDate()));
50
+		params.put("htsxkssj",contract.getEnableDate()==null?"":format.format(contract.getEnableDate()));
51
+		params.put("htwyzr",contract.getBreachLiability());
52
+		params.put("htxxid",contract.getId());
53
+		params.put("htzdj",0);
54
+		params.put("htzje",contract.getMoneyQuantity());
55
+		params.put("htzsl",contract.getGrainQuantity());
56
+		params.put("jfkdbm",0);
57
+		params.put("jfkdmc",0);
58
+		params.put("jfkhh",0);
59
+		params.put("jflxdh",0);
60
+		params.put("jfqydm",0);
61
+		params.put("jfqymc",0);
62
+		params.put("jfqyr",0);
63
+		params.put("jfqzzt",0);
64
+		params.put("jfyhzh",0);
65
+		params.put("jhjssj",0);
66
+		params.put("jhkssj",0);
67
+		params.put("lsdjbm",0);
68
+		params.put("lsdjmc",0);
69
+		params.put("lspzbm",0);
70
+		params.put("lspzhm",contract.getPlanNumber());
71
+		params.put("lspzid",contract.getPlanBid());
72
+		params.put("lspzmc","");
73
+		params.put("refreshTime",contract.getChangeTime()==null?"":format.format(contract.getChangeTime()));
74
+		params.put("refresher","");
75
+		params.put("refresherCode","");
76
+		params.put("remark",contract.getRemark());
77
+		params.put("spzt",contract.getAuditState());
78
+		params.put("status",0);
79
+		params.put("yfkdbm",0);
80
+		params.put("yfkdmc",0);
81
+		params.put("yfkhh",0);
82
+		params.put("yflxdh",0);
83
+		params.put("yfqydm",0);
84
+		params.put("yfqymc",0);
85
+		params.put("yfqyr",0);
86
+		params.put("yfqzzt",0);
87
+		params.put("yfyhzh",0);
88
+		params.put("ysfs",contract.getShippingType());
89
+		params.put("zffs",contract.getContractPayType());
90
+		params.put("zxzt",0);
91
+		params.put("zyjjfs",contract.getDisputeSettlementMethod());
92
+		
93
+		
94
+		
95
+		//json对象转换成json字符串
96
+		String jsonStr = gson.toJson(params);
97
+		String result = HttpClientUtil.doPostJson(urls+"/sinkpoint", jsonStr);
98
+		System.out.print(result);
99
+	}
100
+	
101
+	*//**
102
+	 * 库点信息同步---更新
103
+	 *//*
104
+	public static void orgInfoSynchronizationUpdate(Map<String,Object> params,OrgInfo orgInfo) {
105
+		Gson gson = new Gson();
106
+		params.put("jcrq",orgInfo.getCompleteDate()==null?"":format.format(orgInfo.getCompleteDate()));
107
+		params.put("kdcz",orgInfo.getFax());
108
+		params.put("kddh",orgInfo.getContact());
109
+		params.put("kddm",orgInfo.getOrgId());
110
+		params.put("kddz",orgInfo.getAddress());
111
+		params.put("kdjc",orgInfo.getBriefIntroduction());
112
+		params.put("kdjd",orgInfo.getLongitude());
113
+		params.put("kdmc",orgInfo.getOrgName());
114
+		params.put("kdmj",orgInfo.getDepotArea());
115
+		params.put("kdqyxz",orgInfo.getCompanyNature());
116
+		params.put("kdwd",orgInfo.getLatitude());
117
+		params.put("kdyb",orgInfo.getPost());
118
+		params.put("kdyxcr",orgInfo.getEffectiveCapacity());
119
+		params.put("lklb",orgInfo.getOrgClassId());
120
+		params.put("qymc",orgInfo.getOrgName());
121
+		params.put("refreshTime",orgInfo.getUpdateTime()==null?"":format.format(orgInfo.getUpdateTime()));
122
+		params.put("remark",orgInfo.getRemark());
123
+		params.put("sjcr",orgInfo.getDesignCapacity());
124
+		params.put("status",orgInfo.getStatus());
125
+		params.put("tyshxydm",orgInfo.getCompanyOrgCode());
126
+		params.put("xzqhdm",orgInfo.getAreaCode());
127
+		params.put("xzqhmc",orgInfo.getAreaName());
128
+		//json对象转换成json字符串
129
+		String jsonStr = gson.toJson(params);
130
+		String result = HttpClientUtil.doPutJson(urls+"/sinkpoint", jsonStr);
131
+		System.out.print(result);
132
+	}
133
+	
134
+	*//**
135
+	 * 库点信息同步---删除
136
+	 *//*
137
+	public static void orgInfoSynchronizationDelete(OrgInfo orgInfo) {
138
+		Map<String,String> params = new HashMap<String,String>();
139
+		params.put("kddm",ObjectUtils.toString(orgInfo.getOrgId(),""));
140
+		//json对象转换成json字符串
141
+		String result = HttpClientUtil.doDelete(urls+"/sinkpoint", params);
142
+		System.out.print(result);
143
+	}*/
144
+}

+ 234 - 0
src/main/java/com/chinaitop/depot/utils/HttpClientUtil.java

@@ -0,0 +1,234 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import java.io.IOException;
4
+import java.net.URI;
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+import java.util.Map;
8
+
9
+import org.apache.http.NameValuePair;
10
+import org.apache.http.client.entity.UrlEncodedFormEntity;
11
+import org.apache.http.client.methods.CloseableHttpResponse;
12
+import org.apache.http.client.methods.HttpDelete;
13
+import org.apache.http.client.methods.HttpGet;
14
+import org.apache.http.client.methods.HttpPost;
15
+import org.apache.http.client.methods.HttpPut;
16
+import org.apache.http.client.utils.URIBuilder;
17
+import org.apache.http.entity.ContentType;
18
+import org.apache.http.entity.StringEntity;
19
+import org.apache.http.impl.client.CloseableHttpClient;
20
+import org.apache.http.impl.client.HttpClients;
21
+import org.apache.http.message.BasicNameValuePair;
22
+import org.apache.http.util.EntityUtils;
23
+
24
+public class HttpClientUtil {
25
+	/**
26
+	 * 带参数的get请求
27
+	 * @param url
28
+	 * @param param
29
+	 * @return String
30
+	 */
31
+	public static String doGet(String url, Map<String, String> param) {
32
+		// 创建Httpclient对象
33
+		CloseableHttpClient httpclient = HttpClients.createDefault();
34
+ 
35
+		String resultString = "";
36
+		CloseableHttpResponse response = null;
37
+		try {
38
+			// 创建uri
39
+			URIBuilder builder = new URIBuilder(url);
40
+			if (param != null) {
41
+				for (String key : param.keySet()) {
42
+					builder.addParameter(key, param.get(key));
43
+				}
44
+			}
45
+			URI uri = builder.build();
46
+			// 创建http GET请求
47
+			HttpGet httpGet = new HttpGet(uri);
48
+			// 执行请求
49
+			response = httpclient.execute(httpGet);
50
+			// 判断返回状态是否为200
51
+			if (response.getStatusLine().getStatusCode() == 200) {
52
+				resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
53
+			}
54
+		} catch (Exception e) {
55
+			e.printStackTrace();
56
+		} finally {
57
+			try {
58
+				if (response != null) {
59
+					response.close();
60
+				}
61
+				httpclient.close();
62
+			} catch (IOException e) {
63
+				e.printStackTrace();
64
+			}
65
+		}
66
+		return resultString;
67
+	}
68
+	
69
+	/**
70
+	 * 不带参数的get请求
71
+	 * @param url
72
+	 * @return String
73
+	 */
74
+	public static String doGet(String url) {
75
+		return doGet(url, null);
76
+	}
77
+ 
78
+	/**
79
+	 * 带参数的post请求
80
+	 * @param url
81
+	 * @param param
82
+	 * @return String
83
+	 */
84
+	public static String doPost(String url, Map<String, String> param) {
85
+		// 创建Httpclient对象
86
+		CloseableHttpClient httpClient = HttpClients.createDefault();
87
+		CloseableHttpResponse response = null;
88
+		String resultString = "";
89
+		try {
90
+			// 创建Http Post请求
91
+			HttpPost httpPost = new HttpPost(url);
92
+			// 创建参数列表
93
+			if (param != null) {
94
+				List<NameValuePair> paramList = new ArrayList<>();
95
+				for (String key : param.keySet()) {
96
+					paramList.add(new BasicNameValuePair(key, param.get(key)));
97
+				}
98
+				// 模拟表单
99
+				UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
100
+				httpPost.setEntity(entity);
101
+			}
102
+			// 执行http请求
103
+			response = httpClient.execute(httpPost);
104
+			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
105
+		} catch (Exception e) {
106
+			e.printStackTrace();
107
+		} finally {
108
+			try {
109
+				response.close();
110
+			} catch (IOException e) {
111
+				e.printStackTrace();
112
+			}
113
+		}
114
+		return resultString;
115
+	}
116
+ 
117
+	/**
118
+	 * 不带参数的post请求
119
+	 * @param url
120
+	 * @return String
121
+	 */
122
+	public static String doPost(String url) {
123
+		return doPost(url, null);
124
+	}
125
+	
126
+	/**
127
+	 * 传送json类型的post请求
128
+	 * @param url
129
+	 * @param json
130
+	 * @return String
131
+	 */
132
+	public static String doPostJson(String url, String json) {
133
+		// 创建Httpclient对象
134
+		CloseableHttpClient httpClient = HttpClients.createDefault();
135
+		CloseableHttpResponse response = null;
136
+		String resultString = "";
137
+		try {
138
+			// 创建Http Post请求
139
+			HttpPost httpPost = new HttpPost(url);
140
+			// 创建请求内容
141
+			StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
142
+			httpPost.setEntity(entity);
143
+			// 执行http请求
144
+			response = httpClient.execute(httpPost);
145
+			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
146
+		} catch (Exception e) {
147
+			e.printStackTrace();
148
+		} finally {
149
+			try {
150
+				response.close();
151
+			} catch (IOException e) {
152
+				e.printStackTrace();
153
+			}
154
+		}
155
+		return resultString;
156
+	}
157
+	
158
+	/**
159
+	 * 传送json类型的put请求
160
+	 * @param url
161
+	 * @param json
162
+	 * @return String
163
+	 */
164
+	public static String doPutJson(String url, String json) {
165
+		// 创建Httpclient对象
166
+		CloseableHttpClient httpClient = HttpClients.createDefault();
167
+		CloseableHttpResponse response = null;
168
+		String resultString = "";
169
+		try {
170
+			// 创建Http Put请求
171
+			HttpPut httpPut = new HttpPut(url);
172
+			// 创建请求内容
173
+			StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
174
+			httpPut.setEntity(entity);
175
+			// 执行http请求
176
+			response = httpClient.execute(httpPut);
177
+			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
178
+		} catch (Exception e) {
179
+			e.printStackTrace();
180
+		} finally {
181
+			try {
182
+				response.close();
183
+			} catch (IOException e) {
184
+				e.printStackTrace();
185
+			}
186
+		}
187
+		return resultString;
188
+	}
189
+	
190
+	/**
191
+	 * 带参数的delete请求
192
+	 * @param url
193
+	 * @param param
194
+	 * @return String
195
+	 */
196
+	public static String doDelete(String url, Map<String, String> param) {
197
+		// 创建Httpclient对象
198
+		CloseableHttpClient httpclient = HttpClients.createDefault();
199
+ 
200
+		String resultString = "";
201
+		CloseableHttpResponse response = null;
202
+		try {
203
+			// 创建uri
204
+			URIBuilder builder = new URIBuilder(url);
205
+			if (param != null) {
206
+				for (String key : param.keySet()) {
207
+					builder.addParameter(key, param.get(key));
208
+				}
209
+			}
210
+			URI uri = builder.build();
211
+			// 创建http Delete请求
212
+			HttpDelete httpDelete = new HttpDelete(uri);
213
+			// 执行请求
214
+			response = httpclient.execute(httpDelete);
215
+			// 判断返回状态是否为200
216
+			if (response.getStatusLine().getStatusCode() == 200) {
217
+				resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
218
+			}
219
+		} catch (Exception e) {
220
+			e.printStackTrace();
221
+		} finally {
222
+			try {
223
+				if (response != null) {
224
+					response.close();
225
+				}
226
+				httpclient.close();
227
+			} catch (IOException e) {
228
+				e.printStackTrace();
229
+			}
230
+		}
231
+		return resultString;
232
+	}
233
+
234
+}

+ 6 - 1
src/main/resources/bootstrap.yml

@@ -10,10 +10,15 @@ eureka:
10 10
       defaultZone: http://eureka-depot-yn:9001/eureka/
11 11
   instance:
12 12
     prefer-ip-address: true
13
+    # 每隔10s发送一次心跳(默认30s)
14
+    lease-renewal-interval-in-seconds: 10
15
+    # 告知服务端30秒还未收到心跳的话,就将该服务移除列表(默认90s)
16
+    lease-expiration-duration-in-seconds: 30
17
+    
13 18
 
14 19
 spring:
15 20
   application:
16
-    name: depot-business-yunnan
21
+    name: depot-business
17 22
   # 数据库配置
18 23
   datasource:
19 24
     depot: