Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
d9b03ee7
Commit
d9b03ee7
authored
Apr 07, 2022
by
高东东
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
西飞文件传输webservice
parent
af4d86b3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
17 deletions
+153
-17
InputStreamDataSource.java
...m/yeejoin/amos/avic/face/model/InputStreamDataSource.java
+45
-0
UploadFileModel.java
...ava/com/yeejoin/amos/avic/face/model/UploadFileModel.java
+9
-0
FileFransferService.java
...eejoin/amos/avic/face/webservice/FileFransferService.java
+14
-3
AvicCustomPathResource.java
.../yeejoin/amos/avic/controller/AvicCustomPathResource.java
+5
-3
WebServicesFileFransferResource.java
...amos/avic/controller/WebServicesFileFransferResource.java
+31
-4
FileFransferServiceImpl.java
...ejoin/amos/avic/service/impl/FileFransferServiceImpl.java
+49
-7
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-avic-api/src/main/java/com/yeejoin/amos/avic/face/model/InputStreamDataSource.java
0 → 100644
View file @
d9b03ee7
package
com
.
yeejoin
.
amos
.
avic
.
face
.
model
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
javax.activation.DataSource
;
public
class
InputStreamDataSource
implements
DataSource
{
private
InputStream
inputStream
;
public
InputStreamDataSource
(
InputStream
inputStream
)
{
this
.
inputStream
=
inputStream
;
}
@Override
public
InputStream
getInputStream
()
throws
IOException
{
return
inputStream
;
}
@Override
public
OutputStream
getOutputStream
()
throws
IOException
{
return
parse
(
inputStream
);
}
private
ByteArrayOutputStream
parse
(
final
InputStream
in
)
throws
IOException
{
final
ByteArrayOutputStream
swapStream
=
new
ByteArrayOutputStream
();
int
ch
;
while
((
ch
=
in
.
read
())
!=
-
1
)
{
swapStream
.
write
(
ch
);
}
return
swapStream
;
}
@Override
public
String
getContentType
()
{
return
"application/octet-stream"
;
}
@Override
public
String
getName
()
{
return
"InputStreamDataSource"
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-avic-api/src/main/java/com/yeejoin/amos/avic/face/model/UploadFileModel.java
0 → 100644
View file @
d9b03ee7
package
com
.
yeejoin
.
amos
.
avic
.
face
.
model
;
import
lombok.Data
;
@Data
public
class
UploadFileModel
{
String
path
;
String
avicCode
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-avic-api/src/main/java/com/yeejoin/amos/avic/face/webservice/FileFransferService.java
View file @
d9b03ee7
...
...
@@ -2,7 +2,9 @@ package com.yeejoin.amos.avic.face.webservice;
import
javax.activation.DataHandler
;
import
javax.jws.WebMethod
;
import
javax.jws.WebParam
;
import
javax.jws.WebService
;
import
javax.xml.bind.annotation.XmlMimeType
;
import
com.yeejoin.amos.avic.face.model.AvicCustomPathModel
;
...
...
@@ -17,7 +19,12 @@ public interface FileFransferService {
* @param path
*/
@WebMethod
public
void
useCodetransferFile
(
DataHandler
handler
,
String
fileName
,
String
path
,
String
code
);
public
void
useCodetransferFile
(
@WebParam
(
name
=
"dataHandler"
)
@XmlMimeType
(
value
=
"application/octet-stream"
)
DataHandler
handler
,
@WebParam
(
name
=
"fileName"
)
String
fileName
,
@WebParam
(
name
=
"path"
)
String
path
,
@WebParam
(
name
=
"code"
)
String
code
);
/**
* 传输文件
* @param handler
...
...
@@ -25,7 +32,11 @@ public interface FileFransferService {
* @param path
*/
@WebMethod
public
void
transferFile
(
DataHandler
handler
,
String
fileName
,
String
path
);
public
void
transferFile
(
@WebParam
(
name
=
"dataHandler"
)
@XmlMimeType
(
value
=
"application/octet-stream"
)
DataHandler
handler
,
@WebParam
(
name
=
"fileName"
)
String
fileName
,
@WebParam
(
name
=
"path"
)
String
path
);
/**
* 传输目录配置
...
...
@@ -33,6 +44,6 @@ public interface FileFransferService {
* @param path
* @param desc
*/
@WebMethod
@WebMethod
public
void
transferPathConfig
(
AvicCustomPathModel
model
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-avic-biz/src/main/java/com/yeejoin/amos/avic/controller/AvicCustomPathResource.java
View file @
d9b03ee7
...
...
@@ -47,16 +47,17 @@ public class AvicCustomPathResource {
@ApiOperation
(
value
=
"创建"
)
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
POST
)
public
ResponseModel
<
AvicCustomPathModel
>
create
(
@RequestBody
AvicCustomPathModel
model
)
{
postConfig
(
model
);
model
=
simpleService
.
createWithModel
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
public
void
postConfig
()
{
public
void
postConfig
(
AvicCustomPathModel
model
)
{
JaxWsDynamicClientFactory
dcf
=
JaxWsDynamicClientFactory
.
newInstance
();
Client
client
=
dcf
.
createClient
(
webserviceUrl
);
try
{
// invoke("方法名",参数1,参数2,参数3....);
client
.
invoke
(
"transferPathConfig"
,
"张三"
);
client
.
invoke
(
"transferPathConfig"
,
model
);
}
catch
(
java
.
lang
.
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -68,6 +69,7 @@ public class AvicCustomPathResource {
public
ResponseModel
<
AvicCustomPathModel
>
update
(
@RequestBody
AvicCustomPathModel
model
,
@PathVariable
(
value
=
"sequenceNbr"
)
Long
sequenceNbr
)
{
model
.
setSequenceNbr
(
sequenceNbr
);
postConfig
(
model
);
return
ResponseHelper
.
buildResponse
(
simpleService
.
updateWithModel
(
model
));
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-avic-biz/src/main/java/com/yeejoin/amos/avic/controller/WebServicesFileFransferResource.java
View file @
d9b03ee7
package
com
.
yeejoin
.
amos
.
avic
.
controller
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.util.List
;
import
javax.activation.DataHandler
;
import
javax.activation.FileDataSource
;
import
org.apache.cxf.endpoint.Client
;
import
org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ObjectUtils
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RequestPart
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.doc.TycloudResource
;
...
...
@@ -16,6 +27,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
com.yeejoin.amos.avic.face.model.AvicCustomPathModel
;
import
com.yeejoin.amos.avic.face.model.InputStreamDataSource
;
import
com.yeejoin.amos.avic.face.model.UploadFileModel
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -28,22 +41,36 @@ public class WebServicesFileFransferResource {
private
final
Logger
logger
=
LogManager
.
getLogger
(
WebServicesFileFransferResource
.
class
);
@Value
(
"${avic.webservice.path}"
)
String
webserviceUrl
;
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
value
=
"传输文件"
)
@RequestMapping
(
value
=
"/file"
,
method
=
RequestMethod
.
POST
)
public
ResponseModel
postfile
()
{
public
ResponseModel
postfile
(
@RequestPart
MultipartFile
[]
files
,
@RequestParam
String
code
,
@RequestParam
String
path
)
{
JaxWsDynamicClientFactory
dcf
=
JaxWsDynamicClientFactory
.
newInstance
();
Client
client
=
dcf
.
createClient
(
webserviceUrl
);
try
{
// invoke("方法名",参数1,参数2,参数3....);
client
.
invoke
(
"transferFile"
,
"张三"
);
if
(
ObjectUtils
.
isEmpty
(
code
))
{
for
(
MultipartFile
file
:
files
)
{
InputStream
is
=
file
.
getInputStream
();
DataHandler
handler
=
new
DataHandler
(
new
InputStreamDataSource
(
is
));
client
.
invoke
(
"transferFile"
,
handler
,
file
.
getOriginalFilename
(),
path
);
}
}
else
{
for
(
MultipartFile
file
:
files
)
{
InputStream
is
=
file
.
getInputStream
();
DataHandler
handler
=
new
DataHandler
(
new
InputStreamDataSource
(
is
));
client
.
invoke
(
"useCodetransferFile"
,
handler
,
file
.
getOriginalFilename
(),
path
,
code
);
}
}
}
catch
(
java
.
lang
.
Exception
e
)
{
e
.
printStackTrace
();
}
return
ResponseHelper
.
buildResponse
(
null
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"传输目录配置"
)
@RequestMapping
(
value
=
"/config"
,
method
=
RequestMethod
.
POST
)
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-avic-biz/src/main/java/com/yeejoin/amos/avic/service/impl/FileFransferServiceImpl.java
View file @
d9b03ee7
package
com
.
yeejoin
.
amos
.
avic
.
service
.
impl
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
javax.activation.DataHandler
;
import
javax.jws.WebService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
com.yeejoin.amos.avic.face.model.AvicCustomPathModel
;
import
com.yeejoin.amos.avic.face.service.AvicCustomPathService
;
import
com.yeejoin.amos.avic.face.webservice.FileFransferService
;
@WebService
(
serviceName
=
"FileFransferService"
,
...
...
@@ -17,32 +22,69 @@ import com.yeejoin.amos.avic.face.webservice.FileFransferService;
@Component
public
class
FileFransferServiceImpl
implements
FileFransferService
{
@Autowired
AvicCustomPathService
avicCustomPathService
;
@Override
public
void
useCodetransferFile
(
DataHandler
handler
,
String
fileName
,
String
path
,
String
code
)
{
saveFile
(
handler
,
fileName
,
path
);
sendEmail
(
code
,
fileName
);
}
@Override
public
void
transferFile
(
DataHandler
handler
,
String
fileName
,
String
path
)
{
private
void
saveFile
(
DataHandler
handler
,
String
fileName
,
String
path
)
{
InputStream
is
=
null
;
FileOutputStream
os
=
null
;
try
{
is
=
handler
.
getInputStream
();
File
file
=
new
File
(
String
.
format
(
"%s%s%s"
,
path
,
File
.
separator
,
fileName
));
File
dir
=
new
File
(
String
.
format
(
"%s%s"
,
path
,
File
.
separator
));
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
if
(!
file
.
exists
())
{
file
.
createNewFile
();
}
os
=
new
FileOutputStream
(
file
);
int
ch
;
while
((
ch
=
is
.
read
())
!=
-
1
)
{
os
.
write
(
ch
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
is
.
close
();
if
(
is
!=
null
)
{
is
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
os
!=
null
)
{
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
private
void
sendEmail
(
String
userCode
,
String
fileName
)
{
}
@Override
public
void
transferFile
(
DataHandler
handler
,
String
fileName
,
String
path
)
{
saveFile
(
handler
,
fileName
,
path
);
}
@Override
public
void
transferPathConfig
(
AvicCustomPathModel
model
)
{
if
(
ObjectUtils
.
isEmpty
(
model
.
getSequenceNbr
()))
{
avicCustomPathService
.
createWithModel
(
model
);
}
else
{
avicCustomPathService
.
updateWithModel
(
model
);
}
}
...
...
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