From 790d07b82cc9c803f27308d0c3064bf4ac73ef35 Mon Sep 17 00:00:00 2001 From: itcast Date: Fri, 21 Jul 2023 10:41:02 +0800 Subject: [PATCH] Changes --- .../fieldx/controller/FieldxController.java | 43 +++++++++++++++-- .../jeecg/modules/fieldx/entity/Fielddc.java | 48 +++++++++++++++++++ .../tablex/controller/TablexController.java | 2 +- 3 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fielddc.java diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java index 2554d88..c7d7cc8 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java @@ -23,6 +23,7 @@ import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.fieldx.dto.ExcelInfo; +import org.jeecg.modules.fieldx.entity.Fielddc; import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.entity.Fieldx222; import org.jeecg.modules.fieldx.service.IFieldx222Service; @@ -33,10 +34,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.modulex.vo.ModuleFunctionRule; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.modules.tablex.ws.WebSocketUtils; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jsoup.helper.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -288,7 +293,21 @@ public class FieldxController extends JeecgController { */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, Fieldx fieldx) { - return super.exportXls(request, fieldx, Fieldx.class, "字段管理"); + //获取导出人 + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String getRealname = "佚名"; + if (sysUser != null) { + getRealname = sysUser.getRealname(); + } + //导出表格 + List list=new ArrayList<>(); + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + mv.addObject(org.jeecgframework.poi.excel.def.NormalExcelConstants.FILE_NAME, "字段表"); + mv.addObject(org.jeecgframework.poi.excel.def.NormalExcelConstants.CLASS, Fielddc.class); + ExportParams exportParams = new ExportParams("字段表", "导出人:" + getRealname,"字段表"); + mv.addObject(org.jeecgframework.poi.excel.def.NormalExcelConstants.PARAMS, exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, list); + return mv; } @@ -324,6 +343,24 @@ public class FieldxController extends JeecgController { else { workbook = new XSSFWorkbook(inputStream); } + Sheet first=workbook.getSheetAt(0); + //判断表结构 + Row row=first.getRow(2); + if(row==null) + return Result.error("表结构不能为空"); + + if(!"序号".equals(row.getCell(0).getStringCellValue())||!"表名".equals(row.getCell(1).getStringCellValue()) + ||!"中文名称".equals(row.getCell(2).getStringCellValue())||!"英文名称".equals(row.getCell(3).getStringCellValue()) + ||!"数据类型".equals(row.getCell(4).getStringCellValue())||!"数据长度".equals(row.getCell(5).getStringCellValue()) + ||!"浮点精度".equals(row.getCell(6).getStringCellValue())||!"显示形式".equals(row.getCell(7).getStringCellValue()) + ||!"是否主键".equals(row.getCell(8).getStringCellValue())||!"是否外键".equals(row.getCell(9).getStringCellValue()) + ||!"关联实体".equals(row.getCell(10).getStringCellValue())||!"关联字段".equals(row.getCell(11).getStringCellValue()) + ||!"是否为空".equals(row.getCell(12).getStringCellValue())||!"是否重复".equals(row.getCell(13).getStringCellValue()) + ||!"字段规则".equals(row.getCell(14).getStringCellValue())||!"字段状态".equals(row.getCell(15).getStringCellValue()) + ||!"版本状态".equals(row.getCell(16).getStringCellValue())) + return Result.error("表结构不正确"); + + //读取表 message.put("status", "数据预读入"); webSocketUtils.sendMessage(loginUser.getId(), message); @@ -333,10 +370,6 @@ public class FieldxController extends JeecgController { for (int i=0;i< numberofSheets;i++) { Sheet Sheet=workbook.getSheetAt(i); - //判断表结构 - Row row=Sheet.getRow(3); - if(row==null) - return Result.error("表结构不能为空"); for(int r=3;r<=Sheet.getLastRowNum();r++) { Row cells = Sheet.getRow(r); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fielddc.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fielddc.java new file mode 100644 index 0000000..d7000bf --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fielddc.java @@ -0,0 +1,48 @@ +package org.jeecg.modules.fieldx.entity; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; + +@Data +@ApiModel(value = "字段表模板", description = "字段表模板") +public class Fielddc { + private static final long serialVersionUID = 1L; + + @Excel(name = "序号", width = 15) + private java.lang.String a; + @Excel(name = "表名", width = 15) + private java.lang.String c; + @Excel(name = "中文名称", width = 15) + private java.lang.String ll; + @Excel(name = "英文名称", width = 15) + private java.lang.String d; + @Excel(name = "数据类型", width = 15) + private java.lang.String e; + @Excel(name = "数据长度", width = 15) + private java.lang.String f; + @Excel(name = "浮点精度", width = 15) + private java.lang.String g; + @Excel(name = "显示形式", width = 15) + private java.lang.String h; + @Excel(name = "是否主键", width = 15) + private java.lang.String i; + @Excel(name = "是否外键", width = 15) + private java.lang.String z; + @Excel(name = "关联实体", width = 15) + private java.lang.String k; + @Excel(name = "关联字段", width = 15) + private java.lang.String l; + @Excel(name = "是否为空", width = 15) + private java.lang.String m; + @Excel(name = "是否重复", width = 15) + private java.lang.String ml; + @Excel(name = "字段规则", width = 15) + private java.lang.String o; + @Excel(name = "字段状态", width = 15) + private java.lang.String p; + @Excel(name = "版本状态", width = 15) + private java.lang.String q; + + +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index 3c86d3f..6864c02 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -281,7 +281,7 @@ public class TablexController extends JeecgController { * 通过excel导入数据 * * @param file - * @return + * @return */ @RequestMapping(value = "/importExcel", method = RequestMethod.POST) public Result importExcel(MultipartFile file) {