delete old iot device

plp
chenshuichuan 2 years ago
parent 101a3084a0
commit 7450017d0c

@ -27,34 +27,17 @@ CREATE TABLE `iot_iot_organization`
CREATE TABLE `iot_device` CREATE TABLE `iot_device`
( (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`device_config_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备配置id',
`device_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备编号', `device_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备编号',
`device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备名称', `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备名称',
`device_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备类型', `device_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备类型',
`siemens_series` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Siemens系列(S7-300、S7-1500)', `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '状态',
`siemens_connect_param` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '连接参数(波特率,数据位,停止位,校验位 例如960081N', `read_topic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读主题',
`read_cron_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读取任务方式(0无1有)', `write_topic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '写主题',
`read_repeat_value` int DEFAULT NULL COMMENT '读取任务时间间隔',
`read_repeat_unit` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读取任务时间间隔单位',
`read_cron` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读取任务时间表达式',
`write_cron_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '写入任务时间间隔',
`write_repeat_value` int DEFAULT NULL COMMENT '写入任务时间间隔',
`write_repeat_unit` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '写入任务时间间隔单位',
`write_cron` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '写入任务时间表达式',
`local_persistent` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否持久化(0不持久化1持久化)',
`upload_rate` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '上传方式(1实时2自定义)',
`rate_count` int DEFAULT NULL COMMENT '上传频率',
`modbus_protocol` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'modbus协议类型(serial-rtu)',
`modbus_pattern` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'modbus模式(client)',
`port_name` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'modbus串口号',
`modbus_connect_param` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '连接参数(波特率,数据位,停止位,校验位 例如960081N',
`modbus_read_addr_gap` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读地址是否连续(0否1是)',
`is_upload` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否已下发(0下,1没下)',
`gateway_id` bigint NOT NULL COMMENT '网关id', `gateway_id` bigint NOT NULL COMMENT '网关id',
`org_id` bigint NOT NULL COMMENT '组织设备id', `device_brand_id` bigint NOT NULL COMMENT '设备品牌id',
`off_line_duration` bigint NOT NULL COMMENT '离线间隔',
`last_online_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后上线时间',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注', `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
`is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用', `is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
@ -64,50 +47,26 @@ CREATE TABLE `iot_device`
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint DEFAULT NULL COMMENT '租户id', `tenant_id` bigint DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='物联设备表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='物联设备表';
CREATE TABLE `iot_device_attribute` CREATE TABLE `iot_device_attribute`
( (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`attribute_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '地址编码', `attribute_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '属性编码',
`address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', `attribute_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '属性名称',
`attribute_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '地址名称', `address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'PLC点位地址',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址描述', `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址描述',
`address_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址类型', `attribute_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址类型',
`address_offset` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址偏移',
`address2_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址2类型',
`address2_offset` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址2偏移',
`group_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属组',
`group_id` int DEFAULT NULL COMMENT '所属组id',
`security_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '安全类别',
`io_status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写状态',
`is_linear_transfer` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否线性换算(0是1否)',
`data_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '数据类型',
`unit` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '单位',
`in_min_value` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '输入最小值',
`in_max_value` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '输入最大值',
`out_min_value` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '输出最小值',
`out_max_value` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '输出最大值',
`out_data_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '输出数据类型',
`siemens_field_precision` int DEFAULT '0' COMMENT '精度',
`modbus_slave_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '站号',
`modbus_field_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '寄存器地址',
`modbus_address_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '寄存器类型',
`modbus_field_size` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '个数',
`modbus_field_precision` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '缩放因子默认值为1大于0的小数',
`modbus_field_order` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '字节顺序',
`dept_id` int DEFAULT NULL COMMENT '组织机构',
`dept_name` varchar(255) DEFAULT NULL COMMENT '组织名称',
`source_data_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'mqtt进制类型binary,octal,hexadecimal,decimal',
`transfer_data_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '转化进制类型binary,octal,hexadecimal,decimal',
`cal_addresses` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址合并计算公式',
`factor` varchar(32) DEFAULT NULL COMMENT '系数',
`io_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写方式',
`data_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '数据类型',
`data_type_remark` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '类型描述',
`data_unit` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '单位',
`data_formula` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '数据计算公式',
`gateway_id` bigint NOT NULL COMMENT '网关id', `gateway_id` bigint NOT NULL COMMENT '网关id',
`device_id` bigint NOT NULL COMMENT '设备id', `device_id` bigint NOT NULL COMMENT '设备id',
`org_id` bigint NOT NULL COMMENT '组织设备id', `alert_id` bigint NOT NULL COMMENT '告警id',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注', `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
`is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用', `is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用',
@ -118,8 +77,65 @@ CREATE TABLE `iot_device_attribute`
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint DEFAULT NULL COMMENT '租户id', `tenant_id` bigint DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='设备属性表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='设备属性表';
CREATE TABLE `iot_alert`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`alert_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '编码',
`alert_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称',
`alert_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警类型',
`alert_level` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警等级',
`content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警内容',
`condition` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警条件',
`condition_formula` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逻辑表达式',
`alert_audio` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '告警音频',
`is_repeat` bit(1) NOT NULL DEFAULT b'1' COMMENT '重复告警',
`no_repeat_duration` bigint NOT NULL COMMENT '不重复间隔',
`is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='告警配置';
CREATE TABLE `iot_alert_record`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`alert_id` bigint NOT NULL COMMENT '告警ID',
`alert_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '编码',
`alert_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称',
`alert_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警类型',
`alert_level` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警等级',
`content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警内容',
`condition` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '告警条件',
`condition_formula` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逻辑表达式',
`alert_audio` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '告警音频',
`is_repeat` bit(1) NOT NULL DEFAULT b'1' COMMENT '重复告警',
`no_repeat_duration` bigint NOT NULL COMMENT '不重复间隔',
`data_value` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '数据值',
`data_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '数据类型',
`data_unit` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '单位',
`data_id` bigint NOT NULL COMMENT '来源ID',
`data_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源编码',
`data_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源名称',
`data_type_remark` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '描述',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='告警记录';
CREATE TABLE `iot_formula` CREATE TABLE `iot_formula`

@ -1,152 +0,0 @@
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.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DevicePageReqVO;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DeviceRespVO;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DeviceSaveReqVO;
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.gateway.GatewayDO;
import cn.iocoder.yudao.module.iot.service.device.DeviceService;
import cn.iocoder.yudao.module.iot.service.gateway.GatewayService;
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.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
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 GatewayService gatewayService;
@PostMapping("/create")
@Operation(summary = "创建物联设备")
@PreAuthorize("@ss.hasPermission('iot:device:create')")
public CommonResult<Long> createDevice(@Valid @RequestBody DeviceSaveReqVO createReqVO) {
return success(deviceService.createDevice(createReqVO));
}
@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 = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('iot:device:delete')")
public CommonResult<Boolean> deleteDevice(@RequestParam("id") Long id) {
deviceService.deleteDevice(id);
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) {
DeviceDO device = deviceService.getDevice(id);
return success(BeanUtils.toBean(device, DeviceRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得物联设备分页")
@PreAuthorize("@ss.hasPermission('iot:device:query')")
public CommonResult<PageResult<DeviceRespVO>> getDevicePage(@Valid DevicePageReqVO pageReqVO) {
PageResult<DeviceDO> pageResult = deviceService.getDevicePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, DeviceRespVO.class));
}
@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 {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<DeviceDO> list = deviceService.getDevicePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "物联设备.xls", "数据", DeviceRespVO.class,
BeanUtils.toBean(list, DeviceRespVO.class));
}
@GetMapping("/pushDevice")
@Operation(summary = "下发物联设备配置到网关")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('iot:device:update')")
public CommonResult<String> pushDevice(@RequestParam("id") Long id) {
DeviceDO device = deviceService.getDevice(id);
GatewayDO gatewayDO = gatewayService.getGateway(device.getGatewayId());
return deviceService.pushDevice(device, gatewayDO);
}
// ==================== 子表(设备属性) ====================
@GetMapping("/device-attribute/page")
@Operation(summary = "获得设备属性分页")
@Parameter(name = "deviceId", description = "设备id")
@PreAuthorize("@ss.hasPermission('iot:device:query')")
public CommonResult<PageResult<DeviceAttributeDO>> getDeviceAttributePage(PageParam pageReqVO,
@RequestParam("deviceId") Long deviceId) {
return success(deviceService.getDeviceAttributePage(pageReqVO, deviceId));
}
@PostMapping("/device-attribute/create")
@Operation(summary = "创建设备属性")
@PreAuthorize("@ss.hasPermission('iot:device:create')")
public CommonResult<Long> createDeviceAttribute(@Valid @RequestBody DeviceAttributeDO deviceAttribute) {
DeviceDO deviceDO = deviceService.getDevice(deviceAttribute.getDeviceId());
deviceAttribute.setDeviceCode(deviceDO.getDeviceCode());
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));
}
}

@ -1,128 +0,0 @@
package cn.iocoder.yudao.module.iot.controller.admin.device.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
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 = "管理后台 - 物联设备分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DevicePageReqVO extends PageParam {
@Schema(description = "设备配置id", example = "14050")
private String deviceConfigId;
@Schema(description = "设备编号")
private String deviceCode;
@Schema(description = "设备名称", example = "李四")
private String deviceName;
@Schema(description = "设备类型", example = "2")
private String deviceType;
@Schema(description = "Siemens系列(S7-300、S7-1500)")
private String siemensSeries;
@Schema(description = "连接参数(波特率,数据位,停止位,校验位 例如960081N")
private String siemensConnectParam;
@Schema(description = "读取任务方式(0无1有)", example = "2")
private String readCronType;
@Schema(description = "读取任务时间间隔")
private Integer readRepeatValue;
@Schema(description = "读取任务时间间隔单位")
private String readRepeatUnit;
@Schema(description = "读取任务时间表达式")
private String readCron;
@Schema(description = "写入任务时间间隔", example = "1")
private String writeCronType;
@Schema(description = "写入任务时间间隔")
private Integer writeRepeatValue;
@Schema(description = "写入任务时间间隔单位")
private String writeRepeatUnit;
@Schema(description = "写入任务时间表达式")
private String writeCron;
@Schema(description = "是否持久化(0不持久化1持久化)")
private String localPersistent;
@Schema(description = "上传方式(1实时2自定义)")
private String uploadRate;
@Schema(description = "上传频率", example = "19796")
private Integer rateCount;
@Schema(description = "modbus协议类型(serial-rtu)")
private String modbusProtocol;
@Schema(description = "modbus模式(client)")
private String modbusPattern;
@Schema(description = "modbus串口号", example = "李四")
private String portName;
@Schema(description = "连接参数(波特率,数据位,停止位,校验位 例如960081N")
private String modbusConnectParam;
@Schema(description = "读地址是否连续(0否1是)")
private String modbusReadAddrGap;
@Schema(description = "是否已下发(0下,1没下)")
private String isUpload;
@Schema(description = "网关id", example = "6304")
private Long gatewayId;
@Schema(description = "组织设备id", example = "23150")
private Long orgId;
@Schema(description = "备注", example = "你猜")
private String remark;
@Schema(description = "是否启用")
private Boolean isEnable;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "数采设备类型", example = "2")
private String deviceUseType;
@Schema(description = "ap_ip")
private String apIp;
@Schema(description = "网桥ip")
private String gateBridgeIp;
@Schema(description = "串口服务器IP")
private String comServerIp;
@Schema(description = "串口服务器端口")
private String comServerPort;
@Schema(description = "PLC控制器地址")
private String plcControllerIp;
@Schema(description = "PLC触控屏地址")
private String plcScreenIp;
@Schema(description = "i机台id", example = "18776")
private Long orgMachineId;
}

@ -1,175 +0,0 @@
package cn.iocoder.yudao.module.iot.controller.admin.device.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 物联设备 Response VO")
@Data
@ExcelIgnoreUnannotated
public class DeviceRespVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8540")
@ExcelProperty("ID")
private Long id;
@Schema(description = "设备配置id", example = "14050")
@ExcelProperty("设备配置id")
private String deviceConfigId;
@Schema(description = "设备编号")
@ExcelProperty("设备编号")
private String deviceCode;
@Schema(description = "设备名称", example = "李四")
@ExcelProperty("设备名称")
private String deviceName;
@Schema(description = "设备类型", example = "2")
@ExcelProperty("设备类型")
private String deviceType;
@Schema(description = "Siemens系列(S7-300、S7-1500)")
@ExcelProperty(value = "Siemens系列(S7-300、S7-1500)", converter = DictConvert.class)
@DictFormat("iot_siemens_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String siemensSeries;
@Schema(description = "连接参数(波特率,数据位,停止位,校验位 例如960081N")
@ExcelProperty("连接参数(波特率,数据位,停止位,校验位 例如960081N")
private String siemensConnectParam;
@Schema(description = "读取任务方式(0无1有)", example = "2")
@ExcelProperty(value = "读取任务方式(0无1有)", converter = DictConvert.class)
@DictFormat("iot_1_or_0") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String readCronType;
@Schema(description = "读取任务时间间隔")
@ExcelProperty("读取任务时间间隔")
private Integer readRepeatValue;
@Schema(description = "读取任务时间间隔单位")
@ExcelProperty(value = "读取任务时间间隔单位", converter = DictConvert.class)
@DictFormat("iot_device_data_unit") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String readRepeatUnit;
@Schema(description = "读取任务时间表达式")
@ExcelProperty("读取任务时间表达式")
private String readCron;
@Schema(description = "写入任务时间间隔", example = "1")
@ExcelProperty("写入任务时间间隔")
private String writeCronType;
@Schema(description = "写入任务时间间隔")
@ExcelProperty("写入任务时间间隔")
private Integer writeRepeatValue;
@Schema(description = "写入任务时间间隔单位")
@ExcelProperty("写入任务时间间隔单位")
private String writeRepeatUnit;
@Schema(description = "写入任务时间表达式")
@ExcelProperty("写入任务时间表达式")
private String writeCron;
@Schema(description = "是否持久化(0不持久化1持久化)")
@ExcelProperty(value = "是否持久化(0不持久化1持久化)", converter = DictConvert.class)
@DictFormat("iot_1_or_0") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String localPersistent;
@Schema(description = "上传方式(1实时2自定义)")
@ExcelProperty(value = "上传方式(1实时2自定义)", converter = DictConvert.class)
@DictFormat("iot_device_uploading_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String uploadRate;
@Schema(description = "上传频率", example = "19796")
@ExcelProperty("上传频率")
private Integer rateCount;
@Schema(description = "modbus协议类型(serial-rtu)")
@ExcelProperty(value = "modbus协议类型(serial-rtu)", converter = DictConvert.class)
@DictFormat("iot_modbus_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String modbusProtocol;
@Schema(description = "modbus模式(client)")
@ExcelProperty(value = "modbus模式(client)", converter = DictConvert.class)
@DictFormat("iot_modbus_mold") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String modbusPattern;
@Schema(description = "modbus串口号", example = "李四")
@ExcelProperty(value = "modbus串口号", converter = DictConvert.class)
@DictFormat("iot_modbus_port") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String portName;
@Schema(description = "连接参数(波特率,数据位,停止位,校验位 例如960081N")
@ExcelProperty("连接参数(波特率,数据位,停止位,校验位 例如960081N")
private String modbusConnectParam;
@Schema(description = "读地址是否连续(0否1是)")
@ExcelProperty(value = "读地址是否连续(0否1是)", converter = DictConvert.class)
@DictFormat("iot_1_or_0") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String modbusReadAddrGap;
@Schema(description = "是否已下发(0下,1没下)")
@ExcelProperty(value = "是否已下发(0下,1没下)", converter = DictConvert.class)
@DictFormat("iot_1_or_0") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String isUpload;
@Schema(description = "网关id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6304")
@ExcelProperty("网关id")
private Long gatewayId;
@Schema(description = "组织设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23150")
@ExcelProperty("组织设备id")
private Long orgId;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否启用")
private Boolean isEnable;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "数采设备类型", example = "2")
@ExcelProperty(value = "数采设备类型", converter = DictConvert.class)
@DictFormat("iot_device_use_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String deviceUseType;
@Schema(description = "ap_ip")
@ExcelProperty("ap_ip")
private String apIp;
@Schema(description = "网桥ip")
@ExcelProperty("网桥ip")
private String gateBridgeIp;
@Schema(description = "串口服务器IP")
@ExcelProperty("串口服务器IP")
private String comServerIp;
@Schema(description = "串口服务器端口")
@ExcelProperty("串口服务器端口")
private String comServerPort;
@Schema(description = "PLC控制器地址")
@ExcelProperty("PLC控制器地址")
private String plcControllerIp;
@Schema(description = "PLC触控屏地址")
@ExcelProperty("PLC触控屏地址")
private String plcScreenIp;
@Schema(description = "i机台id", example = "18776")
@ExcelProperty("i机台id")
private Long orgMachineId;
}

@ -1,122 +0,0 @@
package cn.iocoder.yudao.module.iot.controller.admin.device.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 物联设备新增/修改 Request VO")
@Data
public class DeviceSaveReqVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8540")
private Long id;
@Schema(description = "设备配置id", example = "14050")
private String deviceConfigId;
@Schema(description = "设备编号")
private String deviceCode;
@Schema(description = "设备名称", example = "李四")
private String deviceName;
@Schema(description = "设备类型", example = "2")
private String deviceType;
@Schema(description = "Siemens系列(S7-300、S7-1500)")
private String siemensSeries;
@Schema(description = "连接参数(波特率,数据位,停止位,校验位 例如960081N")
private String siemensConnectParam;
@Schema(description = "读取任务方式(0无1有)", example = "2")
private String readCronType;
@Schema(description = "读取任务时间间隔")
private Integer readRepeatValue;
@Schema(description = "读取任务时间间隔单位")
private String readRepeatUnit;
@Schema(description = "读取任务时间表达式")
private String readCron;
@Schema(description = "写入任务时间间隔", example = "1")
private String writeCronType;
@Schema(description = "写入任务时间间隔")
private Integer writeRepeatValue;
@Schema(description = "写入任务时间间隔单位")
private String writeRepeatUnit;
@Schema(description = "写入任务时间表达式")
private String writeCron;
@Schema(description = "是否持久化(0不持久化1持久化)")
private String localPersistent;
@Schema(description = "上传方式(1实时2自定义)")
private String uploadRate;
@Schema(description = "上传频率", example = "19796")
private Integer rateCount;
@Schema(description = "modbus协议类型(serial-rtu)")
private String modbusProtocol;
@Schema(description = "modbus模式(client)")
private String modbusPattern;
@Schema(description = "modbus串口号", example = "李四")
private String portName;
@Schema(description = "连接参数(波特率,数据位,停止位,校验位 例如960081N")
private String modbusConnectParam;
@Schema(description = "读地址是否连续(0否1是)")
private String modbusReadAddrGap;
@Schema(description = "是否已下发(0下,1没下)")
private String isUpload;
@Schema(description = "网关id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6304")
@NotNull(message = "网关id不能为空")
private Long gatewayId;
@Schema(description = "组织设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23150")
@NotNull(message = "组织设备id不能为空")
private Long orgId;
@Schema(description = "备注", example = "你猜")
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean isEnable;
@Schema(description = "数采设备类型", example = "2")
private String deviceUseType;
@Schema(description = "ap_ip")
private String apIp;
@Schema(description = "网桥ip")
private String gateBridgeIp;
@Schema(description = "串口服务器IP")
private String comServerIp;
@Schema(description = "串口服务器端口")
private String comServerPort;
@Schema(description = "PLC控制器地址")
private String plcControllerIp;
@Schema(description = "PLC触控屏地址")
private String plcScreenIp;
@Schema(description = "i机台id", example = "18776")
private Long orgMachineId;
}

@ -1,4 +0,0 @@
/**
* TODO
*/
package cn.iocoder.yudao.module.iot.dal.dataobject.ajreport;

@ -1,180 +0,0 @@
package cn.iocoder.yudao.module.iot.dal.dataobject.device;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* DO
*
* @author
*/
@TableName("iot_device_attribute")
@KeySequence("iot_device_attribute_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeviceAttributeDO extends BaseDO {
/**
* ID
*/
@TableId
private Long id;
/**
*
*/
private String attributeCode;
/**
*
*/
private String address;
/**
*
*/
private String attributeName;
/**
*
*/
private String description;
/**
*
*/
private String addressType;
/**
*
*/
private String addressOffset;
/**
* 2
*/
private String address2Type;
/**
* 2
*/
private String address2Offset;
/**
*
*/
private String groupName;
/**
* id
*/
private Integer groupId;
/**
*
*/
private String securityType;
/**
*
*/
private String ioStatus;
/**
* 线(01)
* <p>
* {@link TODO iot_1_or_0 }
*/
private String isLinearTransfer;
/**
*
* <p>
* {@link TODO iot_device_data_type }
*/
private String dataType;
/**
*
*/
private String unit;
/**
*
*/
private String inMinValue;
/**
*
*/
private String inMaxValue;
/**
*
*/
private String outMinValue;
/**
*
*/
private String outMaxValue;
/**
*
*/
private String outDataType;
/**
*
*/
private Integer siemensFieldPrecision;
/**
*
*/
private String modbusSlaveId;
/**
*
*/
private String modbusFieldAddress;
/**
*
*/
private String modbusAddressType;
/**
*
*/
private Integer modbusFieldSize;
/**
* 10
*/
private String modbusFieldPrecision;
/**
*
*/
private String modbusFieldOrder;
/**
* mqttbinary,octal,hexadecimal,decimal
*/
private String sourceDataType;
/**
* binary,octal,hexadecimal,decimal
* <p>
* {@link TODO iot_device_data_transfer_type }
*/
private String transferDataType;
/**
*
*/
private String factor;
/**
* id
*/
private Long gatewayId;
/**
* id
*/
private Long deviceId;
/**
* code
*/
private String deviceCode;
/**
* id
*/
private Long orgId;
/**
*
*/
private String remark;
/**
*
*/
private Boolean isEnable;
}

@ -1,180 +0,0 @@
package cn.iocoder.yudao.module.iot.dal.dataobject.device;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* DO
*
* @author
*/
@TableName("iot_device")
@KeySequence("iot_device_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeviceDO extends BaseDO {
/**
* ID
*/
@TableId
private Long id;
/**
* id
*/
private String deviceConfigId;
/**
*
*/
private String deviceCode;
/**
*
*/
private String deviceName;
/**
*
*/
private String deviceType;
/**
* Siemens(S7-300S7-1500)
* <p>
* {@link TODO iot_siemens_type }
*/
private String siemensSeries;
/**
* ( 960081N
*/
private String siemensConnectParam;
/**
* (01)
* <p>
* {@link TODO iot_1_or_0 }
*/
private String readCronType;
/**
*
*/
private Integer readRepeatValue;
/**
*
* <p>
* {@link TODO iot_device_data_unit }
*/
private String readRepeatUnit;
/**
*
*/
private String readCron;
/**
*
*/
private String writeCronType;
/**
*
*/
private Integer writeRepeatValue;
/**
*
*/
private String writeRepeatUnit;
/**
*
*/
private String writeCron;
/**
* (01)
* <p>
* {@link TODO iot_1_or_0 }
*/
private String localPersistent;
/**
* (12)
* <p>
* {@link TODO iot_device_uploading_type }
*/
private String uploadRate;
/**
*
*/
private Integer rateCount;
/**
* modbus(serial-rtu)
* <p>
* {@link TODO iot_modbus_type }
*/
private String modbusProtocol;
/**
* modbus(client)
* <p>
* {@link TODO iot_modbus_mold }
*/
private String modbusPattern;
/**
* modbus
* <p>
* {@link TODO iot_modbus_port }
*/
private String portName;
/**
* ( 960081N
*/
private String modbusConnectParam;
/**
* (01)
* <p>
* {@link TODO iot_1_or_0 }
*/
private String modbusReadAddrGap;
/**
* (0,1)
* <p>
* {@link TODO iot_1_or_0 }
*/
private String isUpload;
/**
* id
*/
private Long gatewayId;
/**
* id
*/
private Long orgId;
/**
*
*/
private String remark;
/**
*
*/
private Boolean isEnable;
//@Schema(description = "数采设备类型", example = "2")
private String deviceUseType;
//@Schema(description = "ap_ip")
private String apIp;
//@Schema(description = "网桥ip")
private String gateBridgeIp;
//@Schema(description = "串口服务器IP")
private String comServerIp;
//@Schema(description = "串口服务器端口")
private String comServerPort;
//@Schema(description = "PLC控制器地址")
private String plcControllerIp;
//@Schema(description = "PLC触控屏地址")
private String plcScreenIp;
//@Schema(description = "i机台id", example = "18776")
private Long orgMachineId;
}

@ -1,4 +0,0 @@
/**
* TODO
*/
package cn.iocoder.yudao.module.iot.dal.mysql.ajreport;

@ -1,33 +0,0 @@
package cn.iocoder.yudao.module.iot.dal.mysql.device;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceAttributeDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper
*
* @author
*/
@Mapper
public interface DeviceAttributeMapper extends BaseMapperX<DeviceAttributeDO> {
default PageResult<DeviceAttributeDO> selectPage(PageParam reqVO, Long deviceId) {
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceAttributeDO>()
.eq(DeviceAttributeDO::getDeviceId, deviceId)
.orderByDesc(DeviceAttributeDO::getId));
}
default int deleteByDeviceId(Long deviceId) {
return delete(DeviceAttributeDO::getDeviceId, deviceId);
}
default List<DeviceAttributeDO> selectByDeviceId(Long deviceId) {
return selectList(DeviceAttributeDO::getDeviceId, deviceId);
}
}

@ -1,67 +0,0 @@
package cn.iocoder.yudao.module.iot.dal.mysql.device;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DevicePageReqVO;
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper
*
* @author
*/
@Mapper
public interface DeviceMapper extends BaseMapperX<DeviceDO> {
default PageResult<DeviceDO> selectPage(DevicePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceDO>()
.eqIfPresent(DeviceDO::getDeviceConfigId, reqVO.getDeviceConfigId())
.eqIfPresent(DeviceDO::getDeviceCode, reqVO.getDeviceCode())
.likeIfPresent(DeviceDO::getDeviceName, reqVO.getDeviceName())
.eqIfPresent(DeviceDO::getDeviceType, reqVO.getDeviceType())
.eqIfPresent(DeviceDO::getSiemensSeries, reqVO.getSiemensSeries())
.eqIfPresent(DeviceDO::getSiemensConnectParam, reqVO.getSiemensConnectParam())
.eqIfPresent(DeviceDO::getReadCronType, reqVO.getReadCronType())
.eqIfPresent(DeviceDO::getReadRepeatValue, reqVO.getReadRepeatValue())
.eqIfPresent(DeviceDO::getReadRepeatUnit, reqVO.getReadRepeatUnit())
.eqIfPresent(DeviceDO::getReadCron, reqVO.getReadCron())
.eqIfPresent(DeviceDO::getWriteCronType, reqVO.getWriteCronType())
.eqIfPresent(DeviceDO::getWriteRepeatValue, reqVO.getWriteRepeatValue())
.eqIfPresent(DeviceDO::getWriteRepeatUnit, reqVO.getWriteRepeatUnit())
.eqIfPresent(DeviceDO::getWriteCron, reqVO.getWriteCron())
.eqIfPresent(DeviceDO::getLocalPersistent, reqVO.getLocalPersistent())
.eqIfPresent(DeviceDO::getUploadRate, reqVO.getUploadRate())
.eqIfPresent(DeviceDO::getRateCount, reqVO.getRateCount())
.eqIfPresent(DeviceDO::getModbusProtocol, reqVO.getModbusProtocol())
.eqIfPresent(DeviceDO::getModbusPattern, reqVO.getModbusPattern())
.eqIfPresent(DeviceDO::getPortName, reqVO.getPortName())
.eqIfPresent(DeviceDO::getModbusConnectParam, reqVO.getModbusConnectParam())
.eqIfPresent(DeviceDO::getModbusReadAddrGap, reqVO.getModbusReadAddrGap())
.eqIfPresent(DeviceDO::getIsUpload, reqVO.getIsUpload())
.eqIfPresent(DeviceDO::getGatewayId, reqVO.getGatewayId())
.eqIfPresent(DeviceDO::getOrgId, reqVO.getOrgId())
.eqIfPresent(DeviceDO::getRemark, reqVO.getRemark())
.eqIfPresent(DeviceDO::getIsEnable, reqVO.getIsEnable())
.betweenIfPresent(DeviceDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DeviceDO::getId));
}
default PageResult<DeviceDO> selectPage(PageParam reqVO, Long gatewayId) {
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceDO>()
.eq(DeviceDO::getGatewayId, gatewayId)
.orderByDesc(DeviceDO::getId));
}
default int deleteByGatewayId(Long gatewayId) {
return delete(DeviceDO::getGatewayId, gatewayId);
}
default List<DeviceDO> selectByGatewayId(Long gatewayId) {
return selectList(DeviceDO::getGatewayId, gatewayId);
}
}

@ -1,4 +0,0 @@
/**
* TODO
*/
package cn.iocoder.yudao.module.iot.service.ajreport;

@ -1,102 +0,0 @@
package cn.iocoder.yudao.module.iot.service.device;
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.module.iot.controller.admin.device.vo.DevicePageReqVO;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DeviceSaveReqVO;
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.gateway.GatewayDO;
import javax.validation.Valid;
/**
* Service
*
* @author
*/
public interface DeviceService {
/**
*
*
* @param createReqVO
* @return
*/
Long createDevice(@Valid DeviceSaveReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateDevice(@Valid DeviceSaveReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteDevice(Long id);
/**
*
*
* @param id
* @return
*/
DeviceDO getDevice(Long id);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<DeviceDO> getDevicePage(DevicePageReqVO pageReqVO);
CommonResult<String> pushDevice(DeviceDO deviceDO, GatewayDO gatewayDO);
// ==================== 子表(设备属性) ====================
/**
*
*
* @param pageReqVO
* @param deviceId id
* @return
*/
PageResult<DeviceAttributeDO> getDeviceAttributePage(PageParam pageReqVO, Long deviceId);
/**
*
*
* @param deviceAttribute
* @return
*/
Long createDeviceAttribute(@Valid DeviceAttributeDO deviceAttribute);
/**
*
*
* @param deviceAttribute
*/
void updateDeviceAttribute(@Valid DeviceAttributeDO deviceAttribute);
/**
*
*
* @param id
*/
void deleteDeviceAttribute(Long id);
/**
*
*
* @param id
* @return
*/
DeviceAttributeDO getDeviceAttribute(Long id);
}

@ -1,189 +0,0 @@
package cn.iocoder.yudao.module.iot.service.device;
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.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DevicePageReqVO;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.DeviceSaveReqVO;
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.gateway.GatewayDO;
import cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceAttributeMapper;
import cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceMapper;
import cn.iocoder.yudao.module.iot.framework.constant.DeviceTypeEnum;
import cn.iocoder.yudao.module.iot.framework.gateway.service.impl.TheGatewayServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DEVICE_ATTRIBUTE_NOT_EXISTS;
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DEVICE_NOT_EXISTS;
/**
* Service
*
* @author
*/
@Service
@Validated
public class DeviceServiceImpl implements DeviceService {
@Resource
private DeviceMapper deviceMapper;
@Resource
private DeviceAttributeMapper deviceAttributeMapper;
@Resource
private TheGatewayServiceImpl theGatewayService;
@Override
public Long createDevice(DeviceSaveReqVO createReqVO) {
// 插入
DeviceDO device = BeanUtils.toBean(createReqVO, DeviceDO.class);
deviceMapper.insert(device);
// 返回
return device.getId();
}
@Override
public void updateDevice(DeviceSaveReqVO updateReqVO) {
// 校验存在
validateDeviceExists(updateReqVO.getId());
// 更新
DeviceDO updateObj = BeanUtils.toBean(updateReqVO, DeviceDO.class);
deviceMapper.updateById(updateObj);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDevice(Long id) {
// 校验存在
validateDeviceExists(id);
// 删除
deviceMapper.deleteById(id);
// 删除子表
deleteDeviceAttributeByDeviceId(id);
}
private void validateDeviceExists(Long id) {
if (deviceMapper.selectById(id) == null) {
throw exception(DEVICE_NOT_EXISTS);
}
}
@Override
public DeviceDO getDevice(Long id) {
return deviceMapper.selectById(id);
}
@Override
public PageResult<DeviceDO> getDevicePage(DevicePageReqVO pageReqVO) {
return deviceMapper.selectPage(pageReqVO);
}
@Override
public CommonResult<String> pushDevice(DeviceDO deviceDO, GatewayDO gatewayDO) {
if (DeviceTypeEnum.isSiemens(deviceDO.getDeviceType())) {
return siemensAdd(deviceDO, gatewayDO);
} else if (DeviceTypeEnum.isModbus(deviceDO.getDeviceType())) {
return modbusAdd(deviceDO, gatewayDO);
} else return CommonResult.error(500, "未知类型设备!");
}
public CommonResult<String> siemensAdd(DeviceDO deviceDO, GatewayDO gatewayDO) {
if (gatewayDO != null && deviceDO != null &&
deviceDO.getDeviceCode() != null && gatewayDO.getGatewayCode() != null) {
try {
//清除原本的西门子设备和点位数据
theGatewayService.deleteSiemensEntity(gatewayDO, deviceDO);
//新增西门子设备
theGatewayService.addSiemensEntity(gatewayDO, deviceDO);
//下发完成西门子设备后 下发对应设备的点位
theGatewayService.addDeviceSiemensEntity(gatewayDO, deviceDO.getOrgMachineId(), deviceDO);
//修改下发标识
deviceDO.setIsUpload("1");
deviceMapper.updateById(deviceDO);
//启用设备
//todo 启用有点问题
theGatewayService.changeStatus(gatewayDO, deviceDO.getDeviceCode(), "siemens");
return theGatewayService.compare(gatewayDO, deviceDO, "siemens");
} catch (Exception e) {
e.getLocalizedMessage();
}
}
return CommonResult.error(500, "设备或网关不存在!");
}
/*modbus设备下发*/
public CommonResult<String> modbusAdd(DeviceDO deviceDO, GatewayDO gatewayDO) {
if (deviceDO.getDeviceCode() != null && gatewayDO.getGatewayCode() != null) {
try {
//清除原本的Modbus设备和点位数据
theGatewayService.deleteModbusEntity(gatewayDO, deviceDO.getDeviceCode());
//新增Modbus
theGatewayService.addModbusEntity(gatewayDO, deviceDO);
//下发完成Modbus设备后 下发对应设备的点位
theGatewayService.addDeviceModbusEntity(gatewayDO, deviceDO);
//修改下发标识
deviceDO.setIsUpload("1");
deviceMapper.updateById(deviceDO);
//启用设备
theGatewayService.changeStatus(gatewayDO, deviceDO.getDeviceCode(), "modbus");
return theGatewayService.compare(gatewayDO, deviceDO, "modbus");
} catch (Exception e) {
e.getLocalizedMessage();
}
}
return CommonResult.error(500, "设备或网关不存在!");
}
// ==================== 子表(设备属性) ====================
@Override
public PageResult<DeviceAttributeDO> getDeviceAttributePage(PageParam pageReqVO, Long deviceId) {
return deviceAttributeMapper.selectPage(pageReqVO, deviceId);
}
@Override
public Long createDeviceAttribute(DeviceAttributeDO deviceAttribute) {
deviceAttributeMapper.insert(deviceAttribute);
return deviceAttribute.getId();
}
@Override
public void updateDeviceAttribute(DeviceAttributeDO deviceAttribute) {
// 校验存在
validateDeviceAttributeExists(deviceAttribute.getId());
// 更新
deviceAttributeMapper.updateById(deviceAttribute);
}
@Override
public void deleteDeviceAttribute(Long id) {
// 校验存在
validateDeviceAttributeExists(id);
// 删除
deviceAttributeMapper.deleteById(id);
}
@Override
public DeviceAttributeDO getDeviceAttribute(Long id) {
return deviceAttributeMapper.selectById(id);
}
private void validateDeviceAttributeExists(Long id) {
if (deviceAttributeMapper.selectById(id) == null) {
throw exception(DEVICE_ATTRIBUTE_NOT_EXISTS);
}
}
private void deleteDeviceAttributeByDeviceId(Long deviceId) {
deviceAttributeMapper.deleteByDeviceId(deviceId);
}
}

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -1,231 +0,0 @@
package cn.iocoder.yudao.module.iot.service.device;
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO;
import cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* {@link DeviceServiceImpl}
*
* @author
*/
@Import(DeviceServiceImpl.class)
public class DeviceServiceImplTest extends BaseDbUnitTest {
@Resource
private DeviceServiceImpl deviceService;
@Resource
private DeviceMapper deviceMapper;
@Test
public void testCreateDevice_success() {
// 准备参数
DeviceSaveReqVO createReqVO = randomPojo(DeviceSaveReqVO.class).setId(null);
// 调用
Long deviceId = deviceService.createDevice(createReqVO);
// 断言
assertNotNull(deviceId);
// 校验记录的属性是否正确
DeviceDO device = deviceMapper.selectById(deviceId);
assertPojoEquals(createReqVO, device, "id");
}
@Test
public void testUpdateDevice_success() {
// mock 数据
DeviceDO dbDevice = randomPojo(DeviceDO.class);
deviceMapper.insert(dbDevice);// @Sql: 先插入出一条存在的数据
// 准备参数
DeviceSaveReqVO updateReqVO = randomPojo(DeviceSaveReqVO.class, o -> {
o.setId(dbDevice.getId()); // 设置更新的 ID
});
// 调用
deviceService.updateDevice(updateReqVO);
// 校验是否更新正确
DeviceDO device = deviceMapper.selectById(updateReqVO.getId()); // 获取最新的
assertPojoEquals(updateReqVO, device);
}
@Test
public void testUpdateDevice_notExists() {
// 准备参数
DeviceSaveReqVO updateReqVO = randomPojo(DeviceSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> deviceService.updateDevice(updateReqVO), DEVICE_NOT_EXISTS);
}
@Test
public void testDeleteDevice_success() {
// mock 数据
DeviceDO dbDevice = randomPojo(DeviceDO.class);
deviceMapper.insert(dbDevice);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbDevice.getId();
// 调用
deviceService.deleteDevice(id);
// 校验数据不存在了
assertNull(deviceMapper.selectById(id));
}
@Test
public void testDeleteDevice_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> deviceService.deleteDevice(id), DEVICE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetDevicePage() {
// mock 数据
DeviceDO dbDevice = randomPojo(DeviceDO.class, o -> { // 等会查询到
o.setDeviceConfigId(null);
o.setDeviceCode(null);
o.setDeviceName(null);
o.setDeviceType(null);
o.setSiemensSeries(null);
o.setSiemensConnectParam(null);
o.setReadCronType(null);
o.setReadRepeatValue(null);
o.setReadRepeatUnit(null);
o.setReadCron(null);
o.setWriteCronType(null);
o.setWriteRepeatValue(null);
o.setWriteRepeatUnit(null);
o.setWriteCron(null);
o.setLocalPersistent(null);
o.setUploadRate(null);
o.setRateCount(null);
o.setModbusProtocol(null);
o.setModbusPattern(null);
o.setPortName(null);
o.setModbusConnectParam(null);
o.setModbusReadAddrGap(null);
o.setIsUpload(null);
o.setGatewayId(null);
o.setOrgId(null);
o.setRemark(null);
o.setIsEnable(null);
o.setCreateTime(null);
});
deviceMapper.insert(dbDevice);
// 测试 deviceConfigId 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setDeviceConfigId(null)));
// 测试 deviceCode 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setDeviceCode(null)));
// 测试 deviceName 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setDeviceName(null)));
// 测试 deviceType 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setDeviceType(null)));
// 测试 siemensSeries 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setSiemensSeries(null)));
// 测试 siemensConnectParam 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setSiemensConnectParam(null)));
// 测试 readCronType 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setReadCronType(null)));
// 测试 readRepeatValue 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setReadRepeatValue(null)));
// 测试 readRepeatUnit 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setReadRepeatUnit(null)));
// 测试 readCron 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setReadCron(null)));
// 测试 writeCronType 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setWriteCronType(null)));
// 测试 writeRepeatValue 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setWriteRepeatValue(null)));
// 测试 writeRepeatUnit 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setWriteRepeatUnit(null)));
// 测试 writeCron 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setWriteCron(null)));
// 测试 localPersistent 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setLocalPersistent(null)));
// 测试 uploadRate 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setUploadRate(null)));
// 测试 rateCount 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setRateCount(null)));
// 测试 modbusProtocol 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setModbusProtocol(null)));
// 测试 modbusPattern 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setModbusPattern(null)));
// 测试 portName 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setPortName(null)));
// 测试 modbusConnectParam 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setModbusConnectParam(null)));
// 测试 modbusReadAddrGap 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setModbusReadAddrGap(null)));
// 测试 isUpload 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setIsUpload(null)));
// 测试 gatewayId 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setGatewayId(null)));
// 测试 orgId 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setOrgId(null)));
// 测试 remark 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setRemark(null)));
// 测试 isEnable 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setIsEnable(null)));
// 测试 createTime 不匹配
deviceMapper.insert(cloneIgnoreId(dbDevice, o -> o.setCreateTime(null)));
// 准备参数
DevicePageReqVO reqVO = new DevicePageReqVO();
reqVO.setDeviceConfigId(null);
reqVO.setDeviceCode(null);
reqVO.setDeviceName(null);
reqVO.setDeviceType(null);
reqVO.setSiemensSeries(null);
reqVO.setSiemensConnectParam(null);
reqVO.setReadCronType(null);
reqVO.setReadRepeatValue(null);
reqVO.setReadRepeatUnit(null);
reqVO.setReadCron(null);
reqVO.setWriteCronType(null);
reqVO.setWriteRepeatValue(null);
reqVO.setWriteRepeatUnit(null);
reqVO.setWriteCron(null);
reqVO.setLocalPersistent(null);
reqVO.setUploadRate(null);
reqVO.setRateCount(null);
reqVO.setModbusProtocol(null);
reqVO.setModbusPattern(null);
reqVO.setPortName(null);
reqVO.setModbusConnectParam(null);
reqVO.setModbusReadAddrGap(null);
reqVO.setIsUpload(null);
reqVO.setGatewayId(null);
reqVO.setOrgId(null);
reqVO.setRemark(null);
reqVO.setIsEnable(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
PageResult<DeviceDO> pageResult = deviceService.getDevicePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbDevice, pageResult.getList().get(0));
}
}
Loading…
Cancel
Save