3 Incheckningar 1ca95fd162 ... d0d2e5706c

Upphovsman SHA1 Meddelande Datum
  zzw d0d2e5706c Merge remote-tracking branch 'cs/master' 2 dagar sedan
  zzw 8e9edf03da fix:调查表调整 2 dagar sedan
  zzw a7b81b36a3 fix:调查表调整 2 dagar sedan

+ 6 - 6
assembly/src/main/resources/application-dev.yml

@@ -201,14 +201,14 @@ third:
 archive:
   template:
     # 案卷封面模板路径
-    coverPath: D:/fx/1、卷宗封面.docx
-#    coverPath: /www/fx/1、卷宗封面.docx
+#    coverPath: D:/fx/1、卷宗封面.docx
+    coverPath: /www/fx/1、卷宗封面.docx
 #     卷内目录模板路径
-    catalogPath: D:/fx/2、卷内目录.docx
-#    catalogPath: /www/fx/2、卷内目录.docx
+#    catalogPath: D:/fx/2、卷内目录.docx
+    catalogPath: /www/fx/2、卷内目录.docx
 #     案卷封底模板路径
-    backCoverPath: D:/fx/3、案卷封底.docx
-#    backCoverPath: /www/fx/3、案卷封底.docx
+#    backCoverPath: D:/fx/3、案卷封底.docx
+    backCoverPath: /www/fx/3、案卷封底.docx
 assistmg:
   profile: /home/eip/uploadPath
   imgUrl: http://1.71.9.215:9506

+ 4 - 0
assistMg/src/main/java/com/hotent/baseInfo/manager/impl/AuditedUnitManagerImpl.java

