|
@@ -26,6 +26,7 @@ import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnconfigInfoResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnconfigResVo;
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnconfigResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.mapper.*;
|
|
import com.yunfeiyun.agmp.iotm.web.mapper.*;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotWarnconfigService;
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotWarnconfigService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotWarncountService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotWarnindicatorService;
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotWarnindicatorService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotWarnobjectService;
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotWarnobjectService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -59,8 +60,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
private IotDeviceconfigMapper iotDeviceconfigMapper;
|
|
private IotDeviceconfigMapper iotDeviceconfigMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private RedisCacheManager redisCacheManager;
|
|
private RedisCacheManager redisCacheManager;
|
|
|
- @Resource
|
|
|
|
|
- private IotWarncountMapper iotWarncountMapper;
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private IIotWarnindicatorService iotWarnindicatorService;
|
|
private IIotWarnindicatorService iotWarnindicatorService;
|
|
|
|
|
|
|
@@ -70,6 +70,9 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IIotWarnobjectService iotWarnobjectService;
|
|
private IIotWarnobjectService iotWarnobjectService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIotWarncountService iIotWarncountService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询告警配置
|
|
* 查询告警配置
|
|
@@ -179,34 +182,15 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
public int deleteIotWarnconfigByWcBid(String wcBid, String tid){
|
|
public int deleteIotWarnconfigByWcBid(String wcBid, String tid){
|
|
|
return iotWarnconfigMapper.deleteIotWarnconfigByWcBid(wcBid, tid);
|
|
return iotWarnconfigMapper.deleteIotWarnconfigByWcBid(wcBid, tid);
|
|
|
}
|
|
}
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
- @Override
|
|
|
|
|
- public int add(IotWarnconfigAddReqVo iotWarnconfigAddReqVo) {
|
|
|
|
|
- // 添加告警配置
|
|
|
|
|
- iotWarnconfigAddReqVo.setTid(SecurityUtils.getTid());
|
|
|
|
|
- iotWarnconfigAddReqVo.setWcBid(iotWarnconfigAddReqVo.getUUId());
|
|
|
|
|
- iotWarnconfigAddReqVo.setWcCreateddate(DateUtils.dateTimeNow());
|
|
|
|
|
- iotWarnconfigAddReqVo.setWcCreator(SecurityUtils.getUserId());
|
|
|
|
|
|
|
|
|
|
- // 获取告警对象
|
|
|
|
|
- List<IotWarnobject> warnobjects = iotWarnconfigAddReqVo.getIotWarnobjectList();
|
|
|
|
|
- for(IotWarnobject iotWarnobject : warnobjects){
|
|
|
|
|
- iotWarnobject.setWoBid(iotWarnobject.getUUId());
|
|
|
|
|
- iotWarnobject.setWcBid(iotWarnconfigAddReqVo.getWcBid());
|
|
|
|
|
- iotWarnobject.setTid(SecurityUtils.getTid());
|
|
|
|
|
- iotWarnobjectMapper.insertIotWarnobject(iotWarnobject);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 获取告警规则
|
|
|
|
|
- List<IotWarnindicator> iotWarnindicatorList = iotWarnconfigAddReqVo.getIotWarnindicatorList();
|
|
|
|
|
|
|
+ private void addWarnindicator(String wcBid, List<IotWarnindicator> iotWarnindicatorList){
|
|
|
String createDate = DateUtils.dateTimeNow();
|
|
String createDate = DateUtils.dateTimeNow();
|
|
|
|
|
+ String wiCreator = SecurityUtils.getUserId();
|
|
|
|
|
+ String tid = SecurityUtils.getTid();
|
|
|
List<IotWarnindicator> insertList = new ArrayList<>();
|
|
List<IotWarnindicator> insertList = new ArrayList<>();
|
|
|
|
|
|
|
|
for(IotWarnindicator item : iotWarnindicatorList){
|
|
for(IotWarnindicator item : iotWarnindicatorList){
|
|
|
String wiBid = item.getUUId();
|
|
String wiBid = item.getUUId();
|
|
|
- String tid = SecurityUtils.getTid();
|
|
|
|
|
- String wcBid = iotWarnconfigAddReqVo.getWcBid();
|
|
|
|
|
- String wiCreator = SecurityUtils.getUserId();
|
|
|
|
|
|
|
|
|
|
item.setWiBid(wiBid);
|
|
item.setWiBid(wiBid);
|
|
|
item.setWcBid(wcBid);
|
|
item.setWcBid(wcBid);
|
|
@@ -243,9 +227,34 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
if(!insertList.isEmpty()){
|
|
if(!insertList.isEmpty()){
|
|
|
iotWarnindicatorService.insertIotWarnindicatorBatch(insertList);
|
|
iotWarnindicatorService.insertIotWarnindicatorBatch(insertList);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int add(IotWarnconfigAddReqVo iotWarnconfigAddReqVo) {
|
|
|
|
|
+ // 添加告警配置
|
|
|
|
|
+ iotWarnconfigAddReqVo.setTid(SecurityUtils.getTid());
|
|
|
|
|
+ iotWarnconfigAddReqVo.setWcBid(iotWarnconfigAddReqVo.getUUId());
|
|
|
|
|
+ iotWarnconfigAddReqVo.setWcCreateddate(DateUtils.dateTimeNow());
|
|
|
|
|
+ iotWarnconfigAddReqVo.setWcCreator(SecurityUtils.getUserId());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取告警对象
|
|
|
|
|
+ List<IotWarnobject> warnobjects = iotWarnconfigAddReqVo.getIotWarnobjectList();
|
|
|
|
|
+ for(IotWarnobject iotWarnobject : warnobjects){
|
|
|
|
|
+ iotWarnobject.setWoBid(iotWarnobject.getUUId());
|
|
|
|
|
+ iotWarnobject.setWcBid(iotWarnconfigAddReqVo.getWcBid());
|
|
|
|
|
+ iotWarnobject.setTid(SecurityUtils.getTid());
|
|
|
|
|
+ iotWarnobjectMapper.insertIotWarnobject(iotWarnobject);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取告警规则
|
|
|
|
|
+ List<IotWarnindicator> iotWarnindicatorList = iotWarnconfigAddReqVo.getIotWarnindicatorList();
|
|
|
|
|
+
|
|
|
|
|
+ addWarnindicator(iotWarnconfigAddReqVo.getWcBid(),iotWarnindicatorList);
|
|
|
return iotWarnconfigMapper.insertIotWarnconfig(iotWarnconfigAddReqVo);
|
|
return iotWarnconfigMapper.insertIotWarnconfig(iotWarnconfigAddReqVo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@Override
|
|
|
public int edit(IotWarnconfigEditReqVo iotWarnconfigEditReqVo) {
|
|
public int edit(IotWarnconfigEditReqVo iotWarnconfigEditReqVo) {
|
|
@@ -258,14 +267,14 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
iotWarnobjectQuery.setTid(SecurityUtils.getTid());
|
|
iotWarnobjectQuery.setTid(SecurityUtils.getTid());
|
|
|
iotWarnobjectQuery.setWcBid(iotWarnconfigEditReqVo.getWcBid());
|
|
iotWarnobjectQuery.setWcBid(iotWarnconfigEditReqVo.getWcBid());
|
|
|
// 获取配置的旧的告警对象
|
|
// 获取配置的旧的告警对象
|
|
|
- List<IotWarnobject> oldWarnObjectList = iotWarnobjectMapper.selectIotWarnobjectList(iotWarnobjectQuery);
|
|
|
|
|
|
|
+ List<IotWarnobject> oldWarnObjectList = iotWarnobjectService.selectIotWarnobjectList(iotWarnobjectQuery);
|
|
|
// 对比两个集合,获取不同的内容
|
|
// 对比两个集合,获取不同的内容
|
|
|
Collection<IotWarnobject> differ = CollectionUtils.disjunction(oldWarnObjectList,iotWarnconfigEditReqVo.getIotWarnobjectList());
|
|
Collection<IotWarnobject> differ = CollectionUtils.disjunction(oldWarnObjectList,iotWarnconfigEditReqVo.getIotWarnobjectList());
|
|
|
// 老数据中存在,新数据中不存在,代表被删除的数据,即旧数据与differ的交集
|
|
// 老数据中存在,新数据中不存在,代表被删除的数据,即旧数据与differ的交集
|
|
|
Collection<IotWarnobject> deleteData = CollectionUtils.intersection(oldWarnObjectList,differ);
|
|
Collection<IotWarnobject> deleteData = CollectionUtils.intersection(oldWarnObjectList,differ);
|
|
|
for(IotWarnobject iotWarnobject :deleteData){
|
|
for(IotWarnobject iotWarnobject :deleteData){
|
|
|
- iotWarnobjectMapper.deleteIotWarnobjectByWoBid(iotWarnobject.getWoBid(), SecurityUtils.getTid());
|
|
|
|
|
- iotWarncountMapper.deleteIotWarncountByDevBidAndWcBid(iotWarnobject.getDevBid(),iotWarnobject.getWcBid(),SecurityUtils.getTid());
|
|
|
|
|
|
|
+ iotWarnobjectService.deleteIotWarnobjectByWoBid(iotWarnobject.getWoBid(), SecurityUtils.getTid());
|
|
|
|
|
+ iIotWarncountService.deleteIotWarncountByDevBidAndWcBid(iotWarnobject.getDevBid(),iotWarnobject.getWcBid(),SecurityUtils.getTid());
|
|
|
// 清除告警对象的缓存
|
|
// 清除告警对象的缓存
|
|
|
redisCacheManager.deleteObject(RedisCacheKey.IOT_WARN_RE_COUNTS, iotWarnconfigEditReqVo.getWcBid() + ":" + iotWarnobject.getDevBid());
|
|
redisCacheManager.deleteObject(RedisCacheKey.IOT_WARN_RE_COUNTS, iotWarnconfigEditReqVo.getWcBid() + ":" + iotWarnobject.getDevBid());
|
|
|
}
|
|
}
|
|
@@ -277,16 +286,12 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
addWarnObject.setWoBid(addWarnObject.getUUId());
|
|
addWarnObject.setWoBid(addWarnObject.getUUId());
|
|
|
iotWarnobjectMapper.insertIotWarnobject(addWarnObject);
|
|
iotWarnobjectMapper.insertIotWarnobject(addWarnObject);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 考虑编辑设备的情况下,对应的规则可能出现调整的情况,
|
|
// 考虑编辑设备的情况下,对应的规则可能出现调整的情况,
|
|
|
- iotWarnindicatorMapper.deleteIotWarnindicatorByWcBid(iotWarnconfigEditReqVo.getWcBid(),SecurityUtils.getTid());
|
|
|
|
|
- for(IotWarnindicator iotWarnindicator : iotWarnconfigEditReqVo.getIotWarnindicatorList()){
|
|
|
|
|
- iotWarnindicator.setWiBid(iotWarnindicator.getUUId());
|
|
|
|
|
- iotWarnindicator.setWcBid(iotWarnconfigEditReqVo.getWcBid());
|
|
|
|
|
- iotWarnindicator.setTid(SecurityUtils.getTid());
|
|
|
|
|
- iotWarnindicator.setWiCreator(SecurityUtils.getTid());
|
|
|
|
|
- iotWarnindicator.setWiCreateddate(DateUtils.dateTimeNow());
|
|
|
|
|
- iotWarnindicatorMapper.insertIotWarnindicator(iotWarnindicator);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ iotWarnindicatorService.deleteIotWarnindicatorByWcBid(iotWarnconfigEditReqVo.getWcBid(),SecurityUtils.getTid());
|
|
|
|
|
+
|
|
|
|
|
+ List<IotWarnindicator> iotWarnindicatorList = iotWarnconfigEditReqVo.getIotWarnindicatorList();
|
|
|
|
|
+ addWarnindicator(iotWarnconfigEditReqVo.getWcBid(),iotWarnindicatorList);
|
|
|
return iotWarnconfigMapper.updateIotWarnconfig(iotWarnconfigEditReqVo);
|
|
return iotWarnconfigMapper.updateIotWarnconfig(iotWarnconfigEditReqVo);
|
|
|
}
|
|
}
|
|
|
|
|
|