예제 #1
0
        public void FeedKitOrder(string orderNo, string kitOrderNo, bool isForceFeed, DateTime effectiveDate)
        {
            #region 查询订单
            IList<OrderMaster> orderMasterList = this.genericMgr.FindAll<OrderMaster>("from OrderMaster where OrderNo in (?, ?)",
                new object[] { orderNo, kitOrderNo });
            #endregion

            #region 检查
            OrderMaster productOrder = orderMasterList.Where(o => o.OrderNo == orderNo).Single();
            OrderMaster kitOrder = orderMasterList.Where(o => o.OrderNo == kitOrderNo).Single();

            if (productOrder.Type != CodeMaster.OrderType.Production
                || productOrder.Type == CodeMaster.OrderType.SubContract)
            {
                throw new TechnicalException("ProductOrder type is not correct.");
            }

            if (kitOrder.OrderStrategy != CodeMaster.FlowStrategy.KIT)
            {
                throw new TechnicalException("KitOrder strategy is not correct.");
            }

            if (productOrder.Status != CodeMaster.OrderStatus.InProcess
                && productOrder.Status != CodeMaster.OrderStatus.Complete)
            {
                throw new BusinessException("生产单{0}的状态为{1},不能投料。", productOrder.OrderNo,
                    systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)productOrder.Status).ToString()));
            }

            if (kitOrder.Status != CodeMaster.OrderStatus.Close
                && kitOrder.Status != CodeMaster.OrderStatus.Complete)
            {
                throw new BusinessException("KIT单{0}没有收货,不能投料。", kitOrder.OrderNo);
            }

            if (!isForceFeed && productOrder.TraceCode != kitOrder.TraceCode)
            {
                throw new BusinessException("KIT单{0}的VAN号{1}和生产单的VAN号{2}不一致。", kitOrder.OrderNo, kitOrder.TraceCode, productOrder.TraceCode);
            }

            #region 查询Kit单是否已经投料
            if (this.genericMgr.FindAll<long>("select count(*) as counter from ProductFeed where FeedOrder = ?", kitOrder.OrderNo)[0] > 0)
            {
                throw new BusinessException("KIT单{0}已经投料。", kitOrder.OrderNo);
            }
            #endregion
            #endregion

            #region 根据工位找工序
            OrderOperation orderOperation = this.genericMgr.FindAll<OrderOperation>("from OrderOperation where OrderNo = ? and OpReference = ?",
                new object[] { productOrder.OrderNo, kitOrder.LocationTo }).FirstOrDefault();
            #endregion

            #region 查询Kit收货单明细
            //循环查找kit单的绑定订单,要全部投料至生产线上。
            IList<string> childKitOrderNoList = NestGetChildKitOrderNo(kitOrder.OrderNo);
            string selectKitReceiptStatement = NativeSqlStatement.SELECT_KIT_RECEIPT_STATEMENT;
            IList<object> selectKitReceiptParm = new List<object>();
            selectKitReceiptParm.Add(kitOrder.OrderNo);
            if (childKitOrderNoList != null && childKitOrderNoList.Count > 0)
            {
                foreach (string childKitOrderNo in childKitOrderNoList)
                {
                    selectKitReceiptStatement += ",?";
                    selectKitReceiptParm.Add(childKitOrderNo);
                }
            }
            selectKitReceiptStatement += ")";
            IList<ReceiptLocationDetail> receiptLocationDetailList = this.genericMgr.FindEntityWithNativeSql<ReceiptLocationDetail>(selectKitReceiptStatement, selectKitReceiptParm.ToArray());
            IList<Item> itemList = this.itemMgr.GetItems(receiptLocationDetailList.Select(det => det.Item).Distinct().ToList());
            //查找订单明细,需要取Kit单的预留号、行号、SAP生产单号、批号、移动类型
            IList<OrderDetail> orderDetailList = this.LoadOrderDetails(receiptLocationDetailList.Select(r => r.OrderDetailId.Value).Distinct().ToArray());

            IList<FeedInput> feedInputList = (from det in receiptLocationDetailList
                                              group det by new
                                              {
                                                  Item = det.Item,
                                                  QualityType = det.QualityType,
                                                  HuId = det.HuId,
                                                  ReserveNo = orderDetailList.Where(od => od.Id == det.OrderDetailId).Single().ReserveNo,
                                                  ReserveLine = orderDetailList.Where(od => od.Id == det.OrderDetailId).Single().ReserveLine,
                                                  AUFNR = orderDetailList.Where(od => od.Id == det.OrderDetailId).Single().AUFNR,
                                                  ICHARG = orderDetailList.Where(od => od.Id == det.OrderDetailId).Single().ICHARG,
                                                  BWART = orderDetailList.Where(od => od.Id == det.OrderDetailId).Single().BWART,
                                              } into result
                                              select new FeedInput
                                              {
                                                  Item = result.Key.Item,
                                                  QualityType = result.Key.QualityType,
                                                  HuId = result.Key.HuId,
                                                  LocationFrom = kitOrder.LocationTo,  //投料的扣料库位为Kit单的目的库位
                                                  Uom = itemList.Where(i => i.Code == result.Key.Item).Single().Uom,
                                                  ReserveNo = result.Key.ReserveNo,
                                                  ReserveLine = result.Key.ReserveLine,
                                                  AUFNR = result.Key.AUFNR,
                                                  ICHARG = result.Key.ICHARG,
                                                  BWART = result.Key.BWART,
                                                  Qty = result.Sum(det => det.Qty)
                                              }).ToList();

            #region FeedInput的ITEM赋基本单位
            SetUom4FeedInput(feedInputList);
            #endregion
            #endregion

            #region 记录Kit单投料
            ProductFeed productFeed = new ProductFeed();
            productFeed.TraceCode = productOrder.TraceCode;
            productFeed.FeedOrder = kitOrderNo;
            productFeed.ProductOrder = orderNo;

            this.genericMgr.Create(productFeed);
            #endregion

            #region 投料
            FeedRawMaterial(orderNo, feedInputList, true, effectiveDate);
            #endregion
        }
예제 #2
0
        public void KitOrderOffline(IList<OrderDetail> orderDetailList, IList<string> feedKitOrderNoList, bool isForceFeed, DateTime effectiveDate)
        {
            #region 获取下线Kit单号
            if (orderDetailList.Select(det => det.OrderNo).Distinct().Count() > 1)
            {
                throw new BusinessException("分装生产单不能合并下线。");
            }
            string kitOrderNo = orderDetailList.Select(det => det.OrderNo).Distinct().Single();
            #endregion

            #region 查询Kit单和投料的Kit单
            List<string> orderNoList = new List<string>();
            orderNoList.Add(kitOrderNo);
            if (feedKitOrderNoList != null && feedKitOrderNoList.Count > 0)
            {
                orderNoList.AddRange(feedKitOrderNoList);
            }
            IList<OrderMaster> orderMasterList = this.LoadOrderMasters(orderNoList.ToArray());
            #endregion

            #region 检查
            OrderMaster kitOrder = orderMasterList.Where(o => o.OrderNo == kitOrderNo).Single();
            IList<OrderMaster> feedKitOrderList = orderMasterList.Where(o => o.OrderNo != kitOrderNo).ToList();

            if (kitOrder.OrderStrategy != CodeMaster.FlowStrategy.KIT)
            {
                throw new BusinessException("订单{0}的类型不是分装生产单。", kitOrder.OrderNo);
            }

            if (kitOrder.Status != CodeMaster.OrderStatus.Submit
                && kitOrder.Status != CodeMaster.OrderStatus.InProcess)
            {
                throw new BusinessException("分装生产单{0}的状态为{1}不能下线。", kitOrder.OrderNo,
                    systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)kitOrder.Status).ToString()));
            }

            if (feedKitOrderList != null && feedKitOrderList.Count > 0)
            {
                foreach (OrderMaster feedKitOrder in feedKitOrderList)
                {
                    if (feedKitOrder.OrderStrategy != CodeMaster.FlowStrategy.KIT)
                    {
                        throw new TechnicalException("Childe KitOrder strategy is not correct.");
                    }

                    if (feedKitOrder.Status != CodeMaster.OrderStatus.Close)
                    {
                        throw new BusinessException("子生产单{0}没有收货,不能投料。", feedKitOrder.OrderNo);
                    }

                    if (!isForceFeed && feedKitOrder.TraceCode != feedKitOrder.TraceCode)
                    {
                        throw new BusinessException("子生产单{0}的VAN号{1}和分装生产单的VAN号{2}不一致。", feedKitOrder.OrderNo, feedKitOrder.TraceCode, kitOrder.TraceCode);
                    }

                    if (this.genericMgr.FindAll<long>("select count(*) as counter from ProductFeed where FeedOrder = ?", feedKitOrder.OrderNo)[0] > 0)
                    {
                        throw new BusinessException("子生产单{0}已经投料。", feedKitOrder.OrderNo);
                    }
                }
            }
            #endregion

            #region 记录Kit单投料
            if (feedKitOrderList != null && feedKitOrderList.Count > 0)
            {
                foreach (OrderMaster feedKitOrder in feedKitOrderList)
                {
                    ProductFeed productFeed = new ProductFeed();
                    productFeed.TraceCode = feedKitOrder.TraceCode;
                    productFeed.FeedOrder = feedKitOrder.OrderNo;
                    productFeed.ProductOrder = kitOrderNo;

                    this.genericMgr.Create(productFeed);
                }
            }
            #endregion

            #region Kit收货
            this.ReceiveOrder(orderDetailList, effectiveDate);
            #endregion
        }