@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -165,6 +166,9 @@ public class AuditedUnitManagerImpl extends BaseManagerImpl<AuditedUnitDao, Audi
 
     @Override
     public List<AuditedUnit> getByIds(List<String> list) {
+        if(list == null || list.size() == 0){
+            return new ArrayList<>();
+        }
         QueryWrapper<AuditedUnit> wrapper = new QueryWrapper<>();
         wrapper.in("unit_id",list);
         return this.list(wrapper);

+ 1 - 1
assistMg/src/main/java/com/hotent/enterpriseDeclare/controller/material/CostProjectTaskProccessNodeController.java

@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
  */
 @RestController
 @RequestMapping("/api/taskProccess/v1/")
-@Api(tags = "成本调查表")
+@Api(tags = "监审工作流程")
 @ApiGroup(group = {ApiGroupConsts.GROUP_COST})
 public class CostProjectTaskProccessNodeController {
 

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 403 - 235
assistMg/src/main/java/com/hotent/enterpriseDeclare/controller/material/CostProjectTaskSurveyGenericController.java


+ 1 - 1
assistMg/src/main/java/com/hotent/enterpriseDeclare/controller/material/CostProjectTaskVerifyTemplateController.java

@@ -54,7 +54,7 @@ import java.util.stream.Collectors;
  */
 @RestController
 @RequestMapping("/api/verify/Template/v1/")
-@Api(tags = "成本调查表")
+@Api(tags = "核定表")
 @ApiGroup(group = {ApiGroupConsts.GROUP_COST})
 public class CostProjectTaskVerifyTemplateController {
 

+ 766 - 0
assistMg/src/main/java/com/hotent/enterpriseDeclare/service/CostSurveyExcelAsyncService.java

@@ -0,0 +1,766 @@
+package com.hotent.enterpriseDeclare.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.hotent.base.util.FileUtil;
+import com.hotent.base.util.StringUtil;
+import com.hotent.baseInfo.vo.FileUploadResult;
+import com.hotent.config.EipConfig;
+import com.hotent.enterpriseDeclare.manager.CostSurveyTemplateUploadDataManager;
+import com.hotent.enterpriseDeclare.model.CostSurveyTemplateUploadData;
+import com.hotent.project.manager.CostProjectApprovalManager;
+import com.hotent.project.manager.CostProjectTaskManager;
+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.CostSurveyFdTemplateItemsDao;
+import com.hotent.surveyinfo.dao.CostSurveyTemplateItemsDao;
+import com.hotent.surveyinfo.manager.*;
+import com.hotent.surveyinfo.model.*;
+import com.hotent.util.ExcelStyleUtil;
+import com.hotent.util.FileUploadUtil;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 成本调查表Excel异步生成服务
+ */
+@Service
+public class CostSurveyExcelAsyncService {
+
+    @Autowired
+    private CostProjectTaskManager costProjectTaskManager;
+
+    @Autowired
+    private CostProjectApprovalManager costProjectApprovalManager;
+
+    @Autowired
+    private CostSurveyTemplateManager costSurveyTemplateManager;
+
+    @Autowired
+    private CostSurveyTemplateVersionManager costSurveyTemplateVersionManager;
+
+    @Autowired
+    private CostSurveyTemplateHeadersManager costSurveyTemplateHeadersManager;
+
+    @Autowired
+    private CostSurveyTemplateItemsDao costSurveyTemplateItemsDao;
+
+    @Autowired
+    private CostSurveyTemplateUploadManager costSurveyTemplateUploadManager;
+
+    @Autowired
+    private CostSurveyTemplateUploadDataManager costSurveyTemplateUploadDataManager;
+
+    @Autowired
+    private CostSurveyFdTemplateManager costSurveyFdTemplateManager;
+
+    @Autowired
+    private CostSurveyFdTemplateVersionManager costSurveyFdTemplateVersionManager;
+
+    @Autowired
+    private CostSurveyFdTemplateHeadersManager costSurveyFdTemplateHeadersManager;
+
+    @Autowired
+    private CostSurveyFdTemplateItemsDao costSurveyFdTemplateItemsDao;
+
+    @Autowired
+    private CostProjectTaskMaterialManager costProjectTaskMaterialManager;
+
+    @Autowired
+    private CellDataQueryService cellDataQueryService;
+
+    /**
+     * 异步生成Excel文件并保存到文件服务器
+     * @param type 类型:1-成本调查表 2-财务数据表
+     * @param surveyTemplateId 模板ID
+     * @param taskId 任务ID
+     * @param refId 关联ID(成本调查表的uploadId或财务数据表的materialId)
+     */
+    @Async
+    public void asyncGenerateAndSaveExcel(String type, String surveyTemplateId, String taskId, String refId) {
+        try {
+            generateAndSaveExcelFile(type, surveyTemplateId, taskId, refId);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 生成Excel文件并保存到文件服务器
+     */
+    private void generateAndSaveExcelFile(String type, String surveyTemplateId, String taskId, String refId) throws Exception {
+        // 获取年限数据
+        String[] auditPeriods = null;
+        if (StringUtil.isNotEmpty(taskId)) {
+            CostProjectTask task = costProjectTaskManager.getById(taskId);
+            if (task != null) {
+                CostProjectApproval approval = costProjectApprovalManager.getById(task.getProjectId());
+                if (approval != null && StringUtil.isNotEmpty(approval.getAuditPeriod())) {
+                    auditPeriods = approval.getAuditPeriod().split(",");
+                }
+            }
+        }
+
+        Workbook workbook = new XSSFWorkbook();
+        String fileName;
+
+        if ("1".equals(type)) {
+            fileName = generateCostSurveyExcel(workbook, surveyTemplateId, taskId, refId, auditPeriods);
+        } else if ("2".equals(type)) {
+            fileName = generateFinancialDataExcel(workbook, surveyTemplateId, taskId, refId, auditPeriods);
+        } else {
+            workbook.close();
+            return;
+        }
+
+        // 保存文件到临时目录
+        String tempDir = System.getProperty("java.io.tmpdir");
+        String tempFileName = fileName + "_" + System.currentTimeMillis() + ".xlsx";
+        File tempFile = new File(tempDir, tempFileName);
+
+        try (FileOutputStream fos = new FileOutputStream(tempFile)) {
+            workbook.write(fos);
+        }
+        workbook.close();
+
+        // 上传文件到文件服务器
+        String fileUrl = uploadTempFile(tempFile);
+
+        // 更新数据库中的文件URL
+        if (StringUtil.isNotEmpty(fileUrl)) {
+            if ("1".equals(type)) {
+                CostSurveyTemplateUpload upload = costSurveyTemplateUploadManager.getById(refId);
+                if (upload != null) {
+                    upload.setFileUrl(fileUrl);
+                    costSurveyTemplateUploadManager.updateById(upload);
+                }
+            } else if ("2".equals(type)) {
+                CostProjectTaskMaterial material = costProjectTaskMaterialManager.getById(refId);
+                if (material != null) {
+                    material.setFileUrl(fileUrl);
+                    costProjectTaskMaterialManager.updateById(material);
+                }
+            }
+        }
+
+        // 删除临时文件
+        tempFile.delete();
+    }
+
+    /**
+     * 上传临时文件到文件服务器
+     */
+    private String uploadTempFile(File file) {
+        try {
+            MultipartFile multipartFile = FileUtil.fileToMultipartFile(file);
+            FileUploadResult result = FileUploadUtil.uploadFile(multipartFile, EipConfig.getUploadPath());
+            if (result != null && result.getSavePath() != null) {
+                return EipConfig.getImgUrl() + result.getSavePath();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 生成成本调查表Excel
+     */
+    private String generateCostSurveyExcel(Workbook workbook, String surveyTemplateId, String taskId, String refId, String[] auditPeriods) {
+        CostSurveyTemplate template = costSurveyTemplateManager.getDetail(surveyTemplateId);
+        if (template == null) return "成本调查表";
+
+        String templateName = template.getSurveyTemplateName();
+        String templateType = template.getTemplateType();
+
+        CostSurveyTemplateVersion currentVersion = costSurveyTemplateVersionManager.selectCurrentVersion(surveyTemplateId);
+        if (currentVersion == null) return templateName;
+
+        List<CostSurveyTemplateHeaders> headersList = costSurveyTemplateHeadersManager.listVisibleBySurveyTemplateIdAndVersion(
+                surveyTemplateId, currentVersion.getId()).stream()
+                .filter(header -> StringUtil.isEmpty(header.getShowVisible()) || "1".equals(header.getShowVisible()))
+                .collect(Collectors.toList());
+
+        if (headersList.isEmpty()) return templateName;
+
+        List<CostSurveyTemplateItems> itemsList = costSurveyTemplateItemsDao.selectBySurveyTemplateIdAndVersion(surveyTemplateId, currentVersion.getId());
+
+        QueryWrapper<CostSurveyTemplateUploadData> wrapper = new QueryWrapper<>();
+        wrapper.eq("ref_id", refId).eq("type", "1").eq("is_deleted", "0");
+        List<CostSurveyTemplateUploadData> uploadDataList = costSurveyTemplateUploadDataManager.list(wrapper);
+
+        mergeUploadDataToItems(itemsList, uploadDataList);
+
+        Sheet sheet = workbook.createSheet(templateName);
+        CellStyle titleStyle = ExcelStyleUtil.createTitleStyle(workbook);
+        CellStyle headerStyle = ExcelStyleUtil.createHeaderStyle(workbook);
+        CellStyle dataStyle = ExcelStyleUtil.createDataStyle(workbook);
+
+        Map<String, String> headersIdToUnitMap = new HashMap<>();
+        if (itemsList != null) {
+            for (CostSurveyTemplateItems item : itemsList) {
+                if (StringUtil.isNotEmpty(item.getHeadersId()) && StringUtil.isNotEmpty(item.getUnit())) {
+                    headersIdToUnitMap.putIfAbsent(item.getHeadersId(), item.getUnit());
+                }
+            }
+        }
+
+        int totalColumns = 0;
+        for (CostSurveyTemplateHeaders header : headersList) {
+            if ("true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                totalColumns += auditPeriods.length;
+            } else {
+                totalColumns += 1;
+            }
+        }
+        boolean needExtraColumns = "2".equals(templateType) || "3".equals(templateType);
+        if (needExtraColumns) {
+            totalColumns += 2;
+        }
+
+        Row titleRow = sheet.createRow(0);
+        Cell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue(templateName);
+        titleCell.setCellStyle(titleStyle);
+        if (totalColumns > 1) {
+            sheet.addMergedRegion(new org.apache.poi.ss.util.CellRangeAddress(0, 0, 0, totalColumns - 1));
+        }
+
+        Row headerRow = sheet.createRow(1);
+        int colIndex = 0;
+        for (CostSurveyTemplateHeaders header : headersList) {
+            String fieldName = header.getFieldName();
+            String unit = headersIdToUnitMap.get(header.getId());
+            if ("true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                for (String period : auditPeriods) {
+                    Cell headerCell = headerRow.createCell(colIndex++);
+                    String headerValue = period.trim() + fieldName;
+                    if (StringUtil.isNotEmpty(unit)) {
+                        headerValue = headerValue + "(" + unit + ")";
+                    }
+                    headerCell.setCellValue(headerValue);
+                    headerCell.setCellStyle(headerStyle);
+                }
+            } else {
+                Cell headerCell = headerRow.createCell(colIndex++);
+                String headerValue = StringUtil.isNotEmpty(unit) ? fieldName + "(" + unit + ")" : fieldName;
+                headerCell.setCellValue(headerValue);
+                headerCell.setCellStyle(headerStyle);
+            }
+        }
+
+        int rowIdColIndex = -1;
+        int parentIdColIndex = -1;
+//        if (needExtraColumns) {
+//            rowIdColIndex = colIndex;
+//            Cell rowIdCell = headerRow.createCell(colIndex++);
+//            rowIdCell.setCellValue("行ID");
+//            rowIdCell.setCellStyle(headerStyle);
+//            parentIdColIndex = colIndex;
+//            Cell parentIdCell = headerRow.createCell(colIndex++);
+//            parentIdCell.setCellValue("父行ID");
+//            parentIdCell.setCellStyle(headerStyle);
+//        }
+
+        if (itemsList != null && !itemsList.isEmpty()) {
+            Map<String, Integer> headerIndexMap = new HashMap<>();
+            int idx = 0;
+            for (CostSurveyTemplateHeaders header : headersList) {
+                if ("true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                    headerIndexMap.put(header.getId(), idx);
+                    idx += auditPeriods.length;
+                } else {
+                    headerIndexMap.put(header.getId(), idx);
+                    idx += 1;
+                }
+            }
+            fillExcelData(sheet, itemsList, headerIndexMap, headersList, auditPeriods, templateType, rowIdColIndex, parentIdColIndex, dataStyle, taskId);
+        }
+
+        Row headerRowForWidth = sheet.getRow(1);
+        int totalColsForWidth = headerRowForWidth != null ? headerRowForWidth.getLastCellNum() : headersList.size();
+        for (int i = 0; i < totalColsForWidth; i++) {
+            sheet.autoSizeColumn(i);
+            int autoWidth = sheet.getColumnWidth(i);
+            sheet.setColumnWidth(i, Math.max(autoWidth + 800, 3500));
+        }
+
+        if (rowIdColIndex >= 0) sheet.setColumnHidden(rowIdColIndex, true);
+        if (parentIdColIndex >= 0) sheet.setColumnHidden(parentIdColIndex, true);
+
+        return templateName;
+    }
+
+    /**
+     * 生成财务数据表Excel
+     */
+    private String generateFinancialDataExcel(Workbook workbook, String surveyTemplateId, String taskId, String refId, String[] auditPeriods) {
+        CostSurveyFdTemplate template = costSurveyFdTemplateManager.getDetail(surveyTemplateId);
+        if (template == null) return "财务数据表";
+
+        String templateName = template.getSurveyTemplateName();
+        String templateType = template.getTemplateType();
+
+        CostSurveyFdTemplateVersion currentVersion = costSurveyFdTemplateVersionManager.selectCurrentVersion(surveyTemplateId);
+        if (currentVersion == null) return templateName;
+
+        List<CostSurveyFdTemplateHeaders> headersList = costSurveyFdTemplateHeadersManager.listVisibleBySurveyTemplateIdAndVersion(
+                surveyTemplateId, currentVersion.getId()).stream()
+                .filter(header -> StringUtil.isEmpty(header.getShowVisible()) || "1".equals(header.getShowVisible()))
+                .collect(Collectors.toList());
+
+        if (headersList.isEmpty()) return templateName;
+
+        List<CostSurveyFdTemplateItems> itemsList = costSurveyFdTemplateItemsDao.selectBySurveyTemplateIdAndVersion(surveyTemplateId, currentVersion.getId());
+
+        QueryWrapper<CostSurveyTemplateUploadData> wrapper = new QueryWrapper<>();
+        wrapper.eq("ref_id", refId).eq("type", "2").eq("is_deleted", "0");
+        List<CostSurveyTemplateUploadData> uploadDataList = costSurveyTemplateUploadDataManager.list(wrapper);
+
+        mergeUploadDataToFdItems(itemsList, uploadDataList);
+
+        Sheet sheet = workbook.createSheet(templateName);
+        CellStyle titleStyle = ExcelStyleUtil.createTitleStyle(workbook);
+        CellStyle headerStyle = ExcelStyleUtil.createHeaderStyle(workbook);
+        CellStyle dataStyle = ExcelStyleUtil.createDataStyle(workbook);
+
+        Map<String, String> headersIdToUnitMap = new HashMap<>();
+        if (itemsList != null) {
+            for (CostSurveyFdTemplateItems item : itemsList) {
+                if (StringUtil.isNotEmpty(item.getHeadersId()) && StringUtil.isNotEmpty(item.getUnit())) {
+                    headersIdToUnitMap.putIfAbsent(item.getHeadersId(), item.getUnit());
+                }
+            }
+        }
+
+        int totalColumns = 0;
+        for (CostSurveyFdTemplateHeaders header : headersList) {
+            if ("true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                totalColumns += auditPeriods.length;
+            } else {
+                totalColumns += 1;
+            }
+        }
+        boolean needExtraColumns = "2".equals(templateType) || "3".equals(templateType);
+        if (needExtraColumns) {
+            totalColumns += 2;
+        }
+
+        Row titleRow = sheet.createRow(0);
+        Cell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue(templateName);
+        titleCell.setCellStyle(titleStyle);
+        if (totalColumns > 1) {
+            sheet.addMergedRegion(new org.apache.poi.ss.util.CellRangeAddress(0, 0, 0, totalColumns - 1));
+        }
+
+        Row headerRow = sheet.createRow(1);
+        int colIndex = 0;
+        for (CostSurveyFdTemplateHeaders header : headersList) {
+            String fieldName = header.getFieldName();
+            String unit = headersIdToUnitMap.get(header.getId());
+            if ("true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                for (String period : auditPeriods) {
+                    Cell headerCell = headerRow.createCell(colIndex++);
+                    String headerValue = period.trim() + fieldName;
+                    if (StringUtil.isNotEmpty(unit)) {
+                        headerValue = headerValue + "(" + unit + ")";
+                    }
+                    headerCell.setCellValue(headerValue);
+                    headerCell.setCellStyle(headerStyle);
+                }
+            } else {
+                Cell headerCell = headerRow.createCell(colIndex++);
+                String headerValue = StringUtil.isNotEmpty(unit) ? fieldName + "(" + unit + ")" : fieldName;
+                headerCell.setCellValue(headerValue);
+                headerCell.setCellStyle(headerStyle);
+            }
+        }
+
+        int rowIdColIndex = -1;
+        int parentIdColIndex = -1;
+//        if (needExtraColumns) {
+//            rowIdColIndex = colIndex;
+//            Cell rowIdCell = headerRow.createCell(colIndex++);
+//            rowIdCell.setCellValue("行ID");
+//            rowIdCell.setCellStyle(headerStyle);
+//            parentIdColIndex = colIndex;
+//            Cell parentIdCell = headerRow.createCell(colIndex++);
+//            parentIdCell.setCellValue("父行ID");
+//            parentIdCell.setCellStyle(headerStyle);
+//        }
+
+        if (itemsList != null && !itemsList.isEmpty()) {
+            Map<String, Integer> headerIndexMap = new HashMap<>();
+            int idx = 0;
+            for (CostSurveyFdTemplateHeaders header : headersList) {
+                if ("true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                    headerIndexMap.put(header.getId(), idx);
+                    idx += auditPeriods.length;
+                } else {
+                    headerIndexMap.put(header.getId(), idx);
+                    idx += 1;
+                }
+            }
+            fillExcelDataFd(sheet, itemsList, headerIndexMap, headersList, auditPeriods, templateType, rowIdColIndex, parentIdColIndex, dataStyle, taskId);
+        }
+
+        Row headerRowForWidth = sheet.getRow(1);
+        int totalColsForWidth = headerRowForWidth != null ? headerRowForWidth.getLastCellNum() : headersList.size();
+        for (int i = 0; i < totalColsForWidth; i++) {
+            sheet.autoSizeColumn(i);
+            int autoWidth = sheet.getColumnWidth(i);
+            sheet.setColumnWidth(i, Math.max(autoWidth + 800, 3500));
+        }
+
+        if (rowIdColIndex >= 0) sheet.setColumnHidden(rowIdColIndex, true);
+        if (parentIdColIndex >= 0) sheet.setColumnHidden(parentIdColIndex, true);
+
+        return templateName;
+    }
+
+    /**
+     * 合并上传数据到成本调查表模板项
+     */
+    private void mergeUploadDataToItems(List<CostSurveyTemplateItems> itemsList, List<CostSurveyTemplateUploadData> uploadDataList) {
+        if (itemsList == null || uploadDataList == null || uploadDataList.isEmpty()) return;
+
+        Map<String, String> uploadDataMap = new HashMap<>();
+        for (CostSurveyTemplateUploadData data : uploadDataList) {
+            String key = data.getRowid() + "_" + data.getRkey();
+            uploadDataMap.put(key, data.getRvalue());
+        }
+
+        for (CostSurveyTemplateItems item : itemsList) {
+            String key = item.getRowid() + "_" + item.getHeadersId();
+            if (uploadDataMap.containsKey(key)) {
+                item.setRvalue(uploadDataMap.get(key));
+            }
+        }
+    }
+
+    /**
+     * 合并上传数据到财务数据表模板项
+     */
+    private void mergeUploadDataToFdItems(List<CostSurveyFdTemplateItems> itemsList, List<CostSurveyTemplateUploadData> uploadDataList) {
+        if (itemsList == null || uploadDataList == null || uploadDataList.isEmpty()) return;
+
+        Map<String, String> uploadDataMap = new HashMap<>();
+        for (CostSurveyTemplateUploadData data : uploadDataList) {
+            String key = data.getRowid() + "_" + data.getRkey();
+            uploadDataMap.put(key, data.getRvalue());
+        }
+
+        for (CostSurveyFdTemplateItems item : itemsList) {
+            String key = item.getRowid() + "_" + item.getHeadersId();
+            if (uploadDataMap.containsKey(key)) {
+                item.setRvalue(uploadDataMap.get(key));
+            }
+        }
+    }
+
+    private void fillExcelData(Sheet sheet, List<CostSurveyTemplateItems> itemsList,
+                               Map<String, Integer> headerIndexMap, List<CostSurveyTemplateHeaders> headersList,
+                               String[] auditPeriods, String templateType,
+                               int rowIdColIndex, int parentIdColIndex, CellStyle dataStyle, String taskId) {
+        Map<String, CostSurveyTemplateHeaders> headersMap = headersList.stream()
+                .collect(Collectors.toMap(CostSurveyTemplateHeaders::getId, h -> h));
+
+        if ("1".equals(templateType)) {
+            Row dataRow = sheet.createRow(2);
+            for (CostSurveyTemplateItems item : itemsList) {
+                Integer colIndex = headerIndexMap.get(item.getHeadersId());
+                if (colIndex != null) {
+                    CostSurveyTemplateHeaders header = headersMap.get(item.getHeadersId());
+                    if (header != null && "true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                        for (int i = 0; i < auditPeriods.length; i++) {
+                            Cell cell = dataRow.createCell(colIndex + i);
+                            cell.setCellValue("");
+                            cell.setCellStyle(dataStyle);
+                        }
+                    } else {
+                        Cell cell = dataRow.createCell(colIndex);
+                        String value = item.getRvalue();
+                        if (StringUtil.isEmpty(value) && StringUtil.isNotEmpty(item.getCalculationTemplateId())) {
+                            value = cellDataQueryService.getCellValueByPeriod(taskId, item.getCalculationTemplateId(),
+                                item.getCellCode(), "0", "1");
+                        }
+                        cell.setCellValue(StringUtil.isNotEmpty(value) ? value : "");
+                        cell.setCellStyle(dataStyle);
+                    }
+                }
+            }
+        } else {
+            Map<String, List<CostSurveyTemplateItems>> itemsByRowId = itemsList.stream()
+                    .filter(item -> StringUtil.isNotEmpty(item.getRowid()))
+                    .collect(Collectors.groupingBy(CostSurveyTemplateItems::getRowid));
+
+            List<String> sortedRowIds = sortRowIdsByParentChild(itemsByRowId);
+
+            Row headerRow = sheet.getRow(1);
+            int totalColumns = headerRow != null ? headerRow.getLastCellNum() : 0;
+
+            int rowNum = 2;
+            for (String rowId : sortedRowIds) {
+                List<CostSurveyTemplateItems> rowItems = itemsByRowId.get(rowId);
+                if (rowItems != null && !rowItems.isEmpty()) {
+                    Row dataRow = sheet.createRow(rowNum++);
+
+                    for (CostSurveyTemplateItems item : rowItems) {
+                        Integer colIndex = headerIndexMap.get(item.getHeadersId());
+                        if (colIndex != null) {
+                            CostSurveyTemplateHeaders header = headersMap.get(item.getHeadersId());
+                            if (header != null && "true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                                for (int i = 0; i < auditPeriods.length; i++) {
+                                    Cell cell = dataRow.createCell(colIndex + i);
+                                    cell.setCellValue("");
+                                    cell.setCellStyle(dataStyle);
+                                }
+                            } else {
+                                Cell cell = dataRow.createCell(colIndex);
+                                String value = item.getRvalue();
+                                if (StringUtil.isEmpty(value) && StringUtil.isNotEmpty(item.getCalculationTemplateId())) {
+                                    value = cellDataQueryService.getCellValueByPeriod(taskId, item.getCalculationTemplateId(),
+                                        item.getCellCode(), "0", "1");
+                                }
+                                cell.setCellValue(StringUtil.isNotEmpty(value) ? value : "");
+                                cell.setCellStyle(dataStyle);
+                            }
+                        }
+                    }
+
+                    if (rowIdColIndex >= 0) {
+                        Cell cell = dataRow.createCell(rowIdColIndex);
+                        cell.setCellValue(rowId);
+                        cell.setCellStyle(dataStyle);
+                    }
+                    if (parentIdColIndex >= 0) {
+                        String parentId = rowItems.get(0).getParentid();
+                        Cell cell = dataRow.createCell(parentIdColIndex);
+                        cell.setCellValue(StringUtil.isNotEmpty(parentId) ? parentId : "");
+                        cell.setCellStyle(dataStyle);
+                    }
+
+                    for (int colIndex = 0; colIndex < totalColumns; colIndex++) {
+                        if (dataRow.getCell(colIndex) == null) {
+                            Cell cell = dataRow.createCell(colIndex);
+                            cell.setCellValue("");
+                            cell.setCellStyle(dataStyle);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private List<String> sortRowIdsByParentChild(Map<String, List<CostSurveyTemplateItems>> itemsByRowId) {
+        List<String> result = new ArrayList<>();
+
+        Map<String, String> rowIdToParentId = new HashMap<>();
+        for (Map.Entry<String, List<CostSurveyTemplateItems>> entry : itemsByRowId.entrySet()) {
+            String rowId = entry.getKey();
+            List<CostSurveyTemplateItems> items = entry.getValue();
+            if (!items.isEmpty()) {
+                String parentId = items.get(0).getParentid();
+                rowIdToParentId.put(rowId, parentId);
+            }
+        }
+
+        Set<String> allRowIds = new HashSet<>(itemsByRowId.keySet());
+        List<String> rootRowIds = allRowIds.stream()
+                .filter(rowId -> {
+                    String parentId = rowIdToParentId.get(rowId);
+                    return StringUtil.isEmpty(parentId) || !allRowIds.contains(parentId);
+                })
+                .sorted((id1, id2) -> {
+                    List<CostSurveyTemplateItems> items1 = itemsByRowId.get(id1);
+                    List<CostSurveyTemplateItems> items2 = itemsByRowId.get(id2);
+                    if (items1 == null || items1.isEmpty()) return 1;
+                    if (items2 == null || items2.isEmpty()) return -1;
+                    Integer order1 = items1.get(0).getOrderNum();
+                    Integer order2 = items2.get(0).getOrderNum();
+                    if (order1 == null) return 1;
+                    if (order2 == null) return -1;
+                    return order1.compareTo(order2);
+                })
+                .collect(Collectors.toList());
+
+        for (String rootRowId : rootRowIds) {
+            addRowIdWithChildren(rootRowId, rowIdToParentId, allRowIds, result, itemsByRowId);
+        }
+
+        return result;
+    }
+
+    private void addRowIdWithChildren(String rowId, Map<String, String> rowIdToParentId,
+                                      Set<String> allRowIds, List<String> result, Map<String, List<CostSurveyTemplateItems>> itemsByRowId) {
+        result.add(rowId);
+
+        List<String> children = allRowIds.stream()
+                .filter(id -> rowId.equals(rowIdToParentId.get(id)))
+                .sorted((id1, id2) -> {
+                    List<CostSurveyTemplateItems> items1 = itemsByRowId.get(id1);
+                    List<CostSurveyTemplateItems> items2 = itemsByRowId.get(id2);
+                    if (items1 == null || items1.isEmpty()) return 1;
+                    if (items2 == null || items2.isEmpty()) return -1;
+                    Integer order1 = items1.get(0).getOrderNum();
+                    Integer order2 = items2.get(0).getOrderNum();
+                    if (order1 == null) return 1;
+                    if (order2 == null) return -1;
+                    return order1.compareTo(order2);
+                })
+                .collect(Collectors.toList());
+
+        for (String childRowId : children) {
+            addRowIdWithChildren(childRowId, rowIdToParentId, allRowIds, result, itemsByRowId);
+        }
+    }
+
+    private void fillExcelDataFd(Sheet sheet, List<CostSurveyFdTemplateItems> itemsList,
+                                 Map<String, Integer> headerIndexMap, List<CostSurveyFdTemplateHeaders> headersList,
+                                 String[] auditPeriods, String templateType,
+                                 int rowIdColIndex, int parentIdColIndex, CellStyle dataStyle, String taskId) {
+        Map<String, CostSurveyFdTemplateHeaders> headersMap = headersList.stream()
+                .collect(Collectors.toMap(CostSurveyFdTemplateHeaders::getId, h -> h));
+
+        if ("1".equals(templateType)) {
+            Row dataRow = sheet.createRow(2);
+            for (CostSurveyFdTemplateItems item : itemsList) {
+                Integer colIndex = headerIndexMap.get(item.getHeadersId());
+                if (colIndex != null) {
+                    CostSurveyFdTemplateHeaders header = headersMap.get(item.getHeadersId());
+                    if (header != null && "true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                        for (int i = 0; i < auditPeriods.length; i++) {
+                            Cell cell = dataRow.createCell(colIndex + i);
+                            cell.setCellValue("");
+                            cell.setCellStyle(dataStyle);
+                        }
+                    } else {
+                        Cell cell = dataRow.createCell(colIndex);
+                        String value = item.getRvalue();
+                        if (StringUtil.isEmpty(value) && StringUtil.isNotEmpty(item.getCalculationTemplateId())) {
+                            value = cellDataQueryService.getCellValueByPeriod(taskId, item.getCalculationTemplateId(),
+                                item.getCellCode(), "0", "2");
+                        }
+                        cell.setCellValue(StringUtil.isNotEmpty(value) ? value : "");
+                        cell.setCellStyle(dataStyle);
+                    }
+                }
+            }
+        } else {
+            Map<String, List<CostSurveyFdTemplateItems>> itemsByRowId = itemsList.stream()
+                    .filter(item -> StringUtil.isNotEmpty(item.getRowid()))
+                    .collect(Collectors.groupingBy(CostSurveyFdTemplateItems::getRowid));
+
+            List<String> sortedRowIds = sortRowIdsByParentChildFd(itemsByRowId);
+
+            Row headerRow = sheet.getRow(1);
+            int totalColumns = headerRow != null ? headerRow.getLastCellNum() : 0;
+
+            int rowNum = 2;
+            for (String rowId : sortedRowIds) {
+                List<CostSurveyFdTemplateItems> rowItems = itemsByRowId.get(rowId);
+                if (rowItems != null && !rowItems.isEmpty()) {
+                    Row dataRow = sheet.createRow(rowNum++);
+
+                    for (CostSurveyFdTemplateItems item : rowItems) {
+                        Integer colIndex = headerIndexMap.get(item.getHeadersId());
+                        if (colIndex != null) {
+                            CostSurveyFdTemplateHeaders header = headersMap.get(item.getHeadersId());
+                            if (header != null && "true".equals(header.getIsAuditPeriod()) && auditPeriods != null && auditPeriods.length > 0) {
+                                for (int i = 0; i < auditPeriods.length; i++) {
+                                    Cell cell = dataRow.createCell(colIndex + i);
+                                    cell.setCellValue("");
+                                    cell.setCellStyle(dataStyle);
+                                }
+                            } else {
+                                Cell cell = dataRow.createCell(colIndex);
+                                String value = item.getRvalue();
+                                if (StringUtil.isEmpty(value) && StringUtil.isNotEmpty(item.getCalculationTemplateId())) {
+                                    value = cellDataQueryService.getCellValueByPeriod(taskId, item.getCalculationTemplateId(),
+                                        item.getCellCode(), "0", "2");
+                                }
+                                cell.setCellValue(StringUtil.isNotEmpty(value) ? value : "");
+                                cell.setCellStyle(dataStyle);
+                            }
+                        }
+                    }
+
+                    if (rowIdColIndex >= 0) {
+                        Cell cell = dataRow.createCell(rowIdColIndex);
+                        cell.setCellValue(rowId);
+                        cell.setCellStyle(dataStyle);
+                    }
+                    if (parentIdColIndex >= 0) {
+                        String parentId = rowItems.get(0).getParentid();
+                        Cell cell = dataRow.createCell(parentIdColIndex);
+                        cell.setCellValue(StringUtil.isNotEmpty(parentId) ? parentId : "");
+                        cell.setCellStyle(dataStyle);
+                    }
+
+                    for (int colIndex = 0; colIndex < totalColumns; colIndex++) {
+                        if (dataRow.getCell(colIndex) == null) {
+                            Cell cell = dataRow.createCell(colIndex);
+                            cell.setCellValue("");
+                            cell.setCellStyle(dataStyle);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private List<String> sortRowIdsByParentChildFd(Map<String, List<CostSurveyFdTemplateItems>> itemsByRowId) {
+        List<String> result = new ArrayList<>();
+
+        Map<String, String> rowIdToParentId = new HashMap<>();
+        for (Map.Entry<String, List<CostSurveyFdTemplateItems>> entry : itemsByRowId.entrySet()) {
+            String rowId = entry.getKey();
+            List<CostSurveyFdTemplateItems> items = entry.getValue();
+            if (!items.isEmpty()) {
+                String parentId = items.get(0).getParentid();
+                rowIdToParentId.put(rowId, parentId);
+            }
+        }
+
+        Set<String> allRowIds = new HashSet<>(itemsByRowId.keySet());
+        List<String> rootRowIds = allRowIds.stream()
+                .filter(rowId -> {
+                    String parentId = rowIdToParentId.get(rowId);
+                    return StringUtil.isEmpty(parentId) || !allRowIds.contains(parentId);
+                })
+                .sorted()
+                .collect(Collectors.toList());
+
+        for (String rootRowId : rootRowIds) {
+            addRowIdWithChildrenFd(rootRowId, rowIdToParentId, allRowIds, result);
+        }
+
+        return result;
+    }
+
+    private void addRowIdWithChildrenFd(String rowId, Map<String, String> rowIdToParentId,
+                                        Set<String> allRowIds, List<String> result) {
+        result.add(rowId);
+
+        List<String> children = allRowIds.stream()
+                .filter(id -> rowId.equals(rowIdToParentId.get(id)))
+                .sorted()
+                .collect(Collectors.toList());
+
+        for (String childRowId : children) {
+            addRowIdWithChildrenFd(childRowId, rowIdToParentId, allRowIds, result);
+        }
+    }
+
+}

+ 0 - 1
assistMg/src/main/java/com/hotent/project/controller/CostProjectProccessController.java

@@ -44,7 +44,6 @@ public class CostProjectProccessController {
 	// 创建通用服务实例
 	private final CrudService crudService = new CrudService();
 
-
 	@Autowired
 	private CostProjectProccessManager costProjectProccessManager;
 

+ 4 - 4
assistMg/src/main/java/com/hotent/project/manager/impl/CostNoticeManagerImpl.java

@@ -91,9 +91,9 @@ public class CostNoticeManagerImpl extends BaseManagerImpl<CostNoticeDao, CostNo
 		qw.eq(CostNotice::getIsDeleted, "0");
 
 		// 用户权限过滤:只能看到发给自己或自己企业的消息
-		com.hotent.baseInfo.model.AuditedUnit unit = auditedUnitManager.getOne(
-			new LambdaQueryWrapper<com.hotent.baseInfo.model.AuditedUnit>()
-				.eq(com.hotent.baseInfo.model.AuditedUnit::getAccount, currentUserId)
+		AuditedUnit unit = auditedUnitManager.getOne(
+			new LambdaQueryWrapper<AuditedUnit>()
+				.eq(AuditedUnit::getAccount, currentUserId)
 				.last("limit 1")
 		);
 		if (unit != null) {
@@ -126,7 +126,7 @@ public class CostNoticeManagerImpl extends BaseManagerImpl<CostNoticeDao, CostNo
 				.collect(Collectors.toMap(
 						AuditedUnit::getUnitId,
 						AuditedUnit::getUnitName,
-						(existing, replacement) -> existing  // 如果有重复键,保留第一个
+						(existing, replacement) -> existing
 				));
 		records.forEach(r -> {
 			String unitName = unitIdToNameMap.get(r.getEnterpriseId());

+ 11 - 9
assistMg/src/main/java/com/hotent/surveyinfo/controller/CostSurveyTemplateController.java

@@ -4,9 +4,12 @@ package com.hotent.surveyinfo.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.hotent.base.annotation.ApiGroup;
 import com.hotent.base.constants.ApiGroupConsts;
+import com.hotent.base.controller.BaseController;
 import com.hotent.base.exception.BaseException;
+import com.hotent.base.model.CommonResult;
 import com.hotent.base.query.PageList;
 import com.hotent.base.util.PinyinUtil;
+import com.hotent.base.util.StringUtil;
 import com.hotent.baseInfo.manager.CostCatalogManager;
 import com.hotent.baseInfo.manager.CostCatalogSurveyManager;
 import com.hotent.baseInfo.model.CostCatalog;
@@ -21,11 +24,12 @@ import com.hotent.surveyinfo.model.*;
 import com.hotent.surveyinfo.req.ConstSurveyPageParam;
 import com.hotent.surveyinfo.req.ConstSurveyPageReq;
 import com.hotent.uc.api.model.IUser;
-import com.hotent.uc.api.service.IUserService;
 import com.hotent.uc.manager.UserManager;
 import com.hotent.uc.model.User;
 import com.hotent.uc.util.ContextUtil;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -33,16 +37,14 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import com.hotent.base.model.CommonResult;
-import com.hotent.base.util.StringUtil;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import com.hotent.base.controller.BaseController;
 
 import javax.servlet.http.HttpServletResponse;
 import java.net.URLEncoder;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.UUID;
 import java.util.stream.Collectors;
 
 /**
@@ -54,7 +56,7 @@ import java.util.stream.Collectors;
  */
 @RestController
 @RequestMapping("/costSurveyTemplate/v1/")
-@Api(tags = "成本调查")
+@Api(tags = "成本调查表维护")
 @ApiGroup(group = {ApiGroupConsts.GROUP_COST})
 public class CostSurveyTemplateController extends BaseController<CostSurveyTemplateManager, CostSurveyTemplate> {
     @Autowired
@@ -112,7 +114,7 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
      */
     @GetMapping(value = "/getallCurrentCostSurveyList")
     @ApiOperation(value = "获取所有现行版启用的成本调查表模板数据", httpMethod = "GET", notes = "获取所有现行版启用的成本调查表模板数据")
-    public PageResp<CostSurveyTemplate> allCurrentCostSurveyList(ConstSurveyPageReq req) throws Exception {
+    public PageResp<CostSurveyTemplate> allCurrentCostSurveyList(ConstSurveyPageReq req){
         return crudService.pageQuery(req, constbaseService::getallCurrentCostSurveyList);
     }
 

+ 0 - 1
assistMg/src/main/java/com/hotent/surveyinfo/manager/CostSurveyTemplateManager.java

@@ -47,5 +47,4 @@ public interface CostSurveyTemplateManager extends BaseManager<CostSurveyTemplat
 
 	PageList<CostSurveyTemplate> getCostSurveyListPage( ConstSurveyPageParam params) throws Exception;
 
-	List<CostSurveyTemplate> taskListByCatalogId(String catalogId);
 }

+ 26 - 24
assistMg/src/main/java/com/hotent/surveyinfo/manager/impl/CostSurveyTemplateManagerImpl.java

@@ -43,16 +43,6 @@ import javax.sql.DataSource;
 public class CostSurveyTemplateManagerImpl extends BaseManagerImpl<CostSurveyTemplateDao, CostSurveyTemplate> implements CostSurveyTemplateManager {
 
 	@Autowired
-	private JdbcTemplate jdbcTemplate;
-	@Autowired
-	CostSurveyTemplateHeadersDao costSurveyTemplateheaderMapper;
-	@Autowired
-	CostSurveyTemplateItemsManager costSurveyTemplateItemsManager;
-	@Autowired
-	CostSurveyTemplateVersionDao costSurveyTemplateVersionMapper;
-	@Autowired
-	private DataSource dataSource;
-	@Autowired
 	private UserManager userService;
 
 	@Autowired
@@ -65,6 +55,32 @@ public class CostSurveyTemplateManagerImpl extends BaseManagerImpl<CostSurveyTem
 		// 构建查询条件
 		LambdaQueryWrapper<CostSurveyTemplate> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(CostSurveyTemplate::getStatus, "0")	;
+
+		// 添加区域权限过滤
+		IUser iUser = ContextUtil.getCurrentUser();
+        User user = null;
+        try {
+            user = userService.getByAccount(iUser.getAccount());
+        } catch (Exception e) {}
+        if (user != null && !iUser.isAdmin()) {
+			Integer dataScope = user.getDataScope();
+			if (dataScope != null) {
+				if (dataScope == 0) {
+					// 省级:只能看到省级区域的模板
+					queryWrapper.eq(CostSurveyTemplate::getAreaLevel, "0");
+					queryWrapper.eq(CostSurveyTemplate::getAreaCode, user.getProvinceCode());
+				} else if (dataScope == 1) {
+					// 市级:只能看到市级区域的模板
+					queryWrapper.eq(CostSurveyTemplate::getAreaLevel, "1");
+					queryWrapper.eq(CostSurveyTemplate::getAreaCode, user.getCityCode());
+				} else {
+					// 县级:只能看到县级区域的模板
+					queryWrapper.eq(CostSurveyTemplate::getAreaLevel, "2");
+					queryWrapper.eq(CostSurveyTemplate::getAreaCode, user.getCountyCode());
+				}
+			}
+		}
+
 		// 根据查询条件过滤
 		if (StringUtil.isNotEmpty(req.getType())) {
 			queryWrapper.eq(CostSurveyTemplate::getType, req.getType());
@@ -159,18 +175,4 @@ public class CostSurveyTemplateManagerImpl extends BaseManagerImpl<CostSurveyTem
 		return new PageList<>(page);
 	}
 
-	@Override
-	public List<CostSurveyTemplate> taskListByCatalogId(String catalogId) {
-		List<CostCatalogSurvey> list = costCatalogSurveyManager.list(
-				new LambdaQueryWrapper<CostCatalogSurvey>()
-						.eq(CostCatalogSurvey::getCatalogId, catalogId)
-		);
-		List<String> ids = list.stream().map(CostCatalogSurvey::getSurveyId).collect(Collectors.toList());
-		if (ids.isEmpty()){
-			return Collections.emptyList();
-		}
-		return this.listByIds(ids);
-	}
-
-
 }

+ 105 - 0
assistMg/src/main/java/com/hotent/util/ExcelStyleUtil.java

@@ -0,0 +1,105 @@
+package com.hotent.util;
+
+import org.apache.poi.ss.usermodel.*;
+
+/**
+ * Excel样式工具类
+ */
+public class ExcelStyleUtil {
+
+    /**
+     * 创建标题样式(大标题,居中,加粗,16号字体)
+     */
+    public static CellStyle createTitleStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        Font font = workbook.createFont();
+        font.setBold(true);
+        font.setFontHeightInPoints((short) 16);
+        style.setFont(font);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        return style;
+    }
+
+    /**
+     * 创建表头样式(居中,加粗,带边框,灰色背景)
+     */
+    public static CellStyle createHeaderStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        Font font = workbook.createFont();
+        font.setBold(true);
+        style.setFont(font);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        return style;
+    }
+
+    /**
+     * 创建数据样式(左对齐,带边框)
+     */
+    public static CellStyle createDataStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HorizontalAlignment.LEFT);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        return style;
+    }
+
+    /**
+     * 创建数据样式(居中对齐,带边框)
+     */
+    public static CellStyle createCenterDataStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        return style;
+    }
+
+    /**
+     * 创建数字数据样式(右对齐,带边框)
+     */
+    public static CellStyle createNumberDataStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HorizontalAlignment.RIGHT);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        return style;
+    }
+
+    /**
+     * 计算字符串的显示宽度(中文字符按2个字符宽度计算)
+     * @param text 要计算的字符串
+     * @return 字符宽度
+     */
+    public static int calculateCharWidth(String text) {
+        if (text == null || text.isEmpty()) {
+            return 0;
+        }
+        int width = 0;
+        for (char c : text.toCharArray()) {
+            // 中文字符、全角字符按2个字符宽度计算
+            if (c >= '\u4e00' && c <= '\u9fa5' || c >= '\uff00' && c <= '\uffef') {
+                width += 2;
+            } else {
+                width += 1;
+            }
+        }
+        return width;
+    }
+}

Vissa filer visades inte eftersom för många filer har ändrats