feat(property):
- 数字孪生接口 - xcx活动接口权限
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package org.dromara.property.controller.cockpit;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.bo.smartDevicesBo.TbMeterInfoBo;
|
||||
import org.dromara.property.domain.vo.cockpit.DeviceState;
|
||||
import org.dromara.property.domain.vo.smartDevicesVo.TbMeterInfoVo;
|
||||
import org.dromara.property.service.smartDevicesService.ITbMeterInfoService;
|
||||
import org.dromara.sis.api.RemoteDeviceService;
|
||||
import org.dromara.sis.api.domain.RemoteDeviceStateStatistics;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -27,22 +31,25 @@ import java.util.concurrent.TimeUnit;
|
||||
@RequestMapping("/cockpit")
|
||||
public class DriverController {
|
||||
|
||||
|
||||
@Resource
|
||||
private ScheduledExecutorService executeService;
|
||||
|
||||
@Resource
|
||||
private ITbMeterInfoService tbMeterInfoService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteDeviceService remoteDeviceService;
|
||||
|
||||
/**
|
||||
* 获取设备状态接口
|
||||
*
|
||||
* @param deviceType 0:全部,1:监控设备,2:水表,3t:电表,4:灯孔,5:门禁
|
||||
* @param deviceType 0:全部,1:监控设备,2:水表,3t:电表,4:门禁
|
||||
* @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;
|
||||
Assert.isTrue(deviceType <= 4 && deviceType >= 0, "未知的设备类型");
|
||||
int searchNum = deviceType == 0 ? 4 : 1;
|
||||
List<DeviceState> result = new ArrayList<>(searchNum);
|
||||
CountDownLatch countDownLatch = new CountDownLatch(searchNum);
|
||||
// 查询监控设备状态
|
||||
@@ -60,22 +67,58 @@ public class DriverController {
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
}
|
||||
|
||||
//查询水表
|
||||
if (deviceType == 0 || deviceType == 2) {
|
||||
|
||||
executeService.execute(() -> {
|
||||
TbMeterInfoBo bo = new TbMeterInfoBo();
|
||||
bo.setMeterType(2L); // 水表
|
||||
List<TbMeterInfoVo> meterInfoList = tbMeterInfoService.queryList(bo);
|
||||
if (CollUtil.isNotEmpty(meterInfoList)) {
|
||||
DeviceState state = new DeviceState();
|
||||
state.setType(2);
|
||||
state.setTypeName("水表");
|
||||
state.setOnLine(meterInfoList.stream().filter(item -> item.getCommunicationState() == 1).toList().size());
|
||||
state.setTotal(meterInfoList.size());
|
||||
result.add(state);
|
||||
}
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
}
|
||||
// 查询电表
|
||||
if (deviceType == 0 || deviceType == 3) {
|
||||
|
||||
}
|
||||
// 查询灯
|
||||
if (deviceType == 0 || deviceType == 4) {
|
||||
|
||||
executeService.execute(() -> {
|
||||
TbMeterInfoBo bo = new TbMeterInfoBo();
|
||||
bo.setMeterType(1L); // 水表
|
||||
List<TbMeterInfoVo> meterInfoList = tbMeterInfoService.queryList(bo);
|
||||
if (CollUtil.isNotEmpty(meterInfoList)) {
|
||||
DeviceState state = new DeviceState();
|
||||
state.setType(3);
|
||||
state.setTypeName("电表");
|
||||
state.setOnLine(meterInfoList.stream().filter(item -> item.getCommunicationState() == 1).toList().size());
|
||||
state.setTotal(meterInfoList.size());
|
||||
result.add(state);
|
||||
}
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
}
|
||||
// 查询门禁
|
||||
if (deviceType == 0 || deviceType == 5) {
|
||||
if (deviceType == 0 || deviceType == 4) {
|
||||
executeService.execute(() -> {
|
||||
RemoteDeviceStateStatistics remoteDeviceStateStatistics = remoteDeviceService.statisticsDoorState();
|
||||
if (remoteDeviceStateStatistics != null) {
|
||||
DeviceState state = new DeviceState();
|
||||
state.setType(4);
|
||||
state.setTypeName("门禁");
|
||||
state.setOnLine(remoteDeviceStateStatistics.getOnLine());
|
||||
state.setTotal(remoteDeviceStateStatistics.getTotal());
|
||||
result.add(state);
|
||||
}
|
||||
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认10S,超过自动结束
|
||||
*/
|
||||
|
@@ -3,6 +3,7 @@ package org.dromara.property.controller.xcx;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
@@ -24,6 +25,7 @@ import java.util.Map;
|
||||
* @author lsm
|
||||
* @since 2025-06-19
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
|
@@ -124,6 +124,7 @@ public interface ITbVisitorManagementService {
|
||||
* @return String
|
||||
*/
|
||||
Map<String, Object> getQrCodeByIdForXcx(Long id);
|
||||
|
||||
/**
|
||||
* 大屏访客记录统计
|
||||
*/
|
||||
|
@@ -218,14 +218,16 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
record.setPreviousReading(record.getCurrentReading());
|
||||
}
|
||||
|
||||
// 通信状态改为离线
|
||||
TbMeterInfoBo bo = new TbMeterInfoBo();
|
||||
bo.setId(info.getId());
|
||||
if (record.getCurrentReading().compareTo(BigDecimal.ZERO) == 0){
|
||||
// 通信状态改为离线
|
||||
TbMeterInfoBo bo = new TbMeterInfoBo();
|
||||
bo.setId(info.getId());
|
||||
bo.setCommunicationState(0L);
|
||||
tbMeterInfoService.updateByBo(bo);
|
||||
record.setCurrentReading(record.getPreviousReading());
|
||||
}else {
|
||||
bo.setCommunicationState(1L);
|
||||
}
|
||||
tbMeterInfoService.updateByBo(bo);
|
||||
|
||||
record.setReadingMethod(MeterRecordTypeEnum.AUTO_RECORD.getCode());
|
||||
recordNew.add(record);
|
||||
|
Reference in New Issue
Block a user