diff --git a/bff-engine-core/src/main/java/com/inspur/edp/bff/engine/entity/convertor/BffEngineChangeConvertor.java b/bff-engine-core/src/main/java/com/inspur/edp/bff/engine/entity/convertor/BffEngineChangeConvertor.java index 7314eb450759c617ded0fed8e23c1a79ea5fe63a..c320dfe0904c487be835e8cd4bcfa3be3e8a356d 100644 --- a/bff-engine-core/src/main/java/com/inspur/edp/bff/engine/entity/convertor/BffEngineChangeConvertor.java +++ b/bff-engine-core/src/main/java/com/inspur/edp/bff/engine/entity/convertor/BffEngineChangeConvertor.java @@ -18,8 +18,8 @@ package com.inspur.edp.bff.engine.entity.convertor; import com.inspur.edp.bef.bizentity.GspBizEntityObject; import com.inspur.edp.bff.api.manager.IFSManagerContext; -import com.inspur.edp.bff.engine.core.exception.BffEngineCoreException; import com.inspur.edp.bff.engine.core.exception.BffEngineCoreErrorCodes; +import com.inspur.edp.bff.engine.core.exception.BffEngineCoreException; import com.inspur.edp.bff.spi.AbstractChangeConvertor; import com.inspur.edp.cef.designtime.api.IGspCommonField; import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; @@ -32,7 +32,6 @@ import com.inspur.edp.das.commonmodel.IGspCommonElement; import com.inspur.edp.das.commonmodel.IGspCommonObject; import com.inspur.edp.formserver.viewmodel.GspViewModelElement; import com.inspur.edp.formserver.viewmodel.GspViewObject; - import lombok.var; import java.util.HashMap; @@ -56,7 +55,7 @@ public class BffEngineChangeConvertor extends AbstractChangeConvertor { protected void convertModifyPropFromBE(String beElementCode, Object beValue, ModifyChangeDetail voChange) { for (var voElement : voObject.getContainElements()) { - if ((voElement.getIsVirtual() && ((GspViewModelElement)voElement).getIsVirtualViewElement()) || voElement.getObjectType() == GspElementObjectType.DynamicProp) + if ((voElement.getIsVirtual() && ((GspViewModelElement) voElement).getIsVirtualViewElement()) || voElement.getObjectType() == GspElementObjectType.DynamicProp) continue; var beElement = beObject.findElement(((GspViewModelElement) voElement).getMapping().getTargetElementId()); if (beElement == null || !beElement.getLabelID().equals(beElementCode)) @@ -92,10 +91,10 @@ public class BffEngineChangeConvertor extends AbstractChangeConvertor { try { return ((AssociationInfo) value).clone(); } catch (CloneNotSupportedException e) { - throw new BffEngineCoreException(e, BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1011, sourceEle.getName(),value.getClass().getName()); + throw new BffEngineCoreException(e, BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1011, sourceEle.getName(), value.getClass().getName()); } } - throw new BffEngineCoreException(BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1010,sourceEle.getName(),value.getClass().getName()); + throw new BffEngineCoreException(BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1010, sourceEle.getName(), value.getClass().getName()); } else if (sourceEle.getObjectType() == GspElementObjectType.Enum) { if (value == null) return value; @@ -111,6 +110,7 @@ public class BffEngineChangeConvertor extends AbstractChangeConvertor { private Object getTransDataValue(IGspCommonElement sourceEle, IGspCommonElement targetEle, Object value) { if (sourceEle.getObjectType() == GspElementObjectType.Association) { + //如果是生成型 if (_mgrContext.getLcp().getClass().getSimpleName().equals("EngineStandardLcp") == false) { Object targetValue = _mgrContext.getLcp() .createPropertyDefaultValue(beObject.getCode(), targetEle.getLabelID()); @@ -123,11 +123,11 @@ public class BffEngineChangeConvertor extends AbstractChangeConvertor { return value == null ? null : ((com.inspur.edp.commonmodel.engine.api.data.AssociationInfo) value).clone(); } catch (CloneNotSupportedException e) { - throw new BffEngineCoreException(e, BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1011, sourceEle.getName(),value.getClass().getName()); + throw new BffEngineCoreException(e, BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1011, sourceEle.getName(), value.getClass().getName()); } } else if (sourceEle.getObjectType() == GspElementObjectType.Enum) { //针对枚举,如果是空串,按照NULL处理,兼容前端可以取消默认值设置 - if(value == null || "".equals(value)){ + if (value == null || "".equals(value)) { return null; } if (_mgrContext.getLcp().getClass().getSimpleName().equals("EngineStandardLcp") == false) { @@ -150,18 +150,32 @@ public class BffEngineChangeConvertor extends AbstractChangeConvertor { for (String itemKey : value.getPropertyNames()) { Object itemValue = value.getValue(itemKey); if (itemValue instanceof AssociationInfo) { - AssoInfoBase refElementValue = (AssoInfoBase) targetAssInfo.createValue(itemKey); - targetAssInfo.setValue(itemKey, refElementValue); - setAssoValues((AssociationInfo) itemValue, refElementValue); + //此方法是关联BE是生成型才会进来,如果是带出字段是解析的,直接赋值就行(生成代码的innerCreateValue方法未处理带出解析关联,也无法在代码中构造 解析型关联对象。) + if(itemValue instanceof com.inspur.edp.commonmodel.engine.api.data.AssociationInfo){ + targetAssInfo.setValue(itemKey, itemValue); + } + else { + AssoInfoBase refElementValue = (AssoInfoBase) targetAssInfo.createValue(itemKey); + targetAssInfo.setValue(itemKey, refElementValue); + setAssoValues((AssociationInfo) itemValue, refElementValue); + } } else targetAssInfo.setValue(itemKey, itemValue); } } + /** + * 将VM变更数据属性转换成BE变更数据属性 + * + * @param vmElementCode VM字段编号 + * @param vmValue VM变更属性值 + * @param beChange BE变更 + * @see ModifyChangeDetail + */ @Override protected void convertModifyPropFromVM(String vmElementCode, Object vmValue, ModifyChangeDetail beChange) { for (var voElement : voObject.getContainElements()) { - if (!voElement.getLabelID().equals(vmElementCode) || (voElement.getIsVirtual() && ((GspViewModelElement)voElement).getIsVirtualViewElement()))// || voElement.getObjectType() == GspElementObjectType.DynamicProp) + if (!voElement.getLabelID().equals(vmElementCode) || (voElement.getIsVirtual() && ((GspViewModelElement) voElement).getIsVirtualViewElement()))// || voElement.getObjectType() == GspElementObjectType.DynamicProp) continue; var beElement = beObject.findElement(((GspViewModelElement) voElement).getMapping().getTargetElementId()); if (beElement == null) @@ -182,7 +196,7 @@ public class BffEngineChangeConvertor extends AbstractChangeConvertor { String beChildObjId = childObj.getMapping().getTargetObjId(); var beChildObj = beObject.getChildObjectById(beChildObjId); if (beChildObj == null) { - throw new BffEngineCoreException(BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1012, childCode,beChildObjId); + throw new BffEngineCoreException(BffEngineCoreErrorCodes.GSP_BFF_ENGINE_1012, childCode, beChildObjId); } return new BffEngineChangeConvertor(getMgrContext(), childObj, (GspBizEntityObject) beChildObj); }