Merge branch 'dev' into dev-shiheng
commit
3255090ee6
|
@ -0,0 +1,33 @@
|
|||
package cc.iotkit.common.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: Longjun.Tu
|
||||
* @description:
|
||||
* @date:created in 2023/5/10 23:15
|
||||
* @modificed by:
|
||||
*/
|
||||
public class PageRequest<T> extends Request<T> implements Serializable {
|
||||
private Integer pageNo = 1;
|
||||
private Integer pageSize = 20;
|
||||
|
||||
public PageRequest() {
|
||||
}
|
||||
|
||||
public Integer getPageNo() {
|
||||
return this.pageNo;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public void setPageNo(Integer pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package cc.iotkit.common.api;
|
||||
|
||||
/**
|
||||
* @author: Longjun.Tu
|
||||
* @description:
|
||||
* @date:created in 2023/5/10 23:16
|
||||
* @modificed by:
|
||||
*/
|
||||
public class PageRequestEmpty {
|
||||
private Integer pageNo = 1;
|
||||
private Integer pageSize = 20;
|
||||
|
||||
public PageRequestEmpty() {
|
||||
}
|
||||
|
||||
public Integer getPageNo() {
|
||||
return this.pageNo;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public void setPageNo(Integer pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package cc.iotkit.common.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author: Longjun.Tu
|
||||
* @description:
|
||||
* @date:created in 2023/5/10 23:14
|
||||
* @modificed by:
|
||||
*/
|
||||
public class Request<T> extends RequestEmpty implements Serializable {
|
||||
private T data;
|
||||
|
||||
public Request() {
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static <T> Request<T> of(T data) {
|
||||
Request<T> request = new Request();
|
||||
request.setData(data);
|
||||
request.setRequestId(UUID.randomUUID().toString());
|
||||
return request;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package cc.iotkit.common.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author: Longjun.Tu
|
||||
* @description:
|
||||
* @date:created in 2023/5/10 23:12
|
||||
* @modificed by:
|
||||
*/
|
||||
public class RequestEmpty implements Serializable {
|
||||
|
||||
|
||||
private String language;
|
||||
|
||||
|
||||
@Deprecated
|
||||
private String requestId;
|
||||
|
||||
public RequestEmpty() {
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getRequestId() {
|
||||
return this.requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(String requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public static RequestEmpty of() {
|
||||
RequestEmpty request = new RequestEmpty();
|
||||
request.setRequestId(UUID.randomUUID().toString());
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.data;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.model.Paging;
|
||||
import cc.iotkit.model.alert.AlertConfig;
|
||||
|
||||
|
||||
public interface IAlertConfigData extends ICommonData<AlertConfig, String> {
|
||||
|
||||
|
||||
Paging<AlertConfig> selectAlertConfigPage(PageRequest<AlertConfig> request);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.data;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.model.Paging;
|
||||
import cc.iotkit.model.alert.AlertRecord;
|
||||
|
||||
|
||||
public interface IAlertRecordData extends ICommonData<AlertRecord, String> {
|
||||
|
||||
|
||||
Paging<AlertRecord> selectAlertConfigPage(PageRequest<AlertRecord> request);
|
||||
}
|
|
@ -23,8 +23,6 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AlertConfig implements Owned<String> {
|
||||
public static final String TYPE_EMAIL="email";
|
||||
public static final String TYPE_DINGDING_ROBOT="dingding_robot";
|
||||
|
||||
private String id;
|
||||
|
||||
|
@ -34,30 +32,38 @@ public class AlertConfig implements Owned<String> {
|
|||
private String uid;
|
||||
|
||||
/**
|
||||
* 告警器类型
|
||||
* 告警名称
|
||||
*/
|
||||
private String type;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 告警配置标题
|
||||
* 告警严重度
|
||||
*/
|
||||
private String title;
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 告警器参数配置
|
||||
* 关联规则引擎ID
|
||||
*/
|
||||
private String config;
|
||||
private String ruleInfoId;
|
||||
|
||||
/**
|
||||
* 告警内容模板
|
||||
* 关联消息转发模板ID
|
||||
*/
|
||||
private String template;
|
||||
private String messageTemplateId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private boolean enable;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long createAt;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.model.alert;
|
||||
|
||||
import cc.iotkit.model.Owned;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 告警配置
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AlertRecord implements Owned<String> {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 配置所属用户
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 告警名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 告警严重度(1-5)
|
||||
*/
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 告警时间
|
||||
*/
|
||||
private Long alartTime;
|
||||
|
||||
/**
|
||||
* 告警详情
|
||||
*/
|
||||
private String details;
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
private Boolean read;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.data.dao;
|
||||
|
||||
import cc.iotkit.data.model.TbAlertConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface AlertConfigRepository extends JpaRepository<TbAlertConfig, String> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.data.dao;
|
||||
|
||||
import cc.iotkit.data.model.TbAlertRecord;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface AlertRecordRepository extends JpaRepository<TbAlertRecord, String> {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.model.alert.AlertConfig;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface AlertConfigMapper {
|
||||
|
||||
AlertConfigMapper M = Mappers.getMapper(AlertConfigMapper.class);
|
||||
|
||||
AlertConfig toDto(TbAlertConfig vo);
|
||||
|
||||
TbAlertConfig toVo(AlertConfig dto);
|
||||
|
||||
static List<AlertConfig> toDto(List<TbAlertConfig> alertConfigs) {
|
||||
return alertConfigs.stream().map(M::toDto).collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.model.alert.AlertRecord;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface AlertRecordMapper {
|
||||
|
||||
AlertRecordMapper M = Mappers.getMapper(AlertRecordMapper.class);
|
||||
|
||||
AlertRecord toDto(TbAlertRecord vo);
|
||||
|
||||
TbAlertRecord toVo(AlertRecord dto);
|
||||
|
||||
static List<AlertRecord> toDto(List<TbAlertRecord> alertRecords) {
|
||||
return alertRecords.stream().map(M::toDto).collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "alert_config")
|
||||
public class TbAlertConfig {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 配置所属用户
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 告警名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 告警严重度
|
||||
*/
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 关联规则引擎ID
|
||||
*/
|
||||
private String ruleInfoId;
|
||||
|
||||
/**
|
||||
* 关联消息转发模板ID
|
||||
*/
|
||||
private String messageTemplateId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long createAt;
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "alert_record")
|
||||
public class TbAlertRecord {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 配置所属用户
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 告警名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 告警严重度(1-5)
|
||||
*/
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 告警时间
|
||||
*/
|
||||
private Long alartTime;
|
||||
|
||||
/**
|
||||
* 告警详情
|
||||
*/
|
||||
private String details;
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
private Boolean read;
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.data.IAlertConfigData;
|
||||
import cc.iotkit.data.dao.AlertConfigRepository;
|
||||
import cc.iotkit.data.model.AlertConfigMapper;
|
||||
import cc.iotkit.data.model.ProductMapper;
|
||||
import cc.iotkit.data.model.TbAlertConfig;
|
||||
import cc.iotkit.data.model.TbProduct;
|
||||
import cc.iotkit.model.Paging;
|
||||
import cc.iotkit.model.alert.AlertConfig;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Primary
|
||||
@Service
|
||||
public class AlertConfigDataImpl implements IAlertConfigData {
|
||||
|
||||
@Autowired
|
||||
private AlertConfigRepository alertConfigRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public AlertConfig findById(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertConfig save(AlertConfig data) {
|
||||
if (StringUtils.isBlank(data.getId())) {
|
||||
data.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
alertConfigRepository.save(AlertConfigMapper.M.toVo(data));
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertConfig add(AlertConfig data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlertConfig> findAll() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<AlertConfig> findAll(int page, int size) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<AlertConfig> selectAlertConfigPage(PageRequest<AlertConfig> request) {
|
||||
Pageable pageable = org.springframework.data.domain.PageRequest.of(request.getPageNo(), request.getPageSize(), Sort.Direction.DESC, "createAt");
|
||||
Page<TbAlertConfig> alertConfigPage = alertConfigRepository.findAll(Example.of(AlertConfigMapper.M.toVo(request.getData())), pageable);
|
||||
return new Paging<>(alertConfigPage.getTotalElements(), AlertConfigMapper.toDto(alertConfigPage.getContent()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.data.IAlertRecordData;
|
||||
import cc.iotkit.data.IHomeData;
|
||||
import cc.iotkit.data.dao.AlertRecordRepository;
|
||||
import cc.iotkit.data.dao.HomeRepository;
|
||||
import cc.iotkit.data.model.AlertConfigMapper;
|
||||
import cc.iotkit.data.model.AlertRecordMapper;
|
||||
import cc.iotkit.data.model.HomeMapper;
|
||||
import cc.iotkit.data.model.TbAlertConfig;
|
||||
import cc.iotkit.data.model.TbAlertRecord;
|
||||
import cc.iotkit.model.Paging;
|
||||
import cc.iotkit.model.alert.AlertRecord;
|
||||
import cc.iotkit.model.space.Home;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Primary
|
||||
@Service
|
||||
public class AlertRecordDataImpl implements IAlertRecordData {
|
||||
|
||||
@Autowired
|
||||
private AlertRecordRepository alertRecordRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public AlertRecord findById(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertRecord save(AlertRecord data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertRecord add(AlertRecord data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlertRecord> findAll() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<AlertRecord> findAll(int page, int size) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Paging<AlertRecord> selectAlertConfigPage(PageRequest<AlertRecord> request) {
|
||||
Pageable pageable = org.springframework.data.domain.PageRequest.of(request.getPageNo(),
|
||||
request.getPageSize(), Sort.Direction.DESC, "alartTime");
|
||||
Page<TbAlertRecord> alertRecordPage = alertRecordRepository.findAll(
|
||||
Example.of(AlertRecordMapper.M.toVo(request.getData())), pageable);
|
||||
return new Paging<>(alertRecordPage.getTotalElements(),
|
||||
AlertRecordMapper.toDto(alertRecordPage.getContent()));
|
||||
}
|
||||
}
|
|
@ -7,9 +7,10 @@
|
|||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.ruleengine.action;
|
||||
package cc.iotkit.ruleengine.action.alert;
|
||||
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.ruleengine.action.Action;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -7,9 +7,10 @@
|
|||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.ruleengine.action;
|
||||
package cc.iotkit.ruleengine.action.alert;
|
||||
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.ruleengine.action.ScriptService;
|
||||
import cc.iotkit.ruleengine.alert.Alerter;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import lombok.Data;
|
|
@ -7,10 +7,12 @@
|
|||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.ruleengine.action;
|
||||
package cc.iotkit.ruleengine.action.device;
|
||||
|
||||
import cc.iotkit.common.utils.JsonUtil;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.ruleengine.action.Action;
|
||||
import cc.iotkit.ruleengine.action.device.DeviceActionService.Service;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -21,7 +23,7 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class DeviceAction implements Action<DeviceActionService.Service> {
|
||||
public class DeviceAction implements Action<Service> {
|
||||
|
||||
public static final String TYPE = "device";
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.ruleengine.action;
|
||||
package cc.iotkit.ruleengine.action.device;
|
||||
|
||||
import cc.iotkit.common.utils.UniqueIdUtil;
|
||||
import cc.iotkit.comps.DeviceComponentManager;
|
|
@ -7,9 +7,10 @@
|
|||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.ruleengine.action;
|
||||
package cc.iotkit.ruleengine.action.http;
|
||||
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.ruleengine.action.Action;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -7,12 +7,13 @@
|
|||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.ruleengine.action;
|
||||
package cc.iotkit.ruleengine.action.http;
|
||||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.JsonUtil;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.ruleengine.action.ScriptService;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
|
@ -16,6 +16,10 @@ import cc.iotkit.model.Paging;
|
|||
import cc.iotkit.model.rule.RuleAction;
|
||||
import cc.iotkit.model.rule.RuleInfo;
|
||||
import cc.iotkit.ruleengine.action.*;
|
||||
import cc.iotkit.ruleengine.action.device.DeviceAction;
|
||||
import cc.iotkit.ruleengine.action.device.DeviceActionService;
|
||||
import cc.iotkit.ruleengine.action.http.HttpAction;
|
||||
import cc.iotkit.ruleengine.action.http.HttpService;
|
||||
import cc.iotkit.ruleengine.action.kafka.KafkaAction;
|
||||
import cc.iotkit.ruleengine.action.kafka.KafkaService;
|
||||
import cc.iotkit.ruleengine.action.mqtt.MqttAction;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
package cc.iotkit.ruleengine.task;
|
||||
|
||||
import cc.iotkit.common.utils.JsonUtil;
|
||||
import cc.iotkit.ruleengine.action.DeviceAction;
|
||||
import cc.iotkit.ruleengine.action.DeviceActionService;
|
||||
import cc.iotkit.ruleengine.action.device.DeviceAction;
|
||||
import cc.iotkit.ruleengine.action.device.DeviceActionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Request;
|
||||
import cc.iotkit.manager.service.AlertService;
|
||||
import cc.iotkit.model.Paging;
|
||||
import cc.iotkit.model.alert.AlertConfig;
|
||||
import cc.iotkit.model.alert.AlertRecord;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import javax.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = {"告警中心"})
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/alert")
|
||||
public class AlertController {
|
||||
|
||||
@Autowired
|
||||
private AlertService alertService;
|
||||
|
||||
|
||||
@ApiOperation("新增告警中心配置")
|
||||
@PostMapping("/createAlertConfig")
|
||||
public AlertConfig createAlertConfig(@RequestBody @Valid Request<AlertConfig> request) {
|
||||
return alertService.createAlertConfig(request);
|
||||
}
|
||||
|
||||
@ApiOperation("编辑告警中心配置")
|
||||
@PostMapping("/updateAlertConfig")
|
||||
public AlertConfig updateAlertConfig(@RequestBody @Valid Request<AlertConfig> request) {
|
||||
return alertService.updateAlertConfig(request);
|
||||
}
|
||||
|
||||
@ApiOperation("删除告警中心配置")
|
||||
@PostMapping("/deleteAlertConfigById")
|
||||
public Boolean deleteAlertConfigById(@RequestBody @Valid Request<String> request) {
|
||||
return alertService.deleteAlertConfigById(request);
|
||||
}
|
||||
|
||||
@ApiOperation("查询告警中心配置分页")
|
||||
@PostMapping("/selectAlertConfigPage")
|
||||
public Paging<AlertConfig> selectAlertConfigPage(@RequestBody @Valid PageRequest<AlertConfig> request) {
|
||||
return alertService.selectAlertConfigPage(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询告警消息分页")
|
||||
@PostMapping("/selectAlertRecordPage")
|
||||
public Paging<AlertRecord> selectAlertRecordPage(@RequestBody @Valid PageRequest<AlertRecord> request) {
|
||||
return alertService.selectAlertRecordPage(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.manager.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Request;
|
||||
import cc.iotkit.data.IAlertConfigData;
|
||||
import cc.iotkit.data.IAlertRecordData;
|
||||
import cc.iotkit.model.Paging;
|
||||
import cc.iotkit.model.alert.AlertConfig;
|
||||
import cc.iotkit.model.alert.AlertRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AlertService {
|
||||
|
||||
@Autowired
|
||||
private IAlertConfigData alertConfigData;
|
||||
@Autowired
|
||||
private IAlertRecordData alertRecordData;
|
||||
|
||||
public AlertConfig createAlertConfig(Request<AlertConfig> request) {
|
||||
return alertConfigData.save(request.getData());
|
||||
}
|
||||
|
||||
public AlertConfig updateAlertConfig(Request<AlertConfig> request) {
|
||||
return alertConfigData.save(request.getData());
|
||||
}
|
||||
|
||||
public Boolean deleteAlertConfigById(Request<String> request) {
|
||||
alertConfigData.deleteById(request.getData());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public Paging<AlertConfig> selectAlertConfigPage(PageRequest<AlertConfig> request) {
|
||||
return alertConfigData.selectAlertConfigPage(request);
|
||||
}
|
||||
|
||||
public Paging<AlertRecord> selectAlertRecordPage(PageRequest<AlertRecord> request) {
|
||||
return alertRecordData.selectAlertConfigPage(request);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue