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.GisLoacurrentdWaveformDto;
import com.huatek.busi.dto.curve.BaseCurveQueryDto;
import com.huatek.busi.dto.curve.PointItemDto;
import com.huatek.busi.entity.GisLoacurrentdWaveform;
import com.huatek.busi.mapper.GisLoacurrentdWaveformMapper;
import com.huatek.busi.service.gis.GisLoacurrentdWaveformService;
import com.huatek.busi.service.impl.cac.AbstractCacEtlService;
import com.huatek.busi.vo.GisLoacurrentdWaveformVo;
import com.huatek.busi.vo.curve.PointItemVo;

/**
 * 断路器/GIS——负荷电流波形：024003 ServiceImpl
 *
 * @author anker_cheng
 * @date Jun 26, 2019 1:11:48 PM
 */
@Component
@Service(interfaceClass = GisLoacurrentdWaveformService.class)
@Transactional(rollbackFor = Exception.class)
public class GisLoacurrentdWaveformServiceImpl extends AbstractCacEtlService<GisLoacurrentdWaveform>
        implements GisLoacurrentdWaveformService {

    @Autowired
    private GisLoacurrentdWaveformMapper gisLoacurrentdWaveformMapper;

    @Override
    public Page<GisLoacurrentdWaveformVo> findGisLoacurrentdWaveformPage(
            GisLoacurrentdWaveformDto gisLoacurrentdWaveformDto) {
        if (gisLoacurrentdWaveformDto.getPage() != null && gisLoacurrentdWaveformDto.getLimit() != null) {
            PageHelper.startPage(gisLoacurrentdWaveformDto.getPage(), gisLoacurrentdWaveformDto.getLimit());
        }
        Page<GisLoacurrentdWaveformVo> gisLoacurrentdWaveforms = gisLoacurrentdWaveformMapper
                .selectGisLoacurrentdWaveformPage(gisLoacurrentdWaveformDto);
        return gisLoacurrentdWaveforms;
    }

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

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

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