|
|
@@ -397,6 +397,26 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
data.setType(type);
|
|
|
}
|
|
|
|
|
|
+ // 构建行号映射(新增时使用序号作为行号)
|
|
|
+ Map<String, Integer> rowIdToExcelRowMap = new HashMap<>();
|
|
|
+ Set<String> uniqueRowIds = new HashSet<>();
|
|
|
+ int rowNum = 1;
|
|
|
+ for (CostSurveyTemplateUploadData data : dataList) {
|
|
|
+ String rowid = data.getRowid();
|
|
|
+ if (StringUtil.isNotEmpty(rowid) && !uniqueRowIds.contains(rowid)) {
|
|
|
+ rowIdToExcelRowMap.put(rowid, rowNum++);
|
|
|
+ uniqueRowIds.add(rowid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验数据(和导入时一样的校验)
|
|
|
+ List<String> errors = verifyImportData(dataList, type, surveyTemplateId, rowIdToExcelRowMap);
|
|
|
+ if (!errors.isEmpty()) {
|
|
|
+ CommonResult<String> result = CommonResult.<String>error().message("保存失败,发现以下问题:<br>" + String.join("<br>", errors));
|
|
|
+ result.setCode(250);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
// 计算并设置 orderNum(仅针对核定表 type=3)
|
|
|
if ("3".equals(type) && StringUtil.isNotEmpty(surveyTemplateId)) {
|
|
|
// 收集所有 rowId 和 parentId
|
|
|
@@ -745,7 +765,7 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
}
|
|
|
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
- String sheetName = "成本调查表";
|
|
|
+ String sheetName = templateName;
|
|
|
Sheet sheet = workbook.createSheet(sheetName);
|
|
|
|
|
|
// 创建样式
|
|
|
@@ -934,7 +954,7 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
|
|
|
// 5.返回excel
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
- String sheetName = "财务数据表";
|
|
|
+ String sheetName = templateName;
|
|
|
Sheet sheet = workbook.createSheet(sheetName);
|
|
|
|
|
|
// 创建样式
|
|
|
@@ -1079,7 +1099,7 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
costVerifyTemplateItemsDao.selectByVerifyTemplateId(surveyTemplateId, null);
|
|
|
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
- String sheetName = "核定表";
|
|
|
+ String sheetName = template.getSurveyTemplateName();
|
|
|
Sheet sheet = workbook.createSheet(sheetName);
|
|
|
|
|
|
// 创建样式
|
|
|
@@ -1437,7 +1457,7 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
costSurveyTemplateUploadDataManager.saveData(dataList);
|
|
|
|
|
|
// 更新上传状态
|
|
|
- CostSurveyTemplateUpload upload = costSurveyTemplateUploadManager.getById(materialId);
|
|
|
+ CostSurveyTemplateUpload upload = costSurveyTemplateUploadManager.getById(refId);
|
|
|
if (upload != null) {
|
|
|
upload.setIsUpload("1");
|
|
|
costSurveyTemplateUploadManager.updateById(upload);
|
|
|
@@ -1673,8 +1693,10 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
costSurveyTemplateUploadDataManager.saveData(dataList);
|
|
|
if (materialId != null) {
|
|
|
CostProjectTaskMaterial material = costProjectTaskMaterialManager.getById(materialId);
|
|
|
- material.setIsUpload("1");
|
|
|
- costProjectTaskMaterialManager.updateById(material);
|
|
|
+ if (material != null) {
|
|
|
+ material.setIsUpload("1");
|
|
|
+ costProjectTaskMaterialManager.updateById(material);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return CommonResult.<String>ok().message("导入成功,共导入 " + dataRowCount + " 行数据");
|