AlarmRuleLevelConfigMapper.java 2.0 KB
package com.skua.modules.alarm.mapper;

import java.util.List;

import com.skua.modules.alarm.vo.AlarmRuleAndAlarmRuleLevelVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skua.modules.alarm.entity.AlarmRuleLevelConfig;

public interface AlarmRuleLevelConfigMapper extends BaseMapper<AlarmRuleLevelConfig> {
	@Select({"select a.* from alarm_rule_level_config a inner join alarm_rule_config b on a.alarm_rule_id=b.id  where a.insert_tag = #{insertTag} and b.alarm_param_code=#{indexDict}"})
	List<AlarmRuleLevelConfig> getAlarmRuleLevelConfigsByInsertTag(@Param("insertTag") String insertTag,@Param("indexDict") String indexDict);

	@Select({"SELECT arc.id alarm_rule_id,alarm_param_type,alarm_rule_type," +
			"arc.alarm_param_name,alarm_rule_status,alarm_program_code,arc.alarm_param_code," +
			"arc.alarm_param_unit,alarm_time_interval,alarm_data_over_standard_rate,factory_id," +
			"( SELECT depart_name FROM sys_depart sd WHERE sd.id = arc.factory_id ) factory_name," +
			"arlc.id alarm_rule_level_id,alarm_rule_level_name,is_send_sms," +
			"sms_send_frequency,sms_allow_send_time,is_send_notice,alarm_sms_recipient," +
			"alarm_sms_recipient_phone,alarm_notice_recipient,his.count as warn_count " +
			"FROM " +
			"alarm_rule_config arc " +
			"LEFT JOIN alarm_rule_level_config arlc ON arc.id = arlc.alarm_rule_id " +
			"LEFT JOIN ( SELECT alarm_param_code, count( 1 ) AS count FROM alarm_warning_record_history " +
			"WHERE record_time BETWEEN #{lastDateTime} AND #{nowDateTime} GROUP BY alarm_param_code ) his ON arc.alarm_program_code = his.alarm_param_code " +
			"WHERE arc.alarm_rule_type = '1' " +
			"AND alarm_rule_status = '1' " +
			"AND arc.alarm_param_type = '1' " +
			"AND arc.del_flag = '1' " +
			"AND his.count is null "})
	List<AlarmRuleAndAlarmRuleLevelVO> getAlarmList(@Param("nowDateTime") String nowDateTime, @Param("lastDateTime") String lastDateTime);
}