Search in sources :

Example 1 with SpzEchartsBean

use of itor.topnetwork.com.dxditor.hybrid.bean.spz.SpzEchartsBean in project Dxditor by kimi2009.

the class SpzModel method getTrendData.

@Override
public void getTrendData(final ValueCallBack<String> callBack, int position) {
    spzTrends = new ArrayList<SpzTrend>();
    if (Constants.testData) {
        SpzEchartsBean spzBean = new SpzEchartsBean();
        if (position == 0) {
            for (int i = 0; i < 9; i++) {
                spzTrends.add(new SpzTrend(Float.parseFloat("10" + i), "03-2" + i + " 08:00"));
            }
        } else if (position == 1) {
            for (int i = 0; i < 9; i++) {
                spzTrends.add(new SpzTrend(Float.parseFloat("8" + i), "03-2" + i + " 08:00"));
            }
        } else if (position == 2) {
            for (int i = 0; i < 9; i++) {
                spzTrends.add(new SpzTrend(Float.parseFloat("7" + i), "03-2" + i + " 08:00"));
            }
        }
        List<String> time = new ArrayList<>();
        for (int i = 0; i < spzTrends.size(); i++) {
            time.add(spzTrends.get(i).getStorageTime());
        }
        spzBean.xData = time;
        List<Float> lineDatas = new ArrayList<>();
        for (int i = 0; i < spzTrends.size(); i++) {
            lineDatas.add(spzTrends.get(i).getTypeData());
        }
        spzBean.seriesData = lineDatas;
        callBack.onSuccess(gson.toJson(spzBean));
    } else {
        // Form表单格式的参数传递
        FormBody formBody = new FormBody.Builder().add("bridgeCode", spzWarnings.get(position).getBridgeCode()).add("type", spzWarnings.get(position).getType()).add("storageTime", Constants.MONTH).build();
        Request request = new Request.Builder().post(formBody).url(Constants.getAppSoundBarrierInfo).build();
        okHttpClient.newCall(request).enqueue(new Callback() {

            @Override
            public void onFailure(Call call, IOException e) {
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();
                System.out.println("getAppSoundBarrierInfo:" + res);
                try {
                    JSONObject js = new JSONObject(res);
                    if (js.getBoolean("success")) {
                        spzTrends = gson.fromJson(js.getString("data"), new TypeToken<ArrayList<SpzTrend>>() {
                        }.getType());
                        SpzEchartsBean spzBean = new SpzEchartsBean();
                        // bridgeBean.initValue =;
                        List<String> time = new ArrayList<>();
                        for (int i = 0; i < spzTrends.size(); i++) {
                            time.add(spzTrends.get(i).getStorageTime());
                        }
                        spzBean.xData = time;
                        List<Float> lineDatas = new ArrayList<>();
                        for (int i = 0; i < spzTrends.size(); i++) {
                            lineDatas.add(spzTrends.get(i).getTypeData());
                        }
                        spzBean.seriesData = lineDatas;
                        callBack.onSuccess(gson.toJson(spzBean));
                    } else {
                        callBack.onFail("01");
                    }
                } catch (Exception e) {
                    callBack.onFail("01");
                    e.printStackTrace();
                }
            }
        });
    }
}
Also used : Call(okhttp3.Call) ArrayList(java.util.ArrayList) FormBody(okhttp3.FormBody) Request(okhttp3.Request) IOException(java.io.IOException) IOException(java.io.IOException) Response(okhttp3.Response) Callback(okhttp3.Callback) JSONObject(org.json.JSONObject) TypeToken(com.google.gson.reflect.TypeToken) SpzEchartsBean(itor.topnetwork.com.dxditor.hybrid.bean.spz.SpzEchartsBean) ArrayList(java.util.ArrayList) List(java.util.List) SpzTrend(itor.topnetwork.com.dxditor.bean.SpzTrend)

Example 2 with SpzEchartsBean

use of itor.topnetwork.com.dxditor.hybrid.bean.spz.SpzEchartsBean in project Dxditor by kimi2009.

the class EchartsDataBean method getInstance.

public static synchronized EchartsDataBean getInstance() {
    if (okHttpClient == null) {
        okHttpClient = new OkHttpClient();
        echartsDataBean = new EchartsDataBean();
        gson = new Gson();
        lineBean = new EchartsLineBean();
        barBean = new EchartsBarBean();
        pieBean = new EchartsPieBean();
        totalBean = new TotalBean();
        bridgeBean = new BridgeBean();
        spzEchartsBean = new SpzEchartsBean();
        ztTopEchartsBean = new ZtTopEchartsBean();
    }
    return echartsDataBean;
}
Also used : OkHttpClient(okhttp3.OkHttpClient) TotalBean(itor.topnetwork.com.dxditor.hybrid.bean.total.TotalBean) ZtTopEchartsBean(itor.topnetwork.com.dxditor.hybrid.bean.zt.ZtTopEchartsBean) SpzEchartsBean(itor.topnetwork.com.dxditor.hybrid.bean.spz.SpzEchartsBean) Gson(com.google.gson.Gson) BridgeBean(itor.topnetwork.com.dxditor.hybrid.bean.bridge.BridgeBean)

Aggregations

SpzEchartsBean (itor.topnetwork.com.dxditor.hybrid.bean.spz.SpzEchartsBean)2 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 SpzTrend (itor.topnetwork.com.dxditor.bean.SpzTrend)1 BridgeBean (itor.topnetwork.com.dxditor.hybrid.bean.bridge.BridgeBean)1 TotalBean (itor.topnetwork.com.dxditor.hybrid.bean.total.TotalBean)1 ZtTopEchartsBean (itor.topnetwork.com.dxditor.hybrid.bean.zt.ZtTopEchartsBean)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Call (okhttp3.Call)1 Callback (okhttp3.Callback)1 FormBody (okhttp3.FormBody)1 OkHttpClient (okhttp3.OkHttpClient)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 JSONObject (org.json.JSONObject)1