package com.dsk.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.dsk.biz.domain.bo.BusinessSearchDto;
import com.dsk.biz.domain.vo.BusinessAnalyzeVo;
import com.dsk.biz.mapper.BusinessInfoMapper;
import com.dsk.biz.service.IBusinessOverviewService;
import com.dsk.common.annotation.DataColumn;
import com.dsk.common.annotation.DataPermission;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.utils.DskOpenApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @author lcl
 * @create 2023/8/14
 */
@Service
public class BusinessOverviewServiceImpl implements IBusinessOverviewService {

    @Resource
    private BusinessInfoMapper businessInfoMapper;

    @Autowired
    private DskOpenApiUtil dskOpenApiUtil;

    @Override
    public Map<String, Object> statusStatistics(BusinessSearchDto dto) {
        Map<String, Object> resultMap = new HashMap<>();
        //总
        resultMap.put("totalCount",businessInfoMapper.selectCountByStatus(dto));
        //储备
        dto.setStatus(0);
        resultMap.put("reserveCount",businessInfoMapper.selectCountByStatus(dto));
        //跟进
        dto.setStatus(1);
        resultMap.put("followUpCount",businessInfoMapper.selectCountByStatus(dto));
        //中标(已合作)
        dto.setStatus(2);
        resultMap.put("bidCount",businessInfoMapper.selectCountByStatus(dto));
        return resultMap;
    }

    @Override
    public List<BusinessAnalyzeVo> amountAnalyze(BusinessSearchDto dto) {
        return businessInfoMapper.selectAmountAnalyze(dto);
    }

    @Override
    public List<BusinessAnalyzeVo> typeAnalyze(BusinessSearchDto dto) {
        return businessInfoMapper.selectTypeAnalyze(dto);
    }

    @Override
    public List<BusinessAnalyzeVo> categoryAnalyze(BusinessSearchDto dto) {
        return businessInfoMapper.selectCategoryAnalyze(dto);
    }

    @Override
    public AjaxResult countGroupByProvince(Map<String,Object> object) {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/nationzj/marketAnalysis/project/countGroupByProvince", object);
        return BeanUtil.toBean(map, AjaxResult.class);
    }

    @Override
    public AjaxResult rangByMoney(Map<String,Object> object) {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/nationzj/marketAnalysis/project/rangByMoney", object);
        return BeanUtil.toBean(map, AjaxResult.class);
    }
}
