Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-fb
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王衍超
cloud-fb
Commits
47fb12a2
Commit
47fb12a2
authored
Apr 27, 2021
by
杨清松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账单明细导出
parent
3e0e4d88
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
7 deletions
+112
-7
StatementAccountServiceImpl.java
...finance/internal/service/StatementAccountServiceImpl.java
+71
-4
StatementAccountService.java
...m/xyst/dinas/finance/service/StatementAccountService.java
+6
-1
StatementAccountController.java
...om/xyst/dinas/finance/web/StatementAccountController.java
+35
-2
statementAccount.xlsx
...finance/src/main/resources/template/statementAccount.xlsx
+0
-0
No files found.
backend/xyst.dinas.finance/src/main/java/com/xyst/dinas/finance/internal/service/StatementAccountServiceImpl.java
View file @
47fb12a2
package
com
.
xyst
.
dinas
.
finance
.
internal
.
service
;
import
java.math.BigDecimal
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.poi.hssf.usermodel.HSSFFont
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.inz.basis.team.pojo.ResponseObj
;
...
...
@@ -28,8 +44,7 @@ public class StatementAccountServiceImpl implements StatementAccountService{
private
StatementAccountDao
statementAccountDao
;
@Override
public
Object
queryStatementAccountByContractId
(
JSONObject
jsonObject
)
{
try
{
public
Map
<
String
,
Object
>
queryStatementAccountByContractId
(
JSONObject
jsonObject
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
KObject
>
artificialRechargeList
=
statementAccountDao
.
queryStatementAccountByContractId
(
jsonObject
,
ArtificialRechargeConstant
.
ENTITY
);
List
<
StatementAccount
>
statementAccounts
=
new
ArrayList
<
StatementAccount
>();
...
...
@@ -115,10 +130,62 @@ public class StatementAccountServiceImpl implements StatementAccountService{
}
map
.
put
(
"salesAmount"
,
salesAmount
);
map
.
put
(
"statementAccounts"
,
statementAccounts
);
return
ResponseObj
.
success
(
"查询成功"
,
map
);
return
map
;
}
@Value
(
"classpath:template/statementAccount.xlsx"
)
private
Resource
statementAccountResource
;
@Override
public
void
exportStatementAccountDetails
(
HttpServletResponse
response
,
JSONObject
param
)
{
Map
<
String
,
Object
>
statementAccountMap
=
queryStatementAccountByContractId
(
param
);
Workbook
xssfWorkbook
=
null
;
try
{
xssfWorkbook
=
new
XSSFWorkbook
(
statementAccountResource
.
getInputStream
());
CellStyle
textStyle
=
xssfWorkbook
.
createCellStyle
();
textStyle
.
setBorderBottom
(
CellStyle
.
BORDER_THIN
);
textStyle
.
setBorderTop
(
CellStyle
.
BORDER_THIN
);
textStyle
.
setBorderLeft
(
CellStyle
.
BORDER_THIN
);
textStyle
.
setBorderRight
(
CellStyle
.
BORDER_THIN
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy年MM月dd日"
);
//设置字体
Font
createFont
=
xssfWorkbook
.
createFont
();
createFont
.
setFontHeightInPoints
((
short
)
10
);
createFont
.
setFontName
(
"黑体"
);
textStyle
.
setFont
(
createFont
);
Sheet
sheetAt
=
xssfWorkbook
.
getSheetAt
(
0
);
List
<
StatementAccount
>
statementAccounts
=
(
List
<
StatementAccount
>)
statementAccountMap
.
get
(
"statementAccounts"
);
for
(
int
i
=
0
;
i
<
statementAccounts
.
size
();
i
++)
{
StatementAccount
statementAccount
=
statementAccounts
.
get
(
i
);
//从第2行开始写数据
Row
row
=
sheetAt
.
createRow
(
1
+
i
);
Cell
cell
=
row
.
createCell
(
0
);
cell
.
setCellValue
(
1
+
i
);
cell
.
setCellStyle
(
textStyle
);
Cell
cell1
=
row
.
createCell
(
1
);
cell1
.
setCellValue
(
statementAccount
.
getDealDate
());
cell1
.
setCellStyle
(
textStyle
);
Cell
cell2
=
row
.
createCell
(
2
);
cell2
.
setCellValue
(
statementAccount
.
getDealType
());
cell2
.
setCellStyle
(
textStyle
);
Cell
cell3
=
row
.
createCell
(
3
);
cell3
.
setCellValue
(
statementAccount
.
getDealAmount
().
doubleValue
());
cell3
.
setCellStyle
(
textStyle
);
}
String
fileName
=
URLEncoder
.
encode
(
"对账单明细.xlsx"
,
"utf-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename ="
+
fileName
);
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
xssfWorkbook
.
write
(
outputStream
);
xssfWorkbook
.
close
();
outputStream
.
flush
();
outputStream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ResponseObj
.
error
();
}
}
...
...
backend/xyst.dinas.finance/src/main/java/com/xyst/dinas/finance/service/StatementAccountService.java
View file @
47fb12a2
package
com
.
xyst
.
dinas
.
finance
.
service
;
import
java.util.Map
;
import
java.util.UUID
;
import
javax.servlet.http.HttpServletResponse
;
import
org.json.JSONObject
;
public
interface
StatementAccountService
{
Object
queryStatementAccountByContractId
(
JSONObject
jsonObject
);
Map
<
String
,
Object
>
queryStatementAccountByContractId
(
JSONObject
jsonObject
);
void
exportStatementAccountDetails
(
HttpServletResponse
response
,
JSONObject
param
);
}
backend/xyst.dinas.finance/src/main/java/com/xyst/dinas/finance/web/StatementAccountController.java
View file @
47fb12a2
package
com
.
xyst
.
dinas
.
finance
.
web
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.UUID
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -12,10 +17,11 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.beecode.inz.basis.team.pojo.ResponseObj
;
import
com.xyst.dinas.finance.service.StatementAccountService
;
/**
*
费用调整
*
对账单
*
* @author yangqingsong
* @date 2021年4月25日
...
...
@@ -30,7 +36,34 @@ public class StatementAccountController {
@ResponseBody
@RequestMapping
(
value
=
"/sand/user/finance/statementAccount/queryStatementAccountByContractId"
,
method
=
RequestMethod
.
POST
)
public
Object
queryStatementAccountByContractId
(
@RequestBody
String
body
)
{
return
statementAccountService
.
queryStatementAccountByContractId
(
new
JSONObject
(
body
));
try
{
Map
<
String
,
Object
>
statementAccountByContract
=
statementAccountService
.
queryStatementAccountByContractId
(
new
JSONObject
(
body
));
return
ResponseObj
.
success
(
"查询成功"
,
statementAccountByContract
);
}
catch
(
Exception
e
)
{
return
ResponseObj
.
error
();
}
}
@ResponseBody
@RequestMapping
(
value
=
"/sand/user/finance/exportStatementAccountDetails"
,
method
=
RequestMethod
.
POST
)
public
Object
exportStatementAccountDetails
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
request
.
setCharacterEncoding
(
"utf-8"
);
String
exportParamStr
=
request
.
getParameter
(
"exportParamStr"
);
response
.
reset
();
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"application/x-www-form-urlencoded"
);
JSONObject
obj
=
new
JSONObject
();
try
{
obj
.
put
(
"code"
,
200
);
JSONObject
param
=
new
JSONObject
(
exportParamStr
);
statementAccountService
.
exportStatementAccountDetails
(
response
,
param
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ResponseObj
.
error
();
}
return
obj
.
toString
();
}
}
backend/xyst.dinas.finance/src/main/resources/template/statementAccount.xlsx
0 → 100644
View file @
47fb12a2
File added
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