Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2025-12-17 11:21:59 +08:00
3 changed files with 75 additions and 33 deletions

View File

@ -27,4 +27,9 @@ public class ProjectImageProgressDetailReq implements Serializable {
*/
@NotNull(message = "进度名称不能为空")
private String progressName;
/**
* 是否查询光伏场区所有数据
*/
private Boolean isAll = false;
}

View File

@ -175,6 +175,7 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService {
*/
@Override
public List<ProjectImageProgressDetailVo> getProjectTotalProgressDetail(ProjectImageProgressDetailReq req) {
req.setIsAll(true);
return projectBigScreenService.getProjectImageProgressDetail(req);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq;
@ -530,25 +531,38 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
Set<Long> projectIds = subProjects.stream().map(BusProject::getId).collect(Collectors.toSet());
projectIds.add(projectId);
// 获取对应进度
PgsProgressCategory progressCategory = progressCategoryService.lambdaQuery()
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getProjectId, projectIds)
.eq(PgsProgressCategory::getName, progressName)
.last("limit 1")
.one();
if (progressCategory == null) {
.list();
if (CollUtil.isEmpty(progressCategoryList)) {
return List.of();
}
Long topId = progressCategory.getId();
final List<String> gfcqName = List.of("场地平整", "桩基成孔", "桩基浇筑", "支架安装", "组件安装");
// 查出所有属于该顶级节点的子孙节点
List<PgsProgressCategory> allChildren = progressCategoryService.list(
Wrappers.<PgsProgressCategory>lambdaQuery()
.in(progressName.equals("光伏场区"), PgsProgressCategory::getName, gfcqName)
.and(wrapper ->
wrapper.like(PgsProgressCategory::getAncestors, "," + topId + ",")
.or()
.like(PgsProgressCategory::getAncestors, "," + topId))
);
LambdaQueryWrapper<PgsProgressCategory> lqw = new LambdaQueryWrapper<>();
List<PgsProgressCategory> allChildren;
if (progressName.equals("光伏场区")) {
final List<String> gfcqName = List.of("场地平整", "桩基成孔", "桩基浇筑", "支架安装", "组件安装");
List<Long> topIds = progressCategoryList.stream().map(PgsProgressCategory::getId).toList();
// 查出所有属于这些顶级节点的子孙节点
allChildren = progressCategoryService.list(
Wrappers.<PgsProgressCategory>lambdaQuery()
.in(!req.getIsAll(), PgsProgressCategory::getName, gfcqName)
.and(wrapper -> {
for (Long topId : topIds) {
wrapper.or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId + ","))
.or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId));
}
})
);
} else {
PgsProgressCategory first = progressCategoryList.getFirst();
lqw.and(wrapper ->
wrapper.like(PgsProgressCategory::getAncestors, "," + first.getId() + ",")
.or()
.like(PgsProgressCategory::getAncestors, "," + first.getId()));
allChildren = progressCategoryService.list(lqw);
}
if (allChildren.isEmpty()) {
return Collections.emptyList();
}
@ -556,7 +570,6 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
Set<Long> parentIds = allChildren.stream()
.map(PgsProgressCategory::getParentId)
.collect(Collectors.toSet());
List<PgsProgressCategory> dierList = allChildren.stream()
.filter(item -> !parentIds.contains(item.getId()))
.toList();
@ -575,26 +588,47 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
Set<Long> parentIds = allChildren.stream()
.map(PgsProgressCategory::getParentId)
.collect(Collectors.toSet());
List<PgsProgressCategory> dierList = allChildren.stream()
.filter(item -> parentIds.contains(item.getId()))
.toList();
List<ProjectImageProgressDetailVo> detailVoList = new ArrayList<>();
if (CollUtil.isEmpty(dierList)) {
return allChildren.stream().map(c -> {
// 根据名称进行分类汇总
Map<String, List<PgsProgressCategory>> childrenMap = allChildren.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
childrenMap.forEach((name, children) -> {
if (CollUtil.isEmpty(children)) {
return;
}
ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo();
vo.setId(c.getId());
vo.setUnit(c.getUnit());
vo.setProgressName(c.getName());
vo.setPlanProgress(c.getPlanTotal());
vo.setActualProgress(c.getCompleted());
vo.setTotalProgress(c.getTotal());
return vo;
}).toList();
String unit = children.stream().map(PgsProgressCategory::getUnit)
.filter(Objects::nonNull)
.findFirst().orElse(null);
vo.setUnit(unit);
vo.setProgressName(name);
BigDecimal plan = children.stream().map(PgsProgressCategory::getPlanTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setPlanProgress(plan);
BigDecimal completed = children.stream().map(PgsProgressCategory::getCompleted)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setActualProgress(completed);
BigDecimal total = children.stream().map(PgsProgressCategory::getTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setTotalProgress(total);
detailVoList.add(vo);
});
} else {
return dierList.stream().map(c -> {
// 根据名称进行分类汇总
Map<String, List<PgsProgressCategory>> dierMap = dierList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
dierMap.forEach((name, value) -> {
ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo();
Set<Long> parentIdSet = value.stream()
.map(PgsProgressCategory::getId)
.collect(Collectors.toSet());
// 获取子集
List<PgsProgressCategory> children = allChildren.stream()
.filter(item -> item.getParentId().equals(c.getId()))
.filter(item -> parentIdSet.contains(item.getParentId()))
.toList();
// 计算
BigDecimal plan = children.stream().map(PgsProgressCategory::getPlanTotal)
@ -603,16 +637,18 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total = children.stream().map(PgsProgressCategory::getTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo();
vo.setId(c.getId());
vo.setUnit(c.getUnit());
vo.setProgressName(c.getName());
vo.setPlanProgress(plan);
vo.setActualProgress(actual);
vo.setTotalProgress(total);
return vo;
}).toList();
vo.setProgressName(name);
String unit = value.stream().map(PgsProgressCategory::getUnit)
.filter(Objects::nonNull)
.findFirst().orElse(null);
vo.setUnit(unit);
detailVoList.add(vo);
});
}
return detailVoList;
}
/**