|
@@ -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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|