|  | @@ -3,6 +3,8 @@ package com.xunmei.iot.service.impl;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.mediator.domain.IotAlarmRule;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.mediator.domain.IotAlarmRuleExpress;
 | 
	
	
		
			
				|  | @@ -10,6 +12,7 @@ import com.xunmei.common.core.domain.mediator.domain.IotAlarmSystemField;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.util.BeanHelper;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.utils.IDHelper;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.utils.KeyValue;
 | 
	
		
			
				|  |  | +import com.xunmei.common.core.web.page.TableDataInfo;
 | 
	
		
			
				|  |  |  import com.xunmei.common.security.utils.SecurityUtils;
 | 
	
		
			
				|  |  |  import com.xunmei.iot.dto.alarm.IotAlarmRuleDto;
 | 
	
		
			
				|  |  |  import com.xunmei.iot.dto.alarm.IotAlarmRuleExpressDto;
 | 
	
	
		
			
				|  | @@ -131,19 +134,33 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<IotInitAlarmRuleVo> getAlarmRuleDatas(String alarmType, String ruleName, Integer pageIndex, Integer pageSize) throws Exception {
 | 
	
		
			
				|  |  | +    public TableDataInfo<IotInitAlarmRuleVo> getAlarmRuleDatas(String alarmType, String ruleName, Integer pageIndex, Integer pageSize) throws Exception {
 | 
	
		
			
				|  |  |          LambdaQueryWrapper<IotAlarmRule> queryWrapper = new LambdaQueryWrapper<>();
 | 
	
		
			
				|  |  | -        List<IotAlarmRule> appAlarmRule = this.baseMapper.selectList(queryWrapper);
 | 
	
		
			
				|  |  | +        if(alarmType!=null && !alarmType.isEmpty())
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            queryWrapper.eq(IotAlarmRule::getType,alarmType);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(ruleName !=null && !ruleName.isEmpty())
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            queryWrapper.like(IotAlarmRule::getName,ruleName);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Page<IotAlarmRule> page = new Page<>(pageIndex,pageSize);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        IPage<IotAlarmRule> appAlarmRule= this.baseMapper.selectPage(page,queryWrapper);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<IotInitAlarmRuleVo> datas = new ArrayList<>();
 | 
	
		
			
				|  |  | -        appAlarmRule.stream().forEach(i -> {
 | 
	
		
			
				|  |  | +        appAlarmRule.getRecords().stream().forEach(i -> {
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  datas.add(getAlarmRuleData(i.getId()));
 | 
	
		
			
				|  |  |              } catch (Exception e) {
 | 
	
		
			
				|  |  |                  throw new RuntimeException(e);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        return datas;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        TableDataInfo<IotInitAlarmRuleVo> pageDatas= TableDataInfo.build(datas);
 | 
	
		
			
				|  |  | +        pageDatas.setCode(200);
 | 
	
		
			
				|  |  | +        pageDatas.setTotal(appAlarmRule.getTotal());
 | 
	
		
			
				|  |  | +        return pageDatas;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -181,4 +198,16 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
 | 
	
		
			
				|  |  |          iotAlarmRuleExpressService.remove(new LambdaQueryWrapper<IotAlarmRuleExpress>().eq(IotAlarmRuleExpress::getRuleId, rule.getId()));
 | 
	
		
			
				|  |  |          iotAlarmRuleExpressService.saveBatch(appAlarmRuleExpressesList);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void deleteAlarmRule(Long ruleId)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        LambdaQueryWrapper<IotAlarmRule> queryWrapper = new LambdaQueryWrapper<>();
 | 
	
		
			
				|  |  | +        queryWrapper.eq(IotAlarmRule::getId,ruleId);
 | 
	
		
			
				|  |  | +        this.baseMapper.delete(queryWrapper);
 | 
	
		
			
				|  |  | +        LambdaQueryWrapper<IotAlarmRuleExpress> ruleExpressWrapper = new LambdaQueryWrapper<>();
 | 
	
		
			
				|  |  | +        ruleExpressWrapper.eq(IotAlarmRuleExpress::getRuleId,ruleId);
 | 
	
		
			
				|  |  | +        iotAlarmRuleExpressService.remove(ruleExpressWrapper);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |