新增三重一大、重大经济决策调查表导出功能

This commit is contained in:
2025-11-04 16:24:35 +08:00
parent a9f52f4b76
commit 61e5bac7db
5 changed files with 452 additions and 9 deletions

View File

@@ -3,29 +3,29 @@ package com.gxwebsoft.ai.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.ai.dto.AuditContentRequest;
import com.gxwebsoft.ai.dto.export.TripleOneExportEntity;
import com.gxwebsoft.ai.dto.export.DecisionTableExportEntity;
import com.gxwebsoft.ai.entity.AiCloudDoc;
import com.gxwebsoft.ai.entity.AiCloudFile;
import com.gxwebsoft.ai.utils.ExcelExportTool;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.User;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import com.gxwebsoft.ai.service.AiCloudDocService;
import com.gxwebsoft.ai.service.AiCloudFileService;
import com.gxwebsoft.ai.service.AuditContent3TripleService;
import com.gxwebsoft.ai.service.AuditContent3DecisionService;
import com.gxwebsoft.ai.service.KnowledgeBaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.*;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.hutool.core.util.StrUtil;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* 审计内容3控制器 - 三重一大制度对比分析 & 重大经济决策调查表
@@ -166,4 +166,114 @@ public class AuditContent3Controller extends BaseController {
}
}
}
/**
* 导出三重一大制度对比分析表到Excel
*/
@Operation(summary = "导出三重一大制度对比分析表到Excel")
@PostMapping("/exportTripleOneTable")
public void exportTripleOneTable(@RequestBody Map<String, Object> request, HttpServletResponse response) {
List<Map<String, Object>> dataList = (List<Map<String, Object>>) request.get("data");
String companyName = (String) request.get("companyName");
// 转换为实体列表
List<TripleOneExportEntity> exportData = convertToTripleOneEntityList(dataList);
// 使用工具类导出
String fileName = "三重一大制度对比分析表_" + (companyName != null ? companyName : "未知公司");
String title = companyName != null ? companyName + " - 三重一大制度对比分析表" : "三重一大制度对比分析表";
ExcelExportTool.exportExcel(exportData, TripleOneExportEntity.class, fileName, "三重一大制度对比分析表", title, response);
}
/**
* 导出重大经济决策调查表到Excel
*/
@Operation(summary = "导出重大经济决策调查表到Excel")
@PostMapping("/exportDecisionTable")
public void exportDecisionTable(@RequestBody Map<String, Object> request, HttpServletResponse response) {
List<Map<String, Object>> dataList = (List<Map<String, Object>>) request.get("data");
String companyName = (String) request.get("companyName");
// 转换为实体列表
List<DecisionTableExportEntity> exportData = convertToDecisionTableEntityList(dataList);
// 使用工具类导出
String fileName = "重大经济决策调查表_" + (companyName != null ? companyName : "未知公司");
String title = companyName != null ? companyName + " - 重大经济决策调查表" : "重大经济决策调查表";
ExcelExportTool.exportExcel(exportData, DecisionTableExportEntity.class, fileName, "重大经济决策调查表", title, response);
}
/**
* 转换为三重一大实体列表
*/
private List<TripleOneExportEntity> convertToTripleOneEntityList(List<Map<String, Object>> originalData) {
return originalData.stream().map(this::convertToTripleOneEntity).collect(Collectors.toList());
}
/**
* 转换为重大经济决策调查表实体列表
*/
private List<DecisionTableExportEntity> convertToDecisionTableEntityList(List<Map<String, Object>> originalData) {
return originalData.stream().map(this::convertToDecisionTableEntity).collect(Collectors.toList());
}
/**
* 单个Map转换为三重一大实体
*/
private TripleOneExportEntity convertToTripleOneEntity(Map<String, Object> item) {
TripleOneExportEntity entity = new TripleOneExportEntity();
entity.setCategory(getStringValue(item, "category"));
entity.setPolicyContent(getStringValue(item, "policyContent"));
entity.setGroupSystem(getStringValue(item, "groupSystem"));
entity.setCompanyFormulation(getStringValue(item, "companyFormulation"));
entity.setCheckEvidence(getStringValue(item, "checkEvidence"));
entity.setTestResult(getStringValue(item, "testResult"));
entity.setWorkPaperIndex(formatWorkPaperIndex(item.get("workPaperIndex")));
return entity;
}
/**
* 单个Map转换为重大经济决策调查表实体
*/
private DecisionTableExportEntity convertToDecisionTableEntity(Map<String, Object> item) {
DecisionTableExportEntity entity = new DecisionTableExportEntity();
entity.setIndex(getStringValue(item, "index"));
entity.setDecisionItem(getStringValue(item, "name"));
entity.setMeetingTime(getStringValue(item, "meetingTime"));
entity.setDecisionAmount(getStringValue(item, "decisionAmount"));
entity.setProcedure(getStringValue(item, "procedure"));
entity.setExecutionStatus(getStringValue(item, "executionStatus"));
entity.setGood(getStringValue(item, "goods"));
entity.setNormal(getStringValue(item, "normal"));
entity.setBad(getStringValue(item, "bad"));
return entity;
}
/**
* 安全获取字符串值
*/
private String getStringValue(Map<String, Object> map, String key) {
Object value = map.get(key);
return value != null ? value.toString() : "";
}
/**
* 格式化工作底稿索引(如果是数组则转换为字符串)
*/
private String formatWorkPaperIndex(Object workPaperIndex) {
if (workPaperIndex == null) {
return "";
}
if (workPaperIndex instanceof List) {
List<?> list = (List<?>) workPaperIndex;
return String.join(", ", list.stream()
.map(Object::toString)
.collect(Collectors.toList()));
}
return workPaperIndex.toString();
}
}