From 2fe41de27cbaf9d144ea34e144c1fa8584be463d Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Wed, 29 Jul 2026 17:37:58 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81fastjson=E5=8D=87=E7=BA=A7=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=97=A0=E6=B3=95=E8=A7=A3=E6=9E=90=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=9D=BF=E7=BC=96=E5=8F=B7=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E4=B8=8B=E5=88=92=E7=BA=BF=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=AE=A2=E5=8D=95=E6=95=B0=E6=8D=AE=E6=8B=89?= =?UTF-8?q?=E5=8F=96=EF=BC=9A=E9=85=8D=E4=BB=B6=E9=A2=9C=E8=89=B2/?= =?UTF-8?q?=E6=9D=90=E8=B4=A8=E5=8F=96=E5=80=BC=E4=BF=AE=E5=A4=8D=E3=80=81?= =?UTF-8?q?=E9=85=8D=E4=BB=B6=E5=A4=87=E6=B3=A8=E6=9C=AA=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cf-dependencies/pom.xml | 1 - .../CustomPlateNoGenerateServiceImpl.java | 7 +- .../CustomPlateNoGenerateServiceImpl.java | 7 +- .../factory/ProducingOrderImportFactory.java | 12 ++- .../producing/ProducingOrderConverter.java | 86 ++++++++++++++++--- .../producing/dto/ProducingImportPart.java | 5 ++ .../producing/dto/ProducingOrderResponse.java | 14 ++- 7 files changed, 112 insertions(+), 20 deletions(-) diff --git a/cf-dependencies/pom.xml b/cf-dependencies/pom.xml index ecf09e4ec..3b5a2a18a 100644 --- a/cf-dependencies/pom.xml +++ b/cf-dependencies/pom.xml @@ -57,7 +57,6 @@ 4.0.3 2.4.1 1.0.5 - 1.2.83 2.0.61 33.4.8-jre 5.1.0 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java index 9a49bb9ed..ead5f7c1b 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java @@ -3,6 +3,7 @@ package com.cf.imes.module.executor.service.customplateno; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONReader; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.pojo.CommonResult; @@ -166,7 +167,8 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe if (orgCustomPlateNoConfigResult.isSuccess()) { orgCustomPlateNoConfig = orgCustomPlateNoConfigResult.getData(); customPlateNoRuleVOS = Optional.ofNullable(orgCustomPlateNoConfig) - .map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class)) + .map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class, + JSONReader.Feature.SupportSmartMatch)) .orElse(List.of()); customPlateNoGenerateConfigVO.setOrgCustomPlateNoConfigId(Optional.ofNullable(orgCustomPlateNoConfig).map(SystemConfigRespDTO::getId).orElse(null)); } @@ -179,7 +181,8 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe if (ObjectUtil.isNotNull(orderCustomPlatenoConfigId) && ObjectUtil.notEqual(orgCustomPlateNoConfig.getId(), orderCustomPlatenoConfigId)) { CommonResult previousCustomPlateNoConfig = systemConfigApi.getById(orderCustomPlatenoConfigId); if (previousCustomPlateNoConfig.isSuccess()) { - customPlateNoRuleVOS = JSON.parseArray(previousCustomPlateNoConfig.getData().getSetting(), CustomPlateNoRuleVO.class); + customPlateNoRuleVOS = JSON.parseArray(previousCustomPlateNoConfig.getData().getSetting(), + CustomPlateNoRuleVO.class, JSONReader.Feature.SupportSmartMatch); } } diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/customplateno/CustomPlateNoGenerateServiceImpl.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/customplateno/CustomPlateNoGenerateServiceImpl.java index 305bca831..3b81127b9 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/customplateno/CustomPlateNoGenerateServiceImpl.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/customplateno/CustomPlateNoGenerateServiceImpl.java @@ -3,6 +3,7 @@ package com.cf.imes.module.plan.service.customplateno; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONReader; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.cf.imes.framework.common.exception.ServiceException; @@ -165,7 +166,8 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe if (orgCustomPlateNoConfigResult.isSuccess()) { orgCustomPlateNoConfig = orgCustomPlateNoConfigResult.getData(); customPlateNoRuleVOS = Optional.ofNullable(orgCustomPlateNoConfig) - .map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class)) + .map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class, + JSONReader.Feature.SupportSmartMatch)) .orElse(List.of()); customPlateNoGenerateConfigVO.setOrgCustomPlateNoConfigId(Optional.ofNullable(orgCustomPlateNoConfig).map(SystemConfigRespDTO::getId).orElse(null)); } @@ -178,7 +180,8 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe if (ObjectUtil.isNotNull(orderCustomPlatenoConfigId) && ObjectUtil.notEqual(orgCustomPlateNoConfig.getId(), orderCustomPlatenoConfigId)) { CommonResult previousCustomPlateNoConfig = systemConfigApi.getById(orderCustomPlatenoConfigId); if (previousCustomPlateNoConfig.isSuccess()) { - customPlateNoRuleVOS = JSON.parseArray(previousCustomPlateNoConfig.getData().getSetting(), CustomPlateNoRuleVO.class); + customPlateNoRuleVOS = JSON.parseArray(previousCustomPlateNoConfig.getData().getSetting(), + CustomPlateNoRuleVO.class, JSONReader.Feature.SupportSmartMatch); } } diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/ProducingOrderImportFactory.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/ProducingOrderImportFactory.java index 9f01ffb40..d2b4048b6 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/ProducingOrderImportFactory.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/ProducingOrderImportFactory.java @@ -2013,9 +2013,13 @@ public class ProducingOrderImportFactory { String thickness = part.getThickness(); String unit = part.getUnit(); String brand = part.getBrand(); + String partMaterial = part.getMaterial(); + String partColor = part.getColor(); // 分类配件的键组合 - String groupKey = composite + partType + factory + model + spec + scale3(height) + scale3(width) + scale3(thickness) + unit + brand; + String groupKey = composite + partType + factory + model + spec + + scale3(height) + scale3(width) + scale3(thickness) + + unit + brand + partMaterial + partColor; Long orderPartId = orderPartMap.get(groupKey); if (ObjectUtil.isNull(orderPartId)) { @@ -2033,8 +2037,10 @@ public class ProducingOrderImportFactory { spec = part.getSpec(); } else { spec = getFieldFromSpec(part.getSpec(), 0); - material = getFieldFromSpec(part.getSpec(), 1); - color = getFieldFromSpec(part.getSpec(), 2); + material = StringUtils.isNotEmpty(partMaterial) + ? partMaterial : getFieldFromSpec(part.getSpec(), 1); + color = StringUtils.isNotEmpty(partColor) + ? partColor : getFieldFromSpec(part.getSpec(), 2); } String type = changePartType(partType, part.getIsComposite()); diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/ProducingOrderConverter.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/ProducingOrderConverter.java index dded938f2..320b7a24f 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/ProducingOrderConverter.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/ProducingOrderConverter.java @@ -13,6 +13,7 @@ import com.cf.imes.module.plan.service.orderImport.producing.dto.ProducingImport import com.cf.imes.module.plan.dal.dataobject.plate.PlateGoodDO; import com.cf.imes.module.plan.dal.mysql.plate.PlateGoodMapper; import com.cf.imes.module.plan.service.orderImport.producing.dto.ProducingOrderResponse; +import com.fasterxml.jackson.databind.JsonNode; import jakarta.annotation.Resource; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; @@ -914,7 +915,7 @@ public class ProducingOrderConverter { for (ProducingOrderResponse.ShapeOffset source : safe(shape.getOffsetList())) { ProducingImportBlock.PointInfoDTO.ModelDetailDTO.OffSetListDTO target = new ProducingImportBlock.PointInfoDTO.ModelDetailDTO.OffSetListDTO(); - target.setId(source.getToolPath()); + target.setId(shapeOffsetToolPathId(source.getToolPath())); target.setAngle(zero(source.getAngle())); target.setDeep(zero(source.getDepth())); target.setName(source.getKnifeName()); @@ -925,6 +926,19 @@ public class ProducingOrderConverter { return result; } + /** + * 从新旧两种偏移刀路结构中提取刀路 ID。 + * + *

新结构使用 {@code toolPath.id},旧结构则直接以字符串或数字返回 ID。

+ */ + private String shapeOffsetToolPathId(JsonNode toolPath) { + if (toolPath == null || toolPath.isNull()) { + return null; + } + JsonNode id = toolPath.isObject() ? toolPath.get("id") : toolPath; + return id == null || id.isNull() ? null : id.asText(); + } + /** * 合并 partsItems 与 partsList,并按柜体 ID 汇总待入库配件。 */ @@ -946,23 +960,21 @@ public class ProducingOrderConverter { ? SEAL_PART_GROUP : part.getGroup()); target.setModel(empty(material.getModel())); boolean sealPart = SEAL_PART_GROUP.equals(part.getGroup()); - target.setSpec(sealPart - ? empty(material.getSpec()) - : String.join("|", empty(material.getSpec()), - empty(material.getMaterial()), empty(material.getColor()))); + target.setSpec(empty(material.getSpec())); // 对方 width/length/height 对应原导入结构的宽/长/厚。 target.setWidth(partDimension(part.getWidth())); target.setHeight(partDimension(part.getLength())); target.setThickness(partDimension(part.getHeight())); - target.setMaterial(empty(material.getMaterial())); + target.setMaterial(partMaterial(material)); + target.setColor(partColor(material)); target.setBrand(empty(material.getBrand())); target.setFactory(empty(material.getFactory())); target.setUnit("0"); target.setNum(part.getQuantity() == null ? 1D : part.getQuantity()); int partType = defaultPartType(part.getType()); target.setIsComposite(partType == 1 || partType == 2); - // 配件备注与板件一致,只取实例级 partsItems.remarks。 - target.setRemark(remarksText(item.getRemarks())); + // 实例级备注优先;对方暂未在 partsItems 返回 remarks 时,兼容读取配件定义备注。 + target.setRemark(remarksText(effectivePartRemarks(item, part))); target.setObjectId(partCadViewId(context, part.getId())); target.setGroupIds(parseIds(item.getProcessGroupIds(), "process group")); target.setComponentIds(isNoComponent(item.getComponentGroupId()) @@ -974,8 +986,8 @@ public class ProducingOrderConverter { new ProducingImportPart.GroupData(); groupData.setSize(0); groupData.setThickness(0); - groupData.setMaterial(empty(material.getMaterial())); - groupData.setColor(empty(material.getColor())); + groupData.setMaterial(target.getMaterial()); + groupData.setColor(sealPartColor(material)); groupData.setBoardName(material.getName()); target.setGroupData(groupData); } @@ -1048,6 +1060,60 @@ public class ProducingOrderConverter { .collect(Collectors.joining(",")); } + /** + * 获取配件业务备注:优先使用物理项备注,物理项未返回时兼容配件定义备注。 + */ + private Map effectivePartRemarks( + ProducingOrderResponse.Item item, ProducingOrderResponse.Part part) { + Map itemRemarks = item.getRemarks(); + return itemRemarks == null || itemRemarks.isEmpty() + ? part.getRemarks() : itemRemarks; + } + + /** + * 获取配件材质:优先使用物料独立字段,字段为空时从“规格|材质|颜色”中补齐。 + */ + private String partMaterial(ProducingOrderResponse.Material material) { + return preferredPartField(material.getMaterial(), material.getSpec(), 1); + } + + /** + * 获取配件颜色:优先使用物料独立字段,字段为空时从“规格|材质|颜色”中补齐。 + */ + private String partColor(ProducingOrderResponse.Material material) { + return preferredPartField(material.getColor(), material.getSpec(), 2); + } + + /** + * 按配件物料独立字段优先、组合规格兜底的顺序读取属性。 + */ + private String preferredPartField(String directValue, String spec, int index) { + if (StringUtils.hasText(directValue)) { + return directValue; + } + if (!StringUtils.hasText(spec)) { + return ""; + } + String[] fields = spec.split("\\|", -1); + return fields.length > index ? fields[index].trim() : ""; + } + + /** + * 获取封边条颜色:遵循配件颜色优先级,并兼容当前封边条连字符规格。 + */ + private String sealPartColor(ProducingOrderResponse.Material material) { + String color = partColor(material); + if (StringUtils.hasText(color)) { + return color; + } + String spec = material.getSpec(); + if (!StringUtils.hasText(spec)) { + return ""; + } + String[] fields = spec.split("-", 3); + return fields.length == 3 ? fields[2].trim() : ""; + } + /** * 优先读取 blockList 的显式字段;字段缺失时兼容旧报文 remarks 中的同名派生标记。 */ diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingImportPart.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingImportPart.java index 7af4a1a15..06b8ba345 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingImportPart.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingImportPart.java @@ -34,6 +34,11 @@ public class ProducingImportPart { private String material; + /** + * 对方独立颜色字段优先,缺失时由转换层从组合规格中补齐。 + */ + private String color; + private String brand; private String factory; diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingOrderResponse.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingOrderResponse.java index 2cdcf4913..1dcfdd4dc 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingOrderResponse.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/producing/dto/ProducingOrderResponse.java @@ -2,6 +2,7 @@ package com.cf.imes.module.plan.service.orderImport.producing.dto; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.databind.JsonNode; import lombok.Data; import java.util.Collections; @@ -149,7 +150,7 @@ public class ProducingOrderResponse { private List processGroupIds = Collections.emptyList(); private String componentGroupId; /** - * 物理板件/配件实例的业务备注,导入备注只取本字段。 + * 物理板件/配件实例的业务备注;配件实例未返回时兼容定义级业务备注。 */ private Map remarks = Collections.emptyMap(); } @@ -170,6 +171,9 @@ public class ProducingOrderResponse { private Double length; private Double width; private Double height; + /** + * 配件定义级业务备注,仅在 partsItems.remarks 缺失时作为兼容兜底。 + */ private Map remarks = Collections.emptyMap(); } @@ -257,6 +261,12 @@ public class ProducingOrderResponse { private String knifeName; private Double radius; private Double value; - private String toolPath; + /** + * 偏移刀路。 + * + *

新报文返回包含 {@code id/pts/buls/depths} 的对象,旧报文可能直接返回刀路 ID, + * 因此保留为 JSON 节点并由转换层统一提取 ID。

+ */ + private JsonNode toolPath; } }