Explorar el Código

添加接口调用

hexiao hace 2 años
padre
commit
5d16900a96

+ 5 - 1
purchase-admin/pom.xml

@@ -49,7 +49,11 @@
             <groupId>com.ozs</groupId>
             <artifactId>purchase-generator</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>2.1.6</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 23 - 2
purchase-admin/src/main/java/com/ozs/web/controller/plan/PlanYearsController.java

@@ -1,5 +1,8 @@
 package com.ozs.web.controller.plan;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ozs.common.annotation.Log;
@@ -41,7 +44,9 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -161,8 +166,24 @@ public class PlanYearsController extends BaseController {
     public void exportPlanExamine(HttpServletResponse response, @RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) throws Exception {
         LoginUser loginUser = tokenService.getLoginUser(request);
         List<PlanYearsResponseVo> list = planYearsService.selectPlanYearsExamineListEXP(yearsStandardVo, loginUser);
-        ExcelUtil<PlanYearsResponseVo> util = new ExcelUtil<>(PlanYearsResponseVo.class);
-        util.exportExcel(response, list, "年度计划数据(审核单位)");
+        InputStream resourceAsStream = this.getClass().getResourceAsStream("/template/plan_year.xlsx");
+        OutputStream outputStream = null;
+        InputStream inputStream = null;
+        try {
+            outputStream = response.getOutputStream();
+            ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(resourceAsStream).autoCloseStream(true).build();
+            WriteSheet writeSheet = EasyExcel.writerSheet().build();
+//            FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
+//            excelWriter.fill(list, fillConfig, writeSheet);
+            excelWriter.fill(list, writeSheet);
+            excelWriter.finish();
+            outputStream.flush();
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            throw new BaseException("下载异常");
+        }
+//        ExcelUtil<PlanYearsResponseVo> util = new ExcelUtil<>(PlanYearsResponseVo.class);
+//        util.exportExcel(response, list, "年度计划数据(审核单位)");
     }
 
     @ApiOperation(value = "创建年度计划")

+ 1 - 1
purchase-admin/src/main/resources/application-druid.yml

@@ -5,7 +5,7 @@ spring:
         driverClassName: com.mysql.cj.jdbc.Driver
         druid:
             master:
-                url: jdbc:mysql://124.70.58.209:18806/purchase?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://124.70.58.209:18806/Purchase?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
                 password: 123.asd
             # 从库数据源

BIN
purchase-admin/src/main/resources/template/plan_year.xlsx