chenminghao 1 year ago
parent
commit
5844badc10
1 changed files with 85 additions and 28 deletions
  1. 85 28
      mq-crj-service/src/main/java/cn/com/taiji/mqcrj/task/ScheduleTask.java

+ 85 - 28
mq-crj-service/src/main/java/cn/com/taiji/mqcrj/task/ScheduleTask.java

@@ -58,37 +58,60 @@ public class ScheduleTask {
      */
     @Scheduled(cron = "0 0 6 * * ?")
     public void scheduleOne() throws Exception {
-        log.info("执行START时间-{}", DateUtil.date());
+        log.info("免签-执行START时间-{}", DateUtil.date());
         HttpClient client = new SSLClient();
-        HttpGet get = handleJgUrl(Constant.MQDQZDRS, null, "1");
+        HttpGet get = handleJgUrl(Constant.MQDQZDRS, null, 1);
         HttpResponse res = client.execute(get);
         if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
             log.info(""+res.getStatusLine().getStatusCode());
             HttpEntity entity = res.getEntity();
             String result = EntityUtils.toString(entity);
             JSONObject jsonObject = JSONObject.parseObject(result);
-            if (jsonObject.getBoolean("success")) {
-                String rows = jsonObject.getString("rows");
-                List<VisaFreeAreaIslandPerson> visaFreeAreaIslandPeople = JSONObject.parseArray(rows, VisaFreeAreaIslandPerson.class);
-                mqdqzdrsService.saveOrUpdateBatch(visaFreeAreaIslandPeople);
+            Integer total = jsonObject.getInteger("total");
+            for (int i=1;i<=total/200+1;i++){
+                Thread.sleep(10000);
+                HttpGet httpGet = handleJgUrl(Constant.MQDQZDRS, null, i);
+                HttpResponse response = client.execute(httpGet);
+                if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                    HttpEntity entityPage = response.getEntity();
+                    String resultPage = EntityUtils.toString(entityPage);
+                    JSONObject jsonObject1 = JSONObject.parseObject(resultPage);
+                    if (jsonObject1.getBoolean("success")) {
+                        String rows1 = jsonObject1.getString("rows");
+                        List<VisaFreeAreaIslandPerson> visaFreeAreaIslandPeople = JSONObject.parseArray(rows1, VisaFreeAreaIslandPerson.class);
+                        mqdqzdrsService.saveOrUpdateBatch(visaFreeAreaIslandPeople);
+                    }
+                }
             }
         }
-        log.info("执行END时间-{}", DateUtil.date());
+        log.info("免签-执行END时间-{}", DateUtil.date());
     }
 
     @Scheduled(cron = "1 0 6 * * ?")
     public void scheduleTwo() throws Exception {
         HttpClient client = new SSLClient();
-        HttpGet get = handleJgUrl(Constant.MQDQCRJZDRS, null, "1");
+        HttpGet get = handleJgUrl(Constant.MQDQCRJZDRS, null, 1);
         HttpResponse res = client.execute(get);
         if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
             HttpEntity entity = res.getEntity();
             String result = EntityUtils.toString(entity);
             JSONObject jsonObject = JSONObject.parseObject(result);
-            if (jsonObject.getBoolean("success")) {
-                String rows = jsonObject.getString("rows");
-                List<VisaFreeAreaEntryAndExitIslandPerson> visaFree = JSONObject.parseArray(rows, VisaFreeAreaEntryAndExitIslandPerson.class);
-                mqdqcrjzdrsService.saveOrUpdateBatch(visaFree);
+
+            Integer total = jsonObject.getInteger("total");
+            for (int i=1;i<=total/200+1;i++){
+                Thread.sleep(10000);
+                HttpGet httpGet = handleJgUrl(Constant.MQDQCRJZDRS, null, i);
+                HttpResponse response = client.execute(httpGet);
+                if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                    HttpEntity entityPage = response.getEntity();
+                    String resultPage = EntityUtils.toString(entityPage);
+                    JSONObject jsonObject1 = JSONObject.parseObject(resultPage);
+                    if (jsonObject1.getBoolean("success")) {
+                        String rows = jsonObject.getString("rows");
+                        List<VisaFreeAreaEntryAndExitIslandPerson> visaFree = JSONObject.parseArray(rows, VisaFreeAreaEntryAndExitIslandPerson.class);
+                        mqdqcrjzdrsService.saveOrUpdateBatch(visaFree);
+                    }
+                }
             }
         }
     }
@@ -96,16 +119,27 @@ public class ScheduleTask {
     @Scheduled(cron = "2 0 6 * * ?")
     public void scheduleThree() throws Exception {
         HttpClient client = new SSLClient();
-        HttpGet get = handleJgUrl(Constant.MQWGRQZQK, null, "1");
+        HttpGet get = handleJgUrl(Constant.MQWGRQZQK, null, 1);
         HttpResponse res = client.execute(get);
         if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
             HttpEntity entity = res.getEntity();
             String result = EntityUtils.toString(entity);
             JSONObject jsonObject = JSONObject.parseObject(result);
-            if (jsonObject.getBoolean("success")) {
-                String rows = jsonObject.getString("rows");
-                List<VisaFreeForeignerApply> visaFreeForeignerApplies = JSONObject.parseArray(rows, VisaFreeForeignerApply.class);
-                mqwgrqzblqkService.saveOrUpdateBatch(visaFreeForeignerApplies);
+            Integer total = jsonObject.getInteger("total");
+            for (int i=1;i<=total/200+1;i++){
+                Thread.sleep(10000);
+                HttpGet httpGet = handleJgUrl(Constant.MQWGRQZQK, null, i);
+                HttpResponse response = client.execute(httpGet);
+                if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                    HttpEntity entityPage = response.getEntity();
+                    String resultPage = EntityUtils.toString(entityPage);
+                    JSONObject jsonObject1 = JSONObject.parseObject(resultPage);
+                    if (jsonObject1.getBoolean("success")) {
+                        String rows1 = jsonObject1.getString("rows");
+                        List<VisaFreeForeignerApply> visaFreeForeignerApplies = JSONObject.parseArray(rows1, VisaFreeForeignerApply.class);
+                        mqwgrqzblqkService.saveOrUpdateBatch(visaFreeForeignerApplies);
+                    }
+                }
             }
         }
     }
@@ -113,16 +147,28 @@ public class ScheduleTask {
     @Scheduled(cron = "3 0 6 * * ?")
     public void scheduleFour() throws Exception {
         HttpClient client = new SSLClient();
-        HttpGet get = handleJgUrl(Constant.MQWGRYJ, null, "1");
+        HttpGet get = handleJgUrl(Constant.MQWGRYJ, null, 1);
         HttpResponse res = client.execute(get);
         if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
             HttpEntity entity = res.getEntity();
             String result = EntityUtils.toString(entity);
             JSONObject jsonObject = JSONObject.parseObject(result);
-            if (jsonObject.getBoolean("success")) {
-                String rows = jsonObject.getString("rows");
-                List<VisaFreePersonWarning> visaFreePersonWarnings = JSONObject.parseArray(rows, VisaFreePersonWarning.class);
-                mqwgryjService.saveOrUpdateBatch(visaFreePersonWarnings);
+
+            Integer total = jsonObject.getInteger("total");
+            for (int i=1;i<=total/200+1;i++){
+                Thread.sleep(10000);
+                HttpGet httpGet = handleJgUrl(Constant.MQWGRYJ, null, i);
+                HttpResponse response = client.execute(httpGet);
+                if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                    HttpEntity entityPage = response.getEntity();
+                    String resultPage = EntityUtils.toString(entityPage);
+                    JSONObject jsonObject1 = JSONObject.parseObject(resultPage);
+                    if (jsonObject1.getBoolean("success")) {
+                        String rows = jsonObject.getString("rows");
+                        List<VisaFreePersonWarning> visaFreePersonWarnings = JSONObject.parseArray(rows, VisaFreePersonWarning.class);
+                        mqwgryjService.saveOrUpdateBatch(visaFreePersonWarnings);
+                    }
+                }
             }
         }
     }
@@ -130,23 +176,34 @@ public class ScheduleTask {
     @Scheduled(cron = "4 0 6 * * ?")
     public void scheduleFive() throws Exception {
         HttpClient client = new SSLClient();
-        HttpGet get = handleJgUrl(Constant.MQWGRZDJZQK, null, "1");
+        HttpGet get = handleJgUrl(Constant.MQWGRZDJZQK, null, 1);
         HttpResponse res = client.execute(get);
         if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
             HttpEntity entity = res.getEntity();
             String result = EntityUtils.toString(entity);
             JSONObject jsonObject = JSONObject.parseObject(result);
-            if (jsonObject.getBoolean("success")) {
-                String rows = jsonObject.getString("rows");
-                List<VisaFreePersonPutUpCondition> visaFreePersonPutUpConditions = JSONObject.parseArray(rows, VisaFreePersonPutUpCondition.class);
-                mqwgrzdjzqkService.saveOrUpdateBatch(visaFreePersonPutUpConditions);
+            Integer total = jsonObject.getInteger("total");
+            for (int i=1;i<=total/200+1;i++){
+                Thread.sleep(10000);
+                HttpGet httpGet = handleJgUrl(Constant.MQWGRZDJZQK, null, i);
+                HttpResponse response = client.execute(httpGet);
+                if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                    HttpEntity entityPage = response.getEntity();
+                    String resultPage = EntityUtils.toString(entityPage);
+                    JSONObject jsonObject1 = JSONObject.parseObject(resultPage);
+                    if (jsonObject1.getBoolean("success")) {
+                        String rows = jsonObject.getString("rows");
+                        List<VisaFreePersonPutUpCondition> visaFreePersonPutUpConditions = JSONObject.parseArray(rows, VisaFreePersonPutUpCondition.class);
+                        mqwgrzdjzqkService.saveOrUpdateBatch(visaFreePersonPutUpConditions);
+                    }
+                }
             }
         }
     }
 
 
 
-    public HttpGet handleJgUrl(String qspBizId,String terms,String page){
+    public HttpGet handleJgUrl(String qspBizId,String terms,int page){
         StringBuffer param = new StringBuffer();
         JSONArray parse = JSONArray.parseArray(terms);
         // 特殊字符转译