bihuisong hai 2 meses
achega
6f161daa65
Modificáronse 21 ficheiros con 1136 adicións e 0 borrados
  1. 150 0
      pom.xml
  2. 39 0
      src/main/java/com/sooka/sponest/monitor/SookaMonitorLineChartsApplication.java
  3. 11 0
      src/main/java/com/sooka/sponest/monitor/base/controller/BaseController.java
  4. 52 0
      src/main/java/com/sooka/sponest/monitor/base/domain/BaseBusinessEntity.java
  5. 13 0
      src/main/java/com/sooka/sponest/monitor/base/domain/DataTestVO.java
  6. 73 0
      src/main/java/com/sooka/sponest/monitor/base/service/impl/BaseService.java
  7. 19 0
      src/main/java/com/sooka/sponest/monitor/base/util/database/DynamicDataSource.java
  8. 41 0
      src/main/java/com/sooka/sponest/monitor/base/util/database/DynamicDataSourceAspect.java
  9. 41 0
      src/main/java/com/sooka/sponest/monitor/base/util/database/DynamicDataSourceSwitcher.java
  10. 4 0
      src/main/java/com/sooka/sponest/monitor/base/util/database/GlobalTransactionalRabbitMQ.java
  11. 136 0
      src/main/java/com/sooka/sponest/monitor/base/util/database/MultipleDataSourceConfig.java
  12. 15 0
      src/main/java/com/sooka/sponest/monitor/base/util/database/MyDataSource.java
  13. 119 0
      src/main/java/com/sooka/sponest/monitor/camera/controller/IndexLineChartCountTaskController.java
  14. 26 0
      src/main/java/com/sooka/sponest/monitor/camera/domain/IndexLineChartsVo.java
  15. 42 0
      src/main/java/com/sooka/sponest/monitor/camera/mapper/CentermonitorTCameraMapper.java
  16. 42 0
      src/main/java/com/sooka/sponest/monitor/camera/service/ICentermonitorTCameraService.java
  17. 59 0
      src/main/java/com/sooka/sponest/monitor/camera/service/impl/CentermonitorTCameraServiceImpl.java
  18. 78 0
      src/main/java/com/sooka/sponest/monitor/util/BeanUtil.java
  19. 9 0
      src/main/resources/banner.txt
  20. 26 0
      src/main/resources/bootstrap.yml
  21. 141 0
      src/main/resources/mapper/monitor/camera/CentermonitorTCameraMapper.xml

+ 150 - 0
pom.xml

@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ruoyi-modules</artifactId>
+        <groupId>com.ruoyi</groupId>
+        <version>3.4.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.sooka.onest</groupId>
+    <artifactId>center-monitor-lineCharts</artifactId>
+
+
+    <dependencies>
+        <!-- SpringCloud Alibaba Nacos -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+
+        <!-- SpringCloud Alibaba Nacos Config -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+
+        <!-- SpringCloud Alibaba Sentinel -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
+        </dependency>
+
+        <!-- Sentinel Datasource Nacos -->
+        <dependency>
+            <groupId>com.alibaba.csp</groupId>
+            <artifactId>sentinel-datasource-nacos</artifactId>
+        </dependency>
+
+        <!-- SpringBoot Actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+
+        <!-- Swagger UI -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger.fox.version}</version>
+        </dependency>
+
+        <!-- Mysql Connector -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common DataSource -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>sooka-sponest-common-datasource</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common DataScope -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>sooka-sponest-common-datascope</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common Log -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>sooka-sponest-common-log</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common Swagger -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>sooka-sponest-common-swagger</artifactId>
+        </dependency>
+
+        <!--海康-->
+        <dependency>
+            <groupId>com.hikvision.ga</groupId>
+            <artifactId>artemis-http-client</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+
+        <!-- ICC鉴权 -->
+        <dependency>
+            <groupId>com.dahuatech.icc</groupId>
+            <artifactId>java-sdk-oauth</artifactId>
+            <version>1.0.9</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>java-sdk-core</artifactId>
+                    <groupId>com.dahuatech.icc</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>com.dahuatech.icc</groupId>
+            <artifactId>java-sdk-core</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+
+        <!-- mp4文件操作jar -->
+        <!-- https://mvnrepository.com/artifact/com.googlecode.mp4parser/isoparser -->
+        <dependency>
+            <groupId>com.googlecode.mp4parser</groupId>
+            <artifactId>isoparser</artifactId>
+            <version>1.1.22</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.1.5.RELEASE</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-resources-plugin</artifactId>
+                <configuration>
+                    <nonFilteredFileExtensions>
+                        <nonFilteredFileExtension>xdb</nonFilteredFileExtension>
+                    </nonFilteredFileExtensions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+

+ 39 - 0
src/main/java/com/sooka/sponest/monitor/SookaMonitorLineChartsApplication.java

@@ -0,0 +1,39 @@
+package com.sooka.sponest.monitor;
+
+import com.ruoyi.common.security.annotation.EnableCustomConfig;
+import com.ruoyi.common.security.annotation.EnableRyFeignClients;
+import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.MultipartConfigFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.util.unit.DataSize;
+
+import javax.servlet.MultipartConfigElement;
+
+@EnableAsync
+@EnableCustomConfig
+@EnableCustomSwagger2
+@EnableRyFeignClients
+@SpringBootApplication
+public class SookaMonitorLineChartsApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(SookaMonitorLineChartsApplication.class, args);
+        System.out.println("(♥◠‿◠)ノ゙  首佳科技 一体化 监控中心首页折线图缓存任务 启动成功   ლ(´ڡ`ლ)゙  \n" +
+                "  __________   ____ |  | _______          ____________   ____   ____   ____   _______/  |_\n" +
+                " /  ___/  _ \\ /  _ \\|  |/ /\\__  \\        /  ___/\\____ \\ /  _ \\ /    \\_/ __ \\ /  ___/\\   __\\\n" +
+                " \\___ (  <_> |  <_> )    <  / __ \\_      \\___ \\ |  |_> >  <_> )   |  \\  ___/ \\___ \\  |  |\n" +
+                "/____  >____/ \\____/|__|_ \\(____  /     /____  >|   __/ \\____/|___|  /\\___  >____  > |__|\n" +
+                "     \\/                  \\/     \\/           \\/ |__|               \\/     \\/     \\/\n"
+        );
+    }
+
+    @Bean
+    public MultipartConfigElement multipartConfigElement() {
+        MultipartConfigFactory factory = new MultipartConfigFactory();
+        factory.setMaxFileSize(DataSize.parse("10240000KB"));
+        factory.setMaxRequestSize(DataSize.parse("10240000KB"));
+        return factory.createMultipartConfig();
+    }
+}

+ 11 - 0
src/main/java/com/sooka/sponest/monitor/base/controller/BaseController.java

@@ -0,0 +1,11 @@
+package com.sooka.sponest.monitor.base.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/BaseController")
+public class BaseController {
+
+
+}

+ 52 - 0
src/main/java/com/sooka/sponest/monitor/base/domain/BaseBusinessEntity.java

@@ -0,0 +1,52 @@
+package com.sooka.sponest.monitor.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Getter
+@Setter
+public class BaseBusinessEntity {
+
+    /**
+     * 搜索值
+     */
+    String searchValue;
+
+    Long dataDeptId;
+
+    /**
+     * 创建者
+     */
+    Long createBy;
+    /**
+     * 创建者
+     */
+    String remark;
+    /**
+     * 请求参数
+     */
+    Map<String, Object> params = new HashMap();
+    String database_system;
+    String database_event;
+    String database_data;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime = new Date();
+    /**
+     * 更新者
+     */
+    private Long updateBy;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+}

+ 13 - 0
src/main/java/com/sooka/sponest/monitor/base/domain/DataTestVO.java

@@ -0,0 +1,13 @@
+package com.sooka.sponest.monitor.base.domain;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class DataTestVO extends BaseBusinessEntity {
+
+    String name;
+
+
+}

+ 73 - 0
src/main/java/com/sooka/sponest/monitor/base/service/impl/BaseService.java

@@ -0,0 +1,73 @@
+package com.sooka.sponest.monitor.base.service.impl;
+
+import com.ruoyi.common.datascope.base.domain.BaseBusinessEntity;
+import com.ruoyi.common.redis.service.RedisService;
+import com.ruoyi.common.security.service.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BaseService {
+
+    @Value("${sooka.database.database_system:}")
+    public String database_system;
+    @Value("${sooka.database.database_event:}")
+    public String database_event;
+    @Value("${sooka.database.database_data:}")
+    public String database_data;
+    @Value("${sooka.dahua_video_server.loginIp:}")
+    public String loginIp;
+    @Value("${sooka.dahua_video_server.userName:}")
+    public String userName;
+    @Value("${sooka.dahua_video_server.userPwd:}")
+    public String userPwd;
+    @Value("${sooka.dahua_video_server.loginPort:}")
+    public Integer loginPort;
+    //app
+    @Value("${sooka.dahua_video_server_app.loginIpApp:}")
+    public String loginIpApp;
+    @Value("${sooka.dahua_video_server_app.userNameApp:}")
+    public String userNameApp;
+    @Value("${sooka.dahua_video_server_app.userPwdApp:}")
+    public String userPwdApp;
+    @Value("${sooka.dahua_video_server_app.loginPortApp:}")
+    public Integer loginPortApp;
+    //
+    @Value("${sooka.dahua_dss_server.host:}")
+    public String host;
+    @Value("${sooka.dahua_dss_server.user_name:}")
+    public String user_name;
+    @Value("${sooka.dahua_dss_server.password:}")
+    public String password;
+    @Value("${sooka.dahua_dss_server.client_id:}")
+    public String client_id;
+    @Value("${sooka.dahua_dss_server.client_secret:}")
+    public String client_secret;
+    @Value("${sooka.dahua_dss_server.version:}")
+    public String version;
+    @Value("${sooka.dahua_dss_server.video_download_url_linux:}")
+    public String videoDownloadUrlLinux;
+    @Value("${sooka.dahua_dss_server.video_download_url_win:}")
+    public String videoDownloadUrlWin;
+    @Value("${sooka.haikang_video_server.loginIp:}")
+    public String HkloginIp;
+    @Value("${sooka.haikang_video_server.appkey:}")
+    public String Hkappkey;
+    @Value("${sooka.haikang_video_server.secret:}")
+    public String Hksecret;
+    @Value("${sooka.haikang_video_server.loginPort:}")
+    public String HkloginPort;
+    @Autowired
+    TokenService tokenService;
+    @Autowired
+    private RedisService redisService;
+
+    public void setSookaDataBase(BaseBusinessEntity entity) {
+        entity.setDatabase_system(this.database_system);
+        entity.setDatabase_event(this.database_event);
+        entity.setDatabase_data(this.database_data);
+    }
+
+}
+

