Ejemplo n.º 1
0
 protected override void DeleteObject(object obj)
 {
     if (obj.GetType() == typeof(BomDetail))
     {
         BomDetail bomDetail    = (BomDetail)obj;
         BomDetail newBomDetail = this.bomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code);
         if (newBomDetail != null)
         {
             newBomDetail.EndDate = DateTime.Today.AddDays(-1);
             this.bomDetailMgr.UpdateBomDetail(newBomDetail);
             log.Debug("Update BomDetail to inactive");
             // this.bomDetailMgr.DeleteBomDetail(newBomDetail.Id);
         }
     }
     else if (obj.GetType() == typeof(MesBomDetail))
     {
         MesBomDetail bomDetail    = (MesBomDetail)obj;
         MesBomDetail newBomDetail = this.mesBomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code);
         if (newBomDetail != null)
         {
             newBomDetail.EndDate = DateTime.Today.AddDays(-1);
             this.mesBomDetailMgr.UpdateBomDetail(newBomDetail);
             log.Debug("Update MesBomDetail to inactive");
         }
         IList <MesBom> mesBomList = mesBomDetailMgr.GetRelatedBomDetail(bomDetail);
         if (mesBomList != null && mesBomList.Count > 0)
         {
             foreach (MesBom mesBom in mesBomList)
             {
                 mesBom.TransferFlag = true;
                 mesBomMgr.UpdateBom(mesBom);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public List <MesBomDetail> GetBomDetailList(string bomCode, string itemCode)
        {
            List <MesBomDetail>  mesBomDetailList = new List <MesBomDetail>();
            IList <MesBomDetail> bomDetailList    = GetNextLevelBomDetail(itemCode);

            foreach (MesBomDetail scmsBomDetail in bomDetailList)
            {
                if (scmsBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_N)
                {
                    MesBomDetail bomDetail = new MesBomDetail();
                    bomDetail.Bom      = mesBomMgr.LoadBom(bomCode);
                    bomDetail.Item     = scmsBomDetail.Item;
                    bomDetail.RateQty  = scmsBomDetail.RateQty;
                    bomDetail.IsActive = scmsBomDetail.IsActive;
                    mesBomDetailList.Add(bomDetail);
                }
                else if (scmsBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_X)
                {
                    List <MesBomDetail> xBomDetailList = GetBomDetailList(bomCode, scmsBomDetail.Item.Code);
                    mesBomDetailList.AddRange(xBomDetailList);
                }
            }

            return(mesBomDetailList);
        }
Ejemplo n.º 3
0
        public List <MesBomDetail> GetBomDetailList(MesBom mesBom)
        {
            MesBom topBom = mesBomMgr.LoadBom(mesBom.Code, true);
            List <MesBomDetail> mesBomDetailList = new List <MesBomDetail>();

            if (topBom.BomDetails != null && topBom.BomDetails.Count > 0)
            {
                foreach (MesBomDetail mesBomDetail in topBom.BomDetails)
                {
                    if (mesBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_N)
                    {
                        mesBomDetailList.Add(mesBomDetail);
                    }
                    else if (mesBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_X)
                    {
                        List <MesBomDetail> xBomDetail = GetBomDetailList(mesBomDetail.Bom.Code, mesBomDetail.Item.Code);
                        mesBomDetailList.AddRange(xBomDetail);
                    }
                }
            }

            var query = mesBomDetailList.Select(l => new
            {
                Bom     = l.Bom,
                Item    = l.Item,
                RateQty = (from m in mesBomDetailList
                           where m.Bom.Code.Trim().ToUpper() == l.Bom.Code.Trim().ToUpper() &&
                           m.Item.Code.Trim().ToUpper() == l.Item.Code.Trim().ToUpper() &&
                           m.IsActive == l.IsActive
                           select m.RateQty).Sum(),
                IsActive = l.IsActive
            }).Distinct();

            List <MesBomDetail> list = new List <MesBomDetail>();

            foreach (var item in query)
            {
                MesBomDetail mesBomDetail = new MesBomDetail();
                mesBomDetail.Bom      = item.Bom;
                mesBomDetail.Item     = item.Item;
                mesBomDetail.RateQty  = item.RateQty;
                mesBomDetail.IsActive = item.IsActive;
                list.Add(mesBomDetail);
            }
            return(list);
        }
Ejemplo n.º 4
0
        protected override void CreateOrUpdateObject(object obj)
        {
            if (obj.GetType() == typeof(BomDetail))
            {
                BomDetail bomDetail = (BomDetail)obj;

                BomDetail newBomDetail = this.bomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code);
                if (newBomDetail == null)
                {
                    this.bomDetailMgr.CreateBomDetail(bomDetail);
                    log.Debug("Create BomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########"));
                }
                else
                {
                    CloneHelper.CopyProperty(bomDetail, newBomDetail, this.fields);
                    this.bomDetailMgr.UpdateBomDetail(newBomDetail);
                    log.Debug("Update BomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########"));
                }
            }
            else if (obj.GetType() == typeof(MesBomDetail))
            {
                MesBomDetail bomDetail = (MesBomDetail)obj;

                MesBomDetail newBomDetail = this.mesBomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code);
                if (newBomDetail == null)
                {
                    this.mesBomDetailMgr.CreateBomDetail(bomDetail);
                    log.Debug("Create MesBomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########"));
                }
                else
                {
                    CloneHelper.CopyProperty(bomDetail, newBomDetail, this.fields);
                    this.mesBomDetailMgr.UpdateBomDetail(newBomDetail);
                    log.Debug("Update MesBomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########"));
                }
                IList <MesBom> mesBomList = mesBomDetailMgr.GetRelatedBomDetail(bomDetail);
                if (mesBomList != null && mesBomList.Count > 0)
                {
                    foreach (MesBom mesBom in mesBomList)
                    {
                        mesBom.TransferFlag = true;
                        mesBomMgr.UpdateBom(mesBom);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public IList <MesBom> GetRelatedBomDetail(MesBomDetail mesBomDetail)
        {
            List <MesBom> mesBomList = new List <MesBom>();

            if (mesBomDetail.Item.IsMes)
            {
                mesBomList.Add(mesBomDetail.Bom);
            }
            IList <MesBomDetail> mesBomDetailList = this.GetAllBomDetailList(null, mesBomDetail.Bom.Code);

            if (mesBomDetailList != null && mesBomDetailList.Count > 0)
            {
                foreach (MesBomDetail mb in mesBomDetailList)
                {
                    mesBomList.AddRange(GetRelatedBomDetail(mb));
                }
            }
            return(mesBomList);
        }
Ejemplo n.º 6
0
 public virtual void DeleteBomDetail(MesBomDetail entity)
 {
     entityDao.DeleteBomDetail(entity);
 }
Ejemplo n.º 7
0
 public virtual void UpdateBomDetail(MesBomDetail entity)
 {
     entityDao.UpdateBomDetail(entity);
 }
Ejemplo n.º 8
0
 public virtual void CreateBomDetail(MesBomDetail entity)
 {
     entityDao.CreateBomDetail(entity);
 }
Ejemplo n.º 9
0
        private object Deserialize(DssImportHistory dssImportHistory, bool isUpdate)
        {
            Item bomItem = this.itemMgr.CheckAndLoadItem(dssImportHistory[1]); //bom头
            Item item    = this.itemMgr.CheckAndLoadItem(dssImportHistory[2]); //零件号

            if (item.IsMes && bomItem.IsMes)
            {
                MesBomDetail mesBomDetail = new MesBomDetail();
                mesBomDetail.Bom  = this.LoadMesBom(dssImportHistory[1]);//Bom代码
                mesBomDetail.Item = item;

                mesBomDetail.StartDate = dssImportHistory[4] != null?
                                         DssHelper.GetDate(dssImportHistory[4], BusinessConstants.DSS_SYSTEM_CODE_QAD) : new DateTime(2000, 1, 1);

                if (isUpdate)
                {
                    mesBomDetail.RateQty       = decimal.Parse(dssImportHistory[5]);                                                //用量
                    mesBomDetail.StructureType = this.GetStructureType(dssImportHistory[6], BusinessConstants.DSS_SYSTEM_CODE_QAD); //类型

                    if (dssImportHistory[8] != null)
                    {
                        mesBomDetail.EndDate = DssHelper.GetDate(dssImportHistory[8], BusinessConstants.DSS_SYSTEM_CODE_QAD);                             //结束日期
                    }
                }
                return(mesBomDetail);
            }
            else
            {
                BomDetail bomDetail = new BomDetail();
                bomDetail.Bom       = this.LoadBom(dssImportHistory[1]); //Bom代码
                bomDetail.Item      = item;                              //零件号
                bomDetail.Reference = dssImportHistory[3];               //参考
                bomDetail.StartDate = dssImportHistory[4] != null?
                                      DssHelper.GetDate(dssImportHistory[4], BusinessConstants.DSS_SYSTEM_CODE_QAD) : new DateTime(2000, 1, 1);

                if (isUpdate)
                {
                    bomDetail.RateQty       = decimal.Parse(dssImportHistory[5]);                                                //用量
                    bomDetail.StructureType = this.GetStructureType(dssImportHistory[6], BusinessConstants.DSS_SYSTEM_CODE_QAD); //类型

                    if (dssImportHistory[8] != null)
                    {
                        bomDetail.EndDate = DssHelper.GetDate(dssImportHistory[8], BusinessConstants.DSS_SYSTEM_CODE_QAD);                             //结束日期
                    }
                    //回冲方式从零件上取
                    bomDetail.BackFlushMethod = bomDetail.Item.BackFlushMethod;
                    bomDetail.ScrapPercentage = decimal.Parse(dssImportHistory[10]) / 100;//废品百分比

                    bomDetail.Operation = int.Parse(dssImportHistory[12]);
                }

                #region 默认值
                bomDetail.Uom          = bomDetail.Item.Uom;
                bomDetail.Priority     = 0;
                bomDetail.NeedPrint    = true;
                bomDetail.IsShipScanHu = false;

                #endregion

                return(bomDetail);
            }
        }
Ejemplo n.º 10
0
 public virtual void DeleteBomDetail(MesBomDetail entity)
 {
     Delete(entity);
 }
Ejemplo n.º 11
0
 public virtual void UpdateBomDetail(MesBomDetail entity)
 {
     Update(entity);
 }
Ejemplo n.º 12
0
 public virtual void CreateBomDetail(MesBomDetail entity)
 {
     Create(entity);
 }