/// <summary>
        /// 创建删除子件BOM服务的DTO
        /// </summary>
        /// <param name="_bom"></param>
        /// <param name="_beBOM"></param>
        /// <returns></returns>
        private BOMMasterDTO4CreateSv DelBOMPartDTO(BOMMaster _bom, UFIDA.U9.CBO.MFG.BOM.BOMMaster _beBOM)
        {
            BOMMasterDTO4CreateSv dtoMasterDelPart = null;

            foreach (var beBOMPart in _beBOM.BOMComponents)
            {
                bool bCompIsExists = false;
                foreach (var bompart in _bom.Components)
                {
                    //当传入的BOM子件中没有该物料编码,则从BOM中删除此子件
                    if (bompart.ItemCode == beBOMPart.ItemMaster.Code)
                    {
                        bCompIsExists = true;
                        continue;
                    }
                }

                if (!bCompIsExists)
                {
                    if (dtoMasterDelPart == null)
                    {
                        dtoMasterDelPart = PubMethod.GetDataOfBOMMaster(_beBOM);
                        dtoMasterDelPart.BOMComponents.Clear();
                    }

                    //检索出原始BOM中存在的子件加入到需删除子件服务的dtoMasterDelPart中
                    UFIDA.U9.CBO.MFG.BOM.BOMComponent.EntityList elstBOMComponent = UFIDA.U9.CBO.MFG.BOM.BOMComponent.Finder.FindAll("BOMMaster=@BOMID and ItemMaster.Code=@ItemCode ",
                                                                                                                                     new OqlParam[] { new OqlParam(_beBOM.ID), new OqlParam(beBOMPart.ItemMaster.Code) });
                    if (elstBOMComponent != null && elstBOMComponent.Count > 0)
                    {
                        for (int i = 0; i < elstBOMComponent.Count; i++)
                        {
                            UFIDA.U9.CBO.MFG.BOM.BOMComponent beBOMComponent = elstBOMComponent[i];
                            BOMComponentDTO4CreateSv          dtoComponent   = PubMethod.GetDataOfBOMComponent(beBOMComponent);
                            if (dtoMasterDelPart.BOMComponents.Contains(dtoComponent))
                            {
                                continue;
                            }
                            else
                            {
                                dtoMasterDelPart.BOMComponents.Add(dtoComponent);
                            }
                        }
                    }
                }
            }

            return(dtoMasterDelPart);
        }
        /// <summary>
        /// 创建修改BOM服务的DTO
        /// </summary>
        /// <param name="_bom"></param>
        /// <param name="_beBOM"></param>
        /// <returns></returns>
        private BOMMasterDTO4CreateSv ModifyBOMMasterDTO(BOMMaster _bom, UFIDA.U9.CBO.MFG.BOM.BOMMaster _beBOM, Organization _beOrgContext)
        {
            BOMMasterDTO4CreateSv dtoMasterModify = PubMethod.GetDataOfBOMMaster(_beBOM);

            try
            {
                //清除系统原有子件清单
                dtoMasterModify.BOMComponents.Clear();
                int iSeq = PubMethod.GetNextMaxSequence(_beBOM);
                //加入待修改的子件清单
                bool isAllBomCompOK = true;
                foreach (var bomComp in _bom.Components)
                {
                    UFIDA.U9.CBO.MFG.BOM.BOMComponent.EntityList elstBOMComponent = UFIDA.U9.CBO.MFG.BOM.BOMComponent.Finder.FindAll("BOMMaster=@BOMID and ItemMaster.Code=@ItemCode ",
                                                                                                                                     new OqlParam[] { new OqlParam(_beBOM.ID), new OqlParam(bomComp.ItemCode) });
                    //在系统后台根据BOM主ID和子件的物料编码检索,如果有此子件则由GetDataOfBOMComponent直接创建子件DTO添加dtoMasterModify。
                    if (elstBOMComponent != null && elstBOMComponent.Count > 0)
                    {
                        //处理母件下有相同的子件物料的明细行
                        for (int i = 0; i < elstBOMComponent.Count; i++)
                        {
                            UFIDA.U9.CBO.MFG.BOM.BOMComponent beBOMComponent = elstBOMComponent[i];
                            BOMComponentDTO4CreateSv          dtoComponent   = PubMethod.GetDataOfBOMComponent(beBOMComponent);

                            if (dtoMasterModify.BOMComponents.Contains(dtoComponent))
                            {
                                continue;
                            }
                            else
                            {
                                //修改内容
                                dtoComponent.UsageQty  = bomComp.UsageQty;  //用量
                                dtoComponent.Scrap     = bomComp.Scrap;     //损耗率
                                dtoComponent.ParentQty = bomComp.ParentQty; //母件底数
                                dtoComponent.Remark    = bomComp.Remark;    //备注

                                if (!String.IsNullOrEmpty(bomComp.CompProject))
                                {
                                    Project itemProject = Project.FindByCode(bomComp.CompProject);
                                    if (itemProject != null)
                                    {
                                        dtoComponent.CompProject      = new CommonArchiveDataDTO();
                                        dtoComponent.CompProject.ID   = itemProject.ID;
                                        dtoComponent.CompProject.Code = itemProject.Code;
                                        dtoComponent.CompProject.Name = itemProject.Name;
                                    }
                                }
                                else
                                {
                                    //原接口未对项目置空的处理(UFIDA.U9.ISV.MFG.BOM.PubMethod.UpdateBOMComponent)
                                    string strUpdateVersion = string.Format("update uu set uu.CompProject = null from CBO_BOMComponent uu "
                                                                            + "where uu.ID = {0}", beBOMComponent.ID.ToString());
                                    DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), strUpdateVersion, null);

                                    //dtoComponent.CompProject.ID = 1L;//
                                    //dtoComponent.CompProject.Code = string.Empty;
                                    //dtoComponent.CompProject.Name = string.Empty;
                                    //dtoComponent.CompProject = new CommonArchiveDataDTO();
                                }

                                dtoMasterModify.BOMComponents.Add(dtoComponent);
                                break;
                            }
                        }
                    }
                    else
                    {
                        #region 新增子件
                        BOMComponentDTO4CreateSv dtoComponent = CreateBOMComponentDTO(bomComp, iSeq, _bom, _beBOM.Org);
                        if (dtoComponent == null)
                        {
                            isAllBomCompOK = false;
                        }
                        dtoMasterModify.BOMComponents.Add(dtoComponent);
                        iSeq += 10;
                        #endregion
                    }
                }
                if (!isAllBomCompOK)
                {
                    dtoMasterModify = null;
                }
            }
            catch (Exception ex)
            {
                strbError.AppendLine(string.Format(strErrorItem, _bom.ItemMasterCode, "", ex.Message));
                dtoMasterModify = null;
            }
            return(dtoMasterModify);
        }
