瀏覽代碼

添加webservice接口

lvzhikai 5 年之前
父節點
當前提交
0ac69ea1f7

+ 13 - 0
pom.xml

@@ -138,6 +138,19 @@
138 138
 		    <version>1.3.2</version>
139 139
 		</dependency>
140 140
 
141
+        <!-- webservice  begin -->
142
+        <dependency>
143
+            <groupId>org.apache.cxf</groupId>
144
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
145
+            <version>3.1.10</version>
146
+        </dependency>
147
+        <dependency>
148
+            <groupId>org.apache.cxf</groupId>
149
+            <artifactId>cxf-rt-transports-http</artifactId>
150
+            <version>3.1.10</version>
151
+        </dependency>
152
+        <!-- webservice  end -->
153
+
141 154
         <!--<dependency>-->
142 155
             <!--<groupId>org.springframework.boot</groupId>-->
143 156
             <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->

+ 96 - 0
src/main/java/com/chinaitop/depot/unissoft/model/ResponseEntity.java

@@ -0,0 +1,96 @@
1
+package com.chinaitop.depot.unissoft.model;
2
+
3
+import java.io.Serializable;
4
+
5
+//返回基类
6
+public class ResponseEntity<T> implements Serializable {
7
+
8
+    private static final long serialVersionUID = -2825436079063723409L;
9
+
10
+    //成功
11
+    private static final String OK = "200";
12
+    //失败
13
+    private static final String FAILED = "600";
14
+    private static final String BUSSINESS_FAILED = "550";
15
+    private static final String UNAUTHENTICATION = "401";
16
+
17
+    private String retCode;
18
+    private String message;
19
+    private T data;
20
+
21
+    public String getRetCode() {
22
+        return retCode;
23
+    }
24
+
25
+    public void setRetCode(String retCode) {
26
+        this.retCode = retCode;
27
+    }
28
+
29
+    public String getMessage() {
30
+        return message;
31
+    }
32
+
33
+    public void setMessage(String message) {
34
+        this.message = message;
35
+    }
36
+
37
+    public T getData() {
38
+        return data;
39
+    }
40
+
41
+    public void setData(T data) {
42
+        this.data = data;
43
+    }
44
+
45
+    private static <T> ResponseEntity<T> buildResponse(String retCode, String message, T data){
46
+        ResponseEntity<T> responseEntity = new ResponseEntity<T>();
47
+        responseEntity.retCode = retCode;
48
+        responseEntity.message = message;
49
+        responseEntity.data = data;
50
+        return responseEntity;
51
+    }
52
+
53
+    public static <T> ResponseEntity<T> ok(){
54
+        return buildResponse(ResponseEntity.OK,"success",null);
55
+    }
56
+    public static <T> ResponseEntity<T> ok(T data){
57
+        return buildResponse(ResponseEntity.OK,"success",data);
58
+
59
+    }
60
+    public static <T> ResponseEntity<T> ok(String message, T data){
61
+        return buildResponse(ResponseEntity.OK,message,data);
62
+    }
63
+
64
+
65
+    public static <T> ResponseEntity<T> failed(String message){
66
+        return buildResponse(ResponseEntity.FAILED,message,null);
67
+    }
68
+
69
+    public static <T> ResponseEntity<T> businessFailed(String message){
70
+        return buildResponse(ResponseEntity.BUSSINESS_FAILED,message,null);
71
+    }
72
+
73
+    public static <T> ResponseEntity<T> unauthentication(String message){
74
+        return buildResponse(ResponseEntity.UNAUTHENTICATION,message,null);
75
+    }
76
+
77
+    private String state;
78
+    private String msg;
79
+
80
+    public String getState() {
81
+        return state;
82
+    }
83
+
84
+    public void setState(String state) {
85
+        this.state = state;
86
+    }
87
+
88
+    public String getMsg() {
89
+        return msg;
90
+    }
91
+
92
+    public void setMsg(String msg) {
93
+        this.msg = msg;
94
+    }
95
+}
96
+

+ 33 - 0
src/main/java/com/chinaitop/depot/unissoft/serviceconfig/CxfConfig.java

@@ -0,0 +1,33 @@
1
+package com.chinaitop.depot.unissoft.serviceconfig;
2
+
3
+import javax.xml.ws.Endpoint;
4
+
5
+import org.apache.cxf.Bus;
6
+import org.apache.cxf.bus.spring.SpringBus;
7
+import org.apache.cxf.jaxws.EndpointImpl;
8
+import org.springframework.context.annotation.Bean;
9
+import org.springframework.context.annotation.Configuration;
10
+
11
+import com.chinaitop.depot.unissoft.webservice.ArchiveWebService;
12
+import com.chinaitop.depot.unissoft.webservice.ArchiveWebServiceImpl;
13
+
14
+@Configuration
15
+public class CxfConfig {
16
+    @Bean(name = Bus.DEFAULT_BUS_ID)
17
+    public SpringBus springBus() {
18
+        return new SpringBus();
19
+    }
20
+
21
+    //货位管理
22
+    @Bean
23
+    public ArchiveWebService ArchiveWebService() {
24
+        return new ArchiveWebServiceImpl();
25
+    }
26
+    @Bean
27
+    public Endpoint getCRKArchiveList() {
28
+        EndpointImpl endpoint = new EndpointImpl(springBus(), ArchiveWebService());
29
+        endpoint.publish("/getCRKArchiveList");
30
+        return endpoint;
31
+    }
32
+
33
+}

+ 15 - 0
src/main/java/com/chinaitop/depot/unissoft/webservice/ArchiveWebService.java

@@ -0,0 +1,15 @@
1
+package com.chinaitop.depot.unissoft.webservice;
2
+
3
+import javax.jws.WebParam;
4
+import javax.jws.WebService;
5
+
6
+@WebService
7
+public interface ArchiveWebService {
8
+
9
+	/**
10
+	 * 修改货位的出入库状态(webservice调用)
11
+	 * @param orgId
12
+	 * @return
13
+	 */
14
+	String getCRKArchiveList(@WebParam(name = "orgId") String orgId);
15
+}

+ 40 - 0
src/main/java/com/chinaitop/depot/unissoft/webservice/ArchiveWebServiceImpl.java

@@ -0,0 +1,40 @@
1
+package com.chinaitop.depot.unissoft.webservice;
2
+
3
+import com.chinaitop.depot.agent.archive.service.ArchiveService;
4
+import org.springframework.stereotype.Service;
5
+
6
+import com.alibaba.fastjson.JSONArray;
7
+
8
+import javax.annotation.Resource;
9
+import java.util.HashMap;
10
+import java.util.List;
11
+import java.util.Map;
12
+
13
+@Service
14
+public class ArchiveWebServiceImpl implements ArchiveWebService {
15
+
16
+	@Resource
17
+	private ArchiveService archiveService;
18
+
19
+	@Override
20
+	@SuppressWarnings("all")
21
+	public String getCRKArchiveList(String orgId) {
22
+
23
+		Map<String,Object> map = new HashMap<String, Object>();
24
+		try {
25
+			//执行任务
26
+			List<Map<String, Object>> archiveList = archiveService.getCRKArchiveList(orgId);
27
+			map.put("success",true);
28
+			map.put("msg","查询成功!");
29
+			map.put("rows",archiveList);
30
+			map.put("totalCount",archiveList.size());
31
+		} catch (Exception e) {
32
+			map.put("success",false);
33
+			map.put("msg","查询失败!");
34
+		} finally {
35
+			JSONArray jsonArray = new JSONArray();
36
+			jsonArray.add(map);
37
+			return jsonArray.toString();
38
+		}
39
+	}
40
+}