+ 19 - 0
src/main/java/com/sooka/sponest/monitor/base/util/database/DynamicDataSource.java

@@ -0,0 +1,19 @@
+package com.sooka.sponest.monitor.base.util.database;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
+
+
+public class DynamicDataSource extends AbstractRoutingDataSource {
+
+    Logger logger = LoggerFactory.getLogger(DynamicDataSource.class);
+
+    @Override
+    protected Object determineCurrentLookupKey() {
+        String datasource = DynamicDataSourceSwitcher.getDataSource();
+        logger.info("------------------当前数据源 {}", DynamicDataSourceSwitcher.getDataSource());
+        return DynamicDataSourceSwitcher.getDataSource();
+    }
+}

+ 41 - 0
src/main/java/com/sooka/sponest/monitor/base/util/database/DynamicDataSourceAspect.java

@@ -0,0 +1,41 @@
+package com.sooka.sponest.monitor.base.util.database;
+
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+@Aspect
+@Component
+@Order(1)
+public class DynamicDataSourceAspect {
+    private Logger logger = LoggerFactory.getLogger(DynamicDataSourceAspect.class);
+
+    /**
+     * 切入点只对@Service注解的类上的@DataSource方法生效
+     *
+     * @param myDataSource
+     */
+    @Pointcut(value = "(@within(org.springframework.stereotype.Service) ||@within(org.springframework.stereotype.Repository)) && @annotation(myDataSource)")
+    public void dynamicDataSourcePointCut(MyDataSource myDataSource) {
+    }
+
+    @Before(value = "dynamicDataSourcePointCut(myDataSource)")
+    public void switchDataSource(MyDataSource myDataSource) {
+        DynamicDataSourceSwitcher.setDataSource(myDataSource.value());
+    }
+
+    /**
+     * 切点执行完后 切换成主数据库
+     *
+     * @param myDataSource
+     */
+    @After(value = "dynamicDataSourcePointCut(myDataSource)")
+    public void after(MyDataSource myDataSource) {
+        DynamicDataSourceSwitcher.cleanDataSource();
+    }
+}

+ 41 - 0
src/main/java/com/sooka/sponest/monitor/base/util/database/DynamicDataSourceSwitcher.java

@@ -0,0 +1,41 @@
+package com.sooka.sponest.monitor.base.util.database;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DynamicDataSourceSwitcher {
+
+    public static final String Master = "master";
+    public static final String dbCenterTtranmanager = "db-center-tranmanager";
+    public static final String dbCenterData = "db-center-data";
+    public static final String dbCenterEvent = "db-center-event";
+    public static final String dbCenterMonitor = "db-center-monitor";
+    public static final String dbCenterTask = "db-center-task";
+    public static final String dbCenterEvaluation = "db-center-evaluation";
+    public static final String dbCenterFire = "db-center-fire";
+    public static final String dbCenterStraw = "db-center-straw";
+    public static final String dbCenterPests = "db-center-pests";
+    public static final String dbCenterComprehensive = "db-center-comprehensive";
+    public static final String dbCenterOnest = "db-center-onest";
+    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();
+    static Logger logger = LoggerFactory.getLogger(DynamicDataSourceSwitcher.class);
+
+    public static String getDataSource() {
+        if (StringUtils.isEmpty(contextHolder.get())) {
+            setDataSource(Master);
+        }
+        return contextHolder.get();
+    }
+
+    public static void setDataSource(String name) {
+        logger.info("-------- 设置数据源数据源为 :{} ", name);
+        contextHolder.set(name);
+    }
+
+    public static void cleanDataSource() {
+        contextHolder.remove();
+    }
+
+}

