package com.ruoyi.web.controller.nanjing;

import java.util.*;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.nanjing.domain.ProRpList;
import com.ruoyi.nanjing.domain.TBdProductinfo;
import com.ruoyi.nanjing.service.ITBdProductinfoService;
import com.ruoyi.nanjing.service.ITBdProducttypeService;
import com.ruoyi.nanjing.service.ITSyTracestateService;
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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nanjing.domain.TRpProductchangeinfo;
import com.ruoyi.nanjing.service.ITRpProductchangeinfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletRequest;

/**
 * 时段统计
 *
 * @author limy
 * @date 2021-02-2
 */
@Controller
@RequestMapping("/nanjing/selectProRpList")
public class SelectProRpListController extends BaseController
{
    private String prefix = "nanjing/ProRpList";

    @Autowired
    private ITBdProductinfoService tBdProductinfoService;
    @Autowired
    private ITBdProducttypeService itBdProducttypeService;

    @RequiresPermissions("nanjing:ProRpList:view")
    @GetMapping()
    public String ProRpList(ModelMap map)
    {
        List<TBdProductinfo> tBdProductinfoList = tBdProductinfoService.selectTBdProductinfoList(new TBdProductinfo());
        map.addAttribute("list",tBdProductinfoList);
        return prefix + "/SelectProRpList";
    }

    /**
     * 查询时段统计
     */
    @RequiresPermissions("nanjing:ProRpList:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProRpList proRpList)
    {
//        startPage();
        Map map = new HashMap<String,Object>();
        map.put("beginTime",proRpList.getBeginTime());
        map.put("endTime",proRpList.getEndTime());
        map.put("productId",proRpList.getProductID());
        map.put("productType",proRpList.getProductType());
        map.put("state",proRpList.getState());
        map.put("semiBarcode",proRpList.getSemiBarcode());
        List<ProRpList> list = null;
        return getDataTable(list);
    }

    @PostMapping("/getData")
    @ResponseBody
    public TableDataInfo getData(ProRpList proRpList)
    {
//        startPage();
        List<ProRpList> list = new ArrayList<ProRpList>();
        if(proRpList.getBeginTime()==null||proRpList.getEndTime()==null)
        {
            return getDataTable(list);
        }
        Map map = new HashMap<String,Object>();
        map.put("beginTime",proRpList.getBeginTime());
        map.put("endTime",proRpList.getEndTime());
        map.put("productId",proRpList.getProductID());
        map.put("productType",proRpList.getProductType());
        map.put("state",proRpList.getState());
        map.put("semiBarcode",proRpList.getSemiBarcode());
        list = itBdProducttypeService.selectProLists(map);
        return getDataTable(list);
    }
    /**
     * 导出时段统计
     */
    @RequiresPermissions("nanjing:ProRpList:export")
    @Log(title = "时段统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProRpList proRpList)
    {
        Map map = new HashMap<String,Object>();
        map.put("beginTime",proRpList.getBeginTime());
        map.put("endTime",proRpList.getEndTime());
        map.put("productId",proRpList.getProductID());
        map.put("productType",proRpList.getProductType());
        map.put("state",proRpList.getState());
        map.put("semiBarcode",proRpList.getSemiBarcode());
        List<ProRpList> list = itBdProducttypeService.selectProLists(map);
        ExcelUtil<ProRpList> util = new ExcelUtil<ProRpList>(ProRpList.class);
        return util.exportExcel(list, "ProRpList");
    }

}
