zhonghui 3 年 前
コミット
8a19ac66e6

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/controller/VaccineInfoController.java

@@ -147,7 +147,7 @@ public class VaccineInfoController extends BaseController {
     /**
      * 根据身份证号查询用户疫苗信息集合
      */
-    @PostMapping("/syncData")
+    @PostMapping("/syncDataTest")
     public AjaxResult syncData() throws Exception {
         vaccineInfoUserService.syncData();
         return AjaxResult.success();

+ 56 - 3
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoUserServiceImpl.java

@@ -69,8 +69,7 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
      * 接种情况(是/否)
      * 人群分类
      */
-    @Override
-    public void syncData() throws Exception {
+    public void syncData222() throws Exception {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         // 获取疫苗信息,每次处理1000条
         int counts = syncMapper.selectCount("select count(1) from vaccine_info");
@@ -169,8 +168,62 @@ 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;
+        int counts = 1;
+        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<>();
+
+            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("shouldSlow", "是");
+                    }else {
+                        update.put("shouldSlow", "否");
+                    }
+                    update.put("should_be", "否");
+                } else {
+                    update.put("shouldSlow", "否");
+                    update.put("should_be", "是");
+                }
+
+                System.out.println("secCount: " + secCount);
+                secCount++;
+            }
+            this.updateData(new ArrayList(vannInfoMap.values()), count);
+            count++;
+            startPagte += 1000;
+        }
+    }
+
     private List<JSONObject> getVaccInfo(int startPagte, int endPage) {
-        String sql = "select * from vaccine_info limit " + startPagte + ", " + endPage;
+        String sql = "select * from vaccine_info where id_card = '11010819710505603X' limit " + startPagte + ", " + endPage;
         List<JSONObject> objs = syncMapper.selectBySql(sql);
         return objs;
     }