18 changed files with 770 additions and 295 deletions
@ -1,225 +1,233 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
<modelVersion>4.0.0</modelVersion> |
<modelVersion>4.0.0</modelVersion> |
||||||
<parent> |
<parent> |
||||||
<groupId>org.springframework.boot</groupId> |
<groupId>org.springframework.boot</groupId> |
||||||
<artifactId>spring-boot-starter-parent</artifactId> |
<artifactId>spring-boot-starter-parent</artifactId> |
||||||
<version>3.3.2</version> |
<version>3.3.2</version> |
||||||
<relativePath/> <!-- lookup parent from repository --> |
<relativePath/> <!-- lookup parent from repository --> |
||||||
</parent> |
</parent> |
||||||
<groupId>com.biutag</groupId> |
<groupId>com.biutag</groupId> |
||||||
<artifactId>supervision</artifactId> |
<artifactId>supervision</artifactId> |
||||||
<version>0.0.1-SNAPSHOT</version> |
<version>0.0.1-SNAPSHOT</version> |
||||||
<name>supervision</name> |
<name>supervision</name> |
||||||
<description>长沙公安数据督察</description> |
<description>长沙公安数据督察</description> |
||||||
<url/> |
<url/> |
||||||
<licenses> |
<licenses> |
||||||
<license/> |
<license/> |
||||||
</licenses> |
</licenses> |
||||||
<developers> |
<developers> |
||||||
<developer/> |
<developer/> |
||||||
</developers> |
</developers> |
||||||
<scm> |
<scm> |
||||||
<connection/> |
<connection/> |
||||||
<developerConnection/> |
<developerConnection/> |
||||||
<tag/> |
<tag/> |
||||||
<url/> |
<url/> |
||||||
</scm> |
</scm> |
||||||
<properties> |
<properties> |
||||||
<java.version>17</java.version> |
<java.version>17</java.version> |
||||||
</properties> |
</properties> |
||||||
<dependencies> |
<dependencies> |
||||||
<dependency> |
<dependency> |
||||||
<groupId>org.springframework.boot</groupId> |
<groupId>org.springframework.boot</groupId> |
||||||
<artifactId>spring-boot-starter-web</artifactId> |
<artifactId>spring-boot-starter-web</artifactId> |
||||||
</dependency> |
</dependency> |
||||||
|
|
||||||
<dependency> |
<!-- SQL Server JDBC驱动 --> |
||||||
<groupId>org.springframework.boot</groupId> |
<dependency> |
||||||
<artifactId>spring-boot-starter-validation</artifactId> |
<groupId>com.microsoft.sqlserver</groupId> |
||||||
</dependency> |
<artifactId>mssql-jdbc</artifactId> |
||||||
|
<version>9.4.0.jre11</version> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>org.springframework.boot</groupId> |
|
||||||
<artifactId>spring-boot-starter-data-redis-reactive</artifactId> |
<dependency> |
||||||
</dependency> |
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-starter-validation</artifactId> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>org.springframework.boot</groupId> |
|
||||||
<artifactId>spring-boot-devtools</artifactId> |
<dependency> |
||||||
<scope>runtime</scope> |
<groupId>org.springframework.boot</groupId> |
||||||
<optional>true</optional> |
<artifactId>spring-boot-starter-data-redis-reactive</artifactId> |
||||||
</dependency> |
</dependency> |
||||||
<dependency> |
|
||||||
<groupId>com.mysql</groupId> |
<dependency> |
||||||
<artifactId>mysql-connector-j</artifactId> |
<groupId>org.springframework.boot</groupId> |
||||||
<scope>runtime</scope> |
<artifactId>spring-boot-devtools</artifactId> |
||||||
</dependency> |
<scope>runtime</scope> |
||||||
<dependency> |
<optional>true</optional> |
||||||
<groupId>org.projectlombok</groupId> |
</dependency> |
||||||
<artifactId>lombok</artifactId> |
<dependency> |
||||||
<optional>true</optional> |
<groupId>com.mysql</groupId> |
||||||
</dependency> |
<artifactId>mysql-connector-j</artifactId> |
||||||
<dependency> |
<scope>runtime</scope> |
||||||
<groupId>org.springframework.boot</groupId> |
</dependency> |
||||||
<artifactId>spring-boot-starter-test</artifactId> |
<dependency> |
||||||
<scope>test</scope> |
<groupId>org.projectlombok</groupId> |
||||||
</dependency> |
<artifactId>lombok</artifactId> |
||||||
<dependency> |
<optional>true</optional> |
||||||
<groupId>io.projectreactor</groupId> |
</dependency> |
||||||
<artifactId>reactor-test</artifactId> |
<dependency> |
||||||
<scope>test</scope> |
<groupId>org.springframework.boot</groupId> |
||||||
</dependency> |
<artifactId>spring-boot-starter-test</artifactId> |
||||||
|
<scope>test</scope> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>com.baomidou</groupId> |
<dependency> |
||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId> |
<groupId>io.projectreactor</groupId> |
||||||
<version>3.5.7</version> |
<artifactId>reactor-test</artifactId> |
||||||
</dependency> |
<scope>test</scope> |
||||||
|
</dependency> |
||||||
<dependency> |
|
||||||
<groupId>com.alibaba</groupId> |
<dependency> |
||||||
<artifactId>easyexcel</artifactId> |
<groupId>com.baomidou</groupId> |
||||||
<version>4.0.1</version> |
<artifactId>mybatis-plus-spring-boot3-starter</artifactId> |
||||||
</dependency> |
<version>3.5.7</version> |
||||||
|
</dependency> |
||||||
<dependency> |
|
||||||
<groupId>commons-io</groupId> |
<dependency> |
||||||
<artifactId>commons-io</artifactId> |
<groupId>com.alibaba</groupId> |
||||||
<version>2.17.0</version> |
<artifactId>easyexcel</artifactId> |
||||||
</dependency> |
<version>4.0.1</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
<dependency> |
<dependency> |
||||||
<groupId>cn.hutool</groupId> |
<groupId>commons-io</groupId> |
||||||
<artifactId>hutool-core</artifactId> |
<artifactId>commons-io</artifactId> |
||||||
<version>5.8.29</version> |
<version>2.17.0</version> |
||||||
</dependency> |
</dependency> |
||||||
<dependency> |
|
||||||
<groupId>cn.hutool</groupId> |
|
||||||
<artifactId>hutool-http</artifactId> |
<dependency> |
||||||
<version>5.8.29</version> |
<groupId>cn.hutool</groupId> |
||||||
</dependency> |
<artifactId>hutool-core</artifactId> |
||||||
|
<version>5.8.29</version> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>com.baomidou</groupId> |
<dependency> |
||||||
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId> |
<groupId>cn.hutool</groupId> |
||||||
<version>4.3.1</version> |
<artifactId>hutool-http</artifactId> |
||||||
</dependency> |
<version>5.8.29</version> |
||||||
|
</dependency> |
||||||
<dependency> |
|
||||||
<groupId>org.freemarker</groupId> |
<dependency> |
||||||
<artifactId>freemarker</artifactId> |
<groupId>com.baomidou</groupId> |
||||||
<version>2.3.32</version> |
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId> |
||||||
<scope>test</scope> |
<version>4.3.1</version> |
||||||
</dependency> |
</dependency> |
||||||
|
|
||||||
<dependency> |
<dependency> |
||||||
<groupId>org.springframework.security</groupId> |
<groupId>org.freemarker</groupId> |
||||||
<artifactId>spring-security-crypto</artifactId> |
<artifactId>freemarker</artifactId> |
||||||
</dependency> |
<version>2.3.32</version> |
||||||
|
<scope>test</scope> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>com.github.tobato</groupId> |
|
||||||
<artifactId>fastdfs-client</artifactId> |
<dependency> |
||||||
<version>1.27.2</version> |
<groupId>org.springframework.security</groupId> |
||||||
</dependency> |
<artifactId>spring-security-crypto</artifactId> |
||||||
|
</dependency> |
||||||
<!--knife4j--> |
|
||||||
<dependency> |
<dependency> |
||||||
<groupId>com.github.xiaoymin</groupId> |
<groupId>com.github.tobato</groupId> |
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId> |
<artifactId>fastdfs-client</artifactId> |
||||||
<version>4.1.0</version> |
<version>1.27.2</version> |
||||||
</dependency> |
</dependency> |
||||||
|
|
||||||
<dependency> |
<!--knife4j--> |
||||||
<groupId>com.gbase</groupId> |
<dependency> |
||||||
<artifactId>gbase-jdbc</artifactId> |
<groupId>com.github.xiaoymin</groupId> |
||||||
<scope>system</scope> |
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId> |
||||||
<version>8.3.81.53-build55.2.1-bin</version> |
<version>4.1.0</version> |
||||||
<systemPath>${project.basedir}/src/main/resources/lib/gbase-connector-java-8.3.81.53-build52.8-bin.jar</systemPath> |
</dependency> |
||||||
</dependency> |
|
||||||
|
<dependency> |
||||||
<dependency> |
<groupId>com.gbase</groupId> |
||||||
<groupId>com.alibaba</groupId> |
<artifactId>gbase-jdbc</artifactId> |
||||||
<artifactId>druid-spring-boot-starter</artifactId> |
<scope>system</scope> |
||||||
<version>1.2.22</version> |
<version>8.3.81.53-build55.2.1-bin</version> |
||||||
</dependency> |
<systemPath>${project.basedir}/src/main/resources/lib/gbase-connector-java-8.3.81.53-build52.8-bin.jar |
||||||
|
</systemPath> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>com.alibaba</groupId> |
|
||||||
<artifactId>fastjson</artifactId> |
<dependency> |
||||||
<version>2.0.53</version> |
<groupId>com.alibaba</groupId> |
||||||
</dependency> |
<artifactId>druid-spring-boot-starter</artifactId> |
||||||
|
<version>1.2.22</version> |
||||||
<dependency> |
</dependency> |
||||||
<groupId>com.dameng</groupId> |
|
||||||
<artifactId>DmJdbcDriver18</artifactId> |
<dependency> |
||||||
<version>8.1.3.140</version> |
<groupId>com.alibaba</groupId> |
||||||
</dependency> |
<artifactId>fastjson</artifactId> |
||||||
|
<version>2.0.53</version> |
||||||
</dependencies> |
</dependency> |
||||||
|
|
||||||
<build> |
<dependency> |
||||||
<resources> |
<groupId>com.dameng</groupId> |
||||||
<resource> |
<artifactId>DmJdbcDriver18</artifactId> |
||||||
<directory>src/main/resources</directory> |
<version>8.1.3.140</version> |
||||||
<filtering>false</filtering> |
</dependency> |
||||||
</resource> |
|
||||||
<resource> |
</dependencies> |
||||||
<directory>src/main/resources</directory> |
|
||||||
<includes> |
<build> |
||||||
<include>application.yml</include> |
<resources> |
||||||
</includes> |
<resource> |
||||||
<filtering>true</filtering> |
<directory>src/main/resources</directory> |
||||||
</resource> |
<filtering>false</filtering> |
||||||
</resources> |
</resource> |
||||||
<plugins> |
<resource> |
||||||
<plugin> |
<directory>src/main/resources</directory> |
||||||
<groupId>org.springframework.boot</groupId> |
<includes> |
||||||
<artifactId>spring-boot-maven-plugin</artifactId> |
<include>application.yml</include> |
||||||
<configuration> |
</includes> |
||||||
<includeSystemScope>true</includeSystemScope> |
<filtering>true</filtering> |
||||||
<excludes> |
</resource> |
||||||
<exclude> |
</resources> |
||||||
<groupId>org.projectlombok</groupId> |
<plugins> |
||||||
<artifactId>lombok</artifactId> |
<plugin> |
||||||
</exclude> |
<groupId>org.springframework.boot</groupId> |
||||||
</excludes> |
<artifactId>spring-boot-maven-plugin</artifactId> |
||||||
</configuration> |
<configuration> |
||||||
</plugin> |
<includeSystemScope>true</includeSystemScope> |
||||||
</plugins> |
<excludes> |
||||||
|
<exclude> |
||||||
<finalName>supervision</finalName> |
<groupId>org.projectlombok</groupId> |
||||||
</build> |
<artifactId>lombok</artifactId> |
||||||
|
</exclude> |
||||||
<profiles> |
</excludes> |
||||||
<profile> |
</configuration> |
||||||
<id>local</id> |
</plugin> |
||||||
<properties> |
</plugins> |
||||||
<!-- 环境标识,需要与配置文件的名称相对应 --> |
|
||||||
<profiles.active>local</profiles.active> |
<finalName>supervision</finalName> |
||||||
</properties> |
</build> |
||||||
|
|
||||||
<activation> |
<profiles> |
||||||
<!-- 默认环境 --> |
<profile> |
||||||
<activeByDefault>true</activeByDefault> |
<id>local</id> |
||||||
</activation> |
<properties> |
||||||
</profile> |
<!-- 环境标识,需要与配置文件的名称相对应 --> |
||||||
<profile> |
<profiles.active>local</profiles.active> |
||||||
<id>dev</id> |
</properties> |
||||||
<properties> |
|
||||||
<!-- 环境标识,需要与配置文件的名称相对应 --> |
<activation> |
||||||
<profiles.active>dev</profiles.active> |
<!-- 默认环境 --> |
||||||
</properties> |
<activeByDefault>true</activeByDefault> |
||||||
</profile> |
</activation> |
||||||
<profile> |
</profile> |
||||||
<id>prod</id> |
<profile> |
||||||
<properties> |
<id>dev</id> |
||||||
<profiles.active>prod</profiles.active> |
<properties> |
||||||
</properties> |
<!-- 环境标识,需要与配置文件的名称相对应 --> |
||||||
</profile> |
<profiles.active>dev</profiles.active> |
||||||
</profiles> |
</properties> |
||||||
|
</profile> |
||||||
|
<profile> |
||||||
|
<id>prod</id> |
||||||
|
<properties> |
||||||
|
<profiles.active>prod</profiles.active> |
||||||
|
</properties> |
||||||
|
</profile> |
||||||
|
</profiles> |
||||||
|
|
||||||
</project> |
</project> |
||||||
@ -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<List<Map<String, Object>>> mapData(@RequestParam Map<String, Object> params) { |
|
||||||
if (params.isEmpty()) { |
|
||||||
// return Result.success(dataScreenService.mapData());
|
|
||||||
} else { |
|
||||||
String deptId = params.get("id").toString(); |
|
||||||
// return Result.success(dataScreenService.mapCountyData(deptId));
|
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -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<DataMigration> { |
||||||
|
|
||||||
|
@Select("SELECT * FROM data_migration WHERE end_time = (SELECT MAX(end_time) FROM data_migration)") |
||||||
|
DataMigration selectLastMigrationTime(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -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<DataPoliceMeeting> { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -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<DataPoliceMeetingV> { |
||||||
|
|
||||||
|
@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<DataPoliceMeetingV> 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<DataPoliceMeetingV> selectAimListWithPagination(LocalDateTime lastSelectTime, LocalDateTime now, int offset, int pageSize); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -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; |
||||||
|
} |
||||||
@ -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; |
||||||
|
} |
||||||
@ -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; |
||||||
|
} |
||||||
@ -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<DataMigrationMapper, DataMigration> { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private DataPoliceMeetingMysqlMapper dataPoliceMeetingMysqlMapper; |
||||||
|
@Resource |
||||||
|
private DataPoliceMeetingSqlServerMapper dataPoliceMeetingSqlServerMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private DataMigrationMapper dataMigrationMapper; // 迁移记录
|
||||||
|
|
||||||
|
private static final int BATCH_SIZE = 1000; // 每次处理的记录数
|
||||||
|
|
||||||
|
|
||||||
|
public List<DataPoliceMeetingV> 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<DataPoliceMeetingV> 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<DataPoliceMeetingV> 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<DataPoliceMeetingV> 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<DataPoliceMeetingV> 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("数据迁移失败"); |
||||||
|
* } |
||||||
|
*/ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in new issue