1. 修改发送功能
This commit is contained in:
parent
90b6c51460
commit
b99e08f20a
|
@ -59,9 +59,8 @@ public class AuthUser {
|
|||
new ArrayList<>(),
|
||||
new ArrayList<>(),
|
||||
new ArrayList<>(Arrays.asList(0, 1, 2, 3)));
|
||||
Long id = baidouAdapterService.getAllAdapter().get(0).getId();
|
||||
baidouAdapterService.sendCommond(id, sensorPro);
|
||||
|
||||
baidouAdapterService.sendCommandToAllAdapter(sensorPro);
|
||||
return "{\"result\": 0}";
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,14 @@ import java.util.List;
|
|||
public interface BaidouAdapterService {
|
||||
void startBeidouAdapter();
|
||||
|
||||
List<Long> getActiveAdapter();
|
||||
|
||||
void sendCommond(Long adapterId, Object command);
|
||||
|
||||
void sendCommond(Channel ch, Object command);
|
||||
|
||||
void sendCommandToAllAdapter(Object command);
|
||||
|
||||
List<BeidouAdapterDevice> getAllAdapter();
|
||||
|
||||
void addNewBeidouAdapter(BeidouAdapterDevice adapter);
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.zjyr.beidouservice.pojo.dto.task.AlarmTaskReqDTO;
|
|||
import com.zjyr.beidouservice.pojo.vo.PageInfoVO;
|
||||
import com.zjyr.beidouservice.service.AdapterProtocolService;
|
||||
import com.zjyr.beidouservice.service.AlarmTaskService;
|
||||
import com.zjyr.beidouservice.service.BaidouAdapterService;
|
||||
import com.zjyr.beidouservice.service.DeviceService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -55,6 +56,9 @@ import java.util.stream.Collectors;
|
|||
public class AlarmTaskServiceImpl implements AlarmTaskService {
|
||||
@Resource
|
||||
AdapterProtocolService adapterProtocolService;
|
||||
|
||||
@Resource
|
||||
BaidouAdapterService baidouAdapterService;
|
||||
@Resource
|
||||
DeviceService deviceService;
|
||||
|
||||
|
@ -110,7 +114,7 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
|
|||
// 刷新设备告警状态
|
||||
deviceService.refreshDeviceAlarmStatus(alarmDeviceTaskDOS);
|
||||
//执行控制任,默认只有一种通道方式
|
||||
adapterProtocolService.createSensorControlProtocol(
|
||||
baidouAdapterService.sendCommandToAllAdapter(adapterProtocolService.createSensorControlProtocol(
|
||||
generatedId.intValue(),
|
||||
CommonEnumHandler.codeOf(AlarmModeName.class, alarmTaskReqDTO.getAlarmMode()),
|
||||
CommonEnumHandler.codeOf(AlarmControlTypeName.class, alarmTaskReqDTO.getAlarmType()),
|
||||
|
@ -120,7 +124,7 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
|
|||
deviceInfo.getCityCodes(),
|
||||
deviceInfo.getCountyCodes(),
|
||||
deviceInfo.getBeidouIds()
|
||||
);
|
||||
));
|
||||
|
||||
return MyResp.success("执行任务成功");
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ import static com.zjyr.beidouservice.common.impl.SocketEventName.SOCKET_EVT_CONN
|
|||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implements BaidouAdapterService, ApplicationListener<T> {
|
||||
public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implements BaidouAdapterService,
|
||||
ApplicationListener<T> {
|
||||
|
||||
private final ConcurrentHashMap<Long, ControlAdapterSocketCtx> ctxMap = new ConcurrentHashMap<>();
|
||||
@Resource
|
||||
|
@ -56,6 +57,13 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
|||
tcpServer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getActiveAdapter() {
|
||||
List<Long> adapterList = new ArrayList<>();
|
||||
ctxMap.forEach((key, value) -> adapterList.add(key));
|
||||
return adapterList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCommond(Long adapterId, Object command) {
|
||||
ControlAdapterSocketCtx ctx = ctxMap.get(adapterId);
|
||||
|
@ -72,6 +80,11 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
|||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCommandToAllAdapter(Object command) {
|
||||
getActiveAdapter().forEach(k -> sendCommond(k, command));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(@Nonnull T evtContent) {
|
||||
if (evtContent instanceof SocketNotifyEvent event) {
|
||||
|
|
Loading…
Reference in New Issue