package cn.gyee.tamplate.controller.analysis;

import cn.gyee.tamplate.model.operation.Operation;
import cn.gyee.tamplate.model.vo.AnalsisUpdateVo;
import cn.gyee.tamplate.model.vo.AnalysisMainVo;
import cn.gyee.tamplate.model.vo.BdzVo;
import cn.gyee.tamplate.service.analysis.AnalysisService;
import cn.gyee.tamplate.util.common.StringUtils;
import io.swagger.models.auth.In;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName : AnalysisController
 * @Author : xieshengjie
 * @Date: 2021/3/8 12:11
 * @Description : 统计分析controller
 */
@RestController
@RequestMapping("//analysis")
public class AnalysisController {
    @Resource
    private AnalysisService analysisService;

    /**
     * 首页list
     * @param beginDate
     * @param endDate
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public List<AnalysisMainVo> list(
                                    @RequestParam(value = "beginDate",required = true)String beginDate,
                                    @RequestParam(value = "endDate",required = true)String endDate){
        List<AnalysisMainVo> resultList = analysisService.analysismainlist(beginDate,endDate);
        return resultList;
    }

    /**
     * 表底查询
     * @param theday
     * @param wpid
     * @return
     * @throws Exception
     */
    @GetMapping("/bczlist")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public List<Object>  bczlist(
            @RequestParam(value = "theday",required = true)String theday,
            @RequestParam(value = "wpid",required = true)String wpid) throws Exception {
        List<Object> bdzlist = analysisService.bdzlist(theday, wpid);
        return bdzlist;
    }

    /**
     * 表底值修改
     * @param bdzVo
     */
    @PostMapping("/bczupdate")
    @CrossOrigin(origins = "*", maxAge = 3600)
    public void   bczupdate(@RequestBody List<BdzVo> bdzVo) {
        if (StringUtils.isNotEmpty(bdzVo))
            analysisService.updateBdz(bdzVo);
    }


    @GetMapping("/tjfxlist")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public List<Object>  tjfxlist(
            @RequestParam(value = "theday",required = true)String theday,
            @RequestParam(value = "wpid",required = true)String wpid,
            @RequestParam(value = "identity",required = true) Integer identity) {
        List<Object> tjfxlist = analysisService.tjfxlist(theday, wpid, identity);
        return tjfxlist;
    }


    /**
     * 统计分析修改
     * @param vos
     */
    @PostMapping("/tjfxupdate")
    @CrossOrigin(origins = "*", maxAge = 3600)
    public void   tjfxupdate(@RequestBody List<AnalsisUpdateVo> vos) {
        if (StringUtils.isNotEmpty(vos))
            analysisService.updateTjfx(vos);
    }
}
