@Override
public Option getTrafficChartOption(String type, ReportType reportType, Integer deviceId, Integer direction) {
Integer device = deviceId + 1010000;
List<ChartData> data = chartDao.getTrafficChartData(reportType,device,direction);
String title = Titlehelper.getChartTitle(reportType);
String subtitle = Titlehelper.gettrafficSubText(reportType.getReportTime(),deviceId,direction);
Option option = new Option();
switch (type){
case "bar":
option = BarOption.BarOptionBuiler(title, subtitle, data);
break;
case "line":
option = LineOption.OptionBuilerhelp(title, subtitle, data);
break;
case "pie":
option = PieOption.PieOptionbuilder(title, subtitle, data);
break;
}
return option;
}
@Override
public Option getAmmeterChartOption(String type, ReportType reportType, Integer deviceId) {
List<ChartData> data = chartDao.getAmmeterDataChartData(reportType,deviceId);
String title = Titlehelper.getChartTitle(reportType);
String subtitle = Titlehelper.gettrafficSubText(reportType.getReportTime(),deviceId,1);
Option option = new Option();
switch (type){
case "bar":
option = BarOption.BarOptionBuiler(title, subtitle, data);
break;
case "line":
option = LineOption.OptionBuilerhelp(title, subtitle, data);
break;
case "pie":
option = PieOption.PieOptionbuilder(title, subtitle, data);
break;
}
return option;
}
代碼結構非常相似,只是dao層取數據不一樣,另外這個switch有沒有改進空間,我知道使用eumn來枚舉,沒寫以減少無關代碼
代碼重復求改進方法
慕尼黑8549860
2019-03-01 10:47:42