正在显示
6 个修改的文件
包含
85 行增加
和
15 行删除
1 | server: | 1 | server: |
2 | port: 9001 | 2 | port: 9001 |
3 | - | ||
4 | # spring \u914D\u7F6E | 3 | # spring \u914D\u7F6E |
5 | spring: | 4 | spring: |
6 | application: | 5 | application: |
7 | name: cgonms-provide | 6 | name: cgonms-provide |
7 | + profiles: | ||
8 | + active: dev | ||
9 | +# mvc: | ||
10 | +# static-path-pattern: /exit/** | ||
11 | +# resources: | ||
12 | +# #指定静态资源目录 | ||
13 | +# static-locations: file:../excel/ | ||
8 | datasource: | 14 | datasource: |
9 | type: com.alibaba.druid.pool.DruidDataSource | 15 | type: com.alibaba.druid.pool.DruidDataSource |
10 | driver-class-name: oracle.jdbc.OracleDriver | 16 | driver-class-name: oracle.jdbc.OracleDriver |
11 | url: jdbc:oracle:thin:@192.168.1.253:1522:ORCLL | 17 | url: jdbc:oracle:thin:@192.168.1.253:1522:ORCLL |
12 | username: CGONMS | 18 | username: CGONMS |
13 | password: vmvnv1v2 | 19 | password: vmvnv1v2 |
14 | - profiles: | ||
15 | - active: dev | 20 | + |
16 | jackson: | 21 | jackson: |
17 | default-property-inclusion: ALWAYS | 22 | default-property-inclusion: ALWAYS |
18 | time-zone: GMT+8 | 23 | time-zone: GMT+8 |
@@ -35,12 +40,12 @@ mybatis: | @@ -35,12 +40,12 @@ mybatis: | ||
35 | 40 | ||
36 | # \u65E5\u5FD7\u6253\u5370 | 41 | # \u65E5\u5FD7\u6253\u5370 |
37 | logging: | 42 | logging: |
38 | -# config: config/logback-dev.xml | 43 | + config: config/logback-dev.xml |
39 | level: | 44 | level: |
40 | com.sunyo.wlpt.cgonms.provide.mapper: debug | 45 | com.sunyo.wlpt.cgonms.provide.mapper: debug |
41 | -#logback: | ||
42 | -# appname: cgonms-provide | ||
43 | -# logdir: ./log | 46 | +logback: |
47 | + appname: cgonms-provide | ||
48 | + logdir: ./log | ||
44 | 49 | ||
45 | 50 | ||
46 | #eureka client | 51 | #eureka client |
excel/test.jpg
0 → 100644

140.4 KB
excel/test.xls
0 → 100644
不能预览此文件类型
1 | +package com.sunyo.wlpt.cgonms.provide.config; | ||
2 | + | ||
3 | +import org.springframework.beans.factory.annotation.Autowired; | ||
4 | +import org.springframework.context.annotation.Configuration; | ||
5 | +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
6 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author 子诚 | ||
10 | + * Description: | ||
11 | + * 时间:2020/6/4 15:31 | ||
12 | + */ | ||
13 | +@Configuration | ||
14 | +public class MyWebMvcConfigurer implements WebMvcConfigurer { | ||
15 | + | ||
16 | + @Override | ||
17 | + public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
18 | + registry.addResourceHandler("/exit/**").addResourceLocations("file:excel/"); | ||
19 | + registry.addResourceHandler("/exit/excel/**").addResourceLocations("file:excel/"); | ||
20 | + registry.addResourceHandler("/exit/downExcel/**").addResourceLocations("file:excel/"); | ||
21 | + WebMvcConfigurer.super.addResourceHandlers(registry); | ||
22 | + } | ||
23 | + | ||
24 | +} |
1 | +package com.sunyo.wlpt.cgonms.provide.excle; | ||
2 | + | ||
3 | +import com.sunyo.wlpt.cgonms.provide.response.ResultJson; | ||
4 | +import lombok.extern.slf4j.Slf4j; | ||
5 | +import org.springframework.beans.factory.annotation.Value; | ||
6 | +import org.springframework.web.bind.annotation.GetMapping; | ||
7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
8 | +import org.springframework.web.bind.annotation.RestController; | ||
9 | + | ||
10 | +import javax.servlet.http.HttpServletResponse; | ||
11 | +import java.net.InetAddress; | ||
12 | + | ||
13 | +/** | ||
14 | + * @author 子诚 | ||
15 | + * Description: | ||
16 | + * 时间:2020/6/4 19:10 | ||
17 | + */ | ||
18 | +@Slf4j | ||
19 | +@RestController | ||
20 | +@RequestMapping("/exit") | ||
21 | +public class DownExcel { | ||
22 | + @Value("${server.port}") | ||
23 | + private String port; | ||
24 | + | ||
25 | + @GetMapping("/downExcel") | ||
26 | + public ResultJson downExcel() throws Exception { | ||
27 | + ResultJson result = new ResultJson(); | ||
28 | + | ||
29 | + String ip = InetAddress.getLocalHost().getHostAddress(); | ||
30 | + String address = "http://" +ip+":"+port+"/"+"exit/"; | ||
31 | + result.setCode("200"); | ||
32 | + result.setMsg(address); | ||
33 | + return result; | ||
34 | + } | ||
35 | +} |
1 | package com.sunyo.wlpt.cgonms.provide.excle; | 1 | package com.sunyo.wlpt.cgonms.provide.excle; |
2 | 2 | ||
3 | import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData; | 3 | import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData; |
4 | +import com.sunyo.wlpt.cgonms.provide.response.ResultJson; | ||
4 | import lombok.extern.slf4j.Slf4j; | 5 | import lombok.extern.slf4j.Slf4j; |
5 | import org.apache.poi.hssf.usermodel.*; | 6 | import org.apache.poi.hssf.usermodel.*; |
6 | import org.springframework.beans.factory.annotation.Value; | 7 | import org.springframework.beans.factory.annotation.Value; |
@@ -32,15 +33,18 @@ public class ExitExcel { | @@ -32,15 +33,18 @@ public class ExitExcel { | ||
32 | @Value("${path.dir}") | 33 | @Value("${path.dir}") |
33 | private String dir; | 34 | private String dir; |
34 | 35 | ||
35 | - final SimpleDateFormat sdfShort = new SimpleDateFormat("yyyy-MM-dd"); | ||
36 | - final SimpleDateFormat sdfLong = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
37 | - | ||
38 | @PostMapping("/excel") | 36 | @PostMapping("/excel") |
39 | - public void getExit(@RequestBody List<ResultExitData> exitInfoList, HttpServletResponse httpServletResponse) { | ||
40 | - exportExcel(exitInfoList, httpServletResponse); | 37 | + public ResultJson getExit(@RequestBody List<ResultExitData> exitInfoList, HttpServletResponse httpServletResponse) { |
38 | + ResultJson result = new ResultJson(); | ||
39 | + String title = exportExcel(exitInfoList, httpServletResponse); | ||
40 | + result.setMsg(title); | ||
41 | + result.setCode("200"); | ||
42 | + return result; | ||
41 | } | 43 | } |
42 | 44 | ||
43 | - private void exportExcel(List<ResultExitData> exitInfoList, HttpServletResponse response) { | 45 | + private String exportExcel(List<ResultExitData> exitInfoList, HttpServletResponse response) { |
46 | + // 设置文件名 | ||
47 | + String title = ""; | ||
44 | try { | 48 | try { |
45 | // 创建工作簿 | 49 | // 创建工作簿 |
46 | HSSFWorkbook workbook = new HSSFWorkbook(); | 50 | HSSFWorkbook workbook = new HSSFWorkbook(); |
@@ -156,9 +160,10 @@ public class ExitExcel { | @@ -156,9 +160,10 @@ public class ExitExcel { | ||
156 | 160 | ||
157 | String file_name = UUID.randomUUID().toString().replaceAll("-", ""); | 161 | String file_name = UUID.randomUUID().toString().replaceAll("-", ""); |
158 | // 设置文件名 | 162 | // 设置文件名 |
159 | - String title = file_name + ".xls"; | 163 | + title = file_name + ".xls"; |
160 | 164 | ||
161 | - String filePath = disc + ":" + File.separator + dir + File.separator + title; | 165 | +// String filePath = disc + ":" + File.separator + dir + File.separator + title; |
166 | + String filePath = "excel/" + title; | ||
162 | /** | 167 | /** |
163 | * 创建文件夹 | 168 | * 创建文件夹 |
164 | */ | 169 | */ |
@@ -181,6 +186,7 @@ public class ExitExcel { | @@ -181,6 +186,7 @@ public class ExitExcel { | ||
181 | } catch (Exception e) { | 186 | } catch (Exception e) { |
182 | e.printStackTrace(); | 187 | e.printStackTrace(); |
183 | } | 188 | } |
189 | + return title; | ||
184 | } | 190 | } |
185 | 191 | ||
186 | /** | 192 | /** |
-
请 注册 或 登录 后发表评论