08-27-分项工程单价导入修改

This commit is contained in:
2025-08-27 17:32:36 +08:00
parent 3d57edf374
commit f7940e23fa

View File

@ -92,26 +92,70 @@ public class PgsProgressCategoryController extends BaseController {
@Log(title = "进度类别", businessType = BusinessType.EXPORT)
@Transactional
@PostMapping("/export")
public void export(@RequestBody Map<String, List<String>> ids, HttpServletResponse response) throws IOException {
List<List<PgsProgressCategoryVo>> voList = new ArrayList<>();
List<String> sheetNames = new ArrayList<>();
List<Long> idss = new ArrayList<>();
public void export(@RequestBody Map<String, String> projectId , HttpServletResponse response) throws IOException {
List<String> idStrings = ids.get("ids");
for (String idString : idStrings) {
idss.add(Long.valueOf(idString));
LambdaQueryWrapper<PgsProgressCategory> queryWrapper = new LambdaQueryWrapper<>();
//根据projectid拿到整个数据
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getProjectId, projectId.get("projectId"));
List<PgsProgressCategory> list = pgsProgressCategoryService.list(queryWrapper);
List<Long> ids = new ArrayList<>();
for (PgsProgressCategory pgsProgressCategory : list) {
ids.add(pgsProgressCategory.getId());
}
for (Long id : idss) {
LambdaQueryWrapper<PgsProgressCategory> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getMatrixId, id);
List<PgsProgressCategoryVo> voList1 = pgsProgressCategoryService.getVoList(pgsProgressCategoryService.list(queryWrapper));
voList.add(voList1);
sheetNames.add(matrixService.getById(voList1.getFirst().getMatrixId()).getMatrixName());
//要导出的整个sheet所需要的names
List<String> names = new ArrayList<>();
//要导出的list
List<List<PgsProgressCategoryVo>> listValues = new ArrayList<>();
//获取非方阵类别name 非方阵类别有多级 暂定只有2级 也有可能没有父子关系
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getParentId,0).eq(PgsProgressCategory::getMatrixId,0).in(PgsProgressCategory::getId,ids);
List<PgsProgressCategory> unMatrixList = pgsProgressCategoryService.list(queryWrapper);
if (!unMatrixList.isEmpty()) {
for (PgsProgressCategory unMatrix : unMatrixList) {
//所有非方阵顶类名
names.add(unMatrix.getName());
//寻找子类
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getParentId,unMatrix.getId());
List<PgsProgressCategoryVo> children = pgsProgressCategoryService.getVoList(pgsProgressCategoryService.list(queryWrapper));
if (!children.isEmpty()) {
//寻找孙类 然后添加
List<PgsProgressCategoryVo> grandson = new ArrayList<>();
for (PgsProgressCategoryVo childrenCategory : children) {
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getParentId,childrenCategory.getId());
List<PgsProgressCategoryVo> grandsonCategory = pgsProgressCategoryService.getVoList(pgsProgressCategoryService.list(queryWrapper));
if (!grandsonCategory.isEmpty()) {
grandson.addAll(grandsonCategory);
}else {
grandson = children;
}
}
listValues.add(grandson);
}
}
}
ExcelUtil.exportMultiSheetExcelEnhanced(voList, sheetNames, PgsProgressCategoryVo.class, null, response);
//获取矩阵类别name
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getParentId,0).ne(PgsProgressCategory::getMatrixId,0).in(PgsProgressCategory::getId,ids);
List<PgsProgressCategory> matrixList = pgsProgressCategoryService.list(queryWrapper);
if (!matrixList.isEmpty()) {
for (PgsProgressCategory pgsProgressCategory : matrixList) {
//增加矩阵名
names.add(pgsProgressCategory.getName() + "-" + pgsProgressCategory.getMatrixName());
//找到该矩阵下的列表
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PgsProgressCategory::getMatrixId,pgsProgressCategory.getMatrixId());
listValues.add(pgsProgressCategoryService.getVoList(pgsProgressCategoryService.list(queryWrapper)));
}
}
ExcelUtil.exportMultiSheetExcelEnhanced(listValues, names, PgsProgressCategoryVo.class, null, response);
}
/***