package com.unis.detectionnum.server.domain;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unis.common.utils.LsBeanUtils;
import com.unis.detectionnum.common.vo.AlarmGenerateMainVO;
import com.unis.detectionnum.server.dao.TcAlarmGenerateDetailDao;
import com.unis.detectionnum.server.dao.TcAlarmGenerateMainDao;
import com.unis.detectionnum.server.entity.TcAlarmGenerateMainDO;

/** 
 * @ClassName: AlarmGenerateDomain 
 * @Description: TODO 
 * @author LiuFeng 
 * @date 2019年9月29日 上午10:00:47  
 */
@Component
public class AlarmGenerateDomain extends BaseDomain{
	
	@Autowired
	private TcAlarmGenerateMainDao alarmGenerateMainDao;
	
	@Autowired
	private TcAlarmGenerateDetailDao alarmGenerateDetailDao;
	
	/** 
	 * @Title: saveAlarmGenerateMain 
	 * @Description: TODO
	 * @param @param alarmGenerateMainVO
	 * @param @return
	 * @return String
	 * @throws 
	 */
	public String saveAlarmGenerateMain(AlarmGenerateMainVO alarmGenerateMainVO) {
		
		TcAlarmGenerateMainDO alarmGenerateMainDO = new TcAlarmGenerateMainDO();
		LsBeanUtils.copyAllProperties(alarmGenerateMainVO, alarmGenerateMainDO);
		alarmGenerateMainDao.insertSelective(alarmGenerateMainDO);
		return alarmGenerateMainDO.getGenerateNo();
	}

	/** 
	 * @Title: updateAlarmGenerateMain 
	 * @Description: 告警规则信息修改
	 * @param alarmGenerateMainVO
	 * @return void
	 * @throws 
	 */
	public void updateAlarmGenerateMain(AlarmGenerateMainVO alarmGenerateMainVO) {
		
		TcAlarmGenerateMainDO alarmGenerateMainDO = new TcAlarmGenerateMainDO();
		LsBeanUtils.copyAllProperties(alarmGenerateMainVO, alarmGenerateMainDO);
		alarmGenerateMainDao.updateByPrimaryKeySelective(alarmGenerateMainDO);
	}

	/** 
	 * @Title: deleteAlarmGenerateMain 
	 * @Description: 根据告警编号删除告警信息
	 * @param generateNo
	 * @return void
	 * @throws 
	 */
	public void deleteAlarmGenerateMain(String generateNo) {
		
		alarmGenerateMainDao.deleteByPrimaryKey(generateNo);
	}

	/** 
	 * @Title: alarmGenerateMainPageList 
	 * @Description: TODO
	 * @param pageNum
	 * @param pageSize
	 * @param alarmGenerateMainVO
	 * @return PageInfo<AlarmGenerateMainVO>
	 * @throws 
	 */
	public PageInfo<AlarmGenerateMainVO> alarmGenerateMainPageList(Integer pageNum, Integer pageSize,
			AlarmGenerateMainVO alarmGenerateMainVO) {
		
		PageInfo<AlarmGenerateMainVO> pageInfoVO = new PageInfo<AlarmGenerateMainVO>();
		
		PageHelper.startPage(pageNum, pageSize);
		List<TcAlarmGenerateMainDO> tcAGMainDOs =  alarmGenerateMainDao.selectAGMainListByQuery(alarmGenerateMainVO);
		PageInfo<TcAlarmGenerateMainDO> PageInfoDO = new PageInfo<TcAlarmGenerateMainDO>(tcAGMainDOs);
		LsBeanUtils.copyAllProperties(PageInfoDO,pageInfoVO);
		
		return pageInfoVO;
	}

}
