Browse Source

同步数据

zhonghui 3 years ago
parent
commit
a1e01c7e41

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

@@ -121,4 +121,8 @@ public class VaccineInfoController extends BaseController {
         return AjaxResult.success(hjInfo);
     }
 
+    @PostMapping("/syncData")
+    public void syncData() {
+        vaccineInfoService.syncData();
+    }
 }

+ 5 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoMapper.java

@@ -30,6 +30,9 @@ public interface VaccineInfoMapper
      */
     public List<VaccineInfoOperation> selectVaccineInfoList(VaccineInfoOperation vaccineInfo);
 
+
+    public List<VaccineInfoOperation> selectVaccineInfoListByPage(int startNum, int endNum);
+
     /**
      * 新增疫苗信息
      * 
@@ -76,4 +79,6 @@ public interface VaccineInfoMapper
      * @return
      */
     public String selectSysDictDataByDictLabel(String vaccineName);
+
+    public int selectCount();
 }

+ 2 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoService.java

@@ -66,4 +66,6 @@ public interface IVaccineInfoService
      * @return
      */
     public VaccineInfoOperation  findHjInfo(VaccineInfoOperation vaccineInfo);
+
+    public void syncData();
 }

+ 30 - 1
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -4,6 +4,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.StringUtils;
@@ -13,7 +14,7 @@ import com.boman.web.core.domain.VaccineInfoUser;
 import com.boman.web.core.mapper.VaccineInfoOperationMapper;
 import com.boman.web.core.mapper.VaccineInfoUserMapper;
 import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
-import org.springframework.beans.factory.annotation.Autowired;
+
 import org.springframework.stereotype.Service;
 import com.boman.web.core.mapper.VaccineInfoMapper;
 import org.springframework.transaction.annotation.Isolation;
@@ -41,6 +42,34 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
     @Resource
     private VaccineInfoUserMapper vaccineInfoUserMapper;
 
+    public void syncData() {
+        int count = vaccineInfoMapper.selectCount();
+        int times = count / 1000;
+        int startPage = 0;
+        int endPage = 1000;
+        for (int i = 0;i < times + 1;i++) {
+            List<VaccineInfoOperation> list = vaccineInfoMapper.selectVaccineInfoListByPage(startPage, endPage);
+
+
+
+
+            startPage += 1000;
+        }
+
+    }
+
+    private void save(List<VaccineInfoOperation> list) {
+        for(VaccineInfoOperation operation : list) {
+            vaccineInfoMapper.insertVaccineInfo(operation);
+        }
+    }
+
+    public static void main(String[] args) {
+        int count = 581208;
+        int times = count / 1000;
+        System.out.println(times);
+    }
+
     /**
      * 查询疫苗信息
      *

+ 10 - 1
boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml

@@ -110,7 +110,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         order by vi.create_time DESC
     </select>
-    
+
+    <select id="selectVaccineInfoListByPage" parameterType="Integer" resultMap="VaccineInfoResult">
+        select * from vaccine_info limit   #{startNum}, #{endNum}
+    </select>
+
+
+    <select id="selectCount" parameterType="Long" resultMap="int">
+      select count(1) from vaccine_info
+    </select>
+
     <select id="selectVaccineInfoById" parameterType="Long" resultMap="VaccineInfoResult">
         <include refid="selectVaccineInfoVo"/>
         where vi.id = #{id} and vi.is_del = 'N'