From f45ac28c492886e2c55d915c83985db91ac4dfa5 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期二, 12 八月 2025 18:15:38 +0800
Subject: [PATCH] art: WMS 服务端接口提供

---
 src/main/java/org/jeecg/modules/base/service/IFactoryService.java                       |    2 
 src/main/java/org/jeecg/modules/wms/request/ReceiveMESScanItemList.java                 |   17 +++
 src/main/java/org/jeecg/modules/wms/request/WebServiceSendItem.java                     |   70 ++++++++++++++
 src/main/java/org/jeecg/JeecgSystemApplication.java                                     |    4 
 pom.xml                                                                                 |   10 +-
 /dev/null                                                                               |    4 
 src/main/java/org/jeecg/config/Swagger2Config.java                                      |   18 +++
 src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java               |   18 +++
 src/main/java/org/jeecg/modules/wms/controller/WMSTestController.java                   |   37 +++++++
 src/main/java/org/jeecg/modules/wms/dto/WSResponse.java                                 |   19 +++
 src/main/java/org/jeecg/modules/wms/config/WebServiceServerConfig.java                  |   17 ++-
 src/main/java/org/jeecg/modules/wms/dto/ReceiveMESScanItemListResponse.java             |   19 +++
 src/main/java/org/jeecg/modules/wms/service/impl/ReceiveWMSScanItemListServiceImpl.java |   14 ++
 src/main/java/org/jeecg/modules/base/controller/FactoryController.java                  |    6 
 src/main/java/org/jeecg/modules/wms/service/ReceiveWMSScanItemListService.java          |   12 ++
 15 files changed, 236 insertions(+), 31 deletions(-)

diff --git a/pom.xml b/pom.xml
index 559fb4f..7c25535 100644
--- a/pom.xml
+++ b/pom.xml
@@ -227,11 +227,11 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web-services</artifactId>
         </dependency>
-<!--        <dependency>-->
-<!--            <groupId>org.apache.cxf</groupId>-->
-<!--            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>-->
-<!--            <version>${cxf.version}</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
 
         <!-- CXF webservice -->
         <dependency>
diff --git a/src/main/java/org/jeecg/JeecgSystemApplication.java b/src/main/java/org/jeecg/JeecgSystemApplication.java
index bb8b518..06fff58 100644
--- a/src/main/java/org/jeecg/JeecgSystemApplication.java
+++ b/src/main/java/org/jeecg/JeecgSystemApplication.java
@@ -1,6 +1,7 @@
 package org.jeecg;
 
 import lombok.extern.slf4j.Slf4j;
+import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
 import org.flowable.spring.boot.eventregistry.EventRegistryServicesAutoConfiguration;
 import org.jeecg.common.util.oConvertUtils;
 import org.springframework.boot.SpringApplication;
@@ -22,7 +23,8 @@
 */
 @Slf4j
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, MongoAutoConfiguration.class,
-        ManagementWebSecurityAutoConfiguration.class, EventRegistryServicesAutoConfiguration.class})
+        ManagementWebSecurityAutoConfiguration.class, EventRegistryServicesAutoConfiguration.class,
+        CxfAutoConfiguration.class})
 public class JeecgSystemApplication extends SpringBootServletInitializer {
 
     @Override
diff --git a/src/main/java/org/jeecg/config/Swagger2Config.java b/src/main/java/org/jeecg/config/Swagger2Config.java
index 17afa0c..24aab5a 100644
--- a/src/main/java/org/jeecg/config/Swagger2Config.java
+++ b/src/main/java/org/jeecg/config/Swagger2Config.java
@@ -173,6 +173,24 @@
                 .groupName("MES妯″潡");
     }
 