+ 4 - 0
src/main/java/com/sooka/sponest/monitor/base/util/database/GlobalTransactionalRabbitMQ.java

@@ -0,0 +1,4 @@
+package com.sooka.sponest.monitor.base.util.database;
+
+public @interface GlobalTransactionalRabbitMQ {
+}

+ 136 - 0
src/main/java/com/sooka/sponest/monitor/base/util/database/MultipleDataSourceConfig.java

@@ -0,0 +1,136 @@
+package com.sooka.sponest.monitor.base.util.database;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+import java.util.HashMap;
+import java.util.Map;
+
+@Configuration
+public class MultipleDataSourceConfig {
+
+    @Bean("master")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.master")
+    public DataSource createMasterDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbSystemData")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-system")
+    public DataSource createSystemDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterTranmanager")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-tranmanager")
+    public DataSource createTranmanagerDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterData")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-data")
+    public DataSource createDataDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterEvent")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-event")
+    public DataSource createEventDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterMonitor")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-monitor")
+    public DataSource createMonitorDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterTask")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-task")
+    public DataSource createTaskDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterEvaluation")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-evaluation")
+    public DataSource createEvaluationDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterFire")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-fire")
+    public DataSource createFireDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterStraw")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-straw")
+    public DataSource createStrawDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterPests")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-pests")
+    public DataSource createPestsDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterComprehensive")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-comprehensive")
+    public DataSource createComprehensiveDataSource() {
+        return new DruidDataSource();
+    }
+
+    @Bean("dbCenterOnest")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.db-center-onest")
+    public DataSource createOnestDataSource() {
+        return new DruidDataSource();
+    }
+
+    /**
+     * 设置动态数据源,通过@Primary 来确定主DataSource
+     *
+     * @return
+     */
+    @Bean
+    @Primary
+    public DataSource createDynamicDataSource(@Qualifier("master") DataSource master,
+                                              @Qualifier("dbSystemData") DataSource dbSystemData,
+                                              @Qualifier("dbCenterData") DataSource dbCenterData,
+                                              @Qualifier("dbCenterEvent") DataSource dbCenterEvent,
+                                              @Qualifier("dbCenterMonitor") DataSource dbCenterMonitor,
+                                              @Qualifier("dbCenterTask") DataSource dbCenterTask,
+                                              @Qualifier("dbCenterEvaluation") DataSource dbCenterEvaluation,
+                                              @Qualifier("dbCenterFire") DataSource dbCenterFire,
+                                              @Qualifier("dbCenterStraw") DataSource dbCenterStraw,
+                                              @Qualifier("dbCenterPests") DataSource dbCenterPests,
+                                              @Qualifier("dbCenterComprehensive") DataSource dbCenterComprehensive,
+                                              @Qualifier("dbCenterOnest") DataSource dbCenterOnest,
+                                              @Qualifier("dbCenterTranmanager") DataSource dbCenterTranmanager) {
+        DynamicDataSource dynamicDataSource = new DynamicDataSource();
+        //设置默认数据源
+        dynamicDataSource.setDefaultTargetDataSource(master);
+        //配置多数据源
+        Map<Object, Object> map = new HashMap<>();
+        map.put("master", master);
+        map.put("db-system", dbSystemData);
+        map.put("db-center-tranmanager", dbCenterTranmanager);
+        map.put("db-center-data", dbCenterData);
+        map.put("db-center-event", dbCenterEvent);
+        map.put("db-center-monitor", dbCenterMonitor);
+        map.put("db-center-task", dbCenterTask);
+        map.put("db-center-evaluation", dbCenterEvaluation);
+        map.put("db-center-fire", dbCenterFire);
+        map.put("db-center-straw", dbCenterStraw);
+        map.put("db-center-pests", dbCenterPests);
+        map.put("db-center-comprehensive", dbCenterComprehensive);
+        map.put("db-center-onest", dbCenterOnest);
+        dynamicDataSource.setTargetDataSources(map);
+        return dynamicDataSource;
+    }
+}

+ 15 - 0
src/main/java/com/sooka/sponest/monitor/base/util/database/MyDataSource.java

@@ -0,0 +1,15 @@
+package com.sooka.sponest.monitor.base.util.database;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({
+        ElementType.METHOD
+})
+public @interface MyDataSource {
+    String value() default "";
+}

+ 119 - 0
src/main/java/com/sooka/sponest/monitor/camera/controller/IndexLineChartCountTaskController.java

@@ -0,0 +1,119 @@
+package com.sooka.sponest.monitor.camera.controller;
+
+
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.redis.service.RedisService;
+import com.sooka.sponest.monitor.camera.domain.IndexLineChartsVo;
+import com.sooka.sponest.monitor.camera.service.ICentermonitorTCameraService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+import static org.springframework.web.bind.annotation.RequestMethod.GET;
+
+@Slf4j
+@Component
+@Api(tags = "监控中心首页定时任务")
+@RestController
+@RequestMapping("/camera/quartz")
+public class IndexLineChartCountTaskController {
+
+    @Resource
+    private RedisService redisService;
+
+    @Resource
+    private ICentermonitorTCameraService centermonitorTCameraService;
+
+    private final List<String> monthList = Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
+
+    /**
+     * 监控中心首页-离线设备日折线图缓存
+     **/
+//    @Scheduled(cron = "0 0 0/2 * * ?")
+    @Log(title = "监控中心首页-离线设备日折线图缓存", businessType = BusinessType.OTHER)
+    @ApiOperation(value = "监控中心首页-离线设备日折线图缓存", notes = "监控中心首页-离线设备日折线图缓存")
+    @RequestMapping(value = "/selectDayLineChartCountTask", method = GET)
+    public void selectDayLineChartCountTask() {
+        Date date = new Date();
+        List<Integer> yearList = getPreviousTwoYears(date);
+        for (int year : yearList) {
+            for (String month : monthList) {
+                List<IndexLineChartsVo> list = centermonitorTCameraService.dayLineChart(year + "-" + month);
+                redisService.setCacheObject("selectDayLineChartCount" + year + "-" + month, list);
+            }
+        }
+    }
+
+
+    /**
+     * 监控中心首页-离线设备月折线图缓存
+     **/
+//    @Scheduled(cron = "0 0 0/2 * * ?")
+    @Log(title = "监控中心首页-离线设备月折线图缓存", businessType = BusinessType.OTHER)
+    @ApiOperation(value = "监控中心首页-离线设备月折线图缓存", notes = "监控中心首页-离线设备月折线图缓存")
+    @RequestMapping(value = "/selectMonthlyLineChartCountTask", method = GET)
+    public void selectMonthlyLineChartCountTask() {
+        Date date = new Date();
+        List<Integer> yearList = getPreviousTwoYears(date);
+        for (int year : yearList) {
+            List<IndexLineChartsVo> list = centermonitorTCameraService.monthlyLineChart(year + "-01");
+            redisService.setCacheObject("monthlyLineChartCount" + year + "-01", list);
+        }
+    }
+
+
+    /**
+     * 监控中心首页-离线设备季度折线图缓存
+     **/
+//    @Scheduled(cron = "0 0 0/2 * * ?")
+    @Log(title = "监控中心首页-离线设备季度折线图缓存", businessType = BusinessType.OTHER)
+    @ApiOperation(value = "监控中心首页-离线设备季度折线图缓存", notes = "监控中心首页-离线设备季度折线图缓存")
+    @RequestMapping(value = "/quarterlineChartTask", method = GET)
+    public void quarterlineChartTask() {
+        Date date = new Date();
+        List<Integer> yearList = getPreviousTwoYears(date);
+        for (int year : yearList) {
+            List<IndexLineChartsVo> list = centermonitorTCameraService.quarterLineChart(year + "-01");
+            redisService.setCacheObject("quarterlineChart" + year + "-01", list);
+        }
+    }
+
+
+    /**
+     * 监控中心首页-离线设备年折线图缓存
+     **/
+//    @Scheduled(cron = "0 0 0/2 * * ?")
+    @Log(title = "监控中心首页-离线设备年折线图缓存", businessType = BusinessType.OTHER)
+    @ApiOperation(value = "监控中心首页-离线设备年折线图缓存", notes = "监控中心首页-离线设备年折线图缓存")
+    @RequestMapping(value = "/yearlineChartTask", method = GET)
+    public void yearlineChartTask() {
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int year = calendar.get(Calendar.YEAR);
+        List<IndexLineChartsVo> list = centermonitorTCameraService.yearLineChart(String.valueOf(year));
+        redisService.setCacheObject("yearlineChart" + year, list);
+    }
+
+    //获取当前年份
+    public static List<Integer> getPreviousTwoYears(Date date) {
+        List<Integer> yearList = new ArrayList<>();
+        // 创建 Calendar 实例并设置为当前时间
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        // 获取当前年份
+        int currentYear = calendar.get(Calendar.YEAR);
+        // 添加前两年的年份到列表
+        yearList.add(currentYear - 2);
+        yearList.add(currentYear - 1);
+        yearList.add(currentYear);
+        return yearList;
+    }
+}

+ 26 - 0
src/main/java/com/sooka/sponest/monitor/camera/domain/IndexLineChartsVo.java

