Эх сурвалжийг харах

104协议发送电度总召唤+大屏接口完善

hfxc226 2 жил өмнө
parent
commit
453d0f84ed

+ 1 - 1
platform-iec/src/main/java/com/platform/iec/IecApplication.java

@@ -35,7 +35,7 @@ public class IecApplication implements CommandLineRunner {
         log.info("启动主服务,监听iec……………………………………");
         Iec104Config iec104Config  = new Iec104Config();
         iec104Config.setFrameAmountMax((short) 1);
-        iec104Config.setTerminnalAddress((short) 2);
+        iec104Config.setTerminnalAddress((short) 1);
         Iec104MasterFactory.createTcpClientMaster(Iec104Util.host, Iec104Util.port).setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
         Thread.sleep(1000000);
     }

+ 1 - 1
platform-iec/src/main/java/com/platform/iec/master/MasterSysDataHandler.java

@@ -50,7 +50,7 @@ public class MasterSysDataHandler implements DataHandler {
 		log.info("判断是否有限定词:" + ruleDetail104.getQualifiersType());
 		log.info("判断是否有时标:" + ruleDetail104.isTimeScaleExit());
 		log.info("判断消息是否连续:" + ruleDetail104.isContinuous());*/
-		log.info(JSON.toJSONString(ruleDetail104));
+		// log.info(JSON.toJSONString(ruleDetail104));
 		if(ruleDetail104.getMeasgLength()>0){
 			MySqlUtil.dealMessage(ruleDetail104);
 		}

+ 12 - 6
platform-iec/src/main/java/com/ydl/iec/iec104/common/BasicInstruction104.java

@@ -26,7 +26,7 @@ public class BasicInstruction104 {
 	public static final byte[] STARTDT_YES = new byte[] {0x68, 0x04, 0x0B, 0x00, 0x00, 0x00};
 	
 	/**
-	 * 链路启动指令
+	 * 链路启动指令 发送→激活传输启动
 	 */
 	public static final byte[] STARTDT = new byte[] {0x68, 0x04, 0x07, 0x00, 0x00, 0x00};
 	
@@ -46,11 +46,17 @@ public class BasicInstruction104 {
 	 * 停止确认
 	 */
 	public static final byte[] STOPDT_YES = new byte[] {0x68, 0x04, 0x23, 0x00, 0x00, 0x00};
-	
-	
-	
-	
-	
+
+	/**
+	 * 发送总召唤
+	 */
+	public static final byte[] CALL_ALL = new byte[] {0x68, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x64, 0x01, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x14};
+
+	/**
+	 * 发送电度总召唤
+	 */
+	public static final byte[] CALL_ALL_DEGREE = new byte[] {0x68, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x65, 0x01, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x45};
+
 	/**
 	 * 
 	* @Title: getGeneralCallRuleDetail104  

+ 0 - 2
platform-iec/src/main/java/com/ydl/iec/iec104/config/Iec104Config.java

@@ -12,8 +12,6 @@ public class Iec104Config {
      * 接收到帧的数量到该值就要发一个确认帧
      */
     private short frameAmountMax;
-
-
     /**
      * 终端地址
      */

+ 4 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/core/Decoder104.java

@@ -1,11 +1,13 @@
 package com.ydl.iec.iec104.core;
 
+import com.alibaba.fastjson.JSON;
 import com.ydl.iec.util.Iec104Util;
 import com.ydl.iec.iec104.message.MessageDetail;
 import com.ydl.iec.iec104.message.MessageInfo;
 import com.ydl.iec.iec104.enums.QualifiersEnum;
 import com.ydl.iec.iec104.enums.TypeIdentifierEnum;
 import com.ydl.iec.util.ByteUtil;
+import lombok.extern.slf4j.Slf4j;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -17,6 +19,7 @@ import java.util.List;
 * @author YDL 
 * @date 2020年5月13日
  */
+@Slf4j
 public class Decoder104 {
 
 	/**
@@ -217,6 +220,7 @@ public class Decoder104 {
 	 * 根据类型标识返回消息长度
 	 */
 	private static int getMessageLength(MessageDetail ruleDetail104) {
+		log.info(JSON.toJSONString(ruleDetail104));
 		return ruleDetail104.getTypeIdentifier().getMessageLength();
 //		int messageLength = 0;
 //		switch (ruleDetail104.getTypeIdentifier().getValue()) {

+ 15 - 2
platform-iec/src/main/java/com/ydl/iec/iec104/core/ScheduledTaskPool.java

@@ -1,6 +1,9 @@
 package com.ydl.iec.iec104.core;
 
+import com.alibaba.fastjson.JSON;
 import com.ydl.iec.iec104.common.BasicInstruction104;
+import com.ydl.iec.iec104.message.MessageDetail;
+import com.ydl.iec.util.ByteUtil;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import lombok.extern.slf4j.Slf4j;
@@ -174,9 +177,14 @@ public class ScheduledTaskPool {
 					LOGGER.error("sendTestStatus: " + sendTestStatus);
 					while (sendTestStatus) {
 						try {
-							LOGGER.error("发送总召唤指令");
+							LOGGER.error("发送总召唤指令" );
+							// ctx.channel().writeAndFlush(BasicInstruction104.CALL_ALL);
 							ctx.channel().writeAndFlush(BasicInstruction104.getGeneralCallRuleDetail104());
-							Thread.sleep(1000 * 60 * 15);// 15分钟
+							Thread.sleep(1000 * 60 * 1);// 15分钟
+							//LOGGER.error("发送电度召唤指令," + ByteUtil.byteArrayToHexString(BasicInstruction104.CALL_ALL_DEGREE));
+							LOGGER.error("发送电度召唤指令" );
+							ctx.channel().writeAndFlush(BasicInstruction104.getGeneralCallRuleDetail104Degree());
+							Thread.sleep(1000 * 60 * 1);// 15分钟
 						} catch (Exception e) {
 							e.printStackTrace();
 						}
@@ -187,6 +195,11 @@ public class ScheduledTaskPool {
 		}
 	}
 
+	public static void main(String[] args) {
+		MessageDetail messageDetail = BasicInstruction104.getGeneralCallRuleDetail104();
+		System.out.println(JSON.toJSONString(messageDetail).getBytes());
+	}
+
 	/**
 	 *
 	 * @Title: sendGeneralCall

+ 1 - 1
platform-iec/src/main/java/com/ydl/iec/iec104/server/handler/Check104Handler.java

@@ -28,7 +28,7 @@ public class Check104Handler extends ChannelInboundHandlerAdapter {
 		ByteBuf result = (ByteBuf) msg;
 		byte[] bytes = new byte[result.readableBytes()];
 		result.readBytes(bytes);
-		LOGGER.info("接收到的报文: " + ByteUtil.byteArrayToHexString(bytes));
+		// LOGGER.info("接收到的报文: " + ByteUtil.byteArrayToHexString(bytes));
 		if (bytes.length < Iec104Constant.APCI_LENGTH || bytes[0] != Iec104Constant.HEAD_DATA) {
 			LOGGER.error("报文无效");
 			ReferenceCountUtil.release(result);

+ 1 - 1
platform-iec/src/main/java/com/ydl/iec/iec104/server/handler/DataEncoder.java

@@ -35,7 +35,7 @@ public class DataEncoder extends MessageToByteEncoder<MessageDetail> {
 			}
 			bytes[10] = terminalAddressBytes[0];
 			bytes[11] = terminalAddressBytes[1];
-			log.info(ByteUtil.byteArrayToHexString(bytes));
+			log.info("编码器: " + ByteUtil.byteArrayToHexString(bytes));
 			out.writeBytes(bytes);
 		} catch (Exception e) {
 			log.error("", e);

+ 3 - 3
platform-iec/src/main/java/com/ydl/iec/iec104/server/master/handler/SysUframeClientHandler.java

@@ -69,13 +69,13 @@ public class SysUframeClientHandler extends ChannelInboundHandlerAdapter {
 	private void uInstructionHandler(ChannelHandlerContext ctx, ByteBuf result, UControlEnum uControlEnum) {
 		result.readBytes(new byte[result.readableBytes()]);
 		if (uControlEnum == UControlEnum.TESTFR_YES) {
-			LOGGER.info("收到测试确认指令");
+			//LOGGER.info("收到测试确认指令");
 			Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCall();
-			Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCallDegree();
+			// Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCallDegree();
 		} else if (uControlEnum == UControlEnum.STOPDT_YES) {
 			LOGGER.info("收到停止确认指令");
 		} else if (uControlEnum == UControlEnum.STARTDT_YES) {
-			LOGGER.info("收到启动指令确认指令");
+			//LOGGER.info("收到启动指令确认指令");
 			Iec104ThreadLocal.getScheduledTaskPool().stopSendStatrFrame();
 			Iec104ThreadLocal.getScheduledTaskPool().sendTestFrame();
 		} else {

+ 6 - 6
platform-iec/src/main/java/com/ydl/iec/util/MySqlUtil.java

@@ -68,7 +68,7 @@ public class MySqlUtil {
      * @param ruleDetail104
      */
     public static void dealMessage(MessageDetail ruleDetail104) {
-        log.info("处理数据中……………………");
+        // log.info("处理数据中……………………");
         LocalDateTime time = LocalDateTime.now();
         int year = time.getYear();
         int month = time.getMonthValue();
@@ -84,7 +84,7 @@ public class MySqlUtil {
                 log.info("电度点位:" + messageInfo.getMessageAddress());
                 addMessage.add(messageInfo);
             } else if (messageInfo.getMessageAddress() >= remote_config_measure_min && messageInfo.getMessageAddress() <= remote_config_measure_max) {
-                log.info("遥测点位:" + messageInfo.getMessageAddress());
+                // log.info("遥测点位:" + messageInfo.getMessageAddress());
                 updateMessage.add(messageInfo);
             } else {
                // log.info("数据点位不在采集范围内,不处理" + messageInfo.getMessageAddress());
@@ -119,7 +119,7 @@ public class MySqlUtil {
                         "', update_time='" + DateUtils.dateToString(time, DateUtils.PATTERN_YMD_HMS) +
                         "', info='" + JSON.toJSONString(messageInfo) +
                         "' where position_num = " + messageInfo.getMessageAddress();
-                log.info("updateSql: " + updateSql);
+               // log.info("updateSql: " + updateSql);
                 stmt.addBatch(updateSql);
             }
             // 获取总条数
@@ -128,9 +128,9 @@ public class MySqlUtil {
                 throw new BusinessException("批量更新t_remote_measure失败");
                 // 找不到定位数据,属于新增,则对应新增进入库,但是没有系数也不好处理
             } else {
-                log.info("已更新:" + num.length);
+                // log.info("已更新遥测:" + num.length);
             }
-            stmt.clearBatch();
+           // stmt.clearBatch();
             stmt.close();
             closeConn();
         } catch (SQLException e1) {
@@ -189,7 +189,7 @@ public class MySqlUtil {
             } else {
                 log.info("已新增:" + num.length);
             }
-            ps.clearBatch();
+           // ps.clearBatch();
         } catch (Exception e) {
             e.printStackTrace();
         } finally {

+ 1 - 1
platform-office/src/main/java/com/platform/office/poi/excel/imports/CellValueServer.java

@@ -68,7 +68,7 @@ public class CellValueServer {
             } else {
                 entity.setFormat(DateUtils.PATTERN_YMD);
                 cell.setCellType(Cell.CELL_TYPE_STRING);
-                return getLocalDateData(entity, cell.getStringCellValue());
+                return getLocalDateData(entity, cell.getStringCellValue().trim());
             }
         }
         if (String.class.toString().equals(xclass)) {

+ 2 - 2
platform-office/src/main/java/com/platform/office/poi/util/DateUtils.java

@@ -26,12 +26,12 @@ import java.util.Date;
 @UtilityClass
 public class DateUtils {
     public final static String PATTERN_YMD_HMS = "yyyy-MM-dd HH:mm:ss";
-    public final static String PATTERN_YMD = "yyyy/MM/dd";
+    public final static String PATTERN_YMD = "yyyy/M/d";
     public final static String PATTERN_YMD2 = "yyyy-MM-dd";
     private final static ZoneId ZONE_ID = ZoneId.systemDefault();
 
     public static void main(String[] args) {
-        String ss = "2022/03/05";
+        String ss = "2022/8/3";
         LocalDate localDate = strToLocalDate(ss, PATTERN_YMD);
         System.out.println(localDate.toString());
     }

+ 3 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -29,6 +29,7 @@ import com.platform.dao.dto.workplace.WorkplaceBacklogDTO;
 import com.platform.dao.dto.workplace.WorkplaceBacklogUserDTO;
 import com.platform.dao.entity.check.CheckStandard;
 import com.platform.dao.entity.firm.FirmProducer;
+import com.platform.dao.entity.operate.Article;
 import com.platform.dao.entity.part.PartInfo;
 import com.platform.dao.entity.part.PartType;
 import com.platform.dao.entity.remote.RemoteDegree;
@@ -152,6 +153,8 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
         WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
         weekendCriteria.andIn(SbInfo::getId, ids);
+        SbInfo sbInfo = new SbInfo();
+        //SbInfo.setS(0);
         mapper.deleteByExample(weekend);
         return 1;
     }