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