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

import java.time.LocalDate;
import java.util.List;

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

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huatek.busi.dto.GisEmStatusDto;
import com.huatek.busi.dto.curve.BaseCurveQueryDto;
import com.huatek.busi.dto.curve.PointItemDto;
import com.huatek.busi.entity.GisEmStatus;
import com.huatek.busi.mapper.GisEmStatusMapper;
import com.huatek.busi.service.gis.GisEmStatusService;
import com.huatek.busi.service.impl.cac.AbstractCacEtlService;
import com.huatek.busi.vo.GisEmStatusVo;
import com.huatek.busi.vo.curve.PointItemVo;

/**
 * 断路器/GIS——储能电机工作状态：024006 ServiceImpl
 *
 * @author anker_cheng
 * @date Jun 26, 2019 1:11:48 PM
 */
@Component
@Service(interfaceClass = GisEmStatusService.class)
@Transactional(rollbackFor = Exception.class)
public class GisEmStatusServiceImpl extends AbstractCacEtlService<GisEmStatus> implements GisEmStatusService {

    @Autowired
    private GisEmStatusMapper gisEmStatusMapper;

    @Override
    public Page<GisEmStatusVo> findGisEmStatusPage(GisEmStatusDto gisEmStatusDto) {
        if (gisEmStatusDto.getPage() != null && gisEmStatusDto.getLimit() != null) {
            PageHelper.startPage(gisEmStatusDto.getPage(), gisEmStatusDto.getLimit());
        }
        Page<GisEmStatusVo> gisEmStatuss = gisEmStatusMapper.selectGisEmStatusPage(gisEmStatusDto);
        return gisEmStatuss;
    }

	@Override
	public List<BaseCurveQueryDto> findSensorCodeList(LocalDate day) {
		return gisEmStatusMapper.findSensorCodeList(day.atStartOfDay(), day.plusDays(1).atStartOfDay());
	}

    @Override
    public List<PointItemVo> findDaylyPointList(BaseCurveQueryDto sensorCode, LocalDate day, String subType) {
        return gisEmStatusMapper.findDaylyPointList(sensorCode, subType, day.atStartOfDay(),
            day.plusDays(1).atStartOfDay());
    }

    @Override
    public PointItemDto getDaylyPointStatistics(BaseCurveQueryDto param) {
        return gisEmStatusMapper.getDaylyPointStatistics(param);
    }
}