diff --git a/pom.xml b/pom.xml index db387a1..f933067 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,27 @@ com.microsoft.sqlserver mssql-jdbc - 9.4.0.jre11 + 12.8.1.jre11 + + + javax.xml.bind + jaxb-api + 2.3.0 + + + com.sun.xml.bind + jaxb-impl + 2.3.0 + + + com.sun.xml.bind + jaxb-core + 2.3.0 + + + javax.activation + activation + 1.1.1 diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java b/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java index 5591269..04a4d01 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java @@ -1,5 +1,6 @@ package com.biutag.supervision.pojo.entity; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -7,7 +8,6 @@ import lombok.Data; import java.io.Serializable; import java.time.LocalDateTime; -import java.util.Date; /** * 数据库迁移记录 @@ -19,7 +19,7 @@ public class DataMigration implements Serializable { /** * 数据迁移操作id */ - @TableId(value = "id") + @TableId(value = "id", type = IdType.AUTO) private Integer id; /** diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java index 75ff5b9..eeb8039 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java @@ -54,7 +54,7 @@ public class DataPoliceMeeting implements Serializable { * */ @TableField(value = "business_id") - private String businessId; + private Integer businessId; /** * diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java index 7d4884b..506e1b2 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java @@ -54,7 +54,7 @@ public class DataPoliceMeetingV implements Serializable { * */ @TableField(value = "business_id") - private String businessId; + private Integer businessId; /** * diff --git a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java index 46f44a7..ee5594a 100644 --- a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java +++ b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java @@ -46,6 +46,8 @@ public class BusinessDepartService extends ServiceImpl page(BusinessQueryParam businessQueryParam) { // 测基础数据 if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) { @@ -83,6 +85,12 @@ public class BusinessDepartService extends ServiceImpl getDataPoliceMeetingFromSqlServer(LocalDateTime lastSelectTime, LocalDateTime now) { return dataPoliceMeetingSqlServerMapper.selectAimList(lastSelectTime, now); } - - // @PostConstruct // public void startMigration() { // CompletableFuture.runAsync(() -> migrateData()); @@ -67,21 +52,20 @@ public class DataMigrationServiceImpl extends ServiceImpl dataPoliceMeetingFromSqlServerList; do { dataPoliceMeetingFromSqlServerList = getDataPoliceMeetingFromSqlServer(lastMigrationTime, LocalDateTime.now(), pageNum, pageSize); + System.out.println("查询到" + dataPoliceMeetingFromSqlServerList.size() + "条数据"); // 3、开始新的迁移 boolean migrationSuccessful = updateMigration(dataPoliceMeetingFromSqlServerList); total += dataPoliceMeetingFromSqlServerList.size(); @@ -92,30 +76,30 @@ public class DataMigrationServiceImpl extends ServiceImpl dataPoliceMeetingFromSqlServerList) { try { - - for (DataPoliceMeetingV dataPoliceMeetingV : dataPoliceMeetingFromSqlServerList) { - DataPoliceMeeting dataPoliceMeeting = new DataPoliceMeeting(); - BeanUtils.copyProperties(dataPoliceMeetingV, dataPoliceMeeting); - dataPoliceMeetingMysqlMapper.insert(dataPoliceMeeting); + if (!dataPoliceMeetingFromSqlServerList.isEmpty()) { + List dataPoliceMeetingList = new ArrayList<>(dataPoliceMeetingFromSqlServerList.size()); + for (DataPoliceMeetingV dataPoliceMeetingV : dataPoliceMeetingFromSqlServerList) { + DataPoliceMeeting dataPoliceMeeting = new DataPoliceMeeting(); + BeanUtils.copyProperties(dataPoliceMeetingV, dataPoliceMeeting); + dataPoliceMeetingList.add(dataPoliceMeeting); + } + System.out.println("准备插入" + dataPoliceMeetingList.size() + "条数据"); + dataPoliceMeetingMysqlMapper.insert(dataPoliceMeetingList); + System.out.println("插入成功"); } return true; } catch (BeansException e) { @@ -126,10 +110,10 @@ public class DataMigrationServiceImpl extends ServiceImpl getDataPoliceMeetingFromSqlServer(LocalDateTime lastSelectTime, LocalDateTime now, int pageNum, int pageSize) { int offset = (pageNum - 1) * pageSize; + System.out.println("开始查询sqlserver,offset:" + offset); return dataPoliceMeetingSqlServerMapper.selectAimListWithPagination(lastSelectTime, now, offset, pageSize); } - private void updateMigrationRecord(LocalDateTime startTime, LocalDateTime endTime, List dataPoliceMeetingFromSqlServerList) { DataMigration dataMigration = new DataMigration(); dataMigration.setTarget("sqlServer"); @@ -140,9 +124,6 @@ public class DataMigrationServiceImpl extends ServiceImpl