进度计划产值

This commit is contained in:
lcj
2025-10-16 15:18:39 +08:00
parent bca9745e60
commit aec8667edc
4 changed files with 105 additions and 1 deletions

View File

@ -79,6 +79,15 @@ public class PgsProgressCategoryController extends BaseController {
return R.ok(list);
}
/**
* 根据进度父级查询进度类别列表已完成产值
*/
@SaCheckPermission("progress:progressCategory:listByParent")
@GetMapping("/getValueByParentId")
public R<PgsProgressCategoryValueVo> getValueByParentId(PgsProgressCategoryQueryByParentReq req) {
return R.ok(pgsProgressCategoryService.getValueByParentId(req));
}
/**
* 根据项目获取进度类别模版顶级目录列表
*/

View File

@ -0,0 +1,28 @@
package org.dromara.progress.domain.vo.progresscategory;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-10-16 11:41
*/
@Data
public class PgsProgressCategoryValueVo implements Serializable {
@Serial
private static final long serialVersionUID = -7985655623513612674L;
/**
* 产值金额(业主)
*/
private BigDecimal ownerValue;
/**
* 产值金额(分包)
*/
private BigDecimal constructionValue;
}

View File

@ -155,7 +155,12 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
*/
List<Map<String, Object>> getMatrixIdAndNumber(Long projectId);
/**
* 转换进度类别vo为进度类别实体
*
* @param vo 进度类别vo
* @return 进度类别实体
*/
PgsProgressCategory convertVoToEntity(PgsProgressCategoryVo vo);
/**
@ -246,4 +251,12 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
* @return 进度类别甘特图结构
*/
List<PgsProgressCategoryGanttSubProjectVo> getGanttStructureList(Long progressCategoryId);
/**
* 获取进度类别产值
*
* @param req 查询条件
* @return 进度类别产值
*/
PgsProgressCategoryValueVo getValueByParentId(PgsProgressCategoryQueryByParentReq req);
}

View File

@ -2126,6 +2126,60 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
}
}
/**
* 获取进度类别产值
*
* @param req 查询条件
* @return 进度类别产值
*/
@Override
public PgsProgressCategoryValueVo getValueByParentId(PgsProgressCategoryQueryByParentReq req) {
PgsProgressCategoryValueVo vo = new PgsProgressCategoryValueVo();
vo.setOwnerValue(BigDecimal.ZERO);
vo.setConstructionValue(BigDecimal.ZERO);
// 根据查询条件获取数据
Long parentId = req.getParentId();
String name = req.getName();
if (parentId == null) {
return vo;
}
QueryWrapper<PgsProgressCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.apply("FIND_IN_SET({0}, ancestors)", parentId);
queryWrapper.like(StringUtils.isNotBlank(name), "name", name);
List<PgsProgressCategory> progressCategoryList = this.list(queryWrapper);
if (CollUtil.isEmpty(progressCategoryList)) {
return vo;
}
// 过滤掉那些还有子节点的,只保留最底层
Set<Long> parentIds = progressCategoryList.stream()
.map(PgsProgressCategory::getParentId)
.collect(Collectors.toSet());
List<PgsProgressCategory> categoryList = progressCategoryList.stream()
.filter(item -> !parentIds.contains(item.getId())) // 没有被当作别人父id的就是叶子节点
.toList();
// 统计完成产值
BigDecimal ownerValue = categoryList.stream().map(item -> {
BigDecimal completed = item.getCompleted();
BigDecimal ownerPrice = item.getOwnerPrice();
if (item.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
completed = completed.multiply(item.getTotal()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
}
return completed.multiply(ownerPrice);
}).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_UP);
vo.setOwnerValue(ownerValue);
// 统计施工产值
BigDecimal constructionValue = categoryList.stream().map(item -> {
BigDecimal completed = item.getCompleted();
BigDecimal constructionPrice = item.getConstructionPrice();
if (item.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
completed = completed.multiply(item.getTotal()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
}
return completed.multiply(constructionPrice);
}).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_UP);
vo.setConstructionValue(constructionValue);
return vo;
}
/**
* 计算进度类别(含子类别)的开始和结束时间。
* <p>