|
|
@@ -8,9 +8,8 @@ import com.hotent.base.constants.ApiGroupConsts;
|
|
|
import com.hotent.base.model.CommonResult;
|
|
|
import com.hotent.base.util.StringUtil;
|
|
|
import com.hotent.baseInfo.manager.CostCatalogSurveyManager;
|
|
|
-import com.hotent.baseInfo.manager.CostDictTypeManager;
|
|
|
+import com.hotent.baseInfo.manager.CostCatalogUnitManager;
|
|
|
import com.hotent.baseInfo.model.CostCatalogSurvey;
|
|
|
-import com.hotent.baseInfo.model.CostDictType;
|
|
|
import com.hotent.enterpriseDeclare.manager.CostAuditPeriodRecordManager;
|
|
|
import com.hotent.enterpriseDeclare.manager.CostSurveyTemplateUploadDataManager;
|
|
|
import com.hotent.enterpriseDeclare.model.CostAuditPeriodRecord;
|
|
|
@@ -21,7 +20,10 @@ import com.hotent.project.manager.CostProjectTaskMaterialManager;
|
|
|
import com.hotent.project.model.CostProjectApproval;
|
|
|
import com.hotent.project.model.CostProjectTask;
|
|
|
import com.hotent.project.model.CostProjectTaskMaterial;
|
|
|
-import com.hotent.surveyinfo.dao.*;
|
|
|
+import com.hotent.surveyinfo.dao.CostSurveyFdTemplateItemsDao;
|
|
|
+import com.hotent.surveyinfo.dao.CostSurveyTemplateItemsDao;
|
|
|
+import com.hotent.surveyinfo.dao.CostVerifyTemplateHeadersDao;
|
|
|
+import com.hotent.surveyinfo.dao.CostVerifyTemplateItemsDao;
|
|
|
import com.hotent.surveyinfo.manager.*;
|
|
|
import com.hotent.surveyinfo.model.*;
|
|
|
import com.hotent.surveyinfo.model.dto.CostItemData;
|
|
|
@@ -36,7 +38,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.nfunk.jep.JEP;
|
|
|
-import org.nfunk.jep.function.Str;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -71,17 +72,12 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
private CostSurveyTemplateVersionManager costSurveyTemplateVersionManager;
|
|
|
|
|
|
@Autowired
|
|
|
- private CostSurveyTemplateHeadersDao costSurveyTemplateHeadersDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private CostSurveyTemplateItemsDao costSurveyTemplateItemsDao;
|
|
|
@Resource
|
|
|
DataDictManager dataDictManager;
|
|
|
@Resource
|
|
|
SysTypeManager sysTypeManager;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// 财务数据表相关
|
|
|
@Autowired
|
|
|
private CostSurveyFdTemplateManager costSurveyFdTemplateManager;
|
|
|
@@ -90,9 +86,6 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
private CostSurveyFdTemplateVersionManager costSurveyFdTemplateVersionManager;
|
|
|
|
|
|
@Autowired
|
|
|
- private CostSurveyFdTemplateHeadersDao costSurveyFdTemplateHeadersDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private CostSurveyFdTemplateItemsDao costSurveyFdTemplateItemsDao;
|
|
|
|
|
|
// 核定表
|
|
|
@@ -106,7 +99,6 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
private CostVerifyTemplateItemsDao costVerifyTemplateItemsDao;
|
|
|
|
|
|
|
|
|
- // 通用组件
|
|
|
@Autowired
|
|
|
private CostSurveyTemplateUploadManager costSurveyTemplateUploadManager;
|
|
|
@Autowired
|
|
|
@@ -131,11 +123,17 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
private CostSurveyFdTemplateHeadersManager costSurveyFdTemplateHeadersManager;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CostCatalogSurveyManager costCatalogSurveyManager;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CostCatalogUnitManager costCatalogUnitManager;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 企业报送-调查表-列表
|
|
|
*
|
|
|
* @param taskId 任务ID
|
|
|
- * @param catalogId 目录ID(成本调查表使用)
|
|
|
* @param type 类型:1-成本调查表 2-财务数据表
|
|
|
* @return 上传记录列表
|
|
|
* @throws Exception
|
|
|
@@ -145,21 +143,21 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
public CommonResult<?> listByTaskId(
|
|
|
@ApiParam(name = "taskId", value = "任务ID", required = true)
|
|
|
@RequestParam(required = true) String taskId,
|
|
|
- @ApiParam(name = "catalogId", value = "目录ID(成本调查表使用)")
|
|
|
- @RequestParam(required = false) String catalogId,
|
|
|
@ApiParam(name = "type", value = "类型:1-成本调查表 2-财务数据表", required = true)
|
|
|
@RequestParam(required = true) String type) throws Exception {
|
|
|
+ CostProjectTask task = costProjectTaskManager.getById(taskId);
|
|
|
|
|
|
switch (type) {
|
|
|
case "1": {
|
|
|
+ List<CostCatalogSurvey> list = costCatalogSurveyManager.list(
|
|
|
+ new LambdaQueryWrapper<CostCatalogSurvey>().eq(CostCatalogSurvey::getCatalogId, task.getCatalogId())
|
|
|
+ );
|
|
|
// 成本调查表逻辑
|
|
|
List<CostSurveyTemplateUpload> uploadList = costSurveyTemplateUploadManager.listByTaskId(taskId);
|
|
|
//创建记录
|
|
|
if (uploadList.isEmpty()) {
|
|
|
- CostProjectTask task = costProjectTaskManager.getById(taskId);
|
|
|
- CostProjectApproval approval = costProjectApprovalManager.getById(task.getProjectId());
|
|
|
- List<CostSurveyTemplate> costSurveyTemplates = costSurveyTemplateManager.taskListByCatalogId(approval.getCatalogId());
|
|
|
- for (CostSurveyTemplate template : costSurveyTemplates) {
|
|
|
+ for (CostCatalogSurvey survey : list) {
|
|
|
+ CostSurveyTemplate template = costSurveyTemplateManager.getById(survey.getSurveyId());
|
|
|
CostSurveyTemplateUpload upload = new CostSurveyTemplateUpload();
|
|
|
upload.setSurveyTemplateId(template.getSurveyTemplateId());
|
|
|
upload.setSurveyTemplateName(template.getSurveyTemplateName());
|
|
|
@@ -175,7 +173,6 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
}
|
|
|
List<CostSurveyTemplateUpload> costSurveyTemplateUploads = costSurveyTemplateUploadManager.listByTaskId(taskId);
|
|
|
for (CostSurveyTemplateUpload costSurveyTemplateUpload : costSurveyTemplateUploads) {
|
|
|
- CostProjectTask task = costProjectTaskManager.getById(taskId);
|
|
|
costSurveyTemplateUpload.setAuditedUnitId(task.getAuditedUnitId());
|
|
|
}
|
|
|
return CommonResult.ok().value(costSurveyTemplateUploads);
|
|
|
@@ -186,7 +183,6 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
wrapper.eq("task_id", taskId);
|
|
|
List<CostProjectTaskMaterial> materialList = costProjectTaskMaterialManager.list(wrapper);
|
|
|
for (CostProjectTaskMaterial costProjectTaskMaterial : materialList) {
|
|
|
- CostProjectTask task = costProjectTaskManager.getById(taskId);
|
|
|
costProjectTaskMaterial.setAuditedUnitId(task.getAuditedUnitId()); ;
|
|
|
}
|
|
|
return CommonResult.ok().value(materialList);
|
|
|
@@ -1144,10 +1140,10 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
// 固定表和动态表必须包含行ID和父行ID列
|
|
|
if ("2".equals(templateType) || "3".equals(templateType)) {
|
|
|
if (rowIdColumnIndex == null) {
|
|
|
- return CommonResult.<String>error().message("固定表/动态表导入失败:Excel文件缺少【行ID】列。请使用系统导出的模板,不要删除隐藏列。");
|
|
|
+ return CommonResult.<String>error().message("固定表/动态表导入失败:请使用系统导出的模板,不要删除隐藏列。");
|
|
|
}
|
|
|
if (parentIdColumnIndex == null) {
|
|
|
- return CommonResult.<String>error().message("固定表/动态表导入失败:Excel文件缺少【父行ID】列。请使用系统导出的模板,不要删除隐藏列。");
|
|
|
+ return CommonResult.<String>error().message("固定表/动态表导入失败:请使用系统导出的模板,不要删除隐藏列。");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1755,6 +1751,35 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
return errors;
|
|
|
}
|
|
|
|
|
|
+ // 0. 检查是否修改了已有数据
|
|
|
+ String refId = dataList.get(0).getRefId();
|
|
|
+ if (StringUtil.isNotEmpty(refId)) {
|
|
|
+ QueryWrapper<CostSurveyTemplateUploadData> existingWrapper = new QueryWrapper<>();
|
|
|
+ existingWrapper.eq("ref_id", refId).eq("type", type).eq("is_deleted", "0");
|
|
|
+ List<CostSurveyTemplateUploadData> existingDataList = costSurveyTemplateUploadDataManager.list(existingWrapper);
|
|
|
+
|
|
|
+ if (!existingDataList.isEmpty()) {
|
|
|
+ // 构建已有数据的映射:rowid_rkey -> rvalue
|
|
|
+ Map<String, String> existingDataMap = new HashMap<>();
|
|
|
+ for (CostSurveyTemplateUploadData data : existingDataList) {
|
|
|
+ String key = data.getRowid() + "_" + data.getRkey();
|
|
|
+ existingDataMap.put(key, data.getRvalue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查导入数据是否修改了已有数据
|
|
|
+ for (CostSurveyTemplateUploadData data : dataList) {
|
|
|
+ String key = data.getRowid() + "_" + data.getRkey();
|
|
|
+ String existingValue = existingDataMap.get(key);
|
|
|
+ if (existingValue != null && !existingValue.equals(data.getRvalue())) {
|
|
|
+ Integer excelRowNum = rowIdToExcelRowMap.get(data.getRowid());
|
|
|
+ String rowInfo = excelRowNum != null ? "第" + excelRowNum + "行" : "行[" + data.getRowid() + "]";
|
|
|
+ errors.add(String.format("%s 字段[%s] 不能修改已有数据。原值:%s,新值:%s",
|
|
|
+ rowInfo, data.getRkey(), existingValue, data.getRvalue()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取模板类型(templateType)
|
|
|
String templateType = getTemplateType(type, surveyTemplateId);
|
|
|
|
|
|
@@ -1899,13 +1924,23 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
.filter(StringUtil::isNotEmpty)
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
- int expectedRowCount = templateRowIds.size();
|
|
|
- int actualRowCount = rowDataMap.size();
|
|
|
+ Set<String> actualRowIds = rowDataMap.keySet();
|
|
|
+
|
|
|
+ // 2. 校验行数是否匹配(检查rowId集合是否完全相同)
|
|
|
+ if (!actualRowIds.equals(templateRowIds)) {
|
|
|
+ Set<String> missingRowIds = new HashSet<>(templateRowIds);
|
|
|
+ missingRowIds.removeAll(actualRowIds);
|
|
|
+ Set<String> extraRowIds = new HashSet<>(actualRowIds);
|
|
|
+ extraRowIds.removeAll(templateRowIds);
|
|
|
|
|
|
- // 2. 校验行数是否匹配
|
|
|
- if (actualRowCount != expectedRowCount) {
|
|
|
- errors.add(String.format("固定表行数不匹配!模板定义:%d 行,导入数据:%d 行。固定表不允许增加或减少行。",
|
|
|
- expectedRowCount, actualRowCount));
|
|
|
+ StringBuilder errorMsg = new StringBuilder("固定表行不匹配!");
|
|
|
+ if (!missingRowIds.isEmpty()) {
|
|
|
+ errorMsg.append("缺少行:").append(String.join(", ", missingRowIds)).append(";");
|
|
|
+ }
|
|
|
+ if (!extraRowIds.isEmpty()) {
|
|
|
+ errorMsg.append("多余行:").append(String.join(", ", extraRowIds)).append(";");
|
|
|
+ }
|
|
|
+ errors.add(errorMsg.toString());
|
|
|
}
|
|
|
|
|
|
// 3. 校验每一行的字段是否完整
|
|
|
@@ -3490,18 +3525,12 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 5. 检查是否有多余的表头
|
|
|
- Set<String> extraHeaders = new HashSet<>(actualHeaders);
|
|
|
- extraHeaders.removeAll(expectedHeaders);
|
|
|
- if (!extraHeaders.isEmpty()) {
|
|
|
- errors.add(String.format("Excel文件包含多余的表头列:%s", String.join("、", extraHeaders)));
|
|
|
- }
|
|
|
-
|
|
|
- // 6. 检查是否缺少必需的表头
|
|
|
- Set<String> missingHeaders = new HashSet<>(expectedHeaders);
|
|
|
- missingHeaders.removeAll(actualHeaders);
|
|
|
- if (!missingHeaders.isEmpty()) {
|
|
|
- errors.add(String.format("Excel文件缺少必需的表头列:%s", String.join("、", missingHeaders)));
|
|
|
+ // 5. 检查表头是否完全匹配
|
|
|
+ if (!actualHeaders.equals(expectedHeaders)) {
|
|
|
+ Set<String> displayHeaders = new HashSet<>(expectedHeaders);
|
|
|
+ displayHeaders.remove("行ID");
|
|
|
+ displayHeaders.remove("父行ID");
|
|
|
+ errors.add(String.format("表头校验不通过,应该的表头是:%s,请使用系统导出的模板", String.join("、", displayHeaders)));
|
|
|
}
|
|
|
|
|
|
return errors;
|
|
|
@@ -3557,18 +3586,12 @@ public class CostProjectTaskSurveyGenericController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 5. 检查是否有多余的表头
|
|
|
- Set<String> extraHeaders = new HashSet<>(actualHeaders);
|
|
|
- extraHeaders.removeAll(expectedHeaders);
|
|
|
- if (!extraHeaders.isEmpty()) {
|
|
|
- errors.add(String.format("Excel文件包含多余的表头列:%s", String.join("、", extraHeaders)));
|
|
|
- }
|
|
|
-
|
|
|
- // 6. 检查是否缺少必需的表头
|
|
|
- Set<String> missingHeaders = new HashSet<>(expectedHeaders);
|
|
|
- missingHeaders.removeAll(actualHeaders);
|
|
|
- if (!missingHeaders.isEmpty()) {
|
|
|
- errors.add(String.format("Excel文件缺少必需的表头列:%s", String.join("、", missingHeaders)));
|
|
|
+ // 5. 检查表头是否完全匹配
|
|
|
+ if (!actualHeaders.equals(expectedHeaders)) {
|
|
|
+ Set<String> displayHeaders = new HashSet<>(expectedHeaders);
|
|
|
+ displayHeaders.remove("行ID");
|
|
|
+ displayHeaders.remove("父行ID");
|
|
|
+ errors.add(String.format("表头校验不通过,应该的表头是:%s,请使用系统导出的模板", String.join("、", displayHeaders)));
|
|
|
}
|
|
|
|
|
|
return errors;
|