|
|
@@ -1,10 +1,15 @@
|
|
|
package com.tmzn.devicelinkykc.frameMsg.frameType;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.tmzn.devicelinkykc.constant.DeviceOnlineStatus;
|
|
|
import com.tmzn.devicelinkykc.constant.RedisConstant;
|
|
|
+import com.tmzn.devicelinkykc.entity.Device;
|
|
|
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.service.DeviceControlerService;
|
|
|
+import com.tmzn.devicelinkykc.service.DeviceService;
|
|
|
import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
|
import com.tmzn.devicelinkykc.util.CP56Time2a;
|
|
|
import com.tmzn.devicelinkykc.util.Encrytion;
|
|
|
@@ -14,6 +19,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
@@ -28,9 +34,31 @@ public class OtherFrame {
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DeviceControlerService deviceControlerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DeviceService deviceService;
|
|
|
+
|
|
|
+
|
|
|
//工作参数设置
|
|
|
- public void configSettingSend(DeviceConnectionMsg deviceConnectionMsg,byte[] fromMsgSeq) {
|
|
|
+ public void configSettingSend(DeviceConnectionMsg deviceConnectionMsg, byte[] responeMsg, byte[] fromMsgSeq) {
|
|
|
log.info("{}工作参数应答",deviceConnectionMsg.getDeviceId());
|
|
|
+
|
|
|
+
|
|
|
+ int pileStatus = responeMsg[7] & 0xFF; //0正常 1禁用
|
|
|
+ int socPercent = responeMsg[8] & 0xff; //桩输出功率百分比 1-100% 最小30% 暂时不设置
|
|
|
+
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", deviceConnectionMsg.getDeviceId());
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+
|
|
|
+ if(device!=null && device.getPileStatus()!=pileStatus){
|
|
|
+ device.setPileStatus(pileStatus);
|
|
|
+ deviceService.updateById(device);
|
|
|
+ log.info("设置桩工作状态禁用");
|
|
|
+ }
|
|
|
+
|
|
|
byte[] params = confirmParams(deviceConnectionMsg.getDeviceId(),1);
|
|
|
if(deviceConnectionMsg.getIs18()){
|
|
|
String key = redisCache.getCacheMapValue(RedisConstant.YKC_KEY_MAP,deviceConnectionMsg.getDeviceId());
|
|
|
@@ -56,6 +84,68 @@ public class OtherFrame {
|
|
|
deviceConnectionMsg.incrementMessageCount();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //远程重启
|
|
|
+ public void remoteRebootSend(DeviceConnectionMsg deviceConnectionMsg,byte[] fromMsgSeq) {
|
|
|
+ log.info("{}远程重启应答",deviceConnectionMsg.getDeviceId());
|
|
|
+
|
|
|
+ deviceControlerService.restart(deviceConnectionMsg.getImei(),deviceConnectionMsg.getImei());
|
|
|
+
|
|
|
+ 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.REMOTE_REBOOT_RESPONSE.getFrameType(), DeviceSendYkc.REMOTE_REBOOT_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.REMOTE_REBOOT_RESPONSE.getFrameType(), 0, params, params.length, deviceConnectionMsg.getIs18());
|
|
|
+ deviceConnectionMsg.getOutputStream().write(spliceing);
|
|
|
+ deviceConnectionMsg.getOutputStream().flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ deviceConnectionMsg.incrementMessageCount();
|
|
|
+ }
|
|
|
+
|
|
|
+ //远程更新
|
|
|
+ public void remoteUpdateSend(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.REMOVE_UPDATE_RESPONSE.getFrameType(), DeviceSendYkc.REMOVE_UPDATE_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.REMOVE_UPDATE_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];
|