@@ -0,0 +1,26 @@
+package com.sooka.sponest.monitor.camera.domain;
+
+import lombok.Data;
+
+/**
+ *
+ *
+ * 折线图
+ */
+@Data
+public class IndexLineChartsVo {
+    private static final long serialVersionUID = 1L;
+
+    /** 返回值:日期 **/
+    private String time;
+    /** 返回值:数值 **/
+    private String count;
+
+    /** 条件:年-月 **/
+    private String yearAndMonth;
+    /** 条件:月 **/
+    private String month;
+
+    /** 条件:年 **/
+    private String year;
+}

+ 42 - 0
src/main/java/com/sooka/sponest/monitor/camera/mapper/CentermonitorTCameraMapper.java

@@ -0,0 +1,42 @@
+package com.sooka.sponest.monitor.camera.mapper;
+
+
+import com.sooka.sponest.monitor.camera.domain.IndexLineChartsVo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 摄像头Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-06-08
+ */
+@Repository
+public interface CentermonitorTCameraMapper {
+
+    /**
+     * 监控中心首页-日离线设备折线图
+     **/
+    List<IndexLineChartsVo> dayLineChart(@Param("yearAndMonth") String yearAndMonth);
+
+    /**
+     * 监控中心首页-月离线设备折线图
+     **/
+    List<IndexLineChartsVo> monthlyLineChart(@Param("year") String year);
+
+    /**
+     * 监控中心首页-季度离线设备折线图
+     **/
+    List<IndexLineChartsVo> quarterLineChart(@Param("year") String year);
+
+    /**
+     * 监控中心首页-年离线设备折线图
+     **/
+    List<IndexLineChartsVo> yearLineChart(@Param("year") String year);
+
+
+}
+

+ 42 - 0
src/main/java/com/sooka/sponest/monitor/camera/service/ICentermonitorTCameraService.java

@@ -0,0 +1,42 @@
+package com.sooka.sponest.monitor.camera.service;
+
+import com.sooka.sponest.monitor.camera.domain.IndexLineChartsVo;
+
+import java.util.List;
+
+/**
+ * 摄像头Service接口
+ *
+ * @author ruoyi
+ * @date 2022-06-08
+ */
+public interface ICentermonitorTCameraService {
+
+
+    /**
+     * 监控中心首页-日离线设备折线图
+     **/
+    List<IndexLineChartsVo> dayLineChart(String yearAndMonth);
+
+    /**
+     * 监控中心首页-月离线设备折线图
+     */
+    List<IndexLineChartsVo> monthlyLineChart(String year);
+
+    /**
+     * 监控中心首页-季度离线设备折线图
+     */
+    List<IndexLineChartsVo> quarterLineChart(String year);
+
+    /**
+     * 监控中心首页-年离线设备折线图
+     */
+    List<IndexLineChartsVo> yearLineChart(String year);
+
+}
+
+
+
+
+
+

+ 59 - 0
src/main/java/com/sooka/sponest/monitor/camera/service/impl/CentermonitorTCameraServiceImpl.java

@@ -0,0 +1,59 @@
+package com.sooka.sponest.monitor.camera.service.impl;
+
+import com.sooka.sponest.monitor.base.service.impl.BaseService;
+import com.sooka.sponest.monitor.camera.domain.IndexLineChartsVo;
+import com.sooka.sponest.monitor.camera.mapper.CentermonitorTCameraMapper;
+import com.sooka.sponest.monitor.camera.service.ICentermonitorTCameraService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 摄像头Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-06-08
+ */
+@Service
+public class CentermonitorTCameraServiceImpl extends BaseService implements ICentermonitorTCameraService {
+
+    @Resource
+    private CentermonitorTCameraMapper centermonitorTCameraMapper;
+
+
+    /**
+     * 监控中心首页-日离线设备折线图
+     **/
+    @Override
+    public List<IndexLineChartsVo> dayLineChart(String yearAndMonth) {
+        return centermonitorTCameraMapper.dayLineChart(yearAndMonth);
+    }
+
+    /**
+     * 监控中心首页-月离线设备折线图
+     **/
+    @Override
+    public List<IndexLineChartsVo> monthlyLineChart(String year) {
+        return centermonitorTCameraMapper.monthlyLineChart(year);
+    }
+
+    /**
+     * 监控中心首页-季度离线设备折线图
+     **/
+    @Override
+    public List<IndexLineChartsVo> quarterLineChart(String year) {
+        return centermonitorTCameraMapper.quarterLineChart(year);
+    }
+
+    /**
+     * 监控中心首页-年离线设备折线图
+     **/
+    @Override
+    public List<IndexLineChartsVo> yearLineChart(String year) {
+        return centermonitorTCameraMapper.yearLineChart(year);
+    }
+
+}
+
+

+ 78 - 0
src/main/java/com/sooka/sponest/monitor/util/BeanUtil.java

