package com.aucma.report.controller;

import com.aucma.common.annotation.Excel;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;

import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.report.domain.*;
import com.aucma.report.service.IProductionReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 生产报表Controller
 *
 * @author Yinq
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/report/productionReport")
public class ProductionReportController extends BaseController {
    @Autowired
    private IProductionReportService productionReportService;

    /**
     * 查询清单率报表
     */
    @GetMapping("/inventoryRateReportList")
    public TableDataInfo inventoryRateReportList(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<InventoryRateReport> list = productionReportService.inventoryRateReportList(hashMap);
        return getDataTable(list);
    }

    /**
     * 查询清单率报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/inventoryRateReportList/export")
    public void inventoryRateReportListExport(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        List<InventoryRateReport> list = productionReportService.inventoryRateReportList(hashMap);
        ExcelUtil<InventoryRateReport> util = new ExcelUtil<>(InventoryRateReport. class);
        util.exportExcel(response, list, "清单率报表" );
    }

    /**
     * 查询生产执行报表
     */
    @GetMapping("/productionExecutionReportList")
    public TableDataInfo productionExecutionReportList(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<ProductionExecutionReport> list = productionReportService.productionExecutionReportList(hashMap);
        return getDataTable(list);
    }

    /**
     * 查询生产执行报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/productionExecutionReportList/export")
    public void productionExecutionReportListExport(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<ProductionExecutionReport> list = productionReportService.productionExecutionReportList(hashMap);
        ExcelUtil<ProductionExecutionReport> util = new ExcelUtil<>(ProductionExecutionReport. class);
        util.exportExcel(response, list, "查询生产执行报表" );
    }

    /**
     * 查询在制品查询报表
     */
    @GetMapping("/WIPInquiryReportList")
    public TableDataInfo WIPInquiryReportList(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<WIPInquiryReport> list = productionReportService.WIPInquiryReportList(hashMap);
        return getDataTable(list);
    }

    /**
     * 在制品查询报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/WIPInquiryReportList/export")
    public void WIPInquiryReportListExport(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<WIPInquiryReport> list = productionReportService.WIPInquiryReportList(hashMap);
        ExcelUtil<WIPInquiryReport> util = new ExcelUtil<>(WIPInquiryReport. class);
        util.exportExcel(response, list, "清单率报表" );
    }

    /**
     * 查询在制品查询明细
     */
    @GetMapping("/WIPInquiryDetailReportList")
    public TableDataInfo WIPInquiryDetailReportList(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<WIPInquiryDetailReport> list = productionReportService.WIPInquiryDetailReportList(hashMap);
        return getDataTable(list);
    }

    /**
     * 在制品查询明细导出
     * @param hashMap
     * @return
     */
    @PostMapping("/WIPInquiryDetailReportList/export")
    public void WIPInquiryDetailReportListExport(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<WIPInquiryDetailReport> list = productionReportService.WIPInquiryDetailReportList(hashMap);
        ExcelUtil<WIPInquiryDetailReport> util = new ExcelUtil<>(WIPInquiryDetailReport. class);
        util.exportExcel(response, list, "在制品查询明细" );
    }

    /**
     * 扫描下线记录报表
     */
    @GetMapping("/ScanOfflineRecordReportList")
    public AjaxResult ScanOfflineRecordReportList(@RequestParam(required = false) Map hashMap) {
        List<HashMap<String, Object>> list = productionReportService.ScanOfflineRecordReportList(hashMap);
        return success(list);
    }


    /**
     * 发泡箱体追溯报表
     * @param hashMap
     * @return
     */
    @GetMapping("/boxTraceabilityReport")
    public TableDataInfo boxTraceabilityReport(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<BoxTraceabilityReport> list = productionReportService.boxTraceabilityReport(hashMap);
        return getDataTable(list);
    }

    /**
     * 发泡箱体追溯详情报表
     * @param hashMap
     * @return
     */
    @GetMapping("/boxTraceabilityDetailReport")
    public TableDataInfo boxTraceabilityDetailReport(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<BoxTraceabilityDetailReport> list = productionReportService.boxTraceabilityDetailReport(hashMap);
        return getDataTable(list);
    }

    /**
     * 发泡箱体追溯报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/boxTraceabilityReport/export")
    public void boxTraceabilityReportExport(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<BoxTraceabilityReport> list = productionReportService.boxTraceabilityReport(hashMap);
        ExcelUtil<BoxTraceabilityReport> util = new ExcelUtil<>(BoxTraceabilityReport. class);
        util.exportExcel(response, list, "发泡箱体追溯报表" );
    }

    /**
     * 发泡箱体追溯明细报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/boxTraceabilityDetailReport/export")
    public void boxTraceabilityDetailReport(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<BoxTraceabilityDetailReport> list = productionReportService.boxTraceabilityDetailReport(hashMap);
        ExcelUtil<BoxTraceabilityDetailReport> util = new ExcelUtil<>(BoxTraceabilityDetailReport. class);
        util.exportExcel(response, list, "发泡箱体追溯差异明细报表" );
    }

    /**
     * 箱体流转追溯报表
     * @param hashMap
     * @return
     */
    @GetMapping("/boxTurnoverTraceabilityReportList")
    public TableDataInfo boxTurnoverTraceabilityReportList(@RequestParam(required = false) Map hashMap) {
        startPage();
        List<BoxTurnoverTraceabilityReport> list = productionReportService.boxTurnoverTraceabilityReportList(hashMap);
        return getDataTable(list);
    }

    /**
     * 箱体流转追溯报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/boxTurnoverTraceabilityReportList/export")
    public void boxTurnoverTraceabilityReportList(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<BoxTurnoverTraceabilityReport> list = productionReportService.boxTurnoverTraceabilityReportList(hashMap);
        ExcelUtil<BoxTurnoverTraceabilityReport> util = new ExcelUtil<>(BoxTurnoverTraceabilityReport. class);
        util.exportExcel(response, list, "箱体流转追溯报表" );
    }

    /**
     * 箱体流转追溯详情报表
     * @param hashMap
     * @return
     */
    @GetMapping("/boxTurnoverTraceabilityDetailReportList")
    public AjaxResult boxTurnoverTraceabilityDetailReportList(@RequestParam(required = false) Map hashMap) {
        List<BoxTurnoverTraceabilityDetailReport> list = productionReportService.boxTurnoverTraceabilityDetailReportList(hashMap);
        return success(list);
    }

    /**
     * 箱体流转追溯详情报表导出
     * @param hashMap
     * @return
     */
    @PostMapping("/boxTurnoverTraceabilityDetailReportList/export")
    public void boxTurnoverTraceabilityDetailReportList(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<BoxTurnoverTraceabilityDetailReport> list = productionReportService.boxTurnoverTraceabilityDetailReportList(hashMap);
        ExcelUtil<BoxTurnoverTraceabilityDetailReport> util = new ExcelUtil<>(BoxTurnoverTraceabilityDetailReport. class);
        util.exportExcel(response, list, "箱体流转追溯详情报表" );
    }
    /**
     * 壳胆绑定报表
     * */
    @GetMapping("/codeBandingReportList")
    public TableDataInfo codeBandingReportList(@RequestParam(required = false) Map hashMap){
        startPage();
        List<codeBanding> list = productionReportService.codeBandingReportList(hashMap);
        return getDataTable(list);
    }
    /**
     * 壳胆绑定报表导出
     * */
    @PostMapping("/codeBandingReportList/export")
    public void codeBandingReportListExport(HttpServletResponse response,@RequestParam(required = false) Map hashMap){
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<codeBanding> list = productionReportService.codeBandingReportList(hashMap);
        ExcelUtil<codeBanding> util = new ExcelUtil<>(codeBanding.class);
        util.exportExcel(response,list,"壳胆绑定报表");
    }
    /**
     * 过点数报表
     * */
    @GetMapping("/materialReportList")
    public TableDataInfo materialReportList(@RequestParam(required = false) Map hashMap){
        startPage();
        List<MaterialReport> list = productionReportService.materialReportList(hashMap);
        return getDataTable(list);
    }
    /**
     * 查询过点数报表导出
     * */
    @PostMapping("/materialReportList/export")
    public void materialReportListExport(HttpServletResponse response,@RequestParam(required = false) Map hashMap){
        hashMap.put("pageNum",null);
        hashMap.put("pageSize",null);
        List<MaterialReport> list = productionReportService.materialReportList(hashMap);
        ExcelUtil<MaterialReport> util = new ExcelUtil<>(MaterialReport.class);
        util.exportExcel(response,list,"物料报表");
    }

}


