Browse Source

更新一版 针对于配置入手

15510527737 3 months ago
parent
commit
1959a0e059

+ 13 - 0
pom.xml

@@ -103,6 +103,19 @@
             <version>${geotools.version}</version>
         </dependency>
 
+        <!--	httpClient	-->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+        </dependency>
+
         <dependency>
             <groupId>org.geotools</groupId>
             <artifactId>gt-epsg-hsql</artifactId>

+ 152 - 124
src/main/java/tech/powerjob/work/service/impl/waterPassengerTransport/HMDataServiceImpl.java

@@ -13,6 +13,8 @@ import tech.powerjob.work.mapper.waterPassengerTransport.HMDataServiceMapper;
 import tech.powerjob.work.service.waterPassengerTransport.HMDataShareService;
 import tech.powerjob.work.util.ApiUtils;
 import tech.powerjob.work.util.DateUtils;
+import tech.powerjob.work.util.HttpClientUtils;
+import tech.powerjob.work.util.ReturnMsg;
 import tech.powerjob.worker.core.processor.ProcessResult;
 
 import java.util.HashMap;
@@ -32,6 +34,8 @@ public class HMDataServiceImpl implements HMDataShareService {
 
     @Value("${preGhjgWebService}")
     private String preGhjgWebService;
+    @Value("${hmService}")
+    private String hmService;
 
     @Autowired
     HMDataServiceMapper mapper;
@@ -92,26 +96,59 @@ public class HMDataServiceImpl implements HMDataShareService {
      * }
      */
     // 获取token
+
     public String getToken() {
-        try {
-            Map<String, String> headers = new HashMap();
-            String url = preGhjgWebService + "hdsp/CheckToken";  //资源url地址
-            log.info("getToken开始调用");
-            String result = ApiUtils.post(url, headers, "");   //post请求
-            log.info("getToken 返回结果:" + result);
-            String token = "";
-            if (StringUtils.isBlank(result)) {
-                log.info("CheckToken 返回结果为空");
-            } else {
-                if (result.indexOf("checkToken异常") == -1) {
-                    token = result.replace("\r\n", "");
+        try{
+            String url = preGhjgWebService + "Validate/GetToken";
+            Map<String,String> header = new HashMap<>();
+            Map<String,String> param = new HashMap<>();
+            param.put("userId","chengdi");
+            param.put("password","chengdi@147");
+            String result = HttpClientUtils.doGet(url,header,param,20000);
+            log.info(result);
+            String returnMsg = "";
+            JSONObject object = JSONObject.parseObject(result);
+            if((Boolean) object.get("Success")){
+                JSONObject data = JSONObject.parseObject(String.valueOf(object.get("Data")));
+                if(data!=null){
+                    returnMsg = String.valueOf(data.get("token"));
                 }
+            }else{
+                returnMsg = object.get("Message").toString();
             }
-            return token;
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.info(e.getMessage());
-            return "";
+            return returnMsg;
+        }catch (Exception err){
+            log.info("checkToken异常:"+err.getMessage());
+            return ReturnMsg.returnErrorMsgNew("checkToken异常:"+err.getMessage());
+        }
+    }
+
+    public String getHMService(Map<String, String> map){
+        try{
+            log.info("getHMService接收到参数:"+map.toString());
+            log.info("hwToken:"+map.get("token"));
+            if(StringUtils.isBlank(map.get("token"))){
+                log.info("hwToken为空!");
+                return "token不能为空!";
+            }
+
+            String url = hmService + map.get("method").toString();
+            Map<String,String> header = new HashMap<>();
+            Map<String,String> param = new HashMap<>();
+
+            param.put("token", map.get("token"));
+            for(String key:map.keySet()){
+                if(!"method".equals(key)){
+                    param.put(key,map.get(key));
+                }
+            }
+            String result = HttpClientUtils.doGet(url,header,param,20000);
+            log.info(result);
+            return result;
+        }catch (Exception err){
+            err.getStackTrace();
+            log.info("getHMService异常:"+err.getMessage());
+            return ReturnMsg.returnErrorMsgNew("getHMService异常:"+err.getMessage());
         }
     }
 
@@ -122,16 +159,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             headers.put("method", method);
             headers.put("startTime", startTime);
             headers.put("endTime", endTime);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"startTime\":\"" + startTime + "\",\"endTime\":\"" + endTime + "\",\"token\":\"" + token + "\"}";
-            log.info("Schedule/Query开始调用 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("Schedule/Query 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("Schedule/Query 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     List<HmScheduleTicket> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmScheduleTicket.class);
                     if (list.size() > 0) {
 //                        list.sort((o1, o2) -> {
@@ -150,8 +186,8 @@ public class HMDataServiceImpl implements HMDataShareService {
                         }
                     }
                     log.info("Schedule/Query 执行完毕 数据总数:" + list.size());
-                } else {
-                    log.info("Schedule/Query:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
         } catch (Exception e) {
@@ -167,16 +203,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             headers.put("method", method);
             headers.put("dockCode", "");
             headers.put("dayTime", dayTime);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"dockCode\":\"\",\"dayTime\":\"" + dayTime + "\",\"token\":\"" + token + "\"}";
-            log.info("Schedule/TotalQuery 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("Schedule/TotalQuery 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("Schedule/TotalQuery 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     HmTotalInfo data = JSONObject.parseObject(String.valueOf(object.get("Data")), HmTotalInfo.class);
                     if (data != null) {
                         data.setDockCode("0");
@@ -184,12 +219,13 @@ public class HMDataServiceImpl implements HMDataShareService {
                         mapper.SaveOrUpdateTotalInfo(data);
                     }
                     log.info("Schedule/TotalQuery 执行完毕!");
-                } else {
-                    log.info("Schedule/TotalQuery:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
+            log.info("getTotalInfo异常"+e);
             log.info(e.getMessage());
         }
     }
@@ -199,16 +235,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             String method = "CommonInfo/Company";
             Map<String, String> headers = new HashMap();
             headers.put("method", method);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"token\":\"" + token + "\"}";
-            log.info("CommonInfo/Company 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("CommonInfo/Company 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("CommonInfo/Company 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     List<HmCompanyInfo> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmCompanyInfo.class);
                     if (list.size() > 0) {
                         for (HmCompanyInfo item : list) {
@@ -216,8 +251,8 @@ public class HMDataServiceImpl implements HMDataShareService {
                         }
                     }
                     log.info("CommonInfo/Company 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("CommonInfo/Company:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
 
@@ -232,16 +267,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             String method = "CommonInfo/Ship";
             Map<String, String> headers = new HashMap();
             headers.put("method", method);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"token\":\"" + token + "\"}";
-            log.info("CommonInfo/Ship 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("CommonInfo/Ship 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("CommonInfo/Ship 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     List<HmShipInfo> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmShipInfo.class);
                     if (list.size() > 0) {
                         for (HmShipInfo item : list) {
@@ -249,8 +283,8 @@ public class HMDataServiceImpl implements HMDataShareService {
                         }
                     }
                     log.info("CommonInfo/Ship 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("CommonInfo/Ship:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
 
@@ -260,40 +294,39 @@ public class HMDataServiceImpl implements HMDataShareService {
         }
     }
 
-    private void getScheduleInfo(String startTime, String endTime, String token) {
-        try {
-            String method = "CommonInfo/Schedule";
-            Map<String, String> headers = new HashMap();
-            headers.put("method", method);
-            headers.put("startTime", startTime);
-            headers.put("endTime", endTime);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"startTime\":\"" + startTime + "\",\"endTime\":\"" + endTime + "\",\"token\":\"" + token + "\"}";
-            log.info("CommonInfo/Schedule 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
-            log.info("CommonInfo/Schedule 返回结果:" + result);
-            if (StringUtils.isBlank(result)) {
-                log.info("CommonInfo/Schedule 返回结果为空");
-            } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
-                    List<HmScheduleTicket> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmScheduleTicket.class);
-                    if (list.size() > 0) {
-                        for (HmScheduleTicket item : list) {
-                            mapper.SaveOrUpdateScheduleTicket(item);
-                        }
-                    }
-                    log.info("CommonInfo/Schedule 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("CommonInfo/Schedule:" + object.get("Message").toString());
-                }
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.info(e.getMessage());
-        }
-    }
+//    private void getScheduleInfo(String startTime, String endTime, String token) {
+//        try {
+//            String method = "CommonInfo/Schedule";
+//            Map<String, String> headers = new HashMap();
+//            headers.put("method", method);
+//            headers.put("startTime", startTime);
+//            headers.put("endTime", endTime);
+//            headers.put("token", token);
+//            String result = getHMService(headers);
+//            log.info("CommonInfo/Schedule 返回结果:" + result);
+//            if (StringUtils.isBlank(result)) {
+//                log.info("CommonInfo/Schedule 返回结果为空");
+//            } else {
+//                boolean isTrue = Boolean.parseBoolean(result);
+//                JSONObject object = new JSONObject(isTrue);
+//                if (isTrue) {
+//                    List<HmScheduleTicket> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmScheduleTicket.class);
+//                    if (list.size() > 0) {
+//                        for (HmScheduleTicket item : list) {
+//                            mapper.SaveOrUpdateScheduleTicket(item);
+//                        }
+//                    }
+//                    log.info("CommonInfo/Schedule 执行完毕!数据总数:" + list.size());
+//                }else {
+//                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
+//                }
+//            }
+//
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.info(e.getMessage());
+//        }
+//    }
 
     public void getDaylyLYKYInfo(String startTime, String endTime, String token) {
         try {
@@ -302,16 +335,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             headers.put("method", method);
             headers.put("startTime", startTime);
             headers.put("endTime", endTime);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"startTime\":\"" + startTime + "\",\"endTime\":\"" + endTime + "\",\"token\":\"" + token + "\"}";
-            log.info("CommonInfo/Passenger 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("CommonInfo/Passenger 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("CommonInfo/Passenger 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     List<HmScheduleTicket> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmScheduleTicket.class);
                     if (list.size() > 0) {
                         for (HmScheduleTicket item : list) {
@@ -319,8 +351,8 @@ public class HMDataServiceImpl implements HMDataShareService {
                         }
                     }
                     log.info("CommonInfo/Passenger 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("CommonInfo/Passenger:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
 
@@ -337,16 +369,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             headers.put("method", method);
             headers.put("startTime", startTime);
             headers.put("endTime", endTime);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"startTime\":\"" + startTime + "\",\"endTime\":\"" + endTime + "\",\"token\":\"" + token + "\"}";
-            log.info("CommonInfo/TotalPassenger 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("CommonInfo/TotalPassenger 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("CommonInfo/TotalPassenger 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     JSONArray array = JSONObject.parseArray(String.valueOf(object.get("Data")));
                     if (array.size() > 0) {
                         for (Object item : array) {
@@ -354,8 +385,8 @@ public class HMDataServiceImpl implements HMDataShareService {
                         }
                     }
                     log.info("CommonInfo/TotalPassenger 执行完毕!数据总数:" + array.size());
-                } else {
-                    log.info("CommonInfo/TotalPassenger:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
 
@@ -370,25 +401,24 @@ public class HMDataServiceImpl implements HMDataShareService {
             String method = "Schedule/GetPierBerthInfo";
             Map<String, String> headers = new HashMap();
             headers.put("method", method);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"token\":\"" + token + "\"}";
-            log.info("Schedule/GetPierBerthInfo 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("Schedule/GetPierBerthInfo 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("Schedule/GetPierBerthInfo 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     List<HmPierBerthInfo> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmPierBerthInfo.class);
                     if (list.size() > 0) {
                         for (HmPierBerthInfo item : list) {
                             mapper.SaveOrUpdatePierBerthInfo(item);
                         }
+                    }else {
+                        log.info("CommonInfo/BerthStatus 执行失败!"+result);
                     }
                     log.info("Schedule/GetPierBerthInfo 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("Schedule/GetPierBerthInfo:" + object.get("Message").toString());
                 }
             }
 
@@ -403,16 +433,15 @@ public class HMDataServiceImpl implements HMDataShareService {
             String method = "Schedule/GetScheduleTypeInfo";
             Map<String, String> headers = new HashMap();
             headers.put("method", method);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"token\":\"" + token + "\"}";
-            log.info("Schedule/GetScheduleTypeInfo 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("Schedule/GetScheduleTypeInfo 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("Schedule/GetScheduleTypeInfo 返回结果为空");
             } else {
-                JSONObject object = JSONObject.parseObject(result);
-                if ((Boolean) object.get("Success")) {
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
                     List<HmScheduleTypeInfo> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmScheduleTypeInfo.class);
                     if (list.size() > 0) {
                         for (HmScheduleTypeInfo item : list) {
@@ -420,8 +449,8 @@ public class HMDataServiceImpl implements HMDataShareService {
                         }
                     }
                     log.info("Schedule/GetScheduleTypeInfo 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("Schedule/GetScheduleTypeInfo:" + object.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
 
@@ -437,25 +466,24 @@ public class HMDataServiceImpl implements HMDataShareService {
             String method = "CommonInfo/BerthStatus";
             Map<String, String> headers = new HashMap();
             headers.put("method", method);
-            String url = preGhjgWebService + "hdsp/GetHMService";  //资源url地址
-            String json = "{\"method\":\"" + method + "\",\"token\":\"" + token + "\"}";
-            log.info("CommonInfo/BerthStatus 参数:" + json);
-            String result = ApiUtils.post(url, headers, json);   //post请求
+            headers.put("token", token);
+            String result = getHMService(headers);
             log.info("CommonInfo/BerthStatus 返回结果:" + result);
             if (StringUtils.isBlank(result)) {
                 log.info("CommonInfo/BerthStatus 返回结果为空");
             } else {
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if ((Boolean) jsonObject.get("Success")) {
-                    List<HmScheduleBerthStatus> list = JSONObject.parseArray(String.valueOf(jsonObject.get("Data")), HmScheduleBerthStatus.class);
+                boolean isTrue = Boolean.parseBoolean(result);
+                JSONObject object = new JSONObject(isTrue);
+                if (isTrue) {
+                    List<HmScheduleBerthStatus> list = JSONObject.parseArray(String.valueOf(object.get("Data")), HmScheduleBerthStatus.class);
                     if (list != null && list.size() > 0) {
                         for (HmScheduleBerthStatus hmScheduleBerthStatus : list) {
                             mapper.SaveOrUpdateBerthStatus(hmScheduleBerthStatus);
                         }
                     }
                     log.info("Schedule/GetScheduleTypeInfo 执行完毕!数据总数:" + list.size());
-                } else {
-                    log.info("Schedule/GetScheduleTypeInfo:" + jsonObject.get("Message").toString());
+                }else {
+                    log.info("CommonInfo/BerthStatus 执行失败!"+result);
                 }
             }
         } catch (Exception e) {

+ 103 - 0
src/main/java/tech/powerjob/work/util/HttpClientUtils.java

@@ -0,0 +1,103 @@
+package tech.powerjob.work.util;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import sun.misc.BASE64Encoder;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Author: gll
+ * @Description:
+ * @Data: Create in 13:49 2020/9/30
+ * @Modified By:
+ */
+public class HttpClientUtils {
+    private final static int DEFALUT_TIMEOUT = 5000;
+
+    public static String doGet(String url, Map<String, String> header,Map<String, String> param, Integer timeout) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        String resultString = "";
+        CloseableHttpResponse response = null;
+        try {
+            // 创建uri
+            URIBuilder builder = new URIBuilder(url);
+            if (param != null) {
+                for (String key : param.keySet()) {
+                    builder.addParameter(key, param.get(key));
+                }
+            }
+            URI uri = builder.build();
+            // 创建http GET请求
+            HttpGet httpGet = new HttpGet(uri);
+            if (header != null) {
+                for (String key : header.keySet()) {
+                    httpGet.addHeader(key,header.get(key));
+                }
+            }
+            timeout = (timeout == null ? DEFALUT_TIMEOUT : timeout);
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setConnectTimeout(timeout).setSocketTimeout(timeout).build();
+            httpGet.setConfig(requestConfig);
+            // 执行请求
+            response = httpclient.execute(httpGet);
+            // 判断返回状态是否为200
+            if (response.getStatusLine().getStatusCode() == 200) {
+                resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            }
+        } catch (Exception e) {
+
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return resultString;
+    }
+
+
+
+
+
+
+}

+ 11 - 0
src/main/java/tech/powerjob/work/util/ReturnMsg.java

@@ -1,5 +1,6 @@
 package tech.powerjob.work.util;
 
+import com.alibaba.fastjson.JSONObject;
 import tech.powerjob.worker.core.processor.ProcessResult;
 
 public class ReturnMsg extends ProcessResult {
@@ -11,4 +12,14 @@ public class ReturnMsg extends ProcessResult {
     public static ProcessResult returnMsg(Boolean isSuccess) {
         return new ProcessResult(isSuccess);
     }
+
+    public static String returnErrorMsgNew(String msg){
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("data",null);
+        jsonObject.put("status","error");
+        jsonObject.put("code", "500");
+        jsonObject.put("msg",msg);
+        return jsonObject.toString();
+    }
+
 }

+ 7 - 3
src/main/resources/application.yml

@@ -1,5 +1,5 @@
 server:
-  port: 7805
+  port: 7806
 
   # Spring JPA settings (commented out)
   #spring:
@@ -10,8 +10,8 @@ powerjob:
   worker:
     enabled: true
     allow-lazy-connect-server: false
-    port: 27782
-    app-name: WaterPassengerTransport
+    port: 27783
+    app-name: WaterPassengerTransportKingBase
     server-address: 127.0.0.1:7700
     protocol: http
     # Store strategy of H2 database (commented out)
@@ -20,6 +20,9 @@ powerjob:
     max-appended-wf-context-length: 4096
 
 spring:
+  jackson:
+    deserialization:
+      ACCEPT_SINGLE_VALUE_AS_ARRAY: true
   main:
     allow-circular-references: true
   datasource:
@@ -42,6 +45,7 @@ client_secret: 8c7353785ad2403da28e1e938ad3ba5a
 client_id: 6580df4629bc466395ba0eed8444311b
 
 preGhjgWebService: http://174.0.34.13:8090/HmService/
+hmService : http://174.0.34.13:8090/HmService/
 #preGhjgWebService: http://183.194.248.155:8090/ghjgWebService/ (commented out)