package com.ruoyi.web.controller.nanjing;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.nanjing.domain.QsStation;
import com.ruoyi.nanjing.domain.ReportData;
import com.ruoyi.nanjing.domain.TBdProductinfo;
import com.ruoyi.nanjing.service.ITBdProductinfoService;
import com.ruoyi.nanjing.service.ITBdProducttypeService;
import com.ruoyi.system.domain.SysDept;
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 javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/nanjing/StatisticStation")
public class StatisticStProductController extends BaseController {

    private String prefix = "nanjing/Statistic";
    @Autowired
    private ITBdProducttypeService producttypeService;

    @Autowired
    private ITBdProductinfoService productinfoService;
    @RequiresPermissions("nanjing:stationStatistic:view")
    @GetMapping()
    public String stationProduct(ModelMap map)
    {
        List<TBdProductinfo> tBdProductinfoList = productinfoService.selectTBdProductinfoList(new TBdProductinfo());
        map.addAttribute("list",tBdProductinfoList);
        return prefix + "/QsStation";
    }

    @RequiresPermissions("nanjing:stationStatistic:list")
    @PostMapping("/list")
    @ResponseBody
    public List<QsStation> list(QsStation qsStation)
    {
        List<QsStation> qsProducts = producttypeService.selectStationQs(qsStation);
        return qsProducts;
    }

    @PostMapping("/listAll")
    @ResponseBody
    public List<QsStation> listAll(String begin,String end)
    {
        Map map = new HashMap<String,Object>();
        map.put("begin",begin);
        map.put("end",end);
        map.put("productId","");
        map.put("productType","");
        List<QsStation> qsStations = producttypeService.selectAllQs(map);
        return qsStations;
    }

    @PostMapping("/nodeClick")
    @ResponseBody
    public List<QsStation> nodeClick(String begin,String end,String node)
    {
        Map map = new HashMap<String,Object>();
        map.put("begin",begin);
        map.put("end",end);
        map.put("stationId",node);
        map.put("stationType",1);
        map.put("productId","ALL");
        List<QsStation> qsStations = producttypeService.selectNodeQs(map);
        return qsStations;
    }
}
