z 4 роки тому
батько
коміт
ec3d880967
32 змінених файлів з 487 додано та 1378 видалено
  1. 8 8
      src/main/java/com/zx/dataservice/config/DataSourceConfig2.java
  2. 0 61
      src/main/java/com/zx/dataservice/config/DataSourceConfig3.java
  3. 1 1
      src/main/java/com/zx/dataservice/config/DruidConfig.java
  4. 1 1
      src/main/java/com/zx/dataservice/mapper3/ChoiceBondMapper.java
  5. 0 19
      src/main/java/com/zx/dataservice/mapper2/StockMapper.java
  6. 0 23
      src/main/java/com/zx/dataservice/mapper3/CreatorMapper.java
  7. 0 8
      src/main/java/com/zx/dataservice/service/ChoService.java
  8. 0 4
      src/main/java/com/zx/dataservice/service/ChoiceStockService.java
  9. 9 0
      src/main/java/com/zx/dataservice/service/ChoiceTempIndexService.java
  10. 0 8
      src/main/java/com/zx/dataservice/service/CreatorService.java
  11. 0 422
      src/main/java/com/zx/dataservice/service/impl/ChoServiceImpl.java
  12. 18 18
      src/main/java/com/zx/dataservice/service/impl/ChoiceBondServiceImpl.java
  13. 18 22
      src/main/java/com/zx/dataservice/service/impl/ChoiceStockServiceImpl.java
  14. 210 0
      src/main/java/com/zx/dataservice/service/impl/ChoiceTempIndexServiceImpl.java
  15. 0 343
      src/main/java/com/zx/dataservice/service/impl/CreatorServiceImpl.java
  16. 2 6
      src/main/java/com/zx/dataservice/task/AnalysisBondRestDataTask.java
  17. 0 2
      src/main/java/com/zx/dataservice/task/AnalysisStockRestDataTask.java
  18. 29 0
      src/main/java/com/zx/dataservice/task/AnalysisTempIndexRestDataTask.java
  19. 0 65
      src/main/java/com/zx/dataservice/task/MakeRestDataTask.java
  20. 13 0
      src/main/java/com/zx/dataservice/task/TaskConfig.java
  21. 0 65
      src/main/java/com/zx/dataservice/utils/BuyAndSellUtils.java
  22. 0 19
      src/main/java/com/zx/dataservice/utils/ChoiceUtil.java
  23. 2 1
      src/main/java/com/zx/dataservice/utils/FileBondUtil.java
  24. 2 1
      src/main/java/com/zx/dataservice/utils/FileStockUtil.java
  25. 153 0
      src/main/java/com/zx/dataservice/utils/FileTempIndexUtil.java
  26. 11 0
      src/main/java/com/zx/dataservice/vo/StockRestVO.java
  27. 6 51
      src/main/resources/application-dev.properties
  28. 2 9
      src/main/resources/application-real.properties
  29. 1 0
      src/main/resources/application.properties
  30. 1 1
      src/main/resources/mybatis/mapper3/ChoiceBondMapper.xml
  31. 0 75
      src/main/resources/mybatis/mapper2/StockMapper.xml
  32. 0 145
      src/main/resources/mybatis/mapper3/CreatorMapper.xml

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

@@ -15,10 +15,10 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 import javax.sql.DataSource;
 
 @Configuration
-@MapperScan(basePackages = {"com.zx.dataservice.mapper2"}, sqlSessionTemplateRef = "userSqlSessionTemplate")
+@MapperScan(basePackages = {"com.zx.dataservice.mapper2"}, sqlSessionTemplateRef = "source2SqlSessionTemplate")
 public class DataSourceConfig2 {
 
-    @Bean(name = "userDataSource")
+    @Bean(name = "source2DataSource")
 //    @ConfigurationProperties(prefix = "spring.datasource.test2")
     public DataSource testDataSource() {
         DruidDataSource dataSource = new DruidDataSource();
@@ -43,19 +43,19 @@ public class DataSourceConfig2 {
         return dataSource;
     }
 
-    @Bean(name = "userSqlSessionFactory")
-    public SqlSessionFactory userSqlSessionFactory(@Qualifier("userDataSource") DataSource dataSource) throws Exception {
+    @Bean(name = "source2SqlSessionFactory")
+    public SqlSessionFactory source2SqlSessionFactory(@Qualifier("source2DataSource") 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){
+    @Bean(name="source2TransactionManager")
+    public DataSourceTransactionManager testTransactionManager(@Qualifier("source2DataSource") DataSource dataSource){
         return  new DataSourceTransactionManager(dataSource);
     }
-    @Bean(name = "userSqlSessionTemplate")
-    public SqlSessionTemplate userSqlSessionTemplate(@Qualifier("userSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+    @Bean(name = "source2SqlSessionTemplate")
+    public SqlSessionTemplate source2SqlSessionTemplate(@Qualifier("source2SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
         return new SqlSessionTemplate(sqlSessionFactory);
     }
 }

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

@@ -1,61 +0,0 @@
-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);
-    }
-}

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

@@ -14,7 +14,7 @@ public class DruidConfig {
     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("allow", "127.0.0.1"); // 白名单
         // servletRegistrationBean.addInitParameter("deny", "192.168.1.200"); // 黑名单
         servletRegistrationBean.addInitParameter("loginUsername", "admin"); // 用户名
         servletRegistrationBean.addInitParameter("loginPassword", "admin"); // 密码

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

@@ -1,4 +1,4 @@
-package com.zx.dataservice.mapper3;
+package com.zx.dataservice.mapper2;
 
 
 import com.zx.dataservice.pojo.StockRestPojo;

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

@@ -1,19 +0,0 @@
-package com.zx.dataservice.mapper2;
-
-import com.zx.dataservice.pojo.StockPojo;
-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);
-
-    Integer selectStockByStockCode(@Param("stockCode") String stockCode);
-
-    void insertStock(@Param("info") StockPojo stockPojo);
-}

+ 0 - 23
src/main/java/com/zx/dataservice/mapper3/CreatorMapper.java

@@ -1,23 +0,0 @@
-package com.zx.dataservice.mapper3;
-
-import com.zx.dataservice.pojo.HistoryPojo;
-import com.zx.dataservice.pojo.StockHistPojo;
-import com.zx.dataservice.pojo.StockRestPojo;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
-@Mapper
-public interface CreatorMapper {
-
-    HistoryPojo selectHistory(@Param("tableName") String tableName);
-
-    void insertRt(@Param("info") StockRestPojo stockRestPojo, @Param("tableName") String tableName);
-
-    StockRestPojo selectRtLimitOne(@Param("tableName") String tableName);
-
-    void deleteHistoryTemp(@Param("tableName") String tableName);
-
-    StockRestPojo selectRtAll(@Param("tableName") String tableName);
-
-    void insertHistory(@Param("info") StockHistPojo stockHistPojo, @Param("tableName") String histTableName);
-}

+ 0 - 8
src/main/java/com/zx/dataservice/service/ChoService.java

@@ -1,8 +0,0 @@
-package com.zx.dataservice.service;
-
-public interface ChoService {
-
-    void insertRtStock();
-
-    void insertRtBood();
-}

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

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

+ 9 - 0
src/main/java/com/zx/dataservice/service/ChoiceTempIndexService.java

@@ -0,0 +1,9 @@
+package com.zx.dataservice.service;
+
+public interface ChoiceTempIndexService {
+    /**
+     * 解析东方财富数据
+     */
+    void analysisStockRestData();
+
+}

+ 0 - 8
src/main/java/com/zx/dataservice/service/CreatorService.java

@@ -1,8 +0,0 @@
-package com.zx.dataservice.service;
-
-public interface CreatorService {
-
-    void creatorUvxy();
-
-    void creatorUvxyHist();
-}

+ 0 - 422
src/main/java/com/zx/dataservice/service/impl/ChoServiceImpl.java

@@ -1,422 +0,0 @@
-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.mapper3.ChoiceBondMapper;
-import com.zx.dataservice.pojo.StockPojo;
-import com.zx.dataservice.pojo.StockRestPojo;
-import com.zx.dataservice.service.ChoService;
-import com.zx.dataservice.utils.HttpRequest;
-import com.zx.dataservice.utils.TimeUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-@Service
-public class ChoServiceImpl implements ChoService {
-
-    private static final String url = "http://huarongjgb.com/lucene/updateInfo.do";
-
-    @Autowired
-    private StockMapper stockMapper;
-
-    @Autowired
-    private ChoiceStockMapper choiceStockMapper;
-
-    @Autowired
-    private ChoiceBondMapper choiceBondMapper;
-
-    private BigDecimal random(){
-        Random rd = new Random();
-        BigDecimal returnNum = new BigDecimal((rd.nextDouble() * 100) / 100);
-        int i = ((int)(10 * Math.random())) % 2;
-        if(0 == i){
-            return BigDecimal.ZERO.subtract(returnNum).setScale(2, BigDecimal.ROUND_HALF_UP);
-        }
-        return returnNum.setScale(2, BigDecimal.ROUND_HALF_UP);
-    }
-
-    private int randomInt(){
-        Random r = new Random(1);
-        int max = 10, min1 = 5;
-        int ran1 = (int) (Math.random() * (max - min1) + min1);
-        return ran1;
-    }
-
-    public void insertRtStock() {
-        String code = "897689.SH";
-        String gid = "sh897689";
-        String now = "8.66";
-        String tableName = "data_rt_897689_sh";
-        Integer stockCount = stockMapper.selectStockByStockCode(code);
-        if(0 == stockCount || null == stockCount){
-            StockPojo stockPojo = new StockPojo();
-            stockPojo.setStockName("测试新股4");
-            stockPojo.setStockCode(code);
-            stockPojo.setStockSpell("csxg4");
-            stockPojo.setStockType("sh");
-            stockPojo.setStockGid(gid);
-            stockPojo.setStockPlate("普通");
-            stockPojo.setIsLock(0);
-            stockPojo.setIsShow(0);
-            stockPojo.setBuyLimit(1);
-            stockPojo.setStockOrBond(0);
-            stockMapper.insertStock(stockPojo);
-        }
-        Date d = new Date();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-        SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
-        String dateNowStr = sdf.format(d);
-        String dateNowStr1 = sdf1.format(d);
-        StockRestPojo entry = choiceStockMapper.selectRtLimitOne(tableName);
-        if(null == entry){
-            entry = new StockRestPojo();
-            entry.setCode(code);
-            entry.setNow(now);
-            entry.setHigh(now);
-            entry.setLow(now);
-            entry.setOpen(now);
-            entry.setPreclose(now);
-            entry.setRoundlot("0");
-            entry.setChange("0");
-            entry.setPctchange("0");
-            entry.setVolume("1000");
-            entry.setAmount("1000");
-            entry.setVolumeratio("0");
-            entry.setCommissionratio("0");
-            entry.setCommissiondiff("0");
-            entry.setTradestatus("0");
-            entry.setOutvolume("0");
-            entry.setInvolume("0");
-            entry.setHighlimit("0");
-            entry.setLowlimit("0");
-            entry.setSpeed("0");
-            entry.setAverageprice("0");
-            entry.setBuyprice1(now);
-            entry.setBuyprice2(now);
-            entry.setBuyprice3(now);
-            entry.setBuyprice4(now);
-            entry.setBuyprice5(now);
-            entry.setBuyvolume1("1000");
-            entry.setBuyvolume2("1000");
-            entry.setBuyvolume3("1000");
-            entry.setBuyvolume4("1000");
-            entry.setBuyvolume5("1000");
-            entry.setSellprice1(now);
-            entry.setSellprice2(now);
-            entry.setSellprice3(now);
-            entry.setSellprice4(now);
-            entry.setSellprice5(now);
-            entry.setSellvolume1("1000");
-            entry.setSellvolume2("1000");
-            entry.setSellvolume3("1000");
-            entry.setSellvolume4("1000");
-            entry.setSellvolume5("1000");
-            entry.setClosedtime("0");
-            entry.setClosedvolume("0");
-            entry.setClosedamount("0");
-        }
-        StockRestPojo stockRestPojo = new StockRestPojo();
-        stockRestPojo.setDate(dateNowStr);
-        stockRestPojo.setTime(dateNowStr1);
-        stockRestPojo.setNow(String.valueOf(new BigDecimal(entry.getNow()).add(random())));
-        stockRestPojo.setHigh(String.valueOf(new BigDecimal(entry.getHigh()).add(random())));
-        stockRestPojo.setLow(String.valueOf(new BigDecimal(entry.getLow()).add(random())));
-        stockRestPojo.setOpen(String.valueOf(new BigDecimal(entry.getOpen()).add(random())));
-        stockRestPojo.setPreclose(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
-        stockRestPojo.setRoundlot(String.valueOf(new BigDecimal(entry.getRoundlot()).add(random())));
-        stockRestPojo.setChange(String.valueOf(new BigDecimal(entry.getChange()).add(random())));
-        stockRestPojo.setPctchange(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
-        stockRestPojo.setVolume(String.valueOf(new BigDecimal(entry.getVolume()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setAmount(String.valueOf(new BigDecimal(entry.getAmount()).add(random())));
-        stockRestPojo.setVolumeratio(String.valueOf(new BigDecimal(entry.getVolumeratio()).add(random())));
-        stockRestPojo.setCommissionratio(String.valueOf(new BigDecimal(entry.getCommissionratio()).add(random())));
-        stockRestPojo.setCommissiondiff(String.valueOf(new BigDecimal(entry.getCommissiondiff()).add(random())));
-        stockRestPojo.setTradestatus(String.valueOf(new BigDecimal(entry.getTradestatus()).add(random())));
-        stockRestPojo.setOutvolume(String.valueOf(new BigDecimal(entry.getOutvolume()).add(random())));
-        stockRestPojo.setInvolume(String.valueOf(new BigDecimal(entry.getInvolume()).add(random())));
-        stockRestPojo.setHighlimit(String.valueOf(new BigDecimal(entry.getHighlimit()).add(random())));
-        stockRestPojo.setLowlimit(String.valueOf(new BigDecimal(entry.getLowlimit()).add(random())));
-        stockRestPojo.setSpeed(String.valueOf(new BigDecimal(entry.getSpeed()).add(random())));
-        stockRestPojo.setAverageprice(String.valueOf(new BigDecimal(entry.getAverageprice()).add(random())));
-        stockRestPojo.setBuyprice1(String.valueOf(new BigDecimal(entry.getBuyprice1()).add(random())));
-        stockRestPojo.setBuyprice2(String.valueOf(new BigDecimal(entry.getBuyprice2()).add(random())));
-        stockRestPojo.setBuyprice3(String.valueOf(new BigDecimal(entry.getBuyprice3()).add(random())));
-        stockRestPojo.setBuyprice4(String.valueOf(new BigDecimal(entry.getBuyprice4()).add(random())));
-        stockRestPojo.setBuyprice5(String.valueOf(new BigDecimal(entry.getBuyprice5()).add(random())));
-        stockRestPojo.setBuyvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellprice1(String.valueOf(new BigDecimal(entry.getSellprice1()).add(random())));
-        stockRestPojo.setSellprice2(String.valueOf(new BigDecimal(entry.getSellprice2()).add(random())));
-        stockRestPojo.setSellprice3(String.valueOf(new BigDecimal(entry.getSellprice3()).add(random())));
-        stockRestPojo.setSellprice4(String.valueOf(new BigDecimal(entry.getSellprice4()).add(random())));
-        stockRestPojo.setSellprice5(String.valueOf(new BigDecimal(entry.getSellprice5()).add(random())));
-        stockRestPojo.setSellvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setClosedtime(String.valueOf(new BigDecimal(entry.getClosedtime()).add(random())));
-        stockRestPojo.setClosedvolume(String.valueOf(new BigDecimal(entry.getClosedvolume()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setClosedamount(String.valueOf(new BigDecimal(entry.getClosedamount()).add(random())));
-        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());
-        }
-        stockRestPojo.setCode(code);
-        insertStock(stockRestPojo, tableName);
-        List<StockRestPojo> list = new ArrayList<>();
-        list.add(stockRestPojo);
-        stockMapper.updateBatchStockInfo(list);
-    }
-
-    private void insertStock(StockRestPojo stockRestPojo, String tableName) {
-        choiceStockMapper.insertRt(stockRestPojo, tableName);
-        List<StockRestPojo> list = new ArrayList<>();
-        list.add(stockRestPojo);
-        Thread thread=new Thread(new Runnable() {
-            @Override
-            public void run() {
-                HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
-            }
-        });
-//        thread.start();
-    }
-
-    public void insertRtBood() {
-        String code = "989589.SH";
-        String gid = "sh989589";
-        String now = "108.66";
-        String tableName = "data_rt_989589_sh";
-        Integer stockCount = stockMapper.selectStockByStockCode(code);
-        if(0 == stockCount || null == stockCount){
-            StockPojo stockPojo = new StockPojo();
-            stockPojo.setStockName("测试新债4");
-            stockPojo.setStockCode(code);
-            stockPojo.setStockSpell("csxz4");
-            stockPojo.setStockType("sh");
-            stockPojo.setStockGid(gid);
-            stockPojo.setStockPlate("普通");
-            stockPojo.setIsLock(0);
-            stockPojo.setIsShow(0);
-            stockPojo.setBuyLimit(1);
-            stockPojo.setStockOrBond(1);
-            stockMapper.insertStock(stockPojo);
-        }
-        Date d = new Date();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-        SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
-        String dateNowStr = sdf.format(d);
-        String dateNowStr1 = sdf1.format(d);
-        StockRestPojo entry = choiceBondMapper.selectRtLimitOne(tableName);
-        if(null == entry){
-            entry = new StockRestPojo();
-            entry.setCode(code);
-            entry.setNow(now);
-            entry.setHigh(now);
-            entry.setLow(now);
-            entry.setOpen(now);
-            entry.setPreclose(now);
-            entry.setRoundlot("0");
-            entry.setChange("0");
-            entry.setPctchange("0");
-            entry.setVolume("1000");
-            entry.setAmount("1000");
-            entry.setBuyprice1(now);
-            entry.setBuyprice2(now);
-            entry.setBuyprice3(now);
-            entry.setBuyprice4(now);
-            entry.setBuyprice5(now);
-            entry.setBuyvolume1("1000");
-            entry.setBuyvolume2("1000");
-            entry.setBuyvolume3("1000");
-            entry.setBuyvolume4("1000");
-            entry.setBuyvolume5("1000");
-            entry.setSellprice1(now);
-            entry.setSellprice2(now);
-            entry.setSellprice3(now);
-            entry.setSellprice4(now);
-            entry.setSellprice5(now);
-            entry.setSellvolume1("1000");
-            entry.setSellvolume2("1000");
-            entry.setSellvolume3("1000");
-            entry.setSellvolume4("1000");
-            entry.setSellvolume5("1000");
-        }
-        StockRestPojo stockRestPojo = new StockRestPojo();
-        stockRestPojo.setDate(dateNowStr);
-        stockRestPojo.setTime(dateNowStr1);
-        stockRestPojo.setNow(String.valueOf(new BigDecimal(entry.getNow()).add(random())));
-        stockRestPojo.setHigh(String.valueOf(new BigDecimal(entry.getHigh()).add(random())));
-        stockRestPojo.setLow(String.valueOf(new BigDecimal(entry.getLow()).add(random())));
-        stockRestPojo.setOpen(String.valueOf(new BigDecimal(entry.getOpen()).add(random())));
-        stockRestPojo.setPreclose(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
-        stockRestPojo.setRoundlot(String.valueOf(new BigDecimal(entry.getRoundlot()).add(random())));
-        stockRestPojo.setChange(String.valueOf(new BigDecimal(entry.getChange()).add(random())));
-        stockRestPojo.setPctchange(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
-        stockRestPojo.setVolume(String.valueOf(new BigDecimal(entry.getVolume()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setAmount(String.valueOf(new BigDecimal(entry.getAmount()).add(random())));
-        stockRestPojo.setVolumeratio("");
-        stockRestPojo.setCommissionratio("");
-        stockRestPojo.setCommissiondiff("");
-        stockRestPojo.setTradestatus("");
-        stockRestPojo.setOutvolume("");
-        stockRestPojo.setInvolume("");
-        stockRestPojo.setHighlimit("");
-        stockRestPojo.setLowlimit("");
-        stockRestPojo.setSpeed("");
-        stockRestPojo.setAverageprice("");
-        stockRestPojo.setBuyprice1(String.valueOf(new BigDecimal(entry.getBuyprice1()).add(random())));
-        stockRestPojo.setBuyprice2(String.valueOf(new BigDecimal(entry.getBuyprice2()).add(random())));
-        stockRestPojo.setBuyprice3(String.valueOf(new BigDecimal(entry.getBuyprice3()).add(random())));
-        stockRestPojo.setBuyprice4(String.valueOf(new BigDecimal(entry.getBuyprice4()).add(random())));
-        stockRestPojo.setBuyprice5(String.valueOf(new BigDecimal(entry.getBuyprice5()).add(random())));
-        stockRestPojo.setBuyvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setBuyvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellprice1(String.valueOf(new BigDecimal(entry.getSellprice1()).add(random())));
-        stockRestPojo.setSellprice2(String.valueOf(new BigDecimal(entry.getSellprice2()).add(random())));
-        stockRestPojo.setSellprice3(String.valueOf(new BigDecimal(entry.getSellprice3()).add(random())));
-        stockRestPojo.setSellprice4(String.valueOf(new BigDecimal(entry.getSellprice4()).add(random())));
-        stockRestPojo.setSellprice5(String.valueOf(new BigDecimal(entry.getSellprice5()).add(random())));
-        stockRestPojo.setSellvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setSellvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
-        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());
-        }
-        stockRestPojo.setCode(code);
-        insertListBood(stockRestPojo, tableName);
-        List<StockRestPojo> list = new ArrayList<>();
-        list.add(stockRestPojo);
-        stockMapper.updateBatchStockInfo(list);
-    }
-
-    private void insertListBood(StockRestPojo stockRestPojo, String tableName) {
-        choiceBondMapper.insertRt(stockRestPojo, tableName);
-        List<StockRestPojo> list = new ArrayList<>();
-        list.add(stockRestPojo);
-        Thread thread=new Thread(new Runnable() {
-            @Override
-            public void run() {
-                HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
-            }
-        });
-//        thread.start();
-    }
-}

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

@@ -1,16 +1,17 @@
 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.mapper2.ChoiceBondMapper;
 import com.zx.dataservice.pojo.StockRestPojo;
 import com.zx.dataservice.service.ChoiceBondService;
 import com.zx.dataservice.utils.FileBondUtil;
 import com.zx.dataservice.utils.HttpRequest;
 import com.zx.dataservice.utils.TimeUtil;
+import com.zx.dataservice.vo.StockRestVO;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -26,14 +27,11 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
 
     private static final String goalFileUrl = "/www/wwwroot/csqdata/bond/backup";
 
-    private static final String url = "http://huarongjgb.com/lucene/updateInfo.do";
+    private static final String url = "http://taifooksec.com/api/stock/updateBatchStockInfo.do";
 
     @Autowired
     private ChoiceBondMapper choiceBondMapper;
 
-    @Autowired
-    private StockMapper stockMapper;
-
     @Override
     public void analysisBondRestData() {
         // 1.获取文件夹文件 按照时间顺序拿到一个
@@ -42,8 +40,10 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
             return;
         }
         List<StockRestPojo> stockRestPojoList = new ArrayList<>();
+        List<StockRestVO> stockRestVOList = new ArrayList<>();
+        StockRestPojo stockRestPojo;
+        StockRestVO stockRestVO;
         for (File file : files) {
-//            log.info("债券==当前操作文件名==" + file.getName());
             // 2.移动文件去另外一个文件夹
             FileBondUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
             // 3.读取文件内容
@@ -55,7 +55,6 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
             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()) {
                 try {
                     stockRestPojo = new StockRestPojo();
@@ -166,6 +165,9 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
                     stockRestPojo.setCode(entry.getKey().toLowerCase());
                     stockRestPojo.setTableName(tableName.toString());
                     stockRestPojoList.add(stockRestPojo);
+                    stockRestVO = new StockRestVO();
+                    BeanUtils.copyProperties(stockRestPojo, stockRestVO);
+                    stockRestVOList.add(stockRestVO);
                 }catch (Exception e){
                     log.error("错误数据导致失败" + e);
                 }
@@ -173,39 +175,37 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
             map = null;
         }
         // 5.入库
-        insertList(stockRestPojoList);
+        insertList(stockRestPojoList, stockRestVOList);
         stockRestPojoList = null;
     }
 
-    private void insertList(List<StockRestPojo> list) {
-//        log.info("=====入库==债券==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+    private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList) {
         int insertLength = list.size();
         int i = 0;
         int insertSize = 500;
         while (insertLength > insertSize) {
             choiceBondMapper.insertBatch(list.subList(i, i + insertSize));
-            stockMapper.updateBatchStockInfo(list.subList(i, i + insertSize));
+            List<StockRestVO> subList = stockRestVOList.subList(i, i + insertSize);
             i = i + insertSize;
             insertLength = insertLength - insertSize;
             Thread thread=new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
+                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
                 }
             });
-//            thread.start();
+            thread.start();
         }
         if (insertLength > 0) {
             choiceBondMapper.insertBatch(list.subList(i, i + insertLength));
-            stockMapper.updateBatchStockInfo(list.subList(i, i + insertLength));
+            List<StockRestVO> subList = stockRestVOList.subList(i, i + insertLength);
             Thread thread=new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
+                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
                 }
             });
-//            thread.start();
+            thread.start();
         }
-//        log.info("=====入库==债券==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
     }
 }

+ 18 - 22
src/main/java/com/zx/dataservice/service/impl/ChoiceStockServiceImpl.java

@@ -2,15 +2,16 @@ 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.FileStockUtil;
 import com.zx.dataservice.utils.HttpRequest;
 import com.zx.dataservice.utils.TimeUtil;
+import com.zx.dataservice.vo.StockRestVO;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -26,19 +27,11 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
 
     private static final String goalFileUrl = "/www/wwwroot/csqdata/stock/backup";
 
-    private static final String url = "http://huarongjgb.com/lucene/updateInfo.do";
+    private static final String url = "http://taifooksec.com/api/stock/updateBatchStockInfo.do";
 
     @Autowired
     private ChoiceStockMapper choiceStockMapper;
 
-    @Autowired
-    private StockMapper stockMapper;
-
-    @Override
-    public void getPlateInfo() {
-
-    }
-
     @Override
     public void analysisStockRestData() {
         // 1.获取文件夹文件 按照时间顺序拿到一个
@@ -47,8 +40,10 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
             return;
         }
         List<StockRestPojo> stockRestPojoList = new ArrayList<>();
+        List<StockRestVO> stockRestVOList = new ArrayList<>();
+        StockRestPojo stockRestPojo;
+        StockRestVO stockRestVO;
         for (File file : files){
-//            log.info("股票==当前操作文件名==" + file.getName());
             // 2.移动文件去另外一个文件夹
             FileStockUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
             // 3.读取文件内容
@@ -60,7 +55,6 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
             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()) {
                 try {
                     stockRestPojo = new StockRestPojo();
@@ -170,6 +164,9 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
                     stockRestPojo.setCode(entry.getKey().toLowerCase());
                     stockRestPojo.setTableName(tableName.toString());
                     stockRestPojoList.add(stockRestPojo);
+                    stockRestVO = new StockRestVO();
+                    BeanUtils.copyProperties(stockRestPojo, stockRestVO);
+                    stockRestVOList.add(stockRestVO);
                 }catch (Exception e){
                     log.error("错误数据导致失败" + e);
                 }
@@ -177,39 +174,38 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
             map = null;
         }
         // 5.入库
-        insertList(stockRestPojoList);
+        insertList(stockRestPojoList, stockRestVOList);
         stockRestPojoList = null;
     }
 
-    private void insertList(List<StockRestPojo> list) {
-//        log.info("=====入库===股票==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
+    private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList) {
         int insertLength = list.size();
         int i = 0;
         int insertSize = 500;
         while (insertLength > insertSize) {
             choiceStockMapper.insertBatch(list.subList(i, i + insertSize));
-            stockMapper.updateBatchStockInfo(list.subList(i, i + insertSize));
+            List<StockRestVO> subList = stockRestVOList.subList(i, i + insertSize);
             i = i + insertSize;
             insertLength = insertLength - insertSize;
             Thread thread=new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
+                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
                 }
             });
-//            thread.start();
+            thread.start();
         }
         if (insertLength > 0) {
             choiceStockMapper.insertBatch(list.subList(i, i + insertLength));
-            stockMapper.updateBatchStockInfo(list.subList(i, i + insertLength));
+            List<StockRestVO> subList = stockRestVOList.subList(i, i + insertLength);
             Thread thread=new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
+                    String returnStr = HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
+                    log.info(returnStr);
                 }
             });
