增加数字孪生设备接口

This commit is contained in:
lxj
2025-09-12 14:02:32 +08:00
parent 0389aa9d7b
commit db80fab091
156 changed files with 383 additions and 263 deletions

View File

@@ -1,60 +0,0 @@
package org.dromara.property.controller.BigScreen;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.property.domain.MeetBooking;
import org.dromara.property.domain.vo.BigScreen.TodayMeetCountVo;
import org.dromara.property.domain.vo.BigScreen.TodayVisitorCountVo;
import org.dromara.property.domain.vo.BigScreen.TypeWorkOrderHistogramVo;
import org.dromara.property.service.IMeetBookingService;
import org.dromara.property.service.IServiceWorkOrdersService;
import org.dromara.property.service.ITbVisitorManagementService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @author yuyongle
* @version 1.0
* @description: 大屏接口
* @date 2025/9/9 9:57
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/screen")
public class ScreenController extends BaseController {
private final IServiceWorkOrdersService serviceWorkOrdersService;
private final IMeetBookingService meetBookingService;
private final ITbVisitorManagementService tbVisitorManagementService;
/**
* 大屏工单柱状图
*/
@GetMapping("/typeWorkOrderHistogram")
public R<List<TypeWorkOrderHistogramVo>> typeWorkOrderHistogram() {
return R.ok(serviceWorkOrdersService.typeWorkOrderHistogram());
}
/**
* 大屏会议室总数和当天预约数统计
*/
@GetMapping("/todayMeetCount")
public R<TodayMeetCountVo> todayMeetCount() {
return R.ok(meetBookingService.todayMeetCount());
}
/**
* 大屏访客记录统计
*/
@GetMapping("/todayVisitorCount")
public R<List<TodayVisitorCountVo>> todayVisitorCount() {
return R.ok(tbVisitorManagementService.todayVisitorCount());
}
}

View File

@@ -1,13 +1,86 @@
package org.dromara.property.controller.cockpit;
import cn.hutool.core.lang.Assert;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.domain.R;
import org.dromara.property.domain.vo.cockpit.DeviceState;
import org.dromara.sis.api.RemoteDeviceService;
import org.dromara.sis.api.domain.RemoteDeviceStateStatistics;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 大屏设备接口
* 大屏设备相关接口
*/
@Slf4j
@RestController
@RequestMapping("/cockpit")
public class DriverController {
@Resource
private ScheduledExecutorService executeService;
@DubboReference
private RemoteDeviceService remoteDeviceService;
/**
* 获取设备状态接口
*
* @param deviceType 0:全部1监控设备2水表3t电表4灯孔5门禁
* @return 返回设备状态数据
*/
@GetMapping("/device/state/{deviceType}")
public R<?> getDeviceState(@PathVariable Integer deviceType) throws InterruptedException {
Assert.isTrue(deviceType <= 5 && deviceType >= 0, "未知的设备类型");
int searchNum = deviceType == 0 ? 5 : 1;
List<DeviceState> result = new ArrayList<>(searchNum);
CountDownLatch countDownLatch = new CountDownLatch(searchNum);
// 查询监控设备状态
if (deviceType == 0 || deviceType == 1) {
executeService.execute(() -> {
RemoteDeviceStateStatistics remoteDeviceStateStatistics = remoteDeviceService.statisticsMonitorState();
if (remoteDeviceStateStatistics != null) {
DeviceState state = new DeviceState();
state.setType(1);
state.setTypeName("监控设备");
state.setOnLine(remoteDeviceStateStatistics.getOnLine());
state.setTotal(remoteDeviceStateStatistics.getTotal());
result.add(state);
}
countDownLatch.countDown();
});
}
//查询水表
if (deviceType == 0 || deviceType == 2) {
}
// 查询电表
if (deviceType == 0 || deviceType == 3) {
}
// 查询灯
if (deviceType == 0 || deviceType == 4) {
}
// 查询门禁
if (deviceType == 0 || deviceType == 5) {
}
/**
* 默认10S超过自动结束
*/
countDownLatch.await(10, TimeUnit.SECONDS);
return R.ok(result);
}
}

View File

@@ -1,11 +1,20 @@
package org.dromara.property.controller.cockpit;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.domain.R;
import org.dromara.property.domain.vo.BigScreen.TodayMeetCountVo;
import org.dromara.property.domain.vo.BigScreen.TodayVisitorCountVo;
import org.dromara.property.domain.vo.BigScreen.TypeWorkOrderHistogramVo;
import org.dromara.property.service.IMeetBookingService;
import org.dromara.property.service.IServiceWorkOrdersService;
import org.dromara.property.service.ITbVisitorManagementService;
import org.dromara.system.api.RemoteUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
@@ -14,6 +23,14 @@ import java.util.Map;
@RestController
@RequestMapping("/cockpit")
public class PropertyPersonController {
@Resource
private IServiceWorkOrdersService serviceWorkOrdersService;
@Resource
private IMeetBookingService meetBookingService;
@Resource
private ITbVisitorManagementService tbVisitorManagementService;
@DubboReference
private RemoteUserService remoteUserService;
@@ -22,4 +39,27 @@ public class PropertyPersonController {
return R.ok(remoteUserService.seelectOrgcount());
}
/**
* 大屏工单柱状图
*/
@GetMapping("/screen/typeWorkOrderHistogram")
public R<List<TypeWorkOrderHistogramVo>> typeWorkOrderHistogram() {
return R.ok(serviceWorkOrdersService.typeWorkOrderHistogram());
}
/**
* 大屏会议室总数和当天预约数统计
*/
@GetMapping("/screen/todayMeetCount")
public R<TodayMeetCountVo> todayMeetCount() {
return R.ok(meetBookingService.todayMeetCount());
}
/**
* 大屏访客记录统计
*/
@GetMapping("/screen/todayVisitorCount")
public R<List<TodayVisitorCountVo>> todayVisitorCount() {
return R.ok(tbVisitorManagementService.todayVisitorCount());
}
}

View File

@@ -0,0 +1,26 @@
package org.dromara.property.domain.vo.cockpit;
import lombok.Data;
@Data
public class DeviceState {
/**
* 设备类型
*/
private Integer type;
/**
* 设备类型名称
*/
private String typeName;
/**
* 在线数
*/
private Integer onLine;
/**
* 总数
*/
private Integer total;
}

View File

@@ -1,5 +1,6 @@
package org.dromara.property.tasks;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.util.Map;
@@ -12,7 +13,10 @@ import java.util.concurrent.*;
*/
@Component
public class HeartbeatTasks {
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
@Resource
private ScheduledExecutorService scheduler;
private final Map<String, ScheduledFuture<?>> tasks = new ConcurrentHashMap<>();
public void startHeartbeatTask(String taskId, Runnable task, long intervalMs, long durationMs) {