diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/TaskStatisticsVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/TaskStatisticsVo.java index 0e039ec..37bb17f 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/TaskStatisticsVo.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/TaskStatisticsVo.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.hnac.hzims.fdp.entity.FdpTaskEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; @@ -13,8 +14,9 @@ import java.util.Date; * @created 2023-07-09 **/ @Data +@EqualsAndHashCode(callSuper = true) public class TaskStatisticsVo extends FdpTaskEntity { - + private static final long serialVersionUID = 1L; /** * 开始时间 */ diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java index 909ca71..2dd18d7 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java @@ -145,7 +145,7 @@ public class FdpTaskController extends BladeController { @PostMapping("/getTaskData") @ApiOperationSupport(order = 90) @ApiOperation(value = "获取统计详细数据") - public R getTaskData(TaskStatisticsVo statisticsVo){ - return service.getTaskData(statisticsVo); + public R getTaskData(TaskStatisticsVo statisticsVo,Query query){ + return service.getTaskData(statisticsVo,query); } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java index 3f18288..6282543 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java @@ -31,5 +31,5 @@ public interface IFdpTaskService extends BaseService { R getTaskStatistics(TaskStatisticsVo statisticsVo); - R getTaskData(TaskStatisticsVo statisticsVo); + R getTaskData(TaskStatisticsVo statisticsVo,Query query); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java index 500e43c..ca9e8c3 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java @@ -128,46 +128,75 @@ public class FdpTaskServiceImpl extends BaseServiceImpl res = new ArrayList<>(); - TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); - taskStatisticsVo.setCount(fdpTaskEntities.size()); - taskStatisticsVo.setPercentage("1"); - taskStatisticsVo.setLevel(0); - taskStatisticsVo.setName("总计"); - res.add(taskStatisticsVo); + int size = fdpTaskEntities.size(); + //在第一层去掉为null值数据 + fdpTaskEntities=fdpTaskEntities.stream().filter(s->s.getFdpDeviceName()!=null).collect(Collectors.toList()); + extracted( res,0,"总计",size,size); Map> collectByFdpDeviceName = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); getCount("",collectByFdpDeviceName, fdpTaskEntities, res, 1); if (Func.isEmpty(statisticsVo.getName())) { collectByFdpDeviceName.entrySet().forEach(s->{ - Map> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getName)); + List list=s.getValue().stream().filter(sig->sig.getName()!=null).collect(Collectors.toList()); + Map> 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.getCreateDept())){ collectByFdpDeviceName.entrySet().forEach(s->{ - Map> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getCreateDept)); + List list=s.getValue().stream().filter(sig->sig.getCreateDept()!=null).collect(Collectors.toList()); + Map> 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())){ collectByFdpDeviceName.entrySet().forEach(s->{ - Map> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd)); + List list=s.getValue().stream().filter(sig->sig.getFdpOrd()!=null).collect(Collectors.toList()); + Map> 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())){ collectByFdpDeviceName.entrySet().forEach(s->{ - Map> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getType)); + List list=s.getValue().stream().filter(sig->sig.getFdpOrd()!=null).collect(Collectors.toList()); + Map> 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 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 queryWrapper = getFdpTaskEntityWrapper(statisticsVo); - List 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 getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) { @@ -207,13 +236,14 @@ public class FdpTaskServiceImpl extends BaseServiceImpl{ TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); taskStatisticsVo.setCount(s.getValue().size()); - BigDecimal bigDecimal=BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.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.setName(key+"-"+s.getKey().toString()); + taskStatisticsVo.setMemuName(key+"-"+s.getKey().toString()); res.add(taskStatisticsVo); }); } + //获取对应层级占比和数量 //机构类型需要转换ID为名称 private void getCount2(String key,Map> collectByCreateDept, List fdpTaskEntities, ArrayList res,Integer level) { collectByCreateDept.entrySet().forEach(s->{ @@ -229,7 +259,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl