Jelajahi Sumber

完善功率图采集

chenwen 1 tahun lalu
induk
melakukan
89d753c0b2

+ 1 - 1
src/main/java/com/hb/proj/gather/business/GatherMultiTask.java

@@ -30,7 +30,7 @@ public class GatherMultiTask implements Runnable {
 	
 	
 	/**
-	 * 约8s采集完
+	 * 约8s采集完  用时不稳定,有时很慢
 	 */
 	@Override
 	public void run() {

+ 15 - 3
src/main/java/com/hb/proj/gather/business/GatherScheduler.java

@@ -25,26 +25,38 @@ public class GatherScheduler {
 	
 	private final static  Logger logger = LoggerFactory.getLogger(GatherScheduler.class);
 	
+	private static int scheNum=1; //执行次数
+	
+	public static void resetScheNum() {
+		scheNum=1;
+	}
+	
+	public static int getScheNum() {
+		return scheNum;
+	}
+	
 
 	/**
 	 * 单值1分钟执行一次采集
 	 */
 	@Scheduled(fixedRate=60*1000)  //每分钟执行一次
 	public void startSingleGather() {
-		logger.info("单值定时采集启动...");
+		logger.info("定时采集启动...");
 		Iterator<Channel> iterator=ChannelGroupMgr.iterator();
 		Channel channel=null;
 		while(iterator.hasNext()) {
 			channel=iterator.next();
-			GatherTaskExecutor.execute(new GatherSingleTask(channel));
+			GatherTaskExecutor.execute(new GatherTask(channel));
 		}
+		
+		scheNum+=1;
 	}
 	
 	
 	/**
 	 * 多值3分钟执行一次采集,首次延时30s
 	 */
-	@Scheduled(fixedRate = 300 * 1000,initialDelay= 30000)  
+	//@Scheduled(fixedRate = 300 * 1000,initialDelay= 30000)  
 	public void startMultiGather() {
 		logger.info("多值定时采集启动...");
 		Iterator<Channel> iterator=ChannelGroupMgr.iterator();

+ 5 - 0
src/main/java/com/hb/proj/gather/business/GatherTask.java

@@ -27,8 +27,13 @@ public class GatherTask implements Runnable{
 		synchronized(channel) {
 			logger.info("单值采集开始...");
 			singleGahter(alloc);
+			if((GatherScheduler.getScheNum())%5!=0) {  //5次单值进行一次多值
+				return;
+			}
 			logger.info("多值采集开始...");
 			multiGather(alloc,channel);
+			
+			GatherScheduler.resetScheNum();
 		}
 	}
 	

+ 2 - 2
src/main/java/com/hb/proj/gather/protocol/ZLOpdProtCMDEnum.java

@@ -129,9 +129,9 @@ public enum ZLOpdProtCMDEnum {
 			2,
 			new String[]{"chartpower_2"}),
 				
-	//100-50 功率图功率第3部分 01 03 07 e9 00 32
+	//100-50 功率图功率第3部分 01 03 07 9e 00 32
 	DIAGRAM_POWER_3(
-			new byte[] {0x01, 0x03, 0x07, (byte)0xe9, 0x00, 0x32,       0x14, (byte)0x9f},  
+			new byte[] {0x01, 0x03, 0x07, (byte)0x9e, 0x00, 0x32,       (byte)0xa4, (byte)0x85},  
 			0x64,  
 			2,
 			new String[]{"chartpower_3"})

+ 2 - 2
src/main/resources/application-dev.properties

@@ -18,9 +18,9 @@ spring.jackson.time-zone=GMT+8
 
 
 #数据库连接池配置
-spring.datasource.url=jdbc:mysql://127.0.0.1:3306/zl_opd?useOldAliasMetadataBehavior=true
+spring.datasource.url=jdbc:mysql://127.0.0.1:9601/zl_opd?useOldAliasMetadataBehavior=true
 spring.datasource.username=root
-spring.datasource.password=123456
+spring.datasource.password=zlmysql
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.type=com.hb.xframework.dao.util.HikariDataSourceWrap
 spring.datasource.dialect=MySQL