/// <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); }