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
c7187f34
Commit
c7187f34
authored
Aug 23, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] ouput vourcher item file upalod impl
parent
4e43b5d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
OutputInvoiceController.java
.../pwc/taxtech/atms/controller/OutputInvoiceController.java
+4
-5
FileUploadAdapter.java
.../pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
+17
-8
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/OutputInvoiceController.java
View file @
c7187f34
...
...
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.Multipart
File
;
import
org.springframework.web.multipart.Multipart
HttpServletRequest
;
import
pwc.taxtech.atms.constant.enums.EnumModule
;
import
pwc.taxtech.atms.dto.PagingResultDto
;
import
pwc.taxtech.atms.dto.vatdto.ImportOutputInvoiceDto
;
...
...
@@ -116,9 +116,9 @@ public class OutputInvoiceController {
}
@RequestMapping
(
value
=
"UploadEvidenceFile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseEntity
UploadEvidenceFile
(
String
fileName
,
String
tempFileName
,
String
period
)
{
public
ResponseEntity
UploadEvidenceFile
(
String
fileName
,
String
tempFileName
,
String
period
,
MultipartHttpServletRequest
request
)
{
String
userID
=
identityService
.
getIdentityUser
().
getID
();
String
fullPath
=
fileUploadAdapter
.
uploadEvidence
(
this
,
EnumModule
.
Evidence
,
UUID
.
randomUUID
().
toString
()
);
String
fullPath
=
fileUploadAdapter
.
uploadEvidence
(
request
,
EnumModule
.
Evidence
,
userID
);
if
(!
StringUtil
.
isNotEmpty
(
fullPath
))
{
ImportFile
fileDto
=
new
ImportFile
();
fileDto
.
setFileID
(
tempFileName
.
substring
(
1
,
tempFileName
.
length
()
-
5
));
...
...
@@ -140,8 +140,7 @@ public class OutputInvoiceController {
}
@RequestMapping
(
value
=
"queryOutputInvoiceItemList/{invoiceID}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseEntity
QueryOutputInvoiceItemList
(
@PathVariable
String
invoiceID
)
{
public
ResponseEntity
QueryOutputInvoiceItemList
(
@PathVariable
String
invoiceID
)
{
return
ResponseEntity
.
ok
(
outputInvoiceService
.
QueryOutputInvoiceItemList
(
invoiceID
));
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
View file @
c7187f34
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
org.apache.xmlbeans.impl.store.Path
;
import
org.reflections.util.Utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
pwc.taxtech.atms.constant.enums.EnumModule
;
import
pwc.taxtech.atms.controller.OutputInvoiceController
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
...
...
@@ -23,7 +20,6 @@ import java.util.Date;
import
java.util.UUID
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
CURRENT_USER_UPLOAD_FOLDER
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
UPLOAD_FOLDER_NAME
;
@Service
public
class
FileUploadAdapter
{
...
...
@@ -33,6 +29,8 @@ public class FileUploadAdapter {
private
String
maxFileSize
;
static
final
String
FILE_NAME
=
"filename"
;
private
String
_baseFolder
;
public
static
FileParamBean
CacheFileBean
;
public
static
final
String
TEMP_FILE_NAME
=
"tempFileName"
;
public
static
final
String
CHUNK_NUMBER
=
"_chunkNumber"
;
public
static
final
String
CHUNK_SIZE
=
"_chunkSize"
;
...
...
@@ -51,12 +49,21 @@ public class FileUploadAdapter {
return
null
;
}
public
String
uploadEvidence
(
OutputInvoiceController
outputInvoiceController
,
EnumModule
evidence
,
String
s
)
{
return
null
;
public
synchronized
String
uploadEvidence
(
MultipartHttpServletRequest
request
,
EnumModule
evidence
,
String
userId
)
{
try
{
upload
(
request
,
evidence
,
UUID
.
fromString
(
userId
));
String
uploadFile
=
combine
(
_baseFolder
,
CacheFileBean
.
tempFileName
);
if
(
CacheFileBean
.
isLastChunk
)
{
return
uploadFile
;
}
else
{
return
null
;
}
}
catch
(
Exception
e
)
{
return
null
;
}
}
static
class
FileParamBean
{
String
fileName
;
String
tempFileName
;
long
chunkNumber
;
...
...
@@ -68,7 +75,7 @@ public class FileUploadAdapter {
boolean
isFirsChunk
;
}
public
ResponseEntity
upload
(
MultipartHttpServletRequest
request
,
EnumModule
trailBalance
,
UUID
userIdForUpload
)
{
public
synchronized
ResponseEntity
upload
(
MultipartHttpServletRequest
request
,
EnumModule
trailBalance
,
UUID
userIdForUpload
)
{
if
(
request
.
getFileMap
().
size
()
<=
0
)
return
ResponseEntity
.
badRequest
().
body
(
"NoFile"
);
FileParamBean
paramBean
=
getQueryStringParameters
(
request
);
if
(!
paramBean
.
result
)
return
ResponseEntity
.
badRequest
().
body
(
"ParametersInvalid"
);
...
...
@@ -111,6 +118,7 @@ public class FileUploadAdapter {
File
tempFile
=
new
File
(
tempPath
);
tempFile
.
renameTo
(
completeFile
);
CacheFileBean
=
paramBean
;
LOGGER
.
info
(
"{} upload to temp folder sucess"
,
paramBean
.
fileName
);
}
}
else
{
...
...
@@ -153,6 +161,7 @@ public class FileUploadAdapter {
if
(!
file
.
exists
())
file
.
mkdirs
();
}
_baseFolder
=
uploadFolder
;
return
uploadFolder
;
}
...
...
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