0508优化修改

This commit is contained in:
lzm
2026-05-08 09:32:53 +08:00
parent e3e16f73cc
commit e278ca59bd
7 changed files with 52 additions and 74 deletions

View File

@@ -13,4 +13,7 @@ public class ProjectBudgetExportReqVO {
@NotNull(message = "项目 ID 不能为空")
private Long projectId;
@Schema(description = "导出年度", example = "2026")
private Integer year;
}

View File

@@ -13,4 +13,7 @@ public class ProjectLeadQuarterOutputExportReqVO {
@NotNull(message = "合约规划 ID 不能为空")
private Long planningId;
@Schema(description = "导出年度", example = "2026")
private Integer year;
}

View File

@@ -13,4 +13,7 @@ public class ProjectQuarterOutputExportReqVO {
@NotNull(message = "合约规划 ID 不能为空")
private Long planningId;
@Schema(description = "导出年度", example = "2026")
private Integer year;
}

View File

@@ -18,4 +18,7 @@ public class SpecialtyPersonOutputExportReqVO {
@NotBlank(message = "专业编码不能为空")
private String specialtyCode;
@Schema(description = "导出年度", example = "2026")
private Integer year;
}

View File

@@ -1,15 +1,7 @@
package cn.iocoder.lyzsys.module.tjt.service.report;
import cn.iocoder.lyzsys.framework.common.util.object.BeanUtils;
import cn.iocoder.lyzsys.framework.excel.core.util.ExcelUtils;
import cn.iocoder.lyzsys.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.EmployeeOutputSummaryExcelRespVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.EmployeeOutputSummaryExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectBudgetExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectLeadQuarterOutputExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectOverviewExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectQuarterOutputExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.SpecialtyPersonOutputExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.*;
import cn.iocoder.lyzsys.module.tjt.controller.admin.specialtyrolesplit.vo.SpecialtyRolePersonRespVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.specialtyrolesplit.vo.SpecialtyRoleSplitRespVO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.employee.EmployeeDO;
@@ -17,8 +9,8 @@ import cn.iocoder.lyzsys.module.tjt.dal.dataobject.employeeyearcostbudget.Employ
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.office.OfficeDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.outputsplit.ProjectOutputSplitDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.planning.ProjectPlanningDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.planningquarter.ProjectPlanningQuarterDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.planningguidedetail.ProjectPlanningGuideDetailDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.planningquarter.ProjectPlanningQuarterDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.project.ProjectDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.projectroleperson.ProjectRolePersonDO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.yearkvalue.YearKValueDO;
@@ -34,12 +26,7 @@ import cn.iocoder.lyzsys.module.tjt.enums.OutputSplitBizConstants;
import cn.iocoder.lyzsys.module.tjt.enums.ProjectPlanningBizTypeConstants;
import cn.iocoder.lyzsys.module.tjt.service.outputsplit.ProjectOutputSplitService;
import cn.iocoder.lyzsys.module.tjt.service.planningguidedetail.ProjectPlanningGuideDetailService;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.EmployeeOutputSummaryExcelBuilder;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.ProjectBudgetExcelBuilder;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.ProjectLeadQuarterOutputExcelBuilder;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.ProjectOverviewOutputExcelBuilder;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.ProjectQuarterOutputExcelBuilder;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.SpecialtyPersonOutputExcelBuilder;
import cn.iocoder.lyzsys.module.tjt.service.report.builder.*;
import cn.iocoder.lyzsys.module.tjt.service.specialtyrolesplit.SpecialtyRoleSplitService;
import lombok.Data;
import org.springframework.stereotype.Service;
@@ -51,24 +38,12 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.lyzsys.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.lyzsys.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
import static cn.iocoder.lyzsys.module.tjt.enums.ErrorCodeConstants.OFFICE_NOT_EXISTS;
import static cn.iocoder.lyzsys.module.tjt.enums.ErrorCodeConstants.PROJECT_NOT_EXISTS;
import static cn.iocoder.lyzsys.module.tjt.enums.ErrorCodeConstants.PROJECT_PLANNING_NOT_EXISTS;
import static cn.iocoder.lyzsys.module.tjt.enums.ErrorCodeConstants.SPECIALTY_ROLE_SPLIT_SPECIALTY_INVALID;
import static cn.iocoder.lyzsys.module.tjt.enums.ErrorCodeConstants.*;
@Service
@Validated
@@ -124,6 +99,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
public void exportProjectBudgetExcel(HttpServletResponse response, ProjectBudgetExportReqVO reqVO)
throws IOException {
ProjectDO project = validateProjectExists(reqVO.getProjectId());
Integer reportYear = resolveExportYear(reqVO.getYear());
List<ProjectPlanningDO> planningList = sortPlanningList(projectPlanningMapper.selectListByProjectId(project.getId()));
List<ProjectRolePersonDO> rolePersons = projectRolePersonMapper.selectListByProjectId(project.getId());
Map<Long, List<ProjectPlanningQuarterDO>> quarterMap = getQuarterMap(planningList);
@@ -157,11 +133,11 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
data.setTotalAssessmentArea(totalAssessmentArea);
data.setTotalAssessmentOutputValue(totalAssessmentOutputValue);
data.setTotalAssessmentOutputValueWan(amountToWan(totalAssessmentOutputValue));
data.setQuarterBudgetRows(buildQuarterBudgetRows(planningList, quarterMap, LocalDate.now().getYear()));
data.setQuarterBudgetRows(buildQuarterBudgetRows(planningList, quarterMap, reportYear));
data.setYearRangeText(buildProjectBudgetYearRangeText(planningList, quarterMap));
projectBudgetExcelBuilder.writeWorkbook(response,
buildFileName(project.getProjectName(), "项目考核产值预算表"),
buildFileName(project.getProjectName(), reportYear, "项目考核产值预算表"),
projectBudgetExcelBuilder.build(data));
}
@@ -170,7 +146,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
throws IOException {
ProjectPlanningDO anchorPlanning = validatePlanningExists(reqVO.getPlanningId());
ProjectDO project = validateProjectExists(anchorPlanning.getProjectId());
Integer reportYear = LocalDate.now().getYear();
Integer reportYear = resolveExportYear(reqVO.getYear());
List<ProjectPlanningDO> planningList = sortPlanningList(projectPlanningMapper.selectListByProjectId(project.getId()));
Map<Long, List<ProjectPlanningQuarterDO>> quarterMap = getQuarterMap(planningList);
Map<Long, ProjectOutputSplitDO> outputSplitMap = getExistingOutputSplitMap(planningList);
@@ -184,7 +160,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
data.setRows(buildProjectQuarterOutputRows(planningList, quarterMap, outputSplitMap, reportYear));
projectQuarterOutputExcelBuilder.writeWorkbook(response,
buildFileName(project.getProjectName(), "专业间项目考核产值年度季度计取表"),
buildFileName(project.getProjectName(), reportYear, "专业间项目考核产值年度季度计取表"),
projectQuarterOutputExcelBuilder.build(data));
}
@@ -194,7 +170,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
throws IOException {
ProjectPlanningDO anchorPlanning = validatePlanningExists(reqVO.getPlanningId());
ProjectDO project = validateProjectExists(anchorPlanning.getProjectId());
Integer reportYear = LocalDate.now().getYear();
Integer reportYear = resolveExportYear(reqVO.getYear());
List<ProjectPlanningDO> planningList = projectPlanningMapper.selectListByProjectId(project.getId()).stream()
.sorted(Comparator
.comparingInt((ProjectPlanningDO item) -> projectLeadOutputTypeOrder(item.getOwnershipType()))
@@ -264,7 +240,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
data.setRows(rows);
projectLeadQuarterOutputExcelBuilder.writeWorkbook(response,
buildFileName(project.getProjectName(), "项目经理工程负责人工作量及考核产值表"),
buildFileName(project.getProjectName(), reportYear, "项目经理工程负责人工作量及考核产值表"),
projectLeadQuarterOutputExcelBuilder.build(data));
}
@@ -274,7 +250,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
validateSpecialtyCode(reqVO.getSpecialtyCode());
ProjectPlanningDO anchorPlanning = validatePlanningExists(reqVO.getPlanningId());
ProjectDO project = validateProjectExists(anchorPlanning.getProjectId());
Integer reportYear = LocalDate.now().getYear();
Integer reportYear = resolveExportYear(reqVO.getYear());
List<ProjectPlanningDO> planningList = sortPlanningList(projectPlanningMapper.selectListByProjectId(project.getId()));
Map<Long, List<ProjectPlanningQuarterDO>> quarterMap = getQuarterMap(planningList);
List<ProjectPlanningDO> relevantPlanningList = planningList.stream()
@@ -321,15 +297,14 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
roleSplitMap, project.getProjectName(), reqVO.getSpecialtyCode(), reportYear));
specialtyPersonOutputExcelBuilder.writeWorkbook(response,
buildFileName(project.getProjectName(),
data.getSpecialtyName() + "专业内人员年度季度计取表"),
buildFileName(project.getProjectName(), reportYear, data.getSpecialtyName() + "专业内人员年度季度计取表"),
specialtyPersonOutputExcelBuilder.build(data));
}
@Override
public void exportProjectOverviewExcel(HttpServletResponse response, ProjectOverviewExportReqVO reqVO)
throws IOException {
Integer reportYear = reqVO.getYear() == null ? LocalDate.now().getYear() : reqVO.getYear();
Integer reportYear = resolveExportYear(reqVO.getYear());
OfficeDO office = validateOfficeExists(reqVO.getOfficeId());
List<EmployeeDO> employeeList = employeeMapper.selectList(new LambdaQueryWrapperX<EmployeeDO>()
.eq(EmployeeDO::getOfficeId, reqVO.getOfficeId())
@@ -386,7 +361,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
data.setTotalRow(buildProjectOverviewTotalRow(new ArrayList<>(accumulatorMap.values()), employeeList));
projectOverviewOutputExcelBuilder.writeWorkbook(response,
buildFileName(office.getOfficeName(), "项目总览表"),
buildFileName(office.getOfficeName(), reportYear, "项目总览表"),
projectOverviewOutputExcelBuilder.build(data));
}
@@ -408,7 +383,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
data.setKValue(kValue);
data.setRows(Collections.emptyList());
employeeOutputSummaryExcelBuilder.writeWorkbook(response,
buildFileName(String.valueOf(reqVO.getYear()), "员工个人考核产值汇总"),
buildFileName("员工个人考核产值", reqVO.getYear(), "汇总"),
employeeOutputSummaryExcelBuilder.build(data));
return;
}
@@ -509,7 +484,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
data.setKValue(kValue);
data.setRows(rows);
employeeOutputSummaryExcelBuilder.writeWorkbook(response,
buildFileName(String.valueOf(reqVO.getYear()), "员工个人考核产值汇总"),
buildFileName("员工个人考核产值", reqVO.getYear(), "汇总"),
employeeOutputSummaryExcelBuilder.build(data));
}
@@ -1072,6 +1047,10 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
return planning.getPlanningStartYear() == null ? LocalDate.now().getYear() : planning.getPlanningStartYear();
}
private Integer resolveExportYear(Integer year) {
return year == null ? LocalDate.now().getYear() : year;
}
private List<Integer> resolveBudgetYears(ProjectPlanningDO planning, List<ProjectPlanningQuarterDO> quarterList) {
Set<Integer> yearSet = new LinkedHashSet<>();
if (planning != null && planning.getPlanningStartYear() != null) {
@@ -1889,6 +1868,13 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
return sanitizeFileName(prefix) + "_" + sanitizeFileName(suffix) + ".xlsx";
}
private String buildFileName(String prefix, Integer reportYear, String suffix) {
if (reportYear == null) {
return buildFileName(prefix, suffix);
}
return sanitizeFileName(prefix) + "_" + reportYear + "_" + sanitizeFileName(suffix) + ".xlsx";
}
private String sanitizeFileName(String value) {
if (value == null || value.trim().isEmpty()) {
return "报表";