feat: 增加规则启用停用

dev
huangfeng 1 year ago
parent ca2971fcb0
commit 3de16c5835

@ -59,6 +59,11 @@ public class WarnRule {
@Column(name = "level")
private Integer level;
@NotNull(message = "状态不能为空")
@ApiModelProperty("状态 0:停用 1:启用")
@Column(name = "active")
private Integer active;
@ApiModelProperty("最后数据采集时间")
@Column(name = "last_d_time")
private Date lastDTime;

@ -51,6 +51,7 @@ public class WarnRuleServiceImpl implements WarnRuleService {
@Override
public WarnRule add(WarnRule item) throws Exception {
item.setId(null);
item.setLastDTime(null);
NSensor sensor = sensorService.detail(item.getSensorId());
Optional<ModevTypePoint> optionalModevTypePoint = typePointRepository.findById(item.getModevtypePointId());
if (!optionalModevTypePoint.isPresent()) {
@ -76,6 +77,7 @@ public class WarnRuleServiceImpl implements WarnRuleService {
rule.setOperator(item.getOperator());
rule.setThreshold(item.getThreshold());
rule.setLevel(item.getLevel());
rule.setActive(item.getActive());
repository.save(rule);
}

@ -39,8 +39,10 @@ public class RuleCheckTask {
try {
List<WarnRule> ruleList = ruleService.listAll();
for (WarnRule rule : ruleList) {
if (rule.getActive() != null && rule.getActive().intValue() == 1) {
this.ruleCheck(rule);
}
}
} catch (Exception e) {
log.error("RuleCheckTask.checkAll error.", e);
}

Loading…
Cancel
Save