Commit 71ca1109 authored by 麻笑宇's avatar 麻笑宇

应急处置 / 办理量 (近7天)

代码修改
parent 9758beed
...@@ -54,6 +54,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -54,6 +54,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
...@@ -572,7 +573,7 @@ public class YJDPStatisticsServiceImpl { ...@@ -572,7 +573,7 @@ public class YJDPStatisticsServiceImpl {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
JSONArray legendData = new JSONArray(); JSONArray legendData = new JSONArray();
legendData.add(createLegendData()); legendData.addAll(createLegendData());
List<RegionModel> regionList = stCommonService.setRegionIfRootParentAndNoAccessIf3Level(ValidationUtil.isEmpty(recordFilterVo.getCityCode()) ? "610000" : recordFilterVo.getCityCode()); List<RegionModel> regionList = stCommonService.setRegionIfRootParentAndNoAccessIf3Level(ValidationUtil.isEmpty(recordFilterVo.getCityCode()) ? "610000" : recordFilterVo.getCityCode());
...@@ -595,18 +596,53 @@ public class YJDPStatisticsServiceImpl { ...@@ -595,18 +596,53 @@ public class YJDPStatisticsServiceImpl {
} }
return alertStatisticsMapper.countAlertRecordByOrgCodeAndDate(orgCode, recordFilterVo); return alertStatisticsMapper.countAlertRecordByOrgCodeAndDate(orgCode, recordFilterVo);
}).collect(Collectors.toList()); }).collect(Collectors.toList());
Long totalCount = alertRecordTotal.stream().reduce(0L, Long::sum);
res.put("legendData", legendData); res.put("legendData", legendData);
res.put("xdata", xData); res.put("xdata", xData);
res.put("alertRecordTotal", alertRecordTotal); res.put("alertCount", alertRecordTotal);
List<Long> totalCountList = new ArrayList();
List<String> rateList = new ArrayList();
// 计算比率
double completionRate = 0.0;
for(int i = 0;i<xData.size();i++){
totalCountList.add(totalCount);
if(totalCount != 0 && alertRecordTotal.get(i) != 0){
completionRate = (double) alertRecordTotal.get(i) / totalCount;
}
DecimalFormat df = new DecimalFormat("#,##0.00");
String rate = df.format(completionRate);
rateList.add(rate);
}
res.put("totalCount", totalCountList);
res.put("rate", rateList);
return res; return res;
} }
private JSONObject createLegendData() { private JSONArray createLegendData() {
JSONObject legendSubData = new JSONObject();
legendSubData.put("dataKey", "alertRecordTotal"); JSONArray legendData = new JSONArray();
legendSubData.put("value", "应急事件总数");
legendSubData.put("chartType", "bar"); for(int i = 0;i<3; i++){
return legendSubData; JSONObject legendSubData = new JSONObject();
if(i == 0){
legendSubData.put("dataKey", "alertCount");
legendSubData.put("value", "发生数量");
legendSubData.put("chartType", "bar");
}else if (i == 1){
legendSubData.put("dataKey", "totalCount");
legendSubData.put("value", "总量");
legendSubData.put("chartType", "bar");
}else{
legendSubData.put("dataKey", "rate");
legendSubData.put("value", "比率");
legendSubData.put("chartType", "line");
}
legendData.add(legendSubData);
}
return legendData;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment