|
|
@ -491,46 +491,92 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<VoteChartVo> getMaintenanceListStatistics(String startTime, String endTime,Long deptId) { |
|
|
|
public List<VoteChartVo> getMaintenanceListStatistics(String startTime, String endTime,Long deptId) { |
|
|
|
List<OperMaintenanceTaskEntity> maintenanceTaskEntities = new ArrayList<>(); |
|
|
|
List<VoteChartVo> result = Lists.newArrayList(); |
|
|
|
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser(); |
|
|
|
LambdaQueryWrapper<OperMaintenanceTaskEntity> wq = Wrappers.<OperMaintenanceTaskEntity>lambdaQuery() |
|
|
|
List<Long> deptIds; |
|
|
|
.like(Func.isNotEmpty(deptId),OperMaintenanceTaskEntity::getCreateDept, deptId) |
|
|
|
if (deptByCurrentUser.isSuccess() && CollectionUtil.isNotEmpty(deptByCurrentUser.getData())) { |
|
|
|
.ge(StringUtils.isNotBlank(startTime), OperMaintenanceTaskEntity::getDisposeTime, startTime) |
|
|
|
deptIds = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList()); |
|
|
|
.le(StringUtils.isNotBlank(endTime), OperMaintenanceTaskEntity::getDisposeTime, endTime) |
|
|
|
} else { |
|
|
|
.orderByAsc(OperMaintenanceTaskEntity::getCreateDept); |
|
|
|
throw new ServiceException("暂无机构权限"); |
|
|
|
List<OperMaintenanceTaskEntity> taskList = this.list(wq); |
|
|
|
} |
|
|
|
Map<Long, List<OperMaintenanceTaskEntity>> taskMapList = taskList.stream().filter(t -> Func.isNotEmpty(t.getDisposer())) |
|
|
|
QueryWrapper<OperMaintenanceTaskEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
.flatMap(t -> Func.toLongList(t.getDisposer()).stream().filter(Func::isNotEmpty).map(u -> { |
|
|
|
if (ObjectUtil.isNotEmpty(deptId)) { |
|
|
|
OperMaintenanceTaskEntity task = BeanUtil.copy(t, OperMaintenanceTaskEntity.class); |
|
|
|
if (deptIds.contains(deptId)) { |
|
|
|
task.setDisposer(u.toString()); |
|
|
|
queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptId); |
|
|
|
return task; |
|
|
|
} else { |
|
|
|
})) |
|
|
|
throw new ServiceException("暂无该机构权限"); |
|
|
|
.collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getCreateDept)); |
|
|
|
} |
|
|
|
taskMapList.forEach((id,list) -> { |
|
|
|
} else { |
|
|
|
R<Dept> deptR = sysClient.getDept(id); |
|
|
|
queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds); |
|
|
|
if(deptR.isSuccess() && StringUtil.isNotBlank(deptR.getData().getDeptName())) { |
|
|
|
} |
|
|
|
Map<String, List<OperMaintenanceTaskEntity>> userTaskMap = list.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getDisposer)); |
|
|
|
queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME", startTime); |
|
|
|
userTaskMap.forEach((userId,mt) -> { |
|
|
|
queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME", endTime); |
|
|
|
VoteChartVo chartVo = new VoteChartVo(); |
|
|
|
maintenanceTaskEntities = baseMapper.selectList(queryWrapper); |
|
|
|
chartVo.setName(deptR.getData().getDeptName()); |
|
|
|
|
|
|
|
chartVo.setUserName(Optional.of(userId).map(Long::parseLong).map(UserCache::getUser).map(User::getName).orElse("-")); |
|
|
|
List<VoteChartVo> res = new ArrayList<>(); |
|
|
|
List<Long> sumIds = mt.stream().map(OperMaintenanceTaskEntity::getId).distinct().collect(Collectors.toList()); |
|
|
|
if (CollectionUtil.isNotEmpty(maintenanceTaskEntities)) { |
|
|
|
chartVo.setSumNum(sumIds.size()); |
|
|
|
VoteChartVo all = getVoteChartVo(maintenanceTaskEntities); |
|
|
|
chartVo.setSumIds(sumIds); |
|
|
|
all.setName("总计"); |
|
|
|
List<Long> finishIds = mt.stream().filter(task -> "结束".equals(task.getFlowTaskName())).map(OperMaintenanceTaskEntity::getId).distinct().collect(Collectors.toList()); |
|
|
|
res.add(all); |
|
|
|
chartVo.setFinishIds(finishIds); |
|
|
|
Map<Long, List<OperMaintenanceTaskEntity>> collect = Optional.ofNullable(maintenanceTaskEntities).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getCreateDept)); |
|
|
|
chartVo.setFinishNum(finishIds.size()); |
|
|
|
for (Map.Entry<Long, List<OperMaintenanceTaskEntity>> longListEntry : collect.entrySet()) { |
|
|
|
chartVo.setUndoneIds((List<Long>)org.apache.commons.collections4.CollectionUtils.subtract(sumIds, finishIds)); |
|
|
|
VoteChartVo voteChartVo = getVoteChartVo(longListEntry.getValue()); |
|
|
|
chartVo.setUndoneNum(sumIds.size() - finishIds.size()); |
|
|
|
R<String> deptName = sysClient.getDeptName(longListEntry.getKey()); |
|
|
|
chartVo.setFinishRate(new BigDecimal((double)finishIds.size() / (double)sumIds.size() * 100).setScale(2,RoundingMode.HALF_UP).doubleValue()); |
|
|
|
voteChartVo.setName(deptName.isSuccess() ? deptName.getData() : ""); |
|
|
|
result.add(chartVo); |
|
|
|
res.add(voteChartVo); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
VoteChartVo all = new VoteChartVo(); |
|
|
|
|
|
|
|
all.setName("总计"); |
|
|
|
|
|
|
|
res.add(all); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return res; |
|
|
|
}); |
|
|
|
|
|
|
|
// 合计
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(result)) { |
|
|
|
|
|
|
|
VoteChartVo chartVo = new VoteChartVo(); |
|
|
|
|
|
|
|
chartVo.setName("合计"); |
|
|
|
|
|
|
|
chartVo.setSumNum(result.stream().collect(Collectors.summingInt(VoteChartVo::getSumNum))); |
|
|
|
|
|
|
|
chartVo.setFinishNum(result.stream().collect(Collectors.summingInt(VoteChartVo::getFinishNum))); |
|
|
|
|
|
|
|
chartVo.setUndoneNum(result.stream().collect(Collectors.summingInt(VoteChartVo::getUndoneNum))); |
|
|
|
|
|
|
|
chartVo.setFinishRate(new BigDecimal((double)chartVo.getFinishNum() / (double)chartVo.getSumNum() * 100).setScale(2,RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
result.add(chartVo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
// List<OperMaintenanceTaskEntity> maintenanceTaskEntities = new ArrayList<>();
|
|
|
|
|
|
|
|
// R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
|
|
|
|
|
|
|
|
// List<Long> deptIds;
|
|
|
|
|
|
|
|
// if (deptByCurrentUser.isSuccess() && CollectionUtil.isNotEmpty(deptByCurrentUser.getData())) {
|
|
|
|
|
|
|
|
// deptIds = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// throw new ServiceException("暂无机构权限");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QueryWrapper<OperMaintenanceTaskEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(deptId)) {
|
|
|
|
|
|
|
|
// if (deptIds.contains(deptId)) {
|
|
|
|
|
|
|
|
// queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptId);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// throw new ServiceException("暂无该机构权限");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME", startTime);
|
|
|
|
|
|
|
|
// queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME", endTime);
|
|
|
|
|
|
|
|
// maintenanceTaskEntities = baseMapper.selectList(queryWrapper);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// List<VoteChartVo> res = new ArrayList<>();
|
|
|
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(maintenanceTaskEntities)) {
|
|
|
|
|
|
|
|
// VoteChartVo all = getVoteChartVo(maintenanceTaskEntities);
|
|
|
|
|
|
|
|
// all.setName("总计");
|
|
|
|
|
|
|
|
// res.add(all);
|
|
|
|
|
|
|
|
// Map<Long, List<OperMaintenanceTaskEntity>> collect = Optional.ofNullable(maintenanceTaskEntities).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getCreateDept));
|
|
|
|
|
|
|
|
// for (Map.Entry<Long, List<OperMaintenanceTaskEntity>> longListEntry : collect.entrySet()) {
|
|
|
|
|
|
|
|
// VoteChartVo voteChartVo = getVoteChartVo(longListEntry.getValue());
|
|
|
|
|
|
|
|
// R<String> deptName = sysClient.getDeptName(longListEntry.getKey());
|
|
|
|
|
|
|
|
// voteChartVo.setName(deptName.isSuccess() ? deptName.getData() : "");
|
|
|
|
|
|
|
|
// res.add(voteChartVo);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// VoteChartVo all = new VoteChartVo();
|
|
|
|
|
|
|
|
// all.setName("总计");
|
|
|
|
|
|
|
|
// res.add(all);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return res;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|