瀏覽代碼

初始化提交

z 4 年之前
當前提交
3451730851
共有 41 個文件被更改,包括 2959 次插入0 次删除
  1. 300 0
      pom.xml
  2. 17 0
      src/main/java/com/zx/dataservice/DataServiceApplication.java
  3. 67 0
      src/main/java/com/zx/dataservice/config/DataSourceConfig1.java
  4. 61 0
      src/main/java/com/zx/dataservice/config/DataSourceConfig2.java
  5. 61 0
      src/main/java/com/zx/dataservice/config/DataSourceConfig3.java
  6. 39 0
      src/main/java/com/zx/dataservice/config/DruidConfig.java
  7. 24 0
      src/main/java/com/zx/dataservice/config/ResponseCode.java
  8. 96 0
      src/main/java/com/zx/dataservice/config/ServerResponse.java
  9. 44 0
      src/main/java/com/zx/dataservice/config/SwaggerConfig.java
  10. 30 0
      src/main/java/com/zx/dataservice/controller/ChoiceController.java
  11. 29 0
      src/main/java/com/zx/dataservice/controller/TaskController.java
  12. 15 0
      src/main/java/com/zx/dataservice/mapper1/ChoiceStockMapper.java
  13. 14 0
      src/main/java/com/zx/dataservice/mapper2/StockMapper.java
  14. 16 0
      src/main/java/com/zx/dataservice/mapper3/ChoiceBondMapper.java
  15. 61 0
      src/main/java/com/zx/dataservice/pojo/StockRestPojo.java
  16. 7 0
      src/main/java/com/zx/dataservice/service/ChoiceBondService.java
  17. 14 0
      src/main/java/com/zx/dataservice/service/ChoiceStockService.java
  18. 188 0
      src/main/java/com/zx/dataservice/service/impl/ChoiceBondServiceImpl.java
  19. 202 0
      src/main/java/com/zx/dataservice/service/impl/ChoiceStockServiceImpl.java
  20. 37 0
      src/main/java/com/zx/dataservice/task/AnalysisBondRestDataTask.java
  21. 38 0
      src/main/java/com/zx/dataservice/task/AnalysisStockRestDataTask.java
  22. 49 0
      src/main/java/com/zx/dataservice/task/TaskConfig.java
  23. 19 0
      src/main/java/com/zx/dataservice/utils/ChoiceUtil.java
  24. 127 0
      src/main/java/com/zx/dataservice/utils/DateTimeUtil.java
  25. 155 0
      src/main/java/com/zx/dataservice/utils/FileBondUtil.java
  26. 155 0
      src/main/java/com/zx/dataservice/utils/FileStockUtil.java
  27. 106 0
      src/main/java/com/zx/dataservice/utils/HttpRequest.java
  28. 295 0
      src/main/java/com/zx/dataservice/utils/OkHttpUtils.java
  29. 45 0
      src/main/java/com/zx/dataservice/utils/PropertiesUtil.java
  30. 19 0
      src/main/java/com/zx/dataservice/utils/TimeUtil.java
  31. 28 0
      src/main/java/com/zx/dataservice/vo/SystemBoard.java
  32. 72 0
      src/main/resources/application-dev.properties
  33. 0 0
      src/main/resources/application-test.properties
  34. 12 0
      src/main/resources/application.properties
  35. 54 0
      src/main/resources/log4j.properties
  36. 126 0
      src/main/resources/mybatis/mapper1/ChoiceStockMapper.xml
  37. 31 0
      src/main/resources/mybatis/mapper2/StockMapper.xml
  38. 126 0
      src/main/resources/mybatis/mapper3/ChoiceBondMapper.xml
  39. 26 0
      src/main/resources/mybatis/mybatis-config.xml
  40. 141 0
      src/main/resources/stock.properties
  41. 13 0
      src/test/java/com/zx/dataservice/DataServiceApplicationTests.java

+ 300 - 0
pom.xml

