Commit fb56f838 authored by 高东东's avatar 高东东

添加文件

parent 2d20e78b
package com.yeejoin.amos.avic.face.webservice; package com.yeejoin.amos.avic.face.webservice;
import javax.activation.DataHandler;
import javax.jws.WebMethod; import javax.jws.WebMethod;
import javax.jws.WebService; import javax.jws.WebService;
import com.yeejoin.amos.avic.face.model.AvicCustomPathModel;
@WebService(targetNamespace = "http://service.avic.amos.yeejoin.com") @WebService(targetNamespace = "http://service.avic.amos.yeejoin.com")
public interface FileFransferService { public interface FileFransferService {
/**
* 利用中航码传输文件
* @param handler
* @param fileName
* @param path
*/
@WebMethod
public void useCodetransferFile(DataHandler handler, String fileName, String path, String code);
/** /**
* 传输文件 * 传输文件
* @param fileContent * @param handler
* @param fileName * @param fileName
* @param path * @param path
*/ */
@WebMethod @WebMethod
public void transferFile(byte[] fileContent, String fileName, String path); public void transferFile(DataHandler handler, String fileName, String path);
/** /**
* 传输目录配置 * 传输目录配置
...@@ -21,5 +34,5 @@ public interface FileFransferService { ...@@ -21,5 +34,5 @@ public interface FileFransferService {
* @param desc * @param desc
*/ */
@WebMethod @WebMethod
public void transferPathConfig(String name, String path, String desc); public void transferPathConfig(AvicCustomPathModel model);
} }
...@@ -7,9 +7,13 @@ import com.yeejoin.amos.avic.face.service.AvicCustomPathService; ...@@ -7,9 +7,13 @@ import com.yeejoin.amos.avic.face.service.AvicCustomPathService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource; import org.typroject.tyboot.core.restful.doc.TycloudResource;
...@@ -32,6 +36,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -32,6 +36,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
@Api(tags = "avic-") @Api(tags = "avic-")
public class AvicCustomPathResource { public class AvicCustomPathResource {
@Value("${avic.webservice.path}")
String webserviceUrl;
private final Logger logger = LogManager.getLogger(AvicCustomPathResource.class); private final Logger logger = LogManager.getLogger(AvicCustomPathResource.class);
@Autowired @Autowired
private AvicCustomPathService simpleService; private AvicCustomPathService simpleService;
...@@ -43,6 +50,17 @@ public class AvicCustomPathResource { ...@@ -43,6 +50,17 @@ public class AvicCustomPathResource {
model = simpleService.createWithModel(model); model = simpleService.createWithModel(model);
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse(model);
} }
public void postConfig() {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(webserviceUrl);
try {
// invoke("方法名",参数1,参数2,参数3....);
client.invoke("transferPathConfig", "张三");
} catch (java.lang.Exception e) {
e.printStackTrace();
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "更新") @ApiOperation(value = "更新")
......
package com.yeejoin.amos.avic.controller;
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.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.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@TycloudResource(module = "avic", value = "FileFransfer")
@RequestMapping(value = "/v1/avic/WebServicesFileFransfer")
@Api(tags = "avic-")
public class WebServicesFileFransferResource {
private final Logger logger = LogManager.getLogger(WebServicesFileFransferResource.class);
@Value("${avic.webservice.path}")
String webserviceUrl;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "传输文件")
@RequestMapping(value = "/file", method = RequestMethod.POST)
public ResponseModel postfile() {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(webserviceUrl);
try {
// invoke("方法名",参数1,参数2,参数3....);
client.invoke("transferFile", "张三");
} catch (java.lang.Exception e) {
e.printStackTrace();
}
return ResponseHelper.buildResponse(null);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "传输目录配置")
@RequestMapping(value = "/config", method = RequestMethod.POST)
public ResponseModel postConfig(@RequestBody AvicCustomPathModel model) {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(webserviceUrl);
try {
client.invoke("transferPathConfig", model);
} catch (java.lang.Exception e) {
e.printStackTrace();
}
return ResponseHelper.buildResponse(null);
}
}
package com.yeejoin.amos.avic.service.impl; package com.yeejoin.amos.avic.service.impl;
import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
import javax.jws.WebService; import javax.jws.WebService;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.yeejoin.amos.avic.face.model.AvicCustomPathModel;
import com.yeejoin.amos.avic.face.webservice.FileFransferService; import com.yeejoin.amos.avic.face.webservice.FileFransferService;
@WebService(serviceName = "FileFransferService", @WebService(serviceName = "FileFransferService",
...@@ -12,13 +17,35 @@ import com.yeejoin.amos.avic.face.webservice.FileFransferService; ...@@ -12,13 +17,35 @@ import com.yeejoin.amos.avic.face.webservice.FileFransferService;
@Component @Component
public class FileFransferServiceImpl implements FileFransferService { public class FileFransferServiceImpl implements FileFransferService {
@Override @Override
public void transferFile(byte[] fileContent, String fileName, String path) { public void useCodetransferFile(DataHandler handler, String fileName, String path, String code) {
} }
@Override
public void transferFile(DataHandler handler, String fileName, String path) {
InputStream is = null;
try {
is = handler.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override @Override
public void transferPathConfig(String name, String path, String desc) { public void transferPathConfig(AvicCustomPathModel model) {
} }
} }
...@@ -9,4 +9,6 @@ eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:10001/eu ...@@ -9,4 +9,6 @@ eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:10001/eu
spring.redis.database=1 spring.redis.database=1
spring.redis.host=172.16.3.18 spring.redis.host=172.16.3.18
spring.redis.port=6379 spring.redis.port=6379
spring.redis.password=yeejoin@2020 spring.redis.password=yeejoin@2020
\ No newline at end of file
avic.webservice.path=http://localhost:8808/avic/services/fileFransfer?wsdl
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment