package com.ruoyi.project.production.mapper;

import java.util.List;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
import com.ruoyi.project.production.domain.TMonthlyProductionReport;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 每月生产报告Mapper接口
 * 
 * @author ruoyi
 * @date 2022-10-31
 */
public interface TMonthlyProductionReportMapper 
{
    /**
     * 查询每月生产报告
     * 
     * @param id 每月生产报告ID
     * @return 每月生产报告
     */
    public TMonthlyProductionReport selectTMonthlyProductionReportById(Long id);

    /**
     * 查询每月生产报告列表
     * 
     * @param tMonthlyProductionReport 每月生产报告
     * @return 每月生产报告集合
     */
    @DataScope(deptAlias = "d")
    public List<TMonthlyProductionReport> selectTMonthlyProductionReportList(TMonthlyProductionReport tMonthlyProductionReport);

    /**
     * 新增每月生产报告
     * 
     * @param tMonthlyProductionReport 每月生产报告
     * @return 结果
     */
    public int insertTMonthlyProductionReport(TMonthlyProductionReport tMonthlyProductionReport);

    /**
     * 修改每月生产报告
     * 
     * @param tMonthlyProductionReport 每月生产报告
     * @return 结果
     */
    public int updateTMonthlyProductionReport(TMonthlyProductionReport tMonthlyProductionReport);

    /**
     * 删除每月生产报告
     * 
     * @param id 每月生产报告ID
     * @return 结果
     */
    public int deleteTMonthlyProductionReportById(Long id);

    /**
     * 批量删除每月生产报告
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteTMonthlyProductionReportByIds(Long[] ids);


    /**
     * 按年份查询Cracker Raw Material
     */
    public List<TMonthlyProductionReport> selectCrackerRawMaterialByYear(Long year);

    /**
     * 按年份查询Cracker Output Product
     */
    public List<TMonthlyProductionReport> selectCrackerOutputProductByYear(Long year);

    /**
     * 按年份查询Aromatics RawM aterial
     */
    public List<TMonthlyProductionReport> selectAromaticsRawMaterialByYear(Long year);

    /**
     * 按年份查询Aromatics Output Product
     */
    public List<TMonthlyProductionReport> selectAromaticsOutputProductByYear(Long year);

    /**
     * 按年份查询Eligible Product Rate
     */
    public List<TMonthlyProductionReport> selectEligibleProductRateByYear(Long year);

    /**
     * 按年份查询Product Yield
     */
    public List<TMonthlyProductionReport> selectProductYieldByYear(Long year);

    /**
     * 按年份查询Cracker Utility Consumption
     */
    public List<TMonthlyProductionReport> selectCrackerUtilityConsumptionByYear(Long year);

    /**
     * 按年份查询Cracker Energy Consumption
     */
    public List<TMonthlyProductionReport> selectCrackerEnergyConsumptionByYear(Long year);

    /**
     * 按年份查询Aromatics Utility Consumption
     */
    public List<TMonthlyProductionReport> selectAromaticsUtilityConsumptionByYear(Long year);

    /**
     * 按年份查询Aromatics Energy Consumption
     */
    public List<TMonthlyProductionReport> selectAromaticsEnergyConsumptionByYear(Long year);

    /**
     * 按年份查询Plant Load
     */
    public List<TMonthlyProductionReport> selectPlantLoadByYear(Long year);

    /**
     * 按年份查询Cost Fr Ethylene
     */
    public List<TMonthlyProductionReport> selectCostFrEthyleneByYear(Long year);

    /**
     * 按年份查询Runing Rate
     */
    public List<TMonthlyProductionReport> selectRuningRateByYear(Long year);

    /**
     * 按年份查询ShoudownHour
     */
    public List<TMonthlyProductionReport> selectShoudownHourByYear(Long year);

    /**
     * 按年份查询Otherside
     */
    public List<TMonthlyProductionReport> selectOthersideByYear(Long year);

    /**
     * 按年份查询Chemical Consume
     */
    public List<TMonthlyProductionReport> selectChemicalConsumeByYear(Long year);

    /**
     * 按年份查询SCTU Utility Consumption
     */
    public List<TMonthlyProductionReport> selectSCTUUtilityConsumptionByYear(Long year);

    /**
     * 按年份查询SUB Utility Consumption
     */
    public List<TMonthlyProductionReport> selectSUBUtilityConsumptionByYear(Long year);

    /**
     * 按年份查询SCTF Utility Consumption
     */
    public List<TMonthlyProductionReport> selectSCTFUtilityConsumptionByYear(Long year);

    /**
     * 按年份查询KBI
     */
    public List<TMonthlyProductionReport> selectKbiByYear(Long year);

    /**
     * 按年份查询Summary
     */
    public List<TMonthlyProductionReport> selectSummaryByYear(Long year);

    /**
     * 查询趋势分析数据
     * fromYear==toYear
     *
     * @param item      指标
     * @param fromYear  开始年份
     * @param fromMonth 开始月份
     * @param toYear    截止年份
     * @param toMonth   截止月份
     * @return  item从开始日期至结束日期的数据集合
     */
    @Select(" select d.${item} as valueData, concat(concat(d.REPORT_YEAR, '-'), d.REPORT_MONTH) as dateData, " +
            " d.REPORT_MONTH, d.REPORT_YEAR from t_monthly_production_report d " +
            " where (d.REPORT_YEAR = ${fromYear} and d.REPORT_MONTH >= ${fromMonth}) " +
            " and (d.REPORT_YEAR = ${toYear} and d.REPORT_MONTH <= ${toMonth}) " +
            " ORDER by d.REPORT_YEAR, d.REPORT_MONTH ")
    public List<MonthlyAnalysisDataVO> selectAnalysisDataSameYear(
            @Param("item") String item,
            @Param("fromYear") int fromYear,
            @Param("fromMonth") int fromMonth,
            @Param("toYear") int toYear,
            @Param("toMonth") int toMonth
    );

    /**
     * 查询趋势分析数据
     * fromYear!=toYear
     *
     * @param item      指标
     * @param fromYear  开始年份
     * @param fromMonth 开始月份
     * @param toYear    截止年份
     * @param toMonth   截止月份
     * @return  item从开始日期至结束日期的数据集合
     */
    @Select(" select d.${item} as valueData, concat(concat(d.REPORT_YEAR, '-'), d.REPORT_MONTH) as dateData, " +
            " d.REPORT_MONTH, d.REPORT_YEAR from t_monthly_production_report d " +
            " where (d.REPORT_YEAR = ${fromYear} and d.REPORT_MONTH >= ${fromMonth}) " +
            " or (d.REPORT_YEAR = ${toYear} and d.REPORT_MONTH <= ${toMonth}) " +
            " ORDER by d.REPORT_YEAR, d.REPORT_MONTH ")
    public List<MonthlyAnalysisDataVO> selectAnalysisDataDiffYear(
            @Param("item") String item,
            @Param("fromYear") int fromYear,
            @Param("fromMonth") int fromMonth,
            @Param("toYear") int toYear,
            @Param("toMonth") int toMonth
    );

    /**
     * 查询月报记录是否已存在
     * 返回结果==0表示不存在，>=0表示已存在
     *
     * @param reportYear    报告年份
     * @param reportMonth   报告月份
     * @return
     */
    public int selectTMonthlyProductionReportCountByDate(
            @Param("reportYear")int reportYear,
            @Param("reportMonth")int reportMonth
    );

    /**
     * 查询月报
     *
     * @param reportYear    报告年份
     * @param reportMonth   报告月份
     * @return
     */
    public TMonthlyProductionReport selectTMonthlyProductionReportByDate(
            @Param("reportYear")int reportYear,
            @Param("reportMonth")int reportMonth
    );

}
