package com.ruoyi.web.controller.nanjing;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.nanjing.domain.QsProduct;
import com.ruoyi.nanjing.service.ITBdProducttypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/nanjing/StatisticQ1Product")
public class StatisticQ1ProductController extends BaseController {
    private String prefix = "nanjing/Statistic";
    @Autowired
    private ITBdProducttypeService producttypeService;
    @RequiresPermissions("nanjing:Q1Product:view")
    @GetMapping()
    public String Q1Product()
    {
        return prefix + "/Q1Product";
    }


    /**
     * 一次合格率统计
     */
    @RequiresPermissions("nanjing:Q1Product:list")
    @PostMapping("/Q1list")
    @ResponseBody
    public TableDataInfo Q1list(QsProduct qsProduct)
    {
//        startPage();
        Map map = new HashMap<String,Object>();
        map.put("beginTime",qsProduct.getBeginTime());
        map.put("endTime",qsProduct.getEndTime());
        map.put("productType",qsProduct.getProductType());
        map.put("productId","");
        List<QsProduct> list = producttypeService.selectQsProductList(map);
        return getDataTable(list);
    }

    /**
     * 一次合格率统计
     */
    @RequiresPermissions("nanjing:Q1Product:export")
    @Log(title = "时段统计", businessType = BusinessType.EXPORT)
    @PostMapping("/Q1export")
    @ResponseBody
    public AjaxResult Q1export(QsProduct qsProduct)
    {
        Map map = new HashMap<String,Object>();
        map.put("beginTime",qsProduct.getBeginTime());
        map.put("endTime",qsProduct.getEndTime());
        map.put("productType",qsProduct.getProductType());
        map.put("productId","");
        List<QsProduct> list = producttypeService.selectQ1ProductList(map);
        ExcelUtil<QsProduct> util = new ExcelUtil<QsProduct>(QsProduct.class);
        return util.exportExcel(list, "QsProduct");
    }

}
