package cn.com.capcloud.api.action.myself.system.charts;

import cn.com.capcloud.api.action.service.ApiService;
import cn.com.capcloud.ccui.core.common.json.JackJSONObject;
import cn.com.capcloud.core.cache.KHCRedisCache;
import cn.com.capcloud.core.noentitydb.BaseService;
import cn.com.capcloud.core.system.user.UserService;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class ChartsTestAction {
    @Resource
    private BaseService baseService;
    @Resource
    private UserService userService;
    @Resource
    private ApiService apiService;
    @Resource
    private JdbcTemplate jdbcTemplate;
    @Resource
    private KHCRedisCache khcRedisCache;
    private static ChartsTestAction action;
    @PostConstruct
    public void init(){
        action=this;
        action.baseService=this.baseService;
        action.userService=this.userService;
        action.apiService =this.apiService;
        action.khcRedisCache =this.khcRedisCache;
        action.jdbcTemplate=this.jdbcTemplate;
    }
    public Map<String,Object> getChartData(String jsonStr, JackJSONObject retJson, HttpServletRequest request){
        JackJSONObject json= JackJSONObject.fromObject(jsonStr);
        Map<String,Object> retMap=new HashMap<>();
        String value= String.valueOf(json.get("value"));
        List list=new ArrayList<>();
        //模拟带检索条件的
        if(value.equals("null")||value.equals("")||value.equals("2022")){
            Map<String,Object> dataMap1=new HashMap<>();
            dataMap1.put("value",44652);
            dataMap1.put("name","上海");
            list.add(dataMap1);
            Map<String,Object> dataMap2=new HashMap<>();
            dataMap2.put("value",41610);
            dataMap2.put("name","北京");
            list.add(dataMap2);
            Map<String,Object> dataMap3=new HashMap<>();
            dataMap3.put("value",32387);
            dataMap3.put("name","深圳");
            list.add(dataMap3);
            Map<String,Object> dataMap4=new HashMap<>();
            dataMap4.put("value",29129);
            dataMap4.put("name","重庆");
            list.add(dataMap4);
        }
        retMap.put("message","查询成功");
        retMap.put("data",list);
        return retMap;
    }

}
