package com.huatek.busi.service.impl.arrester;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huatek.busi.dto.BusiOfflineArresterCheckDto;
import com.huatek.busi.entity.BusiOfflineArresterCheck;
import com.huatek.busi.mapper.BusiOfflineArresterCheckMapper;
import com.huatek.busi.service.arrester.BusiOfflineArresterCheckService;
import com.huatek.busi.vo.BusiOfflineArresterCheckVo;
import com.huatek.frame.base.util.BeanUtils;
import com.huatek.torch.util.uuid.Uuid;

/** 
 * @ClassName: BusiOfflineArresterThresholdServiceImpl
 * @FullClassPath: com.huatek.busi.service.impl.arrester.ArresterBrandServiceImpl
 * @Description: 避雷器-例行实验
 * @author: edward_luo
 * @date: Jul 05, 2019 12:01:11 AM
 * @version: 1.0
*/
@Component
@Service(interfaceClass = BusiOfflineArresterCheckService.class)
@Transactional(rollbackFor = Exception.class)
public class BusiOfflineArresterCheckServiceImpl implements BusiOfflineArresterCheckService {
	
	
	@Autowired
	BusiOfflineArresterCheckMapper busiOfflineArresterCheckMapper;
	
	@Override
	public BusiOfflineArresterCheckVo findArresterCheckInfo(String eqmCode) {
		BusiOfflineArresterCheckVo busiOfflineArresterCheckVo = new BusiOfflineArresterCheckVo();
		BusiOfflineArresterCheck busiOfflineArresterCheck = busiOfflineArresterCheckMapper.selectByeqmCode(eqmCode);
		if(!ObjectUtils.isEmpty(busiOfflineArresterCheck)) {
			BeanUtils.copyPropertiesWithIgnoreNull(busiOfflineArresterCheck, busiOfflineArresterCheckVo);
		}
	    return busiOfflineArresterCheckVo;
	}

	@Override
	public PageInfo<BusiOfflineArresterCheckVo> findBusiOfflineArresterCheckPage(
			BusiOfflineArresterCheckDto busiOfflineArresterCheckDto) {
		 return PageHelper.startPage(busiOfflineArresterCheckDto.getPage(), busiOfflineArresterCheckDto.getLimit()).doSelectPageInfo(() -> {
			 busiOfflineArresterCheckMapper.selectBusiOfflineGisCheckPage(busiOfflineArresterCheckDto);
		 });
	}

	@Override
	public int saveBusiOfflineArresterCheck(BusiOfflineArresterCheckDto busiOfflineArresterCheckDto) {
		int result = 0;
		BusiOfflineArresterCheck busiOfflineArresterCheck = new BusiOfflineArresterCheck();
		BeanUtils.copyPropertiesWithIgnoreNull(busiOfflineArresterCheckDto, busiOfflineArresterCheck);
		busiOfflineArresterCheck.setId(Uuid.getUUID());
		result = busiOfflineArresterCheckMapper.insertBusiOfflineArresterCheck(busiOfflineArresterCheck);
		return result;
	}
}
