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
4f21b81c
Commit
4f21b81c
authored
Mar 20, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge档案管理
parent
df3c5b4a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
5 deletions
+76
-5
TaxDocumentServiceImpl.java
...pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
+71
-1
KPSR.java
.../taxtech/atms/vat/service/impl/report/functions/KPSR.java
+3
-4
FileTypesMapper.xml
...esources/pwc/taxtech/atms/dao/extends/FileTypesMapper.xml
+2
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
View file @
4f21b81c
...
...
@@ -22,6 +22,7 @@ import pwc.taxtech.atms.vat.entity.FileUpload;
import
pwc.taxtech.atms.vat.entity.ReportFileUpload
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
...
...
@@ -346,6 +347,76 @@ public class TaxDocumentServiceImpl {
}
}
public
void
downloadAllFile
(
HttpServletResponse
response
,
List
<
Long
>
ids
)
{
//如果只选择了一个附件,则不打包
if
(
null
!=
ids
&&
ids
.
size
()==
1
){
TaxDocumentExample
example
=
new
TaxDocumentExample
();
TaxDocumentExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andIdIn
(
ids
);
TaxDocument
taxDocument
=
taxDocumentMapper
.
selectByExample
(
example
).
get
(
0
);
String
urlPath
=
taxDocument
.
getFilePositionUrl
();
//如果url为null或空字符串而抛出异常
if
(
StringUtils
.
isBlank
(
urlPath
))
{
throw
new
RuntimeException
(
"文件url为空,id为:"
+
taxDocument
.
getId
());
}
//文件名称(带后缀)
String
fileName
=
StringUtils
.
isBlank
(
taxDocument
.
getFileOriginalName
())
?
"未知文件(请修改后缀名).xlsx"
:
taxDocument
.
getFileOriginalName
();
//获取需要下载的文件流
InputStream
is
=
null
;
BufferedInputStream
in
=
null
;
byte
[]
buffer
=
new
byte
[
1024
];
int
len
;
ServletOutputStream
out
=
null
;
try
{
URL
httpurl
=
new
URL
(
URLDecoder
.
decode
(
urlPath
,
"UTF-8"
));
HttpURLConnection
httpConn
=
(
HttpURLConnection
)
httpurl
.
openConnection
();
httpConn
.
setDoOutput
(
true
);
// 使用 URL 连接进行输出
httpConn
.
setDoInput
(
true
);
// 使用 URL 连接进行输入
httpConn
.
setUseCaches
(
false
);
// 忽略缓存
httpConn
.
setRequestMethod
(
"GET"
);
// 设置URL请求方法
//可设置请求头
httpConn
.
setRequestProperty
(
"Content-Type"
,
"application/octet-stream"
);
httpConn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
// 维持长连接
httpConn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
httpConn
.
connect
();
if
(
httpConn
.
getResponseCode
()
>=
400
)
{
is
=
httpConn
.
getErrorStream
();
}
else
{
is
=
httpConn
.
getInputStream
();
}
in
=
new
BufferedInputStream
(
is
);
out
=
response
.
getOutputStream
();
//文件流循环写入ZipOutputStream
while
((
len
=
in
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
len
);
}
}
catch
(
IOException
e
)
{
log
.
error
(
"单个附件下载异常:"
+
e
.
getMessage
());
}
finally
{
if
(
null
!=
out
){
try
{
out
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"关闭输出流错误:"
+
e
.
getMessage
());
}
}
if
(
null
!=
is
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"关闭输入流错误:"
+
e
.
getMessage
());
}
}
if
(
null
!=
in
)
{
try
{
in
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"关闭缓存输入流错误:"
+
e
.
getMessage
());
}
}
}
return
;
}
//如果选择了多个附件
String
downloadName
=
"多选附件.zip"
;
try
{
response
.
setContentType
(
"multipart/form-data"
);
...
...
@@ -353,7 +424,6 @@ public class TaxDocumentServiceImpl {
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
"下载文件名编码时出现错误."
,
e
);
}
OutputStream
outputStream
=
null
;
ZipOutputStream
zos
=
null
;
try
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/KPSR.java
View file @
4f21b81c
...
...
@@ -52,7 +52,6 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
}
private
double
countForTrialBalance
(
String
revenueTypeName
,
List
<
ReportCellDataSourceDto
>
contain
,
Integer
billType
)
{
formulaContext
.
getOrganizationId
();
String
queryDate
=
formulaContext
.
getYear
()+(
formulaContext
.
getPeriod
()<
10
?(
"0"
+
formulaContext
.
getPeriod
()):(
formulaContext
.
getPeriod
()+
""
));
RevenueTypeMappingExample
typeMappingExample
=
new
RevenueTypeMappingExample
();
typeMappingExample
.
createCriteria
().
andOrgIdEqualTo
(
formulaContext
.
getOrganizationId
())
...
...
@@ -69,7 +68,7 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
}
BillDetailExample
billDetailExample
=
new
BillDetailExample
();
BillDetailExample
.
Criteria
c
=
billDetailExample
.
createCriteria
().
andBillContentIn
(
contens
).
andProjectIdEqualTo
(
formulaContext
.
getProjectId
())
.
andPeriodEqualTo
(
formulaContext
.
getPeriod
(
))
.
andPeriodEqualTo
(
Integer
.
valueOf
(
queryDate
))
.
andBillTypeEqualTo
(
BillDetailEnum
.
BillType
.
MAPPING
.
get
(
billType
));
List
<
BillDetail
>
billDetails
=
SpringContextUtil
.
billDetailMapper
.
selectByExample
(
billDetailExample
);
for
(
BillDetail
billDetail
:
billDetails
)
{
...
...
@@ -78,10 +77,10 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
dto
.
setPeriod
(
formulaContext
.
getPeriod
());
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
dto
.
setType
(
FormulaDataSourceType
.
Report
.
getCode
());
contain
.
add
(
dto
);
}
return
billDetails
.
stream
().
mapToDouble
(
a
->
a
.
get
Tax
Amount
().
doubleValue
()).
sum
();
return
billDetails
.
stream
().
mapToDouble
(
a
->
a
.
get
Bill
Amount
().
doubleValue
()).
sum
();
}
...
...
atms-dao/src/main/resources/pwc/taxtech/atms/dao/extends/FileTypesMapper.xml
View file @
4f21b81c
...
...
@@ -403,6 +403,7 @@
SELECT
id,file_attr, file_type
FROM file_types
WHERE status = 1
ORDER BY file_attr
</select>
</mapper>
\ No newline at end of file
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