@@ -0,0 +1,78 @@
+package com.sooka.sponest.monitor.util;
+
+import com.dahuatech.hutool.json.JSONNull;
+import com.ruoyi.common.core.utils.StringUtils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BeanUtil {
+
+    /**
+     * map转对象
+     *
+     * @param map
+     * @param beanClass
+     * @param <T>
+     * @return
+     * @throws Exception
+     */
+    public static <T> T mapToBean(Map map, Class<T> beanClass) throws Exception {
+        T object = beanClass.newInstance();
+        Field[] fields = object.getClass().getDeclaredFields();
+        for (Field field : fields) {
+            int mod = field.getModifiers();
+            if (Modifier.isStatic(mod) || Modifier.isFinal(mod)) {
+                continue;
+            }
+            field.setAccessible(true);
+            if (map.containsKey(field.getName())) {
+                field.set(object, map.get(field.getName()) instanceof JSONNull ? StringUtils.EMPTY : map.get(field.getName()));
+            }
+        }
+        return object;
+    }
+
+    /**
+     * 实体类转Map
+     *
+     * @param object
+     * @return
+     */
+    public static Map<String, Object> beanToMap(Object object) {
+        Map<String, Object> map = new HashMap();
+        for (Field field : object.getClass().getDeclaredFields()) {
+            try {
+                boolean flag = field.isAccessible();
+                field.setAccessible(true);
+                Object o = field.get(object);
+                map.put(field.getName(), o);
+                field.setAccessible(flag);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return map;
+    }
+
+    public static <T> T arrayToBean(String[] values, Class<T> beanClass) throws Exception {
+        T object = beanClass.newInstance();
+        Field[] fields = object.getClass().getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            int mod = fields[i].getModifiers();
+            if (Modifier.isStatic(mod) || Modifier.isFinal(mod)) {
+                continue;
+            }
+            // 检查 values 数组的长度
+            if (i < values.length) {
+                fields[i].setAccessible(true);
+                fields[i].set(object, values[i].split(" ")[0]); // 只取第一个值
+            }
+//            fields[i].setAccessible(true);
+//            fields[i].set(object, values[i].split(" ")[0]);
+        }
+        return object;
+    }
+}

+ 9 - 0
src/main/resources/banner.txt

@@ -0,0 +1,9 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
+
+  __________   ____ |  | _______          ____________   ____   ____   ____   _______/  |_
+
+ /  ___/  _ \ /  _ \|  |/ /\__  \        /  ___/\____ \ /  _ \ /    \_/ __ \ /  ___/\   __\
+ \___ (  <_> |  <_> )    <  / __ \_      \___ \ |  |_> >  <_> )   |  \  ___/ \___ \  |  |
+/____  >____/ \____/|__|_ \(____  /     /____  >|   __/ \____/|___|  /\___  >____  > |__|
+     \/                  \/     \/           \/ |__|               \/     \/     \/

+ 26 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,26 @@
+# Tomcat
+server:
+  port: 9006
+# Spring
+spring:
+  application:
+    # 应用名称
+    name: sooka-sponest-center-monitor-lineCharts
+  profiles:
+    # 环境配置
+    active: dev
+  cloud:
+    nacos:
+      discovery:
+        # 服务注册地址
+        server-addr: www.sooka.onest.com:8848
+#         server-addr: 127.0.0.1:8848
+      config:
+        # 配置中心地址
+        server-addr: www.sooka.onest.com:8848
+#        server-addr: 127.0.0.1:8848
+        # 配置文件格式
+        file-extension: yml
+        # 共享配置
+        shared-configs:
+          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 141 - 0
src/main/resources/mapper/monitor/camera/CentermonitorTCameraMapper.xml

@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sooka.sponest.monitor.camera.mapper.CentermonitorTCameraMapper">
+
+
+    <resultMap id="IndexLineCharts" type="IndexLineChartsVo">
+        <result property="time" column="time"/>
+        <result property="count" column="count"/>
+        <result property="year" column="year"/>
+        <result property="month" column="month"/>
+    </resultMap>
+
+
+    <select id="dayLineChart" parameterType="String" resultMap="IndexLineCharts">
+        SELECT a.time,
+               IFNULL(b.count, 0) count
+        FROM (
+            SELECT
+            DATE_ADD(DATE_ADD(DATE_FORMAT('${yearAndMonth}-01', '%Y-%m-%d'), INTERVAL-DAY(DATE_FORMAT('${yearAndMonth}-01', '%Y-%m-%d')) + 2 DAY), INTERVAL(cast(help_topic_id AS signed INTEGER)-1)DAY) time
+            FROM
+            mysql.help_topic
+            WHERE
+            help_topic_id  <![CDATA[ < ]]> DAY (last_day(DATE_FORMAT('${yearAndMonth}-01', '%Y-%m-%d')))
+            ORDER BY
+            help_topic_id
+            ) a
+            LEFT JOIN (
+            SELECT
+            time, count(id) count
+            FROM (
+            SELECT DISTINCT
+            c.id, DATE_FORMAT(l.create_time, '%Y-%m-%d') time
+            FROM
+            centermonitor_t_camera c
+            LEFT JOIN centermonitor_t_camera_state_log l ON c.id = l.camera_id
+            WHERE
+            DATE_FORMAT(l.create_time, '%Y-%m') = #{yearAndMonth}
+            AND l.state != 0
+            ORDER BY
+            l.create_time DESC
+            ) a
+            GROUP BY
+            time
+            ) b
+        ON a.time = b.time
+    </select>
+
+
+    <select id="monthlyLineChart" parameterType="String" resultMap="IndexLineCharts">
+        SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT('${year}-01', '%Y-%m-01'), INTERVAL (n - 1) MONTH), '%Y-%m') AS time,
+            IFNULL(t.count, 0) AS count
+        FROM
+            (
+            SELECT 1 AS n UNION ALL
+            SELECT 2 AS n UNION ALL
+            SELECT 3 AS n UNION ALL
+            SELECT 4 AS n UNION ALL
+            SELECT 5 AS n UNION ALL
+            SELECT 6 AS n UNION ALL
+            SELECT 7 AS n UNION ALL
+            SELECT 8 AS n UNION ALL
+            SELECT 9 AS n UNION ALL
+            SELECT 10 AS n UNION ALL
+            SELECT 11 AS n UNION ALL
+            SELECT 12 AS n
+            ) AS numbers
+            LEFT JOIN (
+            SELECT
+            DATE_FORMAT(l.create_time, '%Y-%m') AS time, COUNT(distinct c.id) AS count
+            FROM
+            centermonitor_t_camera c
+            LEFT JOIN centermonitor_t_camera_state_log l ON c.id = l.camera_id
+            WHERE
+            YEAR (l.create_time) = #{year}
+            AND l.state != 0
+            GROUP BY
+            DATE_FORMAT(l.create_time, '%Y-%m')
+            ) AS t
+        ON DATE_FORMAT(DATE_ADD(DATE_FORMAT('${year}-01', '%Y-%m-01'), INTERVAL (n - 1) MONTH), '%Y-%m') = t.time;
+    </select>
+
+
+    <select id="quarterLineChart" parameterType="String" resultMap="IndexLineCharts">
+        SELECT CASE
+                   WHEN QUARTER(quarters.date) = 1 THEN '第1季度'
+                   WHEN QUARTER(quarters.date) = 2 THEN '第2季度'
+                   WHEN QUARTER(quarters.date) = 3 THEN '第3季度'
+                   WHEN QUARTER(quarters.date) = 4 THEN '第4季度'
+                   END AS time,
+                  IFNULL(t.count, 0) AS count
+        FROM (
+            SELECT
+            CONCAT(YEAR (d.date), '-', QUARTER(d.date)) AS time, d.date
+            FROM (
+            SELECT
+            DATE_ADD(DATE_FORMAT('${year}-01-01', '%Y-%m-%d'), INTERVAL (n1.num * 100 + n2.num * 10 + n3.num) QUARTER) AS date
+            FROM
+            (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3) n1, (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) n2, (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) n3
+            ) d
+            WHERE YEAR (d.date) = '${year}'
+            GROUP BY time, date
+            ) quarters
+            LEFT JOIN (
+            SELECT
+            CONCAT(YEAR (l.create_time), '-', QUARTER(l.create_time)) AS time, COUNT(distinct c.id) AS count
+            FROM centermonitor_t_camera c
+            LEFT JOIN centermonitor_t_camera_state_log l ON c.id = l.camera_id
+            WHERE
+            YEAR (l.create_time) = '${year}' -- 修改为指定的年份
+            AND l.state != 0
+            GROUP BY time) t
+        ON quarters.time = t.time
+        ORDER BY quarters.date;
+    </select>
+
+
+    <select id="yearLineChart" parameterType="String" resultMap="IndexLineCharts">
+        SELECT gen.year AS time,
+              COALESCE(subquery.count, 0) AS count
+        FROM
+            (
+            SELECT ${year} AS year
+            UNION ALL SELECT ${year} - 1 AS year
+            UNION ALL SELECT ${year} - 2 AS year
+            ) AS gen
+            LEFT JOIN
+            (
+            SELECT YEAR (l.create_time) AS year, COUNT(distinct c.id) AS count
+            FROM centermonitor_t_camera c
+            LEFT JOIN centermonitor_t_camera_state_log l ON c.id = l.camera_id
+            WHERE (YEAR (l.create_time) IN (${year}, ${year} - 1, ${year} - 2) OR l.create_time IS NULL)
+            AND l.state != 0
+            GROUP BY year
+            ) AS subquery
+        ON gen.year = subquery.year
+        ORDER BY gen.year;
+    </select>
+
+</mapper>