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 org.springframework.beans.factory.annotation.Autowired;
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 {
    @Autowired
    private BaseService baseService;
    @Autowired
    private UserService userService;
    @Autowired
    private ApiService apiService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    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;
    }

}

