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.ProRpList;
import com.ruoyi.nanjing.domain.QsProduct;
import com.ruoyi.nanjing.domain.QtProduct;
import com.ruoyi.nanjing.domain.TBdProductinfo;
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.ui.ModelMap;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/nanjing/StatisticQsProduct")
public class StatisticQsProductController extends BaseController {
    private String prefix = "nanjing/Statistic";
    @Autowired
    private ITBdProducttypeService producttypeService;

    @RequiresPermissions("nanjing:QsProduct:view")
    @GetMapping()
    public String QsProduct()
    {
        return prefix + "/QsProduct";
    }


    /**
     * 整机合格率统计
     */
    @RequiresPermissions("nanjing:QsProduct:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(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.selectQ1ProductList(map);
        return getDataTable(list);
    }

    /**
     * 整机合格率统计
     */
    @RequiresPermissions("nanjing:QsProduct:export")
    @Log(title = "时段统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(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.selectQsProductList(map);
        ExcelUtil<QsProduct> util = new ExcelUtil<QsProduct>(QsProduct.class);
        return util.exportExcel(list, "QsProduct");
    }



}
