package com.njcn.prepare.harmonic.service.mysql.Impl.line;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.event.pojo.po.RMpEventDetailM;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpEventDetailMMapper;
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailMService;
import com.njcn.prepare.harmonic.utils.PublicUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2022/12/28  14:58【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
@AllArgsConstructor
public class RMpEventDetailMServiceImpl extends MppServiceImpl<RMpEventDetailMMapper, RMpEventDetailM> implements RMpEventDetailMService{

        private final RMpEventDetailMMapper rMpEventDetailMMapper;

    /**
     * @param lineId
     * @param dataDate
     * @Description: queryOneQtrData  查询一季度Mouth表数据
     * @Param: [lineId, dataDate]
     * @return: java.util.List<com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpEventDetailDPO>
     * @Author: clam
     * @Date: 2022/12/28
     */
    @Override
    public List<RMpEventDetailM> queryOneQtrData(String lineId, String dataDate) {

        QueryWrapper<RMpEventDetailM> queryWrapper = new QueryWrapper<> ();
        queryWrapper.eq ("measurement_point_id", lineId).
                eq("QUARTER( data_date)", PublicUtil.getNowQuarter (dataDate));
        List<RMpEventDetailM> list = rMpEventDetailMMapper.selectList (queryWrapper);
        return list;
    }

    /**
     * @param lineId
     * @param dataDate
     * @Description: queryOneYearData  查询一年Mouth表数据
     * @Param: [lineId, dataDate]
     * @return: java.util.List<com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpEventDetailMPO>
     * @Author: clam
     * @Date: 2022/12/28
     */
    @Override
    public List<RMpEventDetailM> queryOneYearData(String lineId, String dataDate) {
        QueryWrapper<RMpEventDetailM> queryWrapper = new QueryWrapper<> ();
        queryWrapper.eq ("measurement_point_id", lineId).
                eq("YEAR( data_date )",dataDate.substring (0, 4));
        List<RMpEventDetailM> list = rMpEventDetailMMapper.selectList (queryWrapper);
        return list;
    }
}
