This commit is contained in:
2026-07-29 13:08:49 +08:00
parent 29ecbf321f
commit 6be6d5d333
59 changed files with 1396 additions and 304 deletions

View File

@@ -1,14 +1,19 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.maibu.constant.Constant;
import com.maibu.core.business.DeviceRunningStatusHistory;
import com.maibu.core.business.ErrorIdentificationStandard;
import com.maibu.core.business.device.NettyDevice;
import com.maibu.dto.SendCommandDTO;
import com.maibu.mapper.DeviceStatusHistoryMapper;
import com.maibu.mapper.ErrorIdentificationStandardMapper;
import com.maibu.memory.DeviceSessionManager;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
@@ -19,6 +24,9 @@ public class NettyDeviceService {
@Autowired
private DeviceStatusHistoryMapper deviceStatusHistoryMapper;
@Autowired
private DeviceSessionManager deviceSessionManager;
@Autowired
private ErrorIdentificationStandardMapper errorIdentificationStandardMapper;
@@ -40,5 +48,25 @@ public class NettyDeviceService {
return errorIdentificationStandardMapper.updateById(standard);
}
public void sendCommand(SendCommandDTO command) {
if (command == null || command.getCommandType() == null || CollectionUtils.isEmpty(command.getDeviceIds()))
return;
command.getDeviceIds().forEach(deviceId -> {
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
if (nettyDevice != null && !nettyDevice.isExecutingTask()) {
if (nettyDevice.getChannel() != null && nettyDevice.getChannel().isActive()) {
if (Constant.WheelGainCoefficients.equals(command.getCommandType())) {
double leftForwardGain = (double) command.getParams().get("leftForwardGain");
double leftBackwardGain = (double) command.getParams().get("leftBackwardGain");
double rightForwardGain = (double) command.getParams().get("rightForwardGain");
double rightBackwardGain = (double) command.getParams().get("rightBackwardGain");
nettyDevice.sendWheelGainCoefficientsCommand(leftForwardGain, leftBackwardGain, rightForwardGain, rightBackwardGain);
}
}
}
});
}
}