예제 #3
0
        public void FeedProductOrder(string orderNo, string feedOrderNo, bool isForceFeed, DateTime effectiveDate)
        {
            #region 查询订单
            IList<OrderMaster> orderMasterList = this.genericMgr.FindAll<OrderMaster>("from OrderMaster where OrderNo in (?, ?)",
                new object[] { orderNo, feedOrderNo });

            #endregion

            #region 检查
            OrderMaster productOrder = orderMasterList.Where(o => o.OrderNo == orderNo).Single();
            OrderMaster feedProductOrder = orderMasterList.Where(o => o.OrderNo == feedOrderNo).Single();

            if (productOrder.Type != CodeMaster.OrderType.Production
                || productOrder.Type == CodeMaster.OrderType.SubContract)
            {
                throw new TechnicalException("ProductOrder type is not correct.");
            }

            if (feedProductOrder.Type != CodeMaster.OrderType.Production
                || feedProductOrder.Type == CodeMaster.OrderType.SubContract)
            {
                throw new TechnicalException("FeedProductOrder type is not correct.");
            }

            if (productOrder.Status != CodeMaster.OrderStatus.InProcess
                && productOrder.Status != CodeMaster.OrderStatus.Complete)
            {
                throw new BusinessException("父生产单{0}的状态为{1},不能投料。", productOrder.OrderNo,
                    systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)productOrder.Status).ToString()));
            }

            if (feedProductOrder.Status != CodeMaster.OrderStatus.Complete && feedProductOrder.Status != CodeMaster.OrderStatus.Close)
            {
                throw new BusinessException("子生产单{0}没有完工,不能投料。", feedProductOrder.OrderNo);
            }

            if (!isForceFeed && productOrder.TraceCode != feedProductOrder.TraceCode)
            {
                throw new BusinessException("子生产单{0}的VAN号{1}和父生产单的VAN号{2}不一致。", feedProductOrder.OrderNo, feedProductOrder.TraceCode, productOrder.TraceCode);
            }

            #region 查询生产单是否已经投料
            if (this.genericMgr.FindAll<long>("select count(*) as counter from ProductFeed where FeedOrder = ?", feedProductOrder.OrderNo)[0] > 0)
            {
                throw new BusinessException("子生产单{0}已经投料。", feedProductOrder.OrderNo);
            }
            #endregion
            #endregion

            #region 根据工位找工序
            OrderOperation orderOperation = this.genericMgr.FindAll<OrderOperation>("from OrderOperation where OrderNo = ? and OpReference = ?",
                new object[] { productOrder.OrderNo, feedProductOrder.LocationTo }).FirstOrDefault();
            #endregion

            #region 查找投料工单的收货记录
            string selectFeedOrderReceiptStatement = "from ReceiptLocationDetail where OrderDetailId in (select Id from OrderDetail where OrderNo = ?))";
            IList<ReceiptLocationDetail> receiptLocationDetailList = this.genericMgr.FindAll<ReceiptLocationDetail>(selectFeedOrderReceiptStatement, feedProductOrder.OrderNo);
            IList<Item> itemList = this.itemMgr.GetItems(receiptLocationDetailList.Select(det => det.Item).Distinct().ToList());

            IList<FeedInput> feedInputList = (from det in receiptLocationDetailList
                                              group det by new { Item = det.Item, QualityType = det.QualityType, HuId = det.HuId } into result
                                              select new FeedInput
                                              {
                                                  Item = result.Key.Item,
                                                  QualityType = result.Key.QualityType,
                                                  HuId = result.Key.HuId,
                                                  LocationFrom = feedProductOrder.LocationTo,  //投料的扣料库位为Kit单的目的库位
                                                  Uom = itemList.Where(i => i.Code == result.Key.Item).Single().Uom,
                                                  Qty = result.Sum(det => det.Qty),
                                                  NotReport = true,                         //过滤掉驾驶室和底盘总成,不需要传给SAP
                                              }).ToList();

            #region FeedInput的ITEM赋基本单位
            SetUom4FeedInput(feedInputList);
            #endregion
            #endregion

            #region 记录生产单投料
            ProductFeed productFeed = new ProductFeed();
            productFeed.TraceCode = productOrder.TraceCode;
            productFeed.FeedOrder = feedOrderNo;
            productFeed.ProductOrder = orderNo;

            this.genericMgr.Create(productFeed);
            #endregion

            #region 投料
            //投子工单一定是强制投料,因为父工单的Bom不包含子工单的成品
            FeedRawMaterial(orderNo, feedInputList, true, effectiveDate);
            #endregion
        }