package com.dsk.web.controller.search.controller;

import com.alibaba.fastjson2.JSONObject;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.searchService.MarketAnalysisService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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


/**
 * 央企市场分析-统计
 * @author Administrator
 *
 */
@RequestMapping("/marketAnalysis")
@RestController
public class MarketAnalysisController extends BaseController {


    @Resource
    MarketAnalysisService marketAnalysisService;

    /*
     * 各省份备案企业数量
     */
    @RequestMapping("/areaGroupByProvince")
    public AjaxResult areaGroupByProvince() {

        return marketAnalysisService.areaGroupByProvince();
    }

    /*
     * 资质等级按照行业、等级类型分组
     */
    @RequestMapping("/certGroupByMajorAndLevel")
    public AjaxResult certGroupByMajorAndLevel() {

        return marketAnalysisService.certGroupByMajorAndLevel();
    }


    /*
     * 资质等级按照大类、省份、等级类型分组
     */
    @RequestMapping("/certGroupByMajorProvinceLevel")
    public AjaxResult certGroupByMajorProvinceLevel() {
        return marketAnalysisService.certGroupByMajorProvinceLevel();
    }



    /*
     * 产业结构-按年份选择  各个项目类型项目总数
     */
    @RequestMapping("/bidGroupCountByProjectType")
    public AjaxResult bidGroupCountByProjectType(@RequestBody JSONObject object) {
        return marketAnalysisService.bidGroupCountByProjectType(object);
    }
    /*
     * 产业结构-近两年各个项目类型项目总数及金额占比
     */
    @RequestMapping("/bidMoneyGroupByProjectType")
    public AjaxResult bidMoneyGroupByProjectType(@RequestBody JSONObject object) {
        return marketAnalysisService.bidMoneyGroupByProjectType(object);
    }

    /*
     * 全国各地区中标统计TOP10
     */
    @RequestMapping("/countBidGroupByProvince")
    public AjaxResult countBidGroupByProvince(@RequestBody JSONObject object) {
        return marketAnalysisService.countBidGroupByProvince(object);
    }


    //央企数字化经营系统     土地交易
    @RequestMapping("/countLandMarketByType")
    public AjaxResult countLandMarketByType(@RequestBody JSONObject object){
        return marketAnalysisService.countLandMarketByType(object);
    }

    //央企数字化经营系统     全国土地交易项目地区
    @RequestMapping("/countLandMarketByProvince")
    public AjaxResult countLandMarketByProvince(@RequestBody JSONObject object){
        return marketAnalysisService.countLandMarketByProvince(object);
    }

    //央企数字化经营系统     全国土地交易项目地区
    @RequestMapping("/countLandMarketByYear")
    public AjaxResult countLandMarketByYear(){
        return marketAnalysisService.countLandMarketByYear();
    }

    //央企数字化经营系统     全国公招项目统计
    @RequestMapping("/countNewsBidByYear")
    public AjaxResult countNewsBidByYear(){
        return marketAnalysisService.countNewsBidByYear();
    }

    //央企数字化经营系统     招标公告  全国各地区项目统计TOP10
    @RequestMapping("/countNewsBidByProvince")
    public AjaxResult countNewsBidByProvince(@RequestBody JSONObject object){
        return marketAnalysisService.countNewsBidByProvince(object);
    }

    //央企数字化经营系统     招标公告  月度统计
    @RequestMapping("/countNewsBidByMonth")
    public AjaxResult countNewsBidByMonth(@RequestBody JSONObject object){
        return marketAnalysisService.countNewsBidByMonth(object);
    }

    /*
     * 招标数量按省份分组
     */
    @RequestMapping("/countGroupByProvince")
    public AjaxResult countGroupByProvince(@RequestBody JSONObject object) {
        return marketAnalysisService.countGroupByProvince(object);
    }

    @RequestMapping("/getYear")
    public TableDataInfo getYear(){
        List<Integer> list = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        int nowYear = calendar.get(Calendar.YEAR);
        list.add(nowYear);
        for (int i = 1; i < 5; i++) {
            list.add(nowYear-i);
        }
        return getDataTable(list);
    }

    /*
     * 中标数量按月份分组
     */
    @RequestMapping("/countGroupByMonth")
    public AjaxResult countGroupByMonth(@RequestBody JSONObject object) {
        return marketAnalysisService.countGroupByMonth(object);
    }
}
