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
5728602c
Commit
5728602c
authored
Mar 27, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
d4f36128
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
42 deletions
+71
-42
TaxDocumentController.java
...va/pwc/taxtech/atms/controller/TaxDocumentController.java
+1
-0
DidiFileIUploadParam.java
...taxtech/atms/dto/didiFileUpload/DidiFileIUploadParam.java
+11
-0
DidiFileUploadService.java
.../pwc/taxtech/atms/service/impl/DidiFileUploadService.java
+13
-3
TaxDocumentServiceImpl.java
...pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
+17
-9
BB.java
...wc/taxtech/atms/vat/service/impl/report/functions/BB.java
+22
-26
FunctionBase.java
.../atms/vat/service/impl/report/functions/FunctionBase.java
+7
-4
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/TaxDocumentController.java
View file @
5728602c
...
...
@@ -108,6 +108,7 @@ public class TaxDocumentController {
response
.
setHeader
(
"Content-Disposition"
,
"attachment;fileName="
+
new
String
(
"taxDocument.xlsx"
.
getBytes
(
"GB2312"
),
"ISO-8859-1"
));
OutputStream
ouputStream
=
response
.
getOutputStream
();
ExcelUtil
.
exportExcel
(
headers
,
TaxDocument
,
ouputStream
);
ouputStream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/didiFileUpload/DidiFileIUploadParam.java
View file @
5728602c
...
...
@@ -23,6 +23,17 @@ public class DidiFileIUploadParam implements Serializable {
private
List
<
Integer
>
uploadYears
;
//是否转换url为本地url
private
boolean
isParseUrl
=
true
;
public
boolean
isParseUrl
()
{
return
isParseUrl
;
}
public
void
setParseUrl
(
boolean
parseUrl
)
{
isParseUrl
=
parseUrl
;
}
public
List
<
String
>
getBizSources
()
{
return
bizSources
;
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/DidiFileUploadService.java
View file @
5728602c
...
...
@@ -35,6 +35,7 @@ import pwc.taxtech.atms.vat.entity.FileUploadLog;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.security.MessageDigest
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
...
...
@@ -74,6 +75,10 @@ public class DidiFileUploadService extends BaseService {
private
static
final
String
PROXY_PORT
=
"11007"
;
public
FileUpload
getFileUpload
(
String
uid
){
return
fileUploadMapper
.
selectByPrimaryKey
(
uid
);
}
public
FileUpload
uploadFile
(
MultipartFile
file
,
String
fileName
,
String
bizSource
)
throws
ServiceException
{
CloseableHttpClient
httpClient
=
null
;
String
requestKey
=
CommonUtils
.
getUUID
();
...
...
@@ -86,7 +91,7 @@ public class DidiFileUploadService extends BaseService {
httpClient
=
HttpClients
.
createDefault
();
HttpPost
httpPost
=
new
HttpPost
(
requestUrl
);
String
md5Str
=
getFileMD5String
(
file
);
ByteArrayBody
byteBody
=
new
ByteArrayBody
(
file
.
getBytes
(),
ContentType
.
MULTIPART_FORM_DATA
,
StringUtils
.
isBlank
(
fileName
)
?
file
.
getOriginalFilename
()
:
fileName
);
ByteArrayBody
byteBody
=
new
ByteArrayBody
(
file
.
getBytes
(),
ContentType
.
MULTIPART_FORM_DATA
,
StringUtils
.
isBlank
(
fileName
)
?
URLEncoder
.
encode
(
file
.
getOriginalFilename
(),
"UTF-8"
)
:
URLEncoder
.
encode
(
fileName
,
"UTF-8"
)
);
StringBody
md5
=
new
StringBody
(
md5Str
,
ContentType
.
create
(
"text/plain"
));
HttpEntity
httpEntity
=
MultipartEntityBuilder
.
create
().
addPart
(
"filecontent"
,
byteBody
).
addPart
(
"md5"
,
md5
).
build
();
httpPost
.
setEntity
(
httpEntity
);
...
...
@@ -134,7 +139,7 @@ public class DidiFileUploadService extends BaseService {
try
{
httpClient
=
HttpClients
.
createDefault
();
HttpPost
httpPost
=
new
HttpPost
(
requestUrl
);
ByteArrayBody
byteBody
=
new
ByteArrayBody
(
bytes
,
ContentType
.
MULTIPART_FORM_DATA
,
fileName
);
ByteArrayBody
byteBody
=
new
ByteArrayBody
(
bytes
,
ContentType
.
MULTIPART_FORM_DATA
,
URLEncoder
.
encode
(
fileName
,
"UTF-8"
)
);
HttpEntity
httpEntity
=
MultipartEntityBuilder
.
create
().
addPart
(
"filecontent"
,
byteBody
).
build
();
httpPost
.
setEntity
(
httpEntity
);
HttpResponse
httpResponse
=
httpClient
.
execute
(
httpPost
);
...
...
@@ -192,6 +197,7 @@ public class DidiFileUploadService extends BaseService {
}
public
PageInfo
<
DidiFileUploadDetailResult
>
queryPage
(
DidiFileIUploadParam
param
)
{
Page
page
=
null
;
if
(
param
.
getPageInfo
()
!=
null
&&
param
.
getPageInfo
().
getPageSize
()
!=
null
&&
param
.
getPageInfo
().
getPageIndex
()
!=
null
)
{
...
...
@@ -219,7 +225,11 @@ public class DidiFileUploadService extends BaseService {
}
refreshViewUrl
(
param
);
PageInfo
<
DidiFileUploadDetailResult
>
pageInfo
=
new
PageInfo
<>(
fileUploadMapper
.
selectByExample
(
example
).
stream
()
.
map
(
o
->
beanUtil
.
copyProperties
(
o
,
new
DidiFileUploadDetailResult
())).
collect
(
Collectors
.
toList
()));
.
map
(
o
->
{
DidiFileUploadDetailResult
item
=
new
DidiFileUploadDetailResult
();
beanUtil
.
copyProperties
(
o
,
item
);
return
item
;
}).
collect
(
Collectors
.
toList
()));
if
(
page
!=
null
)
{
pageInfo
.
setTotal
(
page
.
getTotal
());
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
View file @
5728602c
...
...
@@ -352,15 +352,18 @@ public class TaxDocumentServiceImpl {
TaxDocumentExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andIdIn
(
ids
);
TaxDocument
taxDocument
=
taxDocumentMapper
.
selectByExample
(
example
).
get
(
0
);
String
urlPath
=
taxDocument
.
getFilePositionUrl
();
DidiFileIUploadParam
fileParam
=
new
DidiFileIUploadParam
();
fileParam
.
setUuids
(
Arrays
.
asList
(
taxDocument
.
getFileUploadId
()));
PageInfo
<
DidiFileUploadDetailResult
>
uploadDetail
=
didiFileUploadService
.
queryPage
(
fileParam
);
String
urlPath
=
uploadDetail
.
getList
().
get
(
0
).
getViewHttpUrl
();
//如果url为null或空字符串而抛出异常
if
(
StringUtils
.
isBlank
(
urlPath
))
{
throw
new
RuntimeException
(
"文件url为空,id为:"
+
taxDocument
.
getId
());
}
//文件名称(带后缀) 文件名前+7位uuid截取码以防文件名相同
String
fileName
=
StringUtils
.
isBlank
(
taxDocument
.
getFileName
())
String
fileName
=
StringUtils
.
isBlank
(
uploadDetail
.
getList
().
get
(
0
)
.
getFileName
())
?
"未知文件(请修改后缀名).xlsx"
:
taxDocument
.
getFileOriginal
Name
();
//设置输出流信息
:
uploadDetail
.
getList
().
get
(
0
).
getFile
Name
();
//设置输出流信息
try
{
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;fileName="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
...
...
@@ -476,15 +479,20 @@ public class TaxDocumentServiceImpl {
criteria
.
andIdIn
(
ids
);
//查询出根据条件过滤后需要下载的附件数据信息
List
<
TaxDocument
>
taxDocuments
=
taxDocumentMapper
.
selectByExample
(
example
);
DidiFileIUploadParam
fileParam
=
new
DidiFileIUploadParam
();
fileParam
.
setUuids
(
taxDocuments
.
stream
()
.
map
(
o
->
o
.
getFileUploadId
()).
collect
(
Collectors
.
toList
()));
PageInfo
<
DidiFileUploadDetailResult
>
uploadDetail
=
didiFileUploadService
.
queryPage
(
fileParam
);
//新建一个空集合,记录下载的名字,并用于判断是否重名,重名则修改名字为(n)
List
<
String
>
fileNameList
=
new
ArrayList
<>();
for
(
TaxDocument
item
:
taxDocuments
)
{
for
(
DidiFileUploadDetailResult
item
:
uploadDetail
.
getList
()
)
{
//文件url
String
urlPath
=
item
.
get
FilePosition
Url
();
//如果url为null或空字符串而抛出异常
if
(
StringUtils
.
isBlank
(
urlPath
))
{
throw
new
RuntimeException
(
"文件url为空,id为:"
+
item
.
getId
());
}
String
urlPath
=
item
.
get
ViewHttp
Url
();
//
//如果url为null或空字符串而抛出异常
//
if (StringUtils.isBlank(urlPath)) {
//
throw new RuntimeException("文件url为空,id为:" + item.getId());
//
}
//检查文件名是否有重复
int
fileNameRepeatTimes
=
0
;
if
(
fileNameList
.
size
()>
0
){
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/BB.java
View file @
5728602c
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.NumberEval
;
import
org.apache.poi.ss.formula.eval.StringEval
;
...
...
@@ -61,21 +62,6 @@ public class BB extends FunctionBase implements FreeRefFunction {
BigDecimal
cellValue
=
BigDecimal
.
ZERO
;
try
{
List
<
CellTemplatePerGroupDto
>
cellTemplateDataList
;
if
(
curPeriod
.
getCurYear
()
!=
formulaContext
.
getYear
())
{
Project
project
=
agent
.
getFixedProject
(
formulaContext
.
getProjectId
(),
curPeriod
.
getCurYear
());
MyAsserts
.
assertNotNull
(
project
,
Exceptions
.
PROJECT_NOT_FOUND
);
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
project
.
getId
(),
bo
.
getReportCode
(),
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
curPeriod
.
getCurPeriod
());
}
else
{
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
(),
bo
.
getReportCode
(),
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
curPeriod
.
getCurPeriod
());
}
MyAsserts
.
assertNotEmpty
(
cellTemplateDataList
,
Exceptions
.
BB_CELL_TEMP_NULL
);
CellTemplatePerGroupDto
cellTemplateData
=
cellTemplateDataList
.
get
(
0
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
if
(
bo
.
getPeriod
().
intValue
()
==
99
)
{
dataSource
.
clear
();
BigDecimal
returnEval
=
defaultBigDecimal
;
...
...
@@ -83,7 +69,7 @@ public class BB extends FunctionBase implements FreeRefFunction {
return
defaultBigDecimal
;
}
//如果是当年取到当期截至,往年取12期
for
(
int
p
=
1
;
p
<
(
curPeriod
.
getCurYear
()==
formulaContext
.
getYear
()?
formulaContext
.
getPeriod
():
12
);
p
++)
{
for
(
int
p
=
1
;
p
<
=
(
curPeriod
.
getCurYear
()==
formulaContext
.
getYear
()?
formulaContext
.
getPeriod
():
12
);
p
++)
{
try
{
returnEval
=
returnEval
.
add
(
bb
(
new
BBParasBo
(
bo
,
p
,
curPeriod
.
getCurYear
()),
ec
,
dataSource
,
bo
));
}
catch
(
Exception
e
)
{
...
...
@@ -92,33 +78,45 @@ public class BB extends FunctionBase implements FreeRefFunction {
}
}
}
return
returnEval
;
}
List
<
CellTemplatePerGroupDto
>
cellTemplateDataList
;
if
(
curPeriod
.
getCurYear
()
!=
formulaContext
.
getYear
())
{
Project
project
=
agent
.
getFixedProject
(
formulaContext
.
getProjectId
(),
curPeriod
.
getCurYear
());
// MyAsserts.assertNotNull(project, Exceptions.PROJECT_NOT_FOUND);
if
(
project
==
null
){
return
cellValue
;
}
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
project
.
getId
(),
bo
.
getReportCode
(),
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
curPeriod
.
getCurPeriod
());
}
else
{
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
(),
bo
.
getReportCode
(),
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
curPeriod
.
getCurPeriod
());
}
// MyAsserts.assertNotEmpty(cellTemplateDataList, Exceptions.BB_CELL_TEMP_NULL);
if
(
CollectionUtils
.
isEmpty
(
cellTemplateDataList
)){
return
cellValue
;
}
CellTemplatePerGroupDto
cellTemplateData
=
cellTemplateDataList
.
get
(
0
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
//当年当期
if
(
bo
.
getPeriod
().
intValue
()
==
0
&&
bo
.
getYear
().
intValue
()
==
0
)
{
int
index
=
ec
.
getWorkbook
().
getSheetIndex
(
bo
.
getReportCode
());
cellValue
=
getCellValue
(
index
,
ec
,
formulaContext
,
agent
,
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()));
nullCellDto
.
extractFromGroup
(
bo
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
cellTemplateData
);
nullCellDto
.
setAmount
(
cellValue
);
return
cellValue
;
}
PeriodCellData
cellData
=
null
;
String
projectId
=
agent
.
getPastProjectId
(
curPeriod
.
getCurYear
(),
formulaContext
.
getOrganizationId
());
MyAsserts
.
assertNotEmpty
(
projectId
,
Exceptions
.
PROJECT_EMPTY
);
cellData
=
agent
.
getCellData
(
cellTemplateData
.
getReportTemplateId
(),
cellTemplateData
.
getCellTemplateId
(),
curPeriod
.
getCurPeriod
(),
formulaContext
.
getProjectId
());
List
<
PeriodDataSource
>
dss
=
agent
.
queryManualDataSource
(
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()),
formulaContext
.
getProjectId
(),
bo
.
getPeriod
());
nullCellDto
.
extractFromGroup
(
bo
,
curPeriod
,
cellData
,
cellTemplateData
);
if
(
cellData
.
getData
()
==
null
&&
!
dss
.
isEmpty
())
{
cellValue
=
dss
.
get
(
0
).
getAmount
();
}
else
if
(
cellData
.
getData
()
!=
null
&&
dss
.
isEmpty
())
{
...
...
@@ -128,14 +126,12 @@ public class BB extends FunctionBase implements FreeRefFunction {
cellValue
=
dss
.
get
(
0
).
getAmount
().
add
(
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
));
}
else
throw
Exceptions
.
BB_CELL_DATA_NULL
;
nullCellDto
.
setAmount
(
cellValue
);
if
(
rootBo
!=
null
)
{
rootBo
.
putPeriodCellTempate
(
curPeriod
.
getCurPeriod
(),
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()));
}
else
{
bo
.
putPeriodCellTempate
(
curPeriod
.
getCurPeriod
(),
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()));
}
LOGGER
.
debug
(
"cell static value "
);
return
cellValue
;
}
catch
(
Exception
e
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/FunctionBase.java
View file @
5728602c
...
...
@@ -251,9 +251,11 @@ public class FunctionBase {
return
bigDecimal
;
}
}
catch
(
Exception
e
)
{
if
(!
dss
.
isEmpty
())
return
dss
.
get
(
0
).
getAmount
();
e
.
printStackTrace
();
if
(!
dss
.
isEmpty
()){
return
dss
.
get
(
0
).
getAmount
();}
else
{
return
new
BigDecimal
(
0
);}
}
}
else
{
try
{
...
...
@@ -264,9 +266,10 @@ public class FunctionBase {
return
bigDecimal
;
}
}
catch
(
Exception
e
)
{
if
(!
dss
.
isEmpty
())
return
dss
.
get
(
0
).
getAmount
();
e
.
printStackTrace
();
if
(!
dss
.
isEmpty
()){
return
dss
.
get
(
0
).
getAmount
();}
else
{
return
new
BigDecimal
(
0
);}
}
}
...
...
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