Sfoglia il codice sorgente

Merge branch '2.2.0' into 2.2.1

klzhangweiya 2 anni fa
parent
commit
39057b0c04

+ 210 - 208
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-acquis-ws/src/main/java/cn/vbdsm/acquis/timer/RebuildTableTimer.java

@@ -1,10 +1,9 @@
 package cn.vbdsm.acquis.timer;
 
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-
+import cn.vbdsm.acquis.dao.*;
+import cn.vbdsm.common.constants.CronExpression;
+import cn.vbdsm.core.plugin.queue.QueuePlugin;
+import cn.vbdsm.core.plugin.queue.model.QueueItem;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -12,218 +11,221 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import cn.vbdsm.acquis.dao.AnalDateAvgDao;
-import cn.vbdsm.acquis.dao.AnalDateFgpDao;
-import cn.vbdsm.acquis.dao.AnalDateMaxDao;
-import cn.vbdsm.acquis.dao.AnalDateMinDao;
-import cn.vbdsm.acquis.dao.OnlineDataEnergyDao;
-import cn.vbdsm.acquis.dao.OnlineDataHarmonicIDao;
-import cn.vbdsm.acquis.dao.OnlineDataHarmonicUDao;
-import cn.vbdsm.acquis.dao.OnlineDataPowerDao;
-import cn.vbdsm.acquis.dao.OnlineDataQtyDao;
-import cn.vbdsm.common.constants.CronExpression;
-import cn.vbdsm.core.plugin.queue.QueuePlugin;
-import cn.vbdsm.core.plugin.queue.model.QueueItem;
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.util.Map;
 
 @Component
 public class RebuildTableTimer {
 
-	
-	private Logger LOG = Logger.getLogger(this.getClass());
-	private QueuePlugin queuePlugin = new QueuePlugin() {
-		protected void process(QueueItem item) {}
-	};
-	
-	
+
+    private final Logger LOG = Logger.getLogger(this.getClass());
+    private final QueuePlugin queuePlugin = new QueuePlugin() {
+        protected void process(QueueItem item) {
+        }
+    };
+
+
 //	@Autowired private AnalData24hEnergyDao analData24hEnergyDao;
-	
-	@Autowired private AnalDateAvgDao analDateAvgDao;
-	@Autowired private AnalDateFgpDao analDateFgpDao;
-	@Autowired private AnalDateMaxDao analDateMaxDao;
-	@Autowired private AnalDateMinDao analDateMinDao;
-	@Autowired private OnlineDataEnergyDao onlineDataEnergyDao;
-	@Autowired private OnlineDataHarmonicIDao onlineDataHarmonicIDao;
-	@Autowired private OnlineDataHarmonicUDao onlineDataHarmonicUDao;
-	@Autowired private OnlineDataPowerDao onlineDataPowerDao;
-	@Autowired private OnlineDataQtyDao onlineDataQtyDao;
-	
-	
-	private JdbcTemplate jdbc;
+
+    @Autowired
+    private AnalDateAvgDao analDateAvgDao;
+    @Autowired
+    private AnalDateFgpDao analDateFgpDao;
+    @Autowired
+    private AnalDateMaxDao analDateMaxDao;
+    @Autowired
+    private AnalDateMinDao analDateMinDao;
+    @Autowired
+    private OnlineDataEnergyDao onlineDataEnergyDao;
+    @Autowired
+    private OnlineDataHarmonicIDao onlineDataHarmonicIDao;
+    @Autowired
+    private OnlineDataHarmonicUDao onlineDataHarmonicUDao;
+    @Autowired
+    private OnlineDataPowerDao onlineDataPowerDao;
+    @Autowired
+    private OnlineDataQtyDao onlineDataQtyDao;
+
+
+    private JdbcTemplate jdbc;
 //	private DynamicDataSourceEntry dynamicDataSourceEntry;
- 	
-	/**
-	 * 设定数据源
-	 * @param dataSource
-	 */
-	@Resource(name="dynamicDataSource")
-	public void setDataSource(DataSource dataSource){
+
+    /**
+     * 设定数据源
+     *
+     * @param dataSource
+     */
+    @Resource(name = "dynamicDataSource")
+    public void setDataSource(DataSource dataSource) {
 //		dynamicDataSourceEntry = ((DynamicDataSource) dataSource).getDataSourceEntry();
-		jdbc = new JdbcTemplate(dataSource);
-	}
-	
-	
-	/**
-	 * 重建数据库表
-	 * @param tableName
-	 * @return
-	 */
-	public boolean rebuildTable(String tableName){
-		String renameTable = tableName + "_bak";
-		
-		String dropSql = "DROP TABLE IF EXISTS " + renameTable;
-		
-		String renameSql = "RENAME TABLE " + tableName + " TO " + renameTable;
-		
-		String getCreateSql = "SHOW CREATE TABLE " + tableName;
-		
-		//获取重建表结构的执行SQL
-		String rebuildSql = null;
-		try {
-			Map<String,Object> r = jdbc.queryForMap(getCreateSql);
-			rebuildSql = r.get("Create Table").toString();
-		}catch(Exception e){
-			LOG.error("获取表结构信息失败" + e.getStackTrace());
-			return false;
-		}
-		//重置自增长值
-		rebuildSql = rebuildSql.replaceFirst("AUTO_INCREMENT=\\d+ ","");
-		
-		try{
-			//判断重命名后的表存不存在,如果存在则先将其删掉
-			jdbc.update(dropSql);
-			//开始重命名表
-			jdbc.update(renameSql);
-			//然后重建表
-			jdbc.update(rebuildSql.toString());
-		}catch(Exception e){
-			LOG.error("执行失败" + e.getStackTrace());
-			return false;
-		}
-		return true;
-	}
-	
-	
-	/**
-	 * 删除表
-	 * @param tableName
-	 * @return
-	 */
-	private boolean dropTable(String tableName){
-		String renameTable = tableName + "_bak";
-		String dropSql = "DROP TABLE IF EXISTS " + renameTable;
-		try{
-			//删除重命名以后的表
-			jdbc.update(dropSql);
-		}catch(Exception e){
-			return false;
-		}
-		return true;
-	}
-	
-	
-	
-	
-	@Async
-	@Scheduled(cron=CronExpression.TIME_0_HOUR_0_MINUTE_30_SECOND)
-	public void rebuildTables(){
-		
-		//暂停分配任务
-		LOG.info("暂停任务分配...");
-		queuePlugin.pause();
-		
-		
+        jdbc = new JdbcTemplate(dataSource);
+    }
+
+
+    /**
+     * 重建数据库表
+     *
+     * @param tableName
+     * @return
+     */
+    private boolean rebuildTable(String tableName) {
+        String renameTable = tableName + "_bak";
+
+        String dropSql = "DROP TABLE IF EXISTS " + renameTable;
+
+        String renameSql = "RENAME TABLE " + tableName + " TO " + renameTable;
+
+        String getCreateSql = "SHOW CREATE TABLE " + tableName;
+
+        //获取重建表结构的执行SQL
+        String rebuildSql = null;
+        try {
+            Map<String, Object> r = jdbc.queryForMap(getCreateSql);
+            rebuildSql = r.get("Create Table").toString();
+        } catch (Exception e) {
+            LOG.error("获取表结构信息失败" + e.getStackTrace());
+            return false;
+        }
+        rebuildSql = rebuildSql.replaceFirst("PRIMARY (.*) USING BTREE", "PRIMARY $1, $1 USING BTREE");
+        //重置自增长值
+        rebuildSql = rebuildSql.replaceFirst("AUTO_INCREMENT=\\d+ ", "");
+
+        try {
+            //判断重命名后的表存不存在,如果存在则先将其删掉
+            jdbc.update(dropSql);
+            //开始重命名表
+            jdbc.update(renameSql);
+            //然后重建表
+            jdbc.update(rebuildSql);
+        } catch (Exception e) {
+            LOG.error("执行失败" + e.getStackTrace());
+            return false;
+        }
+        return true;
+    }
+
+
+    /**
+     * 删除表
+     *
+     * @param tableName
+     * @return
+     */
+    private boolean dropTable(String tableName) {
+        String renameTable = tableName + "_bak";
+        String dropSql = "DROP TABLE IF EXISTS " + renameTable;
+        try {
+            //删除重命名以后的表
+            jdbc.update(dropSql);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+
+    @Async
+    @Scheduled(cron = CronExpression.TIME_0_HOUR_0_MINUTE_30_SECOND)
+    public void rebuildTables() {
+
+        //暂停分配任务
+        LOG.info("暂停任务分配...");
+        queuePlugin.pause();
+
+
 //		String t1 = analData24hEnergyDao.getTableName();
 //		LOG.warn("开始重建" + t1 + "表...");
 //		boolean r1 = rebuildTable(t1);
 //		LOG.warn("重建完成,执行结果:" + r1);
-	
-		String t2 = analDateAvgDao.getTableName();
-		LOG.info("开始重建" + t2 + "表...");
-		boolean r2 = rebuildTable(t2);
-		LOG.info("重建完成,执行结果:" + r2);
-	
-		String t3 = analDateFgpDao.getTableName();
-		LOG.info("开始重建" + t3 + "表...");
-		boolean r3 = rebuildTable(t3);
-		LOG.info("重建完成,执行结果:" + r3);
-		
-		String t4 = analDateMaxDao.getTableName();
-		LOG.info("开始重建" + t4 + "表...");
-		boolean r4 = rebuildTable(t4);
-		LOG.info("重建完成,执行结果:" + r4);
-		
-		String t5 = analDateMinDao.getTableName();
-		LOG.info("开始重建" + t5 + "表...");
-		boolean r5 = rebuildTable(t5);
-		LOG.info("重建完成,执行结果:" + r5);
-		
-		String t6 = onlineDataEnergyDao.getTableName();
-		LOG.info("开始重建" + t6 + "表...");
-		boolean r6 = rebuildTable(t6);
-		LOG.info("重建完成,执行结果:" + r6);
-		
-		String t7 = onlineDataHarmonicIDao.getTableName();
-		LOG.info("开始重建" + t7 + "表...");
-		boolean r7 = rebuildTable(t7);
-		LOG.info("重建完成,执行结果:" + r7);
-		
-		String t8 = onlineDataHarmonicUDao.getTableName();
-		LOG.info("开始重建" + t8 + "表...");
-		boolean r8 = rebuildTable(t8);
-		LOG.info("重建完成,执行结果:" + r8);
-		
-		String t9 = onlineDataPowerDao.getTableName();
-		LOG.info("开始重建" + t9 + "表...");
-		boolean r9 = rebuildTable(t9);
-		LOG.info("重建完成,执行结果:" + r9);
-		
-		String t10 = onlineDataQtyDao.getTableName();
-		LOG.info("开始重建" + t10 + "表...");
-		boolean r10 = rebuildTable(t10);
-		LOG.info("重建完成,执行结果:" + r10);
-			
-		//恢复任务分配
-		LOG.info("恢复任务分配...");
-		queuePlugin.resume();
-		
-		
-		LOG.info("开始删除" + t2 + "表的备份...");
-		r2 = dropTable(t2);
-		LOG.info("删除完成,执行结果:" + r2);
-		
-		LOG.info("开始删除" + t3 + "表的备份...");
-		r3 = dropTable(t3);
-		LOG.info("删除完成,执行结果:" + r3);
-		
-		LOG.info("开始删除" + t4 + "表的备份...");
-		r4 = dropTable(t4);
-		LOG.info("删除完成,执行结果:" + r4);
-		
-		LOG.info("开始删除" + t5 + "表的备份...");
-		r5 = dropTable(t5);
-		LOG.info("删除完成,执行结果:" + r5);
-		
-		LOG.info("开始删除" + t6 + "表的备份...");
-		r6 = dropTable(t6);
-		LOG.info("删除完成,执行结果:" + r6);
-		
-		LOG.info("开始删除" + t7 + "表的备份...");
-		r7 = dropTable(t7);
-		LOG.info("删除完成,执行结果:" + r7);
-		
-		LOG.info("开始删除" + t8 + "表的备份...");
-		r8 = dropTable(t8);
-		LOG.info("删除完成,执行结果:" + r8);
-		
-		LOG.info("开始删除" + t9 + "表的备份...");
-		r9 = dropTable(t9);
-		LOG.info("删除完成,执行结果:" + r9);
-		
-		LOG.info("开始删除" + t10 + "表的备份...");
-		r10 = dropTable(t10);
-		LOG.info("删除完成,执行结果:" + r10);
-		
-		
-	}
-	
+
+        String t2 = analDateAvgDao.getTableName();
+        LOG.info("开始重建" + t2 + "表...");
+        boolean r2 = rebuildTable(t2);
+        LOG.info("重建完成,执行结果:" + r2);
+
+        String t3 = analDateFgpDao.getTableName();
+        LOG.info("开始重建" + t3 + "表...");
+        boolean r3 = rebuildTable(t3);
+        LOG.info("重建完成,执行结果:" + r3);
+
+        String t4 = analDateMaxDao.getTableName();
+        LOG.info("开始重建" + t4 + "表...");
+        boolean r4 = rebuildTable(t4);
+        LOG.info("重建完成,执行结果:" + r4);
+
+        String t5 = analDateMinDao.getTableName();
+        LOG.info("开始重建" + t5 + "表...");
+        boolean r5 = rebuildTable(t5);
+        LOG.info("重建完成,执行结果:" + r5);
+
+        String t6 = onlineDataEnergyDao.getTableName();
+        LOG.info("开始重建" + t6 + "表...");
+        boolean r6 = rebuildTable(t6);
+        LOG.info("重建完成,执行结果:" + r6);
+
+        String t7 = onlineDataHarmonicIDao.getTableName();
+        LOG.info("开始重建" + t7 + "表...");
+        boolean r7 = rebuildTable(t7);
+        LOG.info("重建完成,执行结果:" + r7);
+
+        String t8 = onlineDataHarmonicUDao.getTableName();
+        LOG.info("开始重建" + t8 + "表...");
+        boolean r8 = rebuildTable(t8);
+        LOG.info("重建完成,执行结果:" + r8);
+
+        String t9 = onlineDataPowerDao.getTableName();
+        LOG.info("开始重建" + t9 + "表...");
+        boolean r9 = rebuildTable(t9);
+        LOG.info("重建完成,执行结果:" + r9);
+
+        String t10 = onlineDataQtyDao.getTableName();
+        LOG.info("开始重建" + t10 + "表...");
+        boolean r10 = rebuildTable(t10);
+        LOG.info("重建完成,执行结果:" + r10);
+
+        //恢复任务分配
+        LOG.info("恢复任务分配...");
+        queuePlugin.resume();
+
+
+        LOG.info("开始删除" + t2 + "表的备份...");
+        r2 = dropTable(t2);
+        LOG.info("删除完成,执行结果:" + r2);
+
+        LOG.info("开始删除" + t3 + "表的备份...");
+        r3 = dropTable(t3);
+        LOG.info("删除完成,执行结果:" + r3);
+
+        LOG.info("开始删除" + t4 + "表的备份...");
+        r4 = dropTable(t4);
+        LOG.info("删除完成,执行结果:" + r4);
+
+        LOG.info("开始删除" + t5 + "表的备份...");
+        r5 = dropTable(t5);
+        LOG.info("删除完成,执行结果:" + r5);
+
+        LOG.info("开始删除" + t6 + "表的备份...");
+        r6 = dropTable(t6);
+        LOG.info("删除完成,执行结果:" + r6);
+
+        LOG.info("开始删除" + t7 + "表的备份...");
+        r7 = dropTable(t7);
+        LOG.info("删除完成,执行结果:" + r7);
+
+        LOG.info("开始删除" + t8 + "表的备份...");
+        r8 = dropTable(t8);
+        LOG.info("删除完成,执行结果:" + r8);
+
+        LOG.info("开始删除" + t9 + "表的备份...");
+        r9 = dropTable(t9);
+        LOG.info("删除完成,执行结果:" + r9);
+
+        LOG.info("开始删除" + t10 + "表的备份...");
+        r10 = dropTable(t10);
+        LOG.info("删除完成,执行结果:" + r10);
+
+
+    }
+
 }

+ 2 - 2
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-acquis-ws/src/main/resources/local/schedule.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<timers> 
+<timers>
     <timer>clearLogsTimer.clearHistroyLog</timer>
-<!--    <timer>rebuildTableTimer.rebuildTables</timer>-->
+    <!--    <timer>rebuildTableTimer.rebuildTables</timer>-->
 </timers>

+ 2 - 2
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-acquis-ws/src/main/resources/product/schedule.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<timers> 
+<timers>
     <timer>clearLogsTimer.clearHistroyLog</timer>
-    <timer>rebuildTableTimer.rebuildTables</timer>
+    <!--    <timer>rebuildTableTimer.rebuildTables</timer>-->
 </timers>

+ 5 - 5
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-acquis-ws/src/main/resources/test/schedule.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<timers> 
-    		
+<timers>
+
     <timer>clearLogsTimer.clearHistroyLog</timer>
-    <timer>rebuildTableTimer.rebuildTables</timer>
-   
-   	
+    <!--    <timer>rebuildTableTimer.rebuildTables</timer>-->
+
+
 </timers>

+ 16 - 4
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-hj212/vbdsm-hj212-datacollect/src/main/java/cn/vbdsm/hj212/datacollect/biz/impl/OnlineDataEnergyImpl.java

@@ -71,6 +71,18 @@ public class OnlineDataEnergyImpl implements IOnlineDataEnergyBiz {
         String newkey = KeyUtils.mergeRedisKey(Constants.REDIS_TERMIANL_SYNC2DB_KEY_PRIFIX, time);
         // String newkey = KeyUtils.mergeRedisKey(Constants.REDIS_TERMIANL_ONLINE_KEY_PRIFIX);
         // redisTemplate.opsForList();
+        //if (redisTemplate.hasKey(newkey)) {
+        //    List<OnlineTerminal> terminals = new ArrayList<>();
+        //    for (long i = 0; i < 5; i++) {
+        //        OnlineTerminal ot = (OnlineTerminal) redisTemplate.opsForList().index(newkey, i);
+        //        terminals.add(ot);
+        //        redisTemplate.opsForList().remove(newkey, 0, ot);
+        //    }
+        //    if (!terminals.isEmpty()) {
+        //        insertData(terminals, time);
+        //    }
+        //} else
+
         if (redisTemplate.hasKey(newkey)) {
             long size = redisTemplate.opsForList().size(newkey);
             List<OnlineTerminal> terminals = new ArrayList<>();
@@ -99,7 +111,7 @@ public class OnlineDataEnergyImpl implements IOnlineDataEnergyBiz {
         List<OnlineDataHarmonicU> harmonicUList1 = new ArrayList<>();
         List<OnlineDataHarmonicU> harmonicUList2 = new ArrayList<>();
         List<OnlineDataHarmonicU> harmonicUList3 = new ArrayList<>();
-        List<String> termianls = new ArrayList<>();
+        List<String> terminalIds = new ArrayList<>();
         for (OnlineTerminal entity : terminals) {
             LOG.info(entity.getTerminalId());
             if (entity.getEnergy() != null) {
@@ -107,7 +119,7 @@ public class OnlineDataEnergyImpl implements IOnlineDataEnergyBiz {
             }
             if (entity.getPower() != null) {
                 powerList.add(entity.getPower());
-                termianls.add(entity.getPower().getTerminalId());
+                terminalIds.add(entity.getPower().getTerminalId());
             }
             if (entity.getQty() != null) {
                 qtyList.add(entity.getQty());
@@ -134,9 +146,9 @@ public class OnlineDataEnergyImpl implements IOnlineDataEnergyBiz {
                 analData24hEnergyList.add(entity.getAnalData());
             }
         }
-        if (termianls.size() > 0) {
+        if (terminalIds.size() > 0) {
             Monitor monitor = new Monitor();
-            monitor.setTermianlIds(termianls);
+            monitor.setTermianlIds(terminalIds);
             monitor.setOnlineTime(Long.valueOf(time));
             monitorMapper.update(monitor);
         }

+ 2 - 1
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-hj212/vbdsm-hj212-modle/src/main/java/cn/vbdsm/hj212/modle/NxBody.java → VB_DSM_V2.1/vbdsm-data-upload/vbdsm-hj212/vbdsm-hj212-modle/src/main/java/cn/vbdsm/hj212/modle/VbDsmBody.java

@@ -7,7 +7,7 @@ import java.math.BigDecimal;
 
 @Getter
 @Setter
-public class NxBody {
+public class VbDsmBody {
 
     private BigDecimal p;
     private BigDecimal pa;
@@ -31,6 +31,7 @@ public class NxBody {
     private BigDecimal uab;
     private BigDecimal ubc;
     private BigDecimal uca;
+    private BigDecimal dp;
     private BigDecimal pv;
 
 

+ 4 - 4
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-hj212/vbdsm-hj212-modle/src/main/java/cn/vbdsm/hj212/utils/Constants.java

@@ -6,10 +6,10 @@ public class Constants {
     public static final String PARAM_KEY_SPLITCHAR = "tid";
     public static final String PARAM_INNER_SPLITCHAR = ",";
     public static final String PARAM_KEY_DATETIME = "dataTime";
-    public static final String REDIS_TERMIANL_BASE_KEY_PRIFIX = "nx:online:terminal:base";
-    public static final String REDIS_TERMIANL_ONLINE_KEY_PRIFIX = "nx:online:terminal:online";
-    public static final String REDIS_TERMIANL_SYNC2DB_KEY_PRIFIX = "nx:online:terminal:sync2db";
-    public static final String REDIS_TERMIANL_STATUS_KEY_PRIFIX = "nx:online:terminal:status";
+    public static final String REDIS_TERMIANL_BASE_KEY_PRIFIX = "vbdsm:online:terminal:base";
+    public static final String REDIS_TERMIANL_ONLINE_KEY_PRIFIX = "vbdsm:online:terminal:online";
+    public static final String REDIS_TERMIANL_SYNC2DB_KEY_PRIFIX = "vbdsm:online:terminal:sync2db";
+    public static final String REDIS_TERMIANL_STATUS_KEY_PRIFIX = "vbdsm:online:terminal:status";
     public static final String REDIS_KEY_SPLIT = ":";
     public static final String TER_KEY_SPLITCHAR = "\\$";
     public static final String ELE_KEY_SPLITCHAR = "&";

+ 3 - 3
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-hj212/vbdsm-hj212-rpc/src/main/java/cn/vbdsm/hj212/rpc/DataUploadRequest.java

@@ -1,7 +1,7 @@
 package cn.vbdsm.hj212.rpc;
 
-import cn.vbdsm.hj212.modle.NxBody;
 import cn.vbdsm.hj212.modle.OnlineDataQty;
+import cn.vbdsm.hj212.modle.VbDsmBody;
 import cn.vbdsm.hj212.utils.Constants;
 import com.alibaba.fastjson.JSONObject;
 import lombok.Getter;
@@ -47,9 +47,9 @@ public class DataUploadRequest {
         return request;
     }
 
-    public NxBody getBody(String factor) {
+    public VbDsmBody getBody(String factor) {
         String jsonString = factors.get(factor).toJSONString();
-        return JSONObject.parseObject(jsonString.toLowerCase(), NxBody.class);
+        return JSONObject.parseObject(jsonString.toLowerCase(), VbDsmBody.class);
     }
 
     public OnlineDataQty getDataQty(String factor) {

+ 154 - 95
VB_DSM_V2.1/vbdsm-data-upload/vbdsm-hj212/vbdsm-hj212-server/src/main/java/cn/vbdsm/hj212/server/executor/ReaTimeExector.java

@@ -50,6 +50,8 @@ public class ReaTimeExector implements IExecutor {
             request.getCtx().channel().writeAndFlush(response);
             return;
         }
+        time = time - time % 500;
+
         log.debug(cp);
         DataUploadRequest dataUpload = DataUploadRequest.parse(cp);
         Boolean flag = false;
@@ -59,51 +61,54 @@ public class ReaTimeExector implements IExecutor {
             OnlineTerminal onlineTerminal = new OnlineTerminal();
             onlineTerminal.setTerminalId(tid);
             MonitorCache entity = dataBiz.getMonitorByPk(cn, tid);
+            //Long entity = 20L;
+            //Long entity = null;
             if (entity != null) {
-                NxBody nxBody = dataUpload.getBody(tid);
-                if (nxBody.getP() != null) {
+                VbDsmBody body = dataUpload.getBody(tid);
+                if (body.getP() != null) {
                     //p
                     OnlineDataPower power = new OnlineDataPower();
                     power.setTerminalId(tid);
                     power.setGetTime(time);
-                    power.setPa(nxBody.getPa());
-                    power.setPb(nxBody.getPb());
-                    power.setPc(nxBody.getPc());
-                    power.setP(nxBody.getP());
-                    power.setQa(nxBody.getQa());
-                    power.setQb(nxBody.getQb());
-                    power.setQc(nxBody.getQc());
-                    power.setQ(nxBody.getQ());
-                    power.setPfa(nxBody.getPfa());
-                    power.setPfb(nxBody.getPfb());
-                    power.setPfc(nxBody.getPfc());
-                    power.setPf(nxBody.getPf());
-                    power.setIa(nxBody.getIa());
-                    power.setIb(nxBody.getIb());
-                    power.setIc(nxBody.getIc());
-                    power.setIz(nxBody.getIz());
-                    power.setUa(nxBody.getUa());
-                    power.setUb(nxBody.getUb());
-                    power.setUc(nxBody.getUc());
-                    power.setUab(nxBody.getUab());
-                    power.setUbc(nxBody.getUbc());
-                    power.setUca(nxBody.getUca());
-                    power.setPv(nxBody.getPv());
+                    power.setPa(body.getPa());
+                    power.setPb(body.getPb());
+                    power.setPc(body.getPc());
+                    power.setP(body.getP());
+                    power.setQa(body.getQa());
+                    power.setQb(body.getQb());
+                    power.setQc(body.getQc());
+                    power.setQ(body.getQ());
+                    power.setPfa(body.getPfa());
+                    power.setPfb(body.getPfb());
+                    power.setPfc(body.getPfc());
+                    power.setPf(body.getPf());
+                    power.setIa(body.getIa());
+                    power.setIb(body.getIb());
+                    power.setIc(body.getIc());
+                    power.setIz(body.getIz());
+                    power.setUa(body.getUa());
+                    power.setUb(body.getUb());
+                    power.setUc(body.getUc());
+                    power.setUab(body.getUab());
+                    power.setUbc(body.getUbc());
+                    power.setUca(body.getUca());
+                    power.setDp(body.getDp());
+                    power.setPv(body.getPv());
                     onlineTerminal.setPower(power);
                 }
                 //tps
-                if (nxBody.getTps() != null) {
+                if (body.getTps() != null) {
                     OnlineDataEnergy energy = new OnlineDataEnergy();
                     energy.setTerminalId(tid);
                     energy.setGetTime(time);
-                    energy.setTpe(nxBody.getTpe());
-                    energy.setTqe(nxBody.getTqe());
-                    energy.setFpe(nxBody.getFpe());
-                    energy.setFqe(nxBody.getFqe());
-                    energy.setTps(nxBody.getTps());
-                    energy.setTqs(nxBody.getTqs());
-                    energy.setFps(nxBody.getFps());
-                    energy.setFqs(nxBody.getFqs());
+                    energy.setTpe(body.getTpe());
+                    energy.setTqe(body.getTqe());
+                    energy.setFpe(body.getFpe());
+                    energy.setFqe(body.getFqe());
+                    energy.setTps(body.getTps());
+                    energy.setTqs(body.getTqs());
+                    energy.setFps(body.getFps());
+                    energy.setFqs(body.getFqs());
                     onlineTerminal.setEnergy(energy);
                 }
 
@@ -115,70 +120,82 @@ public class ReaTimeExector implements IExecutor {
                     onlineTerminal.setQty(dataQty);
                 }
                 //
-                String hia = nxBody.getHia();
-                String iahar = nxBody.getIahar();
-                if (!StringUtils.isEmpty(iahar)) {
-                    OnlineDataHarmonicI entity1 = getOnlineI(hia, "IA", time, tid, nxBody.getBaseia(), iahar);
-                    if (entity1 != null) {
-                        onlineTerminal.setHia(entity1);
-                    }
-                }
-                String hib = nxBody.getHib();
-                String ibhar = nxBody.getIbhar();
-                if (!StringUtils.isEmpty(ibhar)) {
-                    OnlineDataHarmonicI entity1 = getOnlineI(hib, "IB", time, tid, nxBody.getBaseib(), ibhar);
-                    if (entity1 != null) {
-                        onlineTerminal.setHib(entity1);
-                    }
-                }
-                String hic = nxBody.getHic();
-                String ichar = nxBody.getIchar();
-                if (!StringUtils.isEmpty(ichar)) {
-                    OnlineDataHarmonicI entity1 = getOnlineI(hic, "IC", time, tid, nxBody.getBaseic(), ichar);
-                    if (entity1 != null) {
-                        onlineTerminal.setHic(entity1);
-                    }
-                }
+                String hia = body.getHia();
+                //String iahar = body.getIahar();
+                //if (!StringUtils.isEmpty(iahar)) {
+                //    OnlineDataHarmonicI entity1 = getOnlineI(hia, "IA", time, tid, body.getBaseia(), iahar);
+                //    if (entity1 != null) {
+                //        onlineTerminal.setHia(entity1);
+                //    }
+                //}
+                String hib = body.getHib();
+                //String ibhar = body.getIbhar();
+                //if (!StringUtils.isEmpty(ibhar)) {
+                //    OnlineDataHarmonicI entity1 = getOnlineI(hib, "IB", time, tid, body.getBaseib(), ibhar);
+                //    if (entity1 != null) {
+                //        onlineTerminal.setHib(entity1);
+                //    }
+                //}
+                String hic = body.getHic();
+                OnlineDataHarmonicI entity_ia = getOnlineI(hia, "IA", time, tid);
+                if (entity_ia != null && entity_ia.getHall() != null) onlineTerminal.setHia(entity_ia);
+                OnlineDataHarmonicI entity_ib = getOnlineI(hib, "IB", time, tid);
+                if (entity_ib != null && entity_ib.getHall() != null) onlineTerminal.setHib(entity_ib);
+                OnlineDataHarmonicI entity_ic = getOnlineI(hic, "IC", time, tid);
+                if (entity_ic != null && entity_ic.getHall() != null) onlineTerminal.setHic(entity_ic);
+                //String ichar = body.getIchar();
+                //if (!StringUtils.isEmpty(ichar)) {
+                //    OnlineDataHarmonicI entity1 = getOnlineI(hic, "IC", time, tid, body.getBaseic(), ichar);
+                //    if (entity1 != null) {
+                //        onlineTerminal.setHic(entity1);
+                //    }
+                //}
 
-                String hua = nxBody.getHua();
-                String uahar = nxBody.getUahar();
-                if (!StringUtils.isEmpty(uahar)) {
-                    OnlineDataHarmonicU entity1 = getOnlineU(hua, "UA", time, tid, nxBody.getBaseua(), uahar);
-                    if (entity1 != null) {
-                        onlineTerminal.setHua(entity1);
-                    }
-                }
-                String hub = nxBody.getHub();
-                String ubhar = nxBody.getUbhar();
-                if (!StringUtils.isEmpty(ubhar)) {
-                    OnlineDataHarmonicU entity1 = getOnlineU(hub, "UB", time, tid, nxBody.getBaseub(), ubhar);
-                    if (entity1 != null) {
-                        onlineTerminal.setHub(entity1);
-                    }
-                }
-                String huc = nxBody.getHuc();
-                String uchar = nxBody.getUchar();
-                if (!StringUtils.isEmpty(uchar)) {
-                    OnlineDataHarmonicU entity1 = getOnlineU(huc, "UC", time, tid, nxBody.getBaseuc(), uchar);
-                    if (entity1 != null) {
-                        onlineTerminal.setHuc(entity1);
-                    }
-                }
-                String hour = nxBody.getHour();
+                String hua = body.getHua();
+                //String uahar = body.getUahar();
+                //if (!StringUtils.isEmpty(uahar)) {
+                //    OnlineDataHarmonicU entity1 = getOnlineU(hua, "UA", time, tid, body.getBaseua(), uahar);
+                //    if (entity1 != null) {
+                //        onlineTerminal.setHua(entity1);
+                //    }
+                //}
+                String hub = body.getHub();
+                //String ubhar = body.getUbhar();
+                //if (!StringUtils.isEmpty(ubhar)) {
+                //    OnlineDataHarmonicU entity1 = getOnlineU(hub, "UB", time, tid, body.getBaseub(), ubhar);
+                //    if (entity1 != null) {
+                //        onlineTerminal.setHub(entity1);
+                //    }
+                //}
+                String huc = body.getHuc();
+                OnlineDataHarmonicU entity_ua = getOnlineU(hua, "UA", time, tid);
+                if (entity_ua != null && entity_ua.getHall() != null) onlineTerminal.setHua(entity_ua);
+                OnlineDataHarmonicU entity_ub = getOnlineU(hub, "UB", time, tid);
+                if (entity_ub != null && entity_ub.getHall() != null) onlineTerminal.setHub(entity_ub);
+                OnlineDataHarmonicU entity_uc = getOnlineU(huc, "UC", time, tid);
+                if (entity_uc != null && entity_uc.getHall() != null) onlineTerminal.setHuc(entity_uc);
+                //String uchar = body.getUchar();
+                //if (!StringUtils.isEmpty(uchar)) {
+                //    OnlineDataHarmonicU entity1 = getOnlineU(huc, "UC", time, tid, body.getBaseuc(), uchar);
+                //    if (entity1 != null) {
+                //        onlineTerminal.setHuc(entity1);
+                //    }
+                //}
+                String hour = body.getHour();
                 if (!StringUtils.isEmpty(hour)) {
                     AnalData24hEnergy analEnergy = new AnalData24hEnergy();
                     analEnergy.setTerminalId(tid);
                     Long getDate = Long.valueOf(dataTime.substring(0, 8));
                     analEnergy.setGetDate(getDate);
-                    analEnergy.setFpe(nxBody.getHourfpe());
-                    analEnergy.setFqe(nxBody.getHourfqe());
-                    analEnergy.setFps(nxBody.getHourfps());
-                    analEnergy.setFqs(nxBody.getHourfqs());
-                    analEnergy.setTpe(nxBody.getHourtpe());
-                    analEnergy.setTqe(nxBody.getHourtqe());
-                    analEnergy.setTps(nxBody.getHourtps());
-                    analEnergy.setTqs(nxBody.getHourtqs());
-                    analEnergy.setHour(Integer.valueOf(nxBody.getHour()));
+                    analEnergy.setFpe(body.getHourfpe());
+                    analEnergy.setFqe(body.getHourfqe());
+                    analEnergy.setFps(body.getHourfps());
+                    analEnergy.setFqs(body.getHourfqs());
+                    analEnergy.setTpe(body.getHourtpe());
+                    analEnergy.setTqe(body.getHourtqe());
+                    analEnergy.setTps(body.getHourtps());
+                    analEnergy.setTqs(body.getHourtqs());
+                    analEnergy.setHour(Integer.valueOf(body.getHour()));
                     onlineTerminal.setAnalData(analEnergy);
                 }
                 dataBiz.insertOnlineData(onlineTerminal);
@@ -186,7 +203,7 @@ public class ReaTimeExector implements IExecutor {
                 flag = true;
             }
         }
-        //zuihou
+
         RpcRemoterStruct response = new RpcRemoterStruct(st, msg.getCn(), msg.getDataTime(), "00");
         if (flag) {
             response.setCp("02");
@@ -195,7 +212,28 @@ public class ReaTimeExector implements IExecutor {
         log.debug(response.toString());
     }
 
-    public OnlineDataHarmonicU getOnlineU(String hia, String type, Long time, String tid, String base, String hall) {
+    public OnlineDataHarmonicU getOnlineU(String hia, String type, Long time, String tid) {
+        JSONObject jsonObject = new JSONObject();
+        OnlineDataHarmonicU onlineDataHu = new OnlineDataHarmonicU();
+        if (!StringUtils.isEmpty(hia)) {
+            String[] temps = hia.split(",");
+            for (String str : temps) {
+                String[] ele = str.split(":");
+                if (ele.length > 1 && !StringUtils.isEmpty(ele[1])) {
+                    jsonObject.put(ele[0], new BigDecimal(ele[1]));
+                }
+            }
+            String jsonString = JSONObject.toJSONString(jsonObject);
+            onlineDataHu = JSONObject.parseObject(jsonString, OnlineDataHarmonicU.class);
+        }
+        onlineDataHu.setGetTime(time);
+        onlineDataHu.setTerminalId(tid);
+        onlineDataHu.setHtype(type);
+
+        return onlineDataHu;
+    }
+
+    public OnlineDataHarmonicU getOnlineU_bak(String hia, String type, Long time, String tid, String base, String hall) {
         JSONObject jsonObject = new JSONObject();
         OnlineDataHarmonicU onlineDataHarmonicI = new OnlineDataHarmonicU();
         if (!StringUtils.isEmpty(hia)) {
@@ -220,7 +258,28 @@ public class ReaTimeExector implements IExecutor {
     }
 
 
-    public OnlineDataHarmonicI getOnlineI(String hia, String type, Long time, String tid, String base, String hall) {
+    public OnlineDataHarmonicI getOnlineI(String hia, String type, Long time, String tid) {
+        JSONObject jsonObject = new JSONObject();
+        OnlineDataHarmonicI onlineDataHarmonicI = new OnlineDataHarmonicI();
+        if (!StringUtils.isEmpty(hia)) {
+            String[] temps = hia.split(",");
+            for (String str : temps) {
+                String[] ele = str.split(":");
+                if (ele.length > 1 && !StringUtils.isEmpty(ele[1])) {
+                    jsonObject.put(ele[0], new BigDecimal(ele[1]));
+                }
+            }
+            String jsonString = JSONObject.toJSONString(jsonObject);
+            onlineDataHarmonicI = JSONObject.parseObject(jsonString, OnlineDataHarmonicI.class);
+        }
+        onlineDataHarmonicI.setGetTime(time);
+        onlineDataHarmonicI.setTerminalId(tid);
+        onlineDataHarmonicI.setHtype(type);
+
+        return onlineDataHarmonicI;
+    }
+
+    public OnlineDataHarmonicI getOnlineI_bak(String hia, String type, Long time, String tid, String base, String hall) {
         JSONObject jsonObject = new JSONObject();
         OnlineDataHarmonicI onlineDataHarmonicI = new OnlineDataHarmonicI();
         if (!StringUtils.isEmpty(hia)) {

+ 192 - 196
VB_DSM_V2.1/vbdsm-statistics/vbdsm-analysis/src/main/java/cn/vbdsm/analysis/timer/impl/RebuildTableTimer.java

@@ -1,10 +1,8 @@
 package cn.vbdsm.analysis.timer.impl;
 
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-
+import cn.vbdsm.analysis.dao.*;
+import cn.vbdsm.common.annotation.Comment;
+import cn.vbdsm.common.constants.CronExpression;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -12,209 +10,207 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import cn.vbdsm.analysis.dao.AnalDateAvgDao;
-import cn.vbdsm.analysis.dao.AnalDateFgpDao;
-import cn.vbdsm.analysis.dao.AnalDateMaxDao;
-import cn.vbdsm.analysis.dao.AnalDateMinDao;
-import cn.vbdsm.analysis.dao.OnlineDataEnergyDao;
-import cn.vbdsm.analysis.dao.OnlineDataHarmonicIDao;
-import cn.vbdsm.analysis.dao.OnlineDataHarmonicUDao;
-import cn.vbdsm.analysis.dao.OnlineDataPowerDao;
-import cn.vbdsm.analysis.dao.OnlineDataQtyDao;
-import cn.vbdsm.common.annotation.Comment;
-import cn.vbdsm.common.constants.CronExpression;
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.util.Map;
 
 
 @Component
 public class RebuildTableTimer {
 
-	private Logger LOG = Logger.getLogger(this.getClass());
-	
-	@Autowired private AnalDateAvgDao analDateAvgDao;
-	@Autowired private AnalDateFgpDao analDateFgpDao;
-	@Autowired private AnalDateMaxDao analDateMaxDao;
-	@Autowired private AnalDateMinDao analDateMinDao;
-	@Autowired private OnlineDataEnergyDao onlineDataEnergyDao;
-	@Autowired private OnlineDataHarmonicIDao onlineDataHarmonicIDao;
-	@Autowired private OnlineDataHarmonicUDao onlineDataHarmonicUDao;
-	@Autowired private OnlineDataPowerDao onlineDataPowerDao;
-	@Autowired private OnlineDataQtyDao onlineDataQtyDao;
-	
-	
-	private JdbcTemplate jdbc;
+    private final Logger LOG = Logger.getLogger(this.getClass());
+
+    @Autowired
+    private AnalDateAvgDao analDateAvgDao;
+    @Autowired
+    private AnalDateFgpDao analDateFgpDao;
+    @Autowired
+    private AnalDateMaxDao analDateMaxDao;
+    @Autowired
+    private AnalDateMinDao analDateMinDao;
+    @Autowired
+    private OnlineDataEnergyDao onlineDataEnergyDao;
+    @Autowired
+    private OnlineDataHarmonicIDao onlineDataHarmonicIDao;
+    @Autowired
+    private OnlineDataHarmonicUDao onlineDataHarmonicUDao;
+    @Autowired
+    private OnlineDataPowerDao onlineDataPowerDao;
+    @Autowired
+    private OnlineDataQtyDao onlineDataQtyDao;
+
+
+    private JdbcTemplate jdbc;
 //	private DynamicDataSourceEntry dynamicDataSourceEntry;
- 	
-	/**
-	 * 设定数据源
-	 * @param dataSource
-	 */
-	@Resource(name="dynamicDataSource")
-	public void setDataSource(DataSource dataSource){
+
+    /**
+     * 设定数据源
+     *
+     * @param dataSource
+     */
+    @Resource(name = "dynamicDataSource")
+    public void setDataSource(DataSource dataSource) {
 //		dynamicDataSourceEntry = ((DynamicDataSource) dataSource).getDataSourceEntry();
-		jdbc = new JdbcTemplate(dataSource);
-	}
-	
-	
-	/**
-	 * 重建数据库表
-	 * @param tableName
-	 * @return
-	 */
-	private boolean rebuildTable(String tableName){
-		String renameTable = tableName + "_bak";
-		
-		String dropSql = "DROP TABLE IF EXISTS " + renameTable;
-		
-		String renameSql = "RENAME TABLE " + tableName + " TO " + renameTable;
-		
-		String getCreateSql = "SHOW CREATE TABLE " + tableName;
-		
-		//获取重建表结构的执行SQL
-		String rebuildSql = null;
-		try {
-			Map<String,Object> r = jdbc.queryForMap(getCreateSql);
-			rebuildSql = r.get("Create Table").toString();
-		}catch(Exception e){
-			LOG.error("获取表结构信息失败" + e.getStackTrace());
-			return false;
-		}
-        rebuildSql = rebuildSql.replaceFirst("PRIMARY (.*) USING BTREE","PRIMARY $1 ,$1 USING BTREE");
-		//重置自增长值
-		rebuildSql = rebuildSql.replaceFirst("AUTO_INCREMENT=\\d+ ","");
-		
-		try{
-
-		   //判断重命名后的表存不存在,如果存在则先将其删掉
-			jdbc.update(dropSql);
-			//开始重命名表
-			jdbc.update(renameSql);
-			//然后重建表
-			jdbc.update(rebuildSql.toString());
-		}catch(Exception e){
-			LOG.error("执行失败" + e.getStackTrace());
-			return false;
-		}
-		return true;
-	}
-	
-	
-	/**
-	 * 删除表
-	 * @param tableName
-	 * @return
-	 */
-	private boolean dropTable(String tableName){
-		String renameTable = tableName + "_bak";
-		String dropSql = "DROP TABLE IF EXISTS " + renameTable;
-		try{
-			//删除重命名以后的表
-			jdbc.update(dropSql);
-		}catch(Exception e){
-			return false;
-		}
-		return true;
-	}
-	
-	
-	
-	
-	@Async
-	@Scheduled(cron=CronExpression.TIME_0_HOUR_0_MINUTE_30_SECOND)
-	@Comment("清除实时表中的历史数据")
-	public void rebuildTables(){
-		
-		
+        jdbc = new JdbcTemplate(dataSource);
+    }
+
+
+    /**
+     * 重建数据库表
+     *
+     * @param tableName
+     * @return
+     */
+    private boolean rebuildTable(String tableName) {
+        String renameTable = tableName + "_bak";
+
+        String dropSql = "DROP TABLE IF EXISTS " + renameTable;
+
+        String renameSql = "RENAME TABLE " + tableName + " TO " + renameTable;
+
+        String getCreateSql = "SHOW CREATE TABLE " + tableName;
+
+        //获取重建表结构的执行SQL
+        String rebuildSql = null;
+        try {
+            Map<String, Object> r = jdbc.queryForMap(getCreateSql);
+            rebuildSql = r.get("Create Table").toString();
+        } catch (Exception e) {
+            LOG.error("获取表结构信息失败" + e.getStackTrace());
+            return false;
+        }
+        rebuildSql = rebuildSql.replaceFirst("PRIMARY (.*) USING BTREE", "PRIMARY $1, $1 USING BTREE");
+        //重置自增长值
+        rebuildSql = rebuildSql.replaceFirst("AUTO_INCREMENT=\\d+ ", "");
+
+        try {
+            //判断重命名后的表存不存在,如果存在则先将其删掉
+            jdbc.update(dropSql);
+            //开始重命名表
+            jdbc.update(renameSql);
+            //然后重建表
+            jdbc.update(rebuildSql);
+        } catch (Exception e) {
+            LOG.error("执行失败" + e.getStackTrace());
+            return false;
+        }
+        return true;
+    }
+
+
+    /**
+     * 删除表
+     *
+     * @param tableName
+     * @return
+     */
+    private boolean dropTable(String tableName) {
+        String renameTable = tableName + "_bak";
+        String dropSql = "DROP TABLE IF EXISTS " + renameTable;
+        try {
+            //删除重命名以后的表
+            jdbc.update(dropSql);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+
+    @Async
+    @Scheduled(cron = CronExpression.TIME_0_HOUR_0_MINUTE_30_SECOND)
+    @Comment("清除实时表中的历史数据")
+    public void rebuildTables() {
+
+
 //		String t1 = analData24hEnergyDao.getTableName();
 //		LOG.warn("开始重建" + t1 + "表...");
 //		boolean r1 = rebuildTable(t1);
 //		LOG.warn("重建完成,执行结果:" + r1);
 
+        String t2 = analDateAvgDao.getTableName();
+        LOG.info("开始重建" + t2 + "表...");
+        boolean r2 = rebuildTable(t2);
+        LOG.info("重建完成,执行结果:" + r2);
+
+        String t3 = analDateFgpDao.getTableName();
+        LOG.info("开始重建" + t3 + "表...");
+        boolean r3 = rebuildTable(t3);
+        LOG.info("重建完成,执行结果:" + r3);
+
+        String t4 = analDateMaxDao.getTableName();
+        LOG.info("开始重建" + t4 + "表...");
+        boolean r4 = rebuildTable(t4);
+        LOG.info("重建完成,执行结果:" + r4);
+
+        String t5 = analDateMinDao.getTableName();
+        LOG.info("开始重建" + t5 + "表...");
+        boolean r5 = rebuildTable(t5);
+        LOG.info("重建完成,执行结果:" + r5);
+
+        String t6 = onlineDataEnergyDao.getTableName();
+        LOG.info("开始重建" + t6 + "表...");
+        boolean r6 = rebuildTable(t6);
+        LOG.info("重建完成,执行结果:" + r6);
+
+        String t7 = onlineDataHarmonicIDao.getTableName();
+        LOG.info("开始重建" + t7 + "表...");
+        boolean r7 = rebuildTable(t7);
+        LOG.info("重建完成,执行结果:" + r7);
+
+        String t8 = onlineDataHarmonicUDao.getTableName();
+        LOG.info("开始重建" + t8 + "表...");
+        boolean r8 = rebuildTable(t8);
+        LOG.info("重建完成,执行结果:" + r8);
+
+        String t9 = onlineDataPowerDao.getTableName();
+        LOG.info("开始重建" + t9 + "表...");
+        boolean r9 = rebuildTable(t9);
+        LOG.info("重建完成,执行结果:" + r9);
+
+        String t10 = onlineDataQtyDao.getTableName();
+        LOG.info("开始重建" + t10 + "表...");
+        boolean r10 = rebuildTable(t10);
+        LOG.info("重建完成,执行结果:" + r10);
+
+
+        LOG.info("开始删除" + t2 + "表的备份...");
+        r2 = dropTable(t2);
+        LOG.info("删除完成,执行结果:" + r2);
+
+        LOG.info("开始删除" + t3 + "表的备份...");
+        r3 = dropTable(t3);
+        LOG.info("删除完成,执行结果:" + r3);
+
+        LOG.info("开始删除" + t4 + "表的备份...");
+        r4 = dropTable(t4);
+        LOG.info("删除完成,执行结果:" + r4);
+
+        LOG.info("开始删除" + t5 + "表的备份...");
+        r5 = dropTable(t5);
+        LOG.info("删除完成,执行结果:" + r5);
+
+        LOG.info("开始删除" + t6 + "表的备份...");
+        r6 = dropTable(t6);
+        LOG.info("删除完成,执行结果:" + r6);
+
+        LOG.info("开始删除" + t7 + "表的备份...");
+        r7 = dropTable(t7);
+        LOG.info("删除完成,执行结果:" + r7);
+
+        LOG.info("开始删除" + t8 + "表的备份...");
+        r8 = dropTable(t8);
+        LOG.info("删除完成,执行结果:" + r8);
+
+        LOG.info("开始删除" + t9 + "表的备份...");
+        r9 = dropTable(t9);
+        LOG.info("删除完成,执行结果:" + r9);
+
+        LOG.info("开始删除" + t10 + "表的备份...");
+        r10 = dropTable(t10);
+        LOG.info("删除完成,执行结果:" + r10);
+
 
+    }
 
-		String t2 = analDateAvgDao.getTableName();
-		LOG.info("开始重建" + t2 + "表...");
-		boolean r2 = rebuildTable(t2);
-		LOG.info("重建完成,执行结果:" + r2);
-	
-		String t3 = analDateFgpDao.getTableName();
-		LOG.info("开始重建" + t3 + "表...");
-		boolean r3 = rebuildTable(t3);
-		LOG.info("重建完成,执行结果:" + r3);
-		
-		String t4 = analDateMaxDao.getTableName();
-		LOG.info("开始重建" + t4 + "表...");
-		boolean r4 = rebuildTable(t4);
-		LOG.info("重建完成,执行结果:" + r4);
-		
-		String t5 = analDateMinDao.getTableName();
-		LOG.info("开始重建" + t5 + "表...");
-		boolean r5 = rebuildTable(t5);
-		LOG.info("重建完成,执行结果:" + r5);
-		
-		String t6 = onlineDataEnergyDao.getTableName();
-		LOG.info("开始重建" + t6 + "表...");
-		boolean r6 = rebuildTable(t6);
-		LOG.info("重建完成,执行结果:" + r6);
-		
-		String t7 = onlineDataHarmonicIDao.getTableName();
-		LOG.info("开始重建" + t7 + "表...");
-		boolean r7 = rebuildTable(t7);
-		LOG.info("重建完成,执行结果:" + r7);
-		
-		String t8 = onlineDataHarmonicUDao.getTableName();
-		LOG.info("开始重建" + t8 + "表...");
-		boolean r8 = rebuildTable(t8);
-		LOG.info("重建完成,执行结果:" + r8);
-		
-		String t9 = onlineDataPowerDao.getTableName();
-		LOG.info("开始重建" + t9 + "表...");
-		boolean r9 = rebuildTable(t9);
-		LOG.info("重建完成,执行结果:" + r9);
-		
-		String t10 = onlineDataQtyDao.getTableName();
-		LOG.info("开始重建" + t10 + "表...");
-		boolean r10 = rebuildTable(t10);
-		LOG.info("重建完成,执行结果:" + r10);
-			
-		
-		
-		LOG.info("开始删除" + t2 + "表的备份...");
-		r2 = dropTable(t2);
-		LOG.info("删除完成,执行结果:" + r2);
-		
-		LOG.info("开始删除" + t3 + "表的备份...");
-		r3 = dropTable(t3);
-		LOG.info("删除完成,执行结果:" + r3);
-		
-		LOG.info("开始删除" + t4 + "表的备份...");
-		r4 = dropTable(t4);
-		LOG.info("删除完成,执行结果:" + r4);
-		
-		LOG.info("开始删除" + t5 + "表的备份...");
-		r5 = dropTable(t5);
-		LOG.info("删除完成,执行结果:" + r5);
-		
-		LOG.info("开始删除" + t6 + "表的备份...");
-		r6 = dropTable(t6);
-		LOG.info("删除完成,执行结果:" + r6);
-		
-		LOG.info("开始删除" + t7 + "表的备份...");
-		r7 = dropTable(t7);
-		LOG.info("删除完成,执行结果:" + r7);
-		
-		LOG.info("开始删除" + t8 + "表的备份...");
-		r8 = dropTable(t8);
-		LOG.info("删除完成,执行结果:" + r8);
-		
-		LOG.info("开始删除" + t9 + "表的备份...");
-		r9 = dropTable(t9);
-		LOG.info("删除完成,执行结果:" + r9);
-		
-		LOG.info("开始删除" + t10 + "表的备份...");
-		r10 = dropTable(t10);
-		LOG.info("删除完成,执行结果:" + r10);
-		
-		
-	}
-	
 }

+ 2 - 2
VB_DSM_V2.1/vbdsm-statistics/vbdsm-analysis/src/main/resources/local/schedule.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<timers> 
-	
+<timers>
+
    	<timer>clearLogsTimer.clearHistroyLog</timer>
    	<timer>clearBibleWaringInfoTimer.clearHistroy</timer>
    	<!-- <timer>energyPriceTimer.energyPrice</timer> -->

+ 152 - 152
VB_DSM_V2.1/vbdsm-web/vbdsm-manage/src/main/java/cn/vbdsm/manage/dao/PowerUserDao.java

@@ -1,7 +1,9 @@
 package cn.vbdsm.manage.dao;
 
-import java.util.List;
-import java.util.Map;
+import cn.vbdsm.common.constants.SystemConstant;
+import cn.vbdsm.model.PowerUser;
+import org.springframework.stereotype.Repository;
+import org.springframework.ui.ModelMap;
 
 import javax.annotation.Resource;
 import javax.core.common.Page;
@@ -9,155 +11,153 @@ import javax.core.common.jdbc.BaseDaoSupport;
 import javax.core.common.jdbc.QueryRule;
 import javax.core.common.utils.StringUtils;
 import javax.sql.DataSource;
+import java.util.List;
+import java.util.Map;
 
-import org.springframework.stereotype.Repository;
-import org.springframework.ui.ModelMap;
-
-import cn.vbdsm.common.constants.SystemConstant;
-import cn.vbdsm.model.PowerUser;
-
-@Repository(value="powerUserDao")
-public class PowerUserDao extends BaseDaoSupport<PowerUser, Long>{
-	@Override
-	protected String getPKColumn() { return "id"; }
-
-	@Resource(name="dynamicDataSource")
-	public void setDataSource(DataSource dataSource){
-		super.setDataSourceReadOnly(dataSource);
-		super.setDataSourceWrite(dataSource);
-	}
-
-	public List<PowerUser> selectAll() {
-		QueryRule queryRule = QueryRule.getInstance();
-		queryRule.andEqual("isDel", SystemConstant.DISABLE);
-		return super.find(queryRule);
-	}
-
-	/**
-	 * 分页查询客户列表
-	 * @param pageNo
-	 * @param pageSize
-	 * @param name
-	 * @param serviceId
-	 * @param province
-	 * @param city
-	 * @param district
-	 * @param siteId
-	 * @return
-	 */
-	public Page<Map<String, Object>> selectAllForPage(int pageNo, int pageSize, String name, Long serviceId,
-			Integer province, Integer city, Integer district, Integer isRoot, Long fromSite) {
-		ModelMap param = new ModelMap();
-		StringBuffer sql = new StringBuffer();
-		sql.append("select * from (select t1.name,t1.serviceId,t1.address,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes from t_org t1,t_poweruser t2");
-		
-		//是系统管理员
-		if(null != isRoot && 1 == isRoot){
-			sql.append(" where  t1.id = t2.orgId and t1.orgType = 1");
-		}else{
-			sql.append(" ,t_org_site t");
-			sql.append(" where t.orgId=t1.id and t1.id = t2.orgId and t1.orgType = 1");
-			sql.append(" and t.siteId = :siteId");
-			param.put("siteId", fromSite);
-		}
-
-		if(!StringUtils.isEmpty(name)){
-			sql.append(" and t1.name like ").append("'%").append(name).append("%'");
-		}
-		if(null != serviceId){
-			sql.append(" and t1.serviceId = :serviceId");
-			param.put("serviceId", serviceId);
-		}
-		if(null != province){
-			sql.append(" and t1.province = :province");
-			param.put("province", province);
-		}
-		if(null != city){
-			sql.append(" and t1.city = :city");
-			param.put("city", city);
-		}
-		if(null != district){
-			sql.append(" and t1.district = :district");
-			param.put("district", district);
-		}
-
-		sql.append(" and t1.isDel=").append(SystemConstant.DISABLE);
-		sql.append(" group by t1.name,t1.serviceId,t1.address,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes) tt");
-		Page<Map<String, Object>> page = super.findBySqlToPage(sql.toString(), param, pageNo, pageSize);
-		return page;
-	}
-
-
-	public int remove(Long id, int state) {
-		String sql = "update t_poweruser set isDel=? where id=?";
-		return super.update(sql, state,id);
-	}
-
-	public int removeBatch(String []ids, int state) {
-		int result = 0  ;
-		String sql = "update t_poweruser set isDel=? where id=?";
-		for(String id : ids){
-			super.update(sql, state,id);
-			result++;
-		}
-		return result;
-	}
-
-	public int modifyState(Long id, int state) {
-		String sql = "update t_poweruser set state=? where id=?";
-		return super.update(sql, state,id);
-	}
-
-	public int modifyStateBatch(String[] ids, int state) {
-		int result = 0  ;
-		String sql = "update t_poweruser set state=? where id=?";
-		for(String id : ids){
-			super.update(sql, state,id);
-			result++;
-		}
-		return result;
-	}
-
-	public Map<String, Object> selectByOrgId(Long orgId) {
-		StringBuffer sql = new StringBuffer();
-		sql.append("select * from (select t1.name,t1.serviceId,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes,t2.industry1 from t_org_site t ,t_org t1,t_poweruser t2 where t.orgId=t1.id and t1.id = t2.orgId and t1.orgType = 1");
-		sql.append(" and t2.orgId=?");
-		sql.append(" and t1.isDel=").append(SystemConstant.DISABLE);
-		sql.append(" group by t1.name,t1.serviceId,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes,t2.industry1) tt");
-		return super.findBySql(sql.toString(), orgId).get(0);
-	}
-
-	public Page<Map<String, Object>> selectListByParkId(Long parkId,Integer province,Integer city, Integer district,
-			int pageNo, int pageSize) {
-		StringBuffer sql = new StringBuffer();
-		sql.append("select t.id,t.orgId,t.state,t1.name,t1.address,t.parkId from t_poweruser t,t_org t1 where t.orgId=t1.id and t1.isDel=0");
-		if(null != parkId){
-			sql.append(" and t.parkId=").append(parkId);
-		}else{
-			sql.append(" and t.parkId is null");
-		}
-		
-		if(null != province){
-			sql.append(" and t1.province=").append(province);
-		}
-		if(null != city){
-			sql.append(" and t1.city=").append(city);
-		}
-		if(null != district){
-			sql.append(" and t1.district=").append(district);
-		}
-		ModelMap param = new ModelMap();
-		Page<Map<String, Object>> page = super.findBySqlToPage(sql.toString(), param, pageNo, pageSize);
-		return page;
-	}
-
-	public int modifyParkIdBatch(String[] ids,Long parkId) {
-		int result = 0  ;
-		String sql = "update t_poweruser set parkId=? where id=?";
-		for(String id : ids){
-			super.update(sql, parkId,id);
-			result++;
-		}
-		return result;
-	}
+@Repository(value = "powerUserDao")
+public class PowerUserDao extends BaseDaoSupport<PowerUser, Long> {
+    @Override
+    protected String getPKColumn() {
+        return "id";
+    }
+
+    @Resource(name = "dynamicDataSource")
+    public void setDataSource(DataSource dataSource) {
+        super.setDataSourceReadOnly(dataSource);
+        super.setDataSourceWrite(dataSource);
+    }
+
+    public List<PowerUser> selectAll() {
+        QueryRule queryRule = QueryRule.getInstance();
+        queryRule.andEqual("isDel", SystemConstant.DISABLE);
+        return super.find(queryRule);
+    }
+
+    /**
+     * 分页查询客户列表
+     *
+     * @param pageNo
+     * @param pageSize
+     * @param name
+     * @param serviceId
+     * @param province
+     * @param city
+     * @param district
+     * @param siteId
+     * @return
+     */
+    public Page<Map<String, Object>> selectAllForPage(int pageNo, int pageSize, String name, Long serviceId,
+                                                      Integer province, Integer city, Integer district, Integer isRoot, Long fromSite) {
+        ModelMap param = new ModelMap();
+        StringBuffer sql = new StringBuffer();
+        sql.append("select * from (select t1.name,t1.serviceId,t1.address,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes from t_org t1,t_poweruser t2");
+
+        //是系统管理员
+        if (null != isRoot && 1 == isRoot) {
+            sql.append(" where  t1.id = t2.orgId and t1.orgType = 1");
+        } else {
+            sql.append(" ,t_org_site t");
+            sql.append(" where t.orgId=t1.id and t1.id = t2.orgId and t1.orgType = 1");
+            sql.append(" and t.siteId = :siteId");
+            param.put("siteId", fromSite);
+        }
+
+        if (!StringUtils.isEmpty(name)) {
+            sql.append(" and t1.name like ").append("'%").append(name).append("%'");
+        }
+        if (null != serviceId) {
+            sql.append(" and t1.serviceId = :serviceId");
+            param.put("serviceId", serviceId);
+        }
+        if (null != province) {
+            sql.append(" and t1.province = :province");
+            param.put("province", province);
+        }
+        if (null != city) {
+            sql.append(" and t1.city = :city");
+            param.put("city", city);
+        }
+        if (null != district) {
+            sql.append(" and t1.district = :district");
+            param.put("district", district);
+        }
+
+        sql.append(" and t1.isDel=").append(SystemConstant.DISABLE);
+        sql.append(" group by t1.name,t1.serviceId,t1.address,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes) tt");
+        Page<Map<String, Object>> page = super.findBySqlToPage(sql.toString(), param, pageNo, pageSize);
+        return page;
+    }
+
+
+    public int remove(Long id, int state) {
+        String sql = "update t_poweruser set isDel=? where id=?";
+        return super.update(sql, state, id);
+    }
+
+    public int removeBatch(String[] ids, int state) {
+        int result = 0;
+        String sql = "update t_poweruser set isDel=? where id=?";
+        for (String id : ids) {
+            super.update(sql, state, id);
+            result++;
+        }
+        return result;
+    }
+
+    public int modifyState(Long id, int state) {
+        String sql = "update t_poweruser set state=? where id=?";
+        return super.update(sql, state, id);
+    }
+
+    public int modifyStateBatch(String[] ids, int state) {
+        int result = 0;
+        String sql = "update t_poweruser set state=? where id=?";
+        for (String id : ids) {
+            super.update(sql, state, id);
+            result++;
+        }
+        return result;
+    }
+
+    public Map<String, Object> selectByOrgId(Long orgId) {
+		String sql = "select * from (select t1.name,t1.serviceId,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes,t2.industry1 from t_org_site t ,t_org t1,t_poweruser t2 where t.orgId=t1.id and t1.id = t2.orgId and t1.orgType = 1" +
+				" and t2.orgId=?" +
+				" and t1.isDel=" + SystemConstant.DISABLE +
+				" group by t1.name,t1.serviceId,t2.id,t2.orgId,t2.state,t2.expiredDate,t2.loginTimes,t2.industry1) tt";
+        return super.findBySql(sql, orgId).get(0);
+    }
+
+    public Page<Map<String, Object>> selectListByParkId(Long parkId, Integer province, Integer city, Integer district,
+                                                        int pageNo, int pageSize) {
+        StringBuffer sql = new StringBuffer();
+        sql.append("select t.id,t.orgId,t.state,t1.name,t1.address,t.parkId from t_poweruser t,t_org t1 where t.orgId=t1.id and t1.isDel=0");
+        if (null != parkId) {
+            sql.append(" and t.parkId=").append(parkId);
+        } else {
+            sql.append(" and t.parkId is null");
+        }
+
+        if (null != province) {
+            sql.append(" and t1.province=").append(province);
+        }
+        if (null != city) {
+            sql.append(" and t1.city=").append(city);
+        }
+        if (null != district) {
+            sql.append(" and t1.district=").append(district);
+        }
+        ModelMap param = new ModelMap();
+        Page<Map<String, Object>> page = super.findBySqlToPage(sql.toString(), param, pageNo, pageSize);
+        return page;
+    }
+
+    public int modifyParkIdBatch(String[] ids, Long parkId) {
+        int result = 0;
+        String sql = "update t_poweruser set parkId=? where id=?";
+        for (String id : ids) {
+            super.update(sql, parkId, id);
+            result++;
+        }
+        return result;
+    }
 }