切换导航条
此项目
正在载入...
登录
exit_data_analysis
/
cgonms_provide
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
王勇
5 years ago
提交
70805e4ca5832e9ad3fac52503caab0753888164
1 个父辈
4edae853
功能基本完善
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
85 行增加
和
15 行删除
src/main/resources/application.yml → config/application.yml
excel/test.jpg
excel/test.xls
src/main/java/com/sunyo/wlpt/cgonms/provide/config/MyWebMvcConfigurer.java
src/main/java/com/sunyo/wlpt/cgonms/provide/excle/DownExcel.java
src/main/java/com/sunyo/wlpt/cgonms/provide/excle/ExitExcel.java
src/main/resources
/application.yml →
config
/application.yml
查看文件 @
70805e4
server
:
port
:
9001
# spring \u914D\u7F6E
spring
:
application
:
name
:
cgonms-provide
profiles
:
active
:
dev
# mvc:
# static-path-pattern: /exit/**
# resources:
# #指定静态资源目录
# static-locations: file:../excel/
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driver-class-name
:
oracle.jdbc.OracleDriver
url
:
jdbc:oracle:thin:@192.168.1.253:1522:ORCLL
username
:
CGONMS
password
:
vmvnv1v2
profiles
:
active
:
dev
jackson
:
default-property-inclusion
:
ALWAYS
time-zone
:
GMT+8
...
...
@@ -35,12 +40,12 @@ mybatis:
# \u65E5\u5FD7\u6253\u5370
logging
:
#
config: config/logback-dev.xml
config
:
config/logback-dev.xml
level
:
com.sunyo.wlpt.cgonms.provide.mapper
:
debug
#logback:
# appname: cgonms-provide
# logdir: ./log
logback
:
appname
:
cgonms-provide
logdir
:
./log
#eureka client
...
...
excel/test.jpg
0 → 100644
查看文件 @
70805e4
140.4 KB
excel/test.xls
0 → 100644
查看文件 @
70805e4
不能预览此文件类型
src/main/java/com/sunyo/wlpt/cgonms/provide/config/MyWebMvcConfigurer.java
0 → 100644
查看文件 @
70805e4
package
com
.
sunyo
.
wlpt
.
cgonms
.
provide
.
config
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* @author 子诚
* Description:
* 时间:2020/6/4 15:31
*/
@Configuration
public
class
MyWebMvcConfigurer
implements
WebMvcConfigurer
{
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"/exit/**"
).
addResourceLocations
(
"file:excel/"
);
registry
.
addResourceHandler
(
"/exit/excel/**"
).
addResourceLocations
(
"file:excel/"
);
registry
.
addResourceHandler
(
"/exit/downExcel/**"
).
addResourceLocations
(
"file:excel/"
);
WebMvcConfigurer
.
super
.
addResourceHandlers
(
registry
);
}
}
...
...
src/main/java/com/sunyo/wlpt/cgonms/provide/excle/DownExcel.java
0 → 100644
查看文件 @
70805e4
package
com
.
sunyo
.
wlpt
.
cgonms
.
provide
.
excle
;
import
com.sunyo.wlpt.cgonms.provide.response.ResultJson
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.net.InetAddress
;
/**
* @author 子诚
* Description:
* 时间:2020/6/4 19:10
*/
@Slf4j
@RestController
@RequestMapping
(
"/exit"
)
public
class
DownExcel
{
@Value
(
"${server.port}"
)
private
String
port
;
@GetMapping
(
"/downExcel"
)
public
ResultJson
downExcel
()
throws
Exception
{
ResultJson
result
=
new
ResultJson
();
String
ip
=
InetAddress
.
getLocalHost
().
getHostAddress
();
String
address
=
"http://"
+
ip
+
":"
+
port
+
"/"
+
"exit/"
;
result
.
setCode
(
"200"
);
result
.
setMsg
(
address
);
return
result
;
}
}
...
...
src/main/java/com/sunyo/wlpt/cgonms/provide/excle/ExitExcel.java
查看文件 @
70805e4
package
com
.
sunyo
.
wlpt
.
cgonms
.
provide
.
excle
;
import
com.sunyo.wlpt.cgonms.provide.domain.ResultExitData
;
import
com.sunyo.wlpt.cgonms.provide.response.ResultJson
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -32,15 +33,18 @@ public class ExitExcel {
@Value
(
"${path.dir}"
)
private
String
dir
;
final
SimpleDateFormat
sdfShort
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
final
SimpleDateFormat
sdfLong
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
@PostMapping
(
"/excel"
)
public
void
getExit
(
@RequestBody
List
<
ResultExitData
>
exitInfoList
,
HttpServletResponse
httpServletResponse
)
{
exportExcel
(
exitInfoList
,
httpServletResponse
);
public
ResultJson
getExit
(
@RequestBody
List
<
ResultExitData
>
exitInfoList
,
HttpServletResponse
httpServletResponse
)
{
ResultJson
result
=
new
ResultJson
();
String
title
=
exportExcel
(
exitInfoList
,
httpServletResponse
);
result
.
setMsg
(
title
);
result
.
setCode
(
"200"
);
return
result
;
}
private
void
exportExcel
(
List
<
ResultExitData
>
exitInfoList
,
HttpServletResponse
response
)
{
private
String
exportExcel
(
List
<
ResultExitData
>
exitInfoList
,
HttpServletResponse
response
)
{
// 设置文件名
String
title
=
""
;
try
{
// 创建工作簿
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
...
...
@@ -156,9 +160,10 @@ public class ExitExcel {
String
file_name
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
// 设置文件名
String
title
=
file_name
+
".xls"
;
title
=
file_name
+
".xls"
;
String
filePath
=
disc
+
":"
+
File
.
separator
+
dir
+
File
.
separator
+
title
;
// String filePath = disc + ":" + File.separator + dir + File.separator + title;
String
filePath
=
"excel/"
+
title
;
/**
* 创建文件夹
*/
...
...
@@ -181,6 +186,7 @@ public class ExitExcel {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
title
;
}
/**
...
...
请
注册
或
登录
后发表评论