예제 #1
0
 public void StartEmptyVanOrder(string flow)
 {
     IList<DeferredFeedCounter> deferredFeedCounterList = this.genericMgr.FindAll<DeferredFeedCounter>("from DeferredFeedCounter where Flow = ?", flow);
     if (deferredFeedCounterList != null && deferredFeedCounterList.Count > 0)
     {
         deferredFeedCounterList[0].Counter++;
         this.genericMgr.Update(deferredFeedCounterList[0]);
     }
     else
     {
         DeferredFeedCounter deferredFeedCounter = new DeferredFeedCounter();
         deferredFeedCounter.Flow = flow;
         deferredFeedCounter.Counter = 1;
         this.genericMgr.Create(deferredFeedCounter);
     }
 }
예제 #2
0
        private void DoStartVanOrder(string orderNo, string feedOrderNo, IList<string> feedHuIdList, bool isForce)
        {
            #region 上线
            OrderMaster orderMaster = this.genericMgr.FindById<OrderMaster>(orderNo);

            #region 判断是否第一辆上线
            IList<long> beforeUnstartVanOrderCount = this.genericMgr.FindAll<long>("select count(*) as counter from OrderMaster where Type = ? and Flow = ? and Status = ? and IsPause = ? and Sequence < ?", new object[] { orderMaster.Type, orderMaster.Flow, CodeMaster.OrderStatus.Submit, false, orderMaster.Sequence });

            if (beforeUnstartVanOrderCount != null && beforeUnstartVanOrderCount.Count > 0 && beforeUnstartVanOrderCount[0] > 0)
            {
                throw new BusinessException("生产单{0}不是生产线{1}第一张待上线的生产单。", orderNo, orderMaster.Flow);
            }
            #endregion

            this.StartOrder(orderMaster);
            #endregion

            #region 子生产单投料
            if (!string.IsNullOrWhiteSpace(feedOrderNo))
            {
                this.productionLineMgr.FeedProductOrder(orderNo, feedOrderNo, isForce);
            }
            #endregion

            #region 物料投料
            if (feedHuIdList != null && feedHuIdList.Count > 0)
            {
                #region 查找投料条码
                IList<Hu> huList = this.huMgr.LoadHus(feedHuIdList);
                #endregion

                #region 查找投料工位
                string hql = string.Empty;
                IList<object> para = new List<object>();
                foreach (string item in huList.Select(h => h.Item).Distinct())
                {
                    if (hql == string.Empty)
                    {
                        hql = "from OrderBomDetail where OrderNo = ? and Item in (?";
                        para.Add(orderNo);
                    }
                    else
                    {
                        hql += ", ?";
                    }
                    para.Add(item);
                }
                hql += ")";

                IList<OrderBomDetail> orderBomDetailList = this.genericMgr.FindAll<OrderBomDetail>(hql, para.ToArray());

                #region 判断条码是否在OrderBomDetial中存在
                if (!isForce)
                {
                    BusinessException businessException = new BusinessException();
                    foreach (Hu hu in huList)
                    {
                        if (orderBomDetailList.Where(det => det.Item == hu.Item).Count() == 0)
                        {
                            businessException.AddMessage("投料的条码{0}在生产单的物料清单中不存在。", hu.HuId);
                        }
                    }

                    if (businessException.HasMessage)
                    {
                        throw businessException;
                    }
                }
                #endregion
                #endregion

                #region 投料
                foreach (string huId in feedHuIdList)
                {
                    Hu hu = huList.Where(h => h.HuId == huId).Single();
                    OrderBomDetail orderBomDetail = orderBomDetailList.Where(o => o.Item == hu.Item).OrderBy(o => o.Sequence).First();

                    FeedInput feedInput = new FeedInput();
                    feedInput.HuId = huId;
                    feedInput.Operation = orderBomDetail.Operation;
                    feedInput.OpReference = orderBomDetail.OpReference;

                    IList<FeedInput> feedInputList = new List<FeedInput>();
                    feedInputList.Add(feedInput);

                    this.productionLineMgr.FeedRawMaterial(orderNo, feedInputList, isForce);
                }
                #endregion
            }
            #endregion

            #region 释放驾驶室生产单
            //由后台Job自动释放
            #endregion

            #region 递延扣减
            //记录递延扣减需求,由后台Job自动扣减
            IList<DeferredFeedCounter> deferredFeedCounterList = this.genericMgr.FindAll<DeferredFeedCounter>("from DeferredFeedCounter where Flow = ?", orderMaster.Flow);
            if (deferredFeedCounterList != null && deferredFeedCounterList.Count > 0)
            {
                deferredFeedCounterList[0].Counter++;
                this.genericMgr.Update(deferredFeedCounterList[0]);
            }
            else
            {
                DeferredFeedCounter deferredFeedCounter = new DeferredFeedCounter();
                deferredFeedCounter.Flow = orderMaster.Flow;
                deferredFeedCounter.Counter = 1;
                this.genericMgr.Create(deferredFeedCounter);
            }
            #endregion
        }