|
|
|
@ -128,46 +128,75 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
|
|
|
|
|
return R.success("暂无数据,请稍后重试"); |
|
|
|
|
} |
|
|
|
|
ArrayList<TaskStatisticsVo> res = new ArrayList<>(); |
|
|
|
|
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); |
|
|
|
|
taskStatisticsVo.setCount(fdpTaskEntities.size()); |
|
|
|
|
taskStatisticsVo.setPercentage("1"); |
|
|
|
|
taskStatisticsVo.setLevel(0); |
|
|
|
|
taskStatisticsVo.setName("总计"); |
|
|
|
|
res.add(taskStatisticsVo); |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByCreateDept = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); |
|
|
|
|
getCount("",collectByCreateDept, fdpTaskEntities, res, 1); |
|
|
|
|
int size = fdpTaskEntities.size(); |
|
|
|
|
//在第一层去掉为null值数据
|
|
|
|
|
fdpTaskEntities=fdpTaskEntities.stream().filter(s->s.getFdpDeviceName()!=null).collect(Collectors.toList()); |
|
|
|
|
extracted( res,0,"总计",size,size); |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByFdpDeviceName = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); |
|
|
|
|
getCount("",collectByFdpDeviceName, fdpTaskEntities, res, 1); |
|
|
|
|
if (Func.isEmpty(statisticsVo.getName())) { |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getName)); |
|
|
|
|
collectByFdpDeviceName.entrySet().forEach(s->{ |
|
|
|
|
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getName()!=null).collect(Collectors.toList()); |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getName)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
if (list.size()!=s.getValue().size()) { |
|
|
|
|
//值为空单独加进来
|
|
|
|
|
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} else if (Func.isEmpty(statisticsVo.getFdpDeviceName())){ |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
} else if (Func.isEmpty(statisticsVo.getCreateDept())){ |
|
|
|
|
collectByFdpDeviceName.entrySet().forEach(s->{ |
|
|
|
|
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getCreateDept()!=null).collect(Collectors.toList()); |
|
|
|
|
Map<Long, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getCreateDept)); |
|
|
|
|
getCount2(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
if (list.size()!=s.getValue().size()) { |
|
|
|
|
//值为空单独加进来
|
|
|
|
|
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}else if (Func.isEmpty(statisticsVo.getFdpOrd())){ |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd)); |
|
|
|
|
collectByFdpDeviceName.entrySet().forEach(s->{ |
|
|
|
|
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getFdpOrd()!=null).collect(Collectors.toList()); |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
if (list.size()!=s.getValue().size()) { |
|
|
|
|
//值为空单独加进来
|
|
|
|
|
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}else if (Func.isEmpty(statisticsVo.getType())){ |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getType)); |
|
|
|
|
collectByFdpDeviceName.entrySet().forEach(s->{ |
|
|
|
|
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getFdpOrd()!=null).collect(Collectors.toList()); |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getType)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
if (list.size()!=s.getValue().size()) { |
|
|
|
|
//值为空单独加进来
|
|
|
|
|
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return R.data(res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void extracted( ArrayList<TaskStatisticsVo> res,Integer level,String name,Integer size,Integer all) { |
|
|
|
|
TaskStatisticsVo taskStatisticsByDeviceName = new TaskStatisticsVo(); |
|
|
|
|
taskStatisticsByDeviceName.setCount(size); |
|
|
|
|
BigDecimal bigDecimal=BigDecimal.valueOf(all).divide(BigDecimal.valueOf(size),2,BigDecimal.ROUND_UP); |
|
|
|
|
taskStatisticsByDeviceName.setPercentage(bigDecimal.toString()); |
|
|
|
|
taskStatisticsByDeviceName.setLevel(level); |
|
|
|
|
taskStatisticsByDeviceName.setMemuName(name); |
|
|
|
|
res.add(taskStatisticsByDeviceName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R getTaskData(TaskStatisticsVo statisticsVo) { |
|
|
|
|
public R getTaskData(TaskStatisticsVo statisticsVo,Query query) { |
|
|
|
|
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo); |
|
|
|
|
List<FdpTaskEntity> fdpTaskEntities = super.baseMapper.selectList(queryWrapper); |
|
|
|
|
if (CollectionUtil.isEmpty(fdpTaskEntities)){ |
|
|
|
|
IPage pages = super.baseMapper.selectPage(Condition.getPage(query),queryWrapper); |
|
|
|
|
if (CollectionUtil.isEmpty(pages.getRecords())){ |
|
|
|
|
return R.success("暂无数据,请稍后重试"); |
|
|
|
|
} |
|
|
|
|
return R.data(fdpTaskEntities); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) { |
|
|
|
@ -179,7 +208,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
|
|
|
|
|
le(FdpTaskEntity::getCreateTime, statisticsVo.getEndTime()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(statisticsVo.getCreateDept())) { |
|
|
|
|
in(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept()); |
|
|
|
|
eq(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(statisticsVo.getName())) { |
|
|
|
|
like(FdpTaskEntity::getName, statisticsVo.getName()); |
|
|
|
@ -207,10 +236,30 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
|
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); |
|
|
|
|
taskStatisticsVo.setCount(s.getValue().size()); |
|
|
|
|
BigDecimal bigDecimal=BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size()),2,BigDecimal.ROUND_UP); |
|
|
|
|
taskStatisticsVo.setPercentage(bigDecimal.toString()); |
|
|
|
|
taskStatisticsVo.setLevel(level); |
|
|
|
|
taskStatisticsVo.setMemuName(key+"-"+s.getKey().toString()); |
|
|
|
|
res.add(taskStatisticsVo); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
//获取对应层级占比和数量
|
|
|
|
|
//机构类型需要转换ID为名称
|
|
|
|
|
private void getCount2(String key,Map<Long, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res,Integer level) { |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); |
|
|
|
|
taskStatisticsVo.setCount(s.getValue().size()); |
|
|
|
|
BigDecimal bigDecimal=BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size())); |
|
|
|
|
taskStatisticsVo.setPercentage(bigDecimal.toString()); |
|
|
|
|
taskStatisticsVo.setLevel(level); |
|
|
|
|
taskStatisticsVo.setName(key+"-"+s.getKey().toString()); |
|
|
|
|
R<String> deptNameCode = sysClient.getDeptName(s.getKey()); |
|
|
|
|
String deptName; |
|
|
|
|
if (deptNameCode.isSuccess()){ |
|
|
|
|
deptName=deptNameCode.getData(); |
|
|
|
|
}else { |
|
|
|
|
deptName=""; |
|
|
|
|
} |
|
|
|
|
taskStatisticsVo.setMemuName(key+"-"+deptName); |
|
|
|
|
res.add(taskStatisticsVo); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|