-//            thread.start();
+            thread.start();
         }
-//        log.info("=====入库==股票==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
     }
 }

+ 210 - 0
src/main/java/com/zx/dataservice/service/impl/ChoiceTempIndexServiceImpl.java

@@ -0,0 +1,210 @@
+package com.zx.dataservice.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.zx.dataservice.mapper1.ChoiceStockMapper;
+import com.zx.dataservice.pojo.StockRestPojo;
+import com.zx.dataservice.service.ChoiceTempIndexService;
+import com.zx.dataservice.utils.FileTempIndexUtil;
+import com.zx.dataservice.utils.HttpRequest;
+import com.zx.dataservice.utils.TimeUtil;
+import com.zx.dataservice.vo.StockRestVO;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.*;
+
+@Service
+public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
+
+    private static final Logger log = LoggerFactory.getLogger(ChoiceTempIndexServiceImpl.class);
+
+    private static final String sourceFileUrl = "/www/wwwroot/csqdata/tempindex";
+
+    private static final String goalFileUrl = "/www/wwwroot/csqdata/tempindex/backup";
+
+    private static final String url = "http://taifooksec.com/api/stock/updateBatchStockInfo.do";
+
+    @Autowired
+    private ChoiceStockMapper choiceStockMapper;
+
+    @Override
+    public void analysisStockRestData() {
+        // 1.获取文件夹文件 按照时间顺序拿到一个
+        List<File> files = FileTempIndexUtil.getFile(sourceFileUrl);
+        if(null == files || 0 == files.size()){
+            return;
+        }
+        List<StockRestPojo> stockRestPojoList = new ArrayList<>();
+        List<StockRestVO> stockRestVOList = new ArrayList<>();
+        StockRestPojo stockRestPojo;
+        StockRestVO stockRestVO;
+        for (File file : files){
+            // 2.移动文件去另外一个文件夹
+            FileTempIndexUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
+            // 3.读取文件内容
+            String str = FileTempIndexUtil.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;
+            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+                try {
+                    stockRestPojo = new StockRestPojo();
+                    stockRestPojo.setDate(String.valueOf(entry.getValue().get(0)));
+                    if(String.valueOf(entry.getValue().get(1)).equals("0")){
+                        continue;
+                    }
+                    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.setVolume(String.valueOf(entry.getValue().get(8)));
+                    stockRestPojo.setAmount(String.valueOf(entry.getValue().get(9)));
+                    stockRestPojo.setChange(String.valueOf(entry.getValue().get(10)));
+                    stockRestPojo.setPctchange(String.valueOf(entry.getValue().get(11)));
+                    stockRestPojo.setSpeed(String.valueOf(entry.getValue().get(12)));
+                    stockRestPojo.setVolumeratio("");
+                    stockRestPojo.setCommissionratio("");
+                    stockRestPojo.setCommissiondiff("");
+                    stockRestPojo.setTradestatus("");
+                    stockRestPojo.setOutvolume("");
+                    stockRestPojo.setInvolume("");
+                    stockRestPojo.setHighlimit("");
+                    stockRestPojo.setLowlimit("");
+                    stockRestPojo.setAverageprice("");
+                    stockRestPojo.setBuyprice1("");
+                    stockRestPojo.setBuyprice2("");
+                    stockRestPojo.setBuyprice3("");
+                    stockRestPojo.setBuyprice4("");
+                    stockRestPojo.setBuyprice5("");
+                    stockRestPojo.setBuyvolume1("");
+                    stockRestPojo.setBuyvolume2("");
+                    stockRestPojo.setBuyvolume3("");
+                    stockRestPojo.setBuyvolume4("");
+                    stockRestPojo.setBuyvolume5("");
+                    stockRestPojo.setSellprice1("");
+                    stockRestPojo.setSellprice2("");
+                    stockRestPojo.setSellprice3("");
+                    stockRestPojo.setSellprice4("");
+                    stockRestPojo.setSellprice5("");
+                    stockRestPojo.setSellvolume1("");
+                    stockRestPojo.setSellvolume2("");
+                    stockRestPojo.setSellvolume3("");
+                    stockRestPojo.setSellvolume4("");
+                    stockRestPojo.setSellvolume5("");
+                    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);
+                    stockRestVO = new StockRestVO();
+                    BeanUtils.copyProperties(stockRestPojo, stockRestVO);
+                    stockRestVOList.add(stockRestVO);
+                }catch (Exception e){
+                    log.error("错误数据导致失败" + e);
+                }
+            }
+            map = null;
+        }
+        // 5.入库
+        insertList(stockRestPojoList, stockRestVOList);
+        stockRestPojoList = null;
+    }
+
+    private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList) {
+        int insertLength = list.size();
+        int i = 0;
+        int insertSize = 500;
+        while (insertLength > insertSize) {
+            choiceStockMapper.insertBatch(list.subList(i, i + insertSize));
+            List<StockRestVO> subList = stockRestVOList.subList(i, i + insertSize);
+            i = i + insertSize;
+            insertLength = insertLength - insertSize;
+            Thread thread=new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
+                }
+            });
+            thread.start();
+        }
+        if (insertLength > 0) {
+            choiceStockMapper.insertBatch(list.subList(i, i + insertLength));
+            List<StockRestVO> subList = stockRestVOList.subList(i, i + insertLength);
+            Thread thread=new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
+                }
+            });
+            thread.start();
+        }
+    }
+}

