|
@@ -507,7 +507,8 @@ public class KprAimWaterCollecationBizFun {
|
|
|
}
|
|
|
|
|
|
//TODO 获取小时实际水量数据
|
|
|
- public static ResponseRes selectRealHourWaterList(JPRealHourWater jpTbMHourWater){
|
|
|
+ public static ResponseRes selectRealHourWaterList(JPRealHourWater jpTbMHourWater,Integer level,Map<String, Map<String, List<String>>> result
|
|
|
+ ,Map<String,String> workZonIds){
|
|
|
ResponseRes responseRes = new ResponseRes();
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -528,25 +529,84 @@ public class KprAimWaterCollecationBizFun {
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(orgConfig)){
|
|
|
//TODO 根据分区编号找到对应的名称
|
|
|
- Optional<Map<String, Object>> mapOrg = orgConfig.stream()
|
|
|
- .filter(maps -> jpTbMHourWater.getOrgId().equals(maps.get("org_id")))
|
|
|
- .findFirst();
|
|
|
- if (mapOrg.isPresent()) {
|
|
|
- Map<String,Object> currentOrg = mapOrg.get();
|
|
|
- List<Map<String,Object>> recordAllRes = getWaterTapApi()
|
|
|
- .getWaterCollectionRecordAllListAll(" WHERE 1=1 " +
|
|
|
- " AND org_name = '"+currentOrg.get("org_name").toString()+"'" +
|
|
|
- jpTbMHourWater.getForDateStr());
|
|
|
- recordAllRes.stream()
|
|
|
+ if(level==null||level!=1) {
|
|
|
+ Optional<Map<String, Object>> mapOrg = orgConfig.stream()
|
|
|
+ .filter(maps -> jpTbMHourWater.getOrgId().equals(maps.get("org_id")))
|
|
|
+ .findFirst();
|
|
|
+ if (mapOrg.isPresent()) {
|
|
|
+ Map<String, Object> currentOrg = mapOrg.get();
|
|
|
+ List<Map<String, Object>> recordAllRes = getWaterTapApi()
|
|
|
+ .getWaterCollectionRecordAllListAll(" WHERE 1=1 " +
|
|
|
+ " AND org_name = '" + currentOrg.get("org_name").toString() + "'" +
|
|
|
+ jpTbMHourWater.getForDateStr());
|
|
|
+ recordAllRes.stream()
|
|
|
+ .forEach(item -> {
|
|
|
+ item.remove("id");
|
|
|
+ item.remove("value_tag");
|
|
|
+ item.remove("collcation_tag_array");
|
|
|
+ });
|
|
|
+ if (jpTbMHourWater.getDayData()) {
|
|
|
+ responseRes.setResdata(aggregateByDay(recordAllRes));
|
|
|
+ } else {
|
|
|
+ responseRes.setResdata(recordAllRes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(level!=null&&level ==1){
|
|
|
+ //TODO 一级已经没有数据了(水厂), 查询一级的话则是将其下的供水数据相加
|
|
|
+ //TODO 查询二级,及其二级带的三级
|
|
|
+ List<String> childList = new ArrayList<>();//要查询的组织机构名称集合
|
|
|
+ List<String> childIdList = new ArrayList<>();//要查询的组织机构id集合
|
|
|
+ Optional zoneNameOpt = findOrgNameByOrgId(workZonIds,jpTbMHourWater.getOrgId());
|
|
|
+ if(zoneNameOpt.isPresent()){
|
|
|
+ String zoneName = zoneNameOpt.get().toString();
|
|
|
+ Map<String, List<String>> childMap = result.get(zoneName);//二级
|
|
|
+ Collection<List<String>> child2Map = childMap.values();//三级
|
|
|
+ // 添加二级组织机构名称(childMap 的 keySet)
|
|
|
+ childList.addAll(childMap.keySet());
|
|
|
+ // 添加三级组织机构名称(child2Map 的所有 List<String>)
|
|
|
+ for (List<String> child2List : child2Map) {
|
|
|
+ childList.addAll(child2List);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 结果集合,存储 childList 对应的组织机构 ID
|
|
|
+ // 遍历 childList,从 workZonIds 中获取对应的 ID
|
|
|
+ for (String orgName : childList) {
|
|
|
+ String orgId = workZonIds.get(orgName);
|
|
|
+ if (orgId != null) { // 避免空值
|
|
|
+ childIdList.add(orgId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Map<String,Object>> newResList = new ArrayList<>();
|
|
|
+ int index = 0;
|
|
|
+ for (String orgName:childList){
|
|
|
+ List<Map<String,Object>> resList = getWaterTapApi()
|
|
|
+ .getWaterCollectionRecordAllListAll(" WHERE 1=1 " +
|
|
|
+ " AND org_name = '"+orgName+"'" +
|
|
|
+ jpTbMHourWater.getForDateStr() + " ORDER BY time ASC ");
|
|
|
+ if(!CollectionUtils.isEmpty(newResList)&&!CollectionUtils.isEmpty(resList)){
|
|
|
+ //TODO 说明要查询的分区不止一个,则&把原来有的数据与新查的数据相加,因为按Date排了序所以一致
|
|
|
+ for (int i=0;i<newResList.size();i++){
|
|
|
+ newResList.get(i).put("value",
|
|
|
+ String.valueOf(parseDouble(newResList.get(i).get("value")) +
|
|
|
+ parseDouble(resList.get(i).get("value"))));
|
|
|
+ newResList.get(i).put("org_name",orgName);
|
|
|
+ newResList.get(i).put("time",resList.get(i).get("time"));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ newResList.addAll(resList);
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ newResList.stream()
|
|
|
.forEach(item -> {
|
|
|
item.remove("id");
|
|
|
item.remove("value_tag");
|
|
|
item.remove("collcation_tag_array");
|
|
|
});
|
|
|
if(jpTbMHourWater.getDayData()){
|
|
|
- responseRes.setResdata(aggregateByDay(recordAllRes));
|
|
|
+ responseRes.setResdata(aggregateByDay(newResList));
|
|
|
}else{
|
|
|
- responseRes.setResdata(recordAllRes);
|
|
|
+ responseRes.setResdata(newResList);
|
|
|
}
|
|
|
}
|
|
|
}
|