Kaynağa Gözat

同步数据

zhonghui 3 yıl önce
ebeveyn
işleme
d859920ef9

+ 2 - 1
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoUserService.java

@@ -1,5 +1,6 @@
 package com.boman.web.core.service.vaccineInfo;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.web.core.domain.VaccineInfoUser;
 
 import java.util.List;
@@ -25,5 +26,5 @@ public interface IVaccineInfoUserService {
     public List<VaccineInfoUser> selectInfoUserByIdCard(VaccineInfoUser vaccineInfoUser);
 
 
-    public void syncData() throws Exception;
+    public List<JSONObject> syncData() throws Exception;
 }

+ 42 - 52
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoUserServiceImpl.java

@@ -69,7 +69,7 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
      * 接种情况(是/否)
      * 人群分类
      */
-    public void syncData222() 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");
@@ -166,70 +166,53 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
             count++;
             startPagte += 1000;
         }
-    }
+    }*/
 
 
     @Override
-    public void syncData() throws Exception {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
+    public List<JSONObject> syncData() throws Exception {
+        List<JSONObject> datas = new ArrayList<>();
         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;
-
-            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("should_slow", "是");
-                        }else {
-                            update.put("should_slow", "否");
-                        }
-                        update.put("should_be", "否");
-                    } else {
+
+            List<JSONObject> jz = this.getvaccUser();
+            Map<String, JSONObject> vannInfoMap = new HashMap<>();
+
+            for (JSONObject jsonObject : jz) {
+                String idCard = jsonObject.getString("idCard");
+                JSONObject update = new JSONObject();
+                update.put("id_card", idCard);
+                vannInfoMap.put(idCard, update);
+            }
+            List<JSONObject> vaccInfos = this.getVaccInfo();
+            for (JSONObject vanninfo : vaccInfos) {
+                String idCard = vanninfo.getString("id_card");
+                JSONObject update = vannInfoMap.get(idCard);
+                String progress = vanninfo.getString("progress");
+                if(update == null) {
+                    update = new JSONObject();
+                    update.put("id_card", idCard);
+                    update.put("should_slow", "否");
+                    update.put("should_be", "是");
+                }else {
+                    if("否".equals(progress)) {
+                        update.put("should_slow", "是");
+                    }else {
                         update.put("should_slow", "否");
-                        update.put("should_be", "是");
                     }
-
-                    System.out.println("secCount: " + secCount);
-                    secCount++;
+                    update.put("should_be", "否");
                 }
-                this.updateData(new ArrayList(vannInfoMap.values()), count);
-                count++;
-                startPagte += 1000;
+                System.out.println(update.toJSONString());
+                datas.add(update);
             }
         }catch (Exception e) {
             e.printStackTrace();
         }
-
+        return datas;
     }
 
-    private List<JSONObject> getVaccInfo(int startPagte, int endPage) {
-        String sql = "select * from vaccine_info limit " + startPagte + ", " + endPage;
+    private List<JSONObject> getVaccInfo() {
+        String sql = "select id_card,progress from vaccine_info";
         List<JSONObject> objs = syncMapper.selectBySql(sql);
         return objs;
     }
@@ -248,7 +231,7 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
         return objs;
     }
 
-    private JSONObject getvaccUser(String idcard) {
+    /*private JSONObject getvaccUser(String idcard) {
         String sql = "SELECT id,`接种日期` as v_date,`生产厂家` as prod,`接种针次` as jici, "
                 + " `人群分类` as crowd_classification, `接种单位` as vaccination_place," +
                 " `电话号码` as phone_num , `出生日期` as 'csrq', `工作单位` as work_unit,  `生产厂家` as manufacturer"
@@ -258,6 +241,13 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
             return objs.get(0);
         }
         return null;
+    }*/
+
+    private List<JSONObject> getvaccUser() {
+        String sql = "SELECT `身份证` as idCard FROM ymjz ";
+        List<JSONObject> objs = syncMapper.selectBySql(sql);
+
+        return objs;
     }
 
     private String getTime(JSONObject userInfo, SimpleDateFormat sdf) throws Exception {