|
|
@@ -45,7 +45,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 告警配置Service业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author 杨晓辉
|
|
|
* @date 2025-03-07
|
|
|
*/
|
|
|
@@ -77,56 +77,58 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
|
|
|
/**
|
|
|
* 查询告警配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param wcBid 告警配置主键
|
|
|
* @return 告警配置
|
|
|
*/
|
|
|
@Override
|
|
|
- public IotWarnconfig selectIotWarnconfigByWcBid(String wcBid, String tid){
|
|
|
+ public IotWarnconfig selectIotWarnconfigByWcBid(String wcBid, String tid) {
|
|
|
|
|
|
return iotWarnconfigMapper.selectIotWarnconfigByWcBid(wcBid, tid);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询告警配置列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param iotWarnconfig 告警配置
|
|
|
* @return 告警配置
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<IotWarnconfig> selectIotWarnconfigList(IotWarnconfig iotWarnconfig){
|
|
|
+ public List<IotWarnconfig> selectIotWarnconfigList(IotWarnconfig iotWarnconfig) {
|
|
|
return iotWarnconfigMapper.selectIotWarnconfigList(iotWarnconfig);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询告警配置列表
|
|
|
- * */
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<IotWarnconfigResVo> selectIotWarnconfigResVoList(IotWarnconfig iotWarnconfig) {
|
|
|
List<IotWarnconfigResVo> iotWarnconfigResVoList = iotWarnconfigMapper.selectIotWarnconfigResVoList(iotWarnconfig);
|
|
|
List<String> wcBids = new ArrayList<>();
|
|
|
- Map<String,IotWarnconfigResVo> map = new HashMap<>();
|
|
|
- for(IotWarnconfigResVo iotWarnconfigResVo : iotWarnconfigResVoList){
|
|
|
+ Map<String, IotWarnconfigResVo> map = new HashMap<>();
|
|
|
+ for (IotWarnconfigResVo iotWarnconfigResVo : iotWarnconfigResVoList) {
|
|
|
iotWarnconfigResVo.setDevtypeName(IotDeviceDictEnum.getNameByCode(iotWarnconfigResVo.getDevtypeBid()));
|
|
|
iotWarnconfigResVo.setWcTouchtypeName(IotWarnTouchTypeEnum.findByCode(iotWarnconfigResVo.getWcTouchtype()).getContent());
|
|
|
iotWarnconfigResVo.setWcLevelName(IotWarnlevelEnum.findByCode(iotWarnconfigResVo.getWcLevel()).getContent());
|
|
|
iotWarnconfigResVo.setIotDeviceList(new ArrayList<>());
|
|
|
iotWarnconfigResVo.setSysUserList(new ArrayList<>());
|
|
|
wcBids.add(iotWarnconfigResVo.getWcBid());
|
|
|
- map.put(iotWarnconfigResVo.getWcBid(),iotWarnconfigResVo);
|
|
|
+ map.put(iotWarnconfigResVo.getWcBid(), iotWarnconfigResVo);
|
|
|
}
|
|
|
- if(!wcBids.isEmpty()){
|
|
|
+ if (!wcBids.isEmpty()) {
|
|
|
// 填充设备信息
|
|
|
- List<IotWarnobject> iotWarnobjectList = iotWarnobjectMapper.selectIotWarnobjectListByWcBids(wcBids,SecurityUtils.getTid());
|
|
|
- Map<String,List<IotWarnobject>> iotWarnobjectMap = iotWarnobjectList.stream().collect(Collectors.groupingBy(IotWarnobject::getDevBid));
|
|
|
- if(!iotWarnobjectMap.isEmpty()){
|
|
|
- List<IotDevice> iotDeviceList = iotDeviceMapper.selectIotDeviceByDevBids(new ArrayList<>(iotWarnobjectMap.keySet()),SecurityUtils.getTid());
|
|
|
- for(IotDevice iotDevice : iotDeviceList){
|
|
|
+ List<IotWarnobject> iotWarnobjectList = iotWarnobjectMapper.selectIotWarnobjectListByWcBids(wcBids, SecurityUtils.getTid());
|
|
|
+ Map<String, List<IotWarnobject>> iotWarnobjectMap = iotWarnobjectList.stream().collect(Collectors.groupingBy(IotWarnobject::getDevBid));
|
|
|
+ if (!iotWarnobjectMap.isEmpty()) {
|
|
|
+ List<IotDevice> iotDeviceList = iotDeviceMapper.selectIotDeviceByDevBids(new ArrayList<>(iotWarnobjectMap.keySet()), SecurityUtils.getTid());
|
|
|
+ for (IotDevice iotDevice : iotDeviceList) {
|
|
|
List<IotWarnobject> devWarnObjectList = iotWarnobjectMap.get(iotDevice.getDevBid());
|
|
|
- if(null == devWarnObjectList){
|
|
|
+ if (null == devWarnObjectList) {
|
|
|
continue;
|
|
|
}
|
|
|
- for(IotWarnobject iotWarnobject : devWarnObjectList){
|
|
|
+ for (IotWarnobject iotWarnobject : devWarnObjectList) {
|
|
|
IotWarnconfigResVo iotWarnconfigResVo = map.get(iotWarnobject.getWcBid());
|
|
|
- if(null != iotWarnconfigResVo){
|
|
|
+ if (null != iotWarnconfigResVo) {
|
|
|
iotWarnconfigResVo.getIotDeviceList().add(iotDevice);
|
|
|
}
|
|
|
}
|
|
|
@@ -142,35 +144,35 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
|
|
|
/**
|
|
|
* 新增告警配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param iotWarnconfig 告警配置
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertIotWarnconfig(IotWarnconfig iotWarnconfig){
|
|
|
+ public int insertIotWarnconfig(IotWarnconfig iotWarnconfig) {
|
|
|
return iotWarnconfigMapper.insertIotWarnconfig(iotWarnconfig);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改告警配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param iotWarnconfig 告警配置
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateIotWarnconfig(IotWarnconfig iotWarnconfig){
|
|
|
+ public int updateIotWarnconfig(IotWarnconfig iotWarnconfig) {
|
|
|
return iotWarnconfigMapper.updateIotWarnconfig(iotWarnconfig);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除告警配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param wcBids 需要删除的告警配置主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public int deleteIotWarnconfigWcBids(String[] wcBids, String tid){
|
|
|
+ public int deleteIotWarnconfigWcBids(String[] wcBids, String tid) {
|
|
|
int status = iotWarnconfigMapper.deleteIotWarnconfigWcBids(wcBids, tid);
|
|
|
iIotWarncountService.deleteIotWarncountByWcBids(wcBids, tid);
|
|
|
iotWarnindicatorService.deleteIotWarnindicatorByWcBids(wcBids, tid);
|
|
|
@@ -180,22 +182,22 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
|
|
|
/**
|
|
|
* 删除告警配置信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param wcBid 告警配置主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteIotWarnconfigByWcBid(String wcBid, String tid){
|
|
|
+ public int deleteIotWarnconfigByWcBid(String wcBid, String tid) {
|
|
|
return iotWarnconfigMapper.deleteIotWarnconfigByWcBid(wcBid, tid);
|
|
|
}
|
|
|
|
|
|
- private void addWarnindicator(String wcBid, List<IotWarnindicator> iotWarnindicatorList){
|
|
|
+ private void addWarnindicator(String wcBid, List<IotWarnindicator> iotWarnindicatorList) {
|
|
|
String createDate = DateUtils.dateTimeNow();
|
|
|
String wiCreator = SecurityUtils.getUserId();
|
|
|
String tid = SecurityUtils.getTid();
|
|
|
List<IotWarnindicator> insertList = new ArrayList<>();
|
|
|
|
|
|
- for(IotWarnindicator item : iotWarnindicatorList){
|
|
|
+ for (IotWarnindicator item : iotWarnindicatorList) {
|
|
|
String wiBid = item.getUUId();
|
|
|
|
|
|
item.setWiBid(wiBid);
|
|
|
@@ -206,15 +208,15 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
insertList.add(item);
|
|
|
|
|
|
List<IotWarnindicator> childrenList = item.getChildrenList();
|
|
|
- if(childrenList != null && !childrenList.isEmpty()){
|
|
|
+ if (childrenList != null && !childrenList.isEmpty()) {
|
|
|
Set<String> wiCodeSet = new HashSet<>();
|
|
|
- for(IotWarnindicator iotWarnindicator : childrenList){
|
|
|
+ for (IotWarnindicator iotWarnindicator : childrenList) {
|
|
|
String wiCode = iotWarnindicator.getWiCode();
|
|
|
- if(StringUtils.isEmpty(wiCode)){
|
|
|
- throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"告警要素不能为空");
|
|
|
+ if (StringUtils.isEmpty(wiCode)) {
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "告警要素不能为空");
|
|
|
}
|
|
|
- if(wiCodeSet.contains(wiCode)){
|
|
|
- throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"告警要素不能重复");
|
|
|
+ if (wiCodeSet.contains(wiCode)) {
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "告警要素不能重复");
|
|
|
}
|
|
|
|
|
|
iotWarnindicator.setWiBid(iotWarnindicator.getUUId());
|
|
|
@@ -231,7 +233,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(!insertList.isEmpty()){
|
|
|
+ if (!insertList.isEmpty()) {
|
|
|
iotWarnindicatorService.insertIotWarnindicatorBatch(insertList);
|
|
|
}
|
|
|
}
|
|
|
@@ -247,7 +249,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
|
|
|
// 获取告警对象
|
|
|
List<IotWarnobject> warnobjects = iotWarnconfigAddReqVo.getIotWarnobjectList();
|
|
|
- for(IotWarnobject iotWarnobject : warnobjects){
|
|
|
+ for (IotWarnobject iotWarnobject : warnobjects) {
|
|
|
iotWarnobject.setWoBid(iotWarnobject.getUUId());
|
|
|
iotWarnobject.setWcBid(iotWarnconfigAddReqVo.getWcBid());
|
|
|
iotWarnobject.setTid(SecurityUtils.getTid());
|
|
|
@@ -257,7 +259,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
// 获取告警规则
|
|
|
List<IotWarnindicator> iotWarnindicatorList = iotWarnconfigAddReqVo.getIotWarnindicatorList();
|
|
|
|
|
|
- addWarnindicator(iotWarnconfigAddReqVo.getWcBid(),iotWarnindicatorList);
|
|
|
+ addWarnindicator(iotWarnconfigAddReqVo.getWcBid(), iotWarnindicatorList);
|
|
|
return iotWarnconfigMapper.insertIotWarnconfig(iotWarnconfigAddReqVo);
|
|
|
}
|
|
|
|
|
|
@@ -265,8 +267,8 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public int edit(IotWarnconfigEditReqVo iotWarnconfigEditReqVo) {
|
|
|
- if(StringUtils.isEmpty(iotWarnconfigEditReqVo.getWcBid())){
|
|
|
- throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"告警规则标识不能为空");
|
|
|
+ if (StringUtils.isEmpty(iotWarnconfigEditReqVo.getWcBid())) {
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "告警规则标识不能为空");
|
|
|
}
|
|
|
// 告警对象全量编辑
|
|
|
// 获取告警对象
|
|
|
@@ -276,18 +278,18 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
// 获取配置的旧的告警对象
|
|
|
List<IotWarnobject> oldWarnObjectList = iotWarnobjectService.selectIotWarnobjectList(iotWarnobjectQuery);
|
|
|
// 对比两个集合,获取不同的内容
|
|
|
- Collection<IotWarnobject> differ = CollectionUtils.disjunction(oldWarnObjectList,iotWarnconfigEditReqVo.getIotWarnobjectList());
|
|
|
+ Collection<IotWarnobject> differ = CollectionUtils.disjunction(oldWarnObjectList, iotWarnconfigEditReqVo.getIotWarnobjectList());
|
|
|
// 老数据中存在,新数据中不存在,代表被删除的数据,即旧数据与differ的交集
|
|
|
- Collection<IotWarnobject> deleteData = CollectionUtils.intersection(oldWarnObjectList,differ);
|
|
|
- for(IotWarnobject iotWarnobject :deleteData){
|
|
|
+ Collection<IotWarnobject> deleteData = CollectionUtils.intersection(oldWarnObjectList, differ);
|
|
|
+ for (IotWarnobject iotWarnobject : deleteData) {
|
|
|
iotWarnobjectService.deleteIotWarnobjectByWoBid(iotWarnobject.getWoBid(), SecurityUtils.getTid());
|
|
|
- iIotWarncountService.deleteIotWarncountByDevBidAndWcBid(iotWarnobject.getDevBid(),iotWarnobject.getWcBid(),SecurityUtils.getTid());
|
|
|
+ iIotWarncountService.deleteIotWarncountByDevBidAndWcBid(iotWarnobject.getDevBid(), iotWarnobject.getWcBid(), SecurityUtils.getTid());
|
|
|
// 清除告警对象的缓存
|
|
|
redisCacheManager.deleteObject(RedisCacheKey.IOT_WARN_RE_COUNTS, iotWarnconfigEditReqVo.getWcBid() + ":" + iotWarnobject.getDevBid());
|
|
|
}
|
|
|
// 老数据中不存在,新数据中存在,代表新增的数据,即入参与differ的交集
|
|
|
- Collection<IotWarnobject> addData = CollectionUtils.intersection(iotWarnconfigEditReqVo.getIotWarnobjectList(),differ);
|
|
|
- for(IotWarnobject addWarnObject : addData){
|
|
|
+ Collection<IotWarnobject> addData = CollectionUtils.intersection(iotWarnconfigEditReqVo.getIotWarnobjectList(), differ);
|
|
|
+ for (IotWarnobject addWarnObject : addData) {
|
|
|
addWarnObject.setTid(SecurityUtils.getTid());
|
|
|
addWarnObject.setWcBid(iotWarnconfigEditReqVo.getWcBid());
|
|
|
addWarnObject.setWoBid(addWarnObject.getUUId());
|
|
|
@@ -295,14 +297,14 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
}
|
|
|
|
|
|
// 考虑编辑设备的情况下,对应的规则可能出现调整的情况,
|
|
|
- iotWarnindicatorService.deleteIotWarnindicatorByWcBid(iotWarnconfigEditReqVo.getWcBid(),SecurityUtils.getTid());
|
|
|
+ iotWarnindicatorService.deleteIotWarnindicatorByWcBid(iotWarnconfigEditReqVo.getWcBid(), SecurityUtils.getTid());
|
|
|
|
|
|
List<IotWarnindicator> iotWarnindicatorList = iotWarnconfigEditReqVo.getIotWarnindicatorList();
|
|
|
- addWarnindicator(iotWarnconfigEditReqVo.getWcBid(),iotWarnindicatorList);
|
|
|
+ addWarnindicator(iotWarnconfigEditReqVo.getWcBid(), iotWarnindicatorList);
|
|
|
return iotWarnconfigMapper.updateIotWarnconfig(iotWarnconfigEditReqVo);
|
|
|
}
|
|
|
|
|
|
- private void setInfoByQxz(IotWarnconfig iotWarnconfig, List<IotWarnobject> iotWarnobjectList, List<IotWarnindicator> resultIotWarnIndicatorList){
|
|
|
+ private void setInfoByQxz(IotWarnconfig iotWarnconfig, List<IotWarnobject> iotWarnobjectList, List<IotWarnindicator> resultIotWarnIndicatorList) {
|
|
|
String wcBid = iotWarnconfig.getWcBid();
|
|
|
String tid = SecurityUtils.getTid();
|
|
|
|
|
|
@@ -312,7 +314,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
// 获取已经配置的设备要素
|
|
|
List<IotWarnindicator> iotWarnindicatorList = iotWarnindicatorService.selectIotWarnindicatorList(iotWarnindicatorQuery);
|
|
|
Set<String> wiCodeSet = new HashSet<>();
|
|
|
- if(iotWarnobjectList.size() ==1){
|
|
|
+ if (iotWarnobjectList.size() == 1) {
|
|
|
IotDevice deviceQuery = new IotDevice();
|
|
|
deviceQuery.setDevBid(iotWarnobjectList.get(0).getDevBid());
|
|
|
deviceQuery.setDevtypeBid(iotWarnconfig.getDevtypeBid());
|
|
|
@@ -320,14 +322,14 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
wiCodeSet.addAll(devNowWarnIndicator.stream().map(IotWarnindicator::getWiCode).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
- for(IotWarnindicator iotWarnindicator : iotWarnindicatorList){
|
|
|
- if(wiCodeSet.contains(iotWarnindicator.getWiCode())){
|
|
|
+ for (IotWarnindicator iotWarnindicator : iotWarnindicatorList) {
|
|
|
+ if (wiCodeSet.contains(iotWarnindicator.getWiCode())) {
|
|
|
resultIotWarnIndicatorList.add(iotWarnindicator);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void setInfoByCbd(IotWarnconfig iotWarnconfig, List<IotWarnobject> iotWarnobjectList, List<IotWarnindicator> resultIotWarnIndicatorList){
|
|
|
+ private void setInfoByCbd(IotWarnconfig iotWarnconfig, List<IotWarnobject> iotWarnobjectList, List<IotWarnindicator> resultIotWarnIndicatorList) {
|
|
|
String wcBid = iotWarnconfig.getWcBid();
|
|
|
String tid = SecurityUtils.getTid();
|
|
|
|
|
|
@@ -337,17 +339,17 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
// 获取已经配置的设备要素
|
|
|
List<IotWarnindicator> iotWarnindicatorList = iotWarnindicatorService.selectIotWarnindicatorList(iotWarnindicatorQuery);
|
|
|
Map<String, IotWarnindicator> iotWarnindicatorMap = new LinkedHashMap<>();
|
|
|
- for(IotWarnindicator iotWarnindicator : iotWarnindicatorList){
|
|
|
+ for (IotWarnindicator iotWarnindicator : iotWarnindicatorList) {
|
|
|
String wiBid = iotWarnindicator.getWiBid();
|
|
|
String wiParentbid = iotWarnindicator.getWiParentbid();
|
|
|
- if(iotWarnindicatorMap.containsKey(wiParentbid)){
|
|
|
+ if (iotWarnindicatorMap.containsKey(wiParentbid)) {
|
|
|
List<IotWarnindicator> childrenList = iotWarnindicatorMap.get(wiParentbid).getChildrenList();
|
|
|
- if(childrenList == null){
|
|
|
+ if (childrenList == null) {
|
|
|
childrenList = new ArrayList<>();
|
|
|
}
|
|
|
childrenList.add(iotWarnindicator);
|
|
|
iotWarnindicatorMap.get(wiParentbid).setChildrenList(childrenList);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
iotWarnindicatorMap.put(wiBid, iotWarnindicator);
|
|
|
}
|
|
|
}
|
|
|
@@ -358,7 +360,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
public IotWarnconfigInfoResVo info(String wcBid) {
|
|
|
String tid = SecurityUtils.getTid();
|
|
|
IotWarnconfig iotWarnconfig = selectIotWarnconfigByWcBid(wcBid, tid);
|
|
|
- if(null == iotWarnconfig){
|
|
|
+ if (null == iotWarnconfig) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -370,19 +372,21 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
List<IotWarnindicator> resultIotWarnIndicatorList = new ArrayList<>();
|
|
|
|
|
|
IotWarnconfigInfoResVo iotWarnconfigInfoResVo = new IotWarnconfigInfoResVo();
|
|
|
- BeanUtils.copyProperties(iotWarnconfig,iotWarnconfigInfoResVo);
|
|
|
+ BeanUtils.copyProperties(iotWarnconfig, iotWarnconfigInfoResVo);
|
|
|
iotWarnconfigInfoResVo.setIotWarnindicatorList(resultIotWarnIndicatorList);
|
|
|
iotWarnconfigInfoResVo.setIotWarnobjectList(iotWarnobjectList);
|
|
|
|
|
|
String devtypeBid = iotWarnconfig.getDevtypeBid();
|
|
|
-
|
|
|
- if(DevTypeUtil.isQxSq(devtypeBid)){
|
|
|
- setInfoByQxz(iotWarnconfig, iotWarnobjectList, resultIotWarnIndicatorList);
|
|
|
- }else if(DevTypeUtil.isYfCbd(devtypeBid)){
|
|
|
- setInfoByCbd(iotWarnconfig, iotWarnobjectList, resultIotWarnIndicatorList);
|
|
|
+ if (!StringUtils.isEmpty(devtypeBid)) {
|
|
|
+ if (DevTypeUtil.isQxSq(devtypeBid)) {
|
|
|
+ setInfoByQxz(iotWarnconfig, iotWarnobjectList, resultIotWarnIndicatorList);
|
|
|
+ } else if (DevTypeUtil.isYfCbd(devtypeBid)) {
|
|
|
+ setInfoByCbd(iotWarnconfig, iotWarnobjectList, resultIotWarnIndicatorList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- BeanUtils.copyProperties(iotWarnconfig,iotWarnconfigInfoResVo);
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(iotWarnconfig, iotWarnconfigInfoResVo);
|
|
|
iotWarnconfigInfoResVo.setIotWarnindicatorList(resultIotWarnIndicatorList);
|
|
|
iotWarnconfigInfoResVo.setIotWarnobjectList(iotWarnobjectList);
|
|
|
return iotWarnconfigInfoResVo;
|
|
|
@@ -399,15 +403,15 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
jsonObject.put("interval", interval);
|
|
|
|
|
|
IotDevice iotDevice = iotDeviceMapper.selectIotDeviceByDevBid(devBid);
|
|
|
- if(iotDevice == null || devtypeSet.contains(iotDevice.getDevtypeBid())){
|
|
|
+ if (iotDevice == null || devtypeSet.contains(iotDevice.getDevtypeBid())) {
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
interval = getReportIntervalByConfig(devBid);
|
|
|
- if(interval == null){
|
|
|
+ if (interval == null) {
|
|
|
interval = getReportIntervalByData(iotDevice);
|
|
|
}
|
|
|
- jsonObject.put("interval",interval);
|
|
|
+ jsonObject.put("interval", interval);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
@@ -415,9 +419,9 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public IotWarnconfig copy(String wcBid) {
|
|
|
// 查询告警规则
|
|
|
- IotWarnconfig iotWarnconfig = selectIotWarnconfigByWcBid(wcBid,SecurityUtils.getTid());
|
|
|
- if(null == iotWarnconfig){
|
|
|
- throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"告警规则不存在");
|
|
|
+ IotWarnconfig iotWarnconfig = selectIotWarnconfigByWcBid(wcBid, SecurityUtils.getTid());
|
|
|
+ if (null == iotWarnconfig) {
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "告警规则不存在");
|
|
|
}
|
|
|
|
|
|
// 查询告警对象
|
|
|
@@ -429,9 +433,9 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
// 查询告警策略
|
|
|
String devtypeBid = iotWarnconfig.getDevtypeBid();
|
|
|
List<IotWarnindicator> iotWarnindicatorList = new ArrayList<>();
|
|
|
- if(DevTypeUtil.isQxSq(devtypeBid)){
|
|
|
+ if (DevTypeUtil.isQxSq(devtypeBid)) {
|
|
|
setInfoByQxz(iotWarnconfig, iotWarnobjectList, iotWarnindicatorList);
|
|
|
- }else if(DevTypeUtil.isYfCbd(devtypeBid)){
|
|
|
+ } else if (DevTypeUtil.isYfCbd(devtypeBid)) {
|
|
|
setInfoByCbd(iotWarnconfig, iotWarnobjectList, iotWarnindicatorList);
|
|
|
}
|
|
|
|
|
|
@@ -442,7 +446,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
iotWarnconfig.setWcCreator(SecurityUtils.getUserId());
|
|
|
iotWarnconfig.setWcModifieddate(null);
|
|
|
iotWarnconfig.setWcModifier(null);
|
|
|
- for(IotWarnobject iotWarnobject : iotWarnobjectList){
|
|
|
+ for (IotWarnobject iotWarnobject : iotWarnobjectList) {
|
|
|
iotWarnobject.setWcBid(newWcBid);
|
|
|
iotWarnobject.setWoBid(iotWarnobject.getUUId());
|
|
|
iotWarnobjectMapper.insertIotWarnobject(iotWarnobject);
|
|
|
@@ -459,9 +463,10 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
public int editStatus(IotWarnconfig updateObject) {
|
|
|
return iotWarnconfigMapper.updateIotWarnconfig(updateObject);
|
|
|
}
|
|
|
+
|
|
|
private Integer getQxZReportInterval(JSONArray dataList) {
|
|
|
Integer interval = null;
|
|
|
- try{
|
|
|
+ try {
|
|
|
JSONArray oneArray = dataList.getJSONArray(0);
|
|
|
JSONArray twoArray = dataList.getJSONArray(1);
|
|
|
|
|
|
@@ -471,11 +476,12 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
Date oneDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, oneTime);
|
|
|
Date twoDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, twoTime);
|
|
|
interval = (int) (oneDate.getTime() - twoDate.getTime()) / 1000 / 60;
|
|
|
- }catch (Exception e){}
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
return interval;
|
|
|
}
|
|
|
|
|
|
- private Integer getReportIntervalByConfig(String devBid){
|
|
|
+ private Integer getReportIntervalByConfig(String devBid) {
|
|
|
Integer interval = null;
|
|
|
String[] keys = {
|
|
|
"interval", "datt", "dat_f"
|
|
|
@@ -485,8 +491,8 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
String configContext = iotDeviceconfig.getDevcfgContext();
|
|
|
if (JSON.isValidObject(configContext)) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(configContext);
|
|
|
- for(String key : keys){
|
|
|
- if(jsonObject.containsKey(key)){
|
|
|
+ for (String key : keys) {
|
|
|
+ if (jsonObject.containsKey(key)) {
|
|
|
interval = jsonObject.getInteger(key);
|
|
|
break;
|
|
|
}
|
|
|
@@ -496,7 +502,7 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
return interval;
|
|
|
}
|
|
|
|
|
|
- private Integer getReportIntervalByData(IotDevice iotDevice){
|
|
|
+ private Integer getReportIntervalByData(IotDevice iotDevice) {
|
|
|
Integer interval = null;
|
|
|
// 获取今天23:59:59
|
|
|
LocalDateTime todayEnd = LocalDateTime.now().withHour(23).withMinute(59).withSecond(59);
|
|
|
@@ -521,12 +527,12 @@ public class IotWarnconfigServiceImpl implements IIotWarnconfigService {
|
|
|
|
|
|
TableDataInfo tableDataInfo = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
|
|
|
List result = tableDataInfo.getData();
|
|
|
- if(result == null || result.size() < 2){
|
|
|
+ if (result == null || result.size() < 2) {
|
|
|
return null;
|
|
|
}
|
|
|
JSONArray dataList = JSONArray.from(result);
|
|
|
String devtypeBid = iotDevice.getDevtypeBid();
|
|
|
- if(DevTypeUtil.isQxSq(devtypeBid)){
|
|
|
+ if (DevTypeUtil.isQxSq(devtypeBid)) {
|
|
|
interval = getQxZReportInterval(dataList);
|
|
|
}
|
|
|
return interval;
|