From c007f0ca1785db093d48f4846cda82fe8e955765 Mon Sep 17 00:00:00 2001
From: kimi <kimi42345@gmail.com>
Date: 星期三, 27 五月 2020 09:59:29 +0800
Subject: [PATCH] merage

---
 src/main/java/com/highdatas/mdm/job/JobClient.java |  112 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 102 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/highdatas/mdm/job/JobClient.java b/src/main/java/com/highdatas/mdm/job/JobClient.java
index 5b339f4..ffb5411 100644
--- a/src/main/java/com/highdatas/mdm/job/JobClient.java
+++ b/src/main/java/com/highdatas/mdm/job/JobClient.java
@@ -41,6 +41,12 @@
     private JobClient() {
         this.prefix = "/xxl-job-admin/";
     }
+    /**
+     *
+     * @description: xxljob 鐧诲綍鎺ュ彛
+     * @return 鍏蜂綋鏁版嵁
+     *
+     */
     public  boolean login() {
         String url = this.url + prefix + "login";
         Map<String, String> params = new LinkedHashMap<>();
@@ -56,6 +62,12 @@
         return  success;
     }
 
+    /**
+     *
+     * @description: xxljob 鍙傛暟杞崲
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     private boolean parse(JSONObject result) {
         boolean success = true;
         Integer code = result.getInteger(Constant.Code);
@@ -67,7 +79,12 @@
         return success;
     }
 
-
+    /**
+     *
+     * @description: xxljob 淇濆瓨jobGroup
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     public boolean saveJobGroup() {
         try {
             String url =  this.url + prefix + "xxlcustapi/saveJobGroup";
@@ -97,7 +114,47 @@
         }
 
     }
+    /**
+     *
+     * @description: xxljob 淇濆瓨鑷姩鑾峰彇ip鐨刯obgroup
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
+    public boolean saveAutoJobGroup() {
+        try {
+            String url =  this.url + prefix + "xxlcustapi/saveJobGroup";
+            Map<String, String> params = new LinkedHashMap<>();
+            params.put("appName","MDMApp");
+            params.put("order", "1");
+            params.put("title","鏁版嵁姹囬泦瀹氭椂浠诲姟鎵ц鍣�");
+            params.put("modelId","MDM");
+            params.put("addressType","0");
+//            params.put("addressList",local);
+            String s = null;
+            Map<String, Object> paramMap = new HashMap<>();
+            paramMap.putAll(params);
+            String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
 
+            s = HttpRestClient(url, HttpMethod.POST, null, urlParamsByMap, MediaType.APPLICATION_JSON);
+
+            JSONObject result = (JSONObject) JSON.parse(s);
+            boolean success = parse(result);
+            if (!success){
+                log.error("璇锋眰saveJobGroup澶辫触:" + result.getString("msg"));
+            }
+            return success;
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
+
+    }
+    /**
+     *
+     * @description: xxljob 鍒犻櫎鑷姩鑾峰彇ip鐨刯obgroup
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     public boolean removeJobGroup() {
         try {
             String url =  this.url + prefix + "xxlcustapi/saveJobGroup";
@@ -120,7 +177,13 @@
 
     }
 
-
+    /**
+     *
+     * @description: xxljob 娣诲姞涓�涓猨ob
+     * @param  assemble 姹囬泦浠诲姟
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     public boolean addJob(SysAssemble assemble) {
         try {
             String jobId = createJobId(assemble.getId());
@@ -135,11 +198,11 @@
             params.put("cronGen_display",assemble.getCron());
             params.put("executorBlockStrategy","DISCARD_LATER");
             params.put("executorTimeout","0");
-            params.put("executorFailRetryCount","3");
+            params.put("executorFailRetryCount","0");
             params.put("triggerStatus","1");
             params.put("glueType","BEAN");
             params.put("executorRouteStrategy","FIRST");
-            params.put("jobDesc","鍒涘缓姹囬泦job");
+            params.put("jobDesc","鍒涘缓姹囬泦job" + jobId);
             Map<String, Object> paramMap = new HashMap<>();
             paramMap.putAll(params);
             String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
@@ -159,22 +222,34 @@
         }
 
     }
-
+    /**
+     *
+     * @description: xxljob 鍒涘缓job id
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     private String createJobId(String id) {
         if (StringUtils.isEmpty(id)) {
             id = DbUtils.getUUID();
         }
         try {
-            String jobId  = "MDM-" + DbUtils.Bit16(id);
+            String jobId  = "MDM-" + id;
             return jobId;
         } catch (Exception e) {
             e.printStackTrace();
             return id;
         }
     }
-
+    /**
+     *
+     * @description: xxljob 鏇存柊job
+     * @param assemble huiji renwu
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     public boolean updateJob(SysAssemble assemble) {
         try {
+            String jobId = createJobId(assemble.getId());
             String url =  this.url + prefix + "xxlcustapi/updateJob";
             Map<String, String> params = new LinkedHashMap<>();
             params.put("modelId","MDM");
@@ -190,7 +265,7 @@
             params.put("triggerStatus","1");
             params.put("glueType","BEAN");
             params.put("executorRouteStrategy","FIRST");
-            params.put("jobDesc","鏇存柊姹囬泦job");
+            params.put("jobDesc","鏇存柊姹囬泦job" + jobId);
             Map<String, Object> paramMap = new HashMap<>();
             paramMap.putAll(params);
             String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
@@ -208,7 +283,13 @@
         }
 
     }
-
+    /**
+     *
+     * @description: xxljob 鍒犻櫎job
+     * @param  jobId job ID
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     public boolean deleteJob(String jobId) {
 
         try {
@@ -263,6 +344,12 @@
 
     }
 
+    /**
+     *
+     * @description: xxljob 瑙﹀彂涓�娆�
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     public boolean trigger(SysAssemble assemble) {
         if (StringUtils.isEmpty(assemble.getJobId())) {
             return false;
@@ -292,7 +379,12 @@
 
     }
 
-
+    /**
+     *
+     * @description: xxljob 浣跨敤鐨刪ttp璇锋眰宸ュ叿鏂规硶
+     * @return 鏄惁璇锋眰鎴愬姛
+     *
+     */
     private  String     HttpRestClient(String url, HttpMethod method, Map<String, String> formParams, String getParams,  MediaType mediaType) {
         if (!StringUtils.isEmpty(getParams)) {
             url = url + Constant.QUESTION + getParams;

--
Gitblit v1.8.0