package com.ruoyi.project.production.controller;

import java.util.List;

import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
import com.ruoyi.project.production.controller.vo.MonthlyUpdateVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.production.domain.TMonthlyProductionReport;
import com.ruoyi.project.production.service.ITMonthlyProductionReportService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 每月生产报告Controller
 *
 * @author ruoyi
 * @date 2022-10-31
 */
@RestController
@RequestMapping("/production/monthly")
public class TMonthlyProductionReportController extends BaseController
{
    @Autowired
    private ITMonthlyProductionReportService tMonthlyProductionReportService;

    /**
     * 导出每月生产报告
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:export')")
    @Log(title = "每月生产报告", businessType = BusinessType.EXPORT)
    @GetMapping("/export/{year}")
    public AjaxResult export(@PathVariable("year") Long year)
    {
        return tMonthlyProductionReportService.export(year);
    }

    /**
     * 修改Cracker Raw Material
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/crackerRawMaterial")
    public AjaxResult updateCrackerRawMaterial(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateCrackerRawMaterial(monthlyUpdateVO));
    }

    /**
     * 修改Cracker Output Product
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/crackerOutputProduct")
    public AjaxResult updateCrackerOutputProduct(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateCrackerOutputProduct(monthlyUpdateVO));
    }

    /**
     * 修改Aromatics Raw Material
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/aAromaticsRawMaterial")
    public AjaxResult updateAromaticsRawMaterial(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateAromaticsRawMaterial(monthlyUpdateVO));
    }

    /**
     * 修改Aromatics Output Product
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/aromaticsOutputProduct")
    public AjaxResult updateAromaticsOutputProduct(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateAromaticsOutputProduct(monthlyUpdateVO));
    }

    /**
     * 修改Product Yield
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/productYield")
    public AjaxResult updateProductYield(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateProductYield(monthlyUpdateVO));
    }

    /**
     * 修改Cracker Energy Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/crackerEnergyConsumption")
    public AjaxResult updateCrackerEnergyConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateCrackerEnergyConsumption(monthlyUpdateVO));
    }

    /**
     * 修改Aromatics Energy Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/aromaticsEnergyConsumption")
    public AjaxResult updateAromaticsEnergyConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateAromaticsEnergyConsumption(monthlyUpdateVO));
    }

    /**
     * 修改Plant Load
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/plantLoad")
    public AjaxResult updatePlantLoad(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updatePlantLoad(monthlyUpdateVO));
    }

    /**
     * 修改Otherside
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/otherside")
    public AjaxResult updateOtherside(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateOtherside(monthlyUpdateVO));
    }

    /**
     * 修改SCTU Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/sctuUtilityConsumption")
    public AjaxResult updateSctuUtilityConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateSctuUtilityConsumption(monthlyUpdateVO));
    }

    /**
     * 修改Summary
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/summary")
    public AjaxResult updateSummary(@RequestBody MonthlyUpdateVO monthlyUpdateVO) {
        return toAjax(tMonthlyProductionReportService.updateSummary(monthlyUpdateVO));
    }

    /**
     * 修改SUB Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/subUtilityConsumption")
    public AjaxResult updateSUBUtilityConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateSUBUtilityConsumption(monthlyUpdateVO));
    }

    /**
     * 修改SCTF Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/sctfUtilityConsumption")
    public AjaxResult updateSctfUtilityConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateSctfUtilityConsumption(monthlyUpdateVO));
    }

    /**
     * 修改KBI
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/kbi")
    public AjaxResult updateKbi(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateKbi(monthlyUpdateVO));
    }

    /**
     * 修改Cost Fr Ethylene
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/costFrEthylene")
    public AjaxResult updateCostFrEthylene(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateCostFrEthylene(monthlyUpdateVO));
    }

    /**
     * 修改Chemical Consume
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/chemicalConsume")
    public AjaxResult updateChemicalConsume(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateChemicalConsume(monthlyUpdateVO));
    }

    /**
     * 修改Runing Rate
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/runingRate")
    public AjaxResult updateRuningRate(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateRuningRate(monthlyUpdateVO));
    }

    /**
     * 修改Shoudown Hour
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/shoudownHour")
    public AjaxResult updateShoudownHour(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateShoudownHour(monthlyUpdateVO));
    }

    /**
     * 修改Aromatics Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/aromaticsUtilityConsumption")
    public AjaxResult editAromaticsUtilityConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateAromaticsUtilityConsumption(monthlyUpdateVO));
    }

    /**
     * 修改Cracker Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/crackerUtilityConsumption")
    public AjaxResult editCrackerUtilityConsumption(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateCrackerUtilityConsumption(monthlyUpdateVO));
    }

    /**
     * 修改Eligible Product Rate
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @PutMapping(value = "/eligibleProductRate")
    public AjaxResult editEligibleProductRate(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
    {
        return toAjax(tMonthlyProductionReportService.updateEligibleProductRate(monthlyUpdateVO));
    }

    /**
     * 按年份查询Summary
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/summary/{year}")
    public AjaxResult getSummaryByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectSummaryByYear(year));
    }

    /**
     * 按年份查询KBI
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/kbi/{year}")
    public AjaxResult getKbiByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectKbiByYear(year));
    }

    /**
     * 按年份查询SCTF Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/SCTFUtilityConsumption/{year}")
    public AjaxResult getSCTFUtilityConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectSCTFUtilityConsumptionByYear(year));
    }

    /**
     * 按年份查询SUB Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/SUBUtilityConsumption/{year}")
    public AjaxResult getSUBUtilityConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectSUBUtilityConsumptionByYear(year));
    }

    /**
     * 按年份查询SCTU Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/SCTUUtilityConsumption/{year}")
    public AjaxResult getSCTUUtilityConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectSCTUUtilityConsumptionByYear(year));
    }

    /**
     * 按年份查询Chemical Consume
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/chemicalConsume/{year}")
    public AjaxResult getChemicalConsumeByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectChemicalConsumeByYear(year));
    }

    /**
     * 按年份查询Otherside
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/otherside/{year}")
    public AjaxResult getOthersideByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectOthersideByYear(year));
    }

    /**
     * 按年份查询Shoudown Hour
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/shoudownHour/{year}")
    public AjaxResult getShoudownHourByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectShoudownHourByYear(year));
    }

    /**
     * 按年份查询Runing Rate
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/runingRate/{year}")
    public AjaxResult getRuningRateByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectRuningRateByYear(year));
    }

    /**
     * 按年份查询Cost Fr Ethylene
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/costFrEthylene/{year}")
    public AjaxResult getCostFrEthyleneByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectCostFrEthyleneByYear(year));
    }

    /**
     * 按年份查询Plant Load
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/plantLoad/{year}")
    public AjaxResult getPlantLoadByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectPlantLoadByYear(year));
    }

    /**
     * 按年份查询Aromatics Energy Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/aromaticsEnergyConsumption/{year}")
    public AjaxResult getAromaticsEnergyConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectAromaticsEnergyConsumptionByYear(year));
    }

    /**
     * 按年份查询Aromatics Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/aromaticsUtilityConsumption/{year}")
    public AjaxResult getAromaticsUtilityConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectAromaticsUtilityConsumptionByYear(year));
    }

    /**
     * 按年份查询Cracker Energy Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/crackerEnergyConsumption/{year}")
    public AjaxResult getCrackerEnergyConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectCrackerEnergyConsumptionByYear(year));
    }

    /**
     * 按年份查询Cracker Utility Consumption
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/crackerUtilityConsumption/{year}")
    public AjaxResult getCrackerUtilityConsumptionByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectCrackerUtilityConsumptionByYear(year));
    }

    /**
     * 按年份查询Product Yield
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/productYield/{year}")
    public AjaxResult getProductYieldByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectProductYieldByYear(year));
    }

    /**
     * 按年份查询Eligible Product Rate
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/eligibleProductRate/{year}")
    public AjaxResult getEligibleProductRateByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectEligibleProductRateByYear(year));
    }

    /**
     * 按年份查询Aromatics Output Product
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/aromaticsOutputProduct/{year}")
    public AjaxResult getAromaticsOutputProductByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectAromaticsOutputProductByYear(year));
    }

    /**
     * 按年份查询Aromatics Raw Material
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/aromaticsRawMaterial/{year}")
    public AjaxResult getAromaticsRawMaterialByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectAromaticsRawMaterialByYear(year));
    }

    /**
     * 按年份查询Cracker Output Product
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/crackerOutputProduct/{year}")
    public AjaxResult getCrackerOutputProductByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectCrackerOutputProductByYear(year));
    }

    /**
     * 按年份查询Cracker Raw Material
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/crackerRawMaterial/{year}")
    public AjaxResult getCrackerRawMaterialByYear(@PathVariable("year") Long year)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectCrackerRawMaterialByYear(year));
    }

    /**
     * 查询月报趋势数据
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:list')")
    @GetMapping("/analysis")
    public AjaxResult getAnalysisData(MonthlyAnalysisQueryVO monthlyAnalysisQueryVO)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectAnalysisData(monthlyAnalysisQueryVO));
    }

    /**
     * 查询每月生产报告列表
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMonthlyProductionReport tMonthlyProductionReport)
    {
        startPage();
        List<TMonthlyProductionReport> list = tMonthlyProductionReportService.selectTMonthlyProductionReportList(tMonthlyProductionReport);
        return getDataTable(list);
    }

    /**
     * 导出每月生产报告列表
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:export')")
    @Log(title = "每月生产报告", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMonthlyProductionReport tMonthlyProductionReport)
    {
        List<TMonthlyProductionReport> list = tMonthlyProductionReportService.selectTMonthlyProductionReportList(tMonthlyProductionReport);
        ExcelUtil<TMonthlyProductionReport> util = new ExcelUtil<TMonthlyProductionReport>(TMonthlyProductionReport.class);
        return util.exportExcel(list, "monthly");
    }

    /**
     * 获取每月生产报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMonthlyProductionReportService.selectTMonthlyProductionReportById(id));
    }

    /**
     * 新增每月生产报告
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:add')")
    @Log(title = "每月生产报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMonthlyProductionReport tMonthlyProductionReport)
    {
        return toAjax(tMonthlyProductionReportService.insertTMonthlyProductionReport(tMonthlyProductionReport));
    }

    /**
     * 修改每月生产报告
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
    @Log(title = "每月生产报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMonthlyProductionReport tMonthlyProductionReport)
    {
        return toAjax(tMonthlyProductionReportService.updateTMonthlyProductionReport(tMonthlyProductionReport));
    }

    /**
     * 删除每月生产报告
     */
    @PreAuthorize("@ss.hasPermi('production:monthly:remove')")
    @Log(title = "每月生产报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMonthlyProductionReportService.deleteTMonthlyProductionReportByIds(ids));
    }
}