+    @Bean(value = "defaultApiWMS")
+    public Docket defaultApiWMS() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                //姝ゅ寘璺緞涓嬬殑绫伙紝鎵嶇敓鎴愭帴鍙f枃妗�
+                .apis(RequestHandlerSelectors.basePackage("org.jeecg.modules.wms"))
+                //鍔犱簡ApiOperation娉ㄨВ鐨勭被锛屾墠鐢熸垚鎺ュ彛鏂囨。
+                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
+                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
+                .paths(PathSelectors.any())
+                .build()
+                .securitySchemes(Collections.singletonList(securityScheme()))
+                .securityContexts(securityContexts())
+                .globalOperationParameters(setHeaderToken())
+                .groupName("WMS妯″潡");
+    }
+
     /***
      * oauth2閰嶇疆
      * 闇�瑕佸鍔爏wagger鎺堟潈鍥炶皟鍦板潃
diff --git a/src/main/java/org/jeecg/modules/base/controller/FactoryController.java b/src/main/java/org/jeecg/modules/base/controller/FactoryController.java
index cfb5a5a..d9f5488 100644
--- a/src/main/java/org/jeecg/modules/base/controller/FactoryController.java
+++ b/src/main/java/org/jeecg/modules/base/controller/FactoryController.java
@@ -222,9 +222,9 @@
 	 }
 
 	 @ApiOperation(value = "鑾峰彇鎵�鏈変骇绾垮垪琛�", notes = "鑾峰彇鎵�鏈変骇绾垮垪琛�")
-	 @GetMapping(value = "/queryProductionLineList")
-	 public Result<List<FactoryModel>> queryProductionLineList() {
-		 List<Factory> factoryList = factoryService.queryProductionLineList();
+	 @GetMapping(value = "/queryUserProductionLineList")
+	 public Result<List<FactoryModel>> queryUserProductionLineList() {
+		 List<Factory> factoryList = factoryService.queryUserProductionLineList();
 		 List<FactoryModel> factoryModels = factoryList.stream()
 				 .map(factory -> new FactoryModel(factory.getId(), factory.getFactoryName()))
 				 .collect(Collectors.toList());
diff --git a/src/main/java/org/jeecg/modules/base/service/IFactoryService.java b/src/main/java/org/jeecg/modules/base/service/IFactoryService.java
index 0f2a799..86fc969 100644
--- a/src/main/java/org/jeecg/modules/base/service/IFactoryService.java
+++ b/src/main/java/org/jeecg/modules/base/service/IFactoryService.java
@@ -50,5 +50,5 @@
      * 鏌ヨ鏌ヨ鍒楄〃
      * @return
      */
-    List<Factory> queryProductionLineList();
+    List<Factory> queryUserProductionLineList();
 }
diff --git a/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java b/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java
index 2307edd..9d4268d 100644
--- a/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java
+++ b/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java
@@ -6,7 +6,9 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.base.entity.Factory;
 import org.jeecg.modules.base.entity.UserFactory;
@@ -24,6 +26,7 @@
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -176,10 +179,21 @@
     }
 
     @Override
-    public List<Factory> queryProductionLineList() {
+    public List<Factory> queryUserProductionLineList() {
+        //鐢ㄦ埛鏁版嵁鏉冮檺
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (sysUser == null) {
+            return Collections.emptyList();
+        }
+        String productionIds = sysUser.getProductionIds();
+        if(StringUtils.isBlank(productionIds)){
+            return Collections.emptyList();
+        }
+        List<String> list = Arrays.asList(productionIds.split(","));
         LambdaQueryWrapper<Factory> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0);
-        queryWrapper.eq(Factory::getFactoryCategory, "PRODUCTION_LINE");
+//        queryWrapper.eq(Factory::getFactoryCategory, "PRODUCTION_LINE");
+        queryWrapper.in(Factory::getId, list);
         queryWrapper.orderByAsc(Factory::getSorter);
         return super.list(queryWrapper);
     }
