diff options
| author | wangwei <[email protected]> | 2019-01-10 19:40:49 +0800 |
|---|---|---|
| committer | wangwei <[email protected]> | 2019-01-10 19:40:49 +0800 |
| commit | d8f25bcd7fad0d737bf07a07b1cf907797c95f19 (patch) | |
| tree | 32ed001084d8ee309f3d67d173ed4df61b192714 | |
| parent | 64eb016fa0fa12314a61eceec3294cc6f1a7ea1d (diff) | |
| parent | 16ca3e70694daf2fa1a3a76f72e9ba01c23ab57e (diff) | |
添加关注网站统计接口最近时间sql
5 files changed, 69 insertions, 2 deletions
diff --git a/config/application.properties b/config/application.properties index 23a3d5e..759021a 100644 --- a/config/application.properties +++ b/config/application.properties @@ -7,7 +7,7 @@ REST_URL_PREFIX_PUSH=http://127.0.0.1:${server.port} #是否开启测试数据(在真实数据为空时触发):true表示开启,false表示关闭 Open.False.Data=false #是否开启无数据时,最近数据的查询(目前只针对累加和实时的封堵整体、分布、DNS欺骗显示接口) -Open.Recent.Data.Actual=false +Open.Recent.Data.Actual=true #是否开启无数据时,最近数据的查询(目前只针对趋势图接口) Open.Recent.Data.Tendency=true #是否开启无数据时,最近数据的查询(其余接口) diff --git a/src/main/java/com/nis/galaxy/template/ForEventsInterface.java b/src/main/java/com/nis/galaxy/template/ForEventsInterface.java index a98e753..8912e80 100644 --- a/src/main/java/com/nis/galaxy/template/ForEventsInterface.java +++ b/src/main/java/com/nis/galaxy/template/ForEventsInterface.java @@ -513,7 +513,6 @@ public class ForEventsInterface { Date start = DateUtil.getSomeHour(end, -1); List contentValue = null; try { - contentValue = eventsService.getFocusWebsite(start, end, logMark); } catch (Exception e) { logger.error(logMark + "\t查询异常\trestTemplate", e); } diff --git a/src/main/java/com/nis/galaxy/web/dao/EventsDao.java b/src/main/java/com/nis/galaxy/web/dao/EventsDao.java index fa5a6cd..9219bf4 100644 --- a/src/main/java/com/nis/galaxy/web/dao/EventsDao.java +++ b/src/main/java/com/nis/galaxy/web/dao/EventsDao.java @@ -27,6 +27,8 @@ public interface EventsDao { List<EventsSpecificWebsites> getSpecificWebsites(@Param("push") Date push); + List<EventsSpecificWebsites> getFocusWebsite(@Param("start") Date start, @Param("end") Date end); + List<EventsAudioMonitor> getEventsAudioMonitor(@Param("push") Date push, @Param("start") Date start, @Param("end") Date end); Date getEventsAudioMonitorLastTime(@Param("end") Date end); diff --git a/src/main/java/com/nis/galaxy/web/service/EventsService.java b/src/main/java/com/nis/galaxy/web/service/EventsService.java index e22fac4..14f8c36 100644 --- a/src/main/java/com/nis/galaxy/web/service/EventsService.java +++ b/src/main/java/com/nis/galaxy/web/service/EventsService.java @@ -61,6 +61,7 @@ public interface EventsService { List<EventsSpecificWebsites> getSpecificWebsites(Date push,String logMark); + /** * 网站统计 * @param start @@ -71,6 +72,7 @@ public interface EventsService { List<EventsSpecificWebsites> getFocusWebsite(Date start, Date end,String logMark); + /** * 事件监测 * diff --git a/src/test/java/com/nis/galaxy/GalaxyApplicationTests.java b/src/test/java/com/nis/galaxy/GalaxyApplicationTests.java index 16fdcee..a68f17c 100644 --- a/src/test/java/com/nis/galaxy/GalaxyApplicationTests.java +++ b/src/test/java/com/nis/galaxy/GalaxyApplicationTests.java @@ -7,10 +7,12 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; import javax.sql.DataSource; +import java.util.Random; @RunWith(SpringRunner.class) @SpringBootTest @@ -26,10 +28,72 @@ public class GalaxyApplicationTests { RestTemplate restTemplate; @Autowired PushParams pushParams; + @Autowired + JdbcTemplate jdbcTemplate; @Test public void contextLoads() { + + int i = new Random().nextInt(2); String root = stringEncryptor.encrypt("root"); System.out.println(root); + + } + + /*private static String driver = "com.mysql.jdbc.Driver"; + private static String url = "jdbc:mysql://192.168.10.204:3306/galaxy-dev?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true"; + private static String user = "root"; + private static String pwd = "111111"; + + static { + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } } + + @Test + public static void main(String[] args) throws SQLException { + Connection conn = DriverManager.getConnection(url, user, pwd); + insertData(conn); + + } + + public static void insertData(Connection conn) throws SQLException { +// String sql = "INSERT INTO ntc_pz_stat_hour(cfg_id,service,sum,report_time) VALUES(?,?,?,?)"; + String sql = "UPDATE ntc_pz_stat_hour set cfg_id = ? WHERE stat_id = ?"; + PreparedStatement ps = conn.prepareStatement(sql); + int count = 1; + int statId = 1025030; + int[] cfgId = {127,125,123,120,4217,4214,4211,838780,839042,1263,1271,839009,838667,798450, 838983, 838601, 115, 838600, 1373,838769, 323,1370,838772, 328, 322, 334, 332, 331, 798450, 77}; + //监测:838983,838601,838600,838769,838772,1370,1373 + //封堵:127,125,123,120,4217,4214,4211,838780,839009,839042,1263,1271,838667 + int[] serviceId = {128, 129, 132, 390, 592, 16, 17, 20, 262, 576,262}; + String time = "2018-12-26 16:00:00"; + while (statId <= 1028502) { + ps.setObject(1, cfgId[new Random().nextInt(30)]); + //ps.setObject(2, serviceId[new Random().nextInt(11)]); + ps.setObject(2, statId); +// ps.setObject(3, new Random().nextInt(1000)); +// ps.setObject(4, time); + if (count % 10 == 0) { + time = DateUtil.getSomeMinute(time ,- 60); + } + if (count % 500 == 0) { + ps.executeBatch(); + ps.clearBatch(); + ps.close(); + ps = conn.prepareStatement(sql); + System.out.println("batch 清空"); + count++; + statId++; + continue; + } + ps.addBatch(); + System.out.println("添加一条-->count=" + count); + count++; + statId++; + } + }*/ } |
