feat:迁移1.0采集设备模块
parent
e2f137fae2
commit
6a4c55a4c0
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.framework.common.core;
|
||||
|
||||
/**
|
||||
* 可生成 Int 数组的接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface IntArrayValuable {
|
||||
|
||||
/**
|
||||
* @return int 数组
|
||||
*/
|
||||
int[] array();
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.framework.common.enums;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 设备连接状态枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DeviceConnectionStatusEnum implements IntArrayValuable {
|
||||
|
||||
CONNECTED(1, "已连接"),
|
||||
DISCONNECTED(2, "已断开");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeviceConnectionStatusEnum::getStatus).toArray();
|
||||
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private final Integer status;
|
||||
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为连接状态
|
||||
*/
|
||||
public static boolean isConnected(Integer status) {
|
||||
return ObjUtil.equal(CONNECTED.status, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为断开状态
|
||||
*/
|
||||
public static boolean isDisconnected(Integer status) {
|
||||
return ObjUtil.equal(DISCONNECTED.status, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态值获取枚举实例
|
||||
*/
|
||||
public static DeviceConnectionStatusEnum valueOf(Integer status) {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
for (DeviceConnectionStatusEnum value : values()) {
|
||||
if (ObjUtil.equal(value.status, status)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.framework.common.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class DeviceEdgeData {
|
||||
private Long deviceId;
|
||||
private LocalDateTime firstTs;
|
||||
private String firstData;
|
||||
private LocalDateTime lastTs;
|
||||
private String lastData;
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO;
|
||||
import cn.iocoder.yudao.module.iot.service.alert.IotAlertConfigService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 告警配置")
|
||||
@RestController
|
||||
@RequestMapping("/iot/alert-config")
|
||||
@Validated
|
||||
public class IotAlertConfigController {
|
||||
|
||||
@Resource
|
||||
private IotAlertConfigService alertConfigService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建告警配置")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-config:create')")
|
||||
public CommonResult<Long> createAlertConfig(@Valid @RequestBody IotAlertConfigSaveReqVO createReqVO) {
|
||||
return success(alertConfigService.createAlertConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新告警配置")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-config:update')")
|
||||
public CommonResult<Boolean> updateAlertConfig(@Valid @RequestBody IotAlertConfigSaveReqVO updateReqVO) {
|
||||
alertConfigService.updateAlertConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除告警配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-config:delete')")
|
||||
public CommonResult<Boolean> deleteAlertConfig(@RequestParam("id") Long id) {
|
||||
alertConfigService.deleteAlertConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得告警配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-config:query')")
|
||||
public CommonResult<IotAlertConfigRespVO> getAlertConfig(@RequestParam("id") Long id) {
|
||||
IotAlertConfigDO alertConfig = alertConfigService.getAlertConfig(id);
|
||||
return success(BeanUtils.toBean(alertConfig, IotAlertConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得告警配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-config:query')")
|
||||
public CommonResult<PageResult<IotAlertConfigRespVO>> getAlertConfigPage(@Valid IotAlertConfigPageReqVO pageReqVO) {
|
||||
PageResult<IotAlertConfigDO> pageResult = alertConfigService.getAlertConfigPage(pageReqVO);
|
||||
|
||||
// 转换返回
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
||||
convertSetByFlatMap(pageResult.getList(), config -> config.getReceiveUserIds().stream()));
|
||||
return success(BeanUtils.toBean(pageResult, IotAlertConfigRespVO.class, vo -> {
|
||||
vo.setReceiveUserNames(vo.getReceiveUserIds().stream()
|
||||
.map(userMap::get)
|
||||
.filter(Objects::nonNull)
|
||||
.map(AdminUserRespDTO::getNickname)
|
||||
.collect(Collectors.toList()));
|
||||
}));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得告警配置简单列表", description = "只包含被开启的告警配置,主要用于前端的下拉选项")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-config:query')")
|
||||
public CommonResult<List<IotAlertConfigRespVO>> getAlertConfigSimpleList() {
|
||||
List<IotAlertConfigDO> list = alertConfigService.getAlertConfigListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(convertList(list, config -> // 只返回 id、name 字段
|
||||
new IotAlertConfigRespVO().setId(config.getId()).setName(config.getName())));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.recrod.IotAlertRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.recrod.IotAlertRecordProcessReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.recrod.IotAlertRecordRespVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertRecordDO;
|
||||
import cn.iocoder.yudao.module.iot.service.alert.IotAlertRecordService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 告警记录")
|
||||
@RestController
|
||||
@RequestMapping("/iot/alert-record")
|
||||
@Validated
|
||||
public class IotAlertRecordController {
|
||||
|
||||
@Resource
|
||||
private IotAlertRecordService alertRecordService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得告警记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-record:query')")
|
||||
public CommonResult<IotAlertRecordRespVO> getAlertRecord(@RequestParam("id") Long id) {
|
||||
IotAlertRecordDO alertRecord = alertRecordService.getAlertRecord(id);
|
||||
return success(BeanUtils.toBean(alertRecord, IotAlertRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得告警记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-record:query')")
|
||||
public CommonResult<PageResult<IotAlertRecordRespVO>> getAlertRecordPage(@Valid IotAlertRecordPageReqVO pageReqVO) {
|
||||
PageResult<IotAlertRecordDO> pageResult = alertRecordService.getAlertRecordPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, IotAlertRecordRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/process")
|
||||
@Operation(summary = "处理告警记录")
|
||||
@PreAuthorize("@ss.hasPermission('iot:alert-record:process')")
|
||||
public CommonResult<Boolean> processAlertRecord(@Valid @RequestBody IotAlertRecordProcessReqVO processReqVO) {
|
||||
alertRecordService.processAlertRecordList(singleton(processReqVO.getId()), processReqVO.getProcessRemark());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 告警配置分页 Request VO")
|
||||
@Data
|
||||
public class IotAlertConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "配置名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配置状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 告警配置 Response VO")
|
||||
@Data
|
||||
public class IotAlertConfigRespVO {
|
||||
|
||||
@Schema(description = "配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3566")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配置描述", example = "你猜")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "告警级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "配置状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "关联的场景联动规则编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3")
|
||||
private List<Long> sceneRuleIds;
|
||||
|
||||
@Schema(description = "接收的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "100,200")
|
||||
private List<Long> receiveUserIds;
|
||||
|
||||
@Schema(description = "接收的用户名称数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三,李四")
|
||||
private List<String> receiveUserNames;
|
||||
|
||||
@Schema(description = "接收的类型数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3")
|
||||
private List<Integer> receiveTypes;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 告警配置新增/修改 Request VO")
|
||||
@Data
|
||||
public class IotAlertConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "配置编号", example = "3566")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "配置名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配置描述", example = "你猜")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "告警级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "告警级别不能为空")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "配置状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "配置状态不能为空")
|
||||
@InEnum(CommonStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "关联的场景联动规则编号数组")
|
||||
@NotEmpty(message = "关联的场景联动规则编号数组不能为空")
|
||||
private List<Long> sceneRuleIds;
|
||||
|
||||
@Schema(description = "接收的用户编号数组")
|
||||
@NotEmpty(message = "接收的用户编号数组不能为空")
|
||||
private List<Long> receiveUserIds;
|
||||
|
||||
@Schema(description = "接收的类型数组")
|
||||
@NotEmpty(message = "接收的类型数组不能为空")
|
||||
private List<Integer> receiveTypes;
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert.vo.recrod;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 告警记录分页 Request VO")
|
||||
@Data
|
||||
public class IotAlertRecordPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "告警配置编号", example = "29320")
|
||||
private Long configId;
|
||||
|
||||
@Schema(description = "告警级别", example = "1")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "产品编号", example = "2050")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "设备编号", example = "21727")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "是否处理", example = "true")
|
||||
private Boolean processStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert.vo.recrod;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 告警记录处理 Request VO")
|
||||
@Data
|
||||
public class IotAlertRecordProcessReqVO {
|
||||
|
||||
@Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "记录编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "处理结果(备注)", requiredMode = Schema.RequiredMode.REQUIRED, example = "已处理告警,问题已解决")
|
||||
private String processRemark;
|
||||
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.alert.vo.recrod;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 告警记录 Response VO")
|
||||
@Data
|
||||
public class IotAlertRecordRespVO {
|
||||
|
||||
@Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19904")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "告警配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29320")
|
||||
private Long configId;
|
||||
|
||||
@Schema(description = "告警名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
private String configName;
|
||||
|
||||
@Schema(description = "告警级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer configLevel;
|
||||
|
||||
@Schema(description = "产品编号", example = "2050")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "设备编号", example = "21727")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(description = "触发的设备消息")
|
||||
private IotDeviceMessage deviceMessage;
|
||||
|
||||
@Schema(description = "是否处理", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Boolean processStatus;
|
||||
|
||||
@Schema(description = "处理结果(备注)", example = "你说的对")
|
||||
private String processRemark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,353 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.infra.service.job.JobService;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.*;
|
||||
//import cn.iocoder.yudao.module.iot.controller.admin.devicecontactmodel.vo.DeviceContactModelPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceAttributeDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO;
|
||||
//import cn.iocoder.yudao.module.iot.dal.dataobject.devicecontactmodel.DeviceContactModelDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicecontactmodel.DeviceContactModelDO;
|
||||
import cn.iocoder.yudao.module.iot.service.device.DeviceService;
|
||||
import cn.iocoder.yudao.module.iot.service.device.TDengineService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 物联设备")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device")
|
||||
@Validated
|
||||
public class DeviceController {
|
||||
|
||||
@Resource
|
||||
private DeviceService deviceService;
|
||||
@Resource
|
||||
private TDengineService tDengineService;
|
||||
@Resource
|
||||
private JobService jobService;
|
||||
|
||||
// @Resource
|
||||
// private OpcUaSubscriptionService opcUaService;
|
||||
|
||||
// @Resource
|
||||
// private IMqttservice mqttService;
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建物联设备")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:create')")
|
||||
public CommonResult<DeviceDO> createDevice(@Valid @RequestBody DeviceSaveReqVO createReqVO) throws SchedulerException {
|
||||
DeviceDO device = deviceService.createDevice(createReqVO);
|
||||
//初始化Td表
|
||||
// tDengineService.initDatabaseAndTable(device.getId());
|
||||
|
||||
return success(device);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新物联设备")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:update')")
|
||||
public CommonResult<Boolean> updateDevice(@Valid @RequestBody DeviceSaveReqVO updateReqVO) {
|
||||
deviceService.updateDevice(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除物联设备")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:delete')")
|
||||
public CommonResult<Boolean> deleteDevice(@RequestParam("ids") String ids) {
|
||||
// 将逗号分隔的字符串转换为Long类型的List
|
||||
List<Long> idList = Arrays.stream(ids.split(","))
|
||||
.map(String::trim) // 去除可能存在的空格
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
deviceService.deleteDevice(idList);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得物联设备")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<DeviceRespVO> getDevice(@RequestParam("id") Long id) {
|
||||
DeviceRespVO deviceRespVO = deviceService.getDevice(id);
|
||||
return success(deviceRespVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得物联设备分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<PageResult<DeviceRespVO>> getDevicePage(@Valid DevicePageReqVO pageReqVO) {
|
||||
PageResult<DeviceRespVO> pageResult = deviceService.getDevicePage(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出物联设备 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDeviceExcel(@Valid DevicePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<DeviceRespVO> list = deviceService.getDevicePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "物联设备.xls", "数据", DeviceRespVO.class,list);
|
||||
}
|
||||
@GetMapping("/deviceList")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<List<DeviceRespVO>> deviceList(@Valid DevicePageReqVO pageReqVO) {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceRespVO> list = deviceService.getDevicePage(pageReqVO).getList();
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/noUsedlist")
|
||||
@Operation(summary = "获得未关联设备台账列表")
|
||||
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
||||
public CommonResult<List<DeviceRespVO>> getDeviceLedgerListByNoUsed() {
|
||||
DevicePageReqVO pageReqVO = new DevicePageReqVO();
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceRespVO> list = deviceService.getDevicePage(pageReqVO).getList();
|
||||
List<Long> ids = deviceService.deviceLedgerList();
|
||||
List<DeviceRespVO> filteredList = list.stream()
|
||||
.filter(device -> !ids.contains(device.getId()))
|
||||
.collect(Collectors.toList());
|
||||
return success(filteredList);
|
||||
}
|
||||
|
||||
@GetMapping("/noUsedlist2")
|
||||
@Operation(summary = "获得未关联设备台账列表")
|
||||
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
||||
public CommonResult<List<DeviceRespVO>> getDeviceLedgerList2ByNoUsed(@RequestParam("id") Long id) {
|
||||
DevicePageReqVO pageReqVO = new DevicePageReqVO();
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceRespVO> list = deviceService.getDevicePage(pageReqVO).getList();
|
||||
List<Long> ids = deviceService.deviceLedgerList();
|
||||
|
||||
List<DeviceRespVO> filteredList = list.stream()
|
||||
.filter(device -> {
|
||||
if (id != null && id.equals(device.getId())) {
|
||||
return true;
|
||||
}
|
||||
return !ids.contains(device.getId());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return success(filteredList);
|
||||
}
|
||||
|
||||
@PostMapping("/connect")
|
||||
@Operation(summary = "连接")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:create')")
|
||||
public CommonResult<Boolean> connectDevice(@RequestBody DeviceSaveReqVO createReqVO) throws SchedulerException {
|
||||
|
||||
deviceService.connectDevice(createReqVO);
|
||||
|
||||
//开启或停止定时任务
|
||||
// JobDO jobDO = jobService.getJobByDeviceId(createReqVO.getId());
|
||||
// jobService.updateJobStatus(jobDO.getId(), createReqVO.getIsConnect());
|
||||
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/copy")
|
||||
@Operation(summary = "复制设备")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model:update')")
|
||||
public CommonResult<Long> copyDevice(@RequestParam("id") Long id) {
|
||||
return success(deviceService.copyDevice(id));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/lineDevicePage")
|
||||
@Operation(summary = "获得产线设备分页")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:lineDevicePage')")
|
||||
public CommonResult<PageResult<LineDeviceRespVO>> lineDevicePage(@Valid LineDeviceRequestVO pageReqVO) {
|
||||
PageResult<LineDeviceRespVO> pageResult = deviceService.lineDevicePage(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-line-device")
|
||||
@Operation(summary = "导出产线设备分页 Excel")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:lineDeviceExport')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportLineDevice(@Valid LineDeviceRequestVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
|
||||
|
||||
PageResult<LineDeviceRespVO> lineDeviceRespVOPageResult = deviceService.lineDevicePage(pageReqVO);
|
||||
// 设置响应头
|
||||
// response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
// response.setHeader("Content-Disposition",
|
||||
// "attachment;filename=" + URLEncoder.encode("设备运行报表记录.xls", "UTF-8"));
|
||||
// response.setHeader("Content-Encoding", "identity");
|
||||
// 导出Excel
|
||||
String fileName = String.format("数据实时监控_%s.xls", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
||||
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, fileName, "数据", LineDeviceRespVO.class,lineDeviceRespVOPageResult.getList());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/singleDevice")
|
||||
@Operation(summary = "单设备查看")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<Map<String, List<Map<String, Object>>>> singleDevice(@RequestParam("deviceId") Long deviceId) throws JsonProcessingException {
|
||||
Map<String, List<Map<String, Object>>> deviceContactModelDO=deviceService.singleDevice(deviceId);
|
||||
return success(deviceContactModelDO);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/historyRecord")
|
||||
@Operation(summary = "历史记录查询")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<PageResult<Map<String, Object>>> historyRecord(@RequestParam("deviceId") Long deviceId,
|
||||
@RequestParam(name = "collectionStartTime", required = false) String collectionStartTime,
|
||||
@RequestParam(name = "collectionEndTime", required = false) String collectionEndTime,
|
||||
@RequestParam(name = "attributeCodes", required = false)List<String> attributeCodes,
|
||||
@RequestParam(name = "pageNo", required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize
|
||||
) throws JsonProcessingException {
|
||||
PageResult<Map<String, Object>> deviceContactModelDO=deviceService.historyRecord(deviceId,collectionStartTime,collectionEndTime,attributeCodes,page,pageSize);
|
||||
return success(deviceContactModelDO);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getDeviceOperationalStatus")
|
||||
@Operation(summary = "获取首页设备运行状态")
|
||||
// @PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
@Parameter(name = "orgId", description = "产线组织Id")
|
||||
public CommonResult<DeviceOperationStatusRespVO> getDeviceOperationalStatus(@RequestParam(name = "orgId",required = false) Long orgId) throws JsonProcessingException {
|
||||
DeviceOperationStatusRespVO deviceOperationalStatus=deviceService.getDeviceOperationalStatus();
|
||||
return success(deviceOperationalStatus);
|
||||
}
|
||||
|
||||
|
||||
// ==================== 子表(设备属性) ====================
|
||||
|
||||
@GetMapping("/device-attribute/page")
|
||||
@Operation(summary = "获得设备属性分页")
|
||||
@Parameter(name = "deviceId", description = "设备id")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<PageResult<DeviceContactModelDO>> getDeviceAttributePage(PageParam pageParam, DeviceContactModelPageReqVO deviceModelAttributePageReqVO) {
|
||||
return success(deviceService.getDeviceAttributePage(pageParam, deviceModelAttributePageReqVO));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/device-attribute/list")
|
||||
@Operation(summary = "获得设备属性列表")
|
||||
@Parameter(name = "deviceId", description = "设备id")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<List<DeviceContactModelDO>> getDeviceAttributeList(@RequestParam(name = "deviceId") Long deviceId) {
|
||||
return success(deviceService.getDeviceAttributeList(deviceId));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/device-attribute/create")
|
||||
@Operation(summary = "创建设备属性")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:create')")
|
||||
public CommonResult<Long> createDeviceAttribute(@Valid @RequestBody DeviceAttributeDO deviceAttribute) {
|
||||
return success(deviceService.createDeviceAttribute(deviceAttribute));
|
||||
}
|
||||
|
||||
@PutMapping("/device-attribute/update")
|
||||
@Operation(summary = "更新设备属性")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:update')")
|
||||
public CommonResult<Boolean> updateDeviceAttribute(@Valid @RequestBody DeviceAttributeDO deviceAttribute) {
|
||||
deviceService.updateDeviceAttribute(deviceAttribute);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/device-attribute/delete")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Operation(summary = "删除设备属性")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:delete')")
|
||||
public CommonResult<Boolean> deleteDeviceAttribute(@RequestParam("id") Long id) {
|
||||
deviceService.deleteDeviceAttribute(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/device-attribute/get")
|
||||
@Operation(summary = "获得设备属性")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<DeviceAttributeDO> getDeviceAttribute(@RequestParam("id") Long id) {
|
||||
return success(deviceService.getDeviceAttribute(id));
|
||||
}
|
||||
|
||||
@GetMapping("/devicePointList")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<List<DevicePointRespVO>> devicePointList() {
|
||||
return success( deviceService.devicePointList());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/scheduledStart")
|
||||
public CommonResult<Boolean> scheduledStart(@RequestParam("id") Long id) {
|
||||
return success(deviceService.scheduledStart(id));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/scheduledStop")
|
||||
public CommonResult<Boolean> scheduledStop(@RequestParam("id") Long id) {
|
||||
return success(deviceService.scheduledStop(id));
|
||||
}
|
||||
|
||||
@GetMapping("/device-attribute/batchList")
|
||||
@Operation(summary = "获得多个设备的属性数据")
|
||||
@Parameter(name = "goviewId", description = "大屏ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<List<Map<String, Object>>> getMultiDeviceAttributes(@RequestParam("goviewId") Long goviewId) {
|
||||
return success(deviceService.getMultiDeviceAttributes(goviewId));
|
||||
}
|
||||
|
||||
|
||||
// @PostMapping("/subscribe")
|
||||
// public String subscribeTopic(@RequestParam String topic) {
|
||||
// try {
|
||||
// int result = mqttService.subscribeTopic(topic); // 使用服务层安全订阅
|
||||
// if (result >0 ) {
|
||||
// return "订阅成功: " + topic;
|
||||
// } else {
|
||||
// return "订阅失败: " + topic;
|
||||
// }
|
||||
// } catch (MqttException e) {
|
||||
// return "订阅异常: " + e.getMessage();
|
||||
// }
|
||||
// }
|
||||
|
||||
@PutMapping("/update-enabled")
|
||||
@Operation(summary = "更新任务管理启用状态")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task-management:update')")
|
||||
public CommonResult<Boolean> updateDeviceEnabled(@Valid @RequestBody DeviceUpdateEnabledReqVO updateEnabledReqVO) throws MqttException {
|
||||
deviceService.updateDeviceEnabled(updateEnabledReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.group.IotDeviceGroupPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.group.IotDeviceGroupRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.group.IotDeviceGroupSaveReqVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceGroupDO;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceGroupService;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 设备分组")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device-group")
|
||||
@Validated
|
||||
public class IotDeviceGroupController {
|
||||
|
||||
@Resource
|
||||
private IotDeviceGroupService deviceGroupService;
|
||||
@Resource
|
||||
private IotDeviceService deviceService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备分组")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-group:create')")
|
||||
public CommonResult<Long> createDeviceGroup(@Valid @RequestBody IotDeviceGroupSaveReqVO createReqVO) {
|
||||
return success(deviceGroupService.createDeviceGroup(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新设备分组")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-group:update')")
|
||||
public CommonResult<Boolean> updateDeviceGroup(@Valid @RequestBody IotDeviceGroupSaveReqVO updateReqVO) {
|
||||
deviceGroupService.updateDeviceGroup(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除设备分组")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-group:delete')")
|
||||
public CommonResult<Boolean> deleteDeviceGroup(@RequestParam("id") Long id) {
|
||||
deviceGroupService.deleteDeviceGroup(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得设备分组")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-group:query')")
|
||||
public CommonResult<IotDeviceGroupRespVO> getDeviceGroup(@RequestParam("id") Long id) {
|
||||
IotDeviceGroupDO deviceGroup = deviceGroupService.getDeviceGroup(id);
|
||||
return success(BeanUtils.toBean(deviceGroup, IotDeviceGroupRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备分组分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-group:query')")
|
||||
public CommonResult<PageResult<IotDeviceGroupRespVO>> getDeviceGroupPage(@Valid IotDeviceGroupPageReqVO pageReqVO) {
|
||||
PageResult<IotDeviceGroupDO> pageResult = deviceGroupService.getDeviceGroupPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, IotDeviceGroupRespVO.class,
|
||||
group -> group.setDeviceCount(deviceService.getDeviceCountByGroupId(group.getId()))));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获取设备分组的精简信息列表", description = "只包含被开启的分组,主要用于前端的下拉选项")
|
||||
public CommonResult<List<IotDeviceGroupRespVO>> getSimpleDeviceGroupList() {
|
||||
List<IotDeviceGroupDO> list = deviceGroupService.getDeviceGroupListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(convertList(list, group -> // 只返回 id、name 字段
|
||||
new IotDeviceGroupRespVO().setId(group.getId()).setName(group.getName())));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.modbus.IotDeviceModbusConfigRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.modbus.IotDeviceModbusConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceModbusConfigDO;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceModbusConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 设备 Modbus 连接配置")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device-modbus-config")
|
||||
@Validated
|
||||
public class IotDeviceModbusConfigController {
|
||||
|
||||
@Resource
|
||||
private IotDeviceModbusConfigService modbusConfigService;
|
||||
|
||||
@PostMapping("/save")
|
||||
@Operation(summary = "保存设备 Modbus 连接配置")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:update')")
|
||||
public CommonResult<Boolean> saveDeviceModbusConfig(@Valid @RequestBody IotDeviceModbusConfigSaveReqVO saveReqVO) {
|
||||
modbusConfigService.saveDeviceModbusConfig(saveReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得设备 Modbus 连接配置")
|
||||
@Parameter(name = "id", description = "编号", example = "1024")
|
||||
@Parameter(name = "deviceId", description = "设备编号", example = "2048")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<IotDeviceModbusConfigRespVO> getDeviceModbusConfig(
|
||||
@RequestParam(value = "id", required = false) Long id,
|
||||
@RequestParam(value = "deviceId", required = false) Long deviceId) {
|
||||
IotDeviceModbusConfigDO modbusConfig = null;
|
||||
if (id != null) {
|
||||
modbusConfig = modbusConfigService.getDeviceModbusConfig(id);
|
||||
} else if (deviceId != null) {
|
||||
modbusConfig = modbusConfigService.getDeviceModbusConfigByDeviceId(deviceId);
|
||||
}
|
||||
return success(BeanUtils.toBean(modbusConfig, IotDeviceModbusConfigRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.modbus.IotDeviceModbusPointPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.modbus.IotDeviceModbusPointRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.modbus.IotDeviceModbusPointSaveReqVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceModbusPointDO;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceModbusPointService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 设备 Modbus 点位配置")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device-modbus-point")
|
||||
@Validated
|
||||
public class IotDeviceModbusPointController {
|
||||
|
||||
@Resource
|
||||
private IotDeviceModbusPointService modbusPointService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备 Modbus 点位配置")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:update')")
|
||||
public CommonResult<Long> createDeviceModbusPoint(@Valid @RequestBody IotDeviceModbusPointSaveReqVO createReqVO) {
|
||||
return success(modbusPointService.createDeviceModbusPoint(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新设备 Modbus 点位配置")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:update')")
|
||||
public CommonResult<Boolean> updateDeviceModbusPoint(@Valid @RequestBody IotDeviceModbusPointSaveReqVO updateReqVO) {
|
||||
modbusPointService.updateDeviceModbusPoint(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除设备 Modbus 点位配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:update')")
|
||||
public CommonResult<Boolean> deleteDeviceModbusPoint(@RequestParam("id") Long id) {
|
||||
modbusPointService.deleteDeviceModbusPoint(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得设备 Modbus 点位配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<IotDeviceModbusPointRespVO> getDeviceModbusPoint(@RequestParam("id") Long id) {
|
||||
IotDeviceModbusPointDO modbusPoint = modbusPointService.getDeviceModbusPoint(id);
|
||||
return success(BeanUtils.toBean(modbusPoint, IotDeviceModbusPointRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备 Modbus 点位配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<PageResult<IotDeviceModbusPointRespVO>> getDeviceModbusPointPage(@Valid IotDeviceModbusPointPageReqVO pageReqVO) {
|
||||
PageResult<IotDeviceModbusPointDO> pageResult = modbusPointService.getDeviceModbusPointPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, IotDeviceModbusPointRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,89 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyDetailRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyHistoryListReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyRespVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.model.ThingModelProperty;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO;
|
||||
import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
||||
import cn.iocoder.yudao.module.iot.service.device.property.IotDevicePropertyService;
|
||||
import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 设备属性")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device/property")
|
||||
@Validated
|
||||
public class IotDevicePropertyController {
|
||||
|
||||
@Resource
|
||||
private IotDevicePropertyService devicePropertyService;
|
||||
@Resource
|
||||
private IotThingModelService thingModelService;
|
||||
@Resource
|
||||
private IotDeviceService deviceService;
|
||||
|
||||
@GetMapping("/get-latest")
|
||||
@Operation(summary = "获取设备属性最新属性")
|
||||
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:property-query')")
|
||||
public CommonResult<List<IotDevicePropertyDetailRespVO>> getLatestDeviceProperties(
|
||||
@RequestParam("deviceId") Long deviceId) {
|
||||
// 1.1 获取设备信息
|
||||
IotDeviceDO device = deviceService.getDevice(deviceId);
|
||||
Assert.notNull(device, "设备不存在");
|
||||
// 1.2 获取设备最新属性
|
||||
Map<String, IotDevicePropertyDO> properties = devicePropertyService.getLatestDeviceProperties(deviceId);
|
||||
// 1.3 根据 productId + type 查询属性类型的物模型
|
||||
List<IotThingModelDO> thingModels = thingModelService.getThingModelListByProductIdAndType(
|
||||
device.getProductId(), IotThingModelTypeEnum.PROPERTY.getType());
|
||||
|
||||
// 2. 基于 thingModels 遍历,拼接 properties
|
||||
return success(convertList(thingModels, thingModel -> {
|
||||
ThingModelProperty thingModelProperty = thingModel.getProperty();
|
||||
Assert.notNull(thingModelProperty, "属性不能为空");
|
||||
IotDevicePropertyDetailRespVO result = new IotDevicePropertyDetailRespVO()
|
||||
.setName(thingModel.getName()).setDataType(thingModelProperty.getDataType())
|
||||
.setDataSpecs(thingModelProperty.getDataSpecs())
|
||||
.setDataSpecsList(thingModelProperty.getDataSpecsList());
|
||||
result.setIdentifier(thingModel.getIdentifier());
|
||||
IotDevicePropertyDO property = properties.get(thingModel.getIdentifier());
|
||||
if (property != null) {
|
||||
result.setValue(property.getValue())
|
||||
.setUpdateTime(LocalDateTimeUtil.toEpochMilli(property.getUpdateTime()));
|
||||
}
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
|
||||
@GetMapping("/history-list")
|
||||
@Operation(summary = "获取设备属性历史数据列表")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:property-query')")
|
||||
public CommonResult<List<IotDevicePropertyRespVO>> getHistoryDevicePropertyList(
|
||||
@Valid IotDevicePropertyHistoryListReqVO listReqVO) {
|
||||
return success(devicePropertyService.getHistoryDevicePropertyList(listReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class TDengineConfig {
|
||||
|
||||
@Bean("tdengineJdbcTemplate")
|
||||
public JdbcTemplate tdengineJdbcTemplate(DataSource dataSource) {
|
||||
// 此处的dataSource会自动注入上面在yml中配置的TDengine数据源
|
||||
return new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
// @Bean(name = "tdengineDataSource")
|
||||
// @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.tdengine")
|
||||
// public DataSource tdengineDataSource() {
|
||||
// return DataSourceBuilder.create().build();
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 设备运行报警状态枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DeviceBasicStatusEnum {
|
||||
/**
|
||||
* 运行状态
|
||||
*/
|
||||
RUNNING("1", "运行", "RUNNING"),
|
||||
|
||||
/**
|
||||
* 报警状态
|
||||
*/
|
||||
ALARM("2", "报警", "ALARM");
|
||||
|
||||
/**
|
||||
* 状态编码
|
||||
*/
|
||||
private final String code;
|
||||
|
||||
/**
|
||||
* 状态名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* 状态描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* 根据编码获取枚举
|
||||
*/
|
||||
public static DeviceBasicStatusEnum getByCode(Integer code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (DeviceBasicStatusEnum status : values()) {
|
||||
if (status.getCode().equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据描述获取枚举
|
||||
*/
|
||||
public static DeviceBasicStatusEnum getByDescription(String description) {
|
||||
if (description == null || description.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (DeviceBasicStatusEnum status : values()) {
|
||||
if (status.getDescription().equalsIgnoreCase(description.trim())) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查编码是否有效
|
||||
*/
|
||||
public static boolean isValidCode(Integer code) {
|
||||
return getByCode(code) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.enums;
|
||||
|
||||
/**
|
||||
* Java 基本类型对应 TDengine 列类型枚举
|
||||
*/
|
||||
public enum JavaToTdengineTypeEnum {
|
||||
|
||||
BYTE("byte", "TINYINT") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Byte.parseByte(value);
|
||||
}
|
||||
},
|
||||
|
||||
SHORT("short", "SMALLINT") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Short.parseShort(value);
|
||||
}
|
||||
},
|
||||
|
||||
INT("int", "INT") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
},
|
||||
|
||||
LONG("long", "BIGINT") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Long.parseLong(value);
|
||||
}
|
||||
},
|
||||
|
||||
FLOAT("float", "FLOAT") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Float.parseFloat(value);
|
||||
}
|
||||
},
|
||||
|
||||
DOUBLE("double", "DOUBLE") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Double.parseDouble(value);
|
||||
}
|
||||
},
|
||||
|
||||
BOOLEAN("boolean", "BOOL") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return Boolean.parseBoolean(value);
|
||||
}
|
||||
},
|
||||
|
||||
CHAR("char", "NCHAR(1)") {
|
||||
@Override
|
||||
public Object convertValue(String value) {
|
||||
return value.charAt(0);
|
||||
}
|
||||
};
|
||||
|
||||
private final String javaType;
|
||||
private final String tdType;
|
||||
|
||||
JavaToTdengineTypeEnum(String javaType, String tdType) {
|
||||
this.javaType = javaType;
|
||||
this.tdType = tdType;
|
||||
}
|
||||
|
||||
public String getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
public String getTdType() {
|
||||
return tdType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个枚举实现自己的值转换
|
||||
*/
|
||||
public abstract Object convertValue(String value);
|
||||
|
||||
/**
|
||||
* 根据 javaType 获取枚举
|
||||
*/
|
||||
public static JavaToTdengineTypeEnum fromJavaType(String javaType) {
|
||||
|
||||
if (javaType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (JavaToTdengineTypeEnum e : values()) {
|
||||
|
||||
if (e.javaType.equalsIgnoreCase(javaType)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 javaType 获取 TDengine 类型
|
||||
*/
|
||||
public static String getTdTypeByJavaType(String javaType) {
|
||||
|
||||
JavaToTdengineTypeEnum e = fromJavaType(javaType);
|
||||
|
||||
return e != null ? e.getTdType() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 javaType 转换 value
|
||||
*/
|
||||
public static Object convertValue(String javaType, String value) {
|
||||
|
||||
try {
|
||||
|
||||
JavaToTdengineTypeEnum e = fromJavaType(javaType);
|
||||
|
||||
if (e == null) {
|
||||
return Double.parseDouble(value);
|
||||
}
|
||||
|
||||
return e.convertValue(value);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
throw new RuntimeException(
|
||||
"数据类型转换失败: javaType=" + javaType + ", value=" + value, ex
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
// TaskTypeEnum.java
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TaskTypeEnum {
|
||||
|
||||
DEVICE("DEVICE", "设备数据采集"),
|
||||
WORK_ORDER("WORK_ORDER", "工单生成");
|
||||
|
||||
/**
|
||||
* 任务类型编码
|
||||
*/
|
||||
private final String code;
|
||||
|
||||
/**
|
||||
* 任务类型名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* 根据编码获取枚举
|
||||
*/
|
||||
public static TaskTypeEnum getByCode(String code) {
|
||||
for (TaskTypeEnum type : values()) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查编码是否存在
|
||||
*/
|
||||
public static boolean contains(String code) {
|
||||
return getByCode(code) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成任务ID
|
||||
*/
|
||||
public Long generateTaskId(Long baseId) {
|
||||
if (baseId == null) {
|
||||
baseId = 0L;
|
||||
}
|
||||
|
||||
switch (this) {
|
||||
case DEVICE:
|
||||
return 1000000L + baseId;
|
||||
case WORK_ORDER:
|
||||
return 2000000L + baseId;
|
||||
default:
|
||||
return 9000000L + baseId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.scheduled.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class SchedulerConfig {
|
||||
|
||||
@Bean
|
||||
public TaskScheduler taskScheduler() {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setPoolSize(50); // 增加线程数
|
||||
scheduler.setThreadNamePrefix("scheduled-task-");
|
||||
scheduler.setAwaitTerminationSeconds(60);
|
||||
scheduler.setWaitForTasksToCompleteOnShutdown(true);
|
||||
|
||||
// 设置队列容量
|
||||
scheduler.setPoolSize(50);
|
||||
scheduler.setThreadPriority(Thread.NORM_PRIORITY);
|
||||
scheduler.setDaemon(false);
|
||||
scheduler.initialize();
|
||||
return scheduler;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.scheduled.core;
|
||||
|
||||
public interface Task {
|
||||
|
||||
/**
|
||||
* 执行任务
|
||||
*/
|
||||
void execute(Long taskId, String taskParam);
|
||||
|
||||
/**
|
||||
* 获取任务类型
|
||||
*/
|
||||
String getTaskType();
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 设备运行状态 Resp VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DeviceOperationStatusRespVO {
|
||||
|
||||
@Schema(description = "总设备数")
|
||||
private int totalDevices;
|
||||
|
||||
@Schema(description = "运行")
|
||||
private int runningCount;
|
||||
|
||||
@Schema(description = "待机中(不运行、没故障)")
|
||||
private int standbyCount;
|
||||
|
||||
@Schema(description = "故障中(故障且待机)")
|
||||
private int faultCount;
|
||||
|
||||
@Schema(description = "报警中(故障且运行)")
|
||||
private int warningCount;
|
||||
|
||||
@Schema(description = "利用率")
|
||||
private String utilizationRate;
|
||||
|
||||
@Schema(description = "故障率")
|
||||
private String faultRate;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue