Merge branch 'hhk' into main
commit
108c207b3d
@ -0,0 +1,111 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules;
|
||||
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicemodelrules.DeviceModelRulesDO;
|
||||
import cn.iocoder.yudao.module.iot.service.devicemodelrules.DeviceModelRulesService;
|
||||
|
||||
@Tag(name = "管理后台 - 点位规则关联模型")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device-model-rules")
|
||||
@Validated
|
||||
public class DeviceModelRulesController {
|
||||
|
||||
@Resource
|
||||
private DeviceModelRulesService deviceModelRulesService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建点位规则关联模型")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model-rules:create')")
|
||||
public CommonResult<Long> createDeviceModelRules(@Valid @RequestBody DeviceModelRulesSaveReqVO createReqVO) {
|
||||
return success(deviceModelRulesService.createDeviceModelRules(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新点位规则关联模型")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model-rules:update')")
|
||||
public CommonResult<Boolean> updateDeviceModelRules(@Valid @RequestBody DeviceModelRulesSaveReqVO updateReqVO) {
|
||||
deviceModelRulesService.updateDeviceModelRules(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除点位规则关联模型")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model-rules:delete')")
|
||||
public CommonResult<Boolean> deleteDeviceModelRules(@RequestParam("id") Long id) {
|
||||
deviceModelRulesService.deleteDeviceModelRules(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得点位规则关联模型")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model-rules:query')")
|
||||
public CommonResult<DeviceModelRulesRespVO> getDeviceModelRules(@RequestParam("id") Long id) {
|
||||
DeviceModelRulesDO deviceModelRules = deviceModelRulesService.getDeviceModelRules(id);
|
||||
DeviceModelRulesRespVO deviceModelRulesRespVO = BeanUtils.toBean(deviceModelRules, DeviceModelRulesRespVO.class);
|
||||
if (StringUtils.isNotBlank(deviceModelRulesRespVO.getFieldRule())){
|
||||
List<PointRulesRespVO> pointRulesVOList = JSON.parseArray(deviceModelRulesRespVO.getFieldRule(), PointRulesRespVO.class);
|
||||
deviceModelRulesRespVO.setPointRulesVOList(pointRulesVOList);
|
||||
}
|
||||
return success(deviceModelRulesRespVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得点位规则关联模型分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model-rules:query')")
|
||||
public CommonResult<PageResult<DeviceModelRulesRespVO>> getDeviceModelRulesPage(@Valid DeviceModelRulesPageReqVO pageReqVO) {
|
||||
PageResult<DeviceModelRulesDO> pageResult = deviceModelRulesService.getDeviceModelRulesPage(pageReqVO);
|
||||
PageResult<DeviceModelRulesRespVO> modelRulesRespVOPageResult = BeanUtils.toBean(pageResult, DeviceModelRulesRespVO.class);
|
||||
for (DeviceModelRulesRespVO deviceModelRulesRespVO : modelRulesRespVOPageResult.getList()) {
|
||||
if (StringUtils.isNotBlank(deviceModelRulesRespVO.getFieldRule())) {
|
||||
List<PointRulesRespVO> pointRulesVOList = JSON.parseArray(deviceModelRulesRespVO.getFieldRule(), PointRulesRespVO.class);
|
||||
deviceModelRulesRespVO.setPointRulesVOList(pointRulesVOList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success(modelRulesRespVOPageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出点位规则关联模型 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-model-rules:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDeviceModelRulesExcel(@Valid DeviceModelRulesPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceModelRulesDO> list = deviceModelRulesService.getDeviceModelRulesPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "点位规则关联模型.xls", "数据", DeviceModelRulesRespVO.class,
|
||||
BeanUtils.toBean(list, DeviceModelRulesRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
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 DeviceModelRulesPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称", example = "王五")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "规则")
|
||||
private String fieldRule;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "关联设备模型Id", example = "13397")
|
||||
private Long modelId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 点位规则关联模型 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DeviceModelRulesRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10916")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标识符")
|
||||
@ExcelProperty("标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称", example = "王五")
|
||||
@ExcelProperty("名称")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "规则")
|
||||
@ExcelProperty("规则")
|
||||
private String fieldRule;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
@ExcelProperty("默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "关联设备模型Id", example = "13397")
|
||||
@ExcelProperty("关联设备模型Id")
|
||||
private Long modelId;
|
||||
|
||||
@Schema(description = "点位规则")
|
||||
private List<PointRulesRespVO> pointRulesVOList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 点位规则关联模型新增/修改 Request VO")
|
||||
@Data
|
||||
public class DeviceModelRulesSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10916")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称", example = "王五")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "规则")
|
||||
private String fieldRule;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "关联设备模型Id", example = "13397")
|
||||
private Long modelId;
|
||||
|
||||
@Schema(description = "点位规则列表", implementation = PointRulesRespVO.class)
|
||||
private List<PointRulesRespVO> pointRulesVOList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 点位具体规则 Resp VO")
|
||||
@Data
|
||||
public class PointRulesRespVO {
|
||||
|
||||
@Schema(description = "点位规则")
|
||||
private String rule;
|
||||
|
||||
@Schema(description = "点位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10916")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "符号")
|
||||
private String operator;
|
||||
|
||||
@Schema(description = "符号值")
|
||||
private String operatorRule;
|
||||
|
||||
@Schema(description = "规则值")
|
||||
private String ruleValue;
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 点位规则 Resp VO")
|
||||
@Data
|
||||
public class RulesRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10916")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@ArraySchema(schema = @Schema(implementation = PointRulesRespVO.class))
|
||||
private List<PointRulesRespVO> pointRulesVOList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
|
||||
import cn.iocoder.yudao.module.iot.service.deviceoperationrecord.DeviceOperationRecordService;
|
||||
|
||||
@Tag(name = "管理后台 - 运行记录")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device-operation-record")
|
||||
@Validated
|
||||
public class DeviceOperationRecordController {
|
||||
|
||||
@Resource
|
||||
private DeviceOperationRecordService deviceOperationRecordService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建运行记录")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:create')")
|
||||
public CommonResult<Long> createDeviceOperationRecord(@Valid @RequestBody DeviceOperationRecordSaveReqVO createReqVO) {
|
||||
return success(deviceOperationRecordService.createDeviceOperationRecord(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新运行记录")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:update')")
|
||||
public CommonResult<Boolean> updateDeviceOperationRecord(@Valid @RequestBody DeviceOperationRecordSaveReqVO updateReqVO) {
|
||||
deviceOperationRecordService.updateDeviceOperationRecord(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除运行记录")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:delete')")
|
||||
public CommonResult<Boolean> deleteDeviceOperationRecord(@RequestParam("id") Long id) {
|
||||
deviceOperationRecordService.deleteDeviceOperationRecord(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得运行记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:query')")
|
||||
public CommonResult<DeviceOperationRecordRespVO> getDeviceOperationRecord(@RequestParam("id") Long id) {
|
||||
DeviceOperationRecordDO deviceOperationRecord = deviceOperationRecordService.getDeviceOperationRecord(id);
|
||||
return success(BeanUtils.toBean(deviceOperationRecord, DeviceOperationRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得运行记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:query')")
|
||||
public CommonResult<PageResult<DeviceOperationRecordRespVO>> getDeviceOperationRecordPage(@Valid DeviceOperationRecordPageReqVO pageReqVO) {
|
||||
PageResult<DeviceOperationRecordDO> pageResult = deviceOperationRecordService.getDeviceOperationRecordPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DeviceOperationRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出运行记录 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDeviceOperationRecordExcel(@Valid DeviceOperationRecordPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceOperationRecordDO> list = deviceOperationRecordService.getDeviceOperationRecordPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "运行记录.xls", "数据", DeviceOperationRecordRespVO.class,
|
||||
BeanUtils.toBean(list, DeviceOperationRecordRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
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 DeviceOperationRecordPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备ID", example = "18965")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(description = "模型ID", example = "26876")
|
||||
private Long modelId;
|
||||
|
||||
@Schema(description = "规则值")
|
||||
private String rule;
|
||||
|
||||
@Schema(description = "地址值")
|
||||
private String addressValue;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "类型 1-RUNNING 2-ALRAM", example = "2")
|
||||
private Integer recordType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 运行记录 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DeviceOperationRecordRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4283")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备ID", example = "18965")
|
||||
@ExcelProperty("设备ID")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(description = "模型ID", example = "26876")
|
||||
@ExcelProperty("模型ID")
|
||||
private Long modelId;
|
||||
|
||||
@Schema(description = "规则值")
|
||||
@ExcelProperty("规则值")
|
||||
private String rule;
|
||||
|
||||
@Schema(description = "地址值")
|
||||
@ExcelProperty("地址值")
|
||||
private String addressValue;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "类型 1-RUNNING 2-ALRAM", example = "2")
|
||||
@ExcelProperty("类型 1-RUNNING 2-ALRAM")
|
||||
private Integer recordType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 运行记录新增/修改 Request VO")
|
||||
@Data
|
||||
public class DeviceOperationRecordSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4283")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备ID", example = "18965")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(description = "模型ID", example = "26876")
|
||||
private Long modelId;
|
||||
|
||||
@Schema(description = "规则值")
|
||||
private String rule;
|
||||
|
||||
@Schema(description = "地址值")
|
||||
private String addressValue;
|
||||
|
||||
@Schema(description = "类型 1-RUNNING 2-ALRAM", example = "2")
|
||||
private Integer recordType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicepointrules;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.PointRulesRespVO;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicepointrules.DevicePointRulesDO;
|
||||
import cn.iocoder.yudao.module.iot.service.devicepointrules.DevicePointRulesService;
|
||||
|
||||
@Tag(name = "管理后台 - 点位规则")
|
||||
@RestController
|
||||
@RequestMapping("/iot/device-point-rules")
|
||||
@Validated
|
||||
public class DevicePointRulesController {
|
||||
|
||||
@Resource
|
||||
private DevicePointRulesService devicePointRulesService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建点位规则")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-point-rules:create')")
|
||||
public CommonResult<Long> createDevicePointRules(@Valid @RequestBody DevicePointRulesSaveReqVO createReqVO) {
|
||||
return success(devicePointRulesService.createDevicePointRules(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新点位规则")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-point-rules:update')")
|
||||
public CommonResult<Boolean> updateDevicePointRules(@Valid @RequestBody DevicePointRulesSaveReqVO updateReqVO) {
|
||||
devicePointRulesService.updateDevicePointRules(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除点位规则")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-point-rules:delete')")
|
||||
public CommonResult<Boolean> deleteDevicePointRules(@RequestParam("id") Long id) {
|
||||
devicePointRulesService.deleteDevicePointRules(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得点位规则")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-point-rules:query')")
|
||||
public CommonResult<DevicePointRulesRespVO> getDevicePointRules(@RequestParam("id") Long id) {
|
||||
DevicePointRulesDO devicePointRules = devicePointRulesService.getDevicePointRules(id);
|
||||
return success(BeanUtils.toBean(devicePointRules, DevicePointRulesRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得点位规则分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-point-rules:query')")
|
||||
public CommonResult<PageResult<DevicePointRulesRespVO>> getDevicePointRulesPage(@Valid DevicePointRulesPageReqVO pageReqVO) {
|
||||
PageResult<DevicePointRulesDO> pageResult = devicePointRulesService.getDevicePointRulesPage(pageReqVO);
|
||||
PageResult<DevicePointRulesRespVO> rulesRespVOPageResult = BeanUtils.toBean(pageResult, DevicePointRulesRespVO.class);
|
||||
for (DevicePointRulesRespVO devicePointRulesRespVO : rulesRespVOPageResult.getList()) {
|
||||
if (StringUtils.isNotBlank(devicePointRulesRespVO.getFieldRule())) {
|
||||
List<PointRulesRespVO> pointRulesVOList = JSON.parseArray(devicePointRulesRespVO.getFieldRule(), PointRulesRespVO.class);
|
||||
devicePointRulesRespVO.setPointRulesVOList(pointRulesVOList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return success(rulesRespVOPageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出点位规则 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device-point-rules:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDevicePointRulesExcel(@Valid DevicePointRulesPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DevicePointRulesDO> list = devicePointRulesService.getDevicePointRulesPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "点位规则.xls", "数据", DevicePointRulesRespVO.class,
|
||||
BeanUtils.toBean(list, DevicePointRulesRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
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 DevicePointRulesPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称", example = "赵六")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "规则")
|
||||
private String fieldRule;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "设备模型Id", example = "19582")
|
||||
private Long deviceId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.PointRulesRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 点位规则 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DevicePointRulesRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13120")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标识符")
|
||||
@ExcelProperty("标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称", example = "赵六")
|
||||
@ExcelProperty("名称")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "规则")
|
||||
@ExcelProperty("规则")
|
||||
private String fieldRule;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
@ExcelProperty("默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "设备模型Id", example = "19582")
|
||||
@ExcelProperty("设备模型Id")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(description = "点位规则")
|
||||
private List<PointRulesRespVO> pointRulesVOList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.PointRulesRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 点位规则新增/修改 Request VO")
|
||||
@Data
|
||||
public class DevicePointRulesSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13120")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标识符")
|
||||
private String identifier;
|
||||
|
||||
@Schema(description = "名称", example = "赵六")
|
||||
private String fieldName;
|
||||
|
||||
@Schema(description = "规则")
|
||||
private String fieldRule;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "设备模型Id", example = "19582")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(description = "点位规则列表", implementation = PointRulesRespVO.class)
|
||||
private List<PointRulesRespVO> pointRulesVOList;
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.devicecontactmodel;
|
||||
package cn.iocoder.yudao.module.iot.dal.dataobject.devicecontactmodel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.dataobject.devicemodelrules;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 点位规则关联模型 DO
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@TableName("iot_device_model_rules")
|
||||
@KeySequence("iot_device_model_rules_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceModelRulesDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 标识符
|
||||
*/
|
||||
private String identifier;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String fieldName;
|
||||
/**
|
||||
* 规则
|
||||
*/
|
||||
private String fieldRule;
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
private String defaultValue;
|
||||
/**
|
||||
* 关联设备模型Id
|
||||
*/
|
||||
private Long modelId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 运行记录 DO
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@TableName("iot_device_operation_record")
|
||||
@KeySequence("iot_device_operation_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceOperationRecordDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Long deviceId;
|
||||
/**
|
||||
* 模型ID
|
||||
*/
|
||||
private Long modelId;
|
||||
/**
|
||||
* 规则值
|
||||
*/
|
||||
private String rule;
|
||||
/**
|
||||
* 地址值
|
||||
*/
|
||||
private String addressValue;
|
||||
/**
|
||||
* 类型 1-RUNNING 2-ALRAM
|
||||
*/
|
||||
private Integer recordType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.dataobject.devicepointrules;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 点位规则 DO
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@TableName("iot_device_point_rules")
|
||||
@KeySequence("iot_device_point_rules_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DevicePointRulesDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 标识符
|
||||
*/
|
||||
private String identifier;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String fieldName;
|
||||
/**
|
||||
* 规则
|
||||
*/
|
||||
private String fieldRule;
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
private String defaultValue;
|
||||
/**
|
||||
* 设备模型Id
|
||||
*/
|
||||
private Long deviceId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.mysql.devicemodelrules;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicemodelrules.DeviceModelRulesDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.*;
|
||||
|
||||
/**
|
||||
* 点位规则关联模型 Mapper
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceModelRulesMapper extends BaseMapperX<DeviceModelRulesDO> {
|
||||
|
||||
default PageResult<DeviceModelRulesDO> selectPage(DeviceModelRulesPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceModelRulesDO>()
|
||||
.eqIfPresent(DeviceModelRulesDO::getIdentifier, reqVO.getIdentifier())
|
||||
.likeIfPresent(DeviceModelRulesDO::getFieldName, reqVO.getFieldName())
|
||||
.eqIfPresent(DeviceModelRulesDO::getFieldRule, reqVO.getFieldRule())
|
||||
.eqIfPresent(DeviceModelRulesDO::getDefaultValue, reqVO.getDefaultValue())
|
||||
.betweenIfPresent(DeviceModelRulesDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(DeviceModelRulesDO::getModelId, reqVO.getModelId())
|
||||
.orderByDesc(DeviceModelRulesDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.mysql.deviceoperationrecord;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.*;
|
||||
|
||||
/**
|
||||
* 运行记录 Mapper
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceOperationRecordMapper extends BaseMapperX<DeviceOperationRecordDO> {
|
||||
|
||||
default PageResult<DeviceOperationRecordDO> selectPage(DeviceOperationRecordPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceOperationRecordDO>()
|
||||
.eqIfPresent(DeviceOperationRecordDO::getDeviceId, reqVO.getDeviceId())
|
||||
.eqIfPresent(DeviceOperationRecordDO::getModelId, reqVO.getModelId())
|
||||
.eqIfPresent(DeviceOperationRecordDO::getRule, reqVO.getRule())
|
||||
.eqIfPresent(DeviceOperationRecordDO::getAddressValue, reqVO.getAddressValue())
|
||||
.betweenIfPresent(DeviceOperationRecordDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(DeviceOperationRecordDO::getRecordType, reqVO.getRecordType())
|
||||
.orderByDesc(DeviceOperationRecordDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.mysql.devicepointrules;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicepointrules.DevicePointRulesDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo.*;
|
||||
|
||||
/**
|
||||
* 点位规则 Mapper
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Mapper
|
||||
public interface DevicePointRulesMapper extends BaseMapperX<DevicePointRulesDO> {
|
||||
|
||||
default PageResult<DevicePointRulesDO> selectPage(DevicePointRulesPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DevicePointRulesDO>()
|
||||
.eqIfPresent(DevicePointRulesDO::getIdentifier, reqVO.getIdentifier())
|
||||
.likeIfPresent(DevicePointRulesDO::getFieldName, reqVO.getFieldName())
|
||||
.eqIfPresent(DevicePointRulesDO::getFieldRule, reqVO.getFieldRule())
|
||||
.eqIfPresent(DevicePointRulesDO::getDefaultValue, reqVO.getDefaultValue())
|
||||
.betweenIfPresent(DevicePointRulesDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(DevicePointRulesDO::getDeviceId, reqVO.getDeviceId())
|
||||
.orderByDesc(DevicePointRulesDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.iot.service.devicemodelrules;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicemodelrules.DeviceModelRulesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 点位规则关联模型 Service 接口
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
public interface DeviceModelRulesService {
|
||||
|
||||
/**
|
||||
* 创建点位规则关联模型
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDeviceModelRules(@Valid DeviceModelRulesSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新点位规则关联模型
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDeviceModelRules(@Valid DeviceModelRulesSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除点位规则关联模型
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDeviceModelRules(Long id);
|
||||
|
||||
/**
|
||||
* 获得点位规则关联模型
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 点位规则关联模型
|
||||
*/
|
||||
DeviceModelRulesDO getDeviceModelRules(Long id);
|
||||
|
||||
/**
|
||||
* 获得点位规则关联模型分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 点位规则关联模型分页
|
||||
*/
|
||||
PageResult<DeviceModelRulesDO> getDeviceModelRulesPage(DeviceModelRulesPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.iot.service.devicemodelrules;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicemodelrules.DeviceModelRulesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.dal.mysql.devicemodelrules.DeviceModelRulesMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 点位规则关联模型 Service 实现类
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DeviceModelRulesServiceImpl implements DeviceModelRulesService {
|
||||
|
||||
@Resource
|
||||
private DeviceModelRulesMapper deviceModelRulesMapper;
|
||||
|
||||
@Override
|
||||
public Long createDeviceModelRules(DeviceModelRulesSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DeviceModelRulesDO deviceModelRules = BeanUtils.toBean(createReqVO, DeviceModelRulesDO.class);
|
||||
deviceModelRulesMapper.insert(deviceModelRules);
|
||||
// 返回
|
||||
return deviceModelRules.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceModelRules(DeviceModelRulesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDeviceModelRulesExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DeviceModelRulesDO updateObj = BeanUtils.toBean(updateReqVO, DeviceModelRulesDO.class);
|
||||
if (!updateReqVO.getPointRulesVOList().isEmpty()){
|
||||
String jsonString = JSON.toJSONString(updateReqVO.getPointRulesVOList());
|
||||
updateObj.setFieldRule(jsonString);
|
||||
|
||||
}
|
||||
|
||||
deviceModelRulesMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDeviceModelRules(Long id) {
|
||||
// 校验存在
|
||||
validateDeviceModelRulesExists(id);
|
||||
// 删除
|
||||
deviceModelRulesMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDeviceModelRulesExists(Long id) {
|
||||
if (deviceModelRulesMapper.selectById(id) == null) {
|
||||
throw exception(DEVICE_MODEL_RULES_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceModelRulesDO getDeviceModelRules(Long id) {
|
||||
return deviceModelRulesMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DeviceModelRulesDO> getDeviceModelRulesPage(DeviceModelRulesPageReqVO pageReqVO) {
|
||||
return deviceModelRulesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.iot.service.deviceoperationrecord;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 运行记录 Service 接口
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
public interface DeviceOperationRecordService {
|
||||
|
||||
/**
|
||||
* 创建运行记录
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDeviceOperationRecord(@Valid DeviceOperationRecordSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新运行记录
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDeviceOperationRecord(@Valid DeviceOperationRecordSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除运行记录
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDeviceOperationRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得运行记录
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 运行记录
|
||||
*/
|
||||
DeviceOperationRecordDO getDeviceOperationRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得运行记录分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 运行记录分页
|
||||
*/
|
||||
PageResult<DeviceOperationRecordDO> getDeviceOperationRecordPage(DeviceOperationRecordPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.iot.service.deviceoperationrecord;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.dal.mysql.deviceoperationrecord.DeviceOperationRecordMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 运行记录 Service 实现类
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DeviceOperationRecordServiceImpl implements DeviceOperationRecordService {
|
||||
|
||||
@Resource
|
||||
private DeviceOperationRecordMapper deviceOperationRecordMapper;
|
||||
|
||||
@Override
|
||||
public Long createDeviceOperationRecord(DeviceOperationRecordSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DeviceOperationRecordDO deviceOperationRecord = BeanUtils.toBean(createReqVO, DeviceOperationRecordDO.class);
|
||||
deviceOperationRecordMapper.insert(deviceOperationRecord);
|
||||
// 返回
|
||||
return deviceOperationRecord.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceOperationRecord(DeviceOperationRecordSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDeviceOperationRecordExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DeviceOperationRecordDO updateObj = BeanUtils.toBean(updateReqVO, DeviceOperationRecordDO.class);
|
||||
deviceOperationRecordMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDeviceOperationRecord(Long id) {
|
||||
// 校验存在
|
||||
validateDeviceOperationRecordExists(id);
|
||||
// 删除
|
||||
deviceOperationRecordMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDeviceOperationRecordExists(Long id) {
|
||||
if (deviceOperationRecordMapper.selectById(id) == null) {
|
||||
throw exception(DEVICE_OPERATION_RECORD_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceOperationRecordDO getDeviceOperationRecord(Long id) {
|
||||
return deviceOperationRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DeviceOperationRecordDO> getDeviceOperationRecordPage(DeviceOperationRecordPageReqVO pageReqVO) {
|
||||
return deviceOperationRecordMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.iot.service.devicepointrules;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicepointrules.DevicePointRulesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 点位规则 Service 接口
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
public interface DevicePointRulesService {
|
||||
|
||||
/**
|
||||
* 创建点位规则
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDevicePointRules(@Valid DevicePointRulesSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新点位规则
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDevicePointRules(@Valid DevicePointRulesSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除点位规则
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDevicePointRules(Long id);
|
||||
|
||||
/**
|
||||
* 获得点位规则
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 点位规则
|
||||
*/
|
||||
DevicePointRulesDO getDevicePointRules(Long id);
|
||||
|
||||
/**
|
||||
* 获得点位规则分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 点位规则分页
|
||||
*/
|
||||
PageResult<DevicePointRulesDO> getDevicePointRulesPage(DevicePointRulesPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.iot.service.devicepointrules;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.devicepointrules.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.devicepointrules.DevicePointRulesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.dal.mysql.devicepointrules.DevicePointRulesMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 点位规则 Service 实现类
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DevicePointRulesServiceImpl implements DevicePointRulesService {
|
||||
|
||||
@Resource
|
||||
private DevicePointRulesMapper devicePointRulesMapper;
|
||||
|
||||
@Override
|
||||
public Long createDevicePointRules(DevicePointRulesSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DevicePointRulesDO devicePointRules = BeanUtils.toBean(createReqVO, DevicePointRulesDO.class);
|
||||
devicePointRulesMapper.insert(devicePointRules);
|
||||
// 返回
|
||||
return devicePointRules.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDevicePointRules(DevicePointRulesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDevicePointRulesExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DevicePointRulesDO updateObj = BeanUtils.toBean(updateReqVO, DevicePointRulesDO.class);
|
||||
if (!updateReqVO.getPointRulesVOList().isEmpty()){
|
||||
String jsonString = JSON.toJSONString(updateReqVO.getPointRulesVOList());
|
||||
updateObj.setFieldRule(jsonString);
|
||||
|
||||
}
|
||||
|
||||
devicePointRulesMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDevicePointRules(Long id) {
|
||||
// 校验存在
|
||||
validateDevicePointRulesExists(id);
|
||||
// 删除
|
||||
devicePointRulesMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDevicePointRulesExists(Long id) {
|
||||
if (devicePointRulesMapper.selectById(id) == null) {
|
||||
throw exception(DEVICE_POINT_RULES_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePointRulesDO getDevicePointRules(Long id) {
|
||||
return devicePointRulesMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DevicePointRulesDO> getDevicePointRulesPage(DevicePointRulesPageReqVO pageReqVO) {
|
||||
return devicePointRulesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue