From a6ef6636864475e94fc41381b6b6aecb95e753e3 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Wed, 18 Dec 2024 10:09:16 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E5=AE=8C=E5=96=84webservice?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/pom.xml | 21 ----------- ktg-mes/pom.xml | 6 ++++ .../ktg/mes/md/config/WebServiceConfig.java | 36 +++++++++++++++++++ .../md/service/IMasterDataSyncService.java | 19 +++++++--- .../impl/MasterDataSyncServiceImpl.java | 27 ++++++++++---- 5 files changed, 77 insertions(+), 32 deletions(-) create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/config/WebServiceConfig.java diff --git a/ktg-admin/pom.xml b/ktg-admin/pom.xml index 93677f9..246b229 100644 --- a/ktg-admin/pom.xml +++ b/ktg-admin/pom.xml @@ -124,27 +124,6 @@ jtds 1.3.1 - - - org.springframework.boot - spring-boot-starter-web-services - - - - org.springframework - spring-oxm - - - - org.apache.cxf - cxf-spring-boot-starter-jaxws - 4.0.3 - - - jakarta.jws - jakarta.jws-api - 2.1.0 - diff --git a/ktg-mes/pom.xml b/ktg-mes/pom.xml index 2dea2b1..2b4f85f 100644 --- a/ktg-mes/pom.xml +++ b/ktg-mes/pom.xml @@ -66,6 +66,12 @@ org.projectlombok lombok + + + org.apache.cxf + cxf-spring-boot-starter-jaxws + 3.4.4 + \ No newline at end of file diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/config/WebServiceConfig.java b/ktg-mes/src/main/java/com/ktg/mes/md/config/WebServiceConfig.java new file mode 100644 index 0000000..463c196 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/config/WebServiceConfig.java @@ -0,0 +1,36 @@ +package com.ktg.mes.md.config; + +import com.ktg.mes.md.service.IMasterDataSyncService; +import lombok.RequiredArgsConstructor; +import org.apache.cxf.Bus; +import org.apache.cxf.bus.spring.SpringBus; +import org.apache.cxf.jaxws.EndpointImpl; +import org.apache.cxf.transport.servlet.CXFServlet; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.xml.ws.Endpoint; + +@Configuration +@RequiredArgsConstructor +public class WebServiceConfig { + private final IMasterDataSyncService masterDataSyncService; + + @Bean(name = Bus.DEFAULT_BUS_ID) + public SpringBus springBus() { + return new SpringBus(); + } + + @Bean + public ServletRegistrationBean cxfServlet() { + return new ServletRegistrationBean<>(new CXFServlet(), "/WebServices/open/*"); + } + + @Bean + public Endpoint endpoint() { + EndpointImpl endpoint = new EndpointImpl(springBus(), masterDataSyncService); + endpoint.publish("/MasterDataSyncService"); + return endpoint; + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/IMasterDataSyncService.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/IMasterDataSyncService.java index 6cb6cd1..8b2021b 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/IMasterDataSyncService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/IMasterDataSyncService.java @@ -2,29 +2,40 @@ package com.ktg.mes.md.service; import javax.jws.WebMethod; import javax.jws.WebParam; +import javax.jws.WebResult; import javax.jws.WebService; import javax.swing.*; -@WebService(name = "masterDataSyncService", targetNamespace = "http://server.spring.zhang.pers/") +@WebService(name = IMasterDataSyncService.SERVICE_NAME, targetNamespace = IMasterDataSyncService.TARGET_NAMESPACE) public interface IMasterDataSyncService { + String SERVICE_NAME = "MasterDataSyncService"; + + String TARGET_NAMESPACE = "http://server.spring.zhang.pers/"; + /** * 同步物料数据 + * * @param materialListStr 物料列表 */ @WebMethod(operationName = "syncMaterial") - String syncMaterial(@WebParam(name = "materialList") Spring materialListStr); + @WebResult + String syncMaterial(@WebParam(name = "materialListStr") String materialListStr); /** * 同步物料分类数据 + * * @param materialCategoryListStr 物料分类列表 */ @WebMethod(operationName = "syncMaterialCategory") - String syncMaterialCategory(@WebParam(name = "materialCategoryList") Spring materialCategoryListStr); + @WebResult + String syncMaterialCategory(@WebParam(name = "materialCategoryList") String materialCategoryListStr); /** * 同步计量单位数据 + * * @param unitListStr 计量单位列表 */ @WebMethod(operationName = "syncUnit") - String syncUnit(@WebParam(name = "unitList") Spring unitListStr); + @WebResult + String syncUnit(@WebParam(name = "unitList") String unitListStr); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MasterDataSyncServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MasterDataSyncServiceImpl.java index ef3ad70..a8a0bb9 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MasterDataSyncServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MasterDataSyncServiceImpl.java @@ -9,29 +9,40 @@ import com.ktg.mes.md.service.IMdUnitMeasureService; import lombok.RequiredArgsConstructor; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.stereotype.Service; +import javax.jws.WebService; import javax.swing.*; import java.util.List; -import java.util.Objects; @RequiredArgsConstructor +@Service +@WebService(name = IMasterDataSyncService.SERVICE_NAME, targetNamespace = IMasterDataSyncService.TARGET_NAMESPACE, endpointInterface = "com.ktg.mes.md.service.IMasterDataSyncService") public class MasterDataSyncServiceImpl implements IMasterDataSyncService { private final ItemTypeServiceImpl itemTypeService; private final IMdItemService mdItemService; private final IMdUnitMeasureService mdUnitMeasureService; + // 无参构造函数(供 CXF 使用) + public MasterDataSyncServiceImpl() { + this.itemTypeService = null; + this.mdItemService = null; + this.mdUnitMeasureService = null; + } + /** * 同步物料数据 + * * @param materialListStr 物料列表 */ @Override - public String syncMaterial(Spring materialListStr) { + public String syncMaterial(String materialListStr) { // 使用 ObjectMapper 来处理 JSON ObjectMapper objectMapper = new ObjectMapper(); try { // 解析传入的 JSON 字符串 - String jsonList = objectMapper.readTree(materialListStr.toString()).get("LIST").asText(); + String jsonList = objectMapper.readTree(materialListStr).get("LIST").asText(); JsonNode jsonNode = objectMapper.readTree(jsonList); for (JsonNode node : jsonNode) { @@ -77,16 +88,17 @@ public class MasterDataSyncServiceImpl implements IMasterDataSyncService { /** * 同步物料分类数据 + * * @param materialCategoryListStr 物料分类列表 */ @Override - public String syncMaterialCategory(Spring materialCategoryListStr) { + public String syncMaterialCategory(String materialCategoryListStr) { // 使用 ObjectMapper 来处理 JSON ObjectMapper objectMapper = new ObjectMapper(); try { // 解析传入的 JSON 字符串 - String jsonList = objectMapper.readTree(materialCategoryListStr.toString()).get("LIST").asText(); + String jsonList = objectMapper.readTree(materialCategoryListStr).get("LIST").asText(); JsonNode jsonNode = objectMapper.readTree(jsonList); for (JsonNode node : jsonNode) { @@ -144,16 +156,17 @@ public class MasterDataSyncServiceImpl implements IMasterDataSyncService { /** * 同步计量单位数据 + * * @param unitListStr 计量单位列表 */ @Override - public String syncUnit(Spring unitListStr) { + public String syncUnit(String unitListStr) { // 使用 ObjectMapper 来处理 JSON ObjectMapper objectMapper = new ObjectMapper(); try { // 解析传入的 JSON 字符串 - String jsonList = objectMapper.readTree(unitListStr.toString()).get("LIST").asText(); + String jsonList = objectMapper.readTree(unitListStr).get("LIST").asText(); JsonNode jsonNode = objectMapper.readTree(jsonList); for (JsonNode node : jsonNode) { From a17bd1844464e29964e37701ffb260e1a046f06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 18 Dec 2024 11:24:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=AE=97=E6=B3=95BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WmStorageLocationServiceImpl.java | 2 +- .../mapper/wm/WmStorageAreaMapper.xml | 468 ++++++++++++------ 2 files changed, 327 insertions(+), 143 deletions(-) diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java index 5fdad83..5b3ebb5 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java @@ -165,7 +165,7 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService { // 获取库位列表 WmStorageArea wmStorageAreaQuery = new WmStorageArea(); wmStorageAreaQuery.setLocationId(wmStorageLocationByCode.getLocationId()); - if (isBig) wmStorageAreaQuery.setAttr3(1L); + wmStorageAreaQuery.setAttr3(isBig ? 1L : 0L); List wmStorageAreaList = this.wmStorageAreaMapper.selectWmStorageAreaList(wmStorageAreaQuery).stream() // 过滤掉全部存在物品的库位 .filter(it -> !selectNotEmptyAreaCodeList.contains(it.getAreaCode())) diff --git a/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml index 2dd98a8..e38919f 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml @@ -1,190 +1,373 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - select area_id, area_code, area_name, location_id, area, max_loa, position_x, position_y, position_z, enable_flag, frozen_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from wm_storage_area + select area_id, + area_code, + area_name, + location_id, + area, + max_loa, + position_x, + position_y, + position_z, + enable_flag, + frozen_flag, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time + from wm_storage_area - + - + insert into wm_storage_area - area_code, - area_name, - location_id, - area, - max_loa, - position_x, - position_y, - position_z, - enable_flag, - frozen_flag, - remark, - attr1, - attr2, - attr3, - attr4, - create_by, - create_time, - update_by, - update_time, - + + area_code, + + + area_name, + + + location_id, + + + area, + + + max_loa, + + + position_x, + + + position_y, + + + position_z, + + + enable_flag, + + + frozen_flag, + + + remark, + + + attr1, + + + attr2, + + + attr3, + + + attr4, + + + create_by, + + + create_time, + + + update_by, + + + update_time, + + - #{areaCode}, - #{areaName}, - #{locationId}, - #{area}, - #{maxLoa}, - #{positionX}, - #{positionY}, - #{positionZ}, - #{enableFlag}, - #{frozenFlag}, - #{remark}, - #{attr1}, - #{attr2}, - #{attr3}, - #{attr4}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - + + #{areaCode}, + + + #{areaName}, + + + #{locationId}, + + + #{area}, + + + #{maxLoa}, + + + #{positionX}, + + + #{positionY}, + + + #{positionZ}, + + + #{enableFlag}, + + + #{frozenFlag}, + + + #{remark}, + + + #{attr1}, + + + #{attr2}, + + + #{attr3}, + + + #{attr4}, + + + #{createBy}, + + + #{createTime}, + + + #{updateBy}, + + + #{updateTime}, + + update wm_storage_area - area_code = #{areaCode}, - area_name = #{areaName}, - location_id = #{locationId}, - area = #{area}, - max_loa = #{maxLoa}, - position_x = #{positionX}, - position_y = #{positionY}, - position_z = #{positionZ}, - enable_flag = #{enableFlag}, - frozen_flag = #{frozenFlag}, - remark = #{remark}, - attr1 = #{attr1}, - attr2 = #{attr2}, - attr3 = #{attr3}, - attr4 = #{attr4}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, + + area_code = #{areaCode}, + + + area_name = #{areaName}, + + + location_id = #{locationId}, + + + area = #{area}, + + + max_loa = #{maxLoa}, + + + position_x = #{positionX}, + + + position_y = #{positionY}, + + + position_z = #{positionZ}, + + + enable_flag = #{enableFlag}, + + + frozen_flag = #{frozenFlag}, + + + remark = #{remark}, + + + attr1 = #{attr1}, + + + attr2 = #{attr2}, + + + attr3 = #{attr3}, + + + attr4 = #{attr4}, + + + create_by = #{createBy}, + + + create_time = #{createTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + where area_id = #{areaId} - update wm_storage_area set IS_DELETE =1 + update wm_storage_area + set IS_DELETE =1 where area_id = #{areaId} - update wm_storage_area set IS_DELETE = 1 + update wm_storage_area + set IS_DELETE = 1 where area_id in #{areaId} @@ -192,13 +375,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update wm_storage_area set IS_DELETE =1 - where location_id in ( select location_id from wm_storage_location where warehouse_id = #{warehouseId}) + update wm_storage_area + set IS_DELETE =1 + where location_id in (select location_id from wm_storage_location where warehouse_id = #{warehouseId}) - update wm_storage_area set IS_DELETE = 1 + update wm_storage_area + set IS_DELETE = 1 where location_id = #{locationId} - \ No newline at end of file From c75117d6934a0d998bede79b155ed1dab601c5c4 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Wed, 18 Dec 2024 17:38:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E5=87=BA=E5=BA=93=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/main/resources/application.yml | 2 +- .../com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ktg-admin/src/main/resources/application.yml b/ktg-admin/src/main/resources/application.yml index e354520..a652115 100644 --- a/ktg-admin/src/main/resources/application.yml +++ b/ktg-admin/src/main/resources/application.yml @@ -47,7 +47,7 @@ spring: # 国际化资源文件路径 basename: i18n/messages profiles: - active: online + active: dev # 文件上传 servlet: multipart: diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java index 11fb02e..b072b4b 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java @@ -97,7 +97,7 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { WmsBusinessType wmsBusinessType = this.wmsBusinessTypeMapper.selectWmsBusinessTypeByTypeId(wmsOutPlan.getWmsBusinessTypeId().toString()); // 获取库位信息 - WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(wmsOutTask.getWmStorageAreaId()); + WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaCode(nowWmsOutPlanDetailEntity.getAreaCode()); // 设定出库信息数据 HashMap hashMap = new HashMap<>(); @@ -117,7 +117,7 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { hashMap.put("planTypeName", wmsBusinessType.getName()); // 出库类型名称 /* 来自计划明细 */ hashMap.put("detailBatchNum", wmsOutPlanDetail.getDetailBatchNum()); // 明细批次 - hashMap.put("wmStorageAreaId", wmsOutPlanDetail.getWmStorageAreaId()); // 库位ID + hashMap.put("wmStorageAreaId", wmStorageArea.getAreaId()); // 库位ID hashMap.put("wmStorageAreaCode", wmStorageArea.getAreaCode()); // 库位编码 hashMap.put("wmStorageAreaName", wmStorageArea.getAreaName()); // 库位名称 hashMap.put("cellX", wmStorageArea.getPositionX().toString());