@@ -0,0 +1,300 @@
+<?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"
+         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>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.5.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.zx</groupId>
+    <artifactId>data-service</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>data-service</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-data-jpa</artifactId>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
+<!--        </dependency>-->
+        <!-- 引入 Druid 数据源依赖:https://mvnrepository.com/artifact/com.alibaba/druid -->
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba</groupId>-->
+<!--            <artifactId>druid</artifactId>-->
+<!--            <version>1.2.3</version>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>1.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+            <version>8.0.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.10.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.60</version>
+        </dependency>
+
+        <!-- swagger -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>20.0</version>
+        </dependency>
+
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.10</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.2</version>
+        </dependency>
+
+        <!-- json -->
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.2.3</version>
+            <classifier>jdk15</classifier>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.47</version>
+        </dependency>
+        <!--Jackson序列化-->
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+            <version>1.9.12</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjrt</artifactId>
+            <version>1.6.11</version>
+        </dependency>
+        <!--        <dependency>-->
+        <!--            <groupId>com.fasterxml.jackson.core</groupId>-->
+        <!--            <artifactId>jackson-databind</artifactId>-->
+        <!--            <version>2.9.8</version>-->
+        <!--        </dependency>-->
+
+        <!-- 热加载 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+        </dependency>
+
+        <!-- mybatis pager -->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.miemiedev</groupId>
+            <artifactId>mybatis-paginator</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.jsqlparser</groupId>
+            <artifactId>jsqlparser</artifactId>
+            <version>0.9.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.12</version>
+        </dependency>
+
+        <!--joda time-->
+        <dependency>
+            <groupId>joda-time</groupId>
+            <artifactId>joda-time</artifactId>
+            <version>2.3</version>
+        </dependency>
+
+        <!-- 日志 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-log4j</artifactId>
+            <version>1.3.8.RELEASE</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!--guava工具类-->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>20.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.5</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+
+        <!-- redis -->
+        <!-- Spring Boot Redis 依赖 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>io.lettuce</groupId>
+                    <artifactId>lettuce-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+        </dependency>
+
+        <!--识别指数首字母-->
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+            <version>2.5.1</version>
+        </dependency>
+
+        <!-- ftpclient -->
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+            <version>3.1</version>
+        </dependency>
+
+        <!--aliyun sms sdk-->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-core</artifactId>
+            <version>3.4.0</version>
+        </dependency>
+
+        <!--发送邮件-->
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>1.4.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>2.1.1</version>
+        </dependency>
+
+        <!-- kaptcha验证码-->
+        <!-- https://mvnrepository.com/artifact/com.github.penggle/kaptcha -->
+        <dependency>
+            <groupId>com.github.penggle</groupId>
+            <artifactId>kaptcha</artifactId>
+            <version>2.3.2</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+        <resources>
+            <resource>
+                <directory>
+                    src/main/java
+                </directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>mybatis/**/**.xml</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                    <include>**/*.properties</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+
+</project>

+ 17 - 0
src/main/java/com/zx/dataservice/DataServiceApplication.java

@@ -0,0 +1,17 @@
+package com.zx.dataservice;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+@EnableScheduling
+@EnableAsync
+public class DataServiceApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DataServiceApplication.class, args);
+    }
+
+}

+ 67 - 0
src/main/java/com/zx/dataservice/config/DataSourceConfig1.java

@@ -0,0 +1,67 @@
+package com.zx.dataservice.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.zx.dataservice.utils.PropertiesUtil;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+//表示这个类为一个配置类
+@Configuration
+// 配置mybatis的接口类放的地方
+@MapperScan(basePackages = {"com.zx.dataservice.mapper1"}, sqlSessionTemplateRef = "testSqlSessionTemplate")
+public class DataSourceConfig1 {
+
+    @Bean(name = "testDataSource")
+//    @ConfigurationProperties(prefix = "spring.datasource.test1")
+    public DataSource testDataSource() throws SQLException {
+        DruidDataSource dataSource = new DruidDataSource();
+        dataSource.setUrl(PropertiesUtil.getProperty("spring.datasource.test1.jdbc-Url"));
+        dataSource.setUsername(PropertiesUtil.getProperty("spring.datasource.test1.username"));
+        dataSource.setPassword(PropertiesUtil.getProperty("spring.datasource.test1.password"));
+        dataSource.setDriverClassName(PropertiesUtil.getProperty("spring.datasource.test1.driver-class-name"));
+        dataSource.setInitialSize(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.initialSize")));
+        dataSource.setMinIdle(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.minIdle")));
+        dataSource.setMaxActive(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxActive")));
+        dataSource.setMaxWait(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxWait")));
+        dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(PropertiesUtil.getProperty("spring.druid.timeBetweenEvictionRunsMillis")));
+        dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(PropertiesUtil.getProperty("spring.druid.minEvictableIdleTimeMillis")));
+        dataSource.setValidationQuery(PropertiesUtil.getProperty("spring.druid.validationQuery"));
+        dataSource.setTestWhileIdle(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testWhileIdle")));
+        dataSource.setTestOnBorrow(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testOnBorrow")));
+        dataSource.setTestOnReturn(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testOnReturn")));
+        dataSource.setPoolPreparedStatements(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.poolPreparedStatements")));
+        dataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxPoolPreparedStatementPerConnectionSize")));
+        dataSource.setRemoveAbandoned(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.removeAbandoned")));
+        dataSource.setRemoveAbandonedTimeout(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.removeAbandonedTimeout")));
+        dataSource.setFilters(PropertiesUtil.getProperty("spring.druid.filters"));
+        return dataSource;
+//        return DataSourceBuilder.create().build();
+    }
+
+    @Bean(name = "testSqlSessionFactory")
+    public SqlSessionFactory testSqlSessionFactory(@Qualifier("testDataSource") DataSource dataSource) throws Exception {
+        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
+        factoryBean.setDataSource(dataSource);
+        factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/mapper1/*.xml"));
+        return factoryBean.getObject();
+    }
+    @Bean(name="testTransactionManager")
+    public DataSourceTransactionManager testTransactionManager(@Qualifier("testDataSource") DataSource dataSource){
+        return  new DataSourceTransactionManager(dataSource);
+    }
+
+    @Bean(name = "testSqlSessionTemplate")
+    public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("testSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}

+ 61 - 0
src/main/java/com/zx/dataservice/config/DataSourceConfig2.java

@@ -0,0 +1,61 @@
+package com.zx.dataservice.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.zx.dataservice.utils.PropertiesUtil;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages = {"com.zx.dataservice.mapper2"}, sqlSessionTemplateRef = "userSqlSessionTemplate")
+public class DataSourceConfig2 {
+
+    @Bean(name = "userDataSource")
+//    @ConfigurationProperties(prefix = "spring.datasource.test2")
+    public DataSource testDataSource() {
+        DruidDataSource dataSource = new DruidDataSource();
+        dataSource.setUrl(PropertiesUtil.getProperty("spring.datasource.test2.jdbc-Url"));
+        dataSource.setUsername(PropertiesUtil.getProperty("spring.datasource.test2.username"));
+        dataSource.setPassword(PropertiesUtil.getProperty("spring.datasource.test2.password"));
+        dataSource.setDriverClassName(PropertiesUtil.getProperty("spring.datasource.test2.driver-class-name"));
+        dataSource.setInitialSize(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.initialSize")));
+        dataSource.setMinIdle(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.minIdle")));
+        dataSource.setMaxActive(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxActive")));
+        dataSource.setMaxWait(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxWait")));
+        dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(PropertiesUtil.getProperty("spring.druid.timeBetweenEvictionRunsMillis")));
+        dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(PropertiesUtil.getProperty("spring.druid.minEvictableIdleTimeMillis")));
+        dataSource.setValidationQuery(PropertiesUtil.getProperty("spring.druid.validationQuery"));
+        dataSource.setTestWhileIdle(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testWhileIdle")));
+        dataSource.setTestOnBorrow(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testOnBorrow")));
+        dataSource.setTestOnReturn(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testOnReturn")));
+        dataSource.setPoolPreparedStatements(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.poolPreparedStatements")));
+        dataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxPoolPreparedStatementPerConnectionSize")));
+        dataSource.setRemoveAbandoned(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.removeAbandoned")));
+        dataSource.setRemoveAbandonedTimeout(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.removeAbandonedTimeout")));
+        return dataSource;
+    }
+
+    @Bean(name = "userSqlSessionFactory")
+    public SqlSessionFactory userSqlSessionFactory(@Qualifier("userDataSource") DataSource dataSource) throws Exception {
+        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
+        factoryBean.setDataSource(dataSource);
+        factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/mapper2/*.xml"));
+        return factoryBean.getObject();
+    }
+    @Bean(name="userTransactionManager")
+    public DataSourceTransactionManager testTransactionManager(@Qualifier("userDataSource") DataSource dataSource){
+        return  new DataSourceTransactionManager(dataSource);
+    }
+    @Bean(name = "userSqlSessionTemplate")
+    public SqlSessionTemplate userSqlSessionTemplate(@Qualifier("userSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}

+ 61 - 0
src/main/java/com/zx/dataservice/config/DataSourceConfig3.java

@@ -0,0 +1,61 @@
+package com.zx.dataservice.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.zx.dataservice.utils.PropertiesUtil;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages = {"com.zx.dataservice.mapper3"}, sqlSessionTemplateRef = "source3SqlSessionTemplate")
+public class DataSourceConfig3 {
+
+    @Bean(name = "source3DataSource")
+//    @ConfigurationProperties(prefix = "spring.datasource.test3")
+    public DataSource testDataSource() {
+        DruidDataSource dataSource = new DruidDataSource();
+        dataSource.setUrl(PropertiesUtil.getProperty("spring.datasource.test3.jdbc-Url"));
+        dataSource.setUsername(PropertiesUtil.getProperty("spring.datasource.test3.username"));
+        dataSource.setPassword(PropertiesUtil.getProperty("spring.datasource.test3.password"));
+        dataSource.setDriverClassName(PropertiesUtil.getProperty("spring.datasource.test3.driver-class-name"));
+        dataSource.setInitialSize(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.initialSize")));
+        dataSource.setMinIdle(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.minIdle")));
+        dataSource.setMaxActive(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxActive")));
+        dataSource.setMaxWait(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxWait")));
+        dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(PropertiesUtil.getProperty("spring.druid.timeBetweenEvictionRunsMillis")));
+        dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(PropertiesUtil.getProperty("spring.druid.minEvictableIdleTimeMillis")));
+        dataSource.setValidationQuery(PropertiesUtil.getProperty("spring.druid.validationQuery"));
+        dataSource.setTestWhileIdle(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testWhileIdle")));
+        dataSource.setTestOnBorrow(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testOnBorrow")));
+        dataSource.setTestOnReturn(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.testOnReturn")));
+        dataSource.setPoolPreparedStatements(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.poolPreparedStatements")));
+        dataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.maxPoolPreparedStatementPerConnectionSize")));
+        dataSource.setRemoveAbandoned(Boolean.parseBoolean(PropertiesUtil.getProperty("spring.druid.removeAbandoned")));
+        dataSource.setRemoveAbandonedTimeout(Integer.parseInt(PropertiesUtil.getProperty("spring.druid.removeAbandonedTimeout")));
+        return dataSource;
+    }
+
+    @Bean(name = "source3SqlSessionFactory")
+    public SqlSessionFactory source3SqlSessionFactory(@Qualifier("source3DataSource") DataSource dataSource) throws Exception {
+        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
+        factoryBean.setDataSource(dataSource);
+        factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/mapper3/*.xml"));
+        return factoryBean.getObject();
+    }
+    @Bean(name="source3TransactionManager")
+    public DataSourceTransactionManager testTransactionManager(@Qualifier("source3DataSource") DataSource dataSource){
+        return  new DataSourceTransactionManager(dataSource);
+    }
+    @Bean(name = "source3SqlSessionTemplate")
+    public SqlSessionTemplate source3SqlSessionTemplate(@Qualifier("source3SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}

+ 39 - 0
src/main/java/com/zx/dataservice/config/DruidConfig.java

@@ -0,0 +1,39 @@
+package com.zx.dataservice.config;
+
+import com.alibaba.druid.support.http.StatViewServlet;
+import com.alibaba.druid.support.http.WebStatFilter;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class DruidConfig {
+
+    @Bean
+    public ServletRegistrationBean druidServlet() { // 主要实现WEB监控的配置处理
+        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(
+                new StatViewServlet(), "/druid/*"); // 现在要进行druid监控的配置处理操作
+        servletRegistrationBean.addInitParameter("allow", "113.246.154.27,127.0.0.1,10.1.1.1"); // 白名单
+        // servletRegistrationBean.addInitParameter("deny", "192.168.1.200"); // 黑名单
+        servletRegistrationBean.addInitParameter("loginUsername", "admin"); // 用户名
+        servletRegistrationBean.addInitParameter("loginPassword", "admin"); // 密码
+        servletRegistrationBean.addInitParameter("resetEnable", "false"); // 是否可以重置数据源
+        return servletRegistrationBean ;
+    }
+
+    @Bean
+    public FilterRegistrationBean filterRegistrationBean() {
+        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean() ;
+        filterRegistrationBean.setFilter(new WebStatFilter());
+        filterRegistrationBean.addUrlPatterns("/*"); // 所有请求进行监控处理
+        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.css,/druid/*");
+        return filterRegistrationBean ;
+    }
+
+//    @Bean
+//    @ConfigurationProperties(prefix = "application-dev.properties")
+//    public DataSource druidDataSource() {
+//        return new DruidDataSource();
+//    }
+}

+ 24 - 0
src/main/java/com/zx/dataservice/config/ResponseCode.java

@@ -0,0 +1,24 @@
+package com.zx.dataservice.config;
+
+
+public enum ResponseCode {
+    SUCCESS(0, "SUCCESS"),
+    ERROR(1, "ERROR"),
+    NEED_LOGIN(10, "NEED_LOGIN"),
+    ILLEGAL_ARGUMENT(2, "ILLEGAL_ARGUMENT");
+    private int code;
+    private String msg;
+
+    ResponseCode(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public int getCode() {
+        return this.code;
+    }
+
+    public String getMsg() {
+        return this.msg;
+    }
+}

+ 96 - 0
src/main/java/com/zx/dataservice/config/ServerResponse.java

@@ -0,0 +1,96 @@
+package com.zx.dataservice.config;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.io.Serializable;
+
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@ApiModel(value = "返回类")
+public class ServerResponse<T> implements Serializable {
+
+    @ApiModelProperty(value = "code")
+    private int status;
+
+    @ApiModelProperty(value = "描述")
+    private String msg;
+
+    @ApiModelProperty(value = "对象")
+    private T data;
+
+    public ServerResponse(){
+
+    }
+
+    private ServerResponse(int status) {
+        this.status = status;
+    }
+
+    private ServerResponse(int status, T data) {
+        this.status = status;
+        this.data = data;
+    }
+
+    private ServerResponse(int status, String msg) {
+        this.status = status;
+        this.msg = msg;
+    }
+
+    private ServerResponse(int status, String msg, T data) {
+        this.status = status;
+        this.msg = msg;
+        this.data = data;
+    }
+
+    @JsonIgnore
+    public boolean isSuccess() {
+        return (this.status == ResponseCode.SUCCESS.getCode());
+    }
+
+    public int getStatus() {
+        return this.status;
+    }
+
+    public T getData() {
+        return (T) this.data;
+    }
+
+    public String getMsg() {
+        return this.msg;
+    }
+
+    public static <T> ServerResponse<T> createBySuccess() {
+        return new ServerResponse(ResponseCode.SUCCESS.getCode());
+    }
+
+    public static <T> ServerResponse<T> createBySuccessMsg(String msg) {
+        return new ServerResponse(ResponseCode.SUCCESS.getCode(), msg);
+    }
+    public static <T> ServerResponse<T> createBySuccessMsg2(String msg) {
+        return new ServerResponse(111, msg);
+    }
+    public static <T> ServerResponse<T> createBySuccess(T data) {
+        return new ServerResponse(ResponseCode.SUCCESS.getCode(), data);
+    }
+
+    public static <T> ServerResponse<T> createBySuccess(String msg, T data) {
+        return new ServerResponse(ResponseCode.SUCCESS.getCode(), msg, data);
+    }
+
+    public static <T> ServerResponse<T> createByError() {
+        return new ServerResponse(ResponseCode.ERROR.getCode(), ResponseCode.ERROR.getMsg());
+    }
+
+    public static <T> ServerResponse<T> createByErrorMsg(String errormsg) {
+        return new ServerResponse(ResponseCode.ERROR.getCode(), errormsg);
+    }
+    public static <T> ServerResponse<T> createByErrorMsg2(String errormsg) {
+        return new ServerResponse(10000, errormsg);
+    }
+
+    public static <T> ServerResponse<T> createByErrorCodeMsg(int errorcode, String errormsg) {
+        return new ServerResponse(errorcode, errormsg);
+    }
+}

+ 44 - 0
src/main/java/com/zx/dataservice/config/SwaggerConfig.java

@@ -0,0 +1,44 @@
+package com.zx.dataservice.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.time.LocalDate;
+import java.util.Date;
+
+@EnableSwagger2
+@Configuration
+public class SwaggerConfig {
+
+
+    public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.zx.dataservice.controller";
+
+    public static final String VERSION = "1.0.0";
+
+    //是否开启swagger,正式环境一般是需要关闭的(避免不必要的漏洞暴露!),可根据springboot的多环境配置进行设置
+    @Value("${swagger.enable}")
+    private boolean enableSwagger;
+
+    ApiInfo apiInfo() {
+        return new ApiInfoBuilder().title("Swagger API").description("This is to show api description")
+                .license("Apache 2.0").licenseUrl("")
+                .termsOfServiceUrl("").version(VERSION).contact(new Contact("", "", "")).build();
+    }
+
+    @Bean
+    public Docket customImplementation() {
+        return new Docket(DocumentationType.SWAGGER_2).select()
+                .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)).build()
+                .enable(enableSwagger)
+                .directModelSubstitute(LocalDate.class, java.sql.Date.class)
+                .directModelSubstitute(Date.class, Date.class).apiInfo(apiInfo());
+    }
+}

+ 30 - 0
src/main/java/com/zx/dataservice/controller/ChoiceController.java

@@ -0,0 +1,30 @@
+package com.zx.dataservice.controller;
+
+import com.zx.dataservice.config.ServerResponse;
+import com.zx.dataservice.service.ChoiceStockService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping({"/api/"})
+@Api(value="获取板块信息")
+public class ChoiceController {
+
+    @Autowired
+    private ChoiceStockService choiceService;
+
+    // 获取Datafeed 配置数据
+    @RequestMapping(value = {"getPlateInfo"}, method = RequestMethod.GET)
+    @ResponseBody
+    @ApiOperation(value="获取东方财富板块信息", notes="获取东方财富板块信息")
+    public ServerResponse getPlateInfo() {
+        choiceService.getPlateInfo();
+        return ServerResponse.createBySuccess();
+    }
+
+}

+ 29 - 0
src/main/java/com/zx/dataservice/controller/TaskController.java

@@ -0,0 +1,29 @@
+package com.zx.dataservice.controller;
+
+import com.zx.dataservice.config.ServerResponse;
+import com.zx.dataservice.service.ChoiceStockService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping({"/api/task"})
+@Api(value="触发定时任务")
+public class TaskController {
+
+    @Autowired
+    private ChoiceStockService choiceService;
+
+    // 获取Datafeed 配置数据
+    @RequestMapping(value = {"toTask"}, method = RequestMethod.GET)
+    @ResponseBody
+    @ApiOperation(value="触发定时任务", notes="触发定时任务")
+    public ServerResponse getPlateInfo() {
+        choiceService.analysisStockRestData();
+        return ServerResponse.createBySuccess();
+    }
+}

+ 15 - 0
src/main/java/com/zx/dataservice/mapper1/ChoiceStockMapper.java

@@ -0,0 +1,15 @@
+package com.zx.dataservice.mapper1;
+
+import com.zx.dataservice.pojo.StockRestPojo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface ChoiceStockMapper {
+    void insertIntoRestData(@Param("tableName") String tableName, @Param("info") StockRestPojo stockRestPojo);
+
+
+    void insertBatch(@Param("list") List<StockRestPojo> stockRestPojoList);
+}

+ 14 - 0
src/main/java/com/zx/dataservice/mapper2/StockMapper.java

@@ -0,0 +1,14 @@
+package com.zx.dataservice.mapper2;
+
+import com.zx.dataservice.pojo.StockRestPojo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface StockMapper {
+    void updateStockInfo(@Param("stockCode") String stockCode, @Param("info") StockRestPojo stockRestPojo);
+
+    void updateBatchStockInfo(@Param("list") List<StockRestPojo> stockRestPojoList);
+}

+ 16 - 0
src/main/java/com/zx/dataservice/mapper3/ChoiceBondMapper.java

@@ -0,0 +1,16 @@
+package com.zx.dataservice.mapper3;
+
+
+import com.zx.dataservice.pojo.StockRestPojo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface ChoiceBondMapper {
+
+    void insertIntoRestData(@Param("tableName") String tableName, @Param("info") StockRestPojo stockRestPojo);
+
+    void insertBatch(@Param("list") List<StockRestPojo> stockRestPojoList);
+}

+ 61 - 0
src/main/java/com/zx/dataservice/pojo/StockRestPojo.java

@@ -0,0 +1,61 @@
+package com.zx.dataservice.pojo;
+
+import lombok.Data;
+
+@Data
+public class StockRestPojo {
+    private String code;
+    private String tableName;
+    private String date;
+    private String time;
+    private String now;
+    private String high;
+    private String low;
+    private String open;
+    private String close;
+    private String preclose;
+    private String roundlot;
+    private String change;
+    private String pctchange;
+    private String volume;
+    private String amount;
+    private String volumeratio;
+    private String commissionratio;
+    private String commissiondiff;
+    private String tradestatus;
+    private String outvolume;
+    private String involume;
+    private String highlimit;
+    private String lowlimit;
+    private String speed;
+    private String averageprice;
+    private String buyprice1;
+    private String buyprice2;
+    private String buyprice3;
+    private String buyprice4;
+    private String buyprice5;
+    private String buyvolume1;
+    private String buyvolume2;
+    private String buyvolume3;
+    private String buyvolume4;
+    private String buyvolume5;
+    private String sellprice1;
+    private String sellprice2;
+    private String sellprice3;
+    private String sellprice4;
+    private String sellprice5;
+    private String sellvolume1;
+    private String sellvolume2;
+    private String sellvolume3;
+    private String sellvolume4;
+    private String sellvolume5;
+    private String closedtime;
+    private String closedvolume;
+    private String closedamount;
+    private Long dateOne;
+    private Long dateFive;
+    private Long dateFifteen;
+    private Long dateThirty;
+    private Long dateSixty;
+    private Long realTime;
+}

+ 7 - 0
src/main/java/com/zx/dataservice/service/ChoiceBondService.java

@@ -0,0 +1,7 @@
+package com.zx.dataservice.service;
+
+public interface ChoiceBondService {
+
+    void analysisBondRestData();
+
+}

+ 14 - 0
src/main/java/com/zx/dataservice/service/ChoiceStockService.java

@@ -0,0 +1,14 @@
+package com.zx.dataservice.service;
+
+public interface ChoiceStockService {
+    /**
+     * 获取东方财富板块列表
+     */
+    void getPlateInfo();
+
+    /**
+     * 解析东方财富数据
+     */
+    void analysisStockRestData();
+
+}

+ 188 - 0
src/main/java/com/zx/dataservice/service/impl/ChoiceBondServiceImpl.java

@@ -0,0 +1,188 @@
+package com.zx.dataservice.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.zx.dataservice.mapper2.StockMapper;
+import com.zx.dataservice.mapper3.ChoiceBondMapper;
+import com.zx.dataservice.pojo.StockRestPojo;
+import com.zx.dataservice.service.ChoiceBondService;
+import com.zx.dataservice.utils.DateTimeUtil;
+import com.zx.dataservice.utils.FileBondUtil;
+import com.zx.dataservice.utils.TimeUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.*;
+
+@Service
+public class ChoiceBondServiceImpl implements ChoiceBondService {
+
+    private static final Logger log = LoggerFactory.getLogger(ChoiceBondServiceImpl.class);
+
+    private static final String sourceFileUrl = "/www/wwwroot/csqdata/bond";
+
+    private static final String goalFileUrl = "/www/wwwroot/csqdata/bond/backup";
+
+    @Autowired
+    private ChoiceBondMapper choiceBondMapper;
+
+    @Autowired
+    private StockMapper stockMapper;
+
+    @Override
+    public void analysisBondRestData() {
+        // 1.获取文件夹文件 按照时间顺序拿到一个
+        List<File> files = FileBondUtil.getFile(sourceFileUrl);
+        if (null == files || 0 == files.size()) {
+            return;
+        }
+        List<StockRestPojo> stockRestPojoList = new ArrayList<>();
+        for (File file : files) {
+            log.info("债券==当前操作文件名==" + file.getName());
+            // 2.移动文件去另外一个文件夹
+            FileBondUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
+            // 3.读取文件内容
+            String str = FileBondUtil.readFileContent(goalFileUrl + File.separator + file.getName());
+            // 4.并解析
+            if(StringUtils.isEmpty(str)){
+                continue;
+            }
+            Map<String, List<String>> map = new HashMap<String, List<String>>();
+            map = JSON.parseObject(str, HashMap.class);
+            str = null;
+            StockRestPojo stockRestPojo;
+            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+                stockRestPojo = new StockRestPojo();
+                stockRestPojo.setDate(String.valueOf(entry.getValue().get(0)));
+                stockRestPojo.setTime(String.valueOf(entry.getValue().get(1)));
+                stockRestPojo.setNow(String.valueOf(entry.getValue().get(2)));
+                stockRestPojo.setHigh(String.valueOf(entry.getValue().get(3)));
+                stockRestPojo.setLow(String.valueOf(entry.getValue().get(4)));
+                stockRestPojo.setOpen(String.valueOf(entry.getValue().get(5)));
+                stockRestPojo.setPreclose(String.valueOf(entry.getValue().get(6)));
+                stockRestPojo.setRoundlot(String.valueOf(entry.getValue().get(7)));
+                stockRestPojo.setChange(String.valueOf(entry.getValue().get(8)));
+                stockRestPojo.setPctchange(String.valueOf(entry.getValue().get(9)));
+                stockRestPojo.setVolume(String.valueOf(entry.getValue().get(10)));
+                stockRestPojo.setAmount(String.valueOf(entry.getValue().get(11)));
+                stockRestPojo.setVolumeratio("");
+                stockRestPojo.setCommissionratio("");
+                stockRestPojo.setCommissiondiff("");
+                stockRestPojo.setTradestatus("");
+                stockRestPojo.setOutvolume("");
+                stockRestPojo.setInvolume("");
+                stockRestPojo.setHighlimit("");
+                stockRestPojo.setLowlimit("");
+                stockRestPojo.setSpeed("");
+                stockRestPojo.setAverageprice("");
+
+                stockRestPojo.setBuyprice1(String.valueOf(entry.getValue().get(12)));
+                stockRestPojo.setBuyprice2(String.valueOf(entry.getValue().get(13)));
+                stockRestPojo.setBuyprice3(String.valueOf(entry.getValue().get(14)));
+                stockRestPojo.setBuyprice4(String.valueOf(entry.getValue().get(15)));
+                stockRestPojo.setBuyprice5(String.valueOf(entry.getValue().get(16)));
+                stockRestPojo.setBuyvolume1(String.valueOf(entry.getValue().get(17)));
+                stockRestPojo.setBuyvolume2(String.valueOf(entry.getValue().get(18)));
+                stockRestPojo.setBuyvolume3(String.valueOf(entry.getValue().get(19)));
+                stockRestPojo.setBuyvolume4(String.valueOf(entry.getValue().get(20)));
+                stockRestPojo.setBuyvolume5(String.valueOf(entry.getValue().get(21)));
+                stockRestPojo.setSellprice1(String.valueOf(entry.getValue().get(22)));
+                stockRestPojo.setSellprice2(String.valueOf(entry.getValue().get(23)));
+                stockRestPojo.setSellprice3(String.valueOf(entry.getValue().get(24)));
+                stockRestPojo.setSellprice4(String.valueOf(entry.getValue().get(25)));
+                stockRestPojo.setSellprice5(String.valueOf(entry.getValue().get(26)));
+                stockRestPojo.setSellvolume1(String.valueOf(entry.getValue().get(27)));
+                stockRestPojo.setSellvolume2(String.valueOf(entry.getValue().get(28)));
+                stockRestPojo.setSellvolume3(String.valueOf(entry.getValue().get(29)));
+                stockRestPojo.setSellvolume4(String.valueOf(entry.getValue().get(30)));
+                stockRestPojo.setSellvolume5(String.valueOf(entry.getValue().get(31)));
+                stockRestPojo.setClosedtime("");
+                stockRestPojo.setClosedvolume("");
+                stockRestPojo.setClosedamount("");
+                StringBuffer dateStr = new StringBuffer(stockRestPojo.getDate());
+                if (StringUtils.isEmpty(stockRestPojo.getTime())) {
+                    dateStr = dateStr.append(000000);
+                } else {
+                    if (5 == stockRestPojo.getTime().length()) {
+                        // 长度为5表示 小时前面需要补0
+                        dateStr = dateStr.append(0).append(stockRestPojo.getTime());
+                    } else {
+                        dateStr = dateStr.append(stockRestPojo.getTime());
+                    }
+                }
+                Date date = TimeUtil.strToDate(dateStr.toString());
+                // 毫秒转成秒
+                stockRestPojo.setRealTime(date.getTime() / 1000);
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(date);
+                int min = calendar.get(Calendar.MINUTE); // 获取分钟
+                int sec = calendar.get(Calendar.SECOND); // 获取秒数
+
+                // 1分钟数据
+                if (sec != 0) {
+                    stockRestPojo.setDateOne(stockRestPojo.getRealTime() + 60 - sec);
+                } else {
+                    stockRestPojo.setDateOne(stockRestPojo.getRealTime());
+                }
+
+                // 5分钟数据
+                if (sec != 0 || min % 5 != 0) {
+                    stockRestPojo.setDateFive(stockRestPojo.getRealTime() + (5 * 60) - sec - (min % 5 * 60));
+                } else {
+                    stockRestPojo.setDateFive(stockRestPojo.getRealTime());
+                }
+
+                // 15分钟数据
+                if (sec != 0 || min % 15 != 0) {
+                    stockRestPojo.setDateFifteen(stockRestPojo.getRealTime() + (15 * 60) - sec - (min % 15 * 60));
+                } else {
+                    stockRestPojo.setDateFifteen(stockRestPojo.getRealTime());
+                }
+
+                // 30分钟数据
+                if (sec != 0 || min % 30 != 0) {
+                    stockRestPojo.setDateThirty(stockRestPojo.getRealTime() + (30 * 60) - sec - (min % 30 * 60));
+                } else {
+                    stockRestPojo.setDateThirty(stockRestPojo.getRealTime());
+                }
+
+                // 60分钟数据
+                if (sec != 0 || min % 60 != 0) {
+                    stockRestPojo.setDateSixty(stockRestPojo.getRealTime() + (60 * 60) - sec - (min % 60 * 60));
+                } else {
+                    stockRestPojo.setDateSixty(stockRestPojo.getRealTime());
+                }
+                StringBuffer tableName = new StringBuffer("data_rt_");
+                tableName.append(entry.getKey().replace(".", "_").toLowerCase());
+                stockRestPojo.setCode(entry.getKey().toLowerCase());
+                stockRestPojo.setTableName(tableName.toString());
+                stockRestPojoList.add(stockRestPojo);
+            }
+            map = null;
+        }
+        // 5.入库
+        insertList(stockRestPojoList);
+        stockRestPojoList = null;
+    }
+
+    private void insertList(List<StockRestPojo> list) {
+        log.info("=====入库==债券==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+        int insertLength = list.size();
+        int i = 0;
+        int insertSize = 200;
+        while (insertLength > insertSize) {
+            choiceBondMapper.insertBatch(list.subList(i, i + insertSize));
+//            stockMapper.updateBatchStockInfo(list.subList(i, i + 500));
+            i = i + insertSize;
+            insertLength = insertLength - insertSize;
+        }
+        if (insertLength > 0) {
+            choiceBondMapper.insertBatch(list.subList(i, i + insertLength));
+//            stockMapper.updateBatchStockInfo(list.subList(i, i + insertLength));
+        }
+        log.info("=====入库==债券==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+    }
+}

+ 202 - 0
src/main/java/com/zx/dataservice/service/impl/ChoiceStockServiceImpl.java

@@ -0,0 +1,202 @@
+package com.zx.dataservice.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.zx.dataservice.mapper1.ChoiceStockMapper;
+import com.zx.dataservice.mapper2.StockMapper;
+import com.zx.dataservice.pojo.StockRestPojo;
+import com.zx.dataservice.service.ChoiceStockService;
+import com.zx.dataservice.utils.DateTimeUtil;
+import com.zx.dataservice.utils.FileStockUtil;
+import com.zx.dataservice.utils.TimeUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.*;
+
+@Service
+public class ChoiceStockServiceImpl implements ChoiceStockService {
+
+    private static final Logger log = LoggerFactory.getLogger(ChoiceStockServiceImpl.class);
+
+    private static final String sourceFileUrl = "/www/wwwroot/csqdata/stock";
+
+    private static final String goalFileUrl = "/www/wwwroot/csqdata/stock/backup";
+
+    @Autowired
+    private ChoiceStockMapper choiceStockMapper;
+
+    @Autowired
+    private StockMapper stockMapper;
+
+    @Override
+    public void getPlateInfo() {
+
+    }
+
+    @Override
+    public void analysisStockRestData() {
+        // 1.获取文件夹文件 按照时间顺序拿到一个
+        List<File> files = FileStockUtil.getFile(sourceFileUrl);
+        if(null == files || 0 == files.size()){
+            return;
+        }
+        List<StockRestPojo> stockRestPojoList = new ArrayList<>();
+        for (File file : files){
+            log.info("股票==当前操作文件名==" + file.getName());
+            // 2.移动文件去另外一个文件夹
+            FileStockUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
+            // 3.读取文件内容
+            String str = FileStockUtil.readFileContent(goalFileUrl + File.separator + file.getName());
+            // 4.并解析
+            if(StringUtils.isEmpty(str)){
+                continue;
+            }
+            Map<String, List<String>> map = new HashMap<String, List<String>>();
+            map = JSON.parseObject(str, HashMap.class);
+            str = null;
+            StockRestPojo stockRestPojo;
+            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+                stockRestPojo = new StockRestPojo();
+                stockRestPojo.setDate(String.valueOf(entry.getValue().get(0)));
+                stockRestPojo.setTime(String.valueOf(entry.getValue().get(1)));
+                stockRestPojo.setNow(String.valueOf(entry.getValue().get(2)));
+                stockRestPojo.setHigh(String.valueOf(entry.getValue().get(3)));
+                stockRestPojo.setLow(String.valueOf(entry.getValue().get(4)));
+                stockRestPojo.setOpen(String.valueOf(entry.getValue().get(5)));
+                stockRestPojo.setPreclose(String.valueOf(entry.getValue().get(6)));
+                stockRestPojo.setRoundlot(String.valueOf(entry.getValue().get(7)));
+                stockRestPojo.setChange(String.valueOf(entry.getValue().get(8)));
+                stockRestPojo.setPctchange(String.valueOf(entry.getValue().get(9)));
+                stockRestPojo.setVolume(String.valueOf(entry.getValue().get(10)));
+                stockRestPojo.setAmount(String.valueOf(entry.getValue().get(11)));
+                stockRestPojo.setVolumeratio(String.valueOf(entry.getValue().get(12)));
+                stockRestPojo.setCommissionratio(String.valueOf(entry.getValue().get(13)));
+                stockRestPojo.setCommissiondiff(String.valueOf(entry.getValue().get(14)));
+                stockRestPojo.setTradestatus(String.valueOf(entry.getValue().get(15)));
+                stockRestPojo.setOutvolume(String.valueOf(entry.getValue().get(16)));
+                stockRestPojo.setInvolume(String.valueOf(entry.getValue().get(17)));
+                stockRestPojo.setHighlimit(String.valueOf(entry.getValue().get(18)));
+                stockRestPojo.setLowlimit(String.valueOf(entry.getValue().get(19)));
+                stockRestPojo.setSpeed(String.valueOf(entry.getValue().get(20)));
+                stockRestPojo.setAverageprice(String.valueOf(entry.getValue().get(21)));
+                stockRestPojo.setBuyprice1(String.valueOf(entry.getValue().get(22)));
+                stockRestPojo.setBuyprice2(String.valueOf(entry.getValue().get(23)));
+                stockRestPojo.setBuyprice3(String.valueOf(entry.getValue().get(24)));
+                stockRestPojo.setBuyprice4(String.valueOf(entry.getValue().get(25)));
+                stockRestPojo.setBuyprice5(String.valueOf(entry.getValue().get(26)));
+                stockRestPojo.setBuyvolume1(String.valueOf(entry.getValue().get(27)));
+                stockRestPojo.setBuyvolume2(String.valueOf(entry.getValue().get(28)));
+                stockRestPojo.setBuyvolume3(String.valueOf(entry.getValue().get(29)));
+                stockRestPojo.setBuyvolume4(String.valueOf(entry.getValue().get(30)));
+                stockRestPojo.setBuyvolume5(String.valueOf(entry.getValue().get(31)));
+                stockRestPojo.setSellprice1(String.valueOf(entry.getValue().get(32)));
+                stockRestPojo.setSellprice2(String.valueOf(entry.getValue().get(33)));
+                stockRestPojo.setSellprice3(String.valueOf(entry.getValue().get(34)));
+                stockRestPojo.setSellprice4(String.valueOf(entry.getValue().get(35)));
+                stockRestPojo.setSellprice5(String.valueOf(entry.getValue().get(36)));
+                stockRestPojo.setSellvolume1(String.valueOf(entry.getValue().get(37)));
+                stockRestPojo.setSellvolume2(String.valueOf(entry.getValue().get(38)));
+                stockRestPojo.setSellvolume3(String.valueOf(entry.getValue().get(39)));
+                stockRestPojo.setSellvolume4(String.valueOf(entry.getValue().get(40)));
+                stockRestPojo.setSellvolume5(String.valueOf(entry.getValue().get(41)));
+                stockRestPojo.setClosedtime(String.valueOf(entry.getValue().get(42)));
+                stockRestPojo.setClosedvolume(String.valueOf(entry.getValue().get(43)));
+                stockRestPojo.setClosedamount(String.valueOf(entry.getValue().get(44)));
+                StringBuffer dateStr = new StringBuffer(stockRestPojo.getDate());
+                if (StringUtils.isEmpty(stockRestPojo.getTime())) {
+                    dateStr = dateStr.append(000000);
+                } else {
+                    if (5 == stockRestPojo.getTime().length()) {
+                        // 长度为5表示 小时前面需要补0
+                        dateStr = dateStr.append(0).append(stockRestPojo.getTime());
+                    } else {
+                        dateStr = dateStr.append(stockRestPojo.getTime());
+                    }
+                }
+                Date date = TimeUtil.strToDate(dateStr.toString());
+                // 毫秒转成秒
+                stockRestPojo.setRealTime(date.getTime() / 1000);
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(date);
+                int min = calendar.get(Calendar.MINUTE); // 获取分钟
+                int sec = calendar.get(Calendar.SECOND); // 获取秒数
+
+                // 1分钟数据
+                if (sec != 0) {
+                    stockRestPojo.setDateOne(stockRestPojo.getRealTime() + 60 - sec);
+                } else {
+                    stockRestPojo.setDateOne(stockRestPojo.getRealTime());
+                }
+
+                // 5分钟数据
+                if (sec != 0 || min % 5 != 0) {
+                    stockRestPojo.setDateFive(stockRestPojo.getRealTime() + (5 * 60) - sec - (min % 5 * 60));
+                } else {
+                    stockRestPojo.setDateFive(stockRestPojo.getRealTime());
+                }
+
+                // 15分钟数据
+                if (sec != 0 || min % 15 != 0) {
+                    stockRestPojo.setDateFifteen(stockRestPojo.getRealTime() + (15 * 60) - sec - (min % 15 * 60));
+                } else {
+                    stockRestPojo.setDateFifteen(stockRestPojo.getRealTime());
+                }
+
+                // 30分钟数据
+                if (sec != 0 || min % 30 != 0) {
+                    stockRestPojo.setDateThirty(stockRestPojo.getRealTime() + (30 * 60) - sec - (min % 30 * 60));
+                } else {
+                    stockRestPojo.setDateThirty(stockRestPojo.getRealTime());
+                }
+
+                // 60分钟数据
+                if (sec != 0 || min % 60 != 0) {
+                    stockRestPojo.setDateSixty(stockRestPojo.getRealTime() + (60 * 60) - sec - (min % 60 * 60));
+                } else {
+                    stockRestPojo.setDateSixty(stockRestPojo.getRealTime());
+                }
+                StringBuffer tableName = new StringBuffer("data_rt_");
+                tableName.append(entry.getKey().replace(".", "_").toLowerCase());
+                stockRestPojo.setCode(entry.getKey().toLowerCase());
+                stockRestPojo.setTableName(tableName.toString());
+                stockRestPojoList.add(stockRestPojo);
+            }
+            map = null;
+        }
+        // 5.入库
+        insertList(stockRestPojoList);
+        stockRestPojoList = null;
+    }
+
+    private void insertList(List<StockRestPojo> list) {
+//        try {
+            log.info("=====入库===股票==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+            int insertLength = list.size();
+            int i = 0;
+            int insertSize = 500;
+            while (insertLength > insertSize) {
+                choiceStockMapper.insertBatch(list.subList(i, i + insertSize));
+//                Thread.sleep(1000);
+                stockMapper.updateBatchStockInfo(list.subList(i, i + insertSize));
+//                Thread.sleep(1000);
+                i = i + insertSize;
+                insertLength = insertLength - insertSize;
+
+            }
+            if (insertLength > 0) {
+                choiceStockMapper.insertBatch(list.subList(i, i + insertLength));
+//                Thread.sleep(1000);
+                stockMapper.updateBatchStockInfo(list.subList(i, i + insertLength));
+            }
+            log.info("=====入库==股票==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+//        } catch (InterruptedException e) {
+//            e.printStackTrace();
+//            log.info(e.getLocalizedMessage());
+//            log.info(e.toString());
+//        }
+    }
+}

+ 37 - 0
src/main/java/com/zx/dataservice/task/AnalysisBondRestDataTask.java

@@ -0,0 +1,37 @@
+package com.zx.dataservice.task;
+
+import com.zx.dataservice.service.ChoiceBondService;
+import com.zx.dataservice.utils.DateTimeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 解析东方财富实时数据
+ */
+@Component
+public class AnalysisBondRestDataTask {
+
+    private static final Logger log = LoggerFactory.getLogger(AnalysisBondRestDataTask.class);
+
+    @Autowired
+    private ChoiceBondService choiceBondService;
+
+    @Async("executorBond")
+//    @Scheduled(cron = "0/1 * * * * ?")
+    @Scheduled(fixedRate=10)
+    public void toAnalysisRestData() {
+        log.info("=====定时任务===解析东方财富数据==债券==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+        doTask();
+        log.info("=====定时任务===解析东方财富数据==债券==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+    }
+
+    public void doTask() {
+        this.choiceBondService.analysisBondRestData();
+    }
+}

+ 38 - 0
src/main/java/com/zx/dataservice/task/AnalysisStockRestDataTask.java

@@ -0,0 +1,38 @@
+package com.zx.dataservice.task;
+
+import com.zx.dataservice.service.ChoiceStockService;
+import com.zx.dataservice.utils.DateTimeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 解析东方财富实时数据
+ */
+@Component
+public class AnalysisStockRestDataTask {
+
+    private static final Logger log = LoggerFactory.getLogger(AnalysisStockRestDataTask.class);
+
+    @Autowired
+    private ChoiceStockService choiceStockService;
+
+    @Async("executorStock")
+//    @Scheduled(cron = "0/1 * * * * ?")
+    @Scheduled(fixedRate=10)
+    public void toAnalysisRestData() throws InterruptedException {
+        log.info("=====定时任务===解析东方财富数据==股票==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+        doTask();
+        log.info("=====定时任务===解析东方财富数据==股票==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+//        Thread.sleep(2000);
+    }
+
+    public void doTask() {
+        this.choiceStockService.analysisStockRestData();
+    }
+}

+ 49 - 0
src/main/java/com/zx/dataservice/task/TaskConfig.java

@@ -0,0 +1,49 @@
+package com.zx.dataservice.task;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+@Configuration
+@EnableAsync
+public class TaskConfig {
+
+
+//    @Bean
+//    public TaskScheduler taskScheduler() {
+//         ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
+//        // 设置scheduler执行线程为20个
+//         scheduler.setPoolSize(2000);
+//         return scheduler;
+//    }
+
+    @Bean("executorStock")
+    public Executor taskSchedulerStock() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        //核心线程数
+        executor.setCorePoolSize(100);
+        //最大核心线程数
+        executor.setMaxPoolSize(200);
+        //队列中等待被调度的任务数
+        executor.setQueueCapacity(20);
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        return executor;
+    }
+
+    @Bean("executorBond")
+    public Executor taskSchedulerBond() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        //核心线程数
+        executor.setCorePoolSize(50);
+        //最大核心线程数
+        executor.setMaxPoolSize(100);
+        //队列中等待被调度的任务数
+        executor.setQueueCapacity(20);
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        return executor;
+    }
+}

+ 19 - 0
src/main/java/com/zx/dataservice/utils/ChoiceUtil.java

@@ -0,0 +1,19 @@
+package com.zx.dataservice.utils;
+
+import com.zx.dataservice.vo.SystemBoard;
+
+import java.util.List;
+
+public class ChoiceUtil {
+
+
+    private static String getSystemBoardUrl = "http://quantapi.eastmoney.com/Command/Sector/GetSystemBoard";
+
+    private static String getLeafNodeSystemBoardUrl = "http://quantapi.eastmoney.com/Command/Sector/GetLeafNodeSystemBoardBy";
+
+
+    public static List<SystemBoard> getSystemBoard(){
+//        HttpRequest.doGet(getSystemBoardUrl,);
+        return null;
+    }
+}

+ 127 - 0
src/main/java/com/zx/dataservice/utils/DateTimeUtil.java

@@ -0,0 +1,127 @@
+package com.zx.dataservice.utils;
+
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+public class DateTimeUtil {
+    private static final Logger log = LoggerFactory.getLogger(DateTimeUtil.class);
+
+
+    public static final String STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+
+    public static final String YMD_FORMAT = "yyyy-MM-dd";
+
+
+    public static final String HM_FORMAT = "HH:mm";
+
+
+    public static Date getCurrentDate() {
+        return new Date();
+    }
+
+
+    public static Date strToDate(String dateTimeStr, String formatStr) {
+        DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(formatStr);
+        DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr);
+        return dateTime.toDate();
+    }
+
+
+    public static String dateToStr(Date date, String formatStr) {
+        if (date == null) {
+            return "";
+        }
+        DateTime dateTime = new DateTime(date);
+        return dateTime.toString(formatStr);
+    }
+
+    public static Date strToDate(String dateTimeStr) {
+        DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
+        DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr);
+        return dateTime.toDate();
+    }
+
+    public static Timestamp searchStrToTimestamp(String dateTimeStr) {
+        return Timestamp.valueOf(dateTimeStr);
+    }
+
+
+    public static String dateToStr(Date date) {
+        if (date == null) {
+            return "";
+        }
+        DateTime dateTime = new DateTime(date);
+        return dateTime.toString("yyyy-MM-dd HH:mm:ss");
+    }
+
+
+    public static Date longToDate(Long time) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        String d = format.format(time);
+
+        Date date = null;
+        try {
+            date = format.parse(d);
+        } catch (Exception e) {
+            log.error("datetime utils longToDate error");
+        }
+        return date;
+    }
+
+
+    public static Date doEndTime(Date begintime, int month) {
+        Long begintimelong = Long.valueOf(begintime.getTime() / 1000L);
+        log.info("计算时间 传入时间 = {} , 时间戳 = {}", dateToStr(begintime), begintimelong);
+
+        Long endtimelong = Long.valueOf(begintimelong.longValue() + (2592000 * month));
+        Date endtimedate = longToDate(Long.valueOf(endtimelong.longValue() * 1000L));
+
+        log.info("endtime 时间戳 = {},时间 = {} , 格式化时间={}", new Object[]{endtimelong, endtimedate,
+                dateToStr(endtimedate)});
+
+        return endtimedate;
+    }
+
+
+    public static String getCurrentTimeMiao() {
+        return String.valueOf(System.currentTimeMillis() / 1000L);
+    }
+
+
+    public static Date parseToDateByMinute(int minuteTimes) {
+        Date nowDate = new Date();
+        Long nowtimes = Long.valueOf(nowDate.getTime() / 1000L);
+
+        Long beginTimesLong = Long.valueOf(nowtimes.longValue() - (minuteTimes * 60));
+        return longToDate(Long.valueOf(beginTimesLong.longValue() * 1000L));
+    }
+
+
+    public static boolean isCanSell(Date buyDate, int maxMinutes) {
+        Long buyDateTimes = Long.valueOf(buyDate.getTime() / 1000L);
+
+        buyDateTimes = Long.valueOf(buyDateTimes.longValue() + (maxMinutes * 60));
+
+        Long nowDateTimes = Long.valueOf((new Date()).getTime() / 1000L);
+
+        if (nowDateTimes.longValue() > buyDateTimes.longValue()) {
+            return true;
+        }
+        return false;
+    }
+
+
+    public static void main(String[] args) {
+        parseToDateByMinute(10);
+    }
+}

+ 155 - 0
src/main/java/com/zx/dataservice/utils/FileBondUtil.java

@@ -0,0 +1,155 @@
+package com.zx.dataservice.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.*;
+
+public class FileBondUtil {
+
+    private static Set<String> fileNameSet = new HashSet<>();
+
+    private static final Logger log = LoggerFactory.getLogger(FileBondUtil.class);
+
+    /**
+     * 根据时间对文件进行排序
+     * @param path
+     * @return
+     */
+    public static File getFileSort(String path) {
+        List<File> list = getFileList(path, new ArrayList<File>());
+        if(0 == list.size()){
+            return null;
+        }
+//        if (list != null && list.size() > 0) {
+//            Collections.sort(list, new Comparator<File>() {
+//                public int compare(File file, File newFile) {
+//                    if (file.lastModified() < newFile.lastModified()) {
+//                        return -1;
+//                    } else if (file.lastModified() == newFile.lastModified()) {
+//                        return 0;
+//                    } else {
+//                        return 1;
+//                    }
+//                }
+//            });
+//        }
+        return list.get(0);
+    }
+
+    public static List<File> getFile(String path) {
+        List<File> list = getFileList(path, new ArrayList<File>());
+        if(0 == list.size()){
+            return null;
+        }
+        if (list != null && list.size() > 0) {
+            Collections.sort(list, new Comparator<File>() {
+                public int compare(File file, File newFile) {
+                    if (file.lastModified() < newFile.lastModified()) {
+                        return -1;
+                    } else if (file.lastModified() == newFile.lastModified()) {
+                        return 0;
+                    } else {
+                        return 1;
+                    }
+                }
+            });
+        }
+        return list;
+    }
+
+    /**
+     * 获取文件
+     * @param realpath
+     * @param files
+     * @return
+     */
+    public static List<File> getFileList(String realpath, List<File> files) {
+        File realFile = new File(realpath);
+        if (realFile.isDirectory()) {
+            File[] subfiles = realFile.listFiles();
+            for (File file : subfiles) {
+                if (!file.isDirectory()) {
+                    if(fileNameSet.add(file.getName())) {
+                        files.add(file);
+                        if(10000 < fileNameSet.size()){
+                            fileNameSet = new HashSet<>();
+                        }
+//                        return files;
+                        if(10 == files.size()) {
+                            return files;
+                        }
+                    }
+                }
+            }
+        }
+        return files;
+    }
+
+    /**
+     * 移动文件
+     * @param sourceFileUrl 来源文件
+     * @param goalFileUrl 目标文件夹
+     */
+    public static void moveFile(String sourceFileUrl, String goalFileUrl){
+        // 源文件路径
+        File startFile=new File(sourceFileUrl);
+        // 目的目录路径
+        File endDirection=new File(goalFileUrl);
+        // 如果目的目录路径不存在,则进行创建
+        if(!endDirection.exists()) {
+            endDirection.mkdirs();
+        }
+        //目的文件路径=目的目录路径+源文件名称
+        File endFile = new File(endDirection + File.separator + startFile.getName());
+        try {
+	        // 调用File类的核心方法renameTo
+            startFile.renameTo(endFile);
+        }catch(Exception e) {
+            log.error("文件移动出现异常!起始路径:{"+startFile.getAbsolutePath()+"}");
+        }
+    }
+
+    public static String readFileContent(String fileName) {
+        File file = new File(fileName);
+        if(null == file){
+            return null;
+        }
+        BufferedReader reader = null;
+        StringBuffer sbf = new StringBuffer();
+        try {
+            reader = new BufferedReader(new FileReader(file));
+            String tempStr;
+            while ((tempStr = reader.readLine()) != null) {
+                sbf.append(tempStr);
+            }
+            reader.close();
+            return sbf.toString();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+        }
+//        deleteFile(fileName);
+        return sbf.toString();
+    }
+
+     public static boolean deleteFile(String path) {
+         File file = new File(path);
+         if (file.isFile() && file.exists()) {
+             file.delete();
+             return true;
+         }
+         return false;
+    }
+}

+ 155 - 0
src/main/java/com/zx/dataservice/utils/FileStockUtil.java

@@ -0,0 +1,155 @@
+package com.zx.dataservice.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.*;
+
+public class FileStockUtil {
+
+    private static Set<String> fileNameSet = new HashSet<>();
+
+    private static final Logger log = LoggerFactory.getLogger(FileStockUtil.class);
+
+    /**
+     * 根据时间对文件进行排序
+     * @param path
+     * @return
+     */
+    public static File getFileSort(String path) {
+        List<File> list = getFileList(path, new ArrayList<File>());
+        if(0 == list.size()){
+            return null;
+        }
+//        if (list != null && list.size() > 0) {
+//            Collections.sort(list, new Comparator<File>() {
+//                public int compare(File file, File newFile) {
+//                    if (file.lastModified() < newFile.lastModified()) {
+//                        return -1;
+//                    } else if (file.lastModified() == newFile.lastModified()) {
+//                        return 0;
+//                    } else {
+//                        return 1;
+//                    }
+//                }
+//            });
+//        }
+        return list.get(0);
+    }
+
+    public static List<File> getFile(String path) {
+        List<File> list = getFileList(path, new ArrayList<File>());
+        if(0 == list.size()){
+            return null;
+        }
+        if (list != null && list.size() > 0) {
+            Collections.sort(list, new Comparator<File>() {
+                public int compare(File file, File newFile) {
+                    if (file.lastModified() < newFile.lastModified()) {
+                        return -1;
+                    } else if (file.lastModified() == newFile.lastModified()) {
+                        return 0;
+                    } else {
+                        return 1;
+                    }
+                }
+            });
+        }
+        return list;
+    }
+
+    /**
+     * 获取文件
+     * @param realpath
+     * @param files
+     * @return
+     */
+    public static List<File> getFileList(String realpath, List<File> files) {
+        File realFile = new File(realpath);
+        if (realFile.isDirectory()) {
+            File[] subfiles = realFile.listFiles();
+            for (File file : subfiles) {
+                if (!file.isDirectory()) {
+                    if(fileNameSet.add(file.getName())) {
+                        files.add(file);
+                        if(10000 < fileNameSet.size()){
+                            fileNameSet = new HashSet<>();
+                        }
+//                        return files;
+                        if(10 == files.size()) {
+                            return files;
+                        }
+                    }
+                }
+            }
+        }
+        return files;
+    }
+
+    /**
+     * 移动文件
+     * @param sourceFileUrl 来源文件
+     * @param goalFileUrl 目标文件夹
+     */
+    public static void moveFile(String sourceFileUrl, String goalFileUrl){
+        // 源文件路径
+        File startFile=new File(sourceFileUrl);
+        // 目的目录路径
+        File endDirection=new File(goalFileUrl);
+        // 如果目的目录路径不存在,则进行创建
+        if(!endDirection.exists()) {
+            endDirection.mkdirs();
+        }
+        //目的文件路径=目的目录路径+源文件名称
+        File endFile = new File(endDirection + File.separator + startFile.getName());
+        try {
+	        // 调用File类的核心方法renameTo
+            startFile.renameTo(endFile);
+        }catch(Exception e) {
+            log.error("文件移动出现异常!起始路径:{"+startFile.getAbsolutePath()+"}");
+        }
+    }
+
+    public static String readFileContent(String fileName) {
+        File file = new File(fileName);
+        if(null == file){
+            return null;
+        }
+        BufferedReader reader = null;
+        StringBuffer sbf = new StringBuffer();
+        try {
+            reader = new BufferedReader(new FileReader(file));
+            String tempStr;
+            while ((tempStr = reader.readLine()) != null) {
+                sbf.append(tempStr);
+            }
+            reader.close();
+            return sbf.toString();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+        }
+//        deleteFile(fileName);
+        return sbf.toString();
+    }
+
+     public static boolean deleteFile(String path) {
+         File file = new File(path);
+         if (file.isFile() && file.exists()) {
+             file.delete();
+             return true;
+         }
+         return false;
+    }
+}

+ 106 - 0
src/main/java/com/zx/dataservice/utils/HttpRequest.java

@@ -0,0 +1,106 @@
+package com.zx.dataservice.utils;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+public class HttpRequest {
+
+    private static final Logger log = LoggerFactory.getLogger(HttpRequest.class);
+
+    public static String doGet(String url, String params) throws Exception {
+        URL localURL;
+        if(StringUtils.isNoneEmpty(params)) {
+            localURL = new URL(url + params);
+        }else {
+            localURL = new URL(url);
+        }
+        URLConnection connection = localURL.openConnection();
+        HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
+        httpURLConnection.setRequestProperty("Accept-Charset", "utf-8");
+        httpURLConnection.setRequestProperty("Content-Type", "application/text");
+        InputStream inputStream = null;
+        InputStreamReader inputStreamReader = null;
+        BufferedReader reader = null;
+        StringBuffer resultBuffer = new StringBuffer();
+        String tempLine = null;
+        if (httpURLConnection.getResponseCode() >= 300) {
+            throw new Exception("HTTP Request is not success, Response code is " + httpURLConnection.getResponseCode());
+        }
+        try {
+            inputStream = httpURLConnection.getInputStream();
+             inputStreamReader = new InputStreamReader(inputStream);
+            reader = new BufferedReader(inputStreamReader);
+            while ((tempLine = reader.readLine()) != null) {
+                resultBuffer.append(tempLine);
+            }
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+            if (inputStreamReader != null) {
+                inputStreamReader.close();
+            }
+            if (inputStream != null) {
+                inputStream.close();
+            }
+        }
+        return resultBuffer.toString();
+    }
+
+
+    public static String doPost(String url, Map<String, String> params) throws Exception {
+        HttpPost httpPost = new HttpPost(url);
+
+        DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
+        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+        if (params != null) {
+            BasicNameValuePair bnvp = null;
+            for (Map.Entry<String, String> p : params.entrySet()) {
+                bnvp = new BasicNameValuePair((String) p.getKey(), (String) p.getValue());
+            }
+        }
+        httpPost.setEntity(new UrlEncodedFormEntity(nvps));
+        HttpResponse response = defaultHttpClient.execute(httpPost);
+        HttpEntity respEntity = response.getEntity();
+        String text = EntityUtils.toString(respEntity, "UTF-8");
+
+        defaultHttpClient.getConnectionManager().shutdown();
+
+        return text;
+    }
+
+
+    public static void main(String[] args) {
+        String url = "http://quantapi.eastmoney.com/Command/Sector/GetSystemBoard";
+
+        String getret = "";
+        try {
+            getret = doGet(url, null);
+            System.out.println(getret);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        log.info("get ret : " + getret);
+    }
+}

+ 295 - 0
src/main/java/com/zx/dataservice/utils/OkHttpUtils.java

@@ -0,0 +1,295 @@
+package com.zx.dataservice.utils;
+
+import com.alibaba.fastjson.JSON;
+import okhttp3.*;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+public class OkHttpUtils {
+    private static volatile OkHttpClient okHttpClient = null;
+    private static volatile Semaphore semaphore = null;
+    private Map<String, String> headerMap;
+    private Map<String, String> paramMap;
+    private String url;
+    private Request.Builder request;
+
+    /**
+     * 初始化okHttpClient,并且允许https访问
+     */
+    private OkHttpUtils() {
+        if (okHttpClient == null) {
+            synchronized (OkHttpUtils.class) {
+                if (okHttpClient == null) {
+                    TrustManager[] trustManagers = buildTrustManagers();
+                    okHttpClient = new OkHttpClient.Builder()
+                            .connectTimeout(15, TimeUnit.SECONDS)
+                            .writeTimeout(20, TimeUnit.SECONDS)
+                            .readTimeout(20, TimeUnit.SECONDS)
+                            .sslSocketFactory(createSSLSocketFactory(trustManagers), (X509TrustManager) trustManagers[0])
+                            .hostnameVerifier((hostName, session) -> true)
+                            .retryOnConnectionFailure(true)
+                            .build();
+                    addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
+                }
+            }
+        }
+    }
+
+    /**
+     * 用于异步请求时,控制访问线程数,返回结果
+     *
+     * @return
+     */
+    private static Semaphore getSemaphoreInstance() {
+        //只能1个线程同时访问
+        synchronized (OkHttpUtils.class) {
+            if (semaphore == null) {
+                semaphore = new Semaphore(0);
+            }
+        }
+        return semaphore;
+    }
+
+    /**
+     * 创建OkHttpUtils
+     *
+     * @return
+     */
+    public static OkHttpUtils builder() {
+        return new OkHttpUtils();
+    }
+
+    /**
+     * 添加url
+     *
+     * @param url
+     * @return
+     */
+    public OkHttpUtils url(String url) {
+        this.url = url;
+        return this;
+    }
+
+    /**
+     * 添加参数
+     *
+     * @param key   参数名
+     * @param value 参数值
+     * @return
+     */
+    public OkHttpUtils addParam(String key, String value) {
+        if (paramMap == null) {
+            paramMap = new LinkedHashMap<>(16);
+        }
+        paramMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * 添加请求头
+     *
+     * @param key   参数名
+     * @param value 参数值
+     * @return
+     */
+    public OkHttpUtils addHeader(String key, String value) {
+        if (headerMap == null) {
+            headerMap = new LinkedHashMap<>(16);
+        }
+        headerMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * 初始化get方法
+     *
+     * @return
+     */
+    public OkHttpUtils get() {
+        request = new Request.Builder().get();
+        StringBuilder urlBuilder = new StringBuilder(url);
+        if (paramMap != null) {
+            urlBuilder.append("?");
+            try {
+                for (Map.Entry<String, String> entry : paramMap.entrySet()) {
+                    urlBuilder.append(URLEncoder.encode(entry.getKey(), "utf-8")).
+                            append("=").
+                            append(URLEncoder.encode(entry.getValue(), "utf-8")).
+                            append("&");
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            urlBuilder.deleteCharAt(urlBuilder.length() - 1);
+        }
+        request.url(urlBuilder.toString());
+        return this;
+    }
+
+    /**
+     * 初始化post方法
+     *
+     * @param isJsonPost true等于json的方式提交数据,类似postman里post方法的raw
+     *                   false等于普通的表单提交
+     * @return
+     */
+    public OkHttpUtils post(boolean isJsonPost) {
+        RequestBody requestBody;
+        if (isJsonPost) {
+            String json = "";
+            if (paramMap != null) {
+                json = JSON.toJSONString(paramMap);
+            }
+            requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json);
+        } else {
+            FormBody.Builder formBody = new FormBody.Builder();
+            if (paramMap != null) {
+                paramMap.forEach(formBody::add);
+            }
+            requestBody = formBody.build();
+        }
+        request = new Request.Builder().post(requestBody).url(url);
+        return this;
+    }
+
+    /**
+     * 同步请求
+     *
+     * @return
+     */
+    public String sync() {
+        setHeader(request);
+        try {
+            Response response = okHttpClient.newCall(request.build()).execute();
+            assert response.body() != null;
+            return response.body().string();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return "请求失败:" + e.getMessage();
+        }
+    }
+
+    /**
+     * 异步请求,有返回值
+     */
+    public String async() {
+        StringBuilder buffer = new StringBuilder("");
+        setHeader(request);
+        okHttpClient.newCall(request.build()).enqueue(new Callback() {
+            @Override
+            public void onFailure(Call call, IOException e) {
+                buffer.append("请求出错:").append(e.getMessage());
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                assert response.body() != null;
+                buffer.append(response.body().string());
+                getSemaphoreInstance().release();
+            }
+        });
+        try {
+            getSemaphoreInstance().acquire();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * 异步请求,带有接口回调
+     *
+     * @param callBack
+     */
+    public void async(ICallBack callBack) {
+        setHeader(request);
+        okHttpClient.newCall(request.build()).enqueue(new Callback() {
+            @Override
+            public void onFailure(Call call, IOException e) {
+                callBack.onFailure(call, e.getMessage());
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                assert response.body() != null;
+                callBack.onSuccessful(call, response.body().string());
+            }
+        });
+    }
+
+    /**
+     * 为request添加请求头
+     *
+     * @param request
+     */
+    private void setHeader(Request.Builder request) {
+        if (headerMap != null) {
+            try {
+                for (Map.Entry<String, String> entry : headerMap.entrySet()) {
+                    request.addHeader(entry.getKey(), entry.getValue());
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    /**
+     * 生成安全套接字工厂,用于https请求的证书跳过
+     *
+     * @return
+     */
+    private static SSLSocketFactory createSSLSocketFactory(TrustManager[] trustAllCerts) {
+        SSLSocketFactory ssfFactory = null;
+        try {
+            SSLContext sc = SSLContext.getInstance("SSL");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            ssfFactory = sc.getSocketFactory();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ssfFactory;
+    }
+
+    private static TrustManager[] buildTrustManagers() {
+        return new TrustManager[]{
+                new X509TrustManager() {
+                    @Override
+                    public void checkClientTrusted(X509Certificate[] chain, String authType) {
+                    }
+
+                    @Override
+                    public void checkServerTrusted(X509Certificate[] chain, String authType) {
+                    }
+
+                    @Override
+                    public X509Certificate[] getAcceptedIssuers() {
+                        return new X509Certificate[]{};
+                    }
+                }
+        };
+    }
+
+    /**
+     * 自定义一个接口回调
+     */
+    public interface ICallBack {
+
+        void onSuccessful(Call call, String data);
+
+        void onFailure(Call call, String errorMsg);
+
+    }
+}

+ 45 - 0
src/main/java/com/zx/dataservice/utils/PropertiesUtil.java

@@ -0,0 +1,45 @@
+package com.zx.dataservice.utils;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+
+public class PropertiesUtil {
+    private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
+
+    private static Properties props;
+
+    static {
+        String fileName = "application-dev.properties";
+        props = new Properties();
+        try {
+            props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName), "UTF-8"));
+        } catch (IOException e) {
+            logger.error("配置文件读取异常", e);
+        }
+    }
+
+    public static String getProperty(String key) {
+        String value = props.getProperty(key.trim());
+        if (StringUtils.isBlank(value)) {
+            return null;
+        }
+        return value.trim();
+    }
+
+
+    public static String getProperty(String key, String defaultValue) {
+        String value = props.getProperty(key.trim());
+        if (StringUtils.isBlank(value)) {
+            value = defaultValue;
+        }
+        return value.trim();
+    }
+}
+

+ 19 - 0
src/main/java/com/zx/dataservice/utils/TimeUtil.java

@@ -0,0 +1,19 @@
+package com.zx.dataservice.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class TimeUtil {
+
+    public static Date strToDate(String dateStr) {
+        try {
+            SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+            Date date = sDateFormat.parse(dateStr);
+            return date;
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 28 - 0
src/main/java/com/zx/dataservice/vo/SystemBoard.java

@@ -0,0 +1,28 @@
+package com.zx.dataservice.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "菜单")
+public class SystemBoard {
+
+    @ApiModelProperty(value = "ID")
+    private Integer id;
+
+    @ApiModelProperty(value = "父ID")
+    private Integer pId;
+
+    @ApiModelProperty(value = "是否为父菜单")
+    private boolean isParent;
+
+    @ApiModelProperty(value = "是否展开")
+    private boolean isExpand;
+
+    @ApiModelProperty(value = "类型ID")
+    private String  typeCode;
+
+    @ApiModelProperty(value = "名字")
+    private String name;
+}

+ 72 - 0
src/main/resources/application-dev.properties

@@ -0,0 +1,72 @@
+#端口
+server.port=8080
+
+#数据库相关配置
+#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+
+#本地地址
+#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/stock2chen?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
+#spring.datasource.username=root
+#spring.datasource.password=root
+
+#测试服务器地址
+#spring.datasource.url=jdbc:mysql://39.101.149.52:3306/stock2chen?characterEncoding=utf-8
+#spring.datasource.username=stock2chen
+#spring.datasource.password=bJRTaEWLZnGaZLTw
+
+# 云正式服务器 外网访问
+spring.datasource.test1.jdbc-Url=jdbc:mysql://172.21.0.14:3306/stock_data?characterEncoding=utf-8&allowMultiQueries=true
+#spring.datasource.test1.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock_data?characterEncoding=utf-8&allowMultiQueries=true
+spring.datasource.test1.username=root
+spring.datasource.test1.password=TestBicon@123
+spring.datasource.test1.driver-class-name=com.mysql.cj.jdbc.Driver
+
+spring.druid.initialSize=50
+spring.druid.minIdle=50
+spring.druid.maxActive=2000
+spring.druid.maxWait=60000
+spring.druid.timeBetweenEvictionRunsMillis=10000
+spring.druid.minEvictableIdleTimeMillis=30000
+spring.druid.validationQuery=SELECT 1 FROM DUAL
+spring.druid.testWhileIdle=false
+spring.druid.testOnBorrow=false
+spring.druid.testOnReturn=false
+spring.druid.poolPreparedStatements=true
+spring.druid.maxPoolPreparedStatementPerConnectionSize=20
+spring.druid.removeAbandoned=true
+spring.druid.removeAbandonedTimeout=1800
+spring.druid.filters=stat
+
+## test2 database
+spring.datasource.test2.jdbc-Url=jdbc:mysql://172.21.0.14:3306/stock?characterEncoding=utf-8&allowMultiQueries=true
+spring.datasource.test2.username=root
+spring.datasource.test2.password=TestBicon@123
+
+#spring.datasource.test2.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock?characterEncoding=utf-8&allowMultiQueries=true
+#spring.datasource.test2.username=root
+#spring.datasource.test2.password=TestBicon@123
+spring.datasource.test2.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.test2.hikari.minimum-idle=10
+#spring.datasource.test2.hikari.idle-timeout=18000
+#spring.datasource.test2.hikari.maximum-pool-size=1500
+#spring.datasource.test2.hikari.connection-timeout=300000
+#spring.datasource.test2.hikari.connection-test-query=SELECT 1
+
+
+spring.datasource.test3.jdbc-Url=jdbc:mysql://172.21.0.14:3306/stock_data_zhaiquan?characterEncoding=utf-8&allowMultiQueries=true
+#spring.datasource.test3.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock_data_zhaiquan?characterEncoding=utf-8&allowMultiQueries=true
+spring.datasource.test3.username=root
+spring.datasource.test3.password=TestBicon@123
+spring.datasource.test3.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.test3.hikari.minimum-idle=10
+#spring.datasource.test3.hikari.idle-timeout=18000
+#spring.datasource.test3.hikari.maximum-pool-size=1500
+#spring.datasource.test3.hikari.connection-timeout=300000
+#spring.datasource.test3.hikari.connection-test-query=SELECT 1
+
+#mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
+#mybatis.config-location=classpath:mybatis/mybatis-config.xml
+#mybatis.type-aliases-package=com.ftw.stock.dao
+
+#是否激活 swagger true or false
+swagger.enable=true

+ 0 - 0
src/main/resources/application-test.properties


+ 12 - 0
src/main/resources/application.properties

@@ -0,0 +1,12 @@
+
+#使用配置文件
+spring.profiles.active=dev
+
+#端口
+#server.port=8080
+
+#编码格式
+server.tomcat.uri-encoding=utf-8
+
+#session生命周期
+server.servlet.session.timeout=30m

+ 54 - 0
src/main/resources/log4j.properties

@@ -0,0 +1,54 @@
+# Output pattern : date [thread] priority category - message
+# FATAL 0  ERROR 3  WARN 4  INFO 6  DEBUG 7   数字越大 级别越低  只能打印该级别以上的信息
+log4j.rootLogger=DEBUG, Console, RollingFile, ERROR, WARN
+#将debug的日志信息输出到console 和 rollingfile
+
+#Console Layout
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+#可以灵活地指定布局模式
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+#指定的打印信息的具体格式
+log4j.appender.Console.layout.ConversionPattern=%d %-5p [%c{5}] - %m%n
+
+#RollingFile d datetime m log n next p priority c class
+#Rollingfile的输出端的类型为每天产生一个日志文件
+log4j.appender.RollingFile=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.RollingFile.File=${user.home}\\Log4j\\Log4j\\Log.log
+log4j.appender.RollingFile.DatePattern='-'yyyy-MM-dd'.log'
+log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout
+log4j.appender.RollingFile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%C]-[%p] %m%n
+
+#ERROR -----输出到文件
+log4j.appender.ERROR = org.apache.log4j.RollingFileAppender  
+log4j.appender.ERROR.File =${user.home}\\Log4j\\Error\\error.log
+log4j.appender.ERROR.MaxFileSize=50000KB
+log4j.appender.ERROR.Append = true  
+log4j.appender.ERROR.Threshold = ERROR   
+log4j.appender.ERROR.layout = org.apache.log4j.PatternLayout  
+log4j.appender.ERROR.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
+
+log4j.appender.WARN = org.apache.log4j.RollingFileAppender  
+log4j.appender.WARN.File =${user.home}\\Log4j\\Warn\\warn.log 
+log4j.appender.WARN.MaxFileSize=50000KB
+log4j.appender.WARN.Append = true  
+log4j.appender.WARN.Threshold = WARN   
+log4j.appender.WARN.layout = org.apache.log4j.PatternLayout  
+log4j.appender.WARN.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n  
+
+
+#指定com。rail包下所有类为debug
+log4j.logger.com.rails=DEBUG
+log4j.logger.com.rails.common.security.shiro=WARN
+log4j.logger.com.rails.common.utils.JedisUtils=WARN
+log4j.logger.com.rails.modules.sys.controller.LoginController=WARN
+
+#ibatis level
+log4j.logger.org.apache.ibatis=DEBUG
+#shiro level
+#sql level
+log4j.logger.java.sql=DEBUG
+
+#Springframework level
+log4j.logger.org.springframework=WARN
+
+log4j.logger.org.mybatis.spring=WARN

File diff suppressed because it is too large
+ 126 - 0
src/main/resources/mybatis/mapper1/ChoiceStockMapper.xml


+ 31 - 0
src/main/resources/mybatis/mapper2/StockMapper.xml

@@ -0,0 +1,31 @@
+<?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.zx.dataservice.mapper2.StockMapper" >
+
+    <update id="updateStockInfo">
+        update
+            stock
+        set
+            `now_price` = #{info.now},
+            `change` = #{info.change},
+            `pct_change` = #{info.pctchange}
+        where
+            stock_code = #{stockCode}
+    </update>
+
+    <update id="updateBatchStockInfo" parameterType="java.util.List">
+        <foreach collection ="list" item="info" index="index" separator=";" >
+            <if test="info.now != 0">
+                update
+                    stock
+                set
+                    `now_price` = #{info.now},
+                    `change` = #{info.change},
+                    `pct_change` = #{info.pctchange}
+                where
+                    stock_code = #{info.code}
+            </if>
+        </foreach>
+    </update>
+
+</mapper>

File diff suppressed because it is too large
+ 126 - 0
src/main/resources/mybatis/mapper3/ChoiceBondMapper.xml


+ 26 - 0
src/main/resources/mybatis/mybatis-config.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <settings>
+        <setting name="callSettersOnNulls" value="true"/>
+        <setting name="cacheEnabled" value="true"/>
+        <setting name="lazyLoadingEnabled" value="true"/>
+        <setting name="aggressiveLazyLoading" value="true"/>
+        <setting name="multipleResultSetsEnabled" value="true"/>
+        <setting name="useColumnLabel" value="true"/>
+        <setting name="useGeneratedKeys" value="false"/>
+        <setting name="autoMappingBehavior" value="PARTIAL"/>
+        <setting name="defaultExecutorType" value="SIMPLE"/>
+        <setting name="mapUnderscoreToCamelCase" value="true"/>
+        <setting name="localCacheScope" value="SESSION"/>
+        <setting name="jdbcTypeForNull" value="NULL"/>
+    </settings>
+    <typeAliases>
+        <typeAlias alias="Integer" type="java.lang.Integer" />
+        <typeAlias alias="Long" type="java.lang.Long" />
+        <typeAlias alias="HashMap" type="java.util.HashMap" />
+        <typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap" />
+        <typeAlias alias="ArrayList" type="java.util.ArrayList" />
+        <typeAlias alias="LinkedList" type="java.util.LinkedList" />
+    </typeAliases>
+</configuration>

+ 141 - 0
src/main/resources/stock.properties

@@ -0,0 +1,141 @@
+
+#   服务器配置 61001/62000 访问
+#启动vsftpd
+#1.	service vsftpd restart
+#2.	执行ifconfig查看运行vsftpd服务的地址
+#3.	用浏览器 ftp://地址
+
+ftp.server.ip=39.101.149.52
+ftp.user=gssyLink
+ftp.pass=Ki7jBwA6HFf2NCYy
+ftp.server.http.prefix=http://img.jiatuixinxi.com/
+#ftp.server.ip=47.56.200.145
+#ftp.user=ofsuccess
+#ftp.pass=fdymdM34HHsS8iB6
+#ftp.server.http.prefix=http://www.img.yfkgzq.com/
+
+#cookie config start
+user.cookie.name=USER_TOKEN
+agent.cookie.name=AGENT_TOKEN
+admin.cookie.name=ADMIN_TOKEN
+
+agent.key.prefix=SR
+admin.super.name=18916320007
+
+#管理 邮箱 - 发件主题
+admin.auth.email.subject=鸿鹄易融 - 支付通知邮件
+#管理 邮箱 - 发件地址
+admin.auth.email=navihold800@163.com
+#管理 邮箱 - 发件密码  118318asd  XY118318asd
+admin.auth.email.pwd=XY118318asd
+#cookie config end
+
+# close order task config start
+close.order.task.time.hour=2
+#   锁的时间 50s ,实际生产环境改为 5s
+lock.timeout=50000
+# close order task config start
+
+#aliyun sms config
+sms.aliyun.accessKeyId=LTAI4FqEYw8va2Bgak2fd9pL
+sms.aliyun.accessKeySecret=WpOZQCHHwuJ9U9oo4yU73RiJY4CuLK
+
+#juhe api
+juhe.stock.key=e27571e4f5f2f07440bf4996d01d5770
+juhe.ip.key=1b87ed225d34571b1ab8666f8f1a018b
+#juhe api end
+
+#site setting
+site.email.auth.url=/api/admin/authCharge.do
+site.pc.reg.url=/homes/#/register?code=
+site.m.reg.url=/wap/#/register?code=
+
+#行情刷新时间
+#pc.refresh.time=3000
+
+# 行情 API 地址
+#sina.market.url=https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673
+sina.market.url=https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673,s_sz399106,s_sz399004,s_sz399100
+sina.single.market.url=https://hq.sinajs.cn/rn=1520407404627&list=s_
+sina.single.stock.url=https://hq.sinajs.cn/list=
+
+sina.single.stock.min.url=http://image.sinajs.cn/newchart/min/n/
+sina.single.stock.day.url=http://image.sinajs.cn/newchart/daily/n/
+sina.single.stock.week.url=http://image.sinajs.cn/newchart/weekly/n/
+sina.single.stock.month.url=http://image.sinajs.cn/newchart/monthly/n/
+
+#期货行情
+sina.single.futures.url=https://hq.sinajs.cn/list=
+
+#外汇行情
+sina.single.exchange.url=https://hq.sinajs.cn/list=
+
+
+# 行情K线
+sina.k.min.url=http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData
+sina.k.min.max.size=240
+
+
+# 聚合支付
+#跳转地址
+juhe1.pay.callbackurl=http://xx.com
+#异步通知地址
+juhe1.pay.notifyurl=http://xx.com
+
+
+#Fly 支付
+fly.pay.merchantid=SLPNXG
+fly.pay.token=0a17a92f45816a88431fa326b3b61baf
+
+#Cmc 支付
+#商户后台密匙
+cmc.pay.key=0a17a92f45816a88431fa326b3b61baf
+#商户后台appid
+cmc.pay.uid=74021809
+#同步返回地址
+cmc.pay.return_url=https://www.bldzb666888.com/homes/#/rechargelist
+#异步回调地址
+cmc.pay.notify_url=https://www.bldzb666888.com/api/pay/juhenewpayNotify.do
+#接口服务器地址
+cmc.pay.url=http://pay.phu889.com/api.php/webRequest/tradePay
+
+
+
+#通知地址
+fly.pay.serverbackurl=http://www.honghoo.top/api/pay/flyNotify.do
+#跳转地址
+fly.pay.callbackurl=http://www.honghoo.top/wap/#/user
+
+#提交地址  Post提交 form 中 enctype=application/x-www-form-urlencoded(HTTP 请求 Content-Type 默认格式)
+fly.pay.payurl=https://zf.flyotcpay.com/payment/
+
+#网建短信配置
+#用户名
+wj.sms.uid=lf123789
+#秘钥
+wj.sms.key=d41d8cd98f00b204e980
+#编码gbk/utf8
+wj.sms.coding=utf8
+
+#聚合短信配置
+#短信类型
+sms.type=jh
+#短信模板ID
+jh.sms.uid=216861
+#秘钥
+jh.sms.key=5c7162a8bd9fc0f4a451acda13991fa7
+
+#是否验证短信true、false
+is.validation.sms=false
+
+#上传文件地址
+#web.file.path=D:\\test\\static
+
+#富文本图片访问地址前缀 http://pz.jiatuixinxi.com
+ueditor.config.imageUrlPrefix=http://127.0.0.1:8080
+
+#资讯appkey
+jisuapi.appkey=eebe6cf3838a5395
+jisuapi.news.url=https://api.jisuapi.com/news/get
+jisuapi.news.channel=股票
+

+ 13 - 0
src/test/java/com/zx/dataservice/DataServiceApplicationTests.java

@@ -0,0 +1,13 @@
+package com.zx.dataservice;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class DataServiceApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}