|
|
@@ -3,13 +3,16 @@ package com.jeeplus.modules.WorkKnowledgeBase.web;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.persistence.Page;
|
|
|
+import com.jeeplus.common.utils.DateUtils;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
|
+import com.jeeplus.common.utils.excel.ExportExcel;
|
|
|
import com.jeeplus.common.utils.excel.ImportExcel;
|
|
|
import com.jeeplus.common.web.BaseController;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.entity.*;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.service.WorkKnowledgeBaseShareService;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.service.WorkKnowledgeExpertService;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@@ -411,6 +414,57 @@ public class WorkKnowledgeBaseShareController extends BaseController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出导入模板(根据rootId动态生成)
|
|
|
+ */
|
|
|
+ @RequiresPermissions("workKnowledgeBase:share:import")
|
|
|
+ @RequestMapping(value = "exportTemplate")
|
|
|
+ public void exportTemplate(@RequestParam(required = false) String rootId, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ // 查询该根节点下的动态字段配置
|
|
|
+ List<WorkKnowledgeBaseDynamicInfo> dynamicFields = shareService.findDynamicFields(rootId);
|
|
|
+
|
|
|
+ // 构建导出列标题(固定列 + 动态列)
|
|
|
+ List<String> headers = new ArrayList<>();
|
|
|
+ // 固定列:体系节点名称、标准名称
|
|
|
+ headers.add("体系节点名称");
|
|
|
+ headers.add("标准名称");
|
|
|
+
|
|
|
+ // 动态列:根据动态字段配置添加
|
|
|
+ if (dynamicFields != null && !dynamicFields.isEmpty()) {
|
|
|
+ for (WorkKnowledgeBaseDynamicInfo field : dynamicFields) {
|
|
|
+ headers.add(field.getFieldLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用ExportExcel工具类导出
|
|
|
+ ExportExcel exportExcel = new ExportExcel("知识库导入模板", headers);
|
|
|
+
|
|
|
+ // 添加示例数据行
|
|
|
+ Row row = exportExcel.addRow();
|
|
|
+ int colIndex = 0;
|
|
|
+ // 固定列示例值
|
|
|
+ exportExcel.addCell(row, colIndex++, "示例节点");
|
|
|
+ exportExcel.addCell(row, colIndex++, "示例标准名称");
|
|
|
+
|
|
|
+ // 动态列示例值
|
|
|
+ if (dynamicFields != null && !dynamicFields.isEmpty()) {
|
|
|
+ for (int i = 0; i < dynamicFields.size(); i++) {
|
|
|
+ exportExcel.addCell(row, colIndex++, "示例值" + (i + 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成文件名
|
|
|
+ String fileName = "知识库导入模板_" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
|
+
|
|
|
+ // 输出到客户端
|
|
|
+ exportExcel.write(response, fileName).dispose();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("导出模板失败:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// ======================== 审核相关接口 ========================
|
|
|
|
|
|
/**
|