进度计划周报数据
This commit is contained in:
@ -278,5 +278,4 @@ public class PgsProgressCategoryController extends BaseController {
|
|||||||
@PathVariable Long[] ids) {
|
@PathVariable Long[] ids) {
|
||||||
return toAjax(pgsProgressCategoryService.deleteWithValidByIds(List.of(ids), true));
|
return toAjax(pgsProgressCategoryService.deleteWithValidByIds(List.of(ids), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
package org.dromara.progress.domain.vo.progresscategory;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-11-19 11:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PgsProgressCategoryDatePlanVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类别名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量方式(0无 1数量 2百分比)
|
||||||
|
*/
|
||||||
|
private String unitType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定日期范围计划数量
|
||||||
|
*/
|
||||||
|
private BigDecimal planNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量单位
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package org.dromara.progress.domain.vo.progresscategory;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-11-19 09:56
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PgsProgressCategoryDateTotalVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类别名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量方式(0无 1数量 2百分比)
|
||||||
|
*/
|
||||||
|
private String unitType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定日期范围完成数量
|
||||||
|
*/
|
||||||
|
private BigDecimal completedNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计完成数量
|
||||||
|
*/
|
||||||
|
private BigDecimal completedTotal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量单位
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
}
|
||||||
@ -7,6 +7,7 @@ import org.dromara.facility.domain.FacMatrix;
|
|||||||
import org.dromara.progress.domain.PgsProgressCategory;
|
import org.dromara.progress.domain.PgsProgressCategory;
|
||||||
import org.dromara.progress.domain.PgsProgressPlan;
|
import org.dromara.progress.domain.PgsProgressPlan;
|
||||||
import org.dromara.progress.domain.dto.progresscategory.*;
|
import org.dromara.progress.domain.dto.progresscategory.*;
|
||||||
|
import org.dromara.progress.domain.enums.PgsProgressCategoryTypeEnum;
|
||||||
import org.dromara.progress.domain.vo.progresscategory.*;
|
import org.dromara.progress.domain.vo.progresscategory.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@ -14,7 +15,6 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进度类别Service接口
|
* 进度类别Service接口
|
||||||
@ -147,21 +147,6 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
|||||||
*/
|
*/
|
||||||
PgsProgressCategoryProjectVo getProjectNumber(Long projectId);
|
PgsProgressCategoryProjectVo getProjectNumber(Long projectId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据父项目id获取项目进度类别列表
|
|
||||||
*
|
|
||||||
* @param projectIds 项目id列表
|
|
||||||
*/
|
|
||||||
List<PgsProgressCategory> queryListByProjectIds(List<Long> projectIds);
|
|
||||||
|
|
||||||
/***
|
|
||||||
* 获取方阵id及对应数量
|
|
||||||
*
|
|
||||||
* @param projectId 项目id
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getMatrixIdAndNumber(Long projectId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换进度类别vo为进度类别实体
|
* 转换进度类别vo为进度类别实体
|
||||||
*
|
*
|
||||||
@ -294,6 +279,38 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
|||||||
*/
|
*/
|
||||||
PgsProgressCategoryDayTotalVo getProgressCategoryByDay(Long projectId, LocalDate date);
|
PgsProgressCategoryDayTotalVo getProgressCategoryByDay(Long projectId, LocalDate date);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定日期进度类别完成情况列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @param type 类型(为空 获取全部)
|
||||||
|
* @param startDate 开始日期
|
||||||
|
* @param endDate 结束日期
|
||||||
|
* @return 进度类别列表
|
||||||
|
*/
|
||||||
|
List<PgsProgressCategoryDateTotalVo> getProgressCategoryByDate(Long projectId, PgsProgressCategoryTypeEnum type,
|
||||||
|
LocalDate startDate, LocalDate endDate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定日期后一周的进度类别计划情况列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @param type 类型(为空 获取全部)
|
||||||
|
* @param startDate 开始日期
|
||||||
|
* @param endDate 结束日期
|
||||||
|
* @return 进度类别列表
|
||||||
|
*/
|
||||||
|
List<PgsProgressCategoryDatePlanVo> getProgressCategoryPlanByDate(Long projectId, PgsProgressCategoryTypeEnum type,
|
||||||
|
LocalDate startDate, LocalDate endDate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取项目进度类别总进度百分比
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @return 项目进度类别总进度百分比
|
||||||
|
*/
|
||||||
|
BigDecimal getTotalProgressPercentage(Long projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出项目进度类别列表
|
* 导出项目进度类别列表
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1353,25 +1353,12 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
@Override
|
* 转换进度类别vo为进度类别实体
|
||||||
public List<PgsProgressCategory> queryListByProjectIds(List<Long> projectIds) {
|
*
|
||||||
|
* @param vo 进度类别vo
|
||||||
List<BusProject> projects = projectService.lambdaQuery().in(BusProject::getPId, projectIds).list();
|
* @return 进度类别实体
|
||||||
List<Long> list = projects.stream().map(BusProject::getId).toList();
|
*/
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
return this.lambdaQuery()
|
|
||||||
.in(PgsProgressCategory::getProjectId, list)
|
|
||||||
.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getMatrixIdAndNumber(Long projectId) {
|
|
||||||
return baseMapper.getMatrixIdAndNumber(projectId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PgsProgressCategory convertVoToEntity(PgsProgressCategoryVo vo) {
|
public PgsProgressCategory convertVoToEntity(PgsProgressCategoryVo vo) {
|
||||||
if (vo == null) {
|
if (vo == null) {
|
||||||
@ -2377,6 +2364,220 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
|||||||
return totalVo;
|
return totalVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定日期进度类别列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @param type 类型(为空 获取全部)
|
||||||
|
* @param startDate 开始日期
|
||||||
|
* @param endDate 结束日期
|
||||||
|
* @return 进度类别列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PgsProgressCategoryDateTotalVo> getProgressCategoryByDate(Long projectId, PgsProgressCategoryTypeEnum type,
|
||||||
|
LocalDate startDate, LocalDate endDate) {
|
||||||
|
List<PgsProgressCategoryDateTotalVo> voList = new ArrayList<>();
|
||||||
|
// 获取项目
|
||||||
|
BusProject project = projectService.getById(projectId);
|
||||||
|
if (project == null) {
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
List<BusProject> projects = projectService.lambdaQuery()
|
||||||
|
.eq(BusProject::getPId, projectId)
|
||||||
|
.list();
|
||||||
|
projects.add(project);
|
||||||
|
List<Long> projectIds = projects.stream().map(BusProject::getId).toList();
|
||||||
|
String text = type != null ? type.getText() : null;
|
||||||
|
// 获取所有进度类别
|
||||||
|
List<PgsProgressCategory> topList = this.lambdaQuery()
|
||||||
|
.in(PgsProgressCategory::getProjectId, projectIds)
|
||||||
|
.eq(PgsProgressCategory::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID)
|
||||||
|
.eq(StringUtils.isNotBlank(text), PgsProgressCategory::getName, text)
|
||||||
|
.list();
|
||||||
|
List<Long> topIds = topList.stream().map(PgsProgressCategory::getId).toList();
|
||||||
|
List<PgsProgressCategory> children = this.getLeafNodesByTopIds(topIds);
|
||||||
|
if (CollUtil.isEmpty(children)) {
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
// 获取所有子类的计划详情
|
||||||
|
Set<Long> childrenIds = children.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
|
||||||
|
List<PgsProgressPlanDetail> planDetailList = progressPlanDetailService.lambdaQuery()
|
||||||
|
.in(PgsProgressPlanDetail::getProgressCategoryId, childrenIds)
|
||||||
|
.ge(PgsProgressPlanDetail::getDate, startDate)
|
||||||
|
.le(PgsProgressPlanDetail::getDate, endDate)
|
||||||
|
.list();
|
||||||
|
if (CollUtil.isEmpty(planDetailList)) {
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
Map<String, List<PgsProgressCategory>> childrenNameMap = children.stream()
|
||||||
|
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
|
||||||
|
childrenNameMap.forEach((name, value) -> {
|
||||||
|
Set<Long> valueIds = value.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
|
||||||
|
// 获取当前类别的计划详情
|
||||||
|
List<PgsProgressPlanDetail> detailList = planDetailList.stream()
|
||||||
|
.filter(detail -> valueIds.contains(detail.getProgressCategoryId()))
|
||||||
|
.filter(detail -> detail.getFinishedNumber().compareTo(BigDecimal.ZERO) > 0)
|
||||||
|
.toList();
|
||||||
|
if (CollUtil.isEmpty(detailList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取指定日期范围的完成数量
|
||||||
|
BigDecimal finishedNum = detailList.stream()
|
||||||
|
.map(PgsProgressPlanDetail::getFinishedNumber)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
if (finishedNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取累计完成数量
|
||||||
|
BigDecimal completedTotal = value.stream()
|
||||||
|
.map(PgsProgressCategory::getCompleted)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
// 获取类别单位
|
||||||
|
String unit = value.stream()
|
||||||
|
.map(PgsProgressCategory::getUnit)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
// 获取类别类型
|
||||||
|
String unitType = value.stream()
|
||||||
|
.map(PgsProgressCategory::getUnitType)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
// 封装数据
|
||||||
|
PgsProgressCategoryDateTotalVo vo = new PgsProgressCategoryDateTotalVo();
|
||||||
|
vo.setName(name);
|
||||||
|
vo.setUnitType(unitType);
|
||||||
|
vo.setCompletedNum(finishedNum);
|
||||||
|
vo.setCompletedTotal(completedTotal);
|
||||||
|
vo.setUnit(unit);
|
||||||
|
voList.add(vo);
|
||||||
|
});
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定日期后一周的进度类别计划情况列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @param type 类型(为空 获取全部)
|
||||||
|
* @param startDate 开始日期
|
||||||
|
* @param endDate 结束日期
|
||||||
|
* @return 进度类别列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PgsProgressCategoryDatePlanVo> getProgressCategoryPlanByDate(Long projectId, PgsProgressCategoryTypeEnum type,
|
||||||
|
LocalDate startDate, LocalDate endDate) {
|
||||||
|
List<PgsProgressCategoryDatePlanVo> voList = new ArrayList<>();
|
||||||
|
// 获取项目
|
||||||
|
BusProject project = projectService.getById(projectId);
|
||||||
|
if (project == null) {
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
List<BusProject> projects = projectService.lambdaQuery()
|
||||||
|
.eq(BusProject::getPId, projectId)
|
||||||
|
.list();
|
||||||
|
projects.add(project);
|
||||||
|
List<Long> projectIds = projects.stream().map(BusProject::getId).toList();
|
||||||
|
String text = type != null ? type.getText() : null;
|
||||||
|
// 获取所有进度类别
|
||||||
|
List<PgsProgressCategory> topList = this.lambdaQuery()
|
||||||
|
.in(PgsProgressCategory::getProjectId, projectIds)
|
||||||
|
.eq(PgsProgressCategory::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID)
|
||||||
|
.eq(StringUtils.isNotBlank(text), PgsProgressCategory::getName, text)
|
||||||
|
.list();
|
||||||
|
List<Long> topIds = topList.stream().map(PgsProgressCategory::getId).toList();
|
||||||
|
List<PgsProgressCategory> children = this.getLeafNodesByTopIds(topIds);
|
||||||
|
if (CollUtil.isEmpty(children)) {
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
// 获取所有子类的计划详情
|
||||||
|
Set<Long> childrenIds = children.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
|
||||||
|
List<PgsProgressPlanDetail> planDetailList = progressPlanDetailService.lambdaQuery()
|
||||||
|
.in(PgsProgressPlanDetail::getProgressCategoryId, childrenIds)
|
||||||
|
.ge(PgsProgressPlanDetail::getDate, startDate.plusWeeks(1))
|
||||||
|
.le(PgsProgressPlanDetail::getDate, endDate.plusWeeks(1))
|
||||||
|
.list();
|
||||||
|
if (CollUtil.isEmpty(planDetailList)) {
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
Map<String, List<PgsProgressCategory>> childrenNameMap = children.stream()
|
||||||
|
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
|
||||||
|
childrenNameMap.forEach((name, value) -> {
|
||||||
|
Set<Long> valueIds = value.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
|
||||||
|
// 获取当前类别的计划详情
|
||||||
|
List<PgsProgressPlanDetail> detailList = planDetailList.stream()
|
||||||
|
.filter(detail -> valueIds.contains(detail.getProgressCategoryId()))
|
||||||
|
.filter(detail -> detail.getPlanNumber().compareTo(BigDecimal.ZERO) > 0)
|
||||||
|
.toList();
|
||||||
|
if (CollUtil.isEmpty(detailList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取指定日期范围的完成数量
|
||||||
|
BigDecimal planNumber = detailList.stream()
|
||||||
|
.map(PgsProgressPlanDetail::getPlanNumber)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
if (planNumber.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取累计完成数量
|
||||||
|
BigDecimal completedTotal = value.stream()
|
||||||
|
.map(PgsProgressCategory::getCompleted)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
// 获取类别单位
|
||||||
|
String unit = value.stream()
|
||||||
|
.map(PgsProgressCategory::getUnit)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
// 获取类别类型
|
||||||
|
String unitType = value.stream()
|
||||||
|
.map(PgsProgressCategory::getUnitType)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
// 封装数据
|
||||||
|
PgsProgressCategoryDatePlanVo vo = new PgsProgressCategoryDatePlanVo();
|
||||||
|
vo.setName(name);
|
||||||
|
vo.setUnitType(unitType);
|
||||||
|
vo.setPlanNum(planNumber);
|
||||||
|
vo.setUnit(unit);
|
||||||
|
voList.add(vo);
|
||||||
|
});
|
||||||
|
return voList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取项目进度类别总进度百分比
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @return 项目进度类别总进度百分比
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BigDecimal getTotalProgressPercentage(Long projectId) {
|
||||||
|
// 获取项目和项目子项
|
||||||
|
BusProject project = projectService.getById(projectId);
|
||||||
|
if (project == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
List<BusProject> projects = projectService.lambdaQuery()
|
||||||
|
.eq(BusProject::getPId, projectId)
|
||||||
|
.list();
|
||||||
|
projects.add(project);
|
||||||
|
List<Long> projectIds = projects.stream().map(BusProject::getId).toList();
|
||||||
|
// 获取当前项目所有父级类别
|
||||||
|
List<PgsProgressCategory> topList = this.lambdaQuery()
|
||||||
|
.in(PgsProgressCategory::getProjectId, projectIds)
|
||||||
|
.eq(PgsProgressCategory::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID)
|
||||||
|
.list();
|
||||||
|
if (CollUtil.isEmpty(topList)) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
List<Long> topIds = topList.stream().map(PgsProgressCategory::getId).toList();
|
||||||
|
List<PgsProgressCategory> children = this.getLeafNodesByTopIds(topIds);
|
||||||
|
return this.getCompletedPercentage(children);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出项目进度类别列表
|
* 导出项目进度类别列表
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user