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.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/StatisticQtProduct")
public class StatisticQtProductController extends BaseController {
    private String prefix = "nanjing/Statistic";
    @Autowired
    private ITBdProducttypeService producttypeService;

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

    /**
     * 查询时段统计
     */
    @RequiresPermissions("nanjing:QtProduct:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QtProduct qtProduct)
    {
//        startPage();
        Map map = new HashMap<String,Object>();
        map.put("beginTime",qtProduct.getBeginTime());
        map.put("endTime",qtProduct.getEndTime());
        map.put("productType",qtProduct.getProductType());
        map.put("productId","");
        map.put("shiftId","");
        map.put("groupId","");
        List<QtProduct> list = producttypeService.selectQtProductList(map);
        return getDataTable(list);
    }

    /**
     * 导出时段统计
     */
    @RequiresPermissions("nanjing:QtProduct:export")
    @Log(title = "时段统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QtProduct qtProduct)
    {
        Map map = new HashMap<String,Object>();
        map.put("beginTime",qtProduct.getBeginTime());
        map.put("endTime",qtProduct.getEndTime());
        map.put("productType",qtProduct.getProductType());
        map.put("productId","");
        map.put("shiftId","");
        map.put("groupId","");
        List<QtProduct> list = producttypeService.selectQtProductList(map);
        ExcelUtil<QtProduct> util = new ExcelUtil<QtProduct>(QtProduct.class);
        return util.exportExcel(list, "QtProduct");
    }


}