Beispiel #3
0
 /// <summary>
 /// Constructor with Full Argument
 /// </summary>
 public OrderBomHeadDTO(System.Int64 iD, System.DateTime createdOn, System.String createdBy, System.DateTime modifiedOn, System.String modifiedBy, System.Int64 sysVersion, UFIDA.U9.CBO.MFG.BOM.BOMMaster bomMaster, UFIDA.U9.CBO.MFG.BOM.BOMComponent bomCompont, UFIDA.U9.CBO.SCM.Item.ItemMaster parentPart, UFIDA.U9.CBO.SCM.Item.ItemMaster subKey, System.Decimal dosage, UFIDA.U9.Base.UOM.UOM dosageUnit, System.Decimal sellNumber, UFIDA.U9.Base.UOM.UOM sellUnit, System.Decimal needNumber, UFIDA.U9.SM.SO.SOLine orderLine, UFIDA.U9.SM.SO.SO orderHead, System.Int32 orderLineRow, UFIDA.U9.Cust.GS.FT.AllEnumBE.SourceTypeEnum sourceType, System.String remark, UFIDA.U9.CBO.HR.Operator.Operators salesMan, UFIDA.U9.CBO.MFG.Enums.SupplyTypeEnum supplierType, System.String tier, System.Decimal loss, System.Boolean arrirmState, List <UFIDA.U9.Cust.GS.FT.OrderBomBE.OrderBomLineDTO> orderBomLine, UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegments descflexfield, UFIDA.U9.CBO.SCM.Item.ItemCategory subkeyType)
 {
     this.ID            = iD;
     this.CreatedOn     = createdOn;
     this.CreatedBy     = createdBy;
     this.ModifiedOn    = modifiedOn;
     this.ModifiedBy    = modifiedBy;
     this.SysVersion    = sysVersion;
     this.BomMaster     = bomMaster;
     this.BomCompont    = bomCompont;
     this.ParentPart    = parentPart;
     this.SubKey        = subKey;
     this.Dosage        = dosage;
     this.DosageUnit    = dosageUnit;
     this.SellNumber    = sellNumber;
     this.SellUnit      = sellUnit;
     this.NeedNumber    = needNumber;
     this.OrderLine     = orderLine;
     this.OrderHead     = orderHead;
     this.OrderLineRow  = orderLineRow;
     this.SourceType    = sourceType;
     this.Remark        = remark;
     this.SalesMan      = salesMan;
     this.SupplierType  = supplierType;
     this.Tier          = tier;
     this.Loss          = loss;
     this.ArrirmState   = arrirmState;
     this.OrderBomLine  = orderBomLine;
     this.Descflexfield = descflexfield;
     this.SubkeyType    = subkeyType;
 }