package com.aucma.report.controller;

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.BoxTraceabilityDetailReport;
import com.aucma.report.domain.BoxTraceabilityReport;
import com.aucma.report.domain.InventoryRateReport;
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 AjaxResult productionExecutionReportList(@RequestParam(required = false) Map hashMap) {
        List<HashMap<String, Object>> list = productionReportService.productionExecutionReportList(hashMap);
        return success(list);
    }

    /**
     * 查询在制品查询报表
     */
    @GetMapping("/WIPInquiryReportList")
    public AjaxResult WIPInquiryReportList(@RequestParam(required = false) Map hashMap) {
        List<HashMap<String, Object>> list = productionReportService.WIPInquiryReportList(hashMap);
        return success(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, "发泡箱体追溯差异明细报表" );
    }

}
