feat:新功能
This commit is contained in:
parent
1d3e2253aa
commit
afd110d2b4
|
@ -78,8 +78,7 @@ public class MessageDTO implements Serializable {
|
|||
*/
|
||||
private String copyToUser;
|
||||
|
||||
public MessageDTO(){
|
||||
}
|
||||
public MessageDTO(){}
|
||||
|
||||
/**
|
||||
* 构造器1 系统消息
|
||||
|
@ -89,7 +88,7 @@ public class MessageDTO implements Serializable {
|
|||
this.toUser = toUser;
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
//默认 都是2系统消息
|
||||
//默认都是 2:系统消息
|
||||
this.category = CommonConstant.MSG_CATEGORY_2;
|
||||
}
|
||||
|
||||
|
@ -104,6 +103,11 @@ public class MessageDTO implements Serializable {
|
|||
this.category = category;
|
||||
}
|
||||
|
||||
public MessageDTO(String title, String content) {
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean isMarkdown() {
|
||||
return this.isMarkdown;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.jeecg.common.constant;
|
||||
|
||||
public interface DateConstant {
|
||||
|
||||
String DATE = "yyyy-MM-dd";
|
||||
|
||||
String TIME = "HH:mm:ss";
|
||||
|
||||
String DATE_TIME = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
String TIME_START = " 00:00:00";
|
||||
|
||||
String TIME_END = " 23:59:59";
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.jeecg.common.constant;
|
||||
|
||||
/**
|
||||
* 提示信息公共常量类
|
||||
*/
|
||||
public interface Prompt {
|
||||
|
||||
String ADD_SUCC = "Add Success!";
|
||||
|
||||
String ADD_ERR = "Add Failure!";
|
||||
|
||||
String UPDATE_SUCC = "Modified Success!";
|
||||
|
||||
String UPDATE_ERR = "Modified Failure!";
|
||||
|
||||
String DELETE_SUCC = "Delete Success!";
|
||||
|
||||
String DELETE_ERR = "Delete Failure!";
|
||||
|
||||
String FILE_NOT_EXITS = "The File Does Not Exist!";
|
||||
|
||||
String DATA_NOT_EXITS = "The Query Data Does Not Exist!";
|
||||
|
||||
String DATA_IS_EMPTY = "The Query Data IS Empty!";
|
||||
|
||||
String FTP_ERR = "FTP Connection Failed!";
|
||||
|
||||
String NOT_REPEAT = " Can Not Repeat!";
|
||||
}
|
|
@ -13,21 +13,22 @@ import java.util.List;
|
|||
@EnumDict("messageType")
|
||||
public enum MessageTypeEnum {
|
||||
|
||||
/* 发送全部 system|email|sms */
|
||||
ALL("all","所有消息","0"),
|
||||
/** 系统消息 */
|
||||
XT("system", "系统消息"),
|
||||
XT("system", "系统消息", "1"),
|
||||
/** 邮件消息 */
|
||||
YJ("email", "邮件消息"),
|
||||
/** 钉钉消息 */
|
||||
DD("dingtalk", "钉钉消息"),
|
||||
/** 企业微信 */
|
||||
QYWX("wechat_enterprise", "企业微信"),
|
||||
/* 邮箱消息 */
|
||||
YX("email-self", "邮箱消息"),
|
||||
YJ("email", "邮件消息", "2"),
|
||||
/* 手机短信 */
|
||||
SMS("sms", "手机短信");
|
||||
SMS("sms", "手机短信", "3"),
|
||||
/** 钉钉消息 */
|
||||
DD("dingtalk", "钉钉消息","4"),
|
||||
/** 企业微信 */
|
||||
QYWX("wechat_enterprise", "企业微信", "5");
|
||||
|
||||
MessageTypeEnum(String type, String note){
|
||||
MessageTypeEnum(String type, String note, String value){
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,8 @@ public enum MessageTypeEnum {
|
|||
*/
|
||||
String type;
|
||||
|
||||
String value;
|
||||
|
||||
/**
|
||||
* 类型说明
|
||||
*/
|
||||
|
@ -57,6 +60,9 @@ public enum MessageTypeEnum {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
|
@ -74,15 +80,9 @@ public enum MessageTypeEnum {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据type获取枚举
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static MessageTypeEnum valueOfType(String type) {
|
||||
public static MessageTypeEnum typeOf(String type) {
|
||||
for (MessageTypeEnum e : MessageTypeEnum.values()) {
|
||||
if (e.getType().equals(type)) {
|
||||
if (e.getValue().equals(type)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.sun.mail.smtp.SMTPAddressFailedException;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.email.emuns.MailContentType;
|
||||
import org.jeecg.modules.base.entity.SysEmail;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -186,18 +187,18 @@ public class EmailServiceManager {
|
|||
* @param messageDTO 消息dto
|
||||
*/
|
||||
private void reSendMail(Address[] invalid,MessageDTO messageDTO){
|
||||
List<String> invalidList = Arrays.stream(invalid)
|
||||
List<String> invalidEmails = Arrays.stream(invalid)
|
||||
.map(address -> address.toString())
|
||||
.collect(Collectors.toList());
|
||||
log.warn("部分或者全部邮件发送失败,无效的电子邮箱:{}",invalidList);
|
||||
String[] allEmails = messageDTO.getToUser().split(",");
|
||||
log.warn("部分或者全部邮件发送失败,无效的电子邮箱:{}",invalidEmails);
|
||||
String[] allEmails = messageDTO.getToUser().split(SymbolConstant.COMMA);
|
||||
String[] emails = new String[]{};
|
||||
for (String address : invalidList) {
|
||||
for (String address : invalidEmails) {
|
||||
emails = ArrayUtil.removeEle(allEmails,address);
|
||||
}
|
||||
// 如果移除无效电子邮箱后,待发送邮箱不为空
|
||||
String toUser = Arrays.stream(emails)
|
||||
.collect(Collectors.joining(","));
|
||||
.collect(Collectors.joining(SymbolConstant.COMMA));
|
||||
if (StrUtil.isNotBlank(toUser)){
|
||||
messageDTO.setToUser(toUser);
|
||||
sendMail(messageDTO);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.base.entity.Rule;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class AlarmRuleDto implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String operator;
|
||||
|
||||
private Integer enabled;
|
||||
|
||||
private String sourceName;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String sourceId;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
public class AlarmRuleInfo implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String operator;
|
||||
|
||||
private Long silenceCycle;
|
||||
|
||||
private String contactId;
|
||||
|
||||
private String sourceId;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String itemId;
|
||||
|
||||
private String sourceName;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DatabaseDto implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean online;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
private String port;
|
||||
|
||||
private String slowQuery;
|
||||
|
||||
private Integer alarms;
|
||||
|
||||
private boolean alarmRed;
|
||||
|
||||
private String cpuUutilzation;
|
||||
|
||||
private boolean cpuRed;
|
||||
|
||||
private String memoryUsage;
|
||||
|
||||
private boolean memoryRed;
|
||||
|
||||
private String diskUsage;
|
||||
|
||||
private boolean diskRed;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class EmailDto implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer enabled;
|
||||
|
||||
private boolean online;
|
||||
|
||||
private String emailServerAddress;
|
||||
|
||||
private Integer today;
|
||||
|
||||
private Integer yesterday;
|
||||
|
||||
private Integer weekly;
|
||||
|
||||
private Integer alarms;
|
||||
|
||||
private boolean alarmRed;
|
||||
|
||||
private String stoerCapacity;
|
||||
|
||||
private boolean stoerRed;
|
||||
}
|
|
@ -1,25 +1,22 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.base.entity.monitor.Item;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ItemDto implements Serializable {
|
||||
public class ItemDto implements Serializable{
|
||||
|
||||
private Double min;
|
||||
|
||||
private Double max;
|
||||
|
||||
private Double avg;
|
||||
|
||||
private Double now;
|
||||
private String itemId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String units;
|
||||
|
||||
private List<Object> list;
|
||||
public ItemDto(Item item) {
|
||||
this.itemId = item.getItemId();
|
||||
this.name = item.getName();
|
||||
this.units = item.getUnits();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.jeecg.modules.base.dto;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.modules.base.enums.Item;
|
||||
import org.jeecg.modules.base.enums.SourceType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ServerDto implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean online;
|
||||
|
||||
private String serverInfo;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
private Integer alarms;
|
||||
|
||||
private boolean alarmRed;
|
||||
|
||||
private String cpuUutilzation;
|
||||
|
||||
private boolean cpuRed;
|
||||
|
||||
private String memoryUsage;
|
||||
|
||||
private boolean memoryRed;
|
||||
|
||||
private String diskUsage;
|
||||
|
||||
private boolean diskRed;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SourceDto implements Serializable {
|
||||
|
||||
private String sourceId;
|
||||
|
||||
private String sourceName;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.jeecg.modules.base.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.system.base.entity.JeecgEntity;
|
||||
|
||||
@Data
|
||||
@TableName("alarm_item")
|
||||
public class AlarmItem extends JeecgEntity {
|
||||
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@TableField("units")
|
||||
private String units;
|
||||
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
@TableField("source_id")
|
||||
private String sourceId;
|
||||
}
|
|
@ -41,7 +41,7 @@ public class AlarmRule implements Serializable {
|
|||
private Long silenceCycle;
|
||||
|
||||
/**
|
||||
* 报警通知方式 1:短信 2.邮件 3.站内
|
||||
* 报警通知方式 3:短信 2.邮件 1.站内 0.全部
|
||||
*/
|
||||
@TableField(value = "notification")
|
||||
private String notification;
|
||||
|
@ -74,7 +74,7 @@ public class AlarmRule implements Serializable {
|
|||
* 监控项
|
||||
*/
|
||||
@TableField(value = "item_id")
|
||||
private Integer itemId;
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
@ -104,4 +104,9 @@ public class AlarmRule implements Serializable {
|
|||
@TableField(value = "update_by")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 用于新增报警规则
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Rule rule;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ public class Rule {
|
|||
|
||||
private Double threshold; // 阈值
|
||||
|
||||
private String units; // 单位
|
||||
|
||||
@JsonIgnore
|
||||
private Double current; // 当前值
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ public class SysEmail implements Serializable {
|
|||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* email服务地址
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package org.jeecg.modules.base.entity.monitor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Host implements Serializable {
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String hostId;
|
||||
|
||||
private String status_dictText;
|
||||
|
||||
private Map<String,Item> items;
|
||||
|
||||
private String status;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.jeecg.modules.base.entity.monitor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Item {
|
||||
|
||||
private String itemId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String hostId;
|
||||
|
||||
private String description;
|
||||
|
||||
private String units;
|
||||
|
||||
private String status;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.jeecg.modules.base.entity.monitor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ItemHistory implements Serializable {
|
||||
|
||||
private Double min;
|
||||
|
||||
private Double max;
|
||||
|
||||
private Double avg;
|
||||
|
||||
private Double now;
|
||||
|
||||
private String name;
|
||||
|
||||
private String units;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.jeecg.modules.base.entity.monitor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Servers implements Serializable {
|
||||
|
||||
private List<Host> records;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package org.jeecg.modules.base.enums;
|
||||
|
||||
public enum Item {
|
||||
|
||||
/* 服务器相关 */
|
||||
CPU_UTILIZ("cpu-utiliz"),
|
||||
/* 邮箱服务相关 */
|
||||
CONN("conn");
|
||||
/* 数据库相关 */
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
Item(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.jeecg.modules.base.enums;
|
||||
|
||||
public enum Notific {
|
||||
SYSTEM("1"),EMAIL("2"),PHONE("3");
|
||||
|
||||
private String way;
|
||||
|
||||
Notific(String way) {
|
||||
this.way = way;
|
||||
}
|
||||
|
||||
public String getWay() {
|
||||
return way;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.modules.base.enums;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*
|
||||
|
@ -22,4 +24,12 @@ public enum SourceType {
|
|||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static SourceType typeOf(String type){
|
||||
for (SourceType sourceType : SourceType.values()) {
|
||||
if (StrUtil.equals(sourceType.getType(),type))
|
||||
return sourceType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.jeecg.modules.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AlarmRuleVo extends QueryRequest implements Serializable {
|
||||
|
||||
private Integer enabled;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String sourceId;
|
||||
|
||||
private Integer pageStart;
|
||||
|
||||
// 标记:根据条件查询但不进行分页
|
||||
private String pageFlag;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.jeecg.modules.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SourceVo extends QueryRequest implements Serializable {
|
||||
|
||||
private List<String> sourceId;
|
||||
|
||||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
private Integer pageStart;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("alarmContactGroup")
|
||||
@Api(value = "联系组管理", tags = "联系组管理")
|
||||
public class AlarmContactGroupController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("alarmContactGroupMember")
|
||||
@Api(value = "联系组成员管理", tags = "联系组成员管理")
|
||||
public class AlarmContactGroupMemberController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.base.entity.AlarmItem;
|
||||
import org.jeecg.modules.service.IAlarmItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Api(value = "监控项管理",tags = "监控项管理")
|
||||
@RestController
|
||||
@RequestMapping("/alarmitem")
|
||||
public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemService> {
|
||||
|
||||
@Autowired
|
||||
private IAlarmItemService alarmItemService;
|
||||
|
||||
|
||||
}
|
|
@ -2,31 +2,41 @@ package org.jeecg.modules.controller;
|
|||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.AlarmRule;
|
||||
import org.jeecg.modules.base.entity.monitor.Host;
|
||||
import org.jeecg.modules.base.entity.monitor.Servers;
|
||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||
import org.jeecg.modules.base.dto.ItemDto;
|
||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||
import org.jeecg.modules.service.IAlarmRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("alarmRule")
|
||||
@Api(value = "报警规则管理", tags = "报警规则管理")
|
||||
public class AlarmRuleController {
|
||||
|
||||
@Autowired
|
||||
private MonitorAlarm monitorAlarm;
|
||||
|
||||
@Autowired
|
||||
private IAlarmRuleService alarmRuleService;
|
||||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "分页查询报警规则信息", notes = "分页查询报警规则信息")
|
||||
public Result findPage(QueryRequest queryRequest, AlarmRule alarmRule){
|
||||
return alarmRuleService.findPage(queryRequest, alarmRule);
|
||||
@ApiOperation(value = "分页查询报警规则", notes = "分页查询报警规则")
|
||||
public Result findPage(AlarmRuleVo alarmRuleVo){
|
||||
return alarmRuleService.findPage(alarmRuleVo);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
@ApiOperation(value = "查看规则信息详情", notes = "查看规则信息详情")
|
||||
public Result findInfo(String id){
|
||||
return alarmRuleService.findInfo(id);
|
||||
public Result findInfo(@RequestParam String alarmRuleId){
|
||||
return alarmRuleService.findInfo(alarmRuleId);
|
||||
}
|
||||
|
||||
@PostMapping("create")
|
||||
|
@ -43,8 +53,36 @@ public class AlarmRuleController {
|
|||
|
||||
@DeleteMapping("deleteById")
|
||||
@ApiOperation(value = "删除规则信息", notes = "删除规则信息")
|
||||
public Result deleteById(String id){
|
||||
return alarmRuleService.deleteById(id);
|
||||
public Result deleteById(@RequestParam String alarmRuleId){
|
||||
return alarmRuleService.deleteById(alarmRuleId);
|
||||
}
|
||||
|
||||
@GetMapping("getSources")
|
||||
@ApiOperation(value = "根据资源类型获取资源",notes = "根据资源类型获取资源")
|
||||
public Result getSources(@RequestParam String souceType){
|
||||
return alarmRuleService.getSourceByType(souceType);
|
||||
}
|
||||
|
||||
@GetMapping("getItems")
|
||||
@ApiOperation(value = "根据资源名称获取监控项",notes = "根据资源名称获取监控项")
|
||||
public Result getItems(@RequestParam String sourceName){
|
||||
Result<Servers> result = monitorAlarm.listBack(sourceName);
|
||||
List<Host> hosts = result.getResult().getRecords();
|
||||
List<ItemDto> itemDtos = new ArrayList<>();
|
||||
for (Host host : hosts) {
|
||||
boolean equals = host.getCode().equals(sourceName);
|
||||
if(!equals)continue;
|
||||
itemDtos = host.getItems().values().stream()
|
||||
.map(ItemDto::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return Result.OK(itemDtos);
|
||||
}
|
||||
|
||||
@PutMapping("updateStatus")
|
||||
@ApiOperation(value = "修改规则状态", notes = "修改规则状态")
|
||||
public Result updateStatus(@RequestParam String alarmRuleId,
|
||||
@RequestParam Integer enabled){
|
||||
return alarmRuleService.updateStatus(alarmRuleId,enabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sysDatabase")
|
||||
|
@ -23,8 +23,8 @@ public class SysDatabaseController {
|
|||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "分页查询数据库配置信息", notes = "分页查询数据库配置信息")
|
||||
public Result findPage(QueryRequest queryRequest, SysDatabase sysDatabase){
|
||||
return sysDatabaseService.findPage(queryRequest, sysDatabase);
|
||||
public Result findPage(QueryRequest query){
|
||||
return sysDatabaseService.findPage(query);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
|
@ -53,9 +53,14 @@ public class SysDatabaseController {
|
|||
|
||||
@GetMapping("findAlarmHistory")
|
||||
@ApiOperation(value = "查询数据库历史报警信息", notes = "查询数据库历史报警信息")
|
||||
public Result findAlarmHistory(String databaseId,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
|
||||
return sysDatabaseService.findAlarmHistory(databaseId, startTime, endTime);
|
||||
public Result findAlarmHistory(SourceVo sourceVo){
|
||||
return sysDatabaseService.findAlarmHistory(sourceVo);
|
||||
}
|
||||
|
||||
@GetMapping("sourceList")
|
||||
@ApiOperation(value = "数据库服务名列表",notes = "数据库服务名列表")
|
||||
public Result sourceList(){
|
||||
List<SourceDto> sourceDtos = sysDatabaseService.listAll();
|
||||
return Result.OK(sourceDtos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,19 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.SysEmail;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.service.ISysEmailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sysEmail")
|
||||
@Api(value = "邮箱配置信息管理", tags = "邮箱配置信息管理")
|
||||
@Api(value = "邮箱配置管理", tags = "邮箱配置管理")
|
||||
public class SysEmailController {
|
||||
|
||||
@Autowired
|
||||
|
@ -22,8 +25,8 @@ public class SysEmailController {
|
|||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "分页查询邮箱配置信息", notes = "分页查询邮箱配置信息")
|
||||
public Result findPage(QueryRequest queryRequest, SysEmail sysEmail){
|
||||
return sysEmailService.findPage(queryRequest, sysEmail);
|
||||
public Result findPage(QueryRequest query){
|
||||
return sysEmailService.findPage(query);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
|
@ -52,13 +55,20 @@ public class SysEmailController {
|
|||
|
||||
@GetMapping("findAlarmHistory")
|
||||
@ApiOperation(value = "查询邮箱历史报警信息", notes = "查询邮箱历史报警信息")
|
||||
public Result findAlarmHistory(String emailId,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
|
||||
return sysEmailService.findAlarmHistory(emailId, startTime, endTime);
|
||||
public Result findAlarmHistory(SourceVo sourceVo){
|
||||
return sysEmailService.findAlarmHistory(sourceVo);
|
||||
}
|
||||
|
||||
@GetMapping("getSender")
|
||||
@ApiOperation(value = "获取发件邮箱服务器", notes = "获取发件邮箱服务器")
|
||||
public Result<SysEmail> getSender(){
|
||||
return sysEmailService.getSender();
|
||||
}
|
||||
|
||||
@GetMapping("sourceList")
|
||||
@ApiOperation(value = "邮箱服务名列表",notes = "邮箱服务名列表")
|
||||
public Result sourceList(){
|
||||
List<SourceDto> sourceDtos = sysEmailService.listAll();
|
||||
return Result.OK(sourceDtos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.SysServer;
|
||||
import org.jeecg.modules.service.ISysServerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -11,10 +13,11 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sysServer")
|
||||
@Api(value = "服务器配置信息管理", tags = "服务器配置信息管理")
|
||||
@Api(value = "服务器配置管理", tags = "服务器配置管理")
|
||||
public class SysServerController {
|
||||
|
||||
@Autowired
|
||||
|
@ -22,8 +25,8 @@ public class SysServerController {
|
|||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "分页查询服务器数据", notes = "分页查询服务器数据")
|
||||
public Result findPage(QueryRequest queryRequest, SysServer sysServer){
|
||||
return sysServerService.findPage(queryRequest, sysServer);
|
||||
public Result findPage(QueryRequest query){
|
||||
return sysServerService.findPage(query);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
|
@ -52,9 +55,14 @@ public class SysServerController {
|
|||
|
||||
@GetMapping("findAlarmHistory")
|
||||
@ApiOperation(value = "查询服务器历史报警信息", notes = "查询服务器历史报警信息")
|
||||
public Result findAlarmHistory(String serverId,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
|
||||
return sysServerService.findAlarmHistory(serverId, startTime, endTime);
|
||||
public Result findAlarmHistory(SourceVo sourceVo){
|
||||
return sysServerService.findAlarmHistory(sourceVo);
|
||||
}
|
||||
|
||||
@GetMapping("sourceList")
|
||||
@ApiOperation(value = "服务器服务名列表",notes = "服务器服务名列表")
|
||||
public Result sourceList(){
|
||||
List<SourceDto> sourceDtos = sysServerService.listAll();
|
||||
return Result.OK(sourceDtos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,4 +36,9 @@ public class AlarmHistory {
|
|||
* 来源类型
|
||||
*/
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 报警值
|
||||
*/
|
||||
private String alarmValue;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.jeecg.modules.feignclient;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.monitor.ItemHistory;
|
||||
import org.jeecg.modules.base.entity.monitor.Servers;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Component
|
||||
@FeignClient(name = "monitorAlarm",url = "http://218.249.158.97:7008/mobile/monitor")
|
||||
public interface MonitorAlarm {
|
||||
|
||||
// --------------------后端专用-------------------
|
||||
@GetMapping("list")
|
||||
Result<Servers> listBack(@RequestParam String code);
|
||||
|
||||
@GetMapping("queryItemHistory")
|
||||
Result<ItemHistory> itemBack(@RequestParam String itemId,
|
||||
@RequestParam Integer itemType,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
// --------------------返给前端-------------------
|
||||
@GetMapping("list")
|
||||
Result<?> list(@RequestParam String code,
|
||||
@RequestParam String hostId,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String status,
|
||||
@RequestParam String type);
|
||||
|
||||
@GetMapping("queryItemHistory")
|
||||
Result<?> item(@RequestParam String itemId,
|
||||
@RequestParam Integer itemType,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
@GetMapping("queryItemHistoryData")
|
||||
Result<?> itemData(@RequestParam String itemId,
|
||||
@RequestParam Integer itemType,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
@GetMapping("queryHostDetails")
|
||||
Result<?> detail(@RequestParam String hostId,
|
||||
@RequestParam String pageName,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
@GetMapping("log")
|
||||
Result<?> log(@RequestParam String code,
|
||||
@RequestParam String deviceType,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end,
|
||||
@RequestParam String status);
|
||||
|
||||
@GetMapping("log/{hostId}")
|
||||
Result<?> OneLog(@PathVariable("hostId") String hostId,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end,
|
||||
@RequestParam String status);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.base.entity.AlarmItem;
|
||||
|
||||
public interface AlarmItemMapper extends BaseMapper<AlarmItem> {
|
||||
|
||||
}
|
|
@ -1,7 +1,16 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.base.dto.AlarmRuleDto;
|
||||
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
||||
import org.jeecg.modules.base.entity.AlarmRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AlarmRuleMapper extends BaseMapper<AlarmRule> {
|
||||
|
||||
List<AlarmRuleDto> findPage(Map<String, Object> params);
|
||||
|
||||
AlarmRuleInfo findInfo(String alarmRuleId);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,18 @@ package org.jeecg.modules.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.dto.DatabaseDto;
|
||||
import org.jeecg.modules.base.dto.ServerDto;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysDatabaseMapper extends BaseMapper<SysDatabase> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory(@Param("databaseId") String databaseId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
||||
|
||||
List<DatabaseDto> findPage(Map<String,Object> params);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,18 @@ package org.jeecg.modules.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.dto.EmailDto;
|
||||
import org.jeecg.modules.base.dto.ServerDto;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.base.entity.SysEmail;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysEmailMapper extends BaseMapper<SysEmail> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory( @Param("emailId") String emailId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
||||
|
||||
List<EmailDto> findPage(Map<String,Object> params);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,18 @@ package org.jeecg.modules.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.jeecg.modules.base.dto.ServerDto;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysServer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysServerMapper extends BaseMapper<SysServer> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory(@Param("serverId")String serverId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
||||
|
||||
List<ServerDto> findPage(Map<String,Object> params);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?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="org.jeecg.modules.mapper.AlarmItemMapper">
|
||||
|
||||
</mapper>
|
|
@ -29,6 +29,7 @@
|
|||
(SELECT
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
l.alarm_value,
|
||||
r.OPERATOR,
|
||||
r.source_type,
|
||||
CASE
|
||||
|
@ -61,6 +62,7 @@
|
|||
AND alarm_start_date <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY alarm_start_date DESC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?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="org.jeecg.modules.mapper.AlarmRuleMapper">
|
||||
<select id="findPage" parameterType="Map" resultType="org.jeecg.modules.base.dto.AlarmRuleDto">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(SELECT
|
||||
r.id,
|
||||
r.NAME,
|
||||
r.enabled,
|
||||
r.OPERATOR,
|
||||
r.source_type,
|
||||
r.source_id,
|
||||
g.NAME AS groupName,
|
||||
CASE
|
||||
r.source_type
|
||||
WHEN 'Server' THEN
|
||||
( SELECT NAME FROM sys_server WHERE ID = r.source_id )
|
||||
WHEN 'Database' THEN
|
||||
( SELECT NAME FROM sys_database WHERE ID = r.source_id )
|
||||
WHEN 'Email' THEN
|
||||
( SELECT USERNAME FROM sys_email WHERE ID = r.source_id )
|
||||
END AS sourceName
|
||||
FROM
|
||||
alarm_rule r
|
||||
INNER JOIN alarm_contact_group g ON g.id = r.contact_id
|
||||
) AS res
|
||||
<where>
|
||||
<if test="enabled != null">
|
||||
enabled = #{enabled}
|
||||
</if>
|
||||
<if test="sourceType != null and sourceType != ''">
|
||||
AND source_type = #{sourceType}
|
||||
</if>
|
||||
<if test="sourceId != null and sourceId != ''">
|
||||
AND source_id = #{sourceId}
|
||||
</if>
|
||||
</where>
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findInfo" parameterType="String" resultType="org.jeecg.modules.base.dto.AlarmRuleInfo">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(SELECT
|
||||
r.id,
|
||||
r.NAME,
|
||||
r.OPERATOR,
|
||||
r.silence_cycle,
|
||||
r.contact_id,
|
||||
r.source_id,
|
||||
r.source_type,
|
||||
r.item_id,
|
||||
CASE
|
||||
r.source_type
|
||||
WHEN 'Server' THEN
|
||||
( SELECT NAME FROM sys_server WHERE ID = r.source_id )
|
||||
WHEN 'Database' THEN
|
||||
( SELECT NAME FROM sys_database WHERE ID = r.source_id )
|
||||
WHEN 'Email' THEN
|
||||
( SELECT USERNAME FROM sys_email WHERE ID = r.source_id )
|
||||
END AS sourceName
|
||||
FROM
|
||||
alarm_rule r
|
||||
) AS res
|
||||
<where>
|
||||
<if test="alarmRuleId != null and alarmRuleId != ''">
|
||||
id = #{alarmRuleId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,23 +1,52 @@
|
|||
<?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="org.jeecg.modules.mapper.SysEmailMapper">
|
||||
|
||||
<select id="findAlarmHistory" resultType="org.jeecg.modules.entity.AlarmHistory">
|
||||
SELECT
|
||||
se.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator
|
||||
e.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator,
|
||||
l.alarm_value
|
||||
FROM
|
||||
sys_email se
|
||||
inner join alarm_rule r on r.source_id = se.id
|
||||
inner join alarm_log l on l.rule_id = r.id
|
||||
sys_email e
|
||||
INNER JOIN alarm_rule r ON r.source_id = e.id
|
||||
INNER JOIN alarm_log l ON l.rule_id = r.id
|
||||
<where>
|
||||
l.alarm_start_date between #{startDate} and #{endDate}
|
||||
<if test=" emailId != null and emailId != '' ">
|
||||
and se.id = #{emailId}
|
||||
<if test="sourceId != null and sourceId.size() > 0">
|
||||
e.id IN
|
||||
<foreach collection="sourceId" index="index" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
AND l.alarm_start_date >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
AND l.alarm_start_date <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY alarm_start_date DESC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.EmailDto">
|
||||
SELECT
|
||||
e.ID,
|
||||
e.NAME,
|
||||
e.enabled,
|
||||
e.email_server_address,
|
||||
COUNT (l.id) AS alarms
|
||||
FROM
|
||||
sys_email e
|
||||
LEFT JOIN alarm_rule r ON e.ID = r.source_id
|
||||
LEFT JOIN alarm_log l ON r.ID = l.rule_id
|
||||
AND l.alarm_start_date BETWEEN #{startDate} AND #{endDate}
|
||||
GROUP BY e.ID, e.NAME, e.email_server_address
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,23 +1,51 @@
|
|||
<?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="org.jeecg.modules.mapper.SysServerMapper">
|
||||
|
||||
<select id="findAlarmHistory" resultType="org.jeecg.modules.entity.AlarmHistory">
|
||||
SELECT
|
||||
se.name,
|
||||
s.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator
|
||||
r.operator,
|
||||
l.alarm_value
|
||||
FROM
|
||||
sys_server se
|
||||
inner join alarm_rule r on r.source_id = se.id
|
||||
inner join alarm_log l on l.rule_id = r.id
|
||||
sys_server s
|
||||
INNER JOIN alarm_rule r ON r.source_id = s.id
|
||||
INNER JOIN alarm_log l ON l.rule_id = r.id
|
||||
<where>
|
||||
l.alarm_start_date between #{startDate} and #{endDate}
|
||||
<if test=" serverId != null and serverId != '' ">
|
||||
and se.id = #{serverId}
|
||||
<if test="sourceId != null and sourceId.size() > 0">
|
||||
s.id IN
|
||||
<foreach collection="sourceId" index="index" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
AND l.alarm_start_date >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
AND l.alarm_start_date <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY alarm_start_date DESC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.ServerDto">
|
||||
SELECT
|
||||
s.ID,
|
||||
s.NAME,
|
||||
s.ip_address,
|
||||
COUNT (l.id) AS alarms
|
||||
FROM
|
||||
sys_server s
|
||||
LEFT JOIN alarm_rule r ON s.ID = r.source_id
|
||||
LEFT JOIN alarm_log l ON r.ID = l.rule_id
|
||||
AND l.alarm_start_date BETWEEN #{startDate} AND #{endDate}
|
||||
GROUP BY s.ID,s.NAME,s.ip_address
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,20 +4,50 @@
|
|||
|
||||
<select id="findAlarmHistory" resultType="org.jeecg.modules.entity.AlarmHistory">
|
||||
SELECT
|
||||
se.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator
|
||||
d.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator,
|
||||
l.alarm_value
|
||||
FROM
|
||||
sys_database se
|
||||
inner join alarm_rule r on r.source_id = se.id
|
||||
inner join alarm_log l on l.rule_id = r.id
|
||||
sys_database d
|
||||
INNER JOIN alarm_rule r ON r.source_id = d.id
|
||||
INNER JOIN alarm_log l ON l.rule_id = r.id
|
||||
<where>
|
||||
l.alarm_start_date between #{startDate} and #{endDate}
|
||||
<if test=" databaseId != null and databaseId != '' ">
|
||||
and se.id = #{databaseId}
|
||||
<if test="sourceId != null and sourceId.size() > 0">
|
||||
d.id IN
|
||||
<foreach collection="sourceId" index="index" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
AND l.alarm_start_date >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
AND l.alarm_start_date <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY alarm_start_date DESC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.DatabaseDto">
|
||||
SELECT
|
||||
d.ID,
|
||||
d.NAME,
|
||||
d.port,
|
||||
d.ip_address,
|
||||
COUNT (l.id) AS alarms
|
||||
FROM
|
||||
sys_database d
|
||||
LEFT JOIN alarm_rule r ON d.ID = r.source_id
|
||||
LEFT JOIN alarm_log l ON r.ID = l.rule_id
|
||||
AND l.alarm_start_date BETWEEN #{startDate} AND #{endDate}
|
||||
GROUP BY d.ID, d.NAME, d.port, d.ip_address
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -19,4 +19,5 @@ public interface IAlarmContactGroupService extends IService<AlarmContactGroup> {
|
|||
|
||||
Result deleteUserById(String id, String userId);
|
||||
|
||||
AlarmContactGroup getByName(String groupName);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.AlarmItem;
|
||||
|
||||
public interface IAlarmItemService extends IService<AlarmItem> {
|
||||
Result syncItem(String sourceType,String code);
|
||||
}
|
|
@ -4,16 +4,21 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.AlarmRule;
|
||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||
|
||||
public interface IAlarmRuleService extends IService<AlarmRule> {
|
||||
|
||||
Result findPage(QueryRequest queryRequest, AlarmRule alarmRule);
|
||||
Result findPage(AlarmRuleVo alarmRuleVo);
|
||||
|
||||
Result findInfo(String id);
|
||||
Result findInfo(String alarmRuleId);
|
||||
|
||||
Result create(AlarmRule alarmRule);
|
||||
|
||||
Result update(AlarmRule alarmRule);
|
||||
|
||||
Result deleteById(String id);
|
||||
Result deleteById(String alarmRuleId);
|
||||
|
||||
Result getSourceByType(String sourceType);
|
||||
|
||||
Result updateStatus(String alarmRuleId,Integer enabled);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,16 @@ package org.jeecg.modules.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysDatabaseService extends IService<SysDatabase> {
|
||||
|
||||
Result findPage(QueryRequest queryRequest, SysDatabase sysDatabase);
|
||||
Result findPage(QueryRequest query);
|
||||
|
||||
Result findInfo(String id);
|
||||
|
||||
|
@ -20,6 +22,7 @@ public interface ISysDatabaseService extends IService<SysDatabase> {
|
|||
|
||||
Result deleteById(String id);
|
||||
|
||||
Result findAlarmHistory(String databaseId, Date startTime, Date endTime);
|
||||
Result findAlarmHistory(SourceVo sourceVo);
|
||||
|
||||
List<SourceDto> listAll();
|
||||
}
|
||||
|
|
|
@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.SysEmail;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysEmailService extends IService<SysEmail> {
|
||||
|
||||
Result findPage(QueryRequest queryRequest, SysEmail sysEmail);
|
||||
Result findPage(QueryRequest query);
|
||||
|
||||
Result findInfo(String id);
|
||||
|
||||
|
@ -19,8 +22,9 @@ public interface ISysEmailService extends IService<SysEmail> {
|
|||
|
||||
Result deleteById(String id);
|
||||
|
||||
Result findAlarmHistory(String emailId, Date startTime, Date endTime);
|
||||
Result findAlarmHistory(SourceVo sourceVo);
|
||||
|
||||
Result<SysEmail> getSender();
|
||||
|
||||
List<SourceDto> listAll();
|
||||
}
|
||||
|
|
|
@ -3,13 +3,16 @@ package org.jeecg.modules.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.SysServer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysServerService extends IService<SysServer> {
|
||||
|
||||
Result findPage(QueryRequest queryRequest, SysServer sysServer);
|
||||
Result findPage(QueryRequest query);
|
||||
|
||||
Result findInfo(String id);
|
||||
|
||||
|
@ -19,6 +22,9 @@ public interface ISysServerService extends IService<SysServer> {
|
|||
|
||||
Result deleteById(String id);
|
||||
|
||||
Result findAlarmHistory(String serverId, Date startTime, Date endTime);
|
||||
Result findAlarmHistory(SourceVo sourceVo);
|
||||
|
||||
List<SourceDto> listAll();
|
||||
|
||||
String getByName(String name);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
|
@ -38,6 +40,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
Map<String ,SysUser> userList = systemClient.findUserMap();
|
||||
Page<AlarmContactGroup> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
LambdaQueryWrapper<AlarmContactGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.orderByDesc(AlarmContactGroup::getCreateTime);
|
||||
Page<AlarmContactGroup> alarmContactGroupPage = this.baseMapper.selectPage(page, queryWrapper);
|
||||
LambdaQueryWrapper<AlarmContactGroupMember> contactGroupMemberQueryWrapper = new LambdaQueryWrapper<>();
|
||||
List<AlarmContactGroupMember> alarmContactGroupMembers = alarmContactGroupMemberMapper.selectList(contactGroupMemberQueryWrapper);
|
||||
|
@ -74,7 +77,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
queryWrapper.eq(AlarmContactGroup::getId, id);
|
||||
AlarmContactGroup alarmContactGroup = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(alarmContactGroup)){
|
||||
result.error500("查询数据失败,对应数据不存在");
|
||||
result.error500("Failed to query the data because the corresponding data does not exist!");
|
||||
return result;
|
||||
}
|
||||
//通过联系人组id查询出对应的联系人信息
|
||||
|
@ -95,6 +98,12 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
|
||||
String groupName = alarmContactGroup.getName();
|
||||
if (StrUtil.isBlank(groupName))return Result.error("Please enter the contact group name!");
|
||||
AlarmContactGroup contactGroup = getByName(groupName);
|
||||
if (ObjectUtil.isNotNull(contactGroup))return Result.error("Contact group name cannot be repeated, please fill in again!");
|
||||
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
Long id = IdWorker.getId();
|
||||
|
@ -114,7 +123,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.success("新增成功");
|
||||
result.success("New success!");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -123,13 +132,24 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
|
||||
String groupName = alarmContactGroup.getName();
|
||||
if (StrUtil.isBlank(groupName))return Result.error("Please enter the contact group name!");
|
||||
AlarmContactGroup groupById = this.getById(alarmContactGroup.getId());
|
||||
boolean equals = groupById.getName().equals(alarmContactGroup.getName());
|
||||
if (!equals){
|
||||
AlarmContactGroup groupByName = getByName(groupName);
|
||||
if (ObjectUtil.isNotNull(groupByName))
|
||||
return Result.error("Contact group name cannot be repeated, please fill in again!");
|
||||
}
|
||||
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
LambdaQueryWrapper<AlarmContactGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AlarmContactGroup::getId, alarmContactGroup.getId());
|
||||
AlarmContactGroup contactGroup = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(contactGroup)){
|
||||
result.error500("对应数据不存在");
|
||||
result.error500("The corresponding data does not exist!");
|
||||
return result;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(alarmContactGroup.getUserIds())){
|
||||
|
@ -150,7 +170,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
alarmContactGroup.setUpdateBy(username);
|
||||
this.baseMapper.updateById(alarmContactGroup);
|
||||
result.setSuccess(true);
|
||||
result.success("修改成功");
|
||||
result.success("Modified successfully!");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -164,7 +184,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
//删除联系人组信息
|
||||
this.baseMapper.deleteById(id);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
result.success("Successfully deleted!");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -176,8 +196,15 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
|||
contactGroupMemberQueryWrapper.eq(AlarmContactGroupMember::getUserId, userId);
|
||||
alarmContactGroupMemberMapper.delete(contactGroupMemberQueryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
result.success("Successfully deleted!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlarmContactGroup getByName(String groupName) {
|
||||
LambdaQueryWrapper<AlarmContactGroup> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AlarmContactGroup::getName,groupName);
|
||||
return getOne(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.modules.base.entity.AlarmItem;
|
||||
import org.jeecg.modules.base.entity.monitor.Host;
|
||||
import org.jeecg.modules.base.entity.monitor.Item;
|
||||
import org.jeecg.modules.base.entity.monitor.Servers;
|
||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||
import org.jeecg.modules.mapper.AlarmItemMapper;
|
||||
import org.jeecg.modules.service.IAlarmItemService;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
import org.jeecg.modules.service.ISysServerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jeecg.modules.base.enums.SourceType.DATABASE;
|
||||
import static org.jeecg.modules.base.enums.SourceType.SERVER;
|
||||
|
||||
|
||||
@Service
|
||||
public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem> implements IAlarmItemService {
|
||||
|
||||
@Autowired
|
||||
private MonitorAlarm monitorAlarm;
|
||||
|
||||
@Autowired
|
||||
private ISysServerService serverService;
|
||||
|
||||
@Autowired
|
||||
private ISysDatabaseService databaseService;
|
||||
|
||||
@Override
|
||||
public Result syncItem(String type,String code) {
|
||||
String sourceId = null;
|
||||
if (SERVER.getType().equals(type)){
|
||||
sourceId = serverService.getByName(code);
|
||||
} else if (DATABASE.getType().equals(type)) {
|
||||
|
||||
}else {
|
||||
return Result.error("Soucrce Type Not Extis!");
|
||||
}
|
||||
if (StrUtil.isBlank(sourceId))
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
|
||||
Result<Servers> result = monitorAlarm.listBack(code);
|
||||
List<Host> hosts = result.getResult().getRecords();
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (Host host : hosts) {
|
||||
boolean equals = host.getCode().equals(code);
|
||||
if(!equals) continue;
|
||||
items = ListUtil.toList(host.getItems().values());
|
||||
}
|
||||
if (CollUtil.isEmpty(items))
|
||||
return Result.error(Prompt.DATA_IS_EMPTY);
|
||||
|
||||
List<AlarmItem> alarmItems = new ArrayList<>();
|
||||
for (Item item : items) {
|
||||
AlarmItem alarmItem = new AlarmItem();
|
||||
alarmItem.setId(item.getItemId());
|
||||
alarmItem.setName(item.getName());
|
||||
alarmItem.setUnits(item.getUnits());
|
||||
alarmItem.setSourceId(sourceId);
|
||||
alarmItem.setDescription(item.getDescription());
|
||||
alarmItems.add(alarmItem);
|
||||
}
|
||||
if(saveOrUpdateBatch(alarmItems))
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
|
@ -9,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.modules.dto.TypeDto;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.base.entity.AlarmLog;
|
||||
|
@ -35,6 +37,8 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
public Result viewAll(AlarmVo alarmVo) {
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
boolean startNotBlank = StrUtil.isNotBlank(startDate);
|
||||
boolean endtNotBlank = StrUtil.isNotBlank(endDate);
|
||||
// 拼接日期为合理的日期+时间范围
|
||||
alarmVo.setStartDate(startDate + " 00:00:00");
|
||||
alarmVo.setEndDate(endDate + " 23:59:59");
|
||||
|
@ -113,17 +117,22 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
public Result findPage(AlarmVo alarmVo) {
|
||||
Integer pageNo = alarmVo.getPageNo();
|
||||
Integer pageSize = alarmVo.getPageSize();
|
||||
Page<AlarmHistory> page = new Page<>(pageNo,pageSize);
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
if (StrUtil.isNotBlank(startDate))
|
||||
alarmVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (StrUtil.isNotBlank(endDate))
|
||||
alarmVo.setEndDate(endDate + DateConstant.TIME_END);
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
alarmVo.setPageStart(pageStart);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
|
||||
List<AlarmHistory> alarmHistories = baseMapper.findPage(params);
|
||||
// 当前页数据
|
||||
page.setRecords(alarmHistories);
|
||||
// 获取数据总条数(经过查询条件过滤后的)
|
||||
params.put("pageFlag","noPage");
|
||||
Integer total = baseMapper.findPage(params).size();
|
||||
page.setTotal(total);
|
||||
Page<AlarmHistory> page = new Page<>(pageNo,pageSize,total);
|
||||
// 当前页数据
|
||||
page.setRecords(alarmHistories);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
|
@ -134,6 +143,12 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
@Override
|
||||
public Result typeAlarms(AlarmVo alarmVo) {
|
||||
/* 饼图数据 */
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
boolean startNotBlank = StrUtil.isNotBlank(startDate);
|
||||
boolean endtNotBlank = StrUtil.isNotBlank(endDate);
|
||||
if (startNotBlank) alarmVo.setStartDate(startDate +" 00:00:00");
|
||||
if (endtNotBlank)alarmVo.setEndDate(endDate +" 23:59:59");
|
||||
// 警报类型-警报数
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
|
||||
List<TypeDto> typeAlarms = baseMapper.typeAlarms(params);
|
||||
|
@ -152,6 +167,12 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
@Override
|
||||
public Result ruleTop5(AlarmVo alarmVo) {
|
||||
/* 柱状图数据 */
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
boolean startNotBlank = StrUtil.isNotBlank(startDate);
|
||||
boolean endtNotBlank = StrUtil.isNotBlank(endDate);
|
||||
if (startNotBlank) alarmVo.setStartDate(startDate +" 00:00:00");
|
||||
if (endtNotBlank)alarmVo.setEndDate(endDate +" 23:59:59");
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
|
||||
List<TypeDto> ruleTop5 = baseMapper.ruleTop5(params);
|
||||
// x轴数据
|
||||
|
|
|
@ -1,130 +1,132 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.AlarmRuleDto;
|
||||
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
||||
import org.jeecg.modules.base.entity.AlarmRule;
|
||||
import org.jeecg.modules.base.entity.Rule;
|
||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.mapper.AlarmRuleMapper;
|
||||
import org.jeecg.modules.service.IAlarmRuleService;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
import org.jeecg.modules.service.ISysEmailService;
|
||||
import org.jeecg.modules.service.ISysServerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jeecg.modules.base.enums.SourceType.*;
|
||||
|
||||
@Service("alarmRuleService")
|
||||
public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule> implements IAlarmRuleService {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private RedisStreamUtil redisStreamUtil;
|
||||
|
||||
@Autowired
|
||||
private ISysEmailService emailService;
|
||||
|
||||
@Autowired
|
||||
private ISysServerService serverService;
|
||||
|
||||
@Autowired
|
||||
private ISysDatabaseService databaseService;
|
||||
|
||||
@Override
|
||||
public Result findPage(QueryRequest queryRequest, AlarmRule alarmRule) {
|
||||
Result result = new Result();
|
||||
Page<AlarmRule> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
LambdaQueryWrapper<AlarmRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Objects.nonNull(alarmRule.getEnabled()), AlarmRule::getEnabled, alarmRule.getEnabled());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(alarmRule.getSourceId()), AlarmRule::getSourceId, alarmRule.getSourceId());
|
||||
Page<AlarmRule> alarmRulePage = this.baseMapper.selectPage(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmRulePage);
|
||||
return result;
|
||||
public Result findPage(AlarmRuleVo alarmRuleVo) {
|
||||
Integer pageNo = alarmRuleVo.getPageNo();
|
||||
Integer pageSize = alarmRuleVo.getPageSize();
|
||||
Page<AlarmRuleDto> page = new Page<>(pageNo,pageSize);
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
alarmRuleVo.setPageStart(pageStart);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmRuleVo);
|
||||
List<AlarmRuleDto> alarmHistories = baseMapper.findPage(params);
|
||||
// 当前页数据
|
||||
page.setRecords(alarmHistories);
|
||||
// 获取数据总条数(经过查询条件过滤后的)
|
||||
params.put("pageFlag","noPage");
|
||||
Integer total = baseMapper.findPage(params).size();
|
||||
page.setTotal(total);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findInfo(String id) {
|
||||
Result result = new Result();
|
||||
//根据id查询对应数据信息
|
||||
LambdaQueryWrapper<AlarmRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AlarmRule::getId, id);
|
||||
AlarmRule alarmRule = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(alarmRule)){
|
||||
result.error500("查询数据不存在");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmRule);
|
||||
return result;
|
||||
public Result findInfo(String alarmRuleId) {
|
||||
AlarmRuleInfo alarmRuleInfo = baseMapper.findInfo(alarmRuleId);
|
||||
return Result.OK(alarmRuleInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result create(AlarmRule alarmRule) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
Long id = IdWorker.getId();
|
||||
alarmRule.setId(id.toString());
|
||||
alarmRule.setCreateTime(new Date());
|
||||
alarmRule.setCreateBy(username);
|
||||
if (StringUtils.isNotBlank(alarmRule.getOperator())){
|
||||
String jsonString = JSON.toJSONString(alarmRule.getOperator());
|
||||
alarmRule.setOperator(jsonString);
|
||||
Rule rule = alarmRule.getRule();
|
||||
if (ObjectUtil.isNotNull(rule)){
|
||||
String operator = JSON.toJSONString(rule);
|
||||
alarmRule.setOperator(operator);
|
||||
}
|
||||
this.baseMapper.insert(alarmRule);
|
||||
result.setSuccess(true);
|
||||
result.success("新增成功");
|
||||
// 同步Redis
|
||||
rule2Redis();
|
||||
return result;
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result update(AlarmRule alarmRule) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
LambdaQueryWrapper<AlarmRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AlarmRule::getId, alarmRule.getId());
|
||||
AlarmRule rule = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(rule)){
|
||||
result.error500("对应数据不存在");
|
||||
return result;
|
||||
LambdaQueryWrapper<AlarmRule> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AlarmRule::getId, alarmRule.getId());
|
||||
AlarmRule alarmRuleOld = this.baseMapper.selectOne(wrapper);
|
||||
if (ObjectUtil.isNull(alarmRuleOld)){
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
}
|
||||
alarmRule.setUpdateTime(new Date());
|
||||
alarmRule.setUpdateBy(username);
|
||||
if (StringUtils.isNotBlank(alarmRule.getOperator())){
|
||||
String jsonString = JSON.toJSONString(alarmRule.getOperator());
|
||||
alarmRule.setOperator(jsonString);
|
||||
Rule rule = alarmRule.getRule();
|
||||
if (ObjectUtil.isNotNull(rule)){
|
||||
String operator = JSON.toJSONString(rule);
|
||||
alarmRule.setOperator(operator);
|
||||
}
|
||||
this.baseMapper.updateById(alarmRule);
|
||||
result.setSuccess(true);
|
||||
result.success("修改成功");
|
||||
// 同步Redis
|
||||
rule2Redis();
|
||||
return result;
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteById(String id) {
|
||||
Result result = new Result();
|
||||
this.baseMapper.deleteById(id);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
// 同步Redis
|
||||
public Result deleteById(String alarmRuleId) {
|
||||
this.baseMapper.deleteById(alarmRuleId);
|
||||
rule2Redis();
|
||||
return result;
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getSourceByType(String sourceType) {
|
||||
List<SourceDto> sourceDtos = new ArrayList<>();
|
||||
if (EMAIL.getType().equals(sourceType)){
|
||||
sourceDtos = emailService.listAll();
|
||||
} else if (DATABASE.getType().equals(sourceType)) {
|
||||
sourceDtos = databaseService.listAll();
|
||||
} else if (SERVER.getType().equals(sourceType)) {
|
||||
sourceDtos = serverService.listAll();
|
||||
}
|
||||
return Result.OK(sourceDtos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateStatus(String alarmRuleId,Integer enabled) {
|
||||
AlarmRule alarmRule = new AlarmRule();
|
||||
alarmRule.setId(alarmRuleId);
|
||||
alarmRule.setEnabled(enabled);
|
||||
if (updateById(alarmRule))
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.DatabaseDto;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
import org.jeecg.modules.mapper.SysDatabaseMapper;
|
||||
|
@ -16,27 +22,40 @@ import org.jeecg.modules.service.ISysDatabaseService;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@Service("sysDatabaseService")
|
||||
public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDatabase> implements ISysDatabaseService {
|
||||
|
||||
@Override
|
||||
public Result findPage(QueryRequest queryRequest, SysDatabase sysDatabase) {
|
||||
Result result = new Result();
|
||||
//声明page
|
||||
Page<SysDatabase> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
//分页查询数据库配置信息
|
||||
LambdaQueryWrapper<SysDatabase> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Page<SysDatabase> sysDatabasePage = this.baseMapper.selectPage(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(sysDatabasePage);
|
||||
return result;
|
||||
public Result findPage(QueryRequest query) {
|
||||
Integer pageNo = query.getPageNo();
|
||||
Integer pageSize = query.getPageSize();
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("pageSize",pageSize);
|
||||
params.put("pageStart",pageStart);
|
||||
DateTimeFormatter formatter = DateTimeFormatter
|
||||
.ofPattern(DateConstant.DATE);
|
||||
String date = LocalDate.now().format(formatter);
|
||||
String startDate = date + DateConstant.TIME_START;
|
||||
String endDate = date + DateConstant.TIME_END;
|
||||
params.put("startDate",startDate);
|
||||
params.put("endDate",endDate);
|
||||
List<DatabaseDto> databaseDtos = baseMapper.findPage(params);
|
||||
for (DatabaseDto databaseDto : databaseDtos) {
|
||||
databaseDto.setOnline(true).setSlowQuery("328/s")
|
||||
.setAlarmRed(true).setCpuUutilzation("35.8%")
|
||||
.setMemoryUsage("55.8%").setDiskUsage("35.68%");
|
||||
}
|
||||
params.put("pageFlag","noPage");
|
||||
long total = baseMapper.findPage(params).size();
|
||||
Page<DatabaseDto> page = new Page<>(pageNo, pageSize, total);
|
||||
page.setRecords(databaseDtos);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,76 +76,92 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
@Override
|
||||
@Transactional
|
||||
public Result create(SysDatabase sysDatabase) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//声明id
|
||||
Long id = IdWorker.getId();
|
||||
sysDatabase.setId(id.toString());
|
||||
sysDatabase.setCreateTime(LocalDate.now());
|
||||
sysDatabase.setCreateBy(username);
|
||||
this.baseMapper.insert(sysDatabase);
|
||||
result.setSuccess(true);
|
||||
result.success("新增成功");
|
||||
return result;
|
||||
String name = sysDatabase.getName();
|
||||
String ipAddress = sysDatabase.getIpAddress();
|
||||
LambdaQueryWrapper<SysDatabase> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysDatabase::getName,name);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("Name"+Prompt.NOT_REPEAT);
|
||||
wrapper.clear();
|
||||
wrapper.eq(SysDatabase::getIpAddress,ipAddress);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("IP Address"+Prompt.NOT_REPEAT);
|
||||
|
||||
int count = baseMapper.insert(sysDatabase);
|
||||
if (count == 1)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result update(SysDatabase sysDatabase) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
LambdaQueryWrapper<SysDatabase> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDatabase::getId, sysDatabase.getId());
|
||||
SysDatabase database = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(database)){
|
||||
result.error500("对应数据不存在,修改失败");
|
||||
return result;
|
||||
SysDatabase database = getById(sysDatabase.getId());
|
||||
if (ObjectUtil.isNull(database))
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
String name = sysDatabase.getName();
|
||||
String ipAddress = sysDatabase.getIpAddress();
|
||||
LambdaQueryWrapper<SysDatabase> wrapper = new LambdaQueryWrapper<>();
|
||||
if (!StrUtil.equals(name,database.getName())){
|
||||
wrapper.eq(SysDatabase::getName,name);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("Name" + Prompt.NOT_REPEAT);
|
||||
wrapper.clear();
|
||||
}
|
||||
sysDatabase.setUpdateTime(LocalDate.now());
|
||||
sysDatabase.setUpdateBy(username);
|
||||
this.baseMapper.updateById(sysDatabase);
|
||||
result.setSuccess(true);
|
||||
result.success("修改成功");
|
||||
return result;
|
||||
if (!StrUtil.equals(ipAddress,database.getIpAddress())){
|
||||
wrapper.eq(SysDatabase::getIpAddress,ipAddress);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("IP Address" + Prompt.NOT_REPEAT);
|
||||
}
|
||||
int count = baseMapper.updateById(sysDatabase);
|
||||
if (count == 1)
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result deleteById(String id) {
|
||||
Result result = new Result();
|
||||
this.baseMapper.deleteById(id);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
return result;
|
||||
int count = baseMapper.deleteById(id);
|
||||
if(count == 1)
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
return Result.error(Prompt.DELETE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findAlarmHistory(String databaseId, Date startTime, Date endTime) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
if (Objects.isNull(startTime)){
|
||||
result.error500("开始时间不能为空");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(endTime)){
|
||||
result.error500("结束时间不能为空");
|
||||
return result;
|
||||
}
|
||||
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||
List<AlarmHistory> alarmHistory = this.baseMapper.findAlarmHistory(databaseId, startDate, endDate);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmHistory);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
public Result findAlarmHistory(SourceVo sourceVo) {
|
||||
String startDate = sourceVo.getStartDate();
|
||||
String endDate = sourceVo.getEndDate();
|
||||
if (StrUtil.isNotBlank(startDate))
|
||||
sourceVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (StrUtil.isNotBlank(endDate))
|
||||
sourceVo.setStartDate(endDate + DateConstant.TIME_END);
|
||||
Integer pageNo = sourceVo.getPageNo();
|
||||
Integer pageSize = sourceVo.getPageSize();
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
sourceVo.setPageStart(pageStart);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(sourceVo);
|
||||
List<AlarmHistory> alarmHistories = baseMapper.findAlarmHistory(params);
|
||||
// 获取数据总条数(经过查询条件过滤后的)
|
||||
params.put("pageFlag","noPage");
|
||||
Integer total = baseMapper.findAlarmHistory(params).size();
|
||||
Page<AlarmHistory> page = new Page<>(pageNo,pageSize,total);
|
||||
// 当前页数据
|
||||
page.setRecords(alarmHistories);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceDto> listAll() {
|
||||
LambdaQueryWrapper<SysDatabase> wrapper = new LambdaQueryWrapper<>();
|
||||
List<SourceDto> sourceDtos = new ArrayList<>();
|
||||
for (SysDatabase sysDatabase : list()) {
|
||||
SourceDto sourceDto = new SourceDto();
|
||||
sourceDto.setSourceId(sysDatabase.getId());
|
||||
sourceDto.setSourceName(sysDatabase.getName());
|
||||
sourceDtos.add(sourceDto);
|
||||
}
|
||||
return result;
|
||||
return sourceDtos;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.email.emuns.SysMailType;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.EmailDto;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.base.entity.SysEmail;
|
||||
import org.jeecg.modules.mapper.SysEmailMapper;
|
||||
|
@ -18,27 +24,40 @@ import org.jeecg.modules.service.ISysEmailService;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@Service("sysEmailService")
|
||||
public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> implements ISysEmailService {
|
||||
|
||||
@Override
|
||||
public Result findPage(QueryRequest queryRequest, SysEmail sysEmail) {
|
||||
Result result = new Result();
|
||||
//声明page
|
||||
Page<SysEmail> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
//分页查询邮箱配置数据
|
||||
LambdaQueryWrapper<SysEmail> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Page<SysEmail> sysEmailPage = this.baseMapper.selectPage(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(sysEmailPage);
|
||||
return result;
|
||||
public Result findPage(QueryRequest query) {
|
||||
Integer pageNo = query.getPageNo();
|
||||
Integer pageSize = query.getPageSize();
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("pageSize",pageSize);
|
||||
params.put("pageStart",pageStart);
|
||||
DateTimeFormatter formatter = DateTimeFormatter
|
||||
.ofPattern(DateConstant.DATE);
|
||||
String date = LocalDate.now().format(formatter);
|
||||
String startDate = date + DateConstant.TIME_START;
|
||||
String endDate = date + DateConstant.TIME_END;
|
||||
params.put("startDate",startDate);
|
||||
params.put("endDate",endDate);
|
||||
List<EmailDto> emailDtos = baseMapper.findPage(params);
|
||||
for (EmailDto emailDto : emailDtos) {
|
||||
emailDto.setOnline(true).setToday(2)
|
||||
.setYesterday(5).setWeekly(7)
|
||||
.setStoerCapacity("100%").setStoerRed(true);
|
||||
}
|
||||
params.put("pageFlag","noPage");
|
||||
long total = baseMapper.findPage(params).size();
|
||||
Page<EmailDto> page = new Page<>(pageNo, pageSize, total);
|
||||
page.setRecords(emailDtos);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,79 +79,68 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
|||
@Override
|
||||
@Transactional
|
||||
public Result create(SysEmail sysEmail) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//声明id
|
||||
Long id = IdWorker.getId();
|
||||
sysEmail.setId(id.toString());
|
||||
//创建时间
|
||||
sysEmail.setCreateTime(LocalDate.now());
|
||||
sysEmail.setCreateBy(username);
|
||||
this.baseMapper.insert(sysEmail);
|
||||
result.setSuccess(true);
|
||||
result.success("新增成功");
|
||||
return result;
|
||||
String name = sysEmail.getName();
|
||||
LambdaQueryWrapper<SysEmail> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysEmail::getName,name);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("Name"+Prompt.NOT_REPEAT);
|
||||
|
||||
int count = baseMapper.insert(sysEmail);
|
||||
if (count == 1)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result update(SysEmail sysEmail) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//根据id查询数据
|
||||
LambdaQueryWrapper<SysEmail> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysEmail::getId, sysEmail.getId());
|
||||
SysEmail email = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(email)){
|
||||
result.error500("对应数据不存在");
|
||||
return result;
|
||||
SysEmail email = getById(sysEmail.getId());
|
||||
if (ObjectUtil.isNull(email))
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
String name = sysEmail.getName();
|
||||
LambdaQueryWrapper<SysEmail> wrapper = new LambdaQueryWrapper<>();
|
||||
if (!StrUtil.equals(name,email.getName())){
|
||||
wrapper.eq(SysEmail::getName,name);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("Name" + Prompt.NOT_REPEAT);
|
||||
wrapper.clear();
|
||||
}
|
||||
//创建时间
|
||||
sysEmail.setUpdateTime(LocalDate.now());
|
||||
sysEmail.setUpdateBy(username);
|
||||
this.baseMapper.updateById(sysEmail);
|
||||
result.setSuccess(true);
|
||||
result.success("修改成功");
|
||||
return result;
|
||||
int count = baseMapper.updateById(sysEmail);
|
||||
if (count == 1)
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result deleteById(String id) {
|
||||
Result result = new Result();
|
||||
this.baseMapper.deleteById(id);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
return result;
|
||||
int count = baseMapper.deleteById(id);
|
||||
if(count == 1)
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
return Result.error(Prompt.DELETE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findAlarmHistory(String emailId, Date startTime, Date endTime) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
if (Objects.isNull(startTime)){
|
||||
result.error500("开始时间不能为空");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(endTime)){
|
||||
result.error500("结束时间不能为空");
|
||||
return result;
|
||||
}
|
||||
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||
List<AlarmHistory> alarmHistory = this.baseMapper.findAlarmHistory(emailId, startDate, endDate);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmHistory);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
public Result findAlarmHistory(SourceVo sourceVo) {
|
||||
String startDate = sourceVo.getStartDate();
|
||||
String endDate = sourceVo.getEndDate();
|
||||
if (StrUtil.isNotBlank(startDate))
|
||||
sourceVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (StrUtil.isNotBlank(endDate))
|
||||
sourceVo.setStartDate(endDate + DateConstant.TIME_END);
|
||||
Integer pageNo = sourceVo.getPageNo();
|
||||
Integer pageSize = sourceVo.getPageSize();
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
sourceVo.setPageStart(pageStart);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(sourceVo);
|
||||
List<AlarmHistory> alarmHistories = baseMapper.findAlarmHistory(params);
|
||||
// 获取数据总条数(经过查询条件过滤后的)
|
||||
params.put("pageFlag","noPage");
|
||||
Integer total = baseMapper.findAlarmHistory(params).size();
|
||||
Page<AlarmHistory> page = new Page<>(pageNo,pageSize,total);
|
||||
// 当前页数据
|
||||
page.setRecords(alarmHistories);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,4 +156,17 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
|||
return Result.OK(sysEmail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceDto> listAll() {
|
||||
LambdaQueryWrapper<SysEmail> wrapper = new LambdaQueryWrapper<>();
|
||||
List<SourceDto> sourceDtos = new ArrayList<>();
|
||||
for (SysEmail sysEmail : list()) {
|
||||
SourceDto sourceDto = new SourceDto();
|
||||
sourceDto.setSourceId(sysEmail.getId());
|
||||
sourceDto.setSourceName(sysEmail.getName());
|
||||
sourceDtos.add(sourceDto);
|
||||
}
|
||||
return sourceDtos;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.ServerDto;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.vo.SourceVo;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysServer;
|
||||
import org.jeecg.modules.mapper.SysServerMapper;
|
||||
|
@ -17,25 +23,41 @@ import org.jeecg.modules.service.ISysServerService;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@Service("sysServerService")
|
||||
public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer> implements ISysServerService {
|
||||
|
||||
@Override
|
||||
public Result findPage(QueryRequest queryRequest, SysServer sysServer) {
|
||||
Result result = new Result();
|
||||
Page<SysServer> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
LambdaQueryWrapper<SysServer> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Page<SysServer> sysServerPage = this.baseMapper.selectPage(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(sysServerPage);
|
||||
return result;
|
||||
public Result findPage(QueryRequest query) {
|
||||
Integer pageNo = query.getPageNo();
|
||||
Integer pageSize = query.getPageSize();
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("pageSize",pageSize);
|
||||
params.put("pageStart",pageStart);
|
||||
DateTimeFormatter formatter = DateTimeFormatter
|
||||
.ofPattern(DateConstant.DATE);
|
||||
String date = LocalDate.now().format(formatter);
|
||||
String startDate = date + DateConstant.TIME_START;
|
||||
String endDate = date + DateConstant.TIME_END;
|
||||
params.put("startDate",startDate);
|
||||
params.put("endDate",endDate);
|
||||
List<ServerDto> serverDtos = baseMapper.findPage(params);
|
||||
for (ServerDto serverDto : serverDtos) {
|
||||
serverDto.setOnline(true)
|
||||
.setServerInfo("(4-core (vCPU)16GiB)")
|
||||
.setCpuUutilzation("35.8%").setMemoryUsage("55.8%")
|
||||
.setDiskUsage("85.68%").setDiskRed(true);
|
||||
}
|
||||
params.put("pageFlag","noPage");
|
||||
long total = baseMapper.findPage(params).size();
|
||||
Page<ServerDto> page = new Page<>(pageNo, pageSize, total);
|
||||
page.setRecords(serverDtos);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,78 +82,100 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
@Override
|
||||
@Transactional
|
||||
public Result create(SysServer sysServer) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//声明id
|
||||
Long id = IdWorker.getId();
|
||||
sysServer.setId(id.toString());
|
||||
//赋值创建时间
|
||||
sysServer.setCreateTime(LocalDate.now());
|
||||
sysServer.setCreateBy(username);
|
||||
this.baseMapper.insert(sysServer);
|
||||
result.setSuccess(true);
|
||||
result.success("新增成功");
|
||||
return result;
|
||||
String name = sysServer.getName();
|
||||
String ipAddress = sysServer.getIpAddress();
|
||||
LambdaQueryWrapper<SysServer> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysServer::getName,name);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("Name"+Prompt.NOT_REPEAT);
|
||||
wrapper.clear();
|
||||
wrapper.eq(SysServer::getIpAddress,ipAddress);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("IP Address"+Prompt.NOT_REPEAT);
|
||||
|
||||
int count = baseMapper.insert(sysServer);
|
||||
if (count == 1)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result update(SysServer sysServer) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//根据id查询对应数据是否存在
|
||||
LambdaQueryWrapper<SysServer> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysServer::getId, sysServer.getId());
|
||||
SysServer server = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(server)){
|
||||
result.error500("当前数据不存在");
|
||||
return result;
|
||||
SysServer server = getById(sysServer.getId());
|
||||
if (ObjectUtil.isNull(server))
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
String name = sysServer.getName();
|
||||
String ipAddress = sysServer.getIpAddress();
|
||||
LambdaQueryWrapper<SysServer> wrapper = new LambdaQueryWrapper<>();
|
||||
if (!StrUtil.equals(name,server.getName())){
|
||||
wrapper.eq(SysServer::getName,name);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("Name" + Prompt.NOT_REPEAT);
|
||||
wrapper.clear();
|
||||
}
|
||||
sysServer.setUpdateTime(LocalDate.now());
|
||||
sysServer.setUpdateBy(username);
|
||||
this.baseMapper.updateById(sysServer);
|
||||
result.setSuccess(true);
|
||||
result.success("修改成功");
|
||||
return result;
|
||||
if (!StrUtil.equals(ipAddress,server.getIpAddress())){
|
||||
wrapper.eq(SysServer::getIpAddress,ipAddress);
|
||||
if (CollUtil.isNotEmpty(list(wrapper)))
|
||||
return Result.error("IP Address" + Prompt.NOT_REPEAT);
|
||||
}
|
||||
int count = baseMapper.updateById(sysServer);
|
||||
if (count == 1)
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result deleteById(String id) {
|
||||
Result result = new Result();
|
||||
this.baseMapper.deleteById(id);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
return result;
|
||||
int count = baseMapper.deleteById(id);
|
||||
if(count == 1)
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
return Result.error(Prompt.DELETE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findAlarmHistory(String serverId, Date startTime, Date endTime) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
if (Objects.isNull(startTime)){
|
||||
result.error500("开始时间不能为空");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(endTime)){
|
||||
result.error500("结束时间不能为空");
|
||||
return result;
|
||||
}
|
||||
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||
List<AlarmHistory> alarmHistory = this.baseMapper.findAlarmHistory(serverId, startDate, endDate);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmHistory);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
public Result findAlarmHistory(SourceVo sourceVo) {
|
||||
String startDate = sourceVo.getStartDate();
|
||||
String endDate = sourceVo.getEndDate();
|
||||
if (StrUtil.isNotBlank(startDate))
|
||||
sourceVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (StrUtil.isNotBlank(endDate))
|
||||
sourceVo.setStartDate(endDate + DateConstant.TIME_END);
|
||||
Integer pageNo = sourceVo.getPageNo();
|
||||
Integer pageSize = sourceVo.getPageSize();
|
||||
Integer pageStart = (pageNo - 1) * pageSize;
|
||||
sourceVo.setPageStart(pageStart);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(sourceVo);
|
||||
List<AlarmHistory> alarmHistories = baseMapper.findAlarmHistory(params);
|
||||
// 获取数据总条数(经过查询条件过滤后的)
|
||||
params.put("pageFlag","noPage");
|
||||
Integer total = baseMapper.findAlarmHistory(params).size();
|
||||
Page<AlarmHistory> page = new Page<>(pageNo,pageSize,total);
|
||||
// 当前页数据
|
||||
page.setRecords(alarmHistories);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceDto> listAll() {
|
||||
LambdaQueryWrapper<SysServer> wrapper = new LambdaQueryWrapper<>();
|
||||
List<SourceDto> sourceDtos = new ArrayList<>();
|
||||
for (SysServer sysServer : list()) {
|
||||
SourceDto sourceDto = new SourceDto();
|
||||
sourceDto.setSourceId(sysServer.getId());
|
||||
sourceDto.setSourceName(sysServer.getName());
|
||||
sourceDtos.add(sourceDto);
|
||||
}
|
||||
return sourceDtos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getByName(String name) {
|
||||
LambdaQueryWrapper<SysServer> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysServer::getName,name);
|
||||
String id = Optional.ofNullable(getOne(wrapper, false))
|
||||
.orElse(new SysServer()).getId();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
package org.jeecg.modules.feignclient;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.dto.ItemDto;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@FeignClient(name = "monitorClient",url = "${monitor.url}")
|
||||
public interface MonitorClient {
|
||||
@GetMapping("list")
|
||||
Result<?> monList(@RequestParam String code,
|
||||
@RequestParam String hostId,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String status,
|
||||
@RequestParam String type);
|
||||
|
||||
@GetMapping("queryHostDetails")
|
||||
Result<?> monDetail(@RequestParam String hostId,
|
||||
@RequestParam String pageName,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
@GetMapping("queryItemHistory")
|
||||
Result<ItemDto> itemHistory(@RequestParam String itemId,
|
||||
@RequestParam Integer itemType,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
@GetMapping("queryItemHistoryData")
|
||||
Result<?> itemHistoryData(@RequestParam String itemId,
|
||||
@RequestParam Integer itemType,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
|
||||
@GetMapping("log")
|
||||
Result<?> monLog(@RequestParam String code,
|
||||
@RequestParam String deviceType,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end,
|
||||
@RequestParam String status);
|
||||
|
||||
@GetMapping("log/{hostId}")
|
||||
Result<?> monOneLog(@PathVariable("hostId") String hostId,
|
||||
@RequestParam Integer pageNo,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end,
|
||||
@RequestParam String status);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.jeecg.modules.feignclient;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.monitor.ItemHistory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Component
|
||||
@FeignClient(name = "monitorSystem",url = "${monitor.url}")
|
||||
public interface MonitorSystem {
|
||||
|
||||
@GetMapping("queryItemHistory")
|
||||
Result<ItemHistory> itemBack(@RequestParam String itemId,
|
||||
@RequestParam Integer itemType,
|
||||
@RequestParam String start,
|
||||
@RequestParam String end);
|
||||
}
|
|
@ -1,27 +1,21 @@
|
|||
package org.jeecg.modules.message;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||
import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.modules.base.entity.Rule;
|
||||
import org.jeecg.modules.base.enums.Notific;
|
||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jeecg.common.constant.enums.MessageTypeEnum.*;
|
||||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||
import static org.jeecg.modules.base.enums.Notific.*;
|
||||
|
||||
/**
|
||||
* 消息推送 (站内|邮箱|短信)
|
||||
|
@ -54,29 +48,31 @@ public class SendMessage {
|
|||
UserTokenContext.setToken(getTempToken());
|
||||
|
||||
// 封装MessageDTO消息体
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setTitle("系统预警消息");
|
||||
messageDTO.setContent(message);
|
||||
String title = "系统预警消息";
|
||||
MessageDTO messageDTO = new MessageDTO(title,message);
|
||||
|
||||
Map<String, String> contact = getContact(groupId);
|
||||
if (StrUtil.isBlank(notific))return;
|
||||
String[] ways = notific.split(",");
|
||||
List<String> ways = ListUtil.toList(notific.split(","));
|
||||
if (ways.contains(ALL.getValue())){
|
||||
ways = ListUtil.toList(XT.getValue(), YJ.getValue(),SMS.getValue());
|
||||
}
|
||||
for (String way : ways) {
|
||||
if(way.equals(SYSTEM.getWay())){// 1.推送系统消息
|
||||
if(way.equals(XT.getValue())){// 1.推送系统消息
|
||||
String toSys = contact.get(System);
|
||||
if (StrUtil.isNotBlank(toSys)){
|
||||
messageDTO.setToUser(toSys);
|
||||
messageDTO.setType(XT.getType());
|
||||
sysBaseAPI.sendTemplateMessage(messageDTO);
|
||||
}
|
||||
} else if (way.equals(EMAIL.getWay())) {// 2.推送邮箱
|
||||
} else if (way.equals(YJ.getValue())) {// 2.推送邮箱
|
||||
String toEmail = contact.get(Email);
|
||||
if (StrUtil.isNotBlank(toEmail)){
|
||||
messageDTO.setToUser(toEmail);
|
||||
messageDTO.setType(YX.getType());
|
||||
messageDTO.setType(YJ.getType());
|
||||
sysBaseAPI.sendTemplateMessage(messageDTO);
|
||||
}
|
||||
} else if (way.equals(PHONE.getWay())) {// 3.推送短信
|
||||
} else if (way.equals(SMS.getValue())) {// 3.推送短信
|
||||
String toSms = contact.get(Sms);
|
||||
if (StrUtil.isNotBlank(toSms)){
|
||||
messageDTO.setToUser(toSms);
|
||||
|
|
|
@ -12,12 +12,6 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
|
@ -25,23 +19,23 @@ import lombok.experimental.Accessors;
|
|||
public class SysMessage extends JeecgEntity {
|
||||
/**推送内容*/
|
||||
@Excel(name = "推送内容", width = 15)
|
||||
private java.lang.String esContent;
|
||||
private String esContent;
|
||||
/**推送所需参数Json格式*/
|
||||
@Excel(name = "推送所需参数Json格式", width = 15)
|
||||
private java.lang.String esParam;
|
||||
private String esParam;
|
||||
/**接收人*/
|
||||
@Excel(name = "接收人", width = 15)
|
||||
private java.lang.String esReceiver;
|
||||
private String esReceiver;
|
||||
/**推送失败原因*/
|
||||
@Excel(name = "推送失败原因", width = 15)
|
||||
private java.lang.String esResult;
|
||||
private String esResult;
|
||||
/**发送次数*/
|
||||
@Excel(name = "发送次数", width = 15)
|
||||
private java.lang.Integer esSendNum;
|
||||
private Integer esSendNum;
|
||||
/**推送状态 0未推送 1推送成功 2推送失败*/
|
||||
@Excel(name = "推送状态 0未推送 1推送成功 2推送失败", width = 15)
|
||||
@Dict(dicCode = "msgSendStatus")
|
||||
private java.lang.String esSendStatus;
|
||||
private String esSendStatus;
|
||||
/**推送时间*/
|
||||
@Excel(name = "推送时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
@ -49,14 +43,14 @@ public class SysMessage extends JeecgEntity {
|
|||
private java.util.Date esSendTime;
|
||||
/**消息标题*/
|
||||
@Excel(name = "消息标题", width = 15)
|
||||
private java.lang.String esTitle;
|
||||
private String esTitle;
|
||||
/**
|
||||
* 推送方式:参考枚举类MessageTypeEnum
|
||||
*/
|
||||
@Excel(name = "推送方式", width = 15)
|
||||
@Dict(dicCode = "messageType")
|
||||
private java.lang.String esType;
|
||||
private String esType;
|
||||
/**备注*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
private java.lang.String remark;
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,7 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 消息模板
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
* 消息模板
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
@ -22,19 +19,19 @@ import lombok.experimental.Accessors;
|
|||
public class SysMessageTemplate extends JeecgEntity{
|
||||
/**模板CODE*/
|
||||
@Excel(name = "模板CODE", width = 15)
|
||||
private java.lang.String templateCode;
|
||||
private String templateCode;
|
||||
/**模板标题*/
|
||||
@Excel(name = "模板标题", width = 30)
|
||||
private java.lang.String templateName;
|
||||
private String templateName;
|
||||
/**模板内容*/
|
||||
@Excel(name = "模板内容", width = 50)
|
||||
private java.lang.String templateContent;
|
||||
private String templateContent;
|
||||
/**模板测试json*/
|
||||
@Excel(name = "模板测试json", width = 15)
|
||||
private java.lang.String templateTestJson;
|
||||
private String templateTestJson;
|
||||
/**模板类型*/
|
||||
@Excel(name = "模板类型", width = 15)
|
||||
private java.lang.String templateType;
|
||||
private String templateType;
|
||||
|
||||
/**已经应用/未应用 1是0否*/
|
||||
@Excel(name = "应用状态", width = 15)
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.jeecg.common.email.EmailServiceManager;
|
|||
import org.jeecg.modules.base.entity.SysEmail;
|
||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.jeecg.modules.message.service.ISysMessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -25,6 +26,9 @@ public class EmailPushMsgHandle implements ISendMsgHandle {
|
|||
@Autowired
|
||||
private AbnormalAlarmClient alarmClient;
|
||||
|
||||
@Autowired
|
||||
private ISysMessageService sysMessageService;
|
||||
|
||||
@Override
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
// 获取邮件发送服务器信息
|
||||
|
@ -35,6 +39,8 @@ public class EmailPushMsgHandle implements ISendMsgHandle {
|
|||
emailService.init(sysEmail);
|
||||
// 发送邮件
|
||||
emailService.sendMail(messageDTO);
|
||||
|
||||
sysMessageService.add(messageDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package org.jeecg.modules.message.handle.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.util.DySmsHelper;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description: 短信发送
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SmsSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.jeecg.modules.message.handle.impl;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
|
@ -11,6 +13,7 @@ import org.jeecg.common.util.SpringContextUtils;
|
|||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.message.enums.Vue3MessageHrefEnum;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.jeecg.modules.message.service.ISysMessageService;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
import org.jeecg.modules.system.entity.SysAnnouncement;
|
||||
import org.jeecg.modules.system.entity.SysAnnouncementSend;
|
||||
|
@ -18,33 +21,72 @@ import org.jeecg.modules.system.entity.SysUser;
|
|||
import org.jeecg.modules.system.mapper.SysAnnouncementMapper;
|
||||
import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 发送系统消息
|
||||
* @Author: wangshuai
|
||||
* @Date: 2022年3月22日 18:48:20
|
||||
*/
|
||||
@Component("systemSendMsgHandle")
|
||||
public class SystemSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
public static final String FROM_USER="system";
|
||||
public static final String FROM_USER = "system";
|
||||
|
||||
@Resource
|
||||
private WebSocket webSocket;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysMessageService sysMessageService;
|
||||
|
||||
@Resource
|
||||
private SysAnnouncementMapper sysAnnouncementMapper;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private SysAnnouncementSendMapper sysAnnouncementSendMapper;
|
||||
|
||||
@Resource
|
||||
private WebSocket webSocket;
|
||||
/**
|
||||
* 仅发送系统消息
|
||||
* @param messageDTO
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
String[] toUsers = messageDTO.getToUser().split(",");
|
||||
for(String toUser: toUsers){
|
||||
SysUser sysUser = userMapper.getUserByName(toUser);
|
||||
if (ObjectUtil.isNull(sysUser)) continue;
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(messageDTO.getTitle());
|
||||
announcement.setMsgContent(messageDTO.getContent());
|
||||
announcement.setSender(messageDTO.getFromUser());
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
String anntId = announcement.getId();
|
||||
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
|
||||
obj.put(WebsocketConst.MSG_USER_ID, sysUser.getId());
|
||||
obj.put(WebsocketConst.MSG_ID, announcement.getId());
|
||||
obj.put(WebsocketConst.MSG_TXT, announcement.getTitile());
|
||||
webSocket.sendMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
sysMessageService.add(messageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 该方法会发送3种消息:系统消息、企业微信 钉钉
|
||||
|
@ -61,68 +103,4 @@ public class SystemSendMsgHandle implements ISendMsgHandle {
|
|||
MessageDTO messageDTO = new MessageDTO(FROM_USER,esReceiver,esTitle,esContent);
|
||||
sysBaseApi.sendSysAnnouncement(messageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅发送系统消息
|
||||
* @param messageDTO
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
//原方法不支持 sysBaseApi.sendSysAnnouncement(messageDTO); 有企业微信消息逻辑,
|
||||
String title = messageDTO.getTitle();
|
||||
String content = messageDTO.getContent();
|
||||
String fromUser = messageDTO.getFromUser();
|
||||
Map<String,Object> data = messageDTO.getData();
|
||||
String[] arr = messageDTO.getToUser().split(",");
|
||||
for(String username: arr){
|
||||
doSend(title, content, fromUser, username, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void doSend(String title, String msgContent, String fromUser, String toUser, Map<String, Object> data){
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
if(data!=null){
|
||||
//摘要信息
|
||||
Object msgAbstract = data.get(CommonConstant.NOTICE_MSG_SUMMARY);
|
||||
if(msgAbstract!=null){
|
||||
announcement.setMsgAbstract(msgAbstract.toString());
|
||||
}
|
||||
// 任务节点ID
|
||||
Object taskId = data.get(CommonConstant.NOTICE_MSG_BUS_ID);
|
||||
if(taskId!=null){
|
||||
announcement.setBusId(taskId.toString());
|
||||
announcement.setBusType(Vue3MessageHrefEnum.BPM_TASK.getBusType());
|
||||
}
|
||||
}
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(msgContent);
|
||||
announcement.setSender(fromUser);
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
//系统消息
|
||||
announcement.setMsgCategory("2");
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String anntId = announcement.getId();
|
||||
if(StrUtil.isNotBlank(toUser)) {
|
||||
SysUser sysUser = userMapper.getUserByName(toUser);
|
||||
if(sysUser==null) {
|
||||
return;
|
||||
}
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
|
||||
obj.put(WebsocketConst.MSG_USER_ID, sysUser.getId());
|
||||
obj.put(WebsocketConst.MSG_ID, announcement.getId());
|
||||
obj.put(WebsocketConst.MSG_TXT, announcement.getTitile());
|
||||
webSocket.sendMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,12 +6,6 @@ import org.apache.ibatis.annotations.Param;
|
|||
import org.jeecg.modules.message.entity.SysMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysMessageMapper extends BaseMapper<SysMessage> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
package org.jeecg.modules.message.service;
|
||||
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.system.base.service.JeecgService;
|
||||
import org.jeecg.modules.message.entity.SysMessage;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysMessageService extends JeecgService<SysMessage> {
|
||||
|
||||
boolean add(MessageDTO messageDTO);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,38 @@
|
|||
package org.jeecg.modules.message.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||
import org.jeecg.common.system.base.service.impl.JeecgServiceImpl;
|
||||
import org.jeecg.modules.message.entity.SysMessage;
|
||||
import org.jeecg.modules.message.mapper.SysMessageMapper;
|
||||
import org.jeecg.modules.message.service.ISysMessageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysMessageServiceImpl extends JeecgServiceImpl<SysMessageMapper, SysMessage> implements ISysMessageService {
|
||||
|
||||
@Override
|
||||
public boolean add(MessageDTO messageDTO) {
|
||||
String toUser = messageDTO.getToUser();
|
||||
List<SysMessage> sysMessages = new ArrayList<>();
|
||||
List<String> toUsers = ListUtil.toList(toUser.split(SymbolConstant.COMMA));
|
||||
Date now = new Date();
|
||||
for (String receiver : toUsers) {
|
||||
SysMessage sms = new SysMessage();
|
||||
sms.setEsSendTime(now);
|
||||
sms.setEsReceiver(receiver);
|
||||
sms.setEsType(messageDTO.getType());
|
||||
sms.setEsTitle(messageDTO.getTitle());
|
||||
sms.setEsContent(messageDTO.getContent());
|
||||
sysMessages.add(sms);
|
||||
}
|
||||
return saveBatch(sysMessages);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.jeecg.modules.quartz.job;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
@ -10,31 +9,22 @@ import lombok.Data;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.ItemDto;
|
||||
import org.jeecg.modules.base.dto.RuleDto;
|
||||
import org.jeecg.modules.base.entity.monitor.ItemHistory;
|
||||
import org.jeecg.modules.base.entity.AlarmLog;
|
||||
import org.jeecg.modules.base.entity.AlarmRule;
|
||||
import org.jeecg.modules.base.entity.Rule;
|
||||
import org.jeecg.modules.base.enums.Item;
|
||||
import org.jeecg.modules.base.enums.SourceType;
|
||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||
import org.jeecg.modules.feignclient.MonitorClient;
|
||||
import org.jeecg.modules.feignclient.MonitorSystem;
|
||||
import org.jeecg.modules.message.SendMessage;
|
||||
import org.quartz.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jeecg.common.constant.enums.MessageTypeEnum.QYWX;
|
||||
import static org.jeecg.modules.base.enums.Op.*;
|
||||
import static org.jeecg.modules.base.enums.SourceType.EMAIL;
|
||||
import static org.jeecg.modules.base.enums.SourceType.SERVER;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
|
@ -53,7 +43,7 @@ public class SysInfoJob implements Job {
|
|||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
RedisStreamUtil redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
|
||||
MonitorClient monitorClient = SpringContextUtils.getBean(MonitorClient.class);
|
||||
MonitorSystem monitorSystem = SpringContextUtils.getBean(MonitorSystem.class);
|
||||
SendMessage sendMessage = SpringContextUtils.getBean(SendMessage.class);
|
||||
AbnormalAlarmClient alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
||||
|
||||
|
@ -90,7 +80,7 @@ public class SysInfoJob implements Job {
|
|||
|
||||
// 向运管查询监控项数据
|
||||
String itemId = alarmRule.getItemId().toString();
|
||||
Result<ItemDto> result = monitorClient.itemHistory(itemId, 0, start, end);
|
||||
Result<ItemHistory> result = monitorSystem.itemBack(itemId, 0, start, end);
|
||||
Double current = result.getResult().getNow();
|
||||
|
||||
// 解析预警规则,判断是否需要报警
|
||||
|
|
|
@ -63,7 +63,6 @@ public class SysDictItem implements Serializable {
|
|||
@Excel(name = "排序", width = 15,type=4)
|
||||
private Integer sortOrder;
|
||||
|
||||
|
||||
/**
|
||||
* 状态(1启用 0不启用)
|
||||
*/
|
||||
|
@ -77,6 +76,4 @@ public class SysDictItem implements Serializable {
|
|||
private String updateBy;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -47,6 +49,8 @@ import java.sql.DatabaseMetaData;
|
|||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jeecg.common.constant.enums.MessageTypeEnum.*;
|
||||
|
||||
/**
|
||||
* @Description: 底层共通业务API,提供其他独立模块调用
|
||||
* @Author: scott
|
||||
|
@ -1176,22 +1180,16 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
|||
}
|
||||
|
||||
//-------------------------------------流程节点发送模板消息-----------------------------------------------
|
||||
@Autowired
|
||||
private QywxSendMsgHandle qywxSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private SystemSendMsgHandle systemSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private EmailSendMsgHandle emailSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private DdSendMsgHandle ddSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private EmailPushMsgHandle emailPushMsgHandle;
|
||||
|
||||
@Override
|
||||
@Autowired
|
||||
private SmsSendMsgHandle smsSendMsgHandle;
|
||||
|
||||
/*@Override
|
||||
public void sendTemplateMessage(MessageDTO message) {
|
||||
String messageType = message.getType();
|
||||
//update-begin-author:taoyan date:2022-7-9 for: 将模板解析代码移至消息发送, 而不是调用的地方
|
||||
|
@ -1226,8 +1224,30 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
|||
ddSendMsgHandle.sendMessage(message);
|
||||
}else if(MessageTypeEnum.QYWX.getType().equals(messageType)){
|
||||
qywxSendMsgHandle.sendMessage(message);
|
||||
} else if (MessageTypeEnum.YX.getType().equals(messageType)) { // 新增邮件推送 2023-06-25
|
||||
}
|
||||
}*/
|
||||
|
||||
public void sendTemplateMessage(MessageDTO message) {
|
||||
String type = message.getType();
|
||||
String code = message.getTemplateCode();
|
||||
if(StrUtil.isNotBlank(code)){
|
||||
SysMessageTemplate template = getTemplateEntity(code);
|
||||
String content = template.getTemplateContent();
|
||||
Map<String, Object> data = message.getData();
|
||||
boolean notBlank = StrUtil.isNotBlank(content);
|
||||
boolean notEmpty = ObjectUtil.isNotEmpty(data);
|
||||
if(notBlank && notEmpty){
|
||||
content = FreemarkerParseFactory
|
||||
.parseTemplateContent(content, data, false);
|
||||
}
|
||||
message.setContent(content);
|
||||
}
|
||||
if(XT.getType().equals(type)){ // 站内消息
|
||||
systemSendMsgHandle.sendMessage(message);
|
||||
}else if(YJ.getType().equals(type)){ // 邮箱消息
|
||||
emailPushMsgHandle.sendMessage(message);
|
||||
} else if (SMS.getType().equals(type)) { // 手机短信
|
||||
smsSendMsgHandle.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1307,25 +1307,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(userRoleQueryWrapper);
|
||||
LambdaQueryWrapper<SysRole> roleQueryWrapper = new LambdaQueryWrapper<>();
|
||||
List<SysRole> sysRoles = sysRoleMapper.selectList(roleQueryWrapper);
|
||||
List<SysRole> roles = new LinkedList<>();
|
||||
//遍历所有用户信息
|
||||
if (CollectionUtils.isNotEmpty(sysUsers)){
|
||||
for (SysUser sysUser:sysUsers) {
|
||||
if (CollectionUtils.isNotEmpty(sysUserRoles)){
|
||||
//获取各用户匹配的权限集合
|
||||
List<SysUserRole> userRoles = sysUserRoles.stream().filter(item -> item.getUserId().equals(sysUser.getId())).collect(Collectors.toList());
|
||||
List<String> roleIds = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(sysRoles)){
|
||||
for (SysRole role:sysRoles) {
|
||||
if (roleIds.contains(role.getId())){
|
||||
roles.add(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
sysUser.setRoles(roles);
|
||||
for (SysUser sysUser:sysUsers) {
|
||||
String userId = sysUser.getId();
|
||||
List<SysRole> roles = new LinkedList<>();
|
||||
//获取各用户匹配的权限集合
|
||||
List<SysUserRole> userRoles = sysUserRoles.stream()
|
||||
.filter(item -> item.getUserId().equals(userId))
|
||||
.collect(Collectors.toList());
|
||||
List<String> roleIds = userRoles.stream()
|
||||
.map(SysUserRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
for (SysRole role:sysRoles) {
|
||||
if (roleIds.contains(role.getId())){
|
||||
roles.add(role);
|
||||
}
|
||||
map.put(sysUser.getId(), sysUser);
|
||||
}
|
||||
sysUser.setRoles(roles);
|
||||
map.put(userId, sysUser);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#database_name=jeecg-boot
|
||||
|
||||
#oracle
|
||||
diver_name=oracle.jdbc.driver.OracleDriver
|
||||
url=jdbc:oracle:thin:@82.157.234.81:1521:orcl
|
||||
username=original
|
||||
password=123456
|
||||
database_name=original
|
||||
#diver_name=oracle.jdbc.driver.OracleDriver
|
||||
#url=jdbc:oracle:thin:@82.157.234.81:1521:orcl
|
||||
#username=original
|
||||
#password=123456
|
||||
#database_name=original
|
||||
|
||||
#postgre
|
||||
#diver_name=org.postgresql.Driver
|
||||
#url=jdbc:postgresql://localhost:5432/jeecg
|
||||
#username=postgres
|
||||
#password=postgres
|
||||
#database_name=jeecg
|
||||
diver_name=org.postgresql.Driver
|
||||
url=jdbc:postgresql://182.92.183.230:5432/jeecg-boot
|
||||
username=postgres
|
||||
password=U6D!TGH3
|
||||
database_name=public
|
||||
|
||||
#SQLServer2005\u4ee5\u4e0a
|
||||
#diver_name=org.hibernate.dialect.SQLServerDialect
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.commons.net.ftp.FTP;
|
|||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.enums.SampleFileHeader;
|
||||
import org.jeecg.modules.entity.data.HistogramData;
|
||||
|
@ -23,6 +24,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jeecg.common.constant.enums.FileTypeEnum.txt;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ReadLineUtil {
|
||||
|
@ -159,7 +162,7 @@ public class ReadLineUtil {
|
|||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (FileNotFoundException e){
|
||||
log.error("File["+filePath+"]does not exist!");
|
||||
log.error("File ["+filePath+"] does not exist!");
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -179,7 +182,7 @@ public class ReadLineUtil {
|
|||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
// 判断FTP是否连接成功
|
||||
if (Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("FTP连接失败!");
|
||||
throw new RuntimeException(Prompt.FTP_ERR);
|
||||
}
|
||||
|
||||
OutputStream outputStream = null;
|
||||
|
@ -191,20 +194,21 @@ public class ReadLineUtil {
|
|||
// 判断FTP服务器上是否存在此文件
|
||||
String[] files = ftpClient.listNames(filePath);
|
||||
if (ArrayUtil.isEmpty(files)){
|
||||
String message = "File["+filePath+"]does not exist!";
|
||||
String message = "File ["+filePath+"] does not exist!";
|
||||
log.error(message);
|
||||
return Result.error(message);
|
||||
}
|
||||
|
||||
// 存在多个文件名表示此路径为目录而非文件
|
||||
if (ArrayUtil.length(files) > 1){
|
||||
String message = "["+filePath+"]There are multiple files, possibly one directory!";
|
||||
String message = "["+filePath+"] There are multiple files, possibly one directory!";
|
||||
log.error(message);
|
||||
return Result.error(message);
|
||||
}
|
||||
|
||||
// 获取文件名
|
||||
String fileName = FileUtil.getName(filePath);
|
||||
if (!fileName.endsWith(txt.getType()))fileName += txt.getType();
|
||||
|
||||
// 在当前工作路径下读取文件
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.util.ReadLineUtil;
|
||||
import org.jeecg.modules.base.entity.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.GardsSohData;
|
||||
|
@ -97,7 +98,7 @@ public class WebStatisticsController {
|
|||
GardsSampleData sampleData = gardsSampleDataWebService.getOneSample(sampleId);
|
||||
String filePath = sampleData.getInputFileName();
|
||||
if (StrUtil.isBlank(filePath))
|
||||
return Result.error("The file you are looking for does not exist!");
|
||||
return Result.error(Prompt.FILE_NOT_EXITS);
|
||||
return readLineUtil.readFtpFile(filePath,response);
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,7 @@ public class WebStatisticsController {
|
|||
GardsSohData soh = gardsSohDataService.getOneSoh(sohId);
|
||||
String filePath = soh.getInputFileName();
|
||||
if (StrUtil.isBlank(filePath))
|
||||
return Result.error("The file you are looking for does not exist!");
|
||||
return Result.error(Prompt.FILE_NOT_EXITS);
|
||||
return readLineUtil.readFtpFile(filePath,response);
|
||||
}
|
||||
|
||||
|
@ -124,7 +125,7 @@ public class WebStatisticsController {
|
|||
reportPath = reviewedService.getOne(sampleId).getReportPath();
|
||||
}
|
||||
if (StrUtil.isBlank(reportPath))
|
||||
return Result.error("The file you are looking for does not exist!");
|
||||
return Result.error(Prompt.FILE_NOT_EXITS);
|
||||
// 将FTP上的文件转为文件流返回到前端
|
||||
return readLineUtil.readFtpFile(reportPath,response);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user