zhonghui пре 3 година
родитељ
комит
895ef7b72d

+ 45 - 39
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoUserServiceImpl.java

@@ -172,54 +172,60 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
     @Override
     public void syncData() throws Exception {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        // 获取疫苗信息,每次处理1000条
-        int counts = syncMapper.selectCount("select count(1) from vaccine_info");
-        int count = 1;
+
+        try{
+            // 获取疫苗信息,每次处理1000条
+            int counts = syncMapper.selectCount("select count(1) from vaccine_info");
+            int count = 1;
 //        int counts = 1;
-        int times = counts / 1000;
-        int startPagte = 0;
-        int endPage = 1000;
+            int times = counts / 1000;
+            int startPagte = 0;
+            int endPage = 1000;
 
-        for (int i = 0; i < times + 1; i++) {
-            List<JSONObject> vaccInfos = this.getVaccInfo(startPagte, endPage);
-            // 身份证号码
-            List<String> idCards = new ArrayList<>();
-            Map<String, JSONObject> vannInfoMap = new HashMap<>();
+            for (int i = 0; i < times + 1; i++) {
+                List<JSONObject> vaccInfos = this.getVaccInfo(startPagte, endPage);
+                // 身份证号码
+                List<String> idCards = new ArrayList<>();
+                Map<String, JSONObject> vannInfoMap = new HashMap<>();
 
-            Map<String, String> progressMap = new HashMap<>();
-            for (JSONObject vanninfo : vaccInfos) {
-                String idcard = vanninfo.getString("id_card");
-                JSONObject jsonObject = new JSONObject();
-                jsonObject.put("id_card", idcard);
-                progressMap.put(idcard, vanninfo.getString("progress"));
-                vannInfoMap.put(idcard, jsonObject);
-                idCards.add(idcard);
-            }
+                Map<String, String> progressMap = new HashMap<>();
+                for (JSONObject vanninfo : vaccInfos) {
+                    String idcard = vanninfo.getString("id_card");
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("id_card", idcard);
+                    progressMap.put(idcard, vanninfo.getString("progress"));
+                    vannInfoMap.put(idcard, jsonObject);
+                    idCards.add(idcard);
+                }
 
-            int secCount = 1;
-            // 查询疫苗是否完成
-            for (String icsard : idCards) {
-                JSONObject update = vannInfoMap.get(icsard);
-                JSONObject userInfo = this.getvaccUser(icsard);
-                if (userInfo != null) {
-                    if(progressMap.get(icsard).equals("否")) {
-                        update.put("should_slow", "是");
-                    }else {
+                int secCount = 1;
+                // 查询疫苗是否完成
+                for (String icsard : idCards) {
+                    JSONObject update = vannInfoMap.get(icsard);
+                    JSONObject userInfo = this.getvaccUser(icsard);
+                    if (userInfo != null) {
+                        if(progressMap.get(icsard).equals("否")) {
+                            update.put("should_slow", "是");
+                        }else {
+                            update.put("should_slow", "否");
+                        }
+                        update.put("should_be", "否");
+                    } else {
                         update.put("should_slow", "否");
+                        update.put("should_be", "是");
                     }
-                    update.put("should_be", "否");
-                } else {
-                    update.put("should_slow", "否");
-                    update.put("should_be", "是");
-                }
 
-                System.out.println("secCount: " + secCount);
-                secCount++;
+                    System.out.println("secCount: " + secCount);
+                    secCount++;
+                }
+                this.updateData(new ArrayList(vannInfoMap.values()), count);
+                count++;
+                startPagte += 1000;
             }
-            this.updateData(new ArrayList(vannInfoMap.values()), count);
-            count++;
-            startPagte += 1000;
+        }catch (Exception e) {
+            e.printStackTrace();
         }
+
     }
 
     private List<JSONObject> getVaccInfo(int startPagte, int endPage) {