From 96c95dabc619e2faf4db7f9e5f6da34a1fb43bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Sat, 25 Jul 2026 19:31:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mhd/system/api/BmsServiceFeign.java | 2 +- .../com/mhd/system/api/OmsServiceFeign.java | 2 +- .../com/mhd/system/api/WlhyServiceFeign.java | 2 +- .../com/mhd/system/api/WmsServiceFeign.java | 2 +- .../com/mhd/system/api/YmsServiceFeign.java | 2 +- .../MaterialBaseInfoAsyncService.java | 181 ++---------------- mhd_wms/src/main/resources/bootstrap.yml | 16 +- 7 files changed, 26 insertions(+), 181 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index 8cc8bfd57..91f2f8a11 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.33.0.109:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java index 560febea1..03d48d2f4 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.concurrent.CompletableFuture; -@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.33.0.99:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface OmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java index d976fcc98..ba9a45148 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.33.0.129:8014",configuration = FeignAutoConfiguration.class) public interface WlhyServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java index 653f44d4b..688e5ea7c 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java @@ -21,7 +21,7 @@ import java.util.Map; * @description: TODO * @date 2024/5/10 8:58 **/ -@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.32:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.33.0.109:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface WmsServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java index 238ec5f81..48d76d01e 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java @@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; -@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.33:8018", configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.33.0.99:8018", configuration = FeignAutoConfiguration.class) public interface YmsServiceFeign { /** diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialBaseInfo/MaterialBaseInfoAsyncService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialBaseInfo/MaterialBaseInfoAsyncService.java index 92412d773..5a3554478 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialBaseInfo/MaterialBaseInfoAsyncService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialBaseInfo/MaterialBaseInfoAsyncService.java @@ -67,6 +67,9 @@ public class MaterialBaseInfoAsyncService { private MaterialBaseInfoDomainService materialBaseInfoDomainService; @Autowired private com.mhd.wms.domain.materialGoodsRule.service.MaterialGoodsRuleDomainService materialGoodsRuleDomainService; + @org.springframework.context.annotation.Lazy + @Autowired + private MaterialBaseInfoApplicationService materialBaseInfoApplicationService; @Async public void doImportData(File tmpFile, String fileName, LoginUser loginUser) { @@ -122,16 +125,16 @@ public class MaterialBaseInfoAsyncService { if (StringUtils.isBlank(row.getHsCode()) && StringUtils.isNotBlank(row.getHsCodeImport())) { row.setHsCode(row.getHsCodeImport().trim()); } - normalizeImportBarCodeWhenDuplicateOfHs(row); - fillIdsFromExistingMasterData(row); - fillOrganizationFromShipperIfNeeded(row); + materialBaseInfoApplicationService.normalizeImportBarCodeWhenDuplicateOfHs(row); + materialBaseInfoApplicationService.fillIdsFromExistingMasterData(row); + materialBaseInfoApplicationService.fillOrganizationFromShipperIfNeeded(row); if (!isValidOrgId(row.getOrganizationId()) && isValidOrgId(loginOrgId)) { row.setOrganizationId(loginOrgId); } if (row.getTopOrganizationId() == null && isValidOrgId(loginTopOrgId)) { row.setTopOrganizationId(loginTopOrgId); } - fillOrganizationName(row, loginUser); + materialBaseInfoApplicationService.fillOrganizationName(row, loginUser); String shipperCode = StringUtils.defaultString(row.getShipperCode(), ""); String duplicateKey = row.getOrganizationId() + "|" + shipperCode + "|" + row.getMaterialCode(); @@ -153,7 +156,7 @@ public class MaterialBaseInfoAsyncService { errors.append("第").append(rowNum).append("行:物料已存在;"); continue; } - normalizeMaterialClassifyImportFields(row); + materialBaseInfoApplicationService.fillClassifyTypeAndUnit(row); // 包装规格查询(带缓存) String packCacheKey = row.getOrganizationId() + "|" + StringUtils.defaultString(row.getPackName()); @@ -193,42 +196,18 @@ public class MaterialBaseInfoAsyncService { MaterialBaseInfoDO materialBaseInfoDO = new MaterialBaseInfoDO(); BeanUtils.copyProperties(row, materialBaseInfoDO); - materialBaseInfoDO.setMaterialGoodsRule(buildImportMaterialGoodsRule(row)); + materialBaseInfoDO.setMaterialGoodsRule(materialBaseInfoApplicationService.buildImportMaterialGoodsRule(row)); materialBaseInfoDO.setMaterialCommon(null); materialBaseInfoDO.setMaterialWarehouseControl(null); - materialBaseInfoDO.setMaterialBarCodeList(buildImportBarCodeList(row)); + materialBaseInfoDO.setMaterialBarCodeList(materialBaseInfoApplicationService.buildImportBarCodeList(row)); // 补全创建人信息(异步线程没有 SecurityContext,用 loginUser) if (loginUser != null) { materialBaseInfoDO.setCreateBy(loginUser.getUserid()); materialBaseInfoDO.setCreateByName(loginUser.getUsername()); } materialBaseInfoDO.setCreateTime(new Date()); - materialBaseInfoDO.setDelFlag(1); - // 通过 domainService 插入,获取自增 ID - Long materialBaseInfoId = materialBaseInfoDomainService.insert(materialBaseInfoDO); - materialBaseInfoDO.setMaterialBaseInfoId(materialBaseInfoId); - // 商品规则 - com.mhd.wms.domain.materialGoodsRule.repository.todo.MaterialGoodsRuleDO goodsRule = materialBaseInfoDO.getMaterialGoodsRule(); - if (goodsRule != null) { - goodsRule.setMaterialBaseInfoId(materialBaseInfoId); - materialGoodsRuleDomainService.insert(goodsRule); - } - // 公共信息 - MaterialCommonDO materialCommonDO = materialBaseInfoDO.getMaterialCommon(); - if (materialCommonDO != null) { - materialCommonDO.setMaterialBaseInfoId(materialBaseInfoId); - materialCommonDomainService.insert(materialCommonDO); - } - // 仓库控制信息 - MaterialWarehouseControlDO materialWarehouseControlDO = materialBaseInfoDO.getMaterialWarehouseControl(); - if (materialWarehouseControlDO != null) { - materialWarehouseControlDO.setMaterialBaseInfoId(materialBaseInfoId); - materialWarehouseControlDomainService.insert(materialWarehouseControlDO); - } - // 库存预警 - materialInventoryWarningDomainService.batchInsertOrUpdate(materialBaseInfoDO); - // 条码信息 - materialBarCodeDomainService.batchInsertOrUpdate(materialBaseInfoDO); + // 调用原 ApplicationService 的 insert,走完整的插入逻辑(含商品规则、公共信息、NC编码等) + materialBaseInfoApplicationService.insert(materialBaseInfoDO); successCount++; } catch (Exception e) { log.error("物料主数据异步导入 - 第{}行处理异常", rowNum, e); @@ -255,141 +234,7 @@ public class MaterialBaseInfoAsyncService { } } - // ====== 以下方法从 MaterialBaseInfoApplicationService 复制,避免循环依赖 ====== - - private void normalizeImportBarCodeWhenDuplicateOfHs(MaterialBaseInfoDTO row) { - if (row == null || StringUtils.isBlank(row.getBarCode())) { - return; - } - String hsCode = StringUtils.trimToEmpty(row.getHsCode()); - if (hsCode.isEmpty()) { - return; - } - if (row.getBarCode().trim().equals(hsCode)) { - row.setBarCode(null); - } - } - - private void fillIdsFromExistingMasterData(MaterialBaseInfoDTO row) { - if (StringUtils.isBlank(row.getPackName()) && StringUtils.isNotBlank(row.getPackImport())) { - row.setPackName(row.getPackImport().trim()); - } - if (row.getShipperId() == null && (StringUtils.isNotBlank(row.getShipperCode()) || StringUtils.isNotBlank(row.getShipperName()))) { - MaterialBaseInfo matched = findExistingMaterialByShipper(row); - if (matched != null) { - row.setShipperId(matched.getShipperId()); - if (StringUtils.isBlank(row.getShipperCode())) { - row.setShipperCode(matched.getShipperCode()); - } - if (StringUtils.isBlank(row.getShipperName())) { - row.setShipperName(matched.getShipperName()); - } - } - } - if (row.getShipperId() == null) { - fillShipperIdFromUserCenterForImport(row); - } - if (row.getPackId() == null && (StringUtils.isNotBlank(row.getPackCode()) || StringUtils.isNotBlank(row.getPackName()))) { - Long packId = queryPackIdByCodeOrName(row.getPackCode(), row.getPackName(), row.getOrganizationId()); - if (packId != null) { - row.setPackId(packId); - } - } - } - - private MaterialBaseInfo findExistingMaterialByShipper(MaterialBaseInfoDTO row) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper() - .eq(MaterialBaseInfo::getDelFlag, 1) - .eq(MaterialBaseInfo::getOrganizationId, row.getOrganizationId()); - if (StringUtils.isNotBlank(row.getShipperCode())) { - wrapper.eq(MaterialBaseInfo::getShipperCode, row.getShipperCode()); - } - wrapper.last("limit 1"); - return materialBaseInfoService.getOne(wrapper, false); - } - - private void fillShipperIdFromUserCenterForImport(MaterialBaseInfoDTO row) { - if (row.getShipperId() != null) { - return; - } - if (StringUtils.isBlank(row.getShipperName()) && StringUtils.isBlank(row.getShipperCode())) { - return; - } - try { - AjaxResult ajaxResult = userServiceFeign.getInfoByName(row.getShipperName()); - if ("200".equals(String.valueOf(ajaxResult.get("code"))) && ajaxResult.get("data") != null) { - UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class); - if (userPo != null) { - row.setShipperId(userPo.getUserId()); - } - } - } catch (Exception ignored) { - } - } - - private void fillOrganizationFromShipperIfNeeded(MaterialBaseInfoDTO row) { - if (isValidOrgId(row.getOrganizationId()) || row.getShipperId() == null) { - return; - } - try { - AjaxResult infoRes = userServiceFeign.getInfo(row.getShipperId()); - if ("200".equals(String.valueOf(infoRes.get("code"))) && infoRes.get("data") != null) { - UserPo userPo = JSON.parseObject(JSONObject.toJSONString(infoRes.get("data")), UserPo.class); - if (userPo != null) { - row.setShipperId(userPo.getUserId()); - if (!isValidOrgId(row.getOrganizationId()) && isValidOrgId(userPo.getOrganizationId())) { - row.setOrganizationId(userPo.getOrganizationId()); - } - if (row.getTopOrganizationId() == null && isValidOrgId(userPo.getTopOrganizationId())) { - row.setTopOrganizationId(userPo.getTopOrganizationId()); - } - } - } - } catch (Exception ignored) { - } - } - - private void fillOrganizationName(MaterialBaseInfoDTO row, LoginUser loginUser) { - if (StringUtils.isNotBlank(row.getOrganizationName())) { - return; - } - if (loginUser != null && loginUser.getUserPo() != null && StringUtils.isNotBlank(loginUser.getUserPo().getOrganizationName())) { - row.setOrganizationName(loginUser.getUserPo().getOrganizationName()); - } - } - - private void normalizeMaterialClassifyImportFields(MaterialBaseInfoDTO row) { - // 简化版:不做复杂分类查询,保持原值 - } - - private Long queryPackIdByCodeOrName(String packCode, String packName, Long organizationId) { - Object result = systemServiceFeign.getPackList(StringUtils.trimToNull(packCode), StringUtils.trimToNull(packName), organizationId); - if (result == null) { - return null; - } - Map resultMap = JSON.parseObject(JSONObject.toJSONString(result), new TypeReference>() {}); - List> rows = extractTableDataRows(resultMap); - if (CollectionUtils.isEmpty(rows)) { - return null; - } - Map first = rows.get(0); - if (first == null) { - return null; - } - String packId = first.get("packId") == null ? "" : String.valueOf(first.get("packId")); - if (StringUtils.isBlank(packId) || !StringUtils.isNumeric(packId)) { - return null; - } - return Long.valueOf(packId); - } - - private List buildImportBarCodeList(MaterialBaseInfoDTO row) { - return Collections.emptyList(); - } - - private com.mhd.wms.domain.materialGoodsRule.repository.todo.MaterialGoodsRuleDO buildImportMaterialGoodsRule(MaterialBaseInfoDTO row) { - return null; - } + // ====== 以下工具方法 ====== private List> extractTableDataRows(Map resultMap) { if (resultMap == null) { diff --git a/mhd_wms/src/main/resources/bootstrap.yml b/mhd_wms/src/main/resources/bootstrap.yml index e8f169bf2..2b8e3f3b0 100644 --- a/mhd_wms/src/main/resources/bootstrap.yml +++ b/mhd_wms/src/main/resources/bootstrap.yml @@ -14,20 +14,20 @@ spring: nacos: discovery: # server-addr: 127.0.0.1:8848 -# server-addr: 10.33.0.129:6010 + server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 - server-addr: 10.102.192.31:6848 - username: nacos - password: manhuoda@2023 +# server-addr: 10.102.192.31:6848 +# username: nacos +# password: manhuoda@2023 #线上正式环境 # server-addr: 10.102.192.105:6848 config: # server-addr: 127.0.0.1:8848 -# server-addr: 10.33.0.129:6010 + server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 - server-addr: 10.102.192.31:6848 - username: nacos - password: manhuoda@2023 +# server-addr: 10.102.192.31:6848 +# username: nacos +# password: manhuoda@2023 #线上正式环境 # server-addr: 10.102.192.105:6848 # 配置文件格式