diff --git a/src/main/java/org/jeecg/modules/wms/config/WebServiceClientConfig.java b/src/main/java/org/jeecg/modules/wms/config/WebServiceClientConfig.java
deleted file mode 100644
index 23a94af..0000000
--- a/src/main/java/org/jeecg/modules/wms/config/WebServiceClientConfig.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.jeecg.modules.wms.config;
-
-public class WebServiceClientConfig {
-}
diff --git a/src/main/java/org/jeecg/modules/wms/config/WebServiceServerConfig.java b/src/main/java/org/jeecg/modules/wms/config/WebServiceServerConfig.java
index 0c818be..17ee53b 100644
--- a/src/main/java/org/jeecg/modules/wms/config/WebServiceServerConfig.java
+++ b/src/main/java/org/jeecg/modules/wms/config/WebServiceServerConfig.java
@@ -5,7 +5,7 @@
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.transport.servlet.CXFServlet;
 import org.jeecg.modules.wms.service.ReceiveWMSScanItemListService;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.jeecg.modules.wms.service.impl.ReceiveWMSScanItemListServiceImpl;
 import org.springframework.boot.web.servlet.ServletRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -15,25 +15,28 @@
 
 @Configuration
 public class WebServiceServerConfig {
-    @Autowired
-    private ReceiveWMSScanItemListService receiveWMSScanItemListService;
 
-    @Bean(name = "cxfServer")
+    @Bean(name = Bus.DEFAULT_BUS_ID)
     public Bus springBus() {
         return new SpringBus();
     }
 
     @Bean(name = "cxfServlet")  // 娉ㄥ叆servlet bean name涓嶈兘dispatcherServlet ,鍚﹀垯浼氳鐩杁ispatcherServlet
     public ServletRegistrationBean<CXFServlet> cxfServlet() {
-        return new ServletRegistrationBean<CXFServlet>(new CXFServlet(), "/webservice/*");
+        return new ServletRegistrationBean<>(new CXFServlet(), "/webservice/*");
+    }
+
+    @Bean
+    public ReceiveWMSScanItemListService receiveWMSScanItemListService() {
+        return new ReceiveWMSScanItemListServiceImpl();
     }
 
     @Bean
     public Endpoint endpoint() {
         // 鍙傛暟浜岋紝鏄疭EI瀹炵幇绫诲璞�
-        Endpoint endpoint = new EndpointImpl(this.springBus(), receiveWMSScanItemListService);
+        Endpoint endpoint = new EndpointImpl(this.springBus(), this.receiveWMSScanItemListService());
         // 鍙戝竷鏈嶅姟
-        endpoint.publish("/userService");
+        endpoint.publish("/ReceiveWMSScanItemList");
         return endpoint;
     }
 }
diff --git a/src/main/java/org/jeecg/modules/wms/controller/WMSTestController.java b/src/main/java/org/jeecg/modules/wms/controller/WMSTestController.java
new file mode 100644
index 0000000..71e1995
--- /dev/null
+++ b/src/main/java/org/jeecg/modules/wms/controller/WMSTestController.java
@@ -0,0 +1,37 @@
+package org.jeecg.modules.wms.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.wms.dto.ReceiveMESScanItemListResponse;
+import org.jeecg.modules.wms.request.ReceiveMESScanItemList;
+import org.jeecg.modules.wms.service.ReceiveWMSScanItemListService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "WMS闆嗘垚娴嬭瘯")
+@RestController
+@RequestMapping("/wms/client")
+@Slf4j
+public class WMSTestController {
+    @Value("${webservice.url}")
+    private String url;
+    @Value("${webservice.namespace}")
+    private String namespace;
+
+    @ApiOperation(value = "WMS闆嗘垚娴嬭瘯-鎺ユ敹WMS绉诲簱缁撴灉", notes = "WMS闆嗘垚娴嬭瘯-鎺ユ敹WMS绉诲簱缁撴灉")
+    @PostMapping("/testReceiveWMSScanItemList")
+    public Result<?> testReceiveWMSScanItemList() {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setAddress(url);
+        factory.setServiceClass(ReceiveWMSScanItemListService.class);
+        ReceiveWMSScanItemListService service = (ReceiveWMSScanItemListService) factory.create();
+        ReceiveMESScanItemList request = new ReceiveMESScanItemList();
+        ReceiveMESScanItemListResponse response = service.receiveWMSScanItemList(request);
+        return Result.ok(response);
+    }
+}
diff --git a/src/main/java/org/jeecg/modules/wms/dto/ReceiveMESScanItemListResponse.java b/src/main/java/org/jeecg/modules/wms/dto/ReceiveMESScanItemListResponse.java
new file mode 100644
index 0000000..99d4316
--- /dev/null
+++ b/src/main/java/org/jeecg/modules/wms/dto/ReceiveMESScanItemListResponse.java
@@ -0,0 +1,19 @@
+package org.jeecg.modules.wms.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+@Getter
+@Setter
+@XmlRootElement(name = "ReceiveMESScanItemListResponse")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ReceiveMESScanItemListResponse implements Serializable {
+    @XmlElement(name = "WSResponse")
+    private WSResponse wsResponse;
+}
diff --git a/src/main/java/org/jeecg/modules/wms/dto/WSResponse.java b/src/main/java/org/jeecg/modules/wms/dto/WSResponse.java
index 611bfcd..2c1669a 100644
--- a/src/main/java/org/jeecg/modules/wms/dto/WSResponse.java
+++ b/src/main/java/org/jeecg/modules/wms/dto/WSResponse.java
@@ -1,6 +1,19 @@
 package org.jeecg.modules.wms.dto;
 
