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
6579afa3
Commit
6579afa3
authored
Aug 23, 2018
by
neo.wang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_neo3' into 'dev'
Dev neo3 See merge request root/atms!95
parents
6a09ce9a
ad11e28d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
18 deletions
+35
-18
Constant.java
...api/src/main/java/pwc/taxtech/atms/constant/Constant.java
+3
-0
FileUploadController.java
...ava/pwc/taxtech/atms/controller/FileUploadController.java
+1
-1
OutputInvoiceController.java
.../pwc/taxtech/atms/controller/OutputInvoiceController.java
+11
-8
FileUploadAdapter.java
.../pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
+20
-9
No files found.
atms-api/src/main/java/pwc/taxtech/atms/constant/Constant.java
View file @
6579afa3
...
...
@@ -33,6 +33,9 @@ public final class Constant {
public
static
final
String
IMAGE_PATH_SUCCESS
=
CURRENT_IMAGE_PATH
+
File
.
separator
+
"success.png"
;
public
static
final
String
IMAGE_PATH_WARN
=
CURRENT_IMAGE_PATH
+
File
.
separator
+
"warning1.png"
;
public
static
final
String
FILE_NAME
=
"filename"
;
public
static
final
String
TEMP_FILE_NAME
=
"tempFileName"
;
public
static
final
boolean
DEFAULT_RESULT
=
true
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/controller/FileUploadController.java
View file @
6579afa3
...
...
@@ -20,6 +20,6 @@ public class FileUploadController {
@RequestMapping
(
value
=
"NewFile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
public
ResponseEntity
getInputInvoiceTreeViewData
(
MultipartHttpServletRequest
request
)
{
return
fileUploadAdapter
.
upload
(
request
,
EnumModule
.
TrailBalance
,
USER_ID_FOR_UPLOAD
);
return
fileUploadAdapter
.
upload
(
request
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/controller/OutputInvoiceController.java
View file @
6579afa3
...
...
@@ -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
;
...
...
@@ -33,6 +33,8 @@ import java.util.UUID;
import
static
javax
.
servlet
.
http
.
HttpServletResponse
.
SC_NO_CONTENT
;
import
static
javax
.
servlet
.
http
.
HttpServletResponse
.
SC_OK
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
FILE_NAME
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
TEMP_FILE_NAME
;
@RestController
@RequestMapping
(
value
=
"api/v1/outputInvoiceImport"
)
...
...
@@ -116,10 +118,13 @@ 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
period
,
MultipartHttpServletRequest
request
)
{
String
userID
=
identityService
.
getIdentityUser
().
getID
();
String
fullPath
=
fileUploadAdapter
.
uploadEvidence
(
this
,
EnumModule
.
Evidence
,
UUID
.
randomUUID
().
toString
());
if
(!
StringUtil
.
isNotEmpty
(
fullPath
))
{
String
fullPath
=
fileUploadAdapter
.
uploadEvidence
(
request
,
EnumModule
.
Evidence
,
userID
);
if
(
StringUtil
.
isNotEmpty
(
fullPath
))
{
String
fileName
=
request
.
getParameter
(
FILE_NAME
);
String
tempFileName
=
request
.
getParameter
(
TEMP_FILE_NAME
);
ImportFile
fileDto
=
new
ImportFile
();
fileDto
.
setFileID
(
tempFileName
.
substring
(
1
,
tempFileName
.
length
()
-
5
));
fileDto
.
setFilePath
(
fullPath
);
...
...
@@ -140,14 +145,12 @@ 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
));
}
private
String
GetExtension
(
String
file
)
{
return
file
.
substring
(
file
.
lastIndexOf
(
"."
)
+
1
,
file
.
length
()
-
file
.
lastIndexOf
(
"."
));
return
file
.
substring
(
file
.
lastIndexOf
(
"."
)
+
1
,
file
.
length
());
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
View file @
6579afa3
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,8 @@ 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
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
FILE_NAME
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
TEMP_FILE_NAME
;
@Service
public
class
FileUploadAdapter
{
...
...
@@ -32,8 +30,10 @@ public class FileUploadAdapter {
@Value
(
"${max_file_length}"
)
private
String
maxFileSize
;
static
final
String
FILE_NAME
=
"filename"
;
public
static
final
String
TEMP_FILE_NAME
=
"tempFileName"
;
private
String
_baseFolder
;
public
static
FileParamBean
CacheFileBean
;
public
static
final
String
CHUNK_NUMBER
=
"_chunkNumber"
;
public
static
final
String
CHUNK_SIZE
=
"_chunkSize"
;
public
static
final
String
TOTAL_SIZE
=
"_totalSize"
;
...
...
@@ -51,12 +51,21 @@ public class FileUploadAdapter {
return
null
;
}
public
String
uploadEvidence
(
OutputInvoiceController
outputInvoiceController
,
EnumModule
evidence
,
String
s
)
{
public
synchronized
String
uploadEvidence
(
MultipartHttpServletRequest
request
,
EnumModule
evidence
,
String
userId
)
{
try
{
upload
(
request
);
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 +77,7 @@ public class FileUploadAdapter {
boolean
isFirsChunk
;
}
public
ResponseEntity
upload
(
MultipartHttpServletRequest
request
,
EnumModule
trailBalance
,
UUID
userIdForUpload
)
{
public
synchronized
ResponseEntity
upload
(
MultipartHttpServletRequest
request
)
{
if
(
request
.
getFileMap
().
size
()
<=
0
)
return
ResponseEntity
.
badRequest
().
body
(
"NoFile"
);
FileParamBean
paramBean
=
getQueryStringParameters
(
request
);
if
(!
paramBean
.
result
)
return
ResponseEntity
.
badRequest
().
body
(
"ParametersInvalid"
);
...
...
@@ -111,6 +120,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 +163,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