+ 0 - 343
src/main/java/com/zx/dataservice/service/impl/CreatorServiceImpl.java

@@ -1,343 +0,0 @@
-package com.zx.dataservice.service.impl;
-
-import com.zx.dataservice.mapper2.StockMapper;
-import com.zx.dataservice.mapper3.CreatorMapper;
-import com.zx.dataservice.pojo.HistoryPojo;
-import com.zx.dataservice.pojo.StockHistPojo;
-import com.zx.dataservice.pojo.StockPojo;
-import com.zx.dataservice.pojo.StockRestPojo;
-import com.zx.dataservice.service.CreatorService;
-import com.zx.dataservice.utils.TimeUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-@Service
-public class CreatorServiceImpl implements CreatorService {
-
-    @Autowired
-    private CreatorMapper creatorMapper;
-
-    @Autowired
-    private StockMapper stockMapper;
-
-    private static String initNow = null;
-    @Override
-    public void creatorUvxy() {
-        // 1.先去临时表查找第一条数据
-        String tableName = "data_hist_869735_sh_temp";
-        String code = "869735.SH";
-        String gid = "sh869735";
-        Integer stockCount = stockMapper.selectStockByStockCode(code);
-        if(0 == stockCount || null == stockCount){
-            StockPojo stockPojo = new StockPojo();
-            stockPojo.setStockName("华融发债");
-            stockPojo.setStockCode(code);
-            stockPojo.setStockSpell("hrfz");
-            stockPojo.setStockType("sh");
-            stockPojo.setStockGid(gid);
-            stockPojo.setStockPlate("普通");
-            stockPojo.setIsLock(0);
-            stockPojo.setIsShow(0);
-            stockPojo.setBuyLimit(1);
-            stockPojo.setStockOrBond(1);
-            stockMapper.insertStock(stockPojo);
-        }
-        HistoryPojo historyPojo = creatorMapper.selectHistory(tableName);
-        // 2.第一次的数据不用实际数据 设置初始值为100
-        toCreatorUvxy(historyPojo);
-    }
-
-    @Override
-    public void creatorUvxyHist() {
-        // 1.首先删除掉temp表中的第一条
-        String histTempTableName = "data_hist_869735_sh_temp";
-        HistoryPojo historyPojo = creatorMapper.selectHistory(histTempTableName);
-        creatorMapper.deleteHistoryTemp(histTempTableName);
-        // 2.用实时表中的数据构造一条历史记录
-        String restTableName = "data_rt_869735_sh";
-        StockRestPojo stockRestPojo = creatorMapper.selectRtAll(restTableName);
-        StockHistPojo stockHistPojo = new StockHistPojo();
-        stockHistPojo.setOpen(stockRestPojo.getOpen());
-        stockHistPojo.setClose(stockRestPojo.getOpen());
-        stockHistPojo.setHigh(stockRestPojo.getHigh());
-        stockHistPojo.setLow(stockRestPojo.getLow());
-        stockHistPojo.setAverage("0");
-        stockHistPojo.setVolume(stockRestPojo.getVolume());
-        stockHistPojo.setHighlimit("0");
-        stockHistPojo.setAmount("0");
-        stockHistPojo.setTnum("0");
-        stockHistPojo.setTradestatus("0");
-        stockHistPojo.setLowlimit("0");
-        stockHistPojo.setAmplitude("0");
-        stockHistPojo.setTnum("0");
-        stockHistPojo.setTafactor("0");
-        stockHistPojo.setFronttafactor("0");
-        stockHistPojo.setIsststock("0");
-        stockHistPojo.setIsxststock("0");
-        stockHistPojo.setPreclose(stockRestPojo.getClose());
-        stockHistPojo.setChange(String.valueOf(new BigDecimal(stockRestPojo.getClose()).subtract(new BigDecimal(stockRestPojo.getPreclose())).setScale(2, BigDecimal.ROUND_HALF_UP)));
-        stockHistPojo.setPctchange(String.valueOf(historyPojo.getPctChange()));
-
-        try {
-            SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
-            Date date = new Date(stockRestPojo.getDate());
-            String dateStr = formatter.format(date);
-            date = formatter.parse(dateStr);
-            String yearDatTime = String.valueOf(date.getTime());
-
-            formatter = new SimpleDateFormat("yyyyMM");
-            date = new Date(stockRestPojo.getDate());
-            dateStr = formatter.format(date);
-            date = formatter.parse(dateStr);
-            String monthDatTime = String.valueOf(date.getTime());
-
-            Calendar cld = Calendar.getInstance();
-            cld.setTime(new Date(stockRestPojo.getDate()));
-            int firstDay = cld.get(Calendar.DAY_OF_WEEK);
-            cld.add(Calendar.DATE, -firstDay);
-            String weekDatTime = String.valueOf(cld.getTime().getTime());
-
-            formatter = new SimpleDateFormat("yyyyMMdd");
-            date = new Date(stockRestPojo.getDate());
-            dateStr = formatter.format(date);
-            date = formatter.parse(dateStr);
-            String dayDatTime = String.valueOf(date.getTime());
-
-            stockHistPojo.setDateYear(yearDatTime);
-            stockHistPojo.setDateMonth(monthDatTime);
-            stockHistPojo.setDateWeek(weekDatTime);
-            stockHistPojo.setDateDay(dayDatTime);
-            stockHistPojo.setRealTime(dayDatTime);
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
-        String histTableName = "data_hist_869735_sh";
-        creatorMapper.insertHistory(stockHistPojo, histTableName);
-    }
-
-    private void toCreatorUvxy(HistoryPojo historyPojo){
-        String code = "869735.SH";
-        String tableName = "data_rt_869735_sh";
-        Date d = new Date();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-        SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
-        String dateNowStr = sdf.format(d);
-        String dateNowStr1 = sdf1.format(d);
-        StockRestPojo entry;
-
-        String now ;
-        StockRestPojo stockRestPojo = new StockRestPojo();
-        stockRestPojo.setDate(dateNowStr);
-        stockRestPojo.setTime(dateNowStr1);
-        entry = creatorMapper.selectRtLimitOne(tableName);
-        if(null == entry){
-            initNow = "100";
-            now = "100";
-            entry = new StockRestPojo();
-            entry.setCode(code);
-            entry.setNow(now);
-            entry.setHigh(now);
-            entry.setLow(now);
-            entry.setOpen(now);
-            entry.setPreclose(now);
-            entry.setRoundlot("0");
-            entry.setChange("0");
-            entry.setPctchange("0");
-            entry.setVolume("0");
-            entry.setAmount("0");
-            entry.setBuyprice1(now);
-            entry.setBuyprice2(now);
-            entry.setBuyprice3(now);
-            entry.setBuyprice4(now);
-            entry.setBuyprice5(now);
-            entry.setBuyvolume1("0");
-            entry.setBuyvolume2("0");
-            entry.setBuyvolume3("0");
-            entry.setBuyvolume4("0");
-            entry.setBuyvolume5("0");
-            entry.setSellprice1(now);
-            entry.setSellprice2(now);
-            entry.setSellprice3(now);
-            entry.setSellprice4(now);
-            entry.setSellprice5(now);
-            entry.setSellvolume1("0");
-            entry.setSellvolume2("0");
-            entry.setSellvolume3("0");
-            entry.setSellvolume4("0");
-            entry.setSellvolume5("0");
-            stockRestPojo.setNow(now);
-        }else{
-            now = entry.getNow();
-            if(null == initNow){
-                initNow = entry.getPreclose();
-            }
-            // 如果当前时间等于15点整, 则入库价格就是今天的昨收
-            String timeStr = "14:59";
-            Date time = new Date();
-            SimpleDateFormat f = new SimpleDateFormat("HH:mm");
-            if(f.format(time).equals(timeStr)){
-                stockRestPojo.setNow(String.valueOf(Double.valueOf(initNow) + historyPojo.getPctChange()));
-            }else{
-                stockRestPojo.setNow(String.valueOf(random(historyPojo, initNow, now)));
-            }
-            //设置最高
-            if(Double.valueOf(stockRestPojo.getNow())  > Double.valueOf(entry.getHigh())){
-                stockRestPojo.setHigh(stockRestPojo.getNow());
-            }else{
-                stockRestPojo.setHigh(entry.getHigh());
-            }
-
-            //设置最低
-            if(Double.valueOf(stockRestPojo.getNow())  < Double.valueOf(entry.getLow())){
-                stockRestPojo.setLow(stockRestPojo.getNow());
-            }else{
-                stockRestPojo.setLow(entry.getLow());
-            }
-            stockRestPojo.setOpen(entry.getOpen());
-            /*System.out.println("最高:"+stockRestPojo.getHigh());
-            System.out.println("最低:"+stockRestPojo.getLow());*/
-        }
-        stockRestPojo.setHigh(stockRestPojo.getHigh());
-        stockRestPojo.setLow(stockRestPojo.getLow());
-        stockRestPojo.setOpen(stockRestPojo.getOpen());
-        stockRestPojo.setPreclose(initNow);
-        stockRestPojo.setRoundlot(String.valueOf(new BigDecimal(entry.getRoundlot()).add(random(historyPojo, initNow, now))));
-        stockRestPojo.setChange(String.valueOf(new BigDecimal(stockRestPojo.getNow()).subtract(new BigDecimal(initNow))));
-        stockRestPojo.setPctchange(String.valueOf((new BigDecimal(stockRestPojo.getNow()).subtract(new BigDecimal(initNow))).divide(new BigDecimal(initNow),2 ,4)));
-        stockRestPojo.setVolume(String.valueOf(new BigDecimal(entry.getVolume()).add(new BigDecimal(randomInt()))));
-        stockRestPojo.setAmount(String.valueOf(new BigDecimal(entry.getNow()).multiply(new BigDecimal(stockRestPojo.getVolume()))));
-        stockRestPojo.setVolumeratio("");
-        stockRestPojo.setCommissionratio("");
-        stockRestPojo.setCommissiondiff("");
-        stockRestPojo.setTradestatus("");
-        stockRestPojo.setOutvolume("");
-        stockRestPojo.setInvolume("");
-        stockRestPojo.setHighlimit("");
-        stockRestPojo.setLowlimit("");
-        stockRestPojo.setSpeed("");
-        stockRestPojo.setAverageprice("");
-        stockRestPojo.setBuyprice1(randomBuySell(stockRestPojo.getNow(),0));
-        stockRestPojo.setBuyprice2(randomBuySell(stockRestPojo.getBuyprice1(),0));
-        stockRestPojo.setBuyprice3(randomBuySell(stockRestPojo.getBuyprice2(),0));
-        stockRestPojo.setBuyprice4(randomBuySell(stockRestPojo.getBuyprice3(),0));
-        stockRestPojo.setBuyprice5(randomBuySell(stockRestPojo.getBuyprice4(),0));
-        stockRestPojo.setBuyvolume1(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setBuyvolume2(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setBuyvolume3(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setBuyvolume4(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setBuyvolume5(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setSellprice1(randomBuySell(stockRestPojo.getNow(),1));
-        stockRestPojo.setSellprice2(randomBuySell(stockRestPojo.getSellprice1(),0));
-        stockRestPojo.setSellprice3(randomBuySell(stockRestPojo.getSellprice2(),0));
-        stockRestPojo.setSellprice4(randomBuySell(stockRestPojo.getSellprice3(),0));
-        stockRestPojo.setSellprice5(randomBuySell(stockRestPojo.getSellprice4(),0));
-        stockRestPojo.setSellvolume1(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setSellvolume2(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setSellvolume3(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setSellvolume4(String.valueOf(new BigDecimal(randomInt())));
-        stockRestPojo.setSellvolume5(String.valueOf(new BigDecimal(randomInt())));
-        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());
-        }
-        stockRestPojo.setCode(code);
-        creatorMapper.insertRt(stockRestPojo, tableName);
-    }
-
-    private BigDecimal random(HistoryPojo historyPojo, String initNow, String now){
-        // 昨收 + 涨跌幅
-        double max;
-        double min;
-        if(historyPojo.getPctChange() > 0) {
-            max = Double.valueOf(initNow) + historyPojo.getPctChange();
-            min = Double.valueOf(initNow) - 2;
-        }else{
-            max = Double.valueOf(initNow) + 2;
-            min = Double.valueOf(initNow) - Math.abs(historyPojo.getPctChange());
-        }
-        double randomMin = Double.valueOf(now) - 2;
-        double randomMax = Double.valueOf(now) + 2;
-        if(randomMin < min){
-            randomMin = min;
-        }
-        if(randomMax > max){
-            randomMax = max;
-        }
-        return new BigDecimal(Math.random() * (randomMax - randomMin) + randomMin).setScale(2, BigDecimal.ROUND_HALF_UP);
-    }
-
-    private String randomBuySell(String now, int type){
-        // 买
-        if(0 == type){
-            return new BigDecimal(now).subtract(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
-        }else{
-            return new BigDecimal(now).add(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
-        }
-    }
-
-    private int randomInt(){
-        int max = 10000;
-        int min = 5000;
-        int ran = (int) (Math.random() * (max - min) + min);
-        return ran;
-    }
-}

+ 2 - 6
src/main/java/com/zx/dataservice/task/AnalysisBondRestDataTask.java

@@ -4,8 +4,6 @@ import com.zx.dataservice.service.ChoiceBondService;
 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;
 
 /**
@@ -19,12 +17,10 @@ public class AnalysisBondRestDataTask {
     @Autowired
     private ChoiceBondService choiceBondService;
 
-    @Async("executorBond")
-    @Scheduled(fixedRate=10)
+//    @Async("executorBond")
+//    @Scheduled(fixedRate=10)
     public void toAnalysisRestData() {
-//        log.info("=====定时任务===解析东方财富数据==债券==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
         doTask();
-//        log.info("=====定时任务===解析东方财富数据==债券==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
     }
 
     public void doTask() {

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

@@ -22,9 +22,7 @@ public class AnalysisStockRestDataTask {
     @Async("executorStock")
     @Scheduled(fixedRate=10)
     public void toAnalysisRestData() {
-//        log.info("=====定时任务===解析东方财富数据==股票==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
         doTask();
-//        log.info("=====定时任务===解析东方财富数据==股票==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
     }
 
     public void doTask() {

+ 29 - 0
src/main/java/com/zx/dataservice/task/AnalysisTempIndexRestDataTask.java

@@ -0,0 +1,29 @@
+package com.zx.dataservice.task;
+
+import com.zx.dataservice.service.ChoiceTempIndexService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 解析东方财富实时数据
+ */
+@Component
+public class AnalysisTempIndexRestDataTask {
+
+    private static final Logger log = LoggerFactory.getLogger(AnalysisTempIndexRestDataTask.class);
+
+    @Autowired
+    private ChoiceTempIndexService choiceTempIndexService;
+
+//    @Async("executorTempIndex")
+//    @Scheduled(fixedRate=100)
+    public void toAnalysisRestData() {
+        doTask();
+    }
+
+    public void doTask() {
+        this.choiceTempIndexService.analysisStockRestData();
+    }
+}

+ 0 - 65
src/main/java/com/zx/dataservice/task/MakeRestDataTask.java

@@ -1,65 +0,0 @@
-package com.zx.dataservice.task;
-
-import com.zx.dataservice.service.ChoService;
-import com.zx.dataservice.service.CreatorService;
-import com.zx.dataservice.utils.BuyAndSellUtils;
-import com.zx.dataservice.utils.DateTimeUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-
-/**
- * 制造新股\新债实时数据
- */
-@Component
-public class MakeRestDataTask {
-
-    private static final Logger log = LoggerFactory.getLogger(MakeRestDataTask.class);
-
-    @Autowired
-    private ChoService choService;
-
-    @Autowired
-    private CreatorService creatorService;
-
-//    @Scheduled(cron = "0/3 * * * * ?")
-    public void toMakeStockRestData() {
-        log.info("=====定时任务===制造新股==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-        choService.insertRtStock();
-        log.info("=====定时任务===制造新股==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-    }
-
-//    @Scheduled(cron = "0/3 * * * * ?")
-    public void toMakeBondRestData() {
-        log.info("=====定时任务===制造新债==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-        choService.insertRtBood();
-        log.info("=====定时任务===制造新债==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-    }
-
-//    @Scheduled(cron = "0/3 * * * * ?")
-    public void creatorUvxy() {
-        try {
-            if(BuyAndSellUtils.isTransTime("09:30", "12:00") || BuyAndSellUtils.isTransTime("13:00", "15:00")){
-                log.info("=====定时任务===制造恐慌指数==实时==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-                creatorService.creatorUvxy();
-                log.info("=====定时任务===制造恐慌指数==实时==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-//    @Scheduled(cron = "0 0 1 * * ?")
-    public void creatorUvxyHist() {
-        try {
-            log.info("=====定时任务===制造恐慌指数==历史==开始,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-            creatorService.creatorUvxyHist();
-            log.info("=====定时任务===制造恐慌指数==历史==结束,当前时间 {} =====", DateTimeUtil.dateToStr(new Date()));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}

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

@@ -37,4 +37,17 @@ public class TaskConfig {
         executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
         return executor;
     }
+
+    @Bean("executorTempIndex")
+    public Executor taskSchedulerTempIndex() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        //核心线程数
+        executor.setCorePoolSize(10);
+        //最大核心线程数
+        executor.setMaxPoolSize(20);
+        //队列中等待被调度的任务数
+        executor.setQueueCapacity(10);
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        return executor;
+    }
 }

+ 0 - 65
src/main/java/com/zx/dataservice/utils/BuyAndSellUtils.java

@@ -1,65 +0,0 @@
-package com.zx.dataservice.utils;
-
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-
-public class BuyAndSellUtils {
-
-    private static final Logger log = LoggerFactory.getLogger(BuyAndSellUtils.class);
-
-
-    public static boolean isTransTime(String begin_time, String end_time) throws Exception {
-        if (StringUtils.isBlank(begin_time) || StringUtils.isBlank(end_time)) {
-            return false;
-        }
-        Date nowDate = new Date();
-        if (!isWorkDay(nowDate)) {
-            return false;
-        }
-        SimpleDateFormat df = new SimpleDateFormat("HH:mm");
-        Date now = null;
-        Date beginTime = null;
-        Date endTime = null;
-        try {
-            now = df.parse(df.format(nowDate));
-            beginTime = df.parse(begin_time);
-            endTime = df.parse(end_time);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        Boolean flag = Boolean.valueOf(belongCalendar(now, beginTime, endTime));
-        return flag.booleanValue();
-    }
-
-
-    public static boolean belongCalendar(Date nowTime, Date beginTime, Date endTime) {
-        Calendar date = Calendar.getInstance();
-        date.setTime(nowTime);
-        Calendar begin = Calendar.getInstance();
-        begin.setTime(beginTime);
-        Calendar end = Calendar.getInstance();
-        end.setTime(endTime);
-        if (date.after(begin) && date.before(end)) {
-            return true;
-        }
-        return false;
-    }
-
-
-    public static boolean isWorkDay(Date currentDate) throws Exception {
-        Calendar cal = Calendar.getInstance();
-        cal.setTime(currentDate);
-        if (cal.get(7) == 7 || cal.get(7) == 1) {
-            return false;
-        }
-        return true;
-    }
-
-}

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

@@ -1,19 +0,0 @@
-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;
-    }
-}

+ 2 - 1
src/main/java/com/zx/dataservice/utils/FileBondUtil.java

@@ -128,6 +128,7 @@ public class FileBondUtil {
                 sbf.append(tempStr);
             }
             reader.close();
+//            deleteFile(fileName);
             return sbf.toString();
         } catch (IOException e) {
             e.printStackTrace();
@@ -140,7 +141,7 @@ public class FileBondUtil {
                 }
             }
         }
-        deleteFile(fileName);
+//        deleteFile(fileName);
         return sbf.toString();
     }
 

+ 2 - 1
src/main/java/com/zx/dataservice/utils/FileStockUtil.java

@@ -128,6 +128,7 @@ public class FileStockUtil {
                 sbf.append(tempStr);
             }
             reader.close();
+//            deleteFile(fileName);
             return sbf.toString();
         } catch (IOException e) {
             e.printStackTrace();
@@ -140,7 +141,7 @@ public class FileStockUtil {
                 }
             }
         }
-        deleteFile(fileName);
+//        deleteFile(fileName);
         return sbf.toString();
     }
 

+ 153 - 0
src/main/java/com/zx/dataservice/utils/FileTempIndexUtil.java

@@ -0,0 +1,153 @@
+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 FileTempIndexUtil {
+
+    private static Set<String> fileNameSet = new HashSet<>();
+
+    private static final Logger log = LoggerFactory.getLogger(FileTempIndexUtil.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;
+                    }
+                }
+            }
+        }
+        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();
+//            deleteFile(fileName);
+            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;
+    }
+}

+ 11 - 0
src/main/java/com/zx/dataservice/vo/StockRestVO.java

@@ -0,0 +1,11 @@
+package com.zx.dataservice.vo;
+
+import lombok.Data;
+
+@Data
+public class StockRestVO {
+    private String code;
+    private String now;
+    private String change;
+    private String pctchange;
+}

+ 6 - 51
src/main/resources/application-dev.properties

@@ -1,29 +1,6 @@
 #端口
 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://127.0.0.1/stock_data?characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=UTC
-#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.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/stock_data?characterEncoding=utf-8&allowMultiQueries=true
-spring.datasource.test1.username=root
-#spring.datasource.test1.password=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
@@ -40,38 +17,16 @@ 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.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.datasource.test2.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock?characterEncoding=utf-8&allowMultiQueries=true
-spring.datasource.test2.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/stock?characterEncoding=utf-8&allowMultiQueries=true
+spring.datasource.test2.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock_data_zhaiquan?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.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/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

+ 2 - 9
src/main/resources/application-real.properties

@@ -17,24 +17,17 @@ spring.druid.removeAbandoned=true
 spring.druid.removeAbandonedTimeout=1800
 spring.druid.filters=stat
 
-
 # 数据源1 股票数据库
 spring.datasource.test1.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/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
 
-# 数据源2 业务数据库
-spring.datasource.test2.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/stock?characterEncoding=utf-8&allowMultiQueries=true
+# 数据源2 债券数据库
+spring.datasource.test2.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/stock_data_zhaiquan?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
 
-# 数据源3 债券数据库
-spring.datasource.test3.jdbc-Url=jdbc:mysql://bj-cdb-1j873yci.sql.tencentcdb.com:61196/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
-
 #是否激活 swagger true or false
 swagger.enable=false

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

@@ -1,6 +1,7 @@
 
 #ʹÓÃÅäÖÃÎļþ
 spring.profiles.active=real
+#spring.profiles.active=dev
 
 #¶Ë¿Ú
 #server.port=8080

+ 1 - 1
src/main/resources/mybatis/mapper3/ChoiceBondMapper.xml

@@ -1,6 +1,6 @@
 <?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.mapper3.ChoiceBondMapper" >
+<mapper namespace="com.zx.dataservice.mapper2.ChoiceBondMapper" >
 
     <insert id="insertIntoRestData">
         insert into ${tableName}

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

@@ -1,75 +0,0 @@
-<?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>
-
-    <select id="selectStockByStockCode" resultType="Integer">
-        select
-            count(1)
-        from
-            stock
-        where
-            stock_code = #{stockCode}
-    </select>
-
-    <insert id="insertStock">
-        insert into
-            stock
-        (
-            stock_name,
-            stock_code,
-            stock_spell,
-            stock_type,
-            stock_gid,
-            stock_plate,
-            is_lock,
-            is_show,
-            buy_limit,
-            is_limit_up_buy,
-            is_stop_trading_buy,
-            stock_or_bond,
-            add_time
-        )
-        values
-        (
-            #{info.stockName},
-            #{info.stockCode},
-            #{info.stockSpell},
-            #{info.stockType},
-            #{info.stockGid},
-            #{info.stockPlate},
-            #{info.isLock},
-            #{info.isShow},
-            #{info.buyLimit},
-            #{info.isLimitUpBuy},
-            #{info.isStopTradingBuy},
-            #{info.stockOrBond},
-            now()
-        )
-    </insert>
-</mapper>

Різницю між файлами не показано, бо вона завелика
+ 0 - 145
src/main/resources/mybatis/mapper3/CreatorMapper.xml