-public class WSResponse {
-    private String ErrorCode;
-    private String ErrorDesc;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import java.io.Serializable;
+
+@Getter
+@Setter
+@XmlAccessorType(XmlAccessType.FIELD)
+public class WSResponse implements Serializable {
+    @XmlElement(name = "ErrorCode")
+    private String errorCode;
+    @XmlElement(name = "ErrorDesc")
+    private String errorDesc;
 }
diff --git a/src/main/java/org/jeecg/modules/wms/request/ReceiveMESScanItemList.java b/src/main/java/org/jeecg/modules/wms/request/ReceiveMESScanItemList.java
index a6132e0..9bb906b 100644
--- a/src/main/java/org/jeecg/modules/wms/request/ReceiveMESScanItemList.java
+++ b/src/main/java/org/jeecg/modules/wms/request/ReceiveMESScanItemList.java
@@ -1,4 +1,19 @@
 package org.jeecg.modules.wms.request;
 
-public class ReceiveMESScanItemList {
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.xml.bind.annotation.*;
+import java.io.Serializable;
+import java.util.List;
+
+@Getter
+@Setter
+@XmlRootElement(name = "ReceiveMESScanItemList")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ReceiveMESScanItemList implements Serializable {
+
+    @XmlElementWrapper(name = "ArrayOfWebServiceSendItem")
+    @XmlElement(name = "WebServiceSendItem")
+    private List<WebServiceSendItem> items;
 }
diff --git a/src/main/java/org/jeecg/modules/wms/request/WebServiceSendItem.java b/src/main/java/org/jeecg/modules/wms/request/WebServiceSendItem.java
new file mode 100644
index 0000000..d87832f
--- /dev/null
+++ b/src/main/java/org/jeecg/modules/wms/request/WebServiceSendItem.java
@@ -0,0 +1,70 @@
+package org.jeecg.modules.wms.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+@XmlAccessorType(XmlAccessType.FIELD)
+public class WebServiceSendItem implements Serializable {
+    /**宸ュ巶缂栫爜 */
+    @XmlElement(name = "FactoryCode")
+    private String factoryCode;
+    /** 鐗╂枡缂栫爜 */
+    @XmlElement(name = "SkuCode")
+    private String skuCode;
+    /** 棰勭暀鍙� */
+    @XmlElement(name = "ReservationOrder")
+    private String reservationOrder;
+    /** 瀵归綈鏂瑰紡 */
+    @XmlElement(name = "Align")
+    private String align;
+    /** 鎵樺彿 */
+    @XmlElement(name = "Pallet")
+    private String pallet;
+    /** 鍖呰缂栫爜 */
+    @XmlElement(name = "PackageNo")
+    private String packageNo;
+    /** 鎵规鍙� */
+    @XmlElement(name = "TrackLot")
+    private String trackLot;
+    /** 绯诲垪鍙� */
+    @XmlElement(name = "Series")
+    private String series;
+    /** MES搴撳瓨ID */
+    @XmlElement(name = "MesStockID")
+    private String mesStockID;
+    /** 鏁伴噺 */
+    @XmlElement(name = "Quantity")
+    private BigDecimal quantity;
+    /** SAP鎵规鍙� */
+    @XmlElement(name = "SapTrackLot")
+    private String sapTrackLot;
+    /** 鍙戦�佸簱瀛樺湴 */
+    @XmlElement(name = "Section")
+    private String section;
+    /** 鐩爣搴撳瓨鍦� */
+    @XmlElement(name = "DestSection")
+    private String destSection;
+    /** 渚涘簲鍟嗕唬鐮� */
+    @XmlElement(name = "SupplierCode")
+    private String supplierCode;
+    /** 渚涘簲鍟嗘壒娆″彿 */
+    @XmlElement(name = "SupplierTrackLot")
+    private String supplierTrackLot;
+    /** 闃舵ID */
+    @XmlElement(name = "StageID")
+    private String stageID;
+    /** 澶囨敞 */
+    @XmlElement(name = "Remark")
+    private String remark;
+    /** 璁㈠崟缂栫爜 */
+    @XmlElement(name = "OrderCode")
+    private String orderCode;
+}
diff --git a/src/main/java/org/jeecg/modules/wms/service/ReceiveWMSScanItemListService.java b/src/main/java/org/jeecg/modules/wms/service/ReceiveWMSScanItemListService.java
index 2026d5a..d5f1b93 100644
--- a/src/main/java/org/jeecg/modules/wms/service/ReceiveWMSScanItemListService.java
+++ b/src/main/java/org/jeecg/modules/wms/service/ReceiveWMSScanItemListService.java
@@ -1,8 +1,16 @@
 package org.jeecg.modules.wms.service;
 
+import org.jeecg.modules.wms.dto.ReceiveMESScanItemListResponse;
+import org.jeecg.modules.wms.request.ReceiveMESScanItemList;
+
 import javax.jws.WebService;
 
-@WebService
+@WebService(name = "ReceiveWMSScanItemList", targetNamespace = "http://xhj008.server.webservice.com")
 public interface ReceiveWMSScanItemListService {
-
+    /**
+     * 鎺ユ敹WMS绉诲簱淇℃伅
+     * @param request
+     * @return
+     */
+    ReceiveMESScanItemListResponse receiveWMSScanItemList(ReceiveMESScanItemList request);
 }
diff --git a/src/main/java/org/jeecg/modules/wms/service/impl/ReceiveWMSScanItemListServiceImpl.java b/src/main/java/org/jeecg/modules/wms/service/impl/ReceiveWMSScanItemListServiceImpl.java
index 94d8dae..f8b405e 100644
--- a/src/main/java/org/jeecg/modules/wms/service/impl/ReceiveWMSScanItemListServiceImpl.java
+++ b/src/main/java/org/jeecg/modules/wms/service/impl/ReceiveWMSScanItemListServiceImpl.java
@@ -1,14 +1,24 @@
 package org.jeecg.modules.wms.service.impl;
 
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.aspect.annotation.ApiLog;
+import org.jeecg.common.constant.ApiLogCategoryEnum;
+import org.jeecg.modules.wms.dto.ReceiveMESScanItemListResponse;
+import org.jeecg.modules.wms.request.ReceiveMESScanItemList;
 import org.jeecg.modules.wms.service.ReceiveWMSScanItemListService;
 import org.springframework.stereotype.Service;
 
 import javax.jws.WebService;
 
 
-@WebService(name = "ReceiveWMSScanItemListService",  targetNamespace = "http://xhj008.server.webservice.com")
 @Slf4j
-@Service
+//@Service
+@WebService(name = "ReceiveWMSScanItemListService",  targetNamespace = "http://xhj008.server.webservice.com", endpointInterface = "org.jeecg.modules.wms.service.ReceiveWMSScanItemListService")
 public class ReceiveWMSScanItemListServiceImpl implements ReceiveWMSScanItemListService {
+
+    @Override
+    @ApiLog(apiName = "鎺ユ敹WMS鐨勭Щ搴撲俊鎭�(ReceiveWMSScanItemList(MES)", apiCategory = ApiLogCategoryEnum.WMS)
+    public ReceiveMESScanItemListResponse receiveWMSScanItemList(ReceiveMESScanItemList request) {
+        return new ReceiveMESScanItemListResponse();
+    }
 }

--
Gitblit v1.9.3