Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv-springboot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bsoft
sv-springboot
Commits
1931eaaf
Commit
1931eaaf
authored
Nov 19, 2019
by
Suvalue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table导出excel接口
parent
88c9efb5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
5 deletions
+86
-5
bsoft-api/pom.xml
+6
-0
bsoft-api/src/main/java/com/bsoft/api/controller/ExcelController.java
+30
-0
bsoft-api/src/main/java/com/bsoft/api/service/ExcelService.java
+11
-0
bsoft-api/src/main/java/com/bsoft/api/service/Impl/ExcelServiceImpl.java
+33
-0
bsoft-api/src/main/resources/application-dev.properties
+1
-1
bsoft-api/src/main/resources/application.properties
+3
-2
bsoft-api/src/main/resources/mapper/SerDiseaseMapper.xml
+1
-1
bsoft-api/src/test/resources/generatorConfig.xml
+1
-1
No files found.
bsoft-api/pom.xml
View file @
1931eaaf
...
@@ -90,6 +90,11 @@
...
@@ -90,6 +90,11 @@
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
me.chyxion
</groupId>
<artifactId>
table-to-xls
</artifactId>
<version>
0.0.1-RELEASE
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -151,6 +156,7 @@
...
@@ -151,6 +156,7 @@
<!--endregion-->
<!--endregion-->
</dependencies>
</dependencies>
</plugin>
</plugin>
</plugins>
</plugins>
...
...
bsoft-api/src/main/java/com/bsoft/api/controller/ExcelController.java
0 → 100644
View file @
1931eaaf
package
com
.
bsoft
.
api
.
controller
;
import
com.bsoft.api.common.Result
;
import
com.bsoft.api.service.ExcelService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
@Api
(
tags
=
"Excel导出"
)
@RestController
public
class
ExcelController
{
@Autowired
private
ExcelService
excelService
;
@PostMapping
(
"xls"
)
@ApiOperation
(
"将Table转换为Xls"
)
public
Object
tableToXls
(
HttpServletRequest
request
,
@RequestBody
String
tableStr
){
String
realPath
=
request
.
getSession
().
getServletContext
().
getRealPath
(
"/"
);
System
.
out
.
println
(
realPath
);
String
fileUrl
=
excelService
.
tableToXls
(
realPath
,
tableStr
);
return
Result
.
success
(
fileUrl
);
}
}
bsoft-api/src/main/java/com/bsoft/api/service/ExcelService.java
0 → 100644
View file @
1931eaaf
package
com
.
bsoft
.
api
.
service
;
import
com.bsoft.api.common.handlers.GlobalExceptionHandler
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
interface
ExcelService
{
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
String
tableToXls
(
String
realPath
,
String
tableStr
);
}
bsoft-api/src/main/java/com/bsoft/api/service/Impl/ExcelServiceImpl.java
0 → 100644
View file @
1931eaaf
package
com
.
bsoft
.
api
.
service
.
Impl
;
import
com.bsoft.api.service.ExcelService
;
import
me.chyxion.xls.TableToXls
;
import
org.springframework.stereotype.Service
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.util.UUID
;
@Service
public
class
ExcelServiceImpl
implements
ExcelService
{
@Override
public
String
tableToXls
(
String
realPath
,
String
tableStr
)
{
try
{
File
directory
=
new
File
(
realPath
+
"/excel"
);
if
(!
directory
.
exists
()
&&
!
directory
.
isDirectory
())
{
directory
.
mkdir
();
}
String
uuid
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
String
fileName
=
uuid
+
".xls"
;
FileOutputStream
fout
=
new
FileOutputStream
(
directory
+
"/"
+
fileName
);
TableToXls
.
process
(
tableStr
,
fout
);
fout
.
close
();
return
"excel/"
+
fileName
;
}
catch
(
Exception
ex
){
log
.
error
(
ex
.
getMessage
(),
ex
);
}
return
null
;
}
}
bsoft-api/src/main/resources/application-dev.properties
View file @
1931eaaf
...
@@ -5,7 +5,7 @@ jdbc.password=123456
...
@@ -5,7 +5,7 @@ jdbc.password=123456
jdbc.driverClass
=
com.mysql.jdbc.Driver
jdbc.driverClass
=
com.mysql.jdbc.Driver
spring.datasource.driver-class-name
=
oracle.jdbc.driver.OracleDriver
spring.datasource.driver-class-name
=
oracle.jdbc.driver.OracleDriver
spring.datasource.username
=
ll
spring.datasource.username
=
ch
spring.datasource.password
=
123456
spring.datasource.password
=
123456
spring.datasource.url
=
jdbc:oracle:thin:@192.168.18.171:1521:his
spring.datasource.url
=
jdbc:oracle:thin:@192.168.18.171:1521:his
...
...
bsoft-api/src/main/resources/application.properties
View file @
1931eaaf
...
@@ -13,4 +13,5 @@ config.path.exclude[0]=/login
...
@@ -13,4 +13,5 @@ config.path.exclude[0]=/login
# Add @EnableAspectJAutoProxy.
# Add @EnableAspectJAutoProxy.
spring.aop.auto
=
true
spring.aop.auto
=
true
# Whether subclass-based (CGLIB) proxies are to be created (true)
# Whether subclass-based (CGLIB) proxies are to be created (true)
spring.aop.proxy-target-class
=
false
spring.aop.proxy-target-class
=
false
\ No newline at end of file
spring.jmx.enabled
=
false
\ No newline at end of file
bsoft-api/src/main/resources/mapper/SerDiseaseMapper.xml
View file @
1931eaaf
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
where ID = #{id,jdbcType=DECIMAL}
where ID = #{id,jdbcType=DECIMAL}
</select>
</select>
<select
id=
"selectByCode"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByCode"
resultMap=
"BaseResultMap"
>
select d.ID, d.CREATE_DATE, d.CREATE_USERID, d.STATE, d.MDC_CODE, d.MDC_NAME, d."DATE",d.MDC_NUM,
select
DISTINCT
d.ID, d.CREATE_DATE, d.CREATE_USERID, d.STATE, d.MDC_CODE, d.MDC_NAME, d."DATE",d.MDC_NUM,
d.PARENT_ID, d."LEVEL", d.ORG_ID, d.ORG_NAME
d.PARENT_ID, d."LEVEL", d.ORG_ID, d.ORG_NAME
from SER_DISEASE d,SER_DISEASE_DOC_RS rs
from SER_DISEASE d,SER_DISEASE_DOC_RS rs
where d.STATE=1
where d.STATE=1
...
...
bsoft-api/src/test/resources/generatorConfig.xml
View file @
1931eaaf
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
<!-- <!– 主键生成方式 –>-->
<!-- <!– 主键生成方式 –>-->
<!-- <generatedKey column="id" sqlStatement="select SEQ_SYS_USER_ID.nextval from dual" identity="true" />-->
<!-- <generatedKey column="id" sqlStatement="select SEQ_SYS_USER_ID.nextval from dual" identity="true" />-->
<!-- </table>-->
<!-- </table>-->
<table
tableName=
"SER_DIM_VALUE"
schema=
"ll"
>
<table
tableName=
"SER_DIM_VALUE"
>
<generatedKey
column=
"id"
sqlStatement=
"select SEQ_SER_DIM_VALUE_ID.nextval from dual"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"select SEQ_SER_DIM_VALUE_ID.nextval from dual"
identity=
"true"
/>
</table>
</table>
<!-- <table tableName="DIC_IND" schema="ll" >-->
<!-- <table tableName="DIC_IND" schema="ll" >-->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment