use of itor.topnetwork.com.dxditor.hybrid.bean.total.Bar 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();
}
}
});
}
}
use of itor.topnetwork.com.dxditor.hybrid.bean.total.Bar in project Dxditor by kimi2009.
the class EchartsDataBean method getEchartsTotalJson.
public String getEchartsTotalJson() {
totalBean.legendData = new String[] { "桥梁", "声屏障", "坠坨", "线夹", "轨道板", "损坏量" };
totalBean.xData = new String[] { "京广线", "京沪线", "京九线", "京津线", "京哈线", "京张铁路", "京通线", "张集线" };
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++) {
d[j] = random.nextInt(150) + 1;
}
bar.data = d;
totalBean.series.add(bar);
}
Line line = new Line();
line.name = "损坏量";
line.type = "line";
line.yAxisIndex = 1;
line.data = new int[] { 23, 34, 42, 24, 32, 23, 23, 23 };
totalBean.series.add(line);
return gson.toJson(totalBean);
}
Aggregations