Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
a90aea4e
Commit
a90aea4e
authored
Mar 31, 2019
by
kevin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#
parent
90ce5d07
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
287 additions
and
164 deletions
+287
-164
FileExcelUtil.java
...main/java/pwc/taxtech/atms/common/util/FileExcelUtil.java
+182
-81
ReportController.java
...in/java/pwc/taxtech/atms/controller/ReportController.java
+15
-6
CitReportServiceImpl.java
...a/pwc/taxtech/atms/service/impl/CitReportServiceImpl.java
+50
-50
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+12
-8
ND.java
...wc/taxtech/atms/vat/service/impl/report/functions/ND.java
+14
-4
RSUMIF.java
...axtech/atms/vat/service/impl/report/functions/RSUMIF.java
+1
-0
index.html
atms-web/src/main/webapp/WEB-INF/templates/index.html
+1
-1
tb-ebit-form.html
...-web/src/main/webapp/app/analysis/table/tb-ebit-form.html
+3
-3
tax-report-cell-detail-modal.ctrl.js
...rt-cell-detail-modal/tax-report-cell-detail-modal.ctrl.js
+4
-5
tax-report-cell-detail-modal.html
...eport-cell-detail-modal/tax-report-cell-detail-modal.html
+2
-2
tax-report-cell-detail-modal.ctrl.js
...rt-cell-detail-modal/tax-report-cell-detail-modal.ctrl.js
+2
-3
tax-report-cell-detail-modal.html
...eport-cell-detail-modal/tax-report-cell-detail-modal.html
+1
-1
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/util/FileExcelUtil.java
View file @
a90aea4e
...
...
@@ -7,30 +7,35 @@ package pwc.taxtech.atms.common.util;
* @Date 3/31/2019 12:35 PM
* Version 1.0
**/
import
com.google.common.collect.Lists
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
sun.misc.BASE64Encoder
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
@SuppressWarnings
(
"restriction"
)
public
class
FileExcelUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FileExcelUtil
.
class
);
/**
* 编译下载的文件名
*
* @param filename
* @param agent
* @return
* @throws IOException
*/
public
static
String
encodeDownloadFilename
(
String
filename
,
String
agent
)
throws
IOException
{
public
static
String
encodeDownloadFilename
(
String
filename
,
String
agent
)
throws
IOException
{
if
(
agent
.
contains
(
"Firefox"
))
{
// 火狐浏览器
filename
=
"=?UTF-8?B?"
+
new
BASE64Encoder
().
encode
(
filename
.
getBytes
(
"utf-8"
))
...
...
@@ -38,50 +43,53 @@ public class FileExcelUtil {
filename
=
filename
.
replaceAll
(
"\r\n"
,
""
);
}
else
{
// IE及其他浏览器
filename
=
URLEncoder
.
encode
(
filename
,
"utf-8"
);
filename
=
filename
.
replace
(
"+"
,
" "
);
filename
=
filename
.
replace
(
"+"
,
" "
);
}
return
filename
;
}
/**
* 创建文件夹;
*
* @param path
*/
public
static
void
createFile
(
String
path
)
{
public
static
File
createFile
(
String
path
)
{
File
file
=
new
File
(
path
);
//判断文件是否存在;
if
(!
file
.
exists
())
{
//创建文件;
file
.
mkdirs
();
}
return
file
;
}
/**
* 生成.zip文件;
*
* @param path
* @throws IOException
*/
public
static
ZipOutputStream
craeteZipPath
(
String
path
)
throws
IOException
{
public
static
ZipOutputStream
craeteZipPath
(
String
path
)
throws
IOException
{
ZipOutputStream
zipOutputStream
=
null
;
File
file
=
new
File
(
path
+
DateUtils
.
nowDateFormat
()+
".zip"
);
File
file
=
new
File
(
path
+
DateUtils
.
nowDateFormat
()
+
".zip"
);
zipOutputStream
=
new
ZipOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
file
)));
File
[]
files
=
new
File
(
path
).
listFiles
();
FileInputStream
fileInputStream
=
null
;
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
if
(
files
!=
null
&&
files
.
length
>
0
)
{
for
(
File
excelFile:
files
)
{
if
(
files
!=
null
&&
files
.
length
>
0
)
{
for
(
File
excelFile
:
files
)
{
String
fileName
=
excelFile
.
getName
();
fileInputStream
=
new
FileInputStream
(
excelFile
);
//放入压缩zip包中;
zipOutputStream
.
putNextEntry
(
new
ZipEntry
(
path
+
"/"
+
fileName
));
zipOutputStream
.
putNextEntry
(
new
ZipEntry
(
path
+
"/"
+
fileName
));
//读取文件;
while
((
len
=
fileInputStream
.
read
(
buf
))
>
0
)
{
while
((
len
=
fileInputStream
.
read
(
buf
))
>
0
)
{
zipOutputStream
.
write
(
buf
,
0
,
len
);
}
//关闭;
zipOutputStream
.
closeEntry
();
if
(
fileInputStream
!=
null
)
{
if
(
fileInputStream
!=
null
)
{
fileInputStream
.
close
();
}
}
...
...
@@ -94,82 +102,16 @@ public class FileExcelUtil {
}
/**
* //压缩文件
* @param srcfile 要压缩的文件数组
* @param zipfile 生成的zip文件对象
*/
public
static
void
ZipFiles
(
java
.
io
.
File
[]
srcfile
,
File
zipfile
)
throws
Exception
{
byte
[]
buf
=
new
byte
[
1024
];
FileOutputStream
fos
=
new
FileOutputStream
(
zipfile
);
ZipOutputStream
out
=
new
ZipOutputStream
(
fos
);
for
(
int
i
=
0
;
i
<
srcfile
.
length
;
i
++)
{
FileInputStream
in
=
new
FileInputStream
(
srcfile
[
i
]);
out
.
putNextEntry
(
new
ZipEntry
(
srcfile
[
i
].
getName
()));
int
len
;
while
((
len
=
in
.
read
(
buf
))
>
0
)
{
out
.
write
(
buf
,
0
,
len
);
}
out
.
closeEntry
();
in
.
close
();
}
out
.
close
();
fos
.
flush
();
fos
.
close
();
}
/**
* 删除文件夹及文件夹下所有文件
* @param dir
* @return
*/
public
static
boolean
deleteDir
(
File
dir
)
{
if
(
dir
==
null
||
!
dir
.
exists
()){
return
true
;
}
if
(
dir
.
isDirectory
())
{
String
[]
children
=
dir
.
list
();
//递归删除目录中的子目录下
for
(
int
i
=
0
;
i
<
children
.
length
;
i
++)
{
boolean
success
=
deleteDir
(
new
File
(
dir
,
children
[
i
]));
if
(!
success
)
{
return
false
;
}
}
}
// 目录此时为空,可以删除
return
dir
.
delete
();
}
/**
* 生成html
* @param msg
* @return
*/
public
static
String
getErrorHtml
(
String
msg
)
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<html>"
);
sb
.
append
(
"<head>"
);
sb
.
append
(
"<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>"
);
sb
.
append
(
"</head>"
);
sb
.
append
(
"<body>"
);
sb
.
append
(
"<div id='errorInfo'> "
);
sb
.
append
(
"</div>"
);
sb
.
append
(
"<script>alert('"
+
msg
+
"')</script>"
);
sb
.
append
(
"</body>"
);
sb
.
append
(
"</html>"
);
return
sb
.
toString
();
}
/**
* 设置下载excel的响应头信息
*
* @param response
* @param request
* @param fileName
* @throws IOException
*/
public
static
void
setExcelHeadInfo
(
HttpServletResponse
response
,
HttpServletRequest
request
,
String
fileName
)
{
public
static
void
setExcelHeadInfo
(
HttpServletResponse
response
,
HttpServletRequest
request
,
String
fileName
)
{
try
{
// 获取客户端浏览器的类型
String
agent
=
request
.
getHeader
(
"User-Agent"
);
...
...
@@ -178,16 +120,17 @@ public class FileExcelUtil {
// 告诉客户端允许断点续传多线程连接下载
response
.
setHeader
(
"Accept-Ranges"
,
"bytes"
);
//文件后缀
response
.
setContentType
(
"application/vnd.
ms-excel;charset=UTF-8
"
);
response
.
setContentType
(
"application/vnd.
openxmlformats-officedocument.spreadsheetml.sheet
"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
encodingFileName
);
}
catch
(
IOException
e
)
{
logger
.
error
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getMethodName
()
+
"发生的异常是: "
,
e
);
logger
.
error
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getMethodName
()
+
"发生的异常是: "
,
e
);
throw
new
RuntimeException
(
e
);
}
}
/**
* 设置下载zip的响应头信息
*
* @param response
* @param fileName 文件名
* @param request
...
...
@@ -206,4 +149,161 @@ public class FileExcelUtil {
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
encodingFileName
);
}
/**
* 下载excel
*
* @param request
* @param response
* @param fileName
* @param workbook
* @time 2018年6月25日11:47:07
*/
private
void
downloadExcel
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
fileName
,
Workbook
workbook
)
{
//一个流两个头
//设置下载excel的头信息
FileExcelUtil
.
setExcelHeadInfo
(
response
,
request
,
fileName
);
// 写出文件
ServletOutputStream
os
=
null
;
try
{
os
=
response
.
getOutputStream
();
workbook
.
write
(
os
);
}
catch
(
IOException
e
)
{
logger
.
error
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getMethodName
()
+
"发生的异常是: "
,
e
);
throw
new
RuntimeException
(
e
);
}
finally
{
try
{
if
(
os
!=
null
)
{
os
.
flush
();
os
.
close
();
}
if
(
workbook
!=
null
)
{
workbook
.
close
();
}
}
catch
(
Exception
e1
)
{
logger
.
error
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getMethodName
()
+
"发生的异常是: "
,
e1
);
throw
new
RuntimeException
(
e1
);
}
}
}
/**
* 生成excel到指定路径
*
* @param wb
* @Param path 文件路径,包括zip文件夹路径
* @throws Exception
*/
public
static
List
<
File
>
generateExcelToPath
(
Workbook
wb
,
String
path
)
throws
Exception
{
String
[]
pathArr
=
path
.
split
(
"\\\\"
);
String
zipDir
=
pathArr
[
0
];
FileExcelUtil
.
createFile
(
zipDir
);
FileOutputStream
fos
=
null
;
List
<
File
>
listFile
=
Lists
.
newArrayList
();
try
{
fos
=
new
FileOutputStream
(
path
);
wb
.
write
(
fos
);
listFile
.
add
(
new
File
(
path
));
}
finally
{
if
(
fos
!=
null
)
{
fos
.
flush
();
fos
.
close
();
}
if
(
wb
!=
null
)
{
wb
.
close
();
}
}
return
listFile
;
}
/**
* 将批量文件打包下载成zip
*
* @param request
* @param response
* @param zipName 下载的zip名
* @param files 要打包的批量文件
* @param zipPath 生成的zip路径
* @throws Exception
*/
public
static
synchronized
void
downloadZip
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
zipName
,
List
<
File
>
files
,
String
zipPath
)
throws
Exception
{
File
srcfile
[]
=
new
File
[
files
.
size
()];
File
zip
=
new
File
(
zipPath
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
srcfile
[
i
]
=
files
.
get
(
i
);
}
//生成.zip文件;
FileInputStream
inStream
=
null
;
ServletOutputStream
os
=
null
;
try
{
//设置下载zip的头信息
FileExcelUtil
.
setZipDownLoadHeadInfo
(
response
,
request
,
zipName
);
os
=
response
.
getOutputStream
();
FileExcelUtil
.
ZipFiles
(
srcfile
,
zip
);
inStream
=
new
FileInputStream
(
zip
);
byte
[]
buf
=
new
byte
[
4096
];
int
readLength
;
while
(((
readLength
=
inStream
.
read
(
buf
))
!=
-
1
))
{
os
.
write
(
buf
,
0
,
readLength
);
}
}
finally
{
if
(
inStream
!=
null
)
{
inStream
.
close
();
}
if
(
os
!=
null
)
{
os
.
flush
();
os
.
close
();
}
deleteDir
(
zip
);
}
}
/**
* //压缩文件
*
* @param srcfile 要压缩的文件数组
* @param zipfile 生成的zip文件对象
*/
public
static
void
ZipFiles
(
java
.
io
.
File
[]
srcfile
,
File
zipfile
)
throws
Exception
{
byte
[]
buf
=
new
byte
[
1024
];
FileOutputStream
fos
=
new
FileOutputStream
(
zipfile
);
ZipOutputStream
out
=
new
ZipOutputStream
(
fos
);
for
(
int
i
=
0
;
i
<
srcfile
.
length
;
i
++)
{
FileInputStream
in
=
new
FileInputStream
(
srcfile
[
i
]);
out
.
putNextEntry
(
new
ZipEntry
(
srcfile
[
i
].
getName
()));
int
len
;
while
((
len
=
in
.
read
(
buf
))
>
0
)
{
out
.
write
(
buf
,
0
,
len
);
}
out
.
closeEntry
();
in
.
close
();
}
out
.
close
();
fos
.
flush
();
fos
.
close
();
}
/**
* 删除文件夹及文件夹下所有文件
*
* @param dir
* @return
*/
public
static
boolean
deleteDir
(
File
dir
)
{
if
(
dir
==
null
||
!
dir
.
exists
())
{
return
true
;
}
if
(
dir
.
isDirectory
())
{
String
[]
children
=
dir
.
list
();
//递归删除目录中的子目录下
for
(
int
i
=
0
;
i
<
children
.
length
;
i
++)
{
boolean
success
=
deleteDir
(
new
File
(
dir
,
children
[
i
]));
if
(!
success
)
{
return
false
;
}
}
}
// 目录此时为空,可以删除
return
dir
.
delete
();
}
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/controller/ReportController.java
View file @
a90aea4e
...
...
@@ -8,6 +8,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
pwc.taxtech.atms.common.message.ErrorMessage
;
import
pwc.taxtech.atms.common.util.FileExcelUtil
;
import
pwc.taxtech.atms.constant.enums.EnumServiceType
;
import
pwc.taxtech.atms.dao.OrganizationMapper
;
import
pwc.taxtech.atms.dao.ProjectMapper
;
...
...
@@ -26,8 +27,10 @@ import pwc.taxtech.atms.vat.entity.*;
import
pwc.taxtech.atms.vat.service.impl.ReportServiceImpl
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.OutputStream
;
import
java.net.URISyntaxException
;
import
java.util.List
;
...
...
@@ -151,10 +154,10 @@ public class ReportController {
return
reportService
.
getCellData
(
reportId
,
from
);
}
private
static
OperationResultDto
<
ReportDataDto
>
operationResultDto
=
null
;
@RequestMapping
(
value
=
"reportEbitData"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
OperationResultDto
<
ReportDataDto
>
reportEbitData
(
@RequestBody
RequestParameterDto
requestParameterDto
)
{
OperationResultDto
operationResultDto
=
new
OperationResultDto
();
/*OperationResultDto resultDto = new OperationResultDto();
*//* if (requestParameterDto.getProjectId() == null || requestParameterDto.getReportId() == null) {
resultDto.setResult(false);
...
...
@@ -257,14 +260,16 @@ public class ReportController {
@RequestMapping
(
value
=
"doUpload"
,
method
=
RequestMethod
.
POST
)
public
OperationResultDto
doUploadAttach
(
@RequestParam
(
"fileName"
)
String
fileName
,
MultipartFile
file
,
String
remarks
,
@RequestParam
(
"activeCol"
)
Long
activeCol
,
@RequestParam
(
"activeRow"
)
Long
activeRow
,
@RequestParam
(
"activeTemplateId"
)
String
activeTemplateId
)
{
FileUpload
fileUpload
=
null
;
OperationResultDto
operationResultDto
=
new
OperationResultDto
();
try
{
fileUpload
=
didiFileUploadService
.
uploadFile
(
file
,
file
.
getOriginalFilename
(),
"附件上传"
);
operationResultDto
.
setData
(
reportService
.
bindPwcAttach
(
activeCol
,
activeRow
,
activeTemplateId
,
fileUpload
,
remarks
));
operationResultDto
.
setResultMsg
(
"success"
);
return
operationResultDto
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
operationResultDto
.
error
();
}
operationResultDto
.
success
();
reportService
.
bindPwcAttach
(
activeCol
,
activeRow
,
activeTemplateId
,
fileUpload
,
remarks
);
return
operationResultDto
;
}
@RequestMapping
(
"loadAttachList"
)
...
...
@@ -345,11 +350,14 @@ public class ReportController {
* 批量导出利润表
*/
@RequestMapping
(
"manyExport"
)
public
OperationResultDto
manyExport
(
@RequestBody
RequestParameterDto
requestParameterDto
)
{
public
OperationResultDto
manyExport
(
@RequestBody
RequestParameterDto
requestParameterDto
,
HttpServletResponse
response
,
HttpServletRequest
request
)
{
OperationResultDto
operationResultDto
=
new
OperationResultDto
();
String
zipName
=
"利润表"
;
try
{
reportService
.
manyExport
(
requestParameterDto
,
zipName
);
String
zipPath
=
"/zipDir"
;
//生成zip文件夹
FileExcelUtil
.
createFile
(
zipPath
);
reportService
.
manyExport
(
requestParameterDto
,
zipName
,
request
,
response
,
zipPath
);
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -357,6 +365,7 @@ public class ReportController {
return
operationResultDto
;
}
/**
* 将spread序列化字符串保存到数据库
*/
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/CitReportServiceImpl.java
View file @
a90aea4e
...
...
@@ -227,56 +227,56 @@ public class CitReportServiceImpl extends BaseService {
//===============================================start validation compute==========================================================
//todo: 1.get the data from workbook, then put the data into new workbook
Workbook
workbook4Validate
=
reportGenerator
.
createWorkBookByPeriodTemplate
(
resources
.
getPeriodTemplates
(),
genJob
);
copyDataToWorkbook4Validate
(
workbook
,
workbook4Validate
);
//todo: 2.get the validate formula in the cell_template_config
List
<
PeriodCellTemplateConfig
>
periodCellTemplateConfigs
=
resources
.
getPeriodCellTemplateConfigs
().
stream
()
.
filter
(
a
->
a
.
getDataSourceType
().
equals
(
CellDataSourceType
.
Validation
.
getCode
())).
collect
(
Collectors
.
toList
());
List
<
PeriodCellTemplateConfigDto
>
periodCellTemplateConfigDtos
=
new
ArrayList
<>();
periodCellTemplateConfigs
.
forEach
(
a
->
{
if
(
StringUtils
.
isNotBlank
(
a
.
getValidation
()))
{
Optional
<
Template
>
template
=
templates
.
stream
().
filter
(
t
->
t
.
getId
().
equals
(
a
.
getReportTemplateId
())).
findFirst
();
String
templateCode
=
template
.
isPresent
()
?
template
.
get
().
getCode
()
:
""
;
Integer
sheetNumber
=
template
.
isPresent
()
?
template
.
get
().
getOrderIndex
()
:
null
;
Optional
<
PeriodCellTemplate
>
periodCellTemplate
=
resources
.
getPeriodCellTemplates
().
stream
().
filter
(
c
->
c
.
getCellTemplateId
().
equals
(
a
.
getCellTemplateId
())).
findFirst
();
Integer
rowNumber
=
periodCellTemplate
.
isPresent
()
?
periodCellTemplate
.
get
().
getRowIndex
()
:
null
;
Integer
colNumber
=
periodCellTemplate
.
isPresent
()
?
periodCellTemplate
.
get
().
getColumnIndex
()
:
null
;
if
(
StringUtils
.
isNotBlank
(
templateCode
)
&&
rowNumber
!=
null
&&
colNumber
!=
null
)
{
String
replaceFormula
=
String
.
format
(
"BB(\"%s\",%d,%d,0,0)"
,
templateCode
,
colNumber
,
rowNumber
);
a
.
setParsedValidation
(
a
.
getValidation
().
replace
(
"aa()"
,
replaceFormula
));
PeriodCellTemplateConfigDto
periodCellTemplateConfigDto
=
new
PeriodCellTemplateConfigDto
();
periodCellTemplateConfigDto
.
setSheetNumber
(
sheetNumber
);
periodCellTemplateConfigDto
.
setRowNumber
(
rowNumber
);
periodCellTemplateConfigDto
.
setColNumber
(
colNumber
);
periodCellTemplateConfigDto
.
setValidation
(
a
.
getValidation
());
periodCellTemplateConfigDto
.
setParsedValidation
(
a
.
getParsedValidation
());
periodCellTemplateConfigDto
.
setCellTemplateId
(
periodCellTemplate
.
get
().
getCellTemplateId
());
periodCellTemplateConfigDto
.
setProjectId
(
projectId
);
periodCellTemplateConfigDto
.
setPeriodParam
(
periodParam
);
periodCellTemplateConfigDtos
.
add
(
periodCellTemplateConfigDto
);
}
}
});
//todo: 3.use the validate formula to recalculate the new workbook
periodCellTemplateConfigDtos
.
forEach
(
a
->
{
workbook4Validate
.
getSheetAt
(
a
.
getSheetNumber
()
-
1
).
getRow
(
a
.
getRowNumber
()).
getCell
(
a
.
getColNumber
()).
setCellFormula
(
a
.
getParsedValidation
());
});
reportGenerator
.
addFunctionsAndContext
(
workbook4Validate
,
functions
,
reportGenerator
.
initContext
(
resources
,
periodParam
));
FormulaEvaluator
validateEvaluator
=
workbook4Validate
.
getCreationHelper
().
createFormulaEvaluator
();
validateEvaluator
.
evaluateAll
();
//todo: 4.then save the validation result to cellData table
periodCellTemplateConfigDtos
.
forEach
(
a
->
{
//todo: according to periodParam , projectId, cellTemplateId to update the cellData table
PeriodCellDataExample
periodCellDataExample
=
new
PeriodCellDataExample
();
periodCellDataExample
.
createCriteria
().
andCellTemplateIdEqualTo
(
a
.
getCellTemplateId
()).
andProjectIdEqualTo
(
a
.
getProjectId
()).
andPeriodEqualTo
(
a
.
getPeriodParam
());
Optional
<
PeriodCellData
>
cellData
=
periodCellDataMapper
.
selectByExample
(
periodCellDataExample
).
stream
().
findFirst
();
if
(
cellData
.
isPresent
())
{
cellData
.
get
().
setValidateFormulaExp
(
a
.
getParsedValidation
());
Boolean
result
=
workbook4Validate
.
getSheetAt
(
a
.
getSheetNumber
()
-
1
).
getRow
(
a
.
getRowNumber
()).
getCell
(
a
.
getColNumber
()).
getBooleanCellValue
();
cellData
.
get
().
setValidateResult
(
result
.
toString
());
periodCellDataMapper
.
updateByPrimaryKey
(
cellData
.
get
());
}
});
//
Workbook workbook4Validate = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob);
//
copyDataToWorkbook4Validate(workbook, workbook4Validate);
//
//todo: 2.get the validate formula in the cell_template_config
//
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = resources.getPeriodCellTemplateConfigs().stream()
//
.filter(a -> a.getDataSourceType().equals(CellDataSourceType.Validation.getCode())).collect(Collectors.toList());
//
List<PeriodCellTemplateConfigDto> periodCellTemplateConfigDtos = new ArrayList<>();
//
periodCellTemplateConfigs.forEach(a -> {
//
if (StringUtils.isNotBlank(a.getValidation())) {
//
Optional<Template> template = templates.stream().filter(t -> t.getId().equals(a.getReportTemplateId())).findFirst();
//
String templateCode = template.isPresent() ? template.get().getCode() : "";
//
Integer sheetNumber = template.isPresent() ? template.get().getOrderIndex() : null;
//
Optional<PeriodCellTemplate> periodCellTemplate = resources.getPeriodCellTemplates().stream().filter(c -> c.getCellTemplateId().equals(a.getCellTemplateId())).findFirst();
//
Integer rowNumber = periodCellTemplate.isPresent() ? periodCellTemplate.get().getRowIndex() : null;
//
Integer colNumber = periodCellTemplate.isPresent() ? periodCellTemplate.get().getColumnIndex() : null;
//
if (StringUtils.isNotBlank(templateCode) && rowNumber != null && colNumber != null) {
//
String replaceFormula = String.format("BB(\"%s\",%d,%d,0,0)", templateCode, colNumber, rowNumber);
//
a.setParsedValidation(a.getValidation().replace("aa()", replaceFormula));
//
PeriodCellTemplateConfigDto periodCellTemplateConfigDto = new PeriodCellTemplateConfigDto();
//
periodCellTemplateConfigDto.setSheetNumber(sheetNumber);
//
periodCellTemplateConfigDto.setRowNumber(rowNumber);
//
periodCellTemplateConfigDto.setColNumber(colNumber);
//
periodCellTemplateConfigDto.setValidation(a.getValidation());
//
periodCellTemplateConfigDto.setParsedValidation(a.getParsedValidation());
//
periodCellTemplateConfigDto.setCellTemplateId(periodCellTemplate.get().getCellTemplateId());
//
periodCellTemplateConfigDto.setProjectId(projectId);
//
periodCellTemplateConfigDto.setPeriodParam(periodParam);
//
periodCellTemplateConfigDtos.add(periodCellTemplateConfigDto);
//
}
//
}
//
});
//
//todo: 3.use the validate formula to recalculate the new workbook
//
periodCellTemplateConfigDtos.forEach(a -> {
//
workbook4Validate.getSheetAt(a.getSheetNumber() - 1).getRow(a.getRowNumber()).getCell(a.getColNumber()).setCellFormula(a.getParsedValidation());
//
});
//
reportGenerator.addFunctionsAndContext(workbook4Validate, functions, reportGenerator.initContext(resources, periodParam));
//
FormulaEvaluator validateEvaluator = workbook4Validate.getCreationHelper().createFormulaEvaluator();
//
validateEvaluator.evaluateAll();
//
//todo: 4.then save the validation result to cellData table
//
periodCellTemplateConfigDtos.forEach(a -> {
//
//todo: according to periodParam , projectId, cellTemplateId to update the cellData table
//
PeriodCellDataExample periodCellDataExample = new PeriodCellDataExample();
//
periodCellDataExample.createCriteria().andCellTemplateIdEqualTo(a.getCellTemplateId()).andProjectIdEqualTo(a.getProjectId()).andPeriodEqualTo(a.getPeriodParam());
//
Optional<PeriodCellData> cellData = periodCellDataMapper.selectByExample(periodCellDataExample).stream().findFirst();
//
if (cellData.isPresent()) {
//
cellData.get().setValidateFormulaExp(a.getParsedValidation());
//
Boolean result = workbook4Validate.getSheetAt(a.getSheetNumber() - 1).getRow(a.getRowNumber()).getCell(a.getColNumber()).getBooleanCellValue();
//
cellData.get().setValidateResult(result.toString());
//
periodCellDataMapper.updateByPrimaryKey(cellData.get());
//
}
//
});
//===============================================end validation compute==============================================================
setStatus
(
genJob
,
STATUS_END
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
a90aea4e
...
...
@@ -15,6 +15,7 @@ import org.apache.poi.ss.usermodel.*;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.nutz.mvc.view.HttpServerResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -27,6 +28,7 @@ import pwc.taxtech.atms.common.CommonUtils;
import
pwc.taxtech.atms.common.POIUtil
;
import
pwc.taxtech.atms.common.message.ErrorMessage
;
import
pwc.taxtech.atms.common.util.DataUtil
;
import
pwc.taxtech.atms.common.util.FileExcelUtil
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.Constant
;
...
...
@@ -51,6 +53,8 @@ import pwc.taxtech.atms.vat.entity.*;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.net.URISyntaxException
;
...
...
@@ -68,7 +72,7 @@ public class ReportServiceImpl extends BaseService {
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ReportServiceImpl
.
class
);
private
BlockingQueue
<
PeriodJob
>
queue
=
new
LinkedBlockingQueue
<>();
private
final
static
String
[]
functions
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
,
"XXFP"
,
"GZSD"
,
"PC"
,
"JXFPMX"
,
"JXFP"
,
"PSUM"
,
"DFFS"
,
"JFFS"
,
"WPSR"
,
"WPNAME"
,
"WPTYPE"
,
"SUM2"
,
"RSUMIF"
,
"SUM"
,
"KPSR"
,
"TBM"
};
"JXFP"
,
"PSUM"
,
"DFFS"
,
"JFFS"
,
"WPSR"
,
"WPNAME"
,
"WPTYPE"
,
"SUM2"
,
"RSUMIF"
,
"SUM"
,
"KPSR"
,
"TBM"
};
@Autowired
private
ReportGeneratorImpl
reportGenerator
;
...
...
@@ -2213,11 +2217,10 @@ public class ReportServiceImpl extends BaseService {
}
@Resource
private
PwcReportAttachMapper
pwcReportAttachMapper
;
public
void
bindPwcAttach
(
Long
activeCol
,
Long
activeRow
,
String
activeTemplateId
,
FileUpload
file
,
String
remarks
)
{
public
PwcReportAttach
bindPwcAttach
(
Long
activeCol
,
Long
activeRow
,
String
activeTemplateId
,
FileUpload
file
,
String
remarks
)
{
PwcReportAttach
pwcReportAttach
=
new
PwcReportAttach
();
pwcReportAttach
.
setCol
(
activeCol
);
pwcReportAttach
.
setCreateTime
(
file
.
getCreateTime
());
...
...
@@ -2230,6 +2233,7 @@ public class ReportServiceImpl extends BaseService {
pwcReportAttach
.
setRemarks
(
remarks
);
pwcReportAttachMapper
.
insert
(
pwcReportAttach
);
System
.
out
.
println
(
"==>>>附件绑定成功"
);
return
pwcReportAttach
;
}
public
List
<
PwcReportAttach
>
loadAttachList
(
ReportAttachDto
param
)
{
...
...
@@ -2377,7 +2381,7 @@ public class ReportServiceImpl extends BaseService {
*
* @param requestParameterDto
*/
public
void
manyExport
(
RequestParameterDto
requestParameterDto
,
String
zipFileName
)
throws
URISyntaxException
{
public
void
manyExport
(
RequestParameterDto
requestParameterDto
,
String
zipFileName
,
HttpServletRequest
request
,
HttpServletResponse
response
,
String
zipPath
)
throws
URISyntaxException
{
try
{
FileOutputStream
out
=
new
FileOutputStream
(
zipFileName
);
//要输出的文件名字
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -2395,7 +2399,6 @@ public class ReportServiceImpl extends BaseService {
filePath
=
this
.
getClass
().
getResource
(
""
).
toURI
().
getPath
();
String
tempPath
=
filePath
.
substring
(
0
,
filePath
.
indexOf
(
"classes"
)
+
"\\classes"
.
length
());
templateFile
=
new
File
(
tempPath
+
templatePath
);
OutputStream
out
=
null
;
//获取当前期间进行过保存更新的机构的数据
EbitCellDataExample
example
=
new
EbitCellDataExample
();
EbitCellDataExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
...
@@ -2449,16 +2452,17 @@ public class ReportServiceImpl extends BaseService {
}
}
workbooksList
.
add
(
workbook
);
//将workbook生成file文件
String
path
=
"\\\\zipDir\\\\"
+
requestParameterDto
.
getPeriod
()
+
Math
.
random
()
+
"利润表"
;
FileExcelUtil
.
downloadZip
(
request
,
response
,
zipFileName
,
FileExcelUtil
.
generateExcelToPath
(
workbook
,
path
),
zipPath
);
}
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
// FileOutputStream fileOut = new FileOutputStream(path);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/ND.java
View file @
a90aea4e
...
...
@@ -5,10 +5,13 @@ import org.apache.poi.ss.formula.eval.NumberEval;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.dto.vatdto.RSUMIFParasBo
;
import
pwc.taxtech.atms.vat.entity.PeriodFormulaBlock
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
import
java.
util.Calendar
;
import
java.util.
Date
;
import
java.
math.BigDecimal
;
import
java.util.
*
;
/// <summary>
...
...
@@ -26,6 +29,7 @@ public class ND extends FunctionBase implements FreeRefFunction {
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
List
<
Object
>
dataSource
=
new
ArrayList
<>();
Calendar
calendar
=
Calendar
.
getInstance
();
Date
creatTime
=
calendar
.
getTime
();
int
value
=
getIntParam
(
args
[
0
],
ec
);
...
...
@@ -34,7 +38,7 @@ public class ND extends FunctionBase implements FreeRefFunction {
String
formulaExpression
=
"ND("
+
value
+
")"
;
value
=
value
+
currentYear
;
logger
.
debug
(
formulaExpression
);
PeriodFormulaBlock
periodFormulaBlock
=
new
PeriodFormulaBlock
();
/*
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIdService.nextId());
periodFormulaBlock.setPeriod(formulaContext.getPeriod());
periodFormulaBlock.setReportId(0L);
...
...
@@ -45,7 +49,12 @@ public class ND extends FunctionBase implements FreeRefFunction {
periodFormulaBlock.setCreateTime(creatTime);
periodFormulaBlock.setUpdateTime(creatTime);
periodFormulaBlock.setUpdateBy("Admin");
SpringContextUtil
.
formulaBlockMapper
.
insertSelective
(
periodFormulaBlock
);
SpringContextUtil.formulaBlockMapper.insertSelective(periodFormulaBlock);*/
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
AssetDetailDataSourceDto
,
new
BigDecimal
(
value
),
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
0
,
ec
,
formulaExpression
,
new
BigDecimal
(
value
),
dataSourceId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
value
);
}
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/RSUMIF.java
View file @
a90aea4e
...
...
@@ -9,6 +9,7 @@ import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceType
;
import
pwc.taxtech.atms.dto.TableRule
;
import
pwc.taxtech.atms.dto.vatdto.RSUMIFParasBo
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellTableSUMIFDataSourceDto
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
...
...
atms-web/src/main/webapp/WEB-INF/templates/index.html
View file @
a90aea4e
...
...
@@ -63,7 +63,7 @@
<!--@Html.AntiForgeryToken()-->
<div
class=
"wrapper"
>
<app-nav></app-nav>
<div
class=
"page-wrapper"
style=
"position:relative;overflow
-x:hidden
;margin-top:55px"
>
<div
class=
"page-wrapper"
style=
"position:relative;overflow
:scroll
;margin-top:55px"
>
<div
class=
"main-contents"
ui-view
></div>
<div
class=
"data-import-contents"
ui-view=
"importContent"
></div>
<!--style="display: none"-->
</div>
...
...
atms-web/src/main/webapp/app/analysis/table/tb-ebit-form.html
View file @
a90aea4e
...
...
@@ -2,8 +2,8 @@
<!--Report SpreadJS-->
<div
class=
"row"
style=
" height: 71px; background: #ccc;"
>
<div
class=
"col-sm-7"
style=
" margin-top: 20px;"
>
<div
class=
"col-sm-
6
"
>
<span
class=
"text-bold"
translate=
"SelectedOrganization"
style=
" top: -11px; position: relative;"
>
:
</span>
<div
class=
"col-sm-
8
"
>
<span
class=
"text-bold"
translate=
"SelectedOrganization"
style=
" top: -11px; position: relative;
width: 320px;
"
>
:
</span>
<!-- <div id="dx-select-industry" class="tab-content-select industry " style=" display: inline-block;"
dx-select-box="dataSourceIndustryList" dx-item-alias="itemObj">
<div data-options="dxTemplate: { name: 'orgList' }" class="dx-item-content dx-list-item-content"
...
...
@@ -13,7 +13,7 @@
</div>-->
<div
dx-tag-box=
"selectOrgOptions"
style=
"width: 340px;display: inline-block"
></div>
</div>
<div
class=
"col-sm-
6
"
class=
"dateClass"
>
<div
class=
"col-sm-
4
"
class=
"dateClass"
>
<span
class=
"text-bold"
translate=
"InvoiceQJ"
>
:
</span>
<div
style=
" display: inline-block;"
>
<input
type=
"text"
id=
"ebitDatepacker"
class=
"datepicker"
style=
"width:120px;height: 34px;"
...
...
atms-web/src/main/webapp/app/cit/report/tax-report-cell-detail-modal/tax-report-cell-detail-modal.ctrl.js
View file @
a90aea4e
...
...
@@ -2487,7 +2487,7 @@
{
caption
:
'文件名'
,
dataField
:
"fileName"
,
cellTemplate
:
function
(
container
,
options
)
{
try
{
$
(
'<a href="'
+
options
.
data
.
fileUrl
+
'" target="_blank" style="cursor: pointer">"'
+
options
.
data
.
fileName
+
'"</a> '
)
$
(
'<a href="'
+
options
.
data
.
fileUrl
+
'"
target="_blank" style="cursor: pointer">"'
+
options
.
data
.
fileName
+
'"</a> '
)
.
appendTo
(
container
);
}
catch
(
e
)
{
...
...
@@ -2502,7 +2502,7 @@
{
caption
:
'操作'
,
cellTemplate
:
function
(
container
,
options
)
{
try
{
$
(
'<button type="button" class="btn btn-in-grid" onclick = "deleteAttach('
+
options
.
data
.
id
+
')"><i class="material-icons middle" style="vertical-align: text-bottom">delete</i>删除</button> '
)
$
(
'<button type="button" class="btn btn-in-grid"
style="margin-top: -11px;"
onclick = "deleteAttach('
+
options
.
data
.
id
+
')"><i class="material-icons middle" style="vertical-align: text-bottom">delete</i>删除</button> '
)
.
appendTo
(
container
);
}
catch
(
e
)
{
...
...
@@ -2665,10 +2665,9 @@
console
.
log
(
'progress: '
+
progressPercentage
+
'% '
);
}).
success
(
function
(
data
,
status
,
headers
,
config
)
{
if
(
data
.
resultMsg
)
{
SweetAlert
.
error
(
data
.
resultMsg
)
re
turn
;
SweetAlert
.
info
(
data
.
resultMsg
)
re
freshAttachData
(
data
)
;
}
refreshAttachData
(
data
);
}).
error
(
function
(
data
,
status
,
headers
,
config
)
{
$
(
'#addCellAttachmentContainer'
).
modal
(
'hide'
);
SweetAlert
.
error
(
status
+
'错误'
+
",上传失败"
)
...
...
atms-web/src/main/webapp/app/cit/report/tax-report-cell-detail-modal/tax-report-cell-detail-modal.html
View file @
a90aea4e
...
...
@@ -22,8 +22,8 @@
<!--{{'ModelAnalysisResults' | translate}}</span>-->
<span
ng-show=
"detail.validationErrorList && detail.validationErrorList.length > 0"
ng-model=
"tabType"
uib-btn-radio=
"3"
><i
class=
"fa fa-exclamation-circle red-color"
></i>
{{'ReportCheckResult' | translate}}
</span>
<span
ng-model=
"tabType"
uib-btn-radio=
"4"
>
{{'cellComment'|translate}}
</span
>
<span
ng-model=
"tabType"
uib-btn-radio=
"5"
ng-click =
"loadAttach()"
>
{{'RelatedAttach'|translate}}
dsdsdsdssd
</span>
<!-- <span ng-model="tabType" uib-btn-radio="4">{{'cellComment'|translate}}</span>--
>
<span
ng-model=
"tabType"
uib-btn-radio=
"5"
ng-click =
"loadAttach()"
>
{{'RelatedAttach'|translate}}
</span>
</div>
<div
class=
"content-info"
ng-show=
"tabType === 1"
>
...
...
atms-web/src/main/webapp/app/common/controls/tax-report-cell-detail-modal/tax-report-cell-detail-modal.ctrl.js
View file @
a90aea4e
...
...
@@ -2514,10 +2514,9 @@
console
.
log
(
'progress: '
+
progressPercentage
+
'% '
);
}).
success
(
function
(
data
,
status
,
headers
,
config
)
{
if
(
data
.
resultMsg
)
{
SweetAlert
.
error
(
data
.
resultMsg
)
re
turn
;
SweetAlert
.
info
(
data
.
resultMsg
)
re
freshAttachData
(
data
)
;
}
refreshAttachData
(
data
);
}).
error
(
function
(
data
,
status
,
headers
,
config
)
{
$
(
'#addCellAttachmentContainer'
).
modal
(
'hide'
);
SweetAlert
.
error
(
status
+
'错误'
+
",上传失败"
)
...
...
atms-web/src/main/webapp/app/common/controls/tax-report-cell-detail-modal/tax-report-cell-detail-modal.html
View file @
a90aea4e
...
...
@@ -22,7 +22,7 @@
<!--{{'ModelAnalysisResults' | translate}}</span>-->
<span
ng-show=
"detail.validationErrorList && detail.validationErrorList.length > 0"
ng-model=
"tabType"
uib-btn-radio=
"3"
><i
class=
"fa fa-exclamation-circle red-color"
></i>
{{'ReportCheckResult' | translate}}
</span>
<span
ng-model=
"tabType"
uib-btn-radio=
"4"
>
{{'cellComment'|translate}}
</span
>
<!-- <span ng-model="tabType" uib-btn-radio="4">{{'cellComment'|translate}}</span>--
>
<span
ng-model=
"tabType"
uib-btn-radio=
"5"
ng-click =
"loadAttach()"
>
{{'RelatedAttach'|translate}}
</span>
</div>
...
...
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