#实时消息和参数
This commit is contained in:
@@ -1,22 +1,19 @@
|
|||||||
package com.maibu.core.business;
|
package com.maibu.core.business;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import com.maibu.annotation.Excel;
|
import com.maibu.annotation.Excel;
|
||||||
import com.maibu.constant.CommandConstant;
|
|
||||||
import com.maibu.core.domain.BaseDO;
|
import com.maibu.core.domain.BaseDO;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@TableName(value = "iot_device_run_param", autoResultMap = true)
|
@TableName(value = "iot_device_run_param", autoResultMap = true)
|
||||||
@@ -25,366 +22,440 @@ public class DeviceRunParam extends BaseDO {
|
|||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
// private String deviceId;
|
// private String deviceId;
|
||||||
|
|
||||||
private Long siteId;
|
private Long siteId;
|
||||||
|
|
||||||
private Long orgId;
|
private Long orgId;
|
||||||
|
|
||||||
private Integer runSpeed; //不下发到设备自己用
|
private Integer runSpeed; // 不下发到设备自己用
|
||||||
|
|
||||||
@Excel(name = "设备序列号", cellType = Excel.ColumnType.STRING, prompt = "设备序列号")
|
@Excel(name = "设备序列号", cellType = Excel.ColumnType.STRING, prompt = "设备序列号")
|
||||||
private String deviceId;//设备序列号
|
private String deviceId;// 设备序列号
|
||||||
|
|
||||||
@Excel(name = "产品型号", cellType = Excel.ColumnType.STRING, prompt = "产品型号")
|
@Excel(name = "产品型号", cellType = Excel.ColumnType.STRING, prompt = "产品型号")
|
||||||
private String productModel;//产品型号
|
private String productModel;// 产品型号
|
||||||
|
|
||||||
@Excel(name = "设备类型", cellType = Excel.ColumnType.STRING, prompt = "设备类型")
|
@Excel(name = "设备类型", cellType = Excel.ColumnType.STRING, prompt = "设备类型")
|
||||||
private String deviceType;//设备类型:mower-割草机器人
|
private String deviceType;// 设备类型:mower-割草机器人
|
||||||
|
|
||||||
@Excel(name = "RTK模式", cellType = Excel.ColumnType.STRING, prompt = "RTK模式")
|
@Excel(name = "RTK模式", cellType = Excel.ColumnType.STRING, prompt = "RTK模式")
|
||||||
private String rtkMode;//RTK模式:network-4G网络差分
|
private String rtkMode;// RTK模式:network-4G网络差分
|
||||||
|
|
||||||
@Excel(name = "摄像头数量", cellType = Excel.ColumnType.STRING, prompt = "摄像头数量")
|
@Excel(name = "摄像头数量", cellType = Excel.ColumnType.STRING, prompt = "摄像头数量")
|
||||||
private Integer cameraNum;//摄像头数量
|
private Integer cameraNum;// 摄像头数量
|
||||||
|
|
||||||
@Excel(name = "动力类型", cellType = Excel.ColumnType.STRING, prompt = "动力类型")
|
@Excel(name = "动力类型", cellType = Excel.ColumnType.STRING, prompt = "动力类型")
|
||||||
private String powerType;//动力类型:hybrid-混动
|
private String powerType;// 动力类型:hybrid-混动
|
||||||
|
|
||||||
@Excel(name = "车轮类型", cellType = Excel.ColumnType.STRING, prompt = "车轮类型")
|
@Excel(name = "车轮类型", cellType = Excel.ColumnType.STRING, prompt = "车轮类型")
|
||||||
private String wheelType;//车轮类型:track-履带式
|
private String wheelType;// 车轮类型:track-履带式
|
||||||
|
|
||||||
@Excel(name = "发动机类型", cellType = Excel.ColumnType.STRING, prompt = "发动机类型")
|
@Excel(name = "发动机类型", cellType = Excel.ColumnType.STRING, prompt = "发动机类型")
|
||||||
private String engineType;//发动机类型:honda-本田发动机
|
private String engineType;// 发动机类型:honda-本田发动机
|
||||||
|
|
||||||
@Excel(name = "是否搭载上位机",cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "是否搭载上位机", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Integer hasHost = 1;//是否搭载上位机
|
private Integer hasHost = 1;// 是否搭载上位机
|
||||||
|
|
||||||
@Excel(name = "设备能力列表")
|
@Excel(name = "设备能力列表")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String capabilities;
|
private String capabilities;
|
||||||
|
|
||||||
|
private String factoryCode; // 工厂码
|
||||||
|
|
||||||
|
private String lineNum;// 产线号
|
||||||
|
|
||||||
|
private LocalDate productionDate;// 生产日期
|
||||||
|
|
||||||
|
private String serialNumber;// 流水号
|
||||||
|
|
||||||
|
@Excel(name = "电池类型", cellType = Excel.ColumnType.STRING, prompt = "电池类型")
|
||||||
|
private String batteryType;// 电池类型
|
||||||
|
|
||||||
|
@Excel(name = "行走驱动类型", cellType = Excel.ColumnType.STRING, prompt = "行走驱动类型")
|
||||||
|
private String walkingDriveType;// 行走驱动类型
|
||||||
|
|
||||||
|
@Excel(name = "割刀驱动类型", cellType = Excel.ColumnType.STRING, prompt = "割刀驱动类型")
|
||||||
|
private String cutterDriveType;// 割刀驱动类型
|
||||||
|
|
||||||
|
@Excel(name = "RTK天线数", cellType = Excel.ColumnType.STRING, prompt = "RTK天线数")
|
||||||
|
private String rtkAntennasNum;// RTK天线数
|
||||||
|
|
||||||
|
@Excel(name = "手柄类型", cellType = Excel.ColumnType.STRING, prompt = "手柄类型")
|
||||||
|
private String handleType;// 手柄类型
|
||||||
|
|
||||||
|
@Excel(name = "PCB硬件版本", cellType = Excel.ColumnType.STRING, prompt = "PCB硬件版本")
|
||||||
|
private String pcbVersion;// PCB硬件版本
|
||||||
|
|
||||||
|
@Excel(name = "长宽高", cellType = Excel.ColumnType.STRING, prompt = "长宽高")
|
||||||
|
private String dimensions;// 长宽高
|
||||||
|
|
||||||
|
@Excel(name = "割刀宽度", cellType = Excel.ColumnType.STRING, prompt = "割刀宽度")
|
||||||
|
private String bladeWidth;// 割刀宽度
|
||||||
|
|
||||||
|
@Excel(name = "轮胎尺寸", cellType = Excel.ColumnType.STRING, prompt = "轮胎尺寸")
|
||||||
|
private String tyreSize;// 轮胎尺寸
|
||||||
|
|
||||||
|
@Excel(name = "转速比", cellType = Excel.ColumnType.STRING, prompt = "转速比")
|
||||||
|
private String speedRatio;// 转速比
|
||||||
|
|
||||||
|
@Excel(name = "蜂窝网络通信信息", cellType = Excel.ColumnType.STRING, prompt = "蜂窝网络通信信息")
|
||||||
|
private String cellularInfo;// 蜂窝网络通信信息
|
||||||
|
|
||||||
|
@Excel(name = "wifi名称", cellType = Excel.ColumnType.STRING, prompt = "wifi名称")
|
||||||
|
private String wifiName;// wifi名称
|
||||||
|
|
||||||
|
@Excel(name = "蓝牙广播名", cellType = Excel.ColumnType.STRING, prompt = "蓝牙广播名")
|
||||||
|
private String bluetoothName;// 蓝牙广播名
|
||||||
|
|
||||||
|
@Excel(name = "硬件标识信息", cellType = Excel.ColumnType.STRING, prompt = "硬件标识信息")
|
||||||
|
private String hardwareIdentifiers;// 硬件标识信息
|
||||||
|
|
||||||
|
@Excel(name = "IMU型号", cellType = Excel.ColumnType.STRING, prompt = "IMU型号")
|
||||||
|
private String imuModel;// IMU型号
|
||||||
|
|
||||||
|
@Excel(name = "温湿度传感器", cellType = Excel.ColumnType.STRING, prompt = "温湿度传感器")
|
||||||
|
private String tempHumiditySensor;// 温湿度传感器
|
||||||
|
|
||||||
|
@Excel(name = "气压计在位", cellType = Excel.ColumnType.STRING, prompt = "气压计在位")
|
||||||
|
private String barometerPresent;// 气压计在位
|
||||||
|
|
||||||
|
@Excel(name = "超声波在位", cellType = Excel.ColumnType.STRING, prompt = "超声波在位")
|
||||||
|
private String ultrasonicPresent;// 超声波在位
|
||||||
|
|
||||||
|
@Excel(name = "DAC在位", cellType = Excel.ColumnType.STRING, prompt = "DAC在位")
|
||||||
|
private String dacPresent;// DAC在位
|
||||||
|
|
||||||
|
@Excel(name = "质检员", cellType = Excel.ColumnType.STRING, prompt = "质检员")
|
||||||
|
private String operator;// 质检员
|
||||||
|
|
||||||
|
@Excel(name = "检测报告号", cellType = Excel.ColumnType.STRING, prompt = "检测报告号")
|
||||||
|
private String inspectionNo;// 检测报告号
|
||||||
|
|
||||||
|
@Excel(name = "固件版本", cellType = Excel.ColumnType.STRING, prompt = "固件版本")
|
||||||
|
private String firmwareVersion;// 固件版本
|
||||||
|
|
||||||
|
@Excel(name = "经销商", cellType = Excel.ColumnType.STRING, prompt = "经销商")
|
||||||
|
private String dealer;// DAC在位
|
||||||
|
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private List<String> capabilityList;//设备能力列表:heartbeat-上报心跳/location-上报位置/vehicle_status-上报整机状态/task_control-任务控制/single_point-单点作业/coverage-全覆盖割草作业/path_upload-作业路径上传
|
private List<String> capabilityList;// 设备能力列表:heartbeat-上报心跳/location-上报位置/vehicle_status-上报整机状态/task_control-任务控制/single_point-单点作业/coverage-全覆盖割草作业/path_upload-作业路径上传
|
||||||
|
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// public byte header1;
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// public byte header2;
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// public byte cmd;
|
||||||
|
|
||||||
|
// public byte chipUidSign;// 芯片UID固化标志位
|
||||||
|
// public String chipUid;// 芯片UID
|
||||||
|
|
||||||
|
// public byte[] remoteConfig;// 遥控器通道配置
|
||||||
|
// public int knifeMotorMode;// 割刀电机模式
|
||||||
|
// public int walkMotorMode;// 行走电机模式
|
||||||
|
// public int leftMotorReverse;// 左轮电机方向极性
|
||||||
|
// public int rightMotorReverse;// 右轮电机方向极性
|
||||||
|
// public int swapChannel;// 左右轮通道互换标志位
|
||||||
|
// public int use4G;// 联网标志位
|
||||||
|
|
||||||
|
// public short forwardSpeedLimit;// 前进速度限制
|
||||||
|
// public short turnSpeedLimit;// 转向速度限制
|
||||||
|
|
||||||
|
// public int knifePolarity;// 割刀通道极性
|
||||||
|
// public int fanPolarity;// 风门通道极性
|
||||||
|
// public int throttlePolarity;// 油门通道极性
|
||||||
|
// public int liftProtectTime;// 底盘升降电机保护时间
|
||||||
|
// public int dualRtk;// RTK配置
|
||||||
|
|
||||||
|
// public int knifeChannel;// 割刀通道配置
|
||||||
|
// public int fanChannel;// 风门通道配置
|
||||||
|
|
||||||
|
// public int throttleChannel;// 油门通道配置
|
||||||
|
// public int remoteType;// 遥控器类型
|
||||||
|
// public boolean relayBoard;// 是否搭载继电器板
|
||||||
|
|
||||||
|
// public int liftChannel;// 底盘升通道配置
|
||||||
|
// public int chassisChannel;// 底盘降通道配置
|
||||||
|
|
||||||
|
// public int armChannel;// 抱闸通道配置
|
||||||
|
// public int fuelPumpChannel;// 燃油励磁通道配置
|
||||||
|
|
||||||
|
// public String wifiName;// wifi名称
|
||||||
|
// public String wifiPassword;// wifi密码
|
||||||
|
|
||||||
|
// public int batteryType;// 电池类型
|
||||||
|
// public int driveType;// 行走驱动配置
|
||||||
|
|
||||||
|
// public float gearRatio;// 转速比
|
||||||
|
// public float robotLength;// 机器人长度
|
||||||
|
// public float robotWidth;// 机器人宽度
|
||||||
|
// public float robotHeight;// 机器人高度
|
||||||
|
// public float knifeWidth;// 割刀宽度
|
||||||
|
// public float tyreSize;// 轮胎尺寸
|
||||||
|
// public float leftForwardGain;// 左轮前进增益
|
||||||
|
// public float leftBackwardGain;// 左轮后退增益
|
||||||
|
// public float rightForwardGain;// 右轮前进增益
|
||||||
|
// public float rightBackwardGain;// 右轮后退增益
|
||||||
|
|
||||||
|
// public String firmwareVersion;// 固件版本
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// public int crc16;
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// public byte tail1;
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// public byte tail2;
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// private byte[] originalData;
|
||||||
|
|
||||||
|
// public static byte[] toReadBytes() {
|
||||||
|
// ByteBuffer buffer = ByteBuffer.allocate(7); // 修改为27字节
|
||||||
|
// buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
|
// buffer.put((byte) 0xAB);
|
||||||
|
// buffer.put((byte) 0xAA);
|
||||||
|
|
||||||
|
// buffer.put(CommandConstant.readConfig);
|
||||||
|
|
||||||
|
// buffer.putShort((short) 0);
|
||||||
|
|
||||||
|
// buffer.put((byte) 0xAA);
|
||||||
|
// buffer.put((byte) 0xAB);
|
||||||
|
|
||||||
|
// return buffer.array();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public byte[] toWriteBytes() {
|
||||||
|
// // 如果没有原始数据,使用静态方法重新构建
|
||||||
|
// if (originalData == null || originalData.length < 178) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 克隆原始数据,避免修改原始数据
|
||||||
|
// byte[] result = originalData.clone();
|
||||||
|
// ByteBuffer buffer = ByteBuffer.wrap(result);
|
||||||
|
// buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
|
// // 修改指令为写配置(字节2)
|
||||||
|
// buffer.put(2, CommandConstant.writeConfig);
|
||||||
|
|
||||||
|
// // 修改字节68:遥控器配置
|
||||||
|
// byte remote = 0;
|
||||||
|
// remote |= (getKnifeMotorMode() & 0x03);
|
||||||
|
// remote |= (getWalkMotorMode() & 0x03) << 2;
|
||||||
|
// remote |= (getLeftMotorReverse() & 0x01) << 4;
|
||||||
|
// remote |= (getRightMotorReverse() & 0x01) << 5;
|
||||||
|
// remote |= (getSwapChannel() & 0x01) << 6;
|
||||||
|
// remote |= (getUse4G() & 0x01) << 7;
|
||||||
|
// buffer.put(68, remote);
|
||||||
|
|
||||||
|
// // 修改字节69-72:速度限制
|
||||||
|
// buffer.putShort(69, getForwardSpeedLimit());
|
||||||
|
// buffer.putShort(71, getTurnSpeedLimit());
|
||||||
|
|
||||||
|
// // 修改字节73:通道极性
|
||||||
|
// byte b73 = 0;
|
||||||
|
// b73 |= (getKnifePolarity() & 1);
|
||||||
|
// b73 |= (getFanPolarity() & 1) << 1;
|
||||||
|
// b73 |= (getThrottlePolarity() & 1) << 2;
|
||||||
|
// b73 |= (getLiftProtectTime() & 0x0F) << 3;
|
||||||
|
// b73 |= (getDualRtk() & 1) << 7;
|
||||||
|
// buffer.put(73, b73);
|
||||||
|
|
||||||
|
// // 修改字节74-77:通道配置
|
||||||
|
// byte b74 = 0;
|
||||||
|
// b74 |= (getKnifeChannel() & 0x0F);
|
||||||
|
// b74 |= (getFanChannel() & 0x0F) << 4;
|
||||||
|
// buffer.put(74, b74);
|
||||||
|
|
||||||
|
// byte b75 = 0;
|
||||||
|
// b75 |= (getThrottleChannel() & 0x0F);
|
||||||
|
// b75 |= (getRemoteType() & 0x07) << 4;
|
||||||
|
// if (isRelayBoard())
|
||||||
|
// b75 |= 1 << 7;
|
||||||
|
// buffer.put(75, b75);
|
||||||
|
|
||||||
|
// byte b76 = 0;
|
||||||
|
// b76 |= (getLiftChannel() & 0x0F);
|
||||||
|
// b76 |= (getChassisChannel() & 0x0F) << 4;
|
||||||
|
// buffer.put(76, b76);
|
||||||
|
|
||||||
|
// byte b77 = 0;
|
||||||
|
// b77 |= (getArmChannel() & 0x0F);
|
||||||
|
// b77 |= (getFuelPumpChannel() & 0x0F) << 4;
|
||||||
|
// buffer.put(77, b77);
|
||||||
|
|
||||||
|
// // // 修改字节78-117:WiFi信息
|
||||||
|
// // byte[] wifiNameBytes = new byte[20];
|
||||||
|
// // if (getWifiName() != null) {
|
||||||
|
// // byte[] src = getWifiName().getBytes(StandardCharsets.UTF_8);
|
||||||
|
// // System.arraycopy(src, 0, wifiNameBytes, 0, Math.min(src.length, 20));
|
||||||
|
// // }
|
||||||
|
// // System.arraycopy(wifiNameBytes, 0, result, 78, 20);
|
||||||
|
// //
|
||||||
|
// // byte[] wifiPwdBytes = new byte[20];
|
||||||
|
// // if (getWifiPassword() != null) {
|
||||||
|
// // byte[] src = getWifiPassword().getBytes(StandardCharsets.UTF_8);
|
||||||
|
// // System.arraycopy(src, 0, wifiPwdBytes, 0, Math.min(src.length, 20));
|
||||||
|
// // }
|
||||||
|
// // System.arraycopy(wifiPwdBytes, 0, result, 98, 20);
|
||||||
|
|
||||||
|
// // // 修改字节118:电池和驱动配置
|
||||||
|
// // byte b118 = 0;
|
||||||
|
// // b118 |= (getBatteryType() & 0x03);
|
||||||
|
// // b118 |= (getDriveType() & 0x03) << 2;
|
||||||
|
// // buffer.put(118, b118);
|
||||||
|
|
||||||
|
// // 修改字节119-158:float参数
|
||||||
|
// buffer.putFloat(119, getGearRatio());
|
||||||
|
// buffer.putFloat(123, getRobotLength());
|
||||||
|
// buffer.putFloat(127, getRobotWidth());
|
||||||
|
// buffer.putFloat(131, getRobotHeight());
|
||||||
|
// buffer.putFloat(135, getKnifeWidth());
|
||||||
|
// buffer.putFloat(139, getTyreSize());
|
||||||
|
// buffer.putFloat(143, getLeftForwardGain());
|
||||||
|
// buffer.putFloat(147, getLeftBackwardGain());
|
||||||
|
// buffer.putFloat(151, getRightForwardGain());
|
||||||
|
// buffer.putFloat(155, getRightBackwardGain());
|
||||||
|
|
||||||
|
// // 修改字节159-173:固件版本
|
||||||
|
// // byte[] fwBytes = new byte[15];
|
||||||
|
// // if (getFirmwareVersion() != null) {
|
||||||
|
// // byte[] src = getFirmwareVersion().getBytes(StandardCharsets.UTF_8);
|
||||||
|
// // System.arraycopy(src, 0, fwBytes, 0, Math.min(src.length, 15));
|
||||||
|
// // }
|
||||||
|
// // System.arraycopy(fwBytes, 0, result, 159, 15);
|
||||||
|
|
||||||
|
// // 保留原始的 CRC 和尾部,不强制修改
|
||||||
|
// // 移除以下强制修改:
|
||||||
|
// // buffer.putShort(174, (short) 0);
|
||||||
|
// // buffer.put(176, (byte) 0xAA);
|
||||||
|
// // buffer.put(177, (byte) 0xAB);
|
||||||
|
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static void putFixedString(ByteBuffer buffer, String value, int len) {
|
||||||
|
|
||||||
|
// byte[] bytes = new byte[len];
|
||||||
|
|
||||||
|
// if (value != null) {
|
||||||
|
// byte[] src = value.getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// System.arraycopy(src, 0, bytes, 0, Math.min(src.length, len));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// buffer.put(bytes);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static DeviceRunParam fromBytes(byte[] data) {
|
||||||
|
// // 183
|
||||||
|
// if (data == null || data.length < 178) {
|
||||||
|
// throw new IllegalArgumentException("数据长度不足");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ByteBuffer buffer = ByteBuffer.wrap(data);
|
||||||
|
// buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
|
// DeviceRunParam p = new DeviceRunParam();
|
||||||
|
|
||||||
|
// p.setOriginalData(data);
|
||||||
|
|
||||||
@TableField(exist = false)
|
// p.setHeader1(buffer.get());
|
||||||
public byte header1;
|
// p.setHeader2(buffer.get());
|
||||||
@TableField(exist = false)
|
|
||||||
public byte header2;
|
|
||||||
@TableField(exist = false)
|
|
||||||
public byte cmd;
|
|
||||||
|
|
||||||
|
|
||||||
public byte chipUidSign;//芯片UID固化标志位
|
|
||||||
public String chipUid;//芯片UID
|
|
||||||
|
|
||||||
public byte[] remoteConfig;//遥控器通道配置
|
|
||||||
public int knifeMotorMode;//割刀电机模式
|
|
||||||
public int walkMotorMode;//行走电机模式
|
|
||||||
public int leftMotorReverse;//左轮电机方向极性
|
|
||||||
public int rightMotorReverse;//右轮电机方向极性
|
|
||||||
public int swapChannel;//左右轮通道互换标志位
|
|
||||||
public int use4G;//联网标志位
|
|
||||||
|
|
||||||
public short forwardSpeedLimit;//前进速度限制
|
|
||||||
public short turnSpeedLimit;//转向速度限制
|
|
||||||
|
|
||||||
public int knifePolarity;//割刀通道极性
|
|
||||||
public int fanPolarity;//风门通道极性
|
|
||||||
public int throttlePolarity;//油门通道极性
|
|
||||||
public int liftProtectTime;//底盘升降电机保护时间
|
|
||||||
public int dualRtk;//RTK配置
|
|
||||||
|
|
||||||
|
|
||||||
public int knifeChannel;//割刀通道配置
|
|
||||||
public int fanChannel;//风门通道配置
|
|
||||||
|
|
||||||
public int throttleChannel;//油门通道配置
|
|
||||||
public int remoteType;//遥控器类型
|
|
||||||
public boolean relayBoard;//是否搭载继电器板
|
|
||||||
|
|
||||||
public int liftChannel;//底盘升通道配置
|
|
||||||
public int chassisChannel;//底盘降通道配置
|
|
||||||
|
|
||||||
public int armChannel;//抱闸通道配置
|
|
||||||
public int fuelPumpChannel;//燃油励磁通道配置
|
|
||||||
|
|
||||||
public String wifiName;//wifi名称
|
|
||||||
public String wifiPassword;//wifi密码
|
|
||||||
|
|
||||||
public int batteryType;//电池类型
|
|
||||||
public int driveType;//行走驱动配置
|
|
||||||
|
|
||||||
public float gearRatio;//转速比
|
|
||||||
public float robotLength;//机器人长度
|
|
||||||
public float robotWidth;//机器人宽度
|
|
||||||
public float robotHeight;//机器人高度
|
|
||||||
public float knifeWidth;//割刀宽度
|
|
||||||
public float tyreSize;//轮胎尺寸
|
|
||||||
public float leftForwardGain;//左轮前进增益
|
|
||||||
public float leftBackwardGain;//左轮后退增益
|
|
||||||
public float rightForwardGain;//右轮前进增益
|
|
||||||
public float rightBackwardGain;//右轮后退增益
|
|
||||||
|
|
||||||
public String firmwareVersion;//固件版本
|
|
||||||
@TableField(exist = false)
|
|
||||||
public int crc16;
|
|
||||||
@TableField(exist = false)
|
|
||||||
public byte tail1;
|
|
||||||
@TableField(exist = false)
|
|
||||||
public byte tail2;
|
|
||||||
@TableField(exist = false)
|
|
||||||
private byte[] originalData;
|
|
||||||
|
|
||||||
public static byte[] toReadBytes() {
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(7); // 修改为27字节
|
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
||||||
|
|
||||||
buffer.put((byte) 0xAB);
|
|
||||||
buffer.put((byte) 0xAA);
|
|
||||||
|
|
||||||
buffer.put(CommandConstant.readConfig);
|
|
||||||
|
|
||||||
buffer.putShort((short) 0);
|
|
||||||
|
|
||||||
buffer.put((byte) 0xAA);
|
|
||||||
buffer.put((byte) 0xAB);
|
|
||||||
|
|
||||||
return buffer.array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] toWriteBytes() {
|
|
||||||
// 如果没有原始数据,使用静态方法重新构建
|
|
||||||
if (originalData == null || originalData.length < 178) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 克隆原始数据,避免修改原始数据
|
|
||||||
byte[] result = originalData.clone();
|
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(result);
|
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
||||||
|
|
||||||
// 修改指令为写配置(字节2)
|
|
||||||
buffer.put(2, CommandConstant.writeConfig);
|
|
||||||
|
|
||||||
// 修改字节68:遥控器配置
|
|
||||||
byte remote = 0;
|
|
||||||
remote |= (getKnifeMotorMode() & 0x03);
|
|
||||||
remote |= (getWalkMotorMode() & 0x03) << 2;
|
|
||||||
remote |= (getLeftMotorReverse() & 0x01) << 4;
|
|
||||||
remote |= (getRightMotorReverse() & 0x01) << 5;
|
|
||||||
remote |= (getSwapChannel() & 0x01) << 6;
|
|
||||||
remote |= (getUse4G() & 0x01) << 7;
|
|
||||||
buffer.put(68, remote);
|
|
||||||
|
|
||||||
// 修改字节69-72:速度限制
|
|
||||||
buffer.putShort(69, getForwardSpeedLimit());
|
|
||||||
buffer.putShort(71, getTurnSpeedLimit());
|
|
||||||
|
|
||||||
// 修改字节73:通道极性
|
|
||||||
byte b73 = 0;
|
|
||||||
b73 |= (getKnifePolarity() & 1);
|
|
||||||
b73 |= (getFanPolarity() & 1) << 1;
|
|
||||||
b73 |= (getThrottlePolarity() & 1) << 2;
|
|
||||||
b73 |= (getLiftProtectTime() & 0x0F) << 3;
|
|
||||||
b73 |= (getDualRtk() & 1) << 7;
|
|
||||||
buffer.put(73, b73);
|
|
||||||
|
|
||||||
// 修改字节74-77:通道配置
|
|
||||||
byte b74 = 0;
|
|
||||||
b74 |= (getKnifeChannel() & 0x0F);
|
|
||||||
b74 |= (getFanChannel() & 0x0F) << 4;
|
|
||||||
buffer.put(74, b74);
|
|
||||||
|
|
||||||
byte b75 = 0;
|
|
||||||
b75 |= (getThrottleChannel() & 0x0F);
|
|
||||||
b75 |= (getRemoteType() & 0x07) << 4;
|
|
||||||
if (isRelayBoard()) b75 |= 1 << 7;
|
|
||||||
buffer.put(75, b75);
|
|
||||||
|
|
||||||
byte b76 = 0;
|
|
||||||
b76 |= (getLiftChannel() & 0x0F);
|
|
||||||
b76 |= (getChassisChannel() & 0x0F) << 4;
|
|
||||||
buffer.put(76, b76);
|
|
||||||
|
|
||||||
byte b77 = 0;
|
|
||||||
b77 |= (getArmChannel() & 0x0F);
|
|
||||||
b77 |= (getFuelPumpChannel() & 0x0F) << 4;
|
|
||||||
buffer.put(77, b77);
|
|
||||||
|
|
||||||
// // 修改字节78-117:WiFi信息
|
|
||||||
// byte[] wifiNameBytes = new byte[20];
|
|
||||||
// if (getWifiName() != null) {
|
|
||||||
// byte[] src = getWifiName().getBytes(StandardCharsets.UTF_8);
|
|
||||||
// System.arraycopy(src, 0, wifiNameBytes, 0, Math.min(src.length, 20));
|
|
||||||
// }
|
|
||||||
// System.arraycopy(wifiNameBytes, 0, result, 78, 20);
|
|
||||||
//
|
|
||||||
// byte[] wifiPwdBytes = new byte[20];
|
|
||||||
// if (getWifiPassword() != null) {
|
|
||||||
// byte[] src = getWifiPassword().getBytes(StandardCharsets.UTF_8);
|
|
||||||
// System.arraycopy(src, 0, wifiPwdBytes, 0, Math.min(src.length, 20));
|
|
||||||
// }
|
|
||||||
// System.arraycopy(wifiPwdBytes, 0, result, 98, 20);
|
|
||||||
|
|
||||||
// // 修改字节118:电池和驱动配置
|
|
||||||
// byte b118 = 0;
|
|
||||||
// b118 |= (getBatteryType() & 0x03);
|
|
||||||
// b118 |= (getDriveType() & 0x03) << 2;
|
|
||||||
// buffer.put(118, b118);
|
|
||||||
|
|
||||||
// 修改字节119-158:float参数
|
|
||||||
buffer.putFloat(119, getGearRatio());
|
|
||||||
buffer.putFloat(123, getRobotLength());
|
|
||||||
buffer.putFloat(127, getRobotWidth());
|
|
||||||
buffer.putFloat(131, getRobotHeight());
|
|
||||||
buffer.putFloat(135, getKnifeWidth());
|
|
||||||
buffer.putFloat(139, getTyreSize());
|
|
||||||
buffer.putFloat(143, getLeftForwardGain());
|
|
||||||
buffer.putFloat(147, getLeftBackwardGain());
|
|
||||||
buffer.putFloat(151, getRightForwardGain());
|
|
||||||
buffer.putFloat(155, getRightBackwardGain());
|
|
||||||
|
|
||||||
// 修改字节159-173:固件版本
|
|
||||||
// byte[] fwBytes = new byte[15];
|
|
||||||
// if (getFirmwareVersion() != null) {
|
|
||||||
// byte[] src = getFirmwareVersion().getBytes(StandardCharsets.UTF_8);
|
|
||||||
// System.arraycopy(src, 0, fwBytes, 0, Math.min(src.length, 15));
|
|
||||||
// }
|
|
||||||
// System.arraycopy(fwBytes, 0, result, 159, 15);
|
|
||||||
|
|
||||||
// 保留原始的 CRC 和尾部,不强制修改
|
|
||||||
// 移除以下强制修改:
|
|
||||||
// buffer.putShort(174, (short) 0);
|
|
||||||
// buffer.put(176, (byte) 0xAA);
|
|
||||||
// buffer.put(177, (byte) 0xAB);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void putFixedString(ByteBuffer buffer, String value, int len) {
|
|
||||||
|
|
||||||
byte[] bytes = new byte[len];
|
|
||||||
|
|
||||||
if (value != null) {
|
|
||||||
byte[] src = value.getBytes(StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
System.arraycopy(src, 0, bytes, 0, Math.min(src.length, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.put(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// p.setCmd(buffer.get());
|
||||||
|
|
||||||
public static DeviceRunParam fromBytes(byte[] data) {
|
// p.setChipUidSign(buffer.get());
|
||||||
// 183
|
|
||||||
if (data == null || data.length < 178) {
|
|
||||||
throw new IllegalArgumentException("数据长度不足");
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(data);
|
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
||||||
|
|
||||||
DeviceRunParam p = new DeviceRunParam();
|
// p.setChipUid(readString(buffer, 45));
|
||||||
|
|
||||||
p.setOriginalData(data);
|
// // 跳过字节49-67(共19字节,预留不用)
|
||||||
|
// buffer.position(buffer.position() + 19);
|
||||||
|
|
||||||
p.setHeader1(buffer.get());
|
// byte remote = buffer.get();
|
||||||
p.setHeader2(buffer.get());
|
|
||||||
|
|
||||||
p.setCmd(buffer.get());
|
// // p.setRemoteConfig(remote);
|
||||||
|
|
||||||
p.setChipUidSign(buffer.get());
|
// p.setKnifeMotorMode(remote & 0x03);
|
||||||
|
// p.setWalkMotorMode((remote >> 2) & 0x03);
|
||||||
|
// p.setLeftMotorReverse((remote >> 4) & 0x01);
|
||||||
|
// p.setRightMotorReverse((remote >> 5) & 0x01);
|
||||||
|
// p.setSwapChannel((remote >> 6) & 0x01);
|
||||||
|
// p.setUse4G((remote >> 7) & 0x01);
|
||||||
|
|
||||||
p.setChipUid(readString(buffer, 45));
|
// p.setForwardSpeedLimit(buffer.getShort());
|
||||||
|
// p.setTurnSpeedLimit(buffer.getShort());
|
||||||
|
|
||||||
// 跳过字节49-67(共19字节,预留不用)
|
// byte b73 = buffer.get();
|
||||||
buffer.position(buffer.position() + 19);
|
|
||||||
|
|
||||||
byte remote = buffer.get();
|
// p.setKnifePolarity(b73 & 1);
|
||||||
|
// p.setFanPolarity((b73 >> 1) & 1);
|
||||||
|
// p.setThrottlePolarity((b73 >> 2) & 1);
|
||||||
|
// p.setLiftProtectTime((b73 >> 3) & 0x0F);
|
||||||
|
// p.setDualRtk((b73 >> 7) & 1);
|
||||||
|
|
||||||
// p.setRemoteConfig(remote);
|
// byte b74 = buffer.get();
|
||||||
|
|
||||||
p.setKnifeMotorMode(remote & 0x03);
|
// p.setKnifeChannel(b74 & 0x0F);
|
||||||
p.setWalkMotorMode((remote >> 2) & 0x03);
|
// p.setFanChannel((b74 >> 4) & 0x0F);
|
||||||
p.setLeftMotorReverse((remote >> 4) & 0x01);
|
|
||||||
p.setRightMotorReverse((remote >> 5) & 0x01);
|
|
||||||
p.setSwapChannel((remote >> 6) & 0x01);
|
|
||||||
p.setUse4G((remote >> 7) & 0x01);
|
|
||||||
|
|
||||||
p.setForwardSpeedLimit(buffer.getShort());
|
// byte b75 = buffer.get();
|
||||||
p.setTurnSpeedLimit(buffer.getShort());
|
|
||||||
|
|
||||||
byte b73 = buffer.get();
|
// p.setThrottleChannel(b75 & 0x0F);
|
||||||
|
// p.setRemoteType((b75 >> 4) & 0x07);
|
||||||
|
// p.setRelayBoard(((b75 >> 7) & 1) == 1);
|
||||||
|
|
||||||
p.setKnifePolarity(b73 & 1);
|
// byte b76 = buffer.get();
|
||||||
p.setFanPolarity((b73 >> 1) & 1);
|
|
||||||
p.setThrottlePolarity((b73 >> 2) & 1);
|
|
||||||
p.setLiftProtectTime((b73 >> 3) & 0x0F);
|
|
||||||
p.setDualRtk((b73 >> 7) & 1);
|
|
||||||
|
|
||||||
byte b74 = buffer.get();
|
// p.setLiftChannel(b76 & 0x0F);
|
||||||
|
// p.setChassisChannel((b76 >> 4) & 0x0F);
|
||||||
|
|
||||||
p.setKnifeChannel(b74 & 0x0F);
|
// byte b77 = buffer.get();
|
||||||
p.setFanChannel((b74 >> 4) & 0x0F);
|
|
||||||
|
|
||||||
byte b75 = buffer.get();
|
// p.setArmChannel(b77 & 0x0F);
|
||||||
|
// p.setFuelPumpChannel((b77 >> 4) & 0x0F);
|
||||||
|
|
||||||
p.setThrottleChannel(b75 & 0x0F);
|
// p.setWifiName(readString(buffer, 20));
|
||||||
p.setRemoteType((b75 >> 4) & 0x07);
|
// p.setWifiPassword(readString(buffer, 20));
|
||||||
p.setRelayBoard(((b75 >> 7) & 1) == 1);
|
|
||||||
|
|
||||||
byte b76 = buffer.get();
|
// byte b118 = buffer.get();
|
||||||
|
|
||||||
p.setLiftChannel(b76 & 0x0F);
|
// p.setBatteryType(b118 & 0x03);
|
||||||
p.setChassisChannel((b76 >> 4) & 0x0F);
|
// p.setDriveType((b118 >> 2) & 0x03);
|
||||||
|
|
||||||
byte b77 = buffer.get();
|
// // float
|
||||||
|
// p.setGearRatio(buffer.getFloat());
|
||||||
|
// p.setRobotLength(buffer.getFloat());
|
||||||
|
// p.setRobotWidth(buffer.getFloat());
|
||||||
|
// p.setRobotHeight(buffer.getFloat());
|
||||||
|
// p.setKnifeWidth(buffer.getFloat());
|
||||||
|
// p.setTyreSize(buffer.getFloat());
|
||||||
|
// p.setLeftForwardGain(buffer.getFloat());
|
||||||
|
// p.setLeftBackwardGain(buffer.getFloat());
|
||||||
|
// p.setRightForwardGain(buffer.getFloat());
|
||||||
|
// p.setRightBackwardGain(buffer.getFloat());
|
||||||
|
|
||||||
p.setArmChannel(b77 & 0x0F);
|
// p.setFirmwareVersion(readString(buffer, 15));
|
||||||
p.setFuelPumpChannel((b77 >> 4) & 0x0F);
|
|
||||||
|
|
||||||
p.setWifiName(readString(buffer, 20));
|
// p.setCrc16(Short.toUnsignedInt(buffer.getShort()));
|
||||||
p.setWifiPassword(readString(buffer, 20));
|
|
||||||
|
|
||||||
byte b118 = buffer.get();
|
// p.setTail1(buffer.get());
|
||||||
|
// p.setTail2(buffer.get());
|
||||||
|
|
||||||
p.setBatteryType(b118 & 0x03);
|
// return p;
|
||||||
p.setDriveType((b118 >> 2) & 0x03);
|
// }
|
||||||
|
|
||||||
// float
|
// public static String readString(ByteBuffer buffer, int len) {
|
||||||
p.setGearRatio(buffer.getFloat());
|
// byte[] bytes = new byte[len];
|
||||||
p.setRobotLength(buffer.getFloat());
|
// buffer.get(bytes);
|
||||||
p.setRobotWidth(buffer.getFloat());
|
|
||||||
p.setRobotHeight(buffer.getFloat());
|
|
||||||
p.setKnifeWidth(buffer.getFloat());
|
|
||||||
p.setTyreSize(buffer.getFloat());
|
|
||||||
p.setLeftForwardGain(buffer.getFloat());
|
|
||||||
p.setLeftBackwardGain(buffer.getFloat());
|
|
||||||
p.setRightForwardGain(buffer.getFloat());
|
|
||||||
p.setRightBackwardGain(buffer.getFloat());
|
|
||||||
|
|
||||||
p.setFirmwareVersion(readString(buffer, 15));
|
// int end = 0;
|
||||||
|
// while (end < bytes.length && bytes[end] != 0) {
|
||||||
|
// end++;
|
||||||
|
// }
|
||||||
|
|
||||||
p.setCrc16(Short.toUnsignedInt(buffer.getShort()));
|
// return new String(bytes, 0, end, StandardCharsets.UTF_8);
|
||||||
|
// }
|
||||||
p.setTail1(buffer.get());
|
|
||||||
p.setTail2(buffer.get());
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String readString(ByteBuffer buffer, int len) {
|
|
||||||
byte[] bytes = new byte[len];
|
|
||||||
buffer.get(bytes);
|
|
||||||
|
|
||||||
int end = 0;
|
|
||||||
while (end < bytes.length && bytes[end] != 0) {
|
|
||||||
end++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new String(bytes, 0, end, StandardCharsets.UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,24 +246,24 @@ public class NettyDevice extends Connector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readConfigCommand() {
|
// public void readConfigCommand() {
|
||||||
byte[] bytes = DeviceRunParam.toReadBytes();
|
// byte[] bytes = DeviceRunParam.toReadBytes();
|
||||||
log.debug("下发读取配置的报文:{}", toHexString(bytes));
|
// log.debug("下发读取配置的报文:{}", toHexString(bytes));
|
||||||
if (this.getChannel() != null && this.getChannel().isActive()) {
|
// if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||||
this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
// this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||||
}
|
// }
|
||||||
log.debug("下发读取配置的报文完成:{}", toHexString(bytes));
|
// log.debug("下发读取配置的报文完成:{}", toHexString(bytes));
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void writeConfigCommand(DeviceRunParam deviceRunParam) {
|
// public void writeConfigCommand(DeviceRunParam deviceRunParam) {
|
||||||
log.debug("下发修改配置的属性:{}", JsonUtils.toJsonString(deviceRunParam));
|
// log.debug("下发修改配置的属性:{}", JsonUtils.toJsonString(deviceRunParam));
|
||||||
byte[] bytes = deviceRunParam.toWriteBytes();
|
// byte[] bytes = deviceRunParam.toWriteBytes();
|
||||||
log.debug("下发修改配置的报文:{}", toHexString(bytes));
|
// log.debug("下发修改配置的报文:{}", toHexString(bytes));
|
||||||
if (this.getChannel() != null && this.getChannel().isActive()) {
|
// if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||||
this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
// this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||||
}
|
// }
|
||||||
log.debug("下发修改配置的报文完成:{}", toHexString(bytes));
|
// log.debug("下发修改配置的报文完成:{}", toHexString(bytes));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// todo 优化
|
// todo 优化
|
||||||
public synchronized boolean pauseTask() {
|
public synchronized boolean pauseTask() {
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ParamDetail {
|
public class ParamDetail {
|
||||||
private short left_wheel_rpm; // 左轮转速
|
// private short left_wheel_rpm; // 左轮转速
|
||||||
private short right_wheel_rpm; // 右轮转速
|
// private short right_wheel_rpm; // 右轮转速
|
||||||
|
|
||||||
private double linear_speed; // 线速度
|
private double linear_x; // 线速度
|
||||||
private double angular_speed; // 角速度
|
private double angular_z; // 角速度
|
||||||
|
|
||||||
private int chassis_lift; // 底盘升降 0:停止 1:升 2:降
|
private int chassis_lift; // 底盘升降 0:停止 1:升 2:降
|
||||||
private int cutter; // 割刀加减速 0:停止 1:加速 2:减速
|
private int cutter; // 割刀加减速 0:停止 1:加速 2:减速
|
||||||
|
|||||||
@@ -31,4 +31,7 @@ public class VehicleMessage {
|
|||||||
private double roll;// 实时翻滚角度
|
private double roll;// 实时翻滚角度
|
||||||
private String control_mode;// 遥控器拨杆对应的当前控制模式
|
private String control_mode;// 遥控器拨杆对应的当前控制模式
|
||||||
|
|
||||||
|
private double linear_speed; // 实时线速度
|
||||||
|
private double angular_speed; // 实时角速度
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,6 +399,18 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
control_mode.setUnit("");
|
control_mode.setUnit("");
|
||||||
transferData.add(control_mode);
|
transferData.add(control_mode);
|
||||||
|
|
||||||
|
DeviceStatusDetail linear_speed = new DeviceStatusDetail();
|
||||||
|
linear_speed.setName("linear_speed");
|
||||||
|
linear_speed.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLinear_speed()));
|
||||||
|
linear_speed.setUnit("");
|
||||||
|
transferData.add(linear_speed);
|
||||||
|
|
||||||
|
DeviceStatusDetail angular_speed = new DeviceStatusDetail();
|
||||||
|
angular_speed.setName("angular_speed");
|
||||||
|
angular_speed.setValue(String.valueOf(vehicleRelTimeDTO.getData().getAngular_speed()));
|
||||||
|
angular_speed.setUnit("");
|
||||||
|
transferData.add(angular_speed);
|
||||||
|
|
||||||
webStatusMessageDTO.setData(transferData);
|
webStatusMessageDTO.setData(transferData);
|
||||||
webStatusMessageDTO.setType(MesType.deviceInfo);
|
webStatusMessageDTO.setType(MesType.deviceInfo);
|
||||||
return webStatusMessageDTO;
|
return webStatusMessageDTO;
|
||||||
@@ -447,7 +459,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// todo 推送实时位置和状态消息到外部
|
// todo 推送实时位置和状态消息到外部
|
||||||
try {
|
try {
|
||||||
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
||||||
String.format(MqttTopic.DEVICE_VEHICLE_MESSAGE_TOPIC, deviceId),
|
String.format(MqttTopic.DEVICE_VEHICLE_MESSAGE_TOPIC, deviceId),
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class CommandForwardHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
}
|
}
|
||||||
for (Connector target : connectedDevices) {
|
for (Connector target : connectedDevices) {
|
||||||
|
|
||||||
if (!target.canReceive()) {
|
if (target == null || !target.canReceive()) {
|
||||||
logger.debug("发送拒绝master:{},消息到达的slave设备:{},处于禁止接收状态", senderDeviceId, target.getConnectorId());
|
logger.debug("发送拒绝master:{},消息到达的slave设备:{},处于禁止接收状态", senderDeviceId, target.getConnectorId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -110,8 +110,8 @@ public class CommandForwardHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
.setScale(2, RoundingMode.HALF_UP)
|
.setScale(2, RoundingMode.HALF_UP)
|
||||||
.doubleValue();
|
.doubleValue();
|
||||||
|
|
||||||
data.setLinear_speed(linearSpeed);
|
data.setLinear_x(linearSpeed);
|
||||||
data.setAngular_speed(angularSpeed);
|
data.setAngular_z(angularSpeed);
|
||||||
|
|
||||||
data.setChassis_lift(pEntity.getChassisLiftFlag());
|
data.setChassis_lift(pEntity.getChassisLiftFlag());
|
||||||
data.setCutter(pEntity.getMowerSpeedFlag());
|
data.setCutter(pEntity.getMowerSpeedFlag());
|
||||||
|
|||||||
@@ -140,13 +140,13 @@ public class DataToDataBaseHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
nettyDevice.setLatestStatus(latestStatus);
|
nettyDevice.setLatestStatus(latestStatus);
|
||||||
}
|
}
|
||||||
} else if (bytes[2] == CommandConstant.readConfig) {
|
} else if (bytes[2] == CommandConstant.readConfig) {
|
||||||
DeviceRunParam runParam = DeviceRunParam.fromBytes(bytes);
|
// DeviceRunParam runParam = DeviceRunParam.fromBytes(bytes);
|
||||||
logger.debug("收到返回的设备运行参数: {}", JsonUtils.toJsonString(runParam));
|
// logger.debug("收到返回的设备运行参数: {}", JsonUtils.toJsonString(runParam));
|
||||||
CompletableFuture<DeviceRunParam> future = ctx.channel().attr(Constant.READ_CONFIG_KEY).get();
|
// CompletableFuture<DeviceRunParam> future = ctx.channel().attr(Constant.READ_CONFIG_KEY).get();
|
||||||
if (future != null) {
|
// if (future != null) {
|
||||||
future.complete(runParam);
|
// future.complete(runParam);
|
||||||
ctx.channel().attr(Constant.READ_CONFIG_KEY).set(null);
|
// ctx.channel().attr(Constant.READ_CONFIG_KEY).set(null);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
ctx.fireChannelRead(msg);
|
ctx.fireChannelRead(msg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -75,20 +75,20 @@ public class ScheduledTask {
|
|||||||
System.out.println("0点定时刷新状态执行完成");
|
System.out.println("0点定时刷新状态执行完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws DecoderException {
|
// public static void main(String[] args) throws DecoderException {
|
||||||
String hex = "AB AA 05 88 4D 43 37 30 30 50 4C 55 53 2D 43 4E 2D 4A 53 2D 31 37 38 34 38 37 31 39 37 39 31 39 30 2D 30 30 30 30 30 30 30 41 2D 36 30 00 B1 FB 7F FE FE FE 00 00 00 00 00 00 00 00 00 00 00 00 00 12 01 48 95 E8 03 E8 03 28 32 91 53 24 4D 43 37 30 30 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 31 32 33 34 35 36 37 38 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 CD CC A4 41 00 00 80 3F 33 33 33 3F B8 1E 05 3F 33 33 33 3F 9A 99 19 3E 00 00 80 3F 00 00 80 3F 00 00 80 3F 32 36 2D 34 2D 32 37 00 2D 32 37 00 50 B1 BF 00 00 AA AB";
|
// String hex = "AB AA 05 88 4D 43 37 30 30 50 4C 55 53 2D 43 4E 2D 4A 53 2D 31 37 38 34 38 37 31 39 37 39 31 39 30 2D 30 30 30 30 30 30 30 41 2D 36 30 00 B1 FB 7F FE FE FE 00 00 00 00 00 00 00 00 00 00 00 00 00 12 01 48 95 E8 03 E8 03 28 32 91 53 24 4D 43 37 30 30 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 31 32 33 34 35 36 37 38 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 CD CC A4 41 00 00 80 3F 33 33 33 3F B8 1E 05 3F 33 33 33 3F 9A 99 19 3E 00 00 80 3F 00 00 80 3F 00 00 80 3F 32 36 2D 34 2D 32 37 00 2D 32 37 00 50 B1 BF 00 00 AA AB";
|
||||||
String cleanHex = hex.replaceAll("\\s+", ""); // 移除所有空白字符
|
// String cleanHex = hex.replaceAll("\\s+", ""); // 移除所有空白字符
|
||||||
byte[] bytes = Hex.decodeHex(cleanHex);
|
// byte[] bytes = Hex.decodeHex(cleanHex);
|
||||||
DeviceRunParam runParam = DeviceRunParam.fromBytes(bytes);
|
// DeviceRunParam runParam = DeviceRunParam.fromBytes(bytes);
|
||||||
System.out.println(JsonUtils.toJsonString(runParam));
|
// System.out.println(JsonUtils.toJsonString(runParam));
|
||||||
|
|
||||||
runParam.setLeftBackwardGain(0.2f);
|
// runParam.setLeftBackwardGain(0.2f);
|
||||||
runParam.setLeftForwardGain(0.2f);
|
// runParam.setLeftForwardGain(0.2f);
|
||||||
runParam.setRightForwardGain(0.2f);
|
// runParam.setRightForwardGain(0.2f);
|
||||||
runParam.setRightBackwardGain(0.2f);
|
// runParam.setRightBackwardGain(0.2f);
|
||||||
|
|
||||||
byte[] newB = runParam.toWriteBytes();
|
// byte[] newB = runParam.toWriteBytes();
|
||||||
System.out.println(Hex.encodeHexString(newB));
|
// System.out.println(Hex.encodeHexString(newB));
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -43,12 +43,11 @@ public class TransferDeviceService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DeviceMapper deviceMapper;
|
private DeviceMapper deviceMapper;
|
||||||
|
|
||||||
|
|
||||||
public AjaxResult bind(DeviceBindDTO bindDTO, LoginUser user) {
|
public AjaxResult bind(DeviceBindDTO bindDTO, LoginUser user) {
|
||||||
try {
|
try {
|
||||||
String deviceId = bindDTO.getDeviceId();
|
String deviceId = bindDTO.getDeviceId();
|
||||||
String deviceAlias = bindDTO.getDeviceAlias();
|
String deviceAlias = bindDTO.getDeviceAlias();
|
||||||
//判断当前设备是否存
|
// 判断当前设备是否存
|
||||||
Device device = iDeviceService.selectDeviceBySerialNumber(deviceId);
|
Device device = iDeviceService.selectDeviceBySerialNumber(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return AjaxResult.error("设备不存在");
|
return AjaxResult.error("设备不存在");
|
||||||
@@ -65,7 +64,7 @@ public class TransferDeviceService {
|
|||||||
device.setDeviceAlias(deviceAlias);
|
device.setDeviceAlias(deviceAlias);
|
||||||
device.setActiveTime(new Date());
|
device.setActiveTime(new Date());
|
||||||
iDeviceService.updateDeviceBySelf(device);
|
iDeviceService.updateDeviceBySelf(device);
|
||||||
// deviceMapper.updateById(device);
|
// deviceMapper.updateById(device);
|
||||||
return AjaxResult.success(true);
|
return AjaxResult.success(true);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -77,7 +76,7 @@ public class TransferDeviceService {
|
|||||||
public AjaxResult unbind(DeviceBindDTO bindDTO, LoginUser user) {
|
public AjaxResult unbind(DeviceBindDTO bindDTO, LoginUser user) {
|
||||||
try {
|
try {
|
||||||
String deviceId = bindDTO.getDeviceId();
|
String deviceId = bindDTO.getDeviceId();
|
||||||
//判断当前设备是否存
|
// 判断当前设备是否存
|
||||||
Device device = iDeviceService.selectDeviceBySerialNumber(deviceId);
|
Device device = iDeviceService.selectDeviceBySerialNumber(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return AjaxResult.error("设备不存在");
|
return AjaxResult.error("设备不存在");
|
||||||
@@ -93,9 +92,9 @@ public class TransferDeviceService {
|
|||||||
device.setTenantName("");
|
device.setTenantName("");
|
||||||
device.setUpdateTime(LocalDateTime.now());
|
device.setUpdateTime(LocalDateTime.now());
|
||||||
device.setDeviceAlias("");
|
device.setDeviceAlias("");
|
||||||
// deviceMapper.updateById(device);
|
// deviceMapper.updateById(device);
|
||||||
iDeviceService.updateDeviceBySelf(device);
|
iDeviceService.updateDeviceBySelf(device);
|
||||||
//判断是否正在控制 如果正在控制,删除控制状态
|
// 判断是否正在控制 如果正在控制,删除控制状态
|
||||||
LambdaQueryWrapper<UserClient> lambdaWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserClient> lambdaWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaWrapper.eq(UserClient::getDeviceName, deviceId);
|
lambdaWrapper.eq(UserClient::getDeviceName, deviceId);
|
||||||
List<UserClient> users = userClientMapper.selectList(lambdaWrapper);
|
List<UserClient> users = userClientMapper.selectList(lambdaWrapper);
|
||||||
@@ -108,12 +107,15 @@ public class TransferDeviceService {
|
|||||||
NettyDevice deviceMaster = sessionManager.getDevice(masterId);
|
NettyDevice deviceMaster = sessionManager.getDevice(masterId);
|
||||||
if (deviceMaster != null) {
|
if (deviceMaster != null) {
|
||||||
String oldSlave = userClient.getDeviceName();
|
String oldSlave = userClient.getDeviceName();
|
||||||
//删除主的连接关系
|
// 删除主的连接关系
|
||||||
deviceMaster.getConnectedConnectors().removeIf(x -> x.getConnectorId().equals(oldSlave));
|
deviceMaster.getConnectedConnectors()
|
||||||
//删除从的连接关系
|
.removeIf(x -> x.getConnectorId().equals(oldSlave));
|
||||||
|
// 删除从的连接关系
|
||||||
NettyDevice oldSlaveDevice = sessionManager.getDevice(oldSlave);
|
NettyDevice oldSlaveDevice = sessionManager.getDevice(oldSlave);
|
||||||
if (oldSlaveDevice != null && !CollectionUtils.isEmpty(oldSlaveDevice.getConnectedConnectors())) {
|
if (oldSlaveDevice != null
|
||||||
Set<com.maibu.core.business.device.Connector> connectedDevices = oldSlaveDevice.getConnectedConnectors();
|
&& !CollectionUtils.isEmpty(oldSlaveDevice.getConnectedConnectors())) {
|
||||||
|
Set<com.maibu.core.business.device.Connector> connectedDevices = oldSlaveDevice
|
||||||
|
.getConnectedConnectors();
|
||||||
connectedDevices.removeIf(x -> x.getConnectorId().equals(masterId));
|
connectedDevices.removeIf(x -> x.getConnectorId().equals(masterId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,21 +132,20 @@ public class TransferDeviceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AjaxResult updateDeviceAlias(DeviceBindDTO bindDTO, LoginUser user) {
|
public AjaxResult updateDeviceAlias(DeviceBindDTO bindDTO, LoginUser user) {
|
||||||
try {
|
try {
|
||||||
String deviceId = bindDTO.getDeviceId();
|
String deviceId = bindDTO.getDeviceId();
|
||||||
//判断当前设备是否存
|
// 判断当前设备是否存
|
||||||
Device device = iDeviceService.selectDeviceBySerialNumber(deviceId);
|
Device device = iDeviceService.selectDeviceBySerialNumber(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return AjaxResult.error("设备不存在");
|
return AjaxResult.error("设备不存在");
|
||||||
} else {
|
} else {
|
||||||
// Long tenantId = device.getTenantId();
|
// Long tenantId = device.getTenantId();
|
||||||
// if (tenantId == -1) {
|
// if (tenantId == -1) {
|
||||||
// return AjaxResult.error("设备未绑定");
|
// return AjaxResult.error("设备未绑定");
|
||||||
// }
|
// }
|
||||||
// if (!tenantId.equals(user.getUserId())) {
|
// if (!tenantId.equals(user.getUserId())) {
|
||||||
// return AjaxResult.error("无操作权限");
|
// return AjaxResult.error("无操作权限");
|
||||||
// }
|
// }
|
||||||
device.setDeviceAlias(bindDTO.getDeviceAlias());
|
device.setDeviceAlias(bindDTO.getDeviceAlias());
|
||||||
device.setUpdateTime(LocalDateTime.now());
|
device.setUpdateTime(LocalDateTime.now());
|
||||||
@@ -158,76 +159,76 @@ public class TransferDeviceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public synchronized boolean switchDevice(DeviceBindDTO bindDTO, LoginUser user) {
|
// public synchronized boolean switchDevice(DeviceBindDTO bindDTO, LoginUser
|
||||||
// try {
|
// user) {
|
||||||
// String slaveId = bindDTO.getDeviceId();
|
// try {
|
||||||
// String platform = bindDTO.getPlatform();
|
// String slaveId = bindDTO.getDeviceId();
|
||||||
// String userName = user.getUsername();
|
// String platform = bindDTO.getPlatform();
|
||||||
// String masterId = userName + ":" + platform;
|
// String userName = user.getUsername();
|
||||||
// //todo 判断是否有权限 正在控制才能切
|
// String masterId = userName + ":" + platform;
|
||||||
// //todo 离线没有控制权的怎么切
|
// //todo 判断是否有权限 正在控制才能切
|
||||||
// log.info("switchDevice:{}", masterId);
|
// //todo 离线没有控制权的怎么切
|
||||||
// NettyDevice deviceMaster = sessionManager.getDevice(masterId);
|
// log.info("switchDevice:{}", masterId);
|
||||||
// log.info("deviceMaster:{}", deviceMaster);
|
// NettyDevice deviceMaster = sessionManager.getDevice(masterId);
|
||||||
// if (deviceMaster != null) {
|
// log.info("deviceMaster:{}", deviceMaster);
|
||||||
// log.info("ConnectorStatus:{}", deviceMaster.getConnectorStatus());
|
// if (deviceMaster != null) {
|
||||||
// if (ConnectorStatus.RECEIVER.equals(deviceMaster.getConnectorStatus())) {
|
// log.info("ConnectorStatus:{}", deviceMaster.getConnectorStatus());
|
||||||
// //当前账号没有控制则可以切换为控制?
|
// if (ConnectorStatus.RECEIVER.equals(deviceMaster.getConnectorStatus())) {
|
||||||
// NettyDevice activeDevice = sessionManager.getUserControl(userName);
|
// //当前账号没有控制则可以切换为控制?
|
||||||
// deviceMaster.getConnectedConnectors().clear();
|
// NettyDevice activeDevice = sessionManager.getUserControl(userName);
|
||||||
// if (activeDevice == null) {
|
// deviceMaster.getConnectedConnectors().clear();
|
||||||
// log.info("bindConnector ACTIVE :{}", masterId);
|
// if (activeDevice == null) {
|
||||||
// sessionManager.bindConnector(masterId, slaveId);
|
// log.info("bindConnector ACTIVE :{}", masterId);
|
||||||
// deviceMaster.setConnectorStatus(ConnectorStatus.ACTIVE);
|
// sessionManager.bindConnector(masterId, slaveId);
|
||||||
// deviceMaster.setCurrentSlaveId(slaveId);
|
// deviceMaster.setConnectorStatus(ConnectorStatus.ACTIVE);
|
||||||
// sysUserClientService.updateAliveStatus(masterId, slaveId, 1);
|
// deviceMaster.setCurrentSlaveId(slaveId);
|
||||||
// } else {
|
// sysUserClientService.updateAliveStatus(masterId, slaveId, 1);
|
||||||
// log.info("bindConnector RECEIVER :{}", masterId);
|
// } else {
|
||||||
// sessionManager.bindConnector(masterId, slaveId);
|
// log.info("bindConnector RECEIVER :{}", masterId);
|
||||||
// deviceMaster.setConnectorStatus(ConnectorStatus.RECEIVER);
|
// sessionManager.bindConnector(masterId, slaveId);
|
||||||
// deviceMaster.setCurrentSlaveId(slaveId);
|
// deviceMaster.setConnectorStatus(ConnectorStatus.RECEIVER);
|
||||||
// sysUserClientService.updateAliveStatus(masterId, slaveId, 2);
|
// deviceMaster.setCurrentSlaveId(slaveId);
|
||||||
// }
|
// sysUserClientService.updateAliveStatus(masterId, slaveId, 2);
|
||||||
// } else {
|
// }
|
||||||
// //从关联其他设备切换到 当前禁言 假如有控制且不是当前更新为2
|
// } else {
|
||||||
// List<NettyDevice> controls = sessionManager.getSlaveControl(slaveId);
|
// //从关联其他设备切换到 当前禁言 假如有控制且不是当前更新为2
|
||||||
// if (CollectionUtils.isEmpty(controls)) {
|
// List<NettyDevice> controls = sessionManager.getSlaveControl(slaveId);
|
||||||
// deviceMaster.getConnectedConnectors().clear();
|
// if (CollectionUtils.isEmpty(controls)) {
|
||||||
// log.info("bindConnector 1:{}", masterId);
|
// deviceMaster.getConnectedConnectors().clear();
|
||||||
// sessionManager.bindConnector(masterId, slaveId);
|
// log.info("bindConnector 1:{}", masterId);
|
||||||
// deviceMaster.setConnectorStatus(ConnectorStatus.ACTIVE);
|
// sessionManager.bindConnector(masterId, slaveId);
|
||||||
// deviceMaster.setCurrentSlaveId(slaveId);
|
// deviceMaster.setConnectorStatus(ConnectorStatus.ACTIVE);
|
||||||
// sysUserClientService.updateAliveStatus(masterId, slaveId, 1);
|
// deviceMaster.setCurrentSlaveId(slaveId);
|
||||||
// } else {
|
// sysUserClientService.updateAliveStatus(masterId, slaveId, 1);
|
||||||
// NettyDevice controlDevice = controls.get(0);
|
// } else {
|
||||||
// if (!masterId.equals(controlDevice.getConnectorId())) {
|
// NettyDevice controlDevice = controls.get(0);
|
||||||
// //当前的设备有控制 的主机
|
// if (!masterId.equals(controlDevice.getConnectorId())) {
|
||||||
// deviceMaster.getConnectedConnectors().clear();
|
// //当前的设备有控制 的主机
|
||||||
// log.info("bindConnector RECEIVER 2:{}", masterId);
|
// deviceMaster.getConnectedConnectors().clear();
|
||||||
// sessionManager.bindConnector(masterId, slaveId);
|
// log.info("bindConnector RECEIVER 2:{}", masterId);
|
||||||
// deviceMaster.setConnectorStatus(ConnectorStatus.RECEIVER);
|
// sessionManager.bindConnector(masterId, slaveId);
|
||||||
// deviceMaster.setCurrentSlaveId(slaveId);
|
// deviceMaster.setConnectorStatus(ConnectorStatus.RECEIVER);
|
||||||
// sysUserClientService.updateAliveStatus(masterId, slaveId, 2);
|
// deviceMaster.setCurrentSlaveId(slaveId);
|
||||||
// }
|
// sysUserClientService.updateAliveStatus(masterId, slaveId, 2);
|
||||||
// //当前 切当前不做操作
|
// }
|
||||||
// }
|
// //当前 切当前不做操作
|
||||||
// }
|
// }
|
||||||
// return true;
|
// }
|
||||||
// }
|
// return true;
|
||||||
// } catch (Exception e) {
|
// }
|
||||||
// log.error("切换设备失败: {}", e.getMessage(), e);
|
// } catch (Exception e) {
|
||||||
// }
|
// log.error("切换设备失败: {}", e.getMessage(), e);
|
||||||
// return false;
|
// }
|
||||||
// }
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
public synchronized boolean switchDevice(DeviceBindDTO bindDTO) {
|
public synchronized boolean switchDevice(DeviceBindDTO bindDTO) {
|
||||||
try {
|
try {
|
||||||
String slaveId = bindDTO.getDeviceId();
|
String slaveId = bindDTO.getDeviceId();
|
||||||
// String platform = bindDTO.getPlatform();
|
// String platform = bindDTO.getPlatform();
|
||||||
// String userName = user.getUsername();
|
// String userName = user.getUsername();
|
||||||
|
|
||||||
// String masterId = userName + ":" + platform;
|
|
||||||
|
|
||||||
|
// String masterId = userName + ":" + platform;
|
||||||
|
|
||||||
String token = bindDTO.getToken();
|
String token = bindDTO.getToken();
|
||||||
|
|
||||||
@@ -247,9 +248,10 @@ public class TransferDeviceService {
|
|||||||
sessionManager.lock(slaveId, token);
|
sessionManager.lock(slaveId, token);
|
||||||
log.info("switchDevice bindConnector slaveId:{},token:{}", slaveId, token);
|
log.info("switchDevice bindConnector slaveId:{},token:{}", slaveId, token);
|
||||||
} else {
|
} else {
|
||||||
List<String> connectorIds = controls.stream().map(NettyDevice::getConnectorId).collect(Collectors.toList());
|
List<String> connectorIds = controls.stream().map(NettyDevice::getConnectorId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
if (!connectorIds.contains(token)) {
|
if (!connectorIds.contains(token)) {
|
||||||
//当前的设备有控制 的主机
|
// 当前的设备有控制 的主机
|
||||||
deviceMaster.getConnectedConnectors().clear();
|
deviceMaster.getConnectedConnectors().clear();
|
||||||
sessionManager.bindConnector(token, slaveId);
|
sessionManager.bindConnector(token, slaveId);
|
||||||
deviceMaster.setConnectorStatus(ConnectorStatus.RECEIVER);
|
deviceMaster.setConnectorStatus(ConnectorStatus.RECEIVER);
|
||||||
@@ -260,16 +262,15 @@ public class TransferDeviceService {
|
|||||||
deviceMaster.setCurrentSlaveId(slaveId);
|
deviceMaster.setCurrentSlaveId(slaveId);
|
||||||
sessionManager.lock(slaveId, token);
|
sessionManager.lock(slaveId, token);
|
||||||
}
|
}
|
||||||
//当前 切当前不做操作
|
// 当前 切当前不做操作
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("切换设备失败: {}", e.getMessage(), e);
|
log.error("切换设备失败", e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DeviceControlDTO remoteControl(DeviceBindDTO bindDTO) {
|
public DeviceControlDTO remoteControl(DeviceBindDTO bindDTO) {
|
||||||
try {
|
try {
|
||||||
String token = bindDTO.getToken();
|
String token = bindDTO.getToken();
|
||||||
@@ -290,7 +291,6 @@ public class TransferDeviceService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DeviceSwitchControlDTO switchControl(DeviceBindDTO bindDTO, LoginUser user) {
|
public DeviceSwitchControlDTO switchControl(DeviceBindDTO bindDTO, LoginUser user) {
|
||||||
try {
|
try {
|
||||||
String slaveId = bindDTO.getDeviceId();
|
String slaveId = bindDTO.getDeviceId();
|
||||||
@@ -299,11 +299,11 @@ public class TransferDeviceService {
|
|||||||
String masterId = userName + ":" + platform;
|
String masterId = userName + ":" + platform;
|
||||||
|
|
||||||
DeviceSwitchControlDTO dto = new DeviceSwitchControlDTO();
|
DeviceSwitchControlDTO dto = new DeviceSwitchControlDTO();
|
||||||
//收到明确的切换设备请求了 从哪边切换到另一边
|
// 收到明确的切换设备请求了 从哪边切换到另一边
|
||||||
//判断当前是否有控制的设备
|
// 判断当前是否有控制的设备
|
||||||
NettyDevice masterDevice = sessionManager.getDevice(masterId);
|
NettyDevice masterDevice = sessionManager.getDevice(masterId);
|
||||||
if (masterDevice == null || !masterDevice.getChannel().isActive()) {
|
if (masterDevice == null || !masterDevice.getChannel().isActive()) {
|
||||||
//主机已离线
|
// 主机已离线
|
||||||
dto.setSwitchControl(false);
|
dto.setSwitchControl(false);
|
||||||
dto.setReason("主机已离线");
|
dto.setReason("主机已离线");
|
||||||
return dto;
|
return dto;
|
||||||
@@ -311,8 +311,8 @@ public class TransferDeviceService {
|
|||||||
|
|
||||||
NettyDevice slaveDevice = sessionManager.getDevice(slaveId);
|
NettyDevice slaveDevice = sessionManager.getDevice(slaveId);
|
||||||
if (slaveDevice == null || !masterDevice.getChannel().isActive()) {
|
if (slaveDevice == null || !masterDevice.getChannel().isActive()) {
|
||||||
//从机已离线
|
// 从机已离线
|
||||||
//主机已离线
|
// 主机已离线
|
||||||
dto.setSwitchControl(false);
|
dto.setSwitchControl(false);
|
||||||
dto.setReason("从机已离线");
|
dto.setReason("从机已离线");
|
||||||
return dto;
|
return dto;
|
||||||
@@ -321,7 +321,7 @@ public class TransferDeviceService {
|
|||||||
List<NettyDevice> controlList = sessionManager.getSlaveControl(slaveId);
|
List<NettyDevice> controlList = sessionManager.getSlaveControl(slaveId);
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(controlList)) {
|
if (!CollectionUtils.isEmpty(controlList)) {
|
||||||
//如果当前设备有控制
|
// 如果当前设备有控制
|
||||||
controlList.forEach(c -> {
|
controlList.forEach(c -> {
|
||||||
if (!c.getConnectorId().equals(masterId)) {
|
if (!c.getConnectorId().equals(masterId)) {
|
||||||
c.setCurrentSlaveId(null);
|
c.setCurrentSlaveId(null);
|
||||||
@@ -333,7 +333,8 @@ public class TransferDeviceService {
|
|||||||
}
|
}
|
||||||
masterDevice.setCurrentSlaveId(slaveId);
|
masterDevice.setCurrentSlaveId(slaveId);
|
||||||
masterDevice.setConnectorStatus(ConnectorStatus.ACTIVE);
|
masterDevice.setConnectorStatus(ConnectorStatus.ACTIVE);
|
||||||
// sysUserClientService.updateAliveStatus(masterDevice.getConnectorId(), slaveId, 1);
|
// sysUserClientService.updateAliveStatus(masterDevice.getConnectorId(),
|
||||||
|
// slaveId, 1);
|
||||||
|
|
||||||
dto.setSwitchControl(true);
|
dto.setSwitchControl(true);
|
||||||
dto.setHolder(platform);
|
dto.setHolder(platform);
|
||||||
|
|||||||
@@ -8,13 +8,20 @@ import com.maibu.dto.BaseQueryDTO;
|
|||||||
import com.maibu.service.impl.DeviceRunParamService;
|
import com.maibu.service.impl.DeviceRunParamService;
|
||||||
import com.maibu.utils.poi.ExcelUtil;
|
import com.maibu.utils.poi.ExcelUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/iot/deviceRunParam")
|
@RequestMapping("/iot/deviceRunParam")
|
||||||
public class DeviceRunParamController extends BaseController {
|
public class DeviceRunParamController extends BaseController {
|
||||||
@@ -23,7 +30,7 @@ public class DeviceRunParamController extends BaseController {
|
|||||||
private DeviceRunParamService service;
|
private DeviceRunParamService service;
|
||||||
|
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public AjaxResult save(@RequestBody DeviceRunParam deviceRunParam) throws ExecutionException, InterruptedException, TimeoutException {
|
public AjaxResult save(@RequestBody DeviceRunParam deviceRunParam) {
|
||||||
|
|
||||||
return AjaxResult.success(service.save(deviceRunParam));
|
return AjaxResult.success(service.save(deviceRunParam));
|
||||||
}
|
}
|
||||||
@@ -35,7 +42,8 @@ public class DeviceRunParamController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/selectByDeviceId")
|
@GetMapping("/selectByDeviceId")
|
||||||
public AjaxResult selectByDeviceId(@RequestParam String deviceId) throws ExecutionException, InterruptedException, TimeoutException {
|
public AjaxResult selectByDeviceId(@RequestParam String deviceId)
|
||||||
|
throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
return AjaxResult.success(service.selectByDeviceId(deviceId));
|
return AjaxResult.success(service.selectByDeviceId(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,4 +59,31 @@ public class DeviceRunParamController extends BaseController {
|
|||||||
boolean message = service.importParam(paramList);
|
boolean message = service.importParam(paramList);
|
||||||
return success(message);
|
return success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载机器属性导入模板
|
||||||
|
*/
|
||||||
|
@GetMapping("/downloadTemplate")
|
||||||
|
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||||
|
String fileName = "机器属性导入模板.xlsx";
|
||||||
|
|
||||||
|
try (InputStream inputStream = new ClassPathResource("机器属性导入模板.xlsx").getInputStream()) {
|
||||||
|
|
||||||
|
response.setContentType(
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setHeader(
|
||||||
|
"Content-Disposition",
|
||||||
|
"attachment; filename*=UTF-8''" +
|
||||||
|
URLEncoder.encode(fileName, "UTF-8").replace("+", "%20"));
|
||||||
|
|
||||||
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int len;
|
||||||
|
while ((len = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
outputStream.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,11 @@ package com.maibu.controller;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.maibu.core.business.DeviceRunParam;
|
|
||||||
import com.maibu.core.business.OrderModel;
|
import com.maibu.core.business.OrderModel;
|
||||||
import com.maibu.core.controller.BaseController;
|
import com.maibu.core.controller.BaseController;
|
||||||
import com.maibu.core.domain.AjaxResult;
|
import com.maibu.core.domain.AjaxResult;
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.maibu.service.impl;
|
package com.maibu.service.impl;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -39,47 +42,55 @@ public class DeviceRunParamService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DeviceSessionManager sessionManager;
|
private DeviceSessionManager sessionManager;
|
||||||
|
|
||||||
public boolean save(DeviceRunParam deviceRunParam)
|
// public boolean save(DeviceRunParam deviceRunParam)
|
||||||
throws ExecutionException, InterruptedException, TimeoutException {
|
// throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
|
||||||
NettyDevice nettyDevice = sessionManager.getDevice(deviceRunParam.getDeviceId());
|
// NettyDevice nettyDevice =
|
||||||
if (nettyDevice == null || !nettyDevice.getChannel().isActive()) {
|
// sessionManager.getDevice(deviceRunParam.getDeviceId());
|
||||||
throw new ServiceException("设备不在线,无法操作!");
|
// if (nettyDevice == null || !nettyDevice.getChannel().isActive()) {
|
||||||
}
|
// throw new ServiceException("设备不在线,无法操作!");
|
||||||
|
// }
|
||||||
|
|
||||||
CompletableFuture<DeviceRunParam> future = new CompletableFuture<>();
|
// CompletableFuture<DeviceRunParam> future = new CompletableFuture<>();
|
||||||
nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(future);
|
// nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(future);
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
nettyDevice.readConfigCommand();
|
// nettyDevice.readConfigCommand();
|
||||||
|
|
||||||
DeviceRunParam param = future.get(5, TimeUnit.SECONDS);
|
// DeviceRunParam param = future.get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
if (param == null) {
|
// if (param == null) {
|
||||||
throw new ServiceException("获取设备当前属性失败!");
|
// throw new ServiceException("获取设备当前属性失败!");
|
||||||
}
|
// }
|
||||||
|
|
||||||
param.setLeftForwardGain(deviceRunParam.getLeftForwardGain());
|
// param.setLeftForwardGain(deviceRunParam.getLeftForwardGain());
|
||||||
param.setLeftBackwardGain(deviceRunParam.getLeftBackwardGain());
|
// param.setLeftBackwardGain(deviceRunParam.getLeftBackwardGain());
|
||||||
param.setRightForwardGain(deviceRunParam.getRightForwardGain());
|
// param.setRightForwardGain(deviceRunParam.getRightForwardGain());
|
||||||
param.setRightBackwardGain(deviceRunParam.getRightBackwardGain());
|
// param.setRightBackwardGain(deviceRunParam.getRightBackwardGain());
|
||||||
|
|
||||||
nettyDevice.writeConfigCommand(param);
|
// nettyDevice.writeConfigCommand(param);
|
||||||
|
|
||||||
param.setRunSpeed(deviceRunParam.getRunSpeed());
|
// param.setRunSpeed(deviceRunParam.getRunSpeed());
|
||||||
param.setDeviceId(deviceRunParam.getDeviceId());
|
// param.setDeviceId(deviceRunParam.getDeviceId());
|
||||||
param.setSiteId(deviceRunParam.getSiteId());
|
// param.setSiteId(deviceRunParam.getSiteId());
|
||||||
param.setOrgId(deviceRunParam.getOrgId());
|
// param.setOrgId(deviceRunParam.getOrgId());
|
||||||
param.setId(deviceRunParam.getId());
|
// param.setId(deviceRunParam.getId());
|
||||||
|
|
||||||
|
// SiteMemory siteMemory = GlobalMemory.getSiteMemory(deviceRunParam.getOrgId(),
|
||||||
|
// deviceRunParam.getSiteId());
|
||||||
|
// if (siteMemory != null) {
|
||||||
|
// siteMemory.saveDeviceRunParam(param);
|
||||||
|
// }
|
||||||
|
// return deviceRunParamMapper.saveOrUpdate(param);
|
||||||
|
// } finally {
|
||||||
|
// nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public boolean save(DeviceRunParam deviceRunParam) {
|
||||||
|
|
||||||
|
return deviceRunParamMapper.saveOrUpdate(deviceRunParam);
|
||||||
|
|
||||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(deviceRunParam.getOrgId(), deviceRunParam.getSiteId());
|
|
||||||
if (siteMemory != null) {
|
|
||||||
siteMemory.saveDeviceRunParam(param);
|
|
||||||
}
|
|
||||||
return deviceRunParamMapper.saveOrUpdate(param);
|
|
||||||
} finally {
|
|
||||||
nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DeviceRunParam> list(BaseQueryDTO dto) {
|
public List<DeviceRunParam> list(BaseQueryDTO dto) {
|
||||||
@@ -127,6 +138,49 @@ public class DeviceRunParamService {
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// public DeviceRunParam selectByDeviceId(String deviceId)
|
||||||
|
// throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
|
||||||
|
// LambdaQueryWrapper<DeviceRunParam> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
// if (!StringUtils.isEmpty(deviceId)) {
|
||||||
|
// queryWrapper.eq(DeviceRunParam::getDeviceId, deviceId);
|
||||||
|
// }
|
||||||
|
// DeviceRunParam result = deviceRunParamMapper.selectOne(queryWrapper);
|
||||||
|
// if (result != null && result.getHasHost() != null && result.getHasHost() ==
|
||||||
|
// 1) {
|
||||||
|
// return result;
|
||||||
|
// } else {
|
||||||
|
// NettyDevice nettyDevice = sessionManager.getDevice(deviceId);
|
||||||
|
// CompletableFuture<DeviceRunParam> future = new CompletableFuture<>();
|
||||||
|
// if (nettyDevice != null && nettyDevice.getChannel() != null &&
|
||||||
|
// nettyDevice.getChannel().isActive()) {
|
||||||
|
// nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(future);
|
||||||
|
// try {
|
||||||
|
// nettyDevice.readConfigCommand();
|
||||||
|
// DeviceRunParam param = future.get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
// // LambdaQueryWrapper<DeviceRunParam> queryWrapper = new
|
||||||
|
// LambdaQueryWrapper<>();
|
||||||
|
// // if (!StringUtils.isEmpty(deviceId)) {
|
||||||
|
// // queryWrapper.eq(DeviceRunParam::getDeviceId, deviceId);
|
||||||
|
// // }
|
||||||
|
// // DeviceRunParam result = deviceRunParamMapper.selectOne(queryWrapper);
|
||||||
|
// if (result != null) {
|
||||||
|
// param.setId(result.getId());
|
||||||
|
// param.setDeviceId(result.getDeviceId());
|
||||||
|
// param.setRunSpeed(result.getRunSpeed());
|
||||||
|
// param.setOrgId(nettyDevice.getDevice().getOrgId());
|
||||||
|
// param.setSiteId(nettyDevice.getDevice().getSiteId());
|
||||||
|
// }
|
||||||
|
// return param;
|
||||||
|
// } finally {
|
||||||
|
// nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
public DeviceRunParam selectByDeviceId(String deviceId)
|
public DeviceRunParam selectByDeviceId(String deviceId)
|
||||||
throws ExecutionException, InterruptedException, TimeoutException {
|
throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
|
||||||
@@ -135,36 +189,7 @@ public class DeviceRunParamService {
|
|||||||
queryWrapper.eq(DeviceRunParam::getDeviceId, deviceId);
|
queryWrapper.eq(DeviceRunParam::getDeviceId, deviceId);
|
||||||
}
|
}
|
||||||
DeviceRunParam result = deviceRunParamMapper.selectOne(queryWrapper);
|
DeviceRunParam result = deviceRunParamMapper.selectOne(queryWrapper);
|
||||||
if (result != null && result.getHasHost() != null && result.getHasHost() == 1) {
|
return result;
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
NettyDevice nettyDevice = sessionManager.getDevice(deviceId);
|
|
||||||
CompletableFuture<DeviceRunParam> future = new CompletableFuture<>();
|
|
||||||
if (nettyDevice != null && nettyDevice.getChannel() != null && nettyDevice.getChannel().isActive()) {
|
|
||||||
nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(future);
|
|
||||||
try {
|
|
||||||
nettyDevice.readConfigCommand();
|
|
||||||
DeviceRunParam param = future.get(5, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
// LambdaQueryWrapper<DeviceRunParam> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
// if (!StringUtils.isEmpty(deviceId)) {
|
|
||||||
// queryWrapper.eq(DeviceRunParam::getDeviceId, deviceId);
|
|
||||||
// }
|
|
||||||
// DeviceRunParam result = deviceRunParamMapper.selectOne(queryWrapper);
|
|
||||||
if (result != null) {
|
|
||||||
param.setId(result.getId());
|
|
||||||
param.setDeviceId(result.getDeviceId());
|
|
||||||
param.setRunSpeed(result.getRunSpeed());
|
|
||||||
param.setOrgId(nettyDevice.getDevice().getOrgId());
|
|
||||||
param.setSiteId(nettyDevice.getDevice().getSiteId());
|
|
||||||
}
|
|
||||||
return param;
|
|
||||||
} finally {
|
|
||||||
nettyDevice.getChannel().attr(Constant.READ_CONFIG_KEY).set(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int delete(List<Long> ids) {
|
public int delete(List<Long> ids) {
|
||||||
@@ -211,20 +236,51 @@ public class DeviceRunParamService {
|
|||||||
}
|
}
|
||||||
if (deviceRunParam != null) {
|
if (deviceRunParam != null) {
|
||||||
deviceRunParam.setCapabilityList(x.getCapabilityList());
|
deviceRunParam.setCapabilityList(x.getCapabilityList());
|
||||||
|
|
||||||
|
deviceRunParam.setDeviceId(x.getDeviceId());
|
||||||
|
|
||||||
|
parseSn(x.getDeviceId(), deviceRunParam);
|
||||||
|
|
||||||
deviceRunParam.setProductModel(x.getProductModel());
|
deviceRunParam.setProductModel(x.getProductModel());
|
||||||
deviceRunParam.setRtkMode(x.getRtkMode());
|
|
||||||
deviceRunParam.setDeviceType(x.getDeviceType());
|
deviceRunParam.setDeviceType(x.getDeviceType());
|
||||||
deviceRunParam.setPowerType(x.getPowerType());
|
deviceRunParam.setRtkMode(x.getRtkMode());
|
||||||
deviceRunParam.setCameraNum(x.getCameraNum());
|
deviceRunParam.setCameraNum(x.getCameraNum());
|
||||||
|
deviceRunParam.setPowerType(x.getPowerType());
|
||||||
deviceRunParam.setWheelType(x.getWheelType());
|
deviceRunParam.setWheelType(x.getWheelType());
|
||||||
deviceRunParam.setEngineType(x.getEngineType());
|
deviceRunParam.setEngineType(x.getEngineType());
|
||||||
deviceRunParam.setHasHost(x.getHasHost());
|
deviceRunParam.setHasHost(x.getHasHost());
|
||||||
|
|
||||||
|
deviceRunParam.setBatteryType(x.getBatteryType());
|
||||||
|
deviceRunParam.setWalkingDriveType(x.getWalkingDriveType());
|
||||||
|
deviceRunParam.setCutterDriveType(x.getCutterDriveType());
|
||||||
|
deviceRunParam.setRtkAntennasNum(x.getRtkAntennasNum());
|
||||||
|
deviceRunParam.setHandleType(x.getHandleType());
|
||||||
|
deviceRunParam.setPcbVersion(x.getPcbVersion());
|
||||||
|
deviceRunParam.setDimensions(x.getDimensions());
|
||||||
|
deviceRunParam.setBladeWidth(x.getBladeWidth());
|
||||||
|
deviceRunParam.setTyreSize(x.getTyreSize());
|
||||||
|
deviceRunParam.setSpeedRatio(x.getSpeedRatio());
|
||||||
|
deviceRunParam.setCellularInfo(x.getCellularInfo());
|
||||||
|
deviceRunParam.setWifiName(x.getWifiName());
|
||||||
|
deviceRunParam.setBluetoothName(x.getBluetoothName());
|
||||||
|
deviceRunParam.setHardwareIdentifiers(x.getHardwareIdentifiers());
|
||||||
|
deviceRunParam.setImuModel(x.getImuModel());
|
||||||
|
deviceRunParam.setTempHumiditySensor(x.getTempHumiditySensor());
|
||||||
|
deviceRunParam.setBarometerPresent(x.getBarometerPresent());
|
||||||
|
deviceRunParam.setUltrasonicPresent(x.getUltrasonicPresent());
|
||||||
|
deviceRunParam.setDacPresent(x.getDacPresent());
|
||||||
|
deviceRunParam.setOperator(x.getOperator());
|
||||||
|
deviceRunParam.setInspectionNo(x.getInspectionNo());
|
||||||
|
deviceRunParam.setFirmwareVersion(x.getFirmwareVersion());
|
||||||
|
deviceRunParam.setDealer(x.getDealer());
|
||||||
|
|
||||||
saveList.add(deviceRunParam);
|
saveList.add(deviceRunParam);
|
||||||
} else {
|
} else {
|
||||||
|
parseSn(x.getDeviceId(), x);
|
||||||
saveList.add(x);
|
saveList.add(x);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//todo 增加 解析sn码的功能
|
// todo 增加 解析sn码的功能
|
||||||
return deviceRunParamMapper.saveOrUpdateBatch(saveList);
|
return deviceRunParamMapper.saveOrUpdateBatch(saveList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,4 +290,21 @@ public class DeviceRunParamService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void parseSn(String sn, DeviceRunParam deviceRunParam) {
|
||||||
|
if (sn == null || sn.length() != 21) {
|
||||||
|
throw new IllegalArgumentException("SN 必须是 21 位字符串");
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceRunParam.setProductModel(sn.substring(0, 2));
|
||||||
|
deviceRunParam.setFactoryCode(sn.substring(2, 4));
|
||||||
|
deviceRunParam.setLineNum(sn.substring(4, 6));
|
||||||
|
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd");
|
||||||
|
LocalDate date = LocalDate.parse(sn.substring(6, 12), formatter);
|
||||||
|
deviceRunParam.setProductionDate(date);
|
||||||
|
|
||||||
|
deviceRunParam.setSerialNumber(sn.substring(12, 17));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
maibu-service/maibu-iot-service/src/main/resources/机器属性导入模板.xlsx
Executable file
BIN
maibu-service/maibu-iot-service/src/main/resources/机器属性导入模板.xlsx
Executable file
Binary file not shown.
Reference in New Issue
Block a user