Search in sources :

Example 1 with TotalBean

use of itor.topnetwork.com.dxditor.hybrid.bean.total.TotalBean in project Dxditor by kimi2009.

the class MainpageModel method getQjxxData.

// 全局信息
@Override
public void getQjxxData(final ValueCallBack<String> callBack) {
    qjxxList = new ArrayList<QjxxBean>();
    if (!Constants.testData) {
        Request request = new Request.Builder().url(Constants.getAppDeviceCount).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("getAppDeviceCount:" + res);
                try {
                    JSONObject js = new JSONObject(res);
                    if (js.getBoolean("success")) {
                        /* QjxxBean qjxxbean = gson.fromJson(js.getString("data"), new TypeToken<QjxxBean>() {
                            }.getType());*/
                        QjxxBean qjxxbean = gson.fromJson(js.getString("data"), QjxxBean.class);
                        TotalBean totalBean = new TotalBean();
                        ArrayList<String> legendList = new ArrayList<String>();
                        for (int i = 0; i < qjxxbean.getIotrappdeviceList().size(); i++) {
                            if (!legendList.contains(qjxxbean.getIotrappdeviceList().get(i).getTypeCode())) {
                                legendList.add(qjxxbean.getIotrappdeviceList().get(i).getTypeCode());
                            }
                        }
                        legendList.add("告警数");
                        String[] arrayt = new String[legendList.size()];
                        totalBean.legendData = legendList.toArray(arrayt);
                        ArrayList<String> xData = new ArrayList<String>();
                        for (int i = 0; i < qjxxbean.getIotrappdeviceList().size(); i++) {
                            if (!xData.contains(qjxxbean.getIotrappdeviceList().get(i).getLineName())) {
                                xData.add(qjxxbean.getIotrappdeviceList().get(i).getLineName());
                            }
                        }
                        String[] arrayp = new String[xData.size()];
                        totalBean.xData = xData.toArray(arrayp);
                        totalBean.series = new ArrayList<>();
                        for (int i = 0; i < totalBean.legendData.length - 1; i++) {
                            Bar bar = new Bar();
                            bar.name = totalBean.legendData[i];
                            bar.type = "bar";
                            bar.yAxisIndex = 0;
                            bar.stack = "a";
                            int[] d = new int[totalBean.xData.length];
                            for (int j = 0; j < totalBean.xData.length; j++) {
                                for (QjxxBean.Qjxx q : qjxxbean.getIotrappdeviceList()) {
                                    if (q.getTypeCode().equals(totalBean.legendData[i]) && q.getLineName().equals(totalBean.xData[j])) {
                                        d[j] = q.getCount();
                                    }
                                }
                            }
                            bar.data = d;
                            totalBean.series.add(bar);
                        }
                        Line line = new Line();
                        line.name = "告警数";
                        line.type = "line";
                        line.yAxisIndex = 1;
                        int[] gjs = new int[totalBean.xData.length];
                        for (int j = 0; j < totalBean.xData.length; j++) {
                            for (QjxxBean.GjCountBean g : qjxxbean.getLineAlarmConutList()) {
                                if (g.getLineName().equals(totalBean.xData[j])) {
                                    gjs[j] = g.getAlarmCount();
                                }
                            }
                        }
                        line.data = gjs;
                        totalBean.series.add(line);
                        callBack.onSuccess(gson.toJson(totalBean));
                    } else {
                        callBack.onFail("01");
                    }
                } catch (Exception e) {
                    callBack.onFail("01");
                    e.printStackTrace();
                }
            }
        });
    }
}
Also used : Call(okhttp3.Call) Request(okhttp3.Request) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IOException(java.io.IOException) Response(okhttp3.Response) Line(itor.topnetwork.com.dxditor.hybrid.bean.total.Line) Bar(itor.topnetwork.com.dxditor.hybrid.bean.total.Bar) Callback(okhttp3.Callback) JSONObject(org.json.JSONObject) TotalBean(itor.topnetwork.com.dxditor.hybrid.bean.total.TotalBean) QjxxBean(itor.topnetwork.com.dxditor.bean.QjxxBean)

Example 2 with TotalBean

use of itor.topnetwork.com.dxditor.hybrid.bean.total.TotalBean 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

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