reg_stat
This commit is contained in:
parent
3494271727
commit
5e57feb52c
@ -21,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 区域检验中心,统计
|
||||
*/
|
||||
@Api(tags = "区域检验中心-统计")
|
||||
@Api(tags = "区域检验中心-大屏统计")
|
||||
@RestController
|
||||
@RequestMapping("/transitstat")
|
||||
@Slf4j
|
||||
@ -72,6 +72,8 @@ public class RegStatController {
|
||||
private List<Map<String,Object>> setmapgroup(List<Map<String,Object>> maps){
|
||||
List<Map<String,Object>> mapref=new ArrayList<>();
|
||||
if(!maps.isEmpty()) {
|
||||
OptionalInt maxOpt = maps.stream().mapToInt(map -> (Integer) map.get("daynum")).max();
|
||||
int lastday = maxOpt.orElse(0);
|
||||
int total = maps.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum();
|
||||
if (total == 0) {
|
||||
return mapref;
|
||||
@ -93,7 +95,7 @@ public class RegStatController {
|
||||
maptemp.put("groupname", srcHospName);
|
||||
maptemp.put("groupsum",total0);
|
||||
maptemp.put("percentage", df.format(percentage));
|
||||
maptemp.put("dayline", result);
|
||||
maptemp.put("dayline", setdayline(result,lastday));
|
||||
mapref.add(maptemp);
|
||||
}
|
||||
}
|
||||
@ -101,5 +103,37 @@ public class RegStatController {
|
||||
}
|
||||
return mapref;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> setdayline(List<Map<String, Object>> maps,Integer lastnum){
|
||||
List<Map<String, Object>> mapref=new ArrayList<>();
|
||||
if(!maps.isEmpty()) {
|
||||
int i=0;
|
||||
for (Map<String, Object> map : maps) {
|
||||
i++;
|
||||
int daynum=(Integer)map.get("daynum");
|
||||
if(daynum>i){
|
||||
while (daynum>i){
|
||||
Map<String, Object> maptemp = new HashMap<>();
|
||||
maptemp.put("daynum",i);
|
||||
maptemp.put("sl",0);
|
||||
mapref.add(maptemp);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Map<String, Object> maptemp = new HashMap<>();
|
||||
maptemp.put("daynum",daynum);
|
||||
maptemp.put("sl",map.get("sl"));
|
||||
mapref.add(maptemp);
|
||||
}
|
||||
if(lastnum>i){
|
||||
while (lastnum>i){
|
||||
Map<String, Object> maptemp = new HashMap<>();
|
||||
maptemp.put("daynum",i);
|
||||
maptemp.put("sl",0);
|
||||
mapref.add(maptemp);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mapref;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user