|
|
@ -3,7 +3,9 @@ package com.xydl.cac.controller;
|
|
|
|
import com.xydl.cac.comparator.Comparator;
|
|
|
|
import com.xydl.cac.comparator.Comparator;
|
|
|
|
import com.xydl.cac.comparator.FloatCompare;
|
|
|
|
import com.xydl.cac.comparator.FloatCompare;
|
|
|
|
import com.xydl.cac.comparator.IntCompare;
|
|
|
|
import com.xydl.cac.comparator.IntCompare;
|
|
|
|
|
|
|
|
import com.xydl.cac.comparator.MissCompare;
|
|
|
|
import com.xydl.cac.entity.WarnRule;
|
|
|
|
import com.xydl.cac.entity.WarnRule;
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.constants.Constants;
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
import com.xydl.cac.model.ColumnModel;
|
|
|
|
import com.xydl.cac.model.ColumnModel;
|
|
|
|
import com.xydl.cac.model.Response;
|
|
|
|
import com.xydl.cac.model.Response;
|
|
|
@ -18,8 +20,6 @@ import javax.annotation.Resource;
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.xydl.cac.entity.constants.Constants.FloatCompare;
|
|
|
|
|
|
|
|
import static com.xydl.cac.entity.constants.Constants.IntCompare;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@Api(tags = {"告警规则相关接口"})
|
|
|
|
@Api(tags = {"告警规则相关接口"})
|
|
|
@ -28,6 +28,7 @@ import static com.xydl.cac.entity.constants.Constants.IntCompare;
|
|
|
|
public class WarnRuleController extends BasicController {
|
|
|
|
public class WarnRuleController extends BasicController {
|
|
|
|
FloatCompare floatCompare = new FloatCompare();
|
|
|
|
FloatCompare floatCompare = new FloatCompare();
|
|
|
|
IntCompare intCompare = new IntCompare();
|
|
|
|
IntCompare intCompare = new IntCompare();
|
|
|
|
|
|
|
|
MissCompare missCompare = new MissCompare();
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
WarnRuleService service;
|
|
|
|
WarnRuleService service;
|
|
|
@ -37,13 +38,17 @@ public class WarnRuleController extends BasicController {
|
|
|
|
public Response<List<ColumnModel>> listComparator() throws Exception {
|
|
|
|
public Response<List<ColumnModel>> listComparator() throws Exception {
|
|
|
|
List<ColumnModel> result = new ArrayList<>();
|
|
|
|
List<ColumnModel> result = new ArrayList<>();
|
|
|
|
ColumnModel item = new ColumnModel();
|
|
|
|
ColumnModel item = new ColumnModel();
|
|
|
|
item.setType(FloatCompare);
|
|
|
|
item.setType(Constants.FloatCompare);
|
|
|
|
item.setComment("浮点型数据比较器");
|
|
|
|
item.setComment("浮点型数据比较器");
|
|
|
|
result.add(item);
|
|
|
|
result.add(item);
|
|
|
|
item = new ColumnModel();
|
|
|
|
item = new ColumnModel();
|
|
|
|
item.setType(IntCompare);
|
|
|
|
item.setType(Constants.IntCompare);
|
|
|
|
item.setComment("整型数据比较器");
|
|
|
|
item.setComment("整型数据比较器");
|
|
|
|
result.add(item);
|
|
|
|
result.add(item);
|
|
|
|
|
|
|
|
item = new ColumnModel();
|
|
|
|
|
|
|
|
item.setType(Constants.MissCompare);
|
|
|
|
|
|
|
|
item.setComment("数据缺失比较器");
|
|
|
|
|
|
|
|
result.add(item);
|
|
|
|
return Response.success(result);
|
|
|
|
return Response.success(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -55,10 +60,12 @@ public class WarnRuleController extends BasicController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Comparator getComparator(String name) throws BusinessException {
|
|
|
|
private Comparator getComparator(String name) throws BusinessException {
|
|
|
|
if (FloatCompare.equalsIgnoreCase(name)) {
|
|
|
|
if (Constants.FloatCompare.equalsIgnoreCase(name)) {
|
|
|
|
return floatCompare;
|
|
|
|
return floatCompare;
|
|
|
|
} else if (IntCompare.equalsIgnoreCase(name)) {
|
|
|
|
} else if (Constants.IntCompare.equalsIgnoreCase(name)) {
|
|
|
|
return intCompare;
|
|
|
|
return intCompare;
|
|
|
|
|
|
|
|
} else if (Constants.MissCompare.equalsIgnoreCase(name)) {
|
|
|
|
|
|
|
|
return missCompare;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new BusinessException("未找到该比较器");
|
|
|
|
throw new BusinessException("未找到该比较器");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -69,14 +76,18 @@ public class WarnRuleController extends BasicController {
|
|
|
|
public Response<List<WarnRule>> listAll(Integer sensorId) throws Exception {
|
|
|
|
public Response<List<WarnRule>> listAll(Integer sensorId) throws Exception {
|
|
|
|
List<WarnRule> result = service.listAll(sensorId);
|
|
|
|
List<WarnRule> result = service.listAll(sensorId);
|
|
|
|
for (WarnRule item : result) {
|
|
|
|
for (WarnRule item : result) {
|
|
|
|
if (FloatCompare.equalsIgnoreCase(item.getComparator())) {
|
|
|
|
if (Constants.FloatCompare.equalsIgnoreCase(item.getComparator())) {
|
|
|
|
item.setComparatorDesc("浮点型数据比较器");
|
|
|
|
item.setComparatorDesc("浮点型数据比较器");
|
|
|
|
String name = floatCompare.supportedOperator().get(item.getOperator());
|
|
|
|
String name = floatCompare.supportedOperator().get(item.getOperator());
|
|
|
|
item.setOperatorDesc(name);
|
|
|
|
item.setOperatorDesc(name);
|
|
|
|
} else if (IntCompare.equalsIgnoreCase(item.getComparator())) {
|
|
|
|
} else if (Constants.IntCompare.equalsIgnoreCase(item.getComparator())) {
|
|
|
|
item.setComparatorDesc("整型数据比较器");
|
|
|
|
item.setComparatorDesc("整型数据比较器");
|
|
|
|
String name = intCompare.supportedOperator().get(item.getOperator());
|
|
|
|
String name = intCompare.supportedOperator().get(item.getOperator());
|
|
|
|
item.setOperatorDesc(name);
|
|
|
|
item.setOperatorDesc(name);
|
|
|
|
|
|
|
|
} else if (Constants.MissCompare.equalsIgnoreCase(item.getComparator())) {
|
|
|
|
|
|
|
|
item.setComparatorDesc("数据缺失比较器");
|
|
|
|
|
|
|
|
String name = intCompare.supportedOperator().get(item.getOperator());
|
|
|
|
|
|
|
|
item.setOperatorDesc(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Response.success(result);
|
|
|
|
return Response.success(result);
|
|
|
|