Procházet zdrojové kódy

[功能修复]调整应答包

liuf před 10 měsíci
rodič
revize
9dd78f1355

+ 3 - 3
src/main/java/com/tmzn/devicelinkykc/frameMsg/frameType/BillingModelFrame.java

@@ -129,14 +129,14 @@ public class BillingModelFrame {
      * @param deviceConnectionMsg
      * @param res
      */
-    public void resp(DeviceConnectionMsg deviceConnectionMsg,byte res){
+    public void resp(DeviceConnectionMsg deviceConnectionMsg,byte res,byte[] fromMsgSeq){
         byte[] params = params(deviceConnectionMsg.getDeviceId(),res);
         if(deviceConnectionMsg.getIs18()){
 //            String key = redisCache.getCacheObject(RedisConstant.KEYS+deviceConnectionMsg.getDeviceId());
             String key = redisCache.getCacheMapValue(RedisConstant.YKC_KEY_MAP,deviceConnectionMsg.getDeviceId());
             try {
                 byte[] encrypt = Encrytion.aesEncrypt(params, key.getBytes());
-                byte[] spliceing = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.BILLING_MODEL_SETTING_RESPONSE.getFrameType(), DeviceSendYkc.BILLING_MODEL_SETTING_RESPONSE.getEncryptFlag(), encrypt, encrypt.length, deviceConnectionMsg.getIs18());
+                byte[] spliceing = FrameDataSplicing.spliceing(fromMsgSeq, DeviceSendYkc.BILLING_MODEL_SETTING_RESPONSE.getFrameType(), DeviceSendYkc.BILLING_MODEL_SETTING_RESPONSE.getEncryptFlag(), encrypt, encrypt.length, deviceConnectionMsg.getIs18());
                 deviceConnectionMsg.getOutputStream().write(spliceing);
                 deviceConnectionMsg.getOutputStream().flush();
             } catch (Exception e) {
@@ -147,7 +147,7 @@ public class BillingModelFrame {
         }
 
         try {
-            byte[] spliceing = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.BILLING_MODEL_SETTING_RESPONSE.getFrameType(), 0, params, params.length, deviceConnectionMsg.getIs18());
+            byte[] spliceing = FrameDataSplicing.spliceing(fromMsgSeq, DeviceSendYkc.BILLING_MODEL_SETTING_RESPONSE.getFrameType(), 0, params, params.length, deviceConnectionMsg.getIs18());
             deviceConnectionMsg.getOutputStream().write(spliceing);
             deviceConnectionMsg.getOutputStream().flush();
         } catch (Exception e) {

+ 79 - 0
src/main/java/com/tmzn/devicelinkykc/frameMsg/frameType/OtherFrame.java

@@ -0,0 +1,79 @@
+package com.tmzn.devicelinkykc.frameMsg.frameType;
+
+import com.tmzn.devicelinkykc.constant.RedisConstant;
+import com.tmzn.devicelinkykc.frameMsg.DataConversion;
+import com.tmzn.devicelinkykc.frameMsg.FrameDataSplicing;
+import com.tmzn.devicelinkykc.msgEnum.DeviceSendYkc;
+import com.tmzn.devicelinkykc.redis.RedisCache;
+import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
+import com.tmzn.devicelinkykc.util.CP56Time2a;
+import com.tmzn.devicelinkykc.util.Encrytion;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author xp
+ * @date 2024/3/19
+ * @explain " 不加密 "
+ */
+@Component
+@Slf4j
+public class OtherFrame {
+
+    @Autowired
+    private RedisCache redisCache;
+
+    //工作参数设置
+    public void configSettingSend(DeviceConnectionMsg deviceConnectionMsg,byte[] fromMsgSeq) {
+        log.info("{}工作参数应答",deviceConnectionMsg.getDeviceId());
+        byte[] params = confirmParams(deviceConnectionMsg.getDeviceId(),1);
+        if(deviceConnectionMsg.getIs18()){
+            String key = redisCache.getCacheMapValue(RedisConstant.YKC_KEY_MAP,deviceConnectionMsg.getDeviceId());
+            try {
+                byte[] encrypt = Encrytion.aesEncrypt(params, key.getBytes());
+                byte[] spliceing = FrameDataSplicing.spliceing(fromMsgSeq, DeviceSendYkc.CONFIG_SETTING_RESPONSE.getFrameType(), DeviceSendYkc.CONFIG_SETTING_RESPONSE.getEncryptFlag(), encrypt, encrypt.length, deviceConnectionMsg.getIs18());
+                deviceConnectionMsg.getOutputStream().write(spliceing);
+                deviceConnectionMsg.getOutputStream().flush();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            deviceConnectionMsg.incrementMessageCount();
+            return;
+        }
+
+        try {
+            byte[] spliceing = FrameDataSplicing.spliceing(fromMsgSeq, DeviceSendYkc.CONFIG_SETTING_RESPONSE.getFrameType(), 0, params, params.length, deviceConnectionMsg.getIs18());
+            deviceConnectionMsg.getOutputStream().write(spliceing);
+            deviceConnectionMsg.getOutputStream().flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        deviceConnectionMsg.incrementMessageCount();
+    }
+
+    private byte[] confirmParams(String pileCode,int result){
+
+        byte[] msg = new byte[10];
+        int index=0;
+        //桩号
+        byte[] pile_code = new byte[7];
+        pile_code = DataConversion.bcdToBytes(pileCode, 7);
+        System.arraycopy(pile_code, 0, msg, index, pile_code.length);
+        index+=pile_code.length;
+
+        //启动结果
+        byte[] resltass = new byte[]{(byte) result};
+        System.arraycopy(resltass, 0, msg, index, resltass.length);
+        index++;
+
+
+        return msg;
+    }
+
+
+}

+ 13 - 4
src/main/java/com/tmzn/devicelinkykc/message/YkcMsgHandle.java

@@ -81,6 +81,9 @@ public class YkcMsgHandle {
     @Autowired
     private TransactionFlowPushFrame transactionFlowPushFrame;
 
+    @Autowired
+    private OtherFrame otherFrame;
+
     @Autowired
     private TransOrderService transOrderService;
     @Autowired
@@ -230,20 +233,26 @@ public class YkcMsgHandle {
                     try {
                         //有异常就是失败
                         billingModelFrame.setSgBillingModel(deviceConnectionMsg, respone_msg);
-                        billingModelFrame.resp(deviceConnectionMsg, (byte) 1);
+                        billingModelFrame.resp(deviceConnectionMsg, (byte) 1,fromMsgSeq);
                     } catch (Exception e) {
-                        billingModelFrame.resp(deviceConnectionMsg, (byte) 0);
+                        billingModelFrame.resp(deviceConnectionMsg, (byte) 0,fromMsgSeq);
                         e.printStackTrace();
                     }
 
+                } else if(framType == YkcSendDevice.CONFIG_SETTING.getFrameType()){
+                    logger.info("↓↓↓↓↓{}工作参数设置",deviceConnectionMsg.getDeviceId());
+                    otherFrame.configSettingSend(deviceConnectionMsg,fromMsgSeq);
+
+
+
                 } else if (framType == YkcSendDevice.BILLING_MODEL_SETTING.getFrameType()) {
                     logger.info("↓↓↓↓↓{}计费模型设置",deviceConnectionMsg.getDeviceId());
                     try {
                         //有异常就是失败
                         billingModelFrame.setBillingModel(deviceConnectionMsg, respone_msg);
-                        billingModelFrame.resp(deviceConnectionMsg, (byte) 1);
+                        billingModelFrame.resp(deviceConnectionMsg, (byte) 1,fromMsgSeq);
                     } catch (Exception e) {
-                        billingModelFrame.resp(deviceConnectionMsg, (byte) 0);
+                        billingModelFrame.resp(deviceConnectionMsg, (byte) 0,fromMsgSeq);
                         e.printStackTrace();
                     }
 

+ 5 - 0
src/main/java/com/tmzn/devicelinkykc/msgEnum/DeviceSendYkc.java

@@ -25,9 +25,14 @@ public enum DeviceSendYkc {
     UPLOAD_FILE_UPDATE_RESPONSE(0x93,0x01,"远程更新应答"),
 
 
+    CONFIG_SETTING_RESPONSE(0x51,0x01,"工作参数设置应答"),
+
+
     START_CHARNGING_RESPONSE_16(0x33,0x00,"运营平台远程控制启机回复"),
 
 
+
+
     ;
 
     private int frameType;          //帧类型

+ 4 - 0
src/main/java/com/tmzn/devicelinkykc/msgEnum/YkcSendDevice.java

@@ -13,6 +13,10 @@ public enum YkcSendDevice {
     BILLING_MODEL_RESPONSE(0x0A,0x01,"计费模型请求应答"),
     TRANSACTION_RECORDS_RESPONSE(0x40,0x01,"交易记录确认"),
 
+    CONFIG_SETTING(0x52,0x01,"工作参数设置"),
+
+
+
     DEVICE_STATUS_REQUEST(0x12,0x01,"读取实时监测数据"),
     START_CHARNGING_REQUEST(0xA8,0x01,"运营平台远程控制启机"),
     STOP_CHARNGING_REQUEST(0x36,0x01,"运营平台远程停机"),