Ver código fonte

Merge branch 'wheng' of wuheng/eas-system into master

wuheng 1 ano atrás
pai
commit
ae0826449d

+ 4 - 0
controller/pom.xml

@@ -14,6 +14,10 @@
     </parent>
 
     <dependencies>
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-spring-boot-starter</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
             <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>

+ 43 - 17
controller/src/test/java/com/koobietech/eas/controller/ControllerApplicationTests.java

@@ -1,38 +1,64 @@
 package com.koobietech.eas.controller;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+import cn.afterturn.easypoi.handler.inter.IWriter;
 import com.koobietech.eas.common.constant.UserType;
 import com.koobietech.eas.common.pojo.JwtUserDto;
 import com.koobietech.eas.common.service.RedisService;
 import com.koobietech.eas.common.utils.JwtManager;
 import com.koobietech.eas.common.utils.PasswordManager;
+import com.koobietech.eas.mbg.model.EasSysLogs;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.*;
 
 
 @SpringBootTest
 class ControllerApplicationTests {
 
-    @Resource
-    RedisService redisService;
-
-    @Resource
-    JwtManager jwtManager;
-
     @Test
-    void contextLoads() {
-
-        JwtUserDto jwtUserDto = new JwtUserDto();
-
-        jwtUserDto.setType(UserType.TEACHER);
-        jwtUserDto.setId(12L);
-        jwtUserDto.setUsername("李四");
-
-        String jwt = jwtManager.createJwt(jwtUserDto);
-        redisService.set("jwttoken", jwt);
-
+    void contextLoads() throws IOException {
+//        List<Map> list = new ArrayList<>();
+//        Workbook workbook = null;
+//        ExportParams params = new ExportParams("大数据测试", "测试");
+//
+//        List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
+//        entity.add(new ExcelExportEntity("ID", "id"));
+//        entity.add(new ExcelExportEntity("级别", "level"));
+//        entity.add(new ExcelExportEntity("日志", "logger"));
+//        entity.add(new ExcelExportEntity("消息", "message"));
+//        entity.add(new ExcelExportEntity("时间", "timestamp"));
+//        entity.add(new ExcelExportEntity("异常", "exception"));
+//
+//        Map<String, Object> map = new HashMap<>();
+//        for (int i = 0; i < 10000; i++) {
+//            map.put("id", i);
+//            map.put("level", "ERROR");
+//            map.put("logger", "发生错误" + i);
+//            map.put("message", "这里是消息");
+//            map.put("timestamp", new Date());
+//            map.put("exception", "异常信息");
+//            list.add(map);
+//        }
+//        workbook = ExcelExportUtil.exportExcel(params, entity, list);
+//        list.clear();
+//        File savefile = new File("C:/Users/lc/Desktop");
+//        if (!savefile.exists()) {
+//            savefile.mkdirs();
+//        }
+//        FileOutputStream fos = new FileOutputStream("C:/Users/lc/Desktop/bigDataExport.xlsx");
+//        workbook.write(fos);
+//        fos.close();
 
 
     }

+ 6 - 0
pom.xml

@@ -33,11 +33,17 @@
         <javax.servlet-api.version>4.0.1</javax.servlet-api.version>
         <spring-data-redis.version>2.7.3</spring-data-redis.version>
         <knife4j.version>4.1.0</knife4j.version>
+        <easypoi.version>4.3.0</easypoi.version>
         <pagehelper.starter.version>1.3.1</pagehelper.starter.version>
         <maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
     </properties>
     <dependencyManagement>
         <dependencies>
+            <dependency>
+                <groupId>cn.afterturn</groupId>
+                <artifactId>easypoi-spring-boot-starter</artifactId>
+                <version>${easypoi.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-starter-security</artifactId>