From bf5a56e66a62f6d448ddcd5be8734ac88152dbb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E7=88=B1=E5=AD=A6=E4=B9=A0=E7=9A=84=E7=9F=B3?=
=?UTF-8?q?=E5=90=8C=E5=AD=A6?= <2936013465@qq.com>
Date: Wed, 13 Nov 2024 20:44:37 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AD=A6=E5=8A=A1=E8=AF=84=E8=AE=AE=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 450 +++++++++---------
.../supervision/SupervisionApplication.java | 2 +
.../controller/datav/DataGobalController.java | 22 +-
.../DataPetitionComplaintViewController.java | 1 +
.../datav/DataScreenController.java | 44 --
.../datav/SupervisionNotifyController.java | 2 +-
.../mapper/DataMigrationMapper.java | 22 +
.../mapper/DataPoliceMeetingMysqlMapper.java | 21 +
.../DataPoliceMeetingSqlServerMapper.java | 37 ++
.../pojo/entity/DataMigration.java | 57 +++
.../pojo/entity/DataPoliceMeeting.java | 103 ++++
.../pojo/entity/DataPoliceMeetingV.java | 103 ++++
.../service/DataMigrationServiceImpl.java | 160 +++++++
src/main/resources/application-dev.yml | 5 +
src/main/resources/application-prod.yml | 5 +
15 files changed, 755 insertions(+), 279 deletions(-)
delete mode 100644 src/main/java/com/biutag/supervision/controller/datav/DataScreenController.java
create mode 100644 src/main/java/com/biutag/supervision/mapper/DataMigrationMapper.java
create mode 100644 src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java
create mode 100644 src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingSqlServerMapper.java
create mode 100644 src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java
create mode 100644 src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java
create mode 100644 src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java
create mode 100644 src/main/java/com/biutag/supervision/service/DataMigrationServiceImpl.java
diff --git a/pom.xml b/pom.xml
index 3a65b6b..63c17e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,225 +1,233 @@
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 3.3.2
-
-
- com.biutag
- supervision
- 0.0.1-SNAPSHOT
- supervision
- 长沙公安数据督察
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 17
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-validation
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis-reactive
-
-
-
- org.springframework.boot
- spring-boot-devtools
- runtime
- true
-
-
- com.mysql
- mysql-connector-j
- runtime
-
-
- org.projectlombok
- lombok
- true
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- io.projectreactor
- reactor-test
- test
-
-
-
- com.baomidou
- mybatis-plus-spring-boot3-starter
- 3.5.7
-
-
-
- com.alibaba
- easyexcel
- 4.0.1
-
-
-
- commons-io
- commons-io
- 2.17.0
-
-
-
-
- cn.hutool
- hutool-core
- 5.8.29
-
-
- cn.hutool
- hutool-http
- 5.8.29
-
-
-
- com.baomidou
- dynamic-datasource-spring-boot3-starter
- 4.3.1
-
-
-
- org.freemarker
- freemarker
- 2.3.32
- test
-
-
-
- org.springframework.security
- spring-security-crypto
-
-
-
- com.github.tobato
- fastdfs-client
- 1.27.2
-
-
-
-
- com.github.xiaoymin
- knife4j-openapi3-jakarta-spring-boot-starter
- 4.1.0
-
-
-
- com.gbase
- gbase-jdbc
- system
- 8.3.81.53-build55.2.1-bin
- ${project.basedir}/src/main/resources/lib/gbase-connector-java-8.3.81.53-build52.8-bin.jar
-
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.2.22
-
-
-
- com.alibaba
- fastjson
- 2.0.53
-
-
-
- com.dameng
- DmJdbcDriver18
- 8.1.3.140
-
-
-
-
-
-
-
- src/main/resources
- false
-
-
- src/main/resources
-
- application.yml
-
- true
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
-
-
- org.projectlombok
- lombok
-
-
-
-
-
-
- supervision
-
-
-
-
- local
-
-
- local
-
-
-
-
- true
-
-
-
- dev
-
-
- dev
-
-
-
- prod
-
- prod
-
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.3.2
+
+
+ com.biutag
+ supervision
+ 0.0.1-SNAPSHOT
+ supervision
+ 长沙公安数据督察
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 17
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ com.microsoft.sqlserver
+ mssql-jdbc
+ 9.4.0.jre11
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis-reactive
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ com.mysql
+ mysql-connector-j
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+
+ com.baomidou
+ mybatis-plus-spring-boot3-starter
+ 3.5.7
+
+
+
+ com.alibaba
+ easyexcel
+ 4.0.1
+
+
+
+ commons-io
+ commons-io
+ 2.17.0
+
+
+
+
+ cn.hutool
+ hutool-core
+ 5.8.29
+
+
+ cn.hutool
+ hutool-http
+ 5.8.29
+
+
+
+ com.baomidou
+ dynamic-datasource-spring-boot3-starter
+ 4.3.1
+
+
+
+ org.freemarker
+ freemarker
+ 2.3.32
+ test
+
+
+
+ org.springframework.security
+ spring-security-crypto
+
+
+
+ com.github.tobato
+ fastdfs-client
+ 1.27.2
+
+
+
+
+ com.github.xiaoymin
+ knife4j-openapi3-jakarta-spring-boot-starter
+ 4.1.0
+
+
+
+ com.gbase
+ gbase-jdbc
+ system
+ 8.3.81.53-build55.2.1-bin
+ ${project.basedir}/src/main/resources/lib/gbase-connector-java-8.3.81.53-build52.8-bin.jar
+
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.2.22
+
+
+
+ com.alibaba
+ fastjson
+ 2.0.53
+
+
+
+ com.dameng
+ DmJdbcDriver18
+ 8.1.3.140
+
+
+
+
+
+
+
+ src/main/resources
+ false
+
+
+ src/main/resources
+
+ application.yml
+
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+ supervision
+
+
+
+
+ local
+
+
+ local
+
+
+
+
+ true
+
+
+
+ dev
+
+
+ dev
+
+
+
+ prod
+
+ prod
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/biutag/supervision/SupervisionApplication.java b/src/main/java/com/biutag/supervision/SupervisionApplication.java
index f010b8f..e49e064 100644
--- a/src/main/java/com/biutag/supervision/SupervisionApplication.java
+++ b/src/main/java/com/biutag/supervision/SupervisionApplication.java
@@ -2,12 +2,14 @@ package com.biutag.supervision;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableAsync
@EnableScheduling
@SpringBootApplication
+@EnableAspectJAutoProxy
public class SupervisionApplication {
public static void main(String[] args) {
diff --git a/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java b/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java
index 0dd7443..22d1d6a 100644
--- a/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java
+++ b/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java
@@ -23,7 +23,6 @@ import java.util.stream.Collectors;
/**
* 数据大屏首页
- *
* @author: sh
* @date: 2024/11/7
*/
@@ -86,21 +85,18 @@ public class DataGobalController {
updateProList(policeProList, gobalMapVoList, GobalMapIconVo::setPolicePro);
updateProList(reviewProList, gobalMapVoList, GobalMapIconVo::setReviewPro);
}else {
-
gobalTempMapVoList.add(new GobalMapIconVo("芙蓉分局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("天心分局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("岳麓分局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("开福分局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("雨花分局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("长沙县局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("望城分局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("宁乡市局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("浏阳市局", 11,11,11,11,11,11));
- gobalTempMapVoList.add(new GobalMapIconVo("高新分局", 11,11,11,11,11,11));
+ gobalTempMapVoList.add(new GobalMapIconVo("天心分局", 22,22,22,22,22,22));
+ gobalTempMapVoList.add(new GobalMapIconVo("岳麓分局", 33,33,33,33,33,33));
+ gobalTempMapVoList.add(new GobalMapIconVo("开福分局", 44,44,44,44,44,44));
+ gobalTempMapVoList.add(new GobalMapIconVo("雨花分局", 55,55,55,55,55,55));
+ gobalTempMapVoList.add(new GobalMapIconVo("长沙县局", 66,66,66,66,66,66));
+ gobalTempMapVoList.add(new GobalMapIconVo("望城分局", 77,77,77,77,77,77));
+ gobalTempMapVoList.add(new GobalMapIconVo("宁乡市局", 88,88,88,88,88,88));
+ gobalTempMapVoList.add(new GobalMapIconVo("浏阳市局", 99,99,99,99,99,99));
+ gobalTempMapVoList.add(new GobalMapIconVo("高新分局", 100,100,100,100,100,100));
}
-
-
JSONObject data = new JSONObject().fluentPut("overview", overview)
.fluentPut("fxsjlist", fxsjlist)
.fluentPut("jsdwlist", jsdwlist)
diff --git a/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java b/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java
index f83fae4..b143481 100644
--- a/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java
+++ b/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java
@@ -32,6 +32,7 @@ import java.util.stream.Collectors;
/**
* @author: sh
* @date: 2024/10/31
+ * @description: 信访投诉大屏相关
*/
@Tag(name = "信访数据大屏选相关")
@RequestMapping("datav/mailVisits")
diff --git a/src/main/java/com/biutag/supervision/controller/datav/DataScreenController.java b/src/main/java/com/biutag/supervision/controller/datav/DataScreenController.java
deleted file mode 100644
index 321a693..0000000
--- a/src/main/java/com/biutag/supervision/controller/datav/DataScreenController.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.biutag.supervision.controller.datav;
-
-import com.biutag.supervision.pojo.Result;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.annotation.Resource;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author: sh
- * @date: 20224/11/5
- */
-@RestController
-@RequiredArgsConstructor
-@RequestMapping("datav/dataScreen")
-public class DataScreenController {
-
-
-// private final DataScreenService dataScreenService;
-
-
- /**
- * todo 获取地图数据
- */
- @GetMapping("/mapData")
- public Result>> mapData(@RequestParam Map params) {
- if (params.isEmpty()) {
-// return Result.success(dataScreenService.mapData());
- } else {
- String deptId = params.get("id").toString();
-// return Result.success(dataScreenService.mapCountyData(deptId));
- }
- return null;
- }
-
-}
diff --git a/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java b/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java
index 1604560..fb280fb 100644
--- a/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java
+++ b/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java
@@ -21,7 +21,7 @@ import java.util.List;
/**
* @Auther: sh
* @Date: 2024/11/7 10:30
- * @Description: 现场督察相关
+ * @Description: 现场督察大屏相关
*/
@Slf4j
@RestController
diff --git a/src/main/java/com/biutag/supervision/mapper/DataMigrationMapper.java b/src/main/java/com/biutag/supervision/mapper/DataMigrationMapper.java
new file mode 100644
index 0000000..7a4bbb5
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/mapper/DataMigrationMapper.java
@@ -0,0 +1,22 @@
+package com.biutag.supervision.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.biutag.supervision.pojo.entity.DataMigration;
+import org.apache.ibatis.annotations.Select;
+
+/**
+* @author 舒云
+* @description 针对表【data_migration】的数据库操作Mapper
+* @createDate 2024-11-13 11:21:19
+* @Entity generator.domain.DataMigration
+*/
+public interface DataMigrationMapper extends BaseMapper {
+
+ @Select("SELECT * FROM data_migration WHERE end_time = (SELECT MAX(end_time) FROM data_migration)")
+ DataMigration selectLastMigrationTime();
+}
+
+
+
+
diff --git a/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java
new file mode 100644
index 0000000..ae40c81
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java
@@ -0,0 +1,21 @@
+package com.biutag.supervision.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.biutag.supervision.pojo.entity.DataPoliceMeeting;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @author 舒云
+* @description 针对表【data_police_meeting】的数据库操作Mapper
+* @createDate 2024-11-13 09:43:04
+*/
+@DS("master")
+@Mapper
+public interface DataPoliceMeetingMysqlMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingSqlServerMapper.java b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingSqlServerMapper.java
new file mode 100644
index 0000000..89ee979
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingSqlServerMapper.java
@@ -0,0 +1,37 @@
+package com.biutag.supervision.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.biutag.supervision.pojo.entity.DataPoliceMeetingV;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+
+/**
+* @author 舒云
+* @createDate 2024-11-13 09:43:04
+*/
+@DS("test1")
+@Mapper
+public interface DataPoliceMeetingSqlServerMapper extends BaseMapper {
+
+ @Select("select max(create_time) from data_police_meeting")
+ LocalDateTime selectMaxCreateTime();
+
+ @Select("select * from data_police_meeting where create_time > #{lastSelectTime} and create_time <= #{now}")
+ List selectAimList(LocalDateTime lastSelectTime, LocalDateTime now);
+
+
+ @Select("SELECT * FROM SampleResultPoolView " +
+ "WHERE create_time > #{lastSelectTime} AND create_time <= #{now} " +
+ "ORDER BY create_time " +
+ "OFFSET #{offset} ROWS FETCH NEXT #{pageSize} ROWS ONLY")
+ List selectAimListWithPagination(LocalDateTime lastSelectTime, LocalDateTime now, int offset, int pageSize);
+}
+
+
+
+
diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java b/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java
new file mode 100644
index 0000000..5591269
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/pojo/entity/DataMigration.java
@@ -0,0 +1,57 @@
+package com.biutag.supervision.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 数据库迁移记录
+ * @TableName data_migration
+ */
+@TableName(value ="data_migration")
+@Data
+public class DataMigration implements Serializable {
+ /**
+ * 数据迁移操作id
+ */
+ @TableId(value = "id")
+ private Integer id;
+
+ /**
+ * 来源库
+ */
+ @TableField(value = "target")
+ private String target;
+
+ /**
+ * 开始时间
+ */
+ @TableField(value = "start_time")
+ private LocalDateTime startTime;
+
+ /**
+ * 结束时间
+ */
+ @TableField(value = "end_time")
+ private LocalDateTime endTime;
+
+ /**
+ * 迁移数量
+ */
+ @TableField(value = "migration_count")
+ private String migrationCount;
+
+ /**
+ * 目标表最大时间
+ */
+ @TableField(value = "target_max_time")
+ private LocalDateTime targetMaxTime;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java
new file mode 100644
index 0000000..75ff5b9
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java
@@ -0,0 +1,103 @@
+package com.biutag.supervision.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * mysql中negative中data_police_meeting表的实体类
+ * @TableName data_police_meeting
+ */
+@TableName(value ="data_police_meeting")
+@Data
+public class DataPoliceMeeting implements Serializable {
+ /**
+ *
+ */
+ @TableField(value = "sample_id")
+ private Integer sampleId;
+
+ /**
+ *
+ */
+ @TableField(value = "name")
+ private String name;
+
+ /**
+ *
+ */
+ @TableField(value = "visit_name")
+ private String visitName;
+
+ /**
+ *
+ */
+ @TableField(value = "visit_phone")
+ private String visitPhone;
+
+ /**
+ *
+ */
+ @TableField(value = "organize_id")
+ private String organizeId;
+
+ /**
+ *
+ */
+ @TableField(value = "org_name")
+ private String orgName;
+
+ /**
+ *
+ */
+ @TableField(value = "business_id")
+ private String businessId;
+
+ /**
+ *
+ */
+ @TableField(value = "business_name")
+ private String businessName;
+
+ /**
+ *
+ */
+ @TableField(value = "sample_time")
+ private Date sampleTime;
+
+ /**
+ *
+ */
+ @TableField(value = "create_time")
+ private Date createTime;
+
+ /**
+ *
+ */
+ @TableField(value = "sample_content")
+ private String sampleContent;
+
+ /**
+ *
+ */
+ @TableField(value = "visitime")
+ private Date visitime;
+
+ /**
+ *
+ */
+ @TableField(value = "result_name")
+ private String resultName;
+
+ /**
+ *
+ */
+ @TableField(value = "code")
+ private String code;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java
new file mode 100644
index 0000000..7d4884b
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeetingV.java
@@ -0,0 +1,103 @@
+package com.biutag.supervision.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * sqlServer数据库SampleResultPoolView视图实体类
+ * @TableName SampleResultPoolView
+ */
+@TableName(value ="SampleResultPoolView")
+@Data
+public class DataPoliceMeetingV implements Serializable {
+ /**
+ *
+ */
+ @TableField(value = "sample_id")
+ private Integer sampleId;
+
+ /**
+ *
+ */
+ @TableField(value = "name")
+ private String name;
+
+ /**
+ *
+ */
+ @TableField(value = "visit_name")
+ private String visitName;
+
+ /**
+ *
+ */
+ @TableField(value = "visit_phone")
+ private String visitPhone;
+
+ /**
+ *
+ */
+ @TableField(value = "organize_id")
+ private String organizeId;
+
+ /**
+ *
+ */
+ @TableField(value = "org_name")
+ private String orgName;
+
+ /**
+ *
+ */
+ @TableField(value = "business_id")
+ private String businessId;
+
+ /**
+ *
+ */
+ @TableField(value = "business_name")
+ private String businessName;
+
+ /**
+ *
+ */
+ @TableField(value = "sample_time")
+ private Date sampleTime;
+
+ /**
+ *
+ */
+ @TableField(value = "create_time")
+ private Date createTime;
+
+ /**
+ *
+ */
+ @TableField(value = "sample_content")
+ private String sampleContent;
+
+ /**
+ *
+ */
+ @TableField(value = "visitime")
+ private Date visitime;
+
+ /**
+ *
+ */
+ @TableField(value = "result_name")
+ private String resultName;
+
+ /**
+ *
+ */
+ @TableField(value = "code")
+ private String code;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/biutag/supervision/service/DataMigrationServiceImpl.java b/src/main/java/com/biutag/supervision/service/DataMigrationServiceImpl.java
new file mode 100644
index 0000000..bcb6fe0
--- /dev/null
+++ b/src/main/java/com/biutag/supervision/service/DataMigrationServiceImpl.java
@@ -0,0 +1,160 @@
+package com.biutag.supervision.service;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.biutag.supervision.mapper.DataMigrationMapper;
+import com.biutag.supervision.mapper.DataPoliceMeetingMysqlMapper;
+import com.biutag.supervision.mapper.DataPoliceMeetingSqlServerMapper;
+import com.biutag.supervision.pojo.entity.DataMigration;
+import com.biutag.supervision.pojo.entity.DataPoliceMeeting;
+import com.biutag.supervision.pojo.entity.DataPoliceMeetingV;
+import jakarta.annotation.PostConstruct;
+import jakarta.annotation.Resource;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.DateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Stream;
+
+/**
+ * @author 舒云
+ * @description 针对表【data_migration】的数据库操作Service实现
+ * @createDate 2024-11-13 11:21:19
+ */
+@Service
+//@EnableAsync
+public class DataMigrationServiceImpl extends ServiceImpl {
+
+ @Resource
+ private DataPoliceMeetingMysqlMapper dataPoliceMeetingMysqlMapper;
+ @Resource
+ private DataPoliceMeetingSqlServerMapper dataPoliceMeetingSqlServerMapper;
+
+ @Resource
+ private DataMigrationMapper dataMigrationMapper; // 迁移记录
+
+ private static final int BATCH_SIZE = 1000; // 每次处理的记录数
+
+
+ public List getDataPoliceMeetingFromSqlServer(LocalDateTime lastSelectTime, LocalDateTime now) {
+ return dataPoliceMeetingSqlServerMapper.selectAimList(lastSelectTime, now);
+ }
+
+
+ @PostConstruct
+ public void startMigration() {
+ CompletableFuture.runAsync(() -> migrateData());
+ }
+
+ /* @Async
+ public void migrateDataAsync() {
+ migrateData();
+ }*/
+ // @Scheduled(cron = "*/10 * * * * ?")
+
+ @Async
+ public void migrateData() {
+
+ LocalDateTime startTime = LocalDateTime.now(); // 开始迁移时间
+ // 1. 查询数据库中最后一次迁移的时间
+ DataMigration lastMigration = dataMigrationMapper.selectLastMigrationTime();
+ LocalDateTime lastMigrationTime = (lastMigration == null || lastMigration.getTargetMaxTime() == null)
+ ? LocalDateTime.of(1970, 1, 1, 0, 0)
+ : lastMigration.getTargetMaxTime();
+
+ // 2、准备数据
+ int pageNum = 1;
+ int pageSize = 1000;
+ Long total = 0L;
+ List dataPoliceMeetingFromSqlServerList;
+ do {
+ dataPoliceMeetingFromSqlServerList = getDataPoliceMeetingFromSqlServer(lastMigrationTime, LocalDateTime.now(), pageNum, pageSize);
+ // 3、开始新的迁移
+ boolean migrationSuccessful = updateMigration(dataPoliceMeetingFromSqlServerList);
+ total += dataPoliceMeetingFromSqlServerList.size();
+ if (!migrationSuccessful) {
+ System.out.println("数据迁移失败");
+ return;
+ }
+ pageNum++;
+ } while (!dataPoliceMeetingFromSqlServerList.isEmpty());
+ LocalDateTime endTime = LocalDateTime.now();
+
+ // updateMigrationRecord(startTime, endTime, dataPoliceMeetingFromSqlServerList);
+
+
+ DataMigration dataMigration = new DataMigration();
+ dataMigration.setTarget("sqlServer");
+ dataMigration.setStartTime(startTime);
+ dataMigration.setEndTime(endTime);
+ dataMigration.setMigrationCount(total.toString());
+ LocalDateTime maxCreateTime = dataPoliceMeetingSqlServerMapper.selectMaxCreateTime();
+ dataMigration.setTargetMaxTime(maxCreateTime);
+ dataMigrationMapper.insert(dataMigration);
+
+
+ System.out.println("数据迁移成功");
+ }
+
+ private boolean updateMigration(List dataPoliceMeetingFromSqlServerList) {
+ try {
+
+ for (DataPoliceMeetingV dataPoliceMeetingV : dataPoliceMeetingFromSqlServerList) {
+ DataPoliceMeeting dataPoliceMeeting = new DataPoliceMeeting();
+ BeanUtils.copyProperties(dataPoliceMeetingV, dataPoliceMeeting);
+ dataPoliceMeetingMysqlMapper.insert(dataPoliceMeeting);
+ }
+ return true;
+ } catch (BeansException e) {
+ return false;
+ }
+ }
+
+ // 大数据分页查询
+ public List getDataPoliceMeetingFromSqlServer(LocalDateTime lastSelectTime, LocalDateTime now, int pageNum, int pageSize) {
+ int offset = (pageNum - 1) * pageSize;
+ return dataPoliceMeetingSqlServerMapper.selectAimListWithPagination(lastSelectTime, now, offset, pageSize);
+ }
+
+
+ private void updateMigrationRecord(LocalDateTime startTime, LocalDateTime endTime, List dataPoliceMeetingFromSqlServerList) {
+ DataMigration dataMigration = new DataMigration();
+ dataMigration.setTarget("sqlServer");
+ dataMigration.setStartTime(startTime);
+ dataMigration.setEndTime(endTime);
+ dataMigration.setMigrationCount(String.valueOf(dataPoliceMeetingFromSqlServerList.size()));
+ LocalDateTime maxCreateTime = dataPoliceMeetingSqlServerMapper.selectMaxCreateTime();
+ dataMigration.setTargetMaxTime(maxCreateTime);
+ dataMigrationMapper.insert(dataMigration);
+ }
+
+ /**
+ * boolean migrationSuccessful = updateMigration(dataPoliceMeetingFromSqlServerList);
+ * if (migrationSuccessful) {
+ * LocalDateTime endTime = LocalDateTime.now(); // 结束迁移时间
+ * // 4、更新迁移记录
+ * updateMigrationRecord(startTime, endTime, dataPoliceMeetingFromSqlServerList);
+ * System.out.println("数据迁移成功");
+ * } else {
+ * System.out.println("数据迁移失败");
+ * }
+ */
+
+}
+
+
+
+
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index b2c2506..614af7b 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -26,6 +26,11 @@ spring:
url: jdbc:mysql://172.31.217.20:31868/negative?serverTimezone=GMT%2B8
username: root
password: ip12341234
+ test1:
+ url: jdbc:sqlserver://8.155.28.101:1433;databaseName=test1
+ username: SA
+ password: shihao&&200003
+ driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
druid:
min-evictable-idle-time-millis: 300000
test-on-borrow: false
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index fbbc244..4b5eaac 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -26,6 +26,11 @@ spring:
url: jdbc:dm://65.47.22.243:5236?SCHEMA=JSDZ_4GDB
username: DCZD
password: DCZD@2024
+ test1:
+ url: jdbc:sqlserver://65.47.6.114:1433;databaseName=VisitManage_CS
+ username: ck1112
+ password: CK@20241112
+ driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
druid:
min-evictable-idle-time-millis: 300000
test-on-borrow: false