Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 8 months ago
parent
commit
8ea4543c28
  1. 15
      hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java
  2. 124
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

15
hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java

@ -16,12 +16,12 @@ import java.util.List;
@ApiModel("各个票种统计表") @ApiModel("各个票种统计表")
public class VoteChartVo { public class VoteChartVo {
@ApiModelProperty(value = "站点名称") @ApiModelProperty(value = "站点名称")
@ColumnWidth(value = 20) @ColumnWidth(value = 25)
@ExcelProperty(value = "站点名称", index = 0) @ExcelProperty(value = "站点名称", index = 0)
private String name; private String name;
@ApiModelProperty(value = "总数量") @ApiModelProperty(value = "总数量")
@ExcelProperty(value = "总数量", index = 1) @ExcelProperty(value = "总数量", index = 2)
@ColumnWidth(value = 20) @ColumnWidth(value = 20)
private int sumNum; private int sumNum;
@ -30,7 +30,7 @@ public class VoteChartVo {
private List<Long> sumIds; private List<Long> sumIds;
@ApiModelProperty(value = "未完成数量") @ApiModelProperty(value = "未完成数量")
@ExcelProperty(value = "未完成数量", index = 2) @ExcelProperty(value = "未完成数量", index = 3)
@ColumnWidth(value = 20) @ColumnWidth(value = 20)
private int undoneNum; private int undoneNum;
@ -40,7 +40,7 @@ public class VoteChartVo {
@ApiModelProperty(value = "完成数量") @ApiModelProperty(value = "完成数量")
@ColumnWidth(value = 20) @ColumnWidth(value = 20)
@ExcelProperty(value = "完成数量", index = 3) @ExcelProperty(value = "完成数量", index = 4)
private int finishNum; private int finishNum;
@ApiModelProperty(value = "完成id") @ApiModelProperty(value = "完成id")
@ -48,7 +48,12 @@ public class VoteChartVo {
private List<Long> finishIds; private List<Long> finishIds;
@ApiModelProperty(value = "完成率") @ApiModelProperty(value = "完成率")
@ExcelProperty(value = "完成率", index = 4) @ExcelProperty(value = "完成率", index = 5)
@ColumnWidth(value = 20) @ColumnWidth(value = 20)
private Double finishRate; private Double finishRate;
@ApiModelProperty(value = "用戶名")
@ExcelProperty(value = "用戶名", index = 1)
@ColumnWidth(value = 20)
private String userName;
} }

124
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

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

Loading…
Cancel
Save