Exemplo n.º 1
0
 public IList <OrderDetail> GenerateOrderDetail(OrderHead orderHead, FlowDetail flowDetail)
 {
     return(GenerateOrderDetail(orderHead, flowDetail, false));
 }
Exemplo n.º 2
0
        public void ProcessNewOrder(LeanEngine.Entity.Orders order)
        {
            log.Debug("-------------------------------Current flow code:" + order.Flow.Code + "-------------------------------------");
            Flow flow = _flows.SingleOrDefault(o => StringHelper.Eq(order.Flow.Code, o.Code));

            if (flow == null)
            {
                return;
            }

            #region 更新窗口时间
            if (order.Flow.IsUpdateWindowTime)
            {
                if (flow.NextOrderTime != order.Flow.NextOrderTime || flow.NextWinTime != order.Flow.NextWindowTime)
                {
                    flow.NextOrderTime = order.Flow.NextOrderTime;
                    flow.NextWinTime   = order.Flow.NextWindowTime;
                    this.FlowMgr.UpdateFlow(flow, false);
                    log.Debug("Update window time to :" + flow.NextWinTime);
                }
            }
            #endregion

            if (order.ItemFlows == null || order.ItemFlows.Count == 0)
            {
                return;
            }

            #region Initialize
            OrderHead orderHead = OrderMgr.TransferFlow2Order(flow);
            orderHead.IsAutoRelease = true;
            orderHead.WindowTime    = order.WindowTime;
            orderHead.StartTime     = order.StartTime;
            #endregion

            #region New Orders
            if (orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0)
            {
                foreach (var orderDetail in orderHead.OrderDetails)
                {
                    var itemFlow = order.ItemFlows.SingleOrDefault(i => i.ID == orderDetail.FlowDetail.Id);

                    if (itemFlow != null)
                    {
                        orderDetail.RequiredQty  = itemFlow.ReqQty;
                        orderDetail.OrderedQty   = itemFlow.OrderQty;
                        orderDetail.OrderTracers = this.TransformToOrderTracer(itemFlow.OrderTracers);

                        if (orderDetail.OrderTracers != null && orderDetail.OrderTracers.Count > 0)
                        {
                            foreach (var orderTracer in orderDetail.OrderTracers)
                            {
                                orderTracer.OrderDetail = orderDetail;
                            }
                        }
                    }
                }
                orderHead.OrderDetails = orderHead.OrderDetails.Where(o => o.OrderedQty > 0).ToList();

                if (orderHead.OrderDetails.Count > 0)
                {
                    log.Debug("Detail count:" + orderHead.OrderDetails.Count);

                    try
                    {
                        orderHead.Priority = order.IsEmergency ? BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT :
                                             BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;

                        this.OrderMgr.CreateOrder(orderHead, user);
                        this.FlushSession();
                        log.Info("Create order:" + orderHead.OrderNo + " finished. Detail count:" + orderHead.OrderDetails.Count + ",IsEmergency:" + order.IsEmergency);
                        //todo,orderlotsize
                    }
                    catch (BusinessErrorException ex)
                    {
                        log.Error("Fail to create order:", ex);
                    }
                }
            }
            #endregion
        }
Exemplo n.º 3
0
    public string AdjustInProcessLocationTo()
    {
        try
        {
            InProcessLocation ip      = TheInProcessLocationMgr.LoadInProcessLocation(this.IpNo, true);
            Receipt           receipt = new Receipt();
            InProcessLocation nmlIp   = CloneHelper.DeepClone(ip);
            IList <InProcessLocationDetail> nmlReceiptDetailList = new List <InProcessLocationDetail>();
            foreach (InProcessLocationDetail ipdet in ip.InProcessLocationDetails)
            {
                #region 对应的ipdet
                InProcessLocationDetail nmlInProcessLocationDetail = new InProcessLocationDetail();
                nmlInProcessLocationDetail.Qty = 0 - ipdet.Qty;
                nmlInProcessLocationDetail.OrderLocationTransaction = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(ipdet.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_IN)[0];
                nmlInProcessLocationDetail.IsConsignment            = ipdet.IsConsignment;
                nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill;
                nmlReceiptDetailList.Add(nmlInProcessLocationDetail);
                #endregion

                #region 收货单明细
                ReceiptDetail receiptDetail = new ReceiptDetail();
                receiptDetail.Receipt     = receipt;
                receiptDetail.ReceivedQty = nmlInProcessLocationDetail.Qty;
                receiptDetail.ShippedQty  = nmlInProcessLocationDetail.Qty;
                receiptDetail.OrderLocationTransaction = nmlInProcessLocationDetail.OrderLocationTransaction;
                receiptDetail.IsConsignment            = ipdet.IsConsignment;
                nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill;

                OrderDetail orderDetail = receiptDetail.OrderLocationTransaction.OrderDetail;

                OrderHead orderHead = orderDetail.OrderHead;

                if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                {
                    PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListFrom, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency);
                    if (priceListDetail == null)
                    {
                        throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code });
                    }
                    receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty;
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                {
                    PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListTo, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency);
                    if (priceListDetail == null)
                    {
                        throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code });
                    }
                    receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty;
                }

                receipt.AddReceiptDetail(receiptDetail);
                #endregion
            }


            nmlIp.InProcessLocationDetails = nmlReceiptDetailList;
            if (receipt.InProcessLocations == null)
            {
                receipt.InProcessLocations = new List <InProcessLocation>();
            }
            receipt.InProcessLocations.Add(nmlIp);

            TheReceiptMgr.CreateReceipt(receipt, this.CurrentUser);
            return(receipt.ReceiptNo);
        }
        catch (BusinessErrorException ex)
        {
            throw (ex);
        }
    }
Exemplo n.º 4
0
        public virtual void ReceiveWo(DssImportHistory dssImportHistory)
        {
            try
            {
                string  prodLine    = dssImportHistory.data0;
                string  itemCode    = dssImportHistory.data1;
                string  huId        = dssImportHistory.data2;
                decimal qty         = decimal.Parse(dssImportHistory.data3);
                string  itemHuId    = dssImportHistory.data4;
                string  onlineDate  = dssImportHistory.data5;
                string  onlineTime  = dssImportHistory.data6;
                string  offlineDate = dssImportHistory.data7;
                string  offlineTime = dssImportHistory.data8;

                DateTime woOffTime = DateTime.Parse(offlineDate);
                string[] timeArr   = offlineTime.Split(':');
                if (timeArr == null && timeArr.Length != 3)
                {
                    log.Error("Error date format" + offlineTime);
                    dssImportHistory.Memo = "Error date format" + offlineTime;
                    dssImportHistory.ErrorCount++;
                    this.dssImportHistoryMgr.UpdateDssImportHistory(dssImportHistory);
                    return;
                }
                DateTime woTime = woOffTime.AddHours(double.Parse(timeArr[0])).AddMinutes(double.Parse(timeArr[1])).AddSeconds(double.Parse(timeArr[2]));

                string customerCode = dssImportHistory.data9;
                string customerLoc  = dssImportHistory.data10;

                if (this.huMgr.LoadHu(huId) != null)
                {
                    log.Error("Hu " + huId + " already exist in database.");
                    dssImportHistory.Memo = "Hu " + huId + " already exist in database.";
                    dssImportHistory.ErrorCount++;
                    this.dssImportHistoryMgr.UpdateDssImportHistory(dssImportHistory);

                    return;
                }

                #region 查找工单
                //shiftCode = BarcodeHelper.GetShiftCode(huId);
                DetachedCriteria criteria = DetachedCriteria.For <OrderDetail>();
                criteria.CreateAlias("OrderHead", "od");
                // criteria.CreateAlias("od.Flow", "f");
                criteria.CreateAlias("Item", "i");
                //criteria.CreateAlias("Shift", "s");

                criteria.Add(Expression.Like("od.Flow", prodLine, MatchMode.End));
                criteria.Add(Expression.Eq("i.Code", itemCode));
                //criteria.Add(Expression.Eq("s.Code", shiftCode));
                criteria.Add(Expression.Eq("od.Type", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION));
                criteria.Add(Expression.Eq("od.Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS));
                criteria.Add(Expression.Le("od.StartTime", woTime));
                criteria.Add(Expression.Ge("od.WindowTime", woTime));

                criteria.AddOrder(Order.Asc("od.StartTime"));

                IList <OrderDetail> orderDetailList = this.criteriaMgr.FindAll <OrderDetail>(criteria);

                OrderDetail orderDetail = null;
                if (orderDetailList != null && orderDetailList.Count > 0)
                {
                    for (int i = 0; i < orderDetailList.Count; i++)
                    {
                        orderDetail = orderDetailList[i];
                        if (orderDetail.ReceivedQty == null || orderDetail.OrderedQty > (decimal)orderDetail.ReceivedQty)
                        {
                            break;
                        }
                    }

                    log.Info("Find match wo " + orderDetail.OrderHead.OrderNo);
                }
                else
                {
                    FlowDetail flowDetail = this.LoadFlowDetail(prodLine, itemCode);
                    if (flowDetail != null)
                    {
                        OrderHead orderHead = this.orderManager.TransferFlow2Order(flowDetail.Flow);
                        orderDetail             = orderHead.OrderDetails.SingleOrDefault(o => flowDetail.Equals(o.FlowDetail));
                        orderHead.StartTime     = woTime.AddHours(-12);
                        orderHead.WindowTime    = woTime.AddHours(12);
                        orderHead.Priority      = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
                        orderDetail.RequiredQty = qty;
                        orderDetail.OrderedQty  = qty;
                        OrderHelper.FilterZeroOrderQty(orderHead);
                        this.orderManager.CreateOrder(orderHead, this.userMgr.GetMonitorUser());
                        log.Info("Find match wo " + orderHead.OrderNo);
                    }
                }

                if (orderDetail != null)
                {
                    this.FlushSession();
                    this.CleanSession();
                    this.orderManager.DoReceiveWO(huId, orderDetail, qty);
                    dssImportHistory.IsActive = false;
                    this.dssImportHistoryMgr.UpdateDssImportHistory(dssImportHistory);
                }
                else
                {
                    log.Error("No item found for item code " + itemCode + " for prodline + " + prodLine);
                    dssImportHistory.Memo = "No item found for item code " + itemCode + " for prodline + " + prodLine;
                    dssImportHistory.ErrorCount++;
                    this.dssImportHistoryMgr.UpdateDssImportHistory(dssImportHistory);
                }
                #endregion
            }
            catch (Exception ex)
            {
                this.CleanSession();
                log.Error("Receive WO Error.", ex);
                dssImportHistory.Memo = ex.Message;
                dssImportHistory.ErrorCount++;
                this.dssImportHistoryMgr.UpdateDssImportHistory(dssImportHistory);
            }
        }
Exemplo n.º 5
0
 /*
  * 填充报表尾
  *
  * Param pageIndex 页号
  * Param orderHead 订单头对象
  */
 protected void FillFooter(int pageIndex, OrderHead orderHead)
 {
     //计划员Planner
     this.SetRowCell(pageIndex, (rowCount - 1), 2, orderHead.CreateUser.Name);
 }
Exemplo n.º 6
0
        public virtual void ProcessSingleFile(string inboundDirectoryName, string inboundFileName)
        {
            log.Info("Start inbound file " + inboundFileName);
            FlatFileReader reader = new FlatFileReader(inboundFileName, Encoding.ASCII, "\t");

            try
            {
                OrderHead   orderHead   = null;
                OrderDetail orderDetail = null;
                string      shiftCode   = string.Empty;
                Hu          hu          = null;

                string[] fields = reader.ReadLine();
                while (fields != null)
                {
                    string  prodLine     = fields[0];
                    string  itemCode     = fields[1];
                    string  huId         = fields[2];
                    decimal qty          = decimal.Parse(fields[3]);
                    string  itemHuId     = fields[4];
                    string  onlineDate   = fields[5];
                    string  onlineTime   = fields[6];
                    string  offlineDate  = fields[7];
                    string  offlineTime  = fields[8];
                    string  customerCode = fields[9];
                    string  customerLoc  = fields[10];

                    if (orderHead == null)
                    {
                        #region 查找工单
                        shiftCode = BarcodeHelper.GetShiftCode(huId);

                        DetachedCriteria criteria = DetachedCriteria.For <OrderHead>();
                        criteria.CreateAlias("Flow", "f");
                        //criteria.CreateAlias("Shift", "s");

                        criteria.Add(Expression.Like("f.Code", prodLine, MatchMode.End));
                        criteria.Add(Expression.Eq("s.Code", shiftCode));
                        criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS));

                        criteria.AddOrder(Order.Asc("StartTime"));

                        IList <OrderHead> orderHeadList = this.criteriaMgr.FindAll <OrderHead>(criteria);
                        #endregion

                        if (orderHeadList != null && orderHeadList.Count > 0)
                        {
                            foreach (OrderHead targetOrderHead in orderHeadList)
                            {
                                orderHead = targetOrderHead;

                                #region 查找工单明细
                                IList <OrderDetail> orderDetailList = orderHead.OrderDetails;
                                foreach (OrderDetail targetOrderDetail in orderDetailList)
                                {
                                    if (targetOrderDetail.Item.Code == itemCode)
                                    {
                                        log.Info("Find match wo " + orderHead.OrderNo);
                                        orderDetail = targetOrderDetail;
                                        orderDetail.CurrentReceiveQty = qty;
                                        break;
                                    }
                                }
                                #endregion

                                if (orderDetail != null)
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            throw new BusinessErrorException("No active wo find for prodline + " + prodLine + ", shift " + shiftCode);
                        }

                        if (orderDetail != null)
                        {
                            #region 创建外包装条码
                            if (this.huMgr.LoadHu(huId) == null)
                            {
                                log.Info("Insert hu " + huId + " into database.");
                                hu = ResolveAndCreateHu(huId, orderDetail, qty);
                                orderDetail.HuId = hu.HuId;

                                Receipt       receipt       = new Receipt();
                                ReceiptDetail receiptDetail = new ReceiptDetail();
                                receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgr.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0];
                                receiptDetail.HuId        = hu.HuId;
                                receiptDetail.ReceivedQty = qty;
                                receiptDetail.Receipt     = receipt;
                                receiptDetail.LotNo       = hu.LotNo;

                                #region 找Out的OrderLocTrans,填充MaterialFulshBack
                                IList <OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgr.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT);
                                foreach (OrderLocationTransaction orderLocTrans in orderLocTransList)
                                {
                                    MaterialFlushBack material = new MaterialFlushBack();
                                    material.OrderLocationTransaction = orderLocTrans;
                                    if (orderLocTrans.UnitQty != 0)
                                    {
                                        material.Qty = qty;
                                    }
                                    receiptDetail.AddMaterialFlushBack(material);
                                }
                                #endregion
                                receipt.AddReceiptDetail(receiptDetail);

                                this.orderManager.ReceiveOrder(receipt, this.userMgr.GetMonitorUser());
                            }
                            else
                            {
                                throw new BusinessErrorException("Hu " + huId + " already exist in database.");
                            }
                            #endregion
                        }
                        else
                        {
                            throw new BusinessErrorException("No item found for item code " + itemCode + " for prodline + " + prodLine + ", shift " + shiftCode);
                        }
                    }

                    #region 创建内包装条码
                    if (this.huMgr.LoadHu(itemHuId) == null)
                    {
                        log.Info("Insert hu " + itemHuId + " into database.");
                        CreateItemHu(itemHuId, orderDetail, hu.LotNo, hu.ManufactureDate);
                    }
                    else
                    {
                        throw new BusinessErrorException("Hu " + itemHuId + " already exist in database.");
                    }
                    #endregion

                    fields = reader.ReadLine();
                }
            }
            finally
            {
                reader.Dispose();
            }
        }
Exemplo n.º 7
0
        public void RunMes()
        {
            #region 找到所有Mes的生产线,默认一个生产线对应一个线边库位
            log.Info("Flow begin.");
            DetachedCriteria fCriteria = DetachedCriteria.For <Flow>();
            fCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION));
            fCriteria.Add(Expression.Eq("FlowStrategy", BusinessConstants.CODE_MASTER_FLOW_STRATEGY_VALUE_MES));
            fCriteria.Add(Expression.Eq("IsActive", true));
            fCriteria.Add(Expression.Or(Expression.Le("NextWinTime", DateTime.Now), Expression.IsNull("NextWinTime")));
            IList <Flow> flowList = criteriaMgr.FindAll <Flow>(fCriteria);
            log.Info("Flow end.");
            #endregion

            #region 找到所有Mes的移库路线
            log.Info("TransferFlow begin.");
            DetachedCriteria tCriteria = DetachedCriteria.For <FlowDetail>();
            tCriteria.CreateAlias("Flow", "f");
            tCriteria.Add(Expression.Eq("f.Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER));
            tCriteria.Add(Expression.Eq("f.IsActive", true));
            tCriteria.Add(Expression.Ge("f.IsMes", true));
            IList <FlowDetail> transferFlowList = criteriaMgr.FindAll <FlowDetail>(tCriteria);
            log.Info("TransferFlow end.");
            #endregion

            #region 找到所有货架和活动工单
            log.Info("Shelf begin.");
            IList <Shelf> shelfList = shelfMgr.GetAllShelf();
            log.Info("Shelf end.");

            log.Info("ActiveOrder begin.");
            DetachedCriteria oCriteria = DetachedCriteria.For(typeof(OrderLocationTransaction));
            oCriteria.CreateAlias("OrderDetail", "od");
            oCriteria.CreateAlias("od.OrderHead", "oh");
            oCriteria.Add(Expression.In("oh.Status", new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS, BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT }));
            oCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO));
            oCriteria.Add(Expression.Gt("Cartons", 0));
            oCriteria.Add(Expression.IsNotNull("Shelf"));
            IList <OrderLocationTransaction> orderLocTransList = criteriaMgr.FindAll <OrderLocationTransaction>(oCriteria);
            log.Info("ActiveOrder end.");

            IDictionary <string, int> rawDemandDic        = new Dictionary <string, int>();
            IDictionary <string, int> nonZeroRawDemandDic = new Dictionary <string, int>();
            #endregion


            #region 找到所有库存
            log.Info("Inventory begin.");
            string hql = @"select h.Location, h.Item.Code,Count(h.HuId)
                    from Hu as h 
                    where h.Status = ? and h.IsMes = ? 
                    group by h.Location, h.Item.Code";

            IList <object[]> invList = hqlMgr.FindAll <object[]>(hql,
                                                                 new Object[] {
                BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS,
                true
            });

            log.Info("Inventory end.");

            #endregion

            #region 获取实时库存和在途,只有待发,全部为一步移库无待收
            log.Info("ToShip begin.");
            hql = @"select olt.Location.Code, olt.Item.Code,olt.Cartons
                    from OrderLocationTransaction as olt 
                    join olt.OrderDetail as od
                    join od.OrderHead as oh
                    where oh.Status in (?, ?) and oh.SubType = ? and  oh.Type=? and olt.IOType = ? and oh.IsMes = ?
                    and olt.Cartons > 0";

            IList <object[]> expectTransitInvList = hqlMgr.FindAll <object[]>(hql,
                                                                              new Object[] {
                BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT,
                BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS,
                BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML,
                BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER,       //只考虑移库
                BusinessConstants.IO_TYPE_IN,
                true
            });
            log.Info("ToShip end.");

            IList <object[]> totalInvList = new List <object[]>();
            if (invList != null)
            {
                totalInvList = totalInvList.Union(invList).ToList();
            }
            if (expectTransitInvList != null)
            {
                totalInvList = totalInvList.Union(expectTransitInvList).ToList();
            }
            #endregion

            if (flowList != null && flowList.Count > 0)
            {
                foreach (Flow flow in flowList)
                {
                    #region 对每个生产线找到下面的货架
                    IList <Shelf> flowShelfList = shelfList.Where(s => s.ProductLine.Code == flow.Code).ToList();
                    #endregion

                    #region 计算总的毛需求
                    if (flowShelfList != null && flowShelfList.Count > 0)
                    {
                        foreach (Shelf shelf in flowShelfList)
                        {
                            #region 货架找到对应的活动工单
                            IList <OrderLocationTransaction> shelfOrderLocTransList = orderLocTransList.Where(l => l.Shelf.Trim().ToUpper() == shelf.Code.Trim().ToUpper()).OrderByDescending(l => l.OrderDetail.OrderHead.StartTime).ToList();
                            if (shelfOrderLocTransList != null && shelfOrderLocTransList.Count > 0)
                            {
                                int count = shelf.Capacity;
                                foreach (OrderLocationTransaction ol in shelfOrderLocTransList)
                                {
                                    if (rawDemandDic.ContainsKey(ol.Item.Code))
                                    {
                                        rawDemandDic[ol.Item.Code] += ol.Cartons <= count ? ol.Cartons : count;
                                    }
                                    else
                                    {
                                        rawDemandDic.Add(ol.Item.Code, ol.Cartons <= count ? ol.Cartons : count);
                                    }
                                    count -= ol.Cartons <= count ? ol.Cartons : count;
                                    if (count == 0)
                                    {
                                        break;
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 计算净需求,和整个库位比较
                    foreach (string item in rawDemandDic.Keys)
                    {
                        var locQty = totalInvList.Where(h => (string)h[0] == flow.LocationFrom.Code && (string)h[1] == item).Sum(h => Convert.ToInt32(h[2]));

                        int requireQty = rawDemandDic[item] > locQty ? rawDemandDic[item] - locQty : 0;
                        if (rawDemandDic[item] > 0)
                        {
                            nonZeroRawDemandDic.Add(item, requireQty);
                        }
                    }
                    #endregion


                    #region 生成要货单

                    var q = from l in transferFlowList
                            where l.DefaultLocationTo.Code == flow.LocationFrom.Code &&
                            nonZeroRawDemandDic.Keys.ToArray <string>().Contains(l.Item.Code)
                            group l by new { l.Flow } into g
                        select new { g.Key };

                    foreach (var f in q)
                    {
                        try
                        {
                            OrderHead oh = orderMgr.TransferFlow2Order(f.Key.Flow);
                            oh.StartTime  = DateTime.Now;
                            oh.WindowTime = DateTime.Now.AddHours(Convert.ToDouble(f.Key.Flow.LeadTime));
                            oh.Priority   = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
                            IList <OrderDetail> nonZeroOrderDetailList = new List <OrderDetail>();
                            foreach (OrderDetail od in oh.OrderDetails)
                            {
                                if (nonZeroRawDemandDic.Count > 0)
                                {
                                    var qty = (from r in nonZeroRawDemandDic where r.Key == od.Item.Code select new { Value = r.Value }).SingleOrDefault();
                                    if (qty != null && Convert.ToDecimal(qty.Value) > 0)
                                    {
                                        OrderDetail newOrderDetail = od;
                                        newOrderDetail.OrderedQty  = Convert.ToDecimal(qty.Value) * od.UnitCount;
                                        newOrderDetail.RequiredQty = Convert.ToDecimal(qty.Value) * od.UnitCount;
                                        nonZeroOrderDetailList.Add(newOrderDetail);
                                        nonZeroRawDemandDic.Remove(od.Item.Code);
                                    }
                                }
                            }
                            if (nonZeroOrderDetailList.Count > 0)
                            {
                                oh.OrderDetails = nonZeroOrderDetailList;
                                orderMgr.CreateOrder(oh, userMgr.GetMonitorUser());
                            }
                        }
                        catch (Exception e)
                        {
                            log.Error("error create order", e);
                            continue;
                        }
                    }



                    #endregion

                    #region 更新路线
                    flow.NextOrderTime = DateTime.Now.AddHours(Convert.ToDouble(flow.Interval));
                    flowMgr.UpdateFlow(flow);

                    #endregion
                }
            }
        }
Exemplo n.º 8
0
        /*
         * 填充报表头
         *
         * Param repack 报验单头对象
         */
        private void FillHead(OrderHead orderHead)
        {
            //订单号:
            string orderCode = Utility.BarcodeHelper.GetBarcodeStr(orderHead.OrderNo, this.barCodeFontName);

            this.SetRowCell(2, 8, orderCode);
            //Order No.:
            this.SetRowCell(3, 8, orderHead.OrderNo);

            if ("Normal".Equals(orderHead.Priority))
            {
                this.SetRowCell(4, 5, "");
            }
            else
            {
                this.SetRowCell(3, 5, "");
            }

            //发出时间 Issue Time:
            this.SetRowCell(4, 9, orderHead.StartDate.ToString());

            //供应商代码 Supplier Code:
            this.SetRowCell(6, 3, orderHead.PartyFrom != null ? orderHead.PartyFrom.Code : String.Empty);

            //交货日期 Delivery Date:getDemandDeliverDate
            this.SetRowCell(6, 8, orderHead.WindowTime.ToLongDateString());


            //供应商名称 Supplier Name:
            this.SetRowCell(7, 3, orderHead.PartyFrom != null ? orderHead.PartyFrom.Name : String.Empty);
            //窗口时间 Window Time:
            this.SetRowCell(7, 8, orderHead.WindowTime.ToLongTimeString());

            //供应商地址 Address:
            this.SetRowCell(8, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.Address : String.Empty);
            //交货道口 Delivery Dock:
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
            {
                this.SetRowCell(8, 8, orderHead.Flow);
            }
            else
            {
                this.SetRowCell(8, 8, orderHead.DockDescription);
            }

            //供应商联系人 Contact:
            this.SetRowCell(9, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.ContactPersonName : String.Empty);
            //物流协调员 Follow Up:
            this.SetRowCell(9, 8, orderHead.ShipTo != null ? orderHead.ShipTo.ContactPersonName : String.Empty);

            //供应商电话 Telephone:
            this.SetRowCell(10, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.TelephoneNumber : String.Empty);
            //YFV电话 Telephone:
            this.SetRowCell(10, 8, orderHead.ShipTo != null ? orderHead.ShipTo.TelephoneNumber : String.Empty);

            //供应商传真 Fax:
            this.SetRowCell(11, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.Fax : String.Empty);
            //YFV传真 Fax:
            this.SetRowCell(11, 8, orderHead.ShipTo != null ? orderHead.ShipTo.Fax : String.Empty);

            //系统号 SysCode:
            //this.SetRowCell(++rowNum, 3, "");
            //版本号 Version:
            //this.SetRowCell(rowNum, 8, "");
        }
Exemplo n.º 9
0
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);


                if (orderHead == null ||
                    orderDetails == null || orderDetails.Count == 0)
                {
                    return(false);
                }


                //this.SetRowCellBarCode(0, 2, 8);
                this.barCodeFontName = this.GetBarcodeFontName(2, 8);
                this.CopyPage(orderDetails.Count);

                this.FillHead(orderHead);


                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                foreach (OrderDetail orderDetail in orderDetails)
                {
                    // No.
                    this.SetRowCell(pageIndex, rowIndex, 0, "" + orderDetail.Sequence);

                    //零件号 Item Code
                    this.SetRowCell(pageIndex, rowIndex, 1, orderDetail.Item.Code);

                    //参考号 Ref No.
                    this.SetRowCell(pageIndex, rowIndex, 2, orderDetail.ReferenceItemCode);

                    //描述Description
                    this.SetRowCell(pageIndex, rowIndex, 3, orderDetail.Item.Description);

                    //单位Unit
                    this.SetRowCell(pageIndex, rowIndex, 4, orderDetail.Item.Uom.Code);

                    //单包装UC
                    this.SetRowCell(pageIndex, rowIndex, 5, orderDetail.UnitCount.ToString("0.########"));

                    //需求 Request	包装
                    int UCs = (int)Math.Ceiling(orderDetail.OrderedQty / orderDetail.UnitCount);
                    this.SetRowCell(pageIndex, rowIndex, 6, UCs.ToString());

                    //需求 Request	零件数
                    this.SetRowCell(pageIndex, rowIndex, 7, orderDetail.OrderedQty.ToString("0.########"));

                    //发货数
                    this.SetRowCell(pageIndex, rowIndex, 8, orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value.ToString("0.########") : string.Empty);

                    //实收 Received	包装
                    this.SetRowCell(pageIndex, rowIndex, 9, "");

                    //实收 Received	零件数
                    this.SetRowCell(pageIndex, rowIndex, 10, orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value.ToString("0.########") : string.Empty);

                    //批号/备注
                    if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
                    {
                        IList <LocationLotDetail> locationLotDetailList = locationLotDetailMgr.GetHuLocationLotDetail(orderDetail.DefaultLocationFrom.Code, null, orderDetail.Item.Code, null, false);

                        decimal qty        = (from l in locationLotDetailList select l.Qty).Sum();
                        decimal shippedQty = orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value : 0;
                        if (qty < orderDetail.OrderedQty - shippedQty)
                        {
                            string memo = languageMgr.TranslateMessage("MasterData.PickList.NotEnoughInventory", orderHead.CreateUser.Code);
                            this.SetRowCell(pageIndex, rowIndex, 11, memo);
                        }
                    }
                    else
                    {
                        this.SetRowCell(pageIndex, rowIndex, 11, string.Empty);
                    }
                    if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行
                    {
                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 10
0
        public void RecordOrderShipQty(OrderLocationTransaction orderLocationTransaction, InProcessLocationDetail inProcessLocationDetail, bool checkExcceed)
        {
            //orderLocationTransaction = this.orderLocationTransactionMgr.LoadOrderLocationTransaction(orderLocationTransaction.Id);
            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_ALLOW_EXCEED_GI_GR);
            bool             allowExceedGiGR  = bool.Parse(entityPreference.Value); //企业属性,允许过量发货和收货

            OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
            OrderHead   orderHead   = orderDetail.OrderHead;
            decimal     shipQty     = inProcessLocationDetail.Qty * orderLocationTransaction.UnitQty;

            #region 是否过量发货判断
            //生产物料发货不检查过量选项
            if (orderLocationTransaction.OrderDetail.OrderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION &&
                orderLocationTransaction.OrderDetail.OrderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ)
            {
                //检查AccumulateQty(已发数)不能大于等于OrderedQty(订单数)
                //if (!(orderHead.AllowExceed && allowExceedGiGR))
                //{
                //    if ((orderLocationTransaction.OrderedQty > 0 && orderLocationTransaction.AccumulateQty.HasValue && orderLocationTransaction.AccumulateQty.Value >= orderLocationTransaction.OrderedQty && shipQty > 0)
                //            || (orderLocationTransaction.OrderedQty < 0 && orderLocationTransaction.AccumulateQty.HasValue && orderLocationTransaction.AccumulateQty.Value <= orderLocationTransaction.OrderedQty && shipQty < 0))
                //    {
                //        throw new BusinessErrorException("Order.Error.ShipExcceed", orderHead.OrderNo, orderLocationTransaction.Item.Code);
                //    }
                //}

                if (!(orderHead.AllowExceed && allowExceedGiGR) && checkExcceed)   //不允许过量发货
                {
                    //检查AccumulateQty(已发数) + shipQty(本次发货数)不能大于OrderedQty(订单数)
                    orderLocationTransaction.AccumulateQty = orderLocationTransaction.AccumulateQty.HasValue ? orderLocationTransaction.AccumulateQty.Value : 0;
                    if ((orderLocationTransaction.OrderedQty > 0 && (orderLocationTransaction.AccumulateQty + shipQty > orderLocationTransaction.OrderedQty)) ||
                        (orderLocationTransaction.OrderedQty < 0 && (orderLocationTransaction.AccumulateQty + shipQty < orderLocationTransaction.OrderedQty)))
                    {
                        throw new BusinessErrorException("Order.Error.ShipExcceed", orderHead.OrderNo, orderLocationTransaction.Item.Code);
                    }
                }
            }
            #endregion

            #region 记录发货量
            if (orderLocationTransaction.BackFlushMethod == null ||
                orderLocationTransaction.BackFlushMethod == BusinessConstants.CODE_MASTER_BACKFLUSH_METHOD_VALUE_GOODS_RECEIVE)
            {
                if (!orderLocationTransaction.AccumulateQty.HasValue)
                {
                    orderLocationTransaction.AccumulateQty = 0;
                }
                //记录LocationTransaction的累计发货量
                orderLocationTransaction.AccumulateQty += shipQty;
                this.orderLocationTransactionMgr.UpdateOrderLocationTransaction(orderLocationTransaction);

                //记录OrderDetail的累计发货量
                if (orderLocationTransaction.Item.Code == orderLocationTransaction.OrderDetail.Item.Code)
                {
                    //如果OrderLocationTransaction和OrderDetail上的Item一致,需要更新OrderDetail上的ShippedQty
                    if (!orderDetail.ShippedQty.HasValue)
                    {
                        orderDetail.ShippedQty = 0;
                    }

                    //OrderLocationTransaction和OrderDetail上的Item可能单位不一致,直接除以UnitQty就可以转换了
                    orderDetail.ShippedQty += (shipQty / orderLocationTransaction.UnitQty);
                    this.UpdateOrderDetail(orderDetail);
                }
            }
            #endregion
        }
Exemplo n.º 11
0
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                InProcessLocation inProcessLocation = (InProcessLocation)list[0];
                IList <InProcessLocationDetail> inProcessLocationDetailList = (IList <InProcessLocationDetail>)list[1];

                if (inProcessLocation == null ||
                    inProcessLocationDetailList == null || inProcessLocationDetailList.Count == 0)
                {
                    return(false);
                }

                //this.SetRowCellBarCode(0, 2, 5);
                List <Transformer> transformerList = Utility.TransformerHelper.ConvertInProcessLocationDetailsToTransformers(inProcessLocationDetailList);

                this.barCodeFontName = this.GetBarcodeFontName(2, 5);

                this.CopyPage(transformerList.Count);

                this.FillHead(inProcessLocation);

                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                //ASN号:
                //  List<Transformer> transformerList = Utility.TransformerHelper.ConvertInProcessLocationDetailsToTransformers(inProcessLocationDetailList);

                foreach (Transformer transformer in transformerList)
                {
                    OrderHead orderHead = orderHeadMgr.LoadOrderHead(transformer.OrderNo);

                    //订单号 (销售发运显示客户订单号,其它为订单号)
                    if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                    {
                        this.SetRowCell(pageIndex, rowIndex, 0, orderHead.ExternalOrderNo);
                    }
                    else
                    {
                        this.SetRowCell(pageIndex, rowIndex, 0, orderHead.OrderNo);
                    }

                    //序号.
                    this.SetRowCell(pageIndex, rowIndex, 1, transformer.Sequence.ToString());

                    //"零件号Item Code"
                    this.SetRowCell(pageIndex, rowIndex, 2, transformer.ItemCode);
                    //"参考号Ref No."
                    //this.SetRowCell(pageIndex, rowIndex, 3, orderDetail.ReferenceItemCode);

                    //"描述Description"
                    this.SetRowCell(pageIndex, rowIndex, 3, transformer.ItemDescription);
                    //"单位Unit"
                    this.SetRowCell(pageIndex, rowIndex, 4, transformer.UomCode);
                    //"单包装UC"
                    this.SetRowCell(pageIndex, rowIndex, 5, transformer.UnitCount.ToString("0.########"));
                    //发货 Delivery	包装
                    int UCs = (int)Math.Ceiling(transformer.Qty / transformer.UnitCount);
                    this.SetRowCell(pageIndex, rowIndex, 6, UCs.ToString());

                    //发货 Delivery	发货数
                    this.SetRowCell(pageIndex, rowIndex, 7, transformer.Qty.ToString("0.########"));

                    //实收 Received	包装
                    //this.SetRowCell(pageIndex, rowIndex, 8, "");
                    //实收 Received	零件数
                    //this.SetRowCell(pageIndex, rowIndex, 9, "");


                    if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行
                    {
                        //实际到货时间:
                        //this.SetRowCell(pageIndex, rowIndex, , "");

                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;

                if (inProcessLocation.IsPrinted == null || inProcessLocation.IsPrinted == false)
                {
                    inProcessLocation.IsPrinted = true;
                }
                inProcessLocation.PrintCount += 1;
                inProcessLocationMgr.UpdateInProcessLocation(inProcessLocation);
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 12
0
 public IList <OrderDetail> GetOrderDetail(OrderHead orderHead)
 {
     return(GetOrderDetail(orderHead.OrderNo));
 }
Exemplo n.º 13
0
        public void GenerateOrderDetailSubsidiary(OrderDetail orderDetail)
        {
            OrderHead orderHead = orderDetail.OrderHead;
            int       maxOp     = 0; //记录最大工序号,给成品收货时用
            int       minOp     = 0; //记录最小工序号,给返工成品用

            #region 把OrderDetail的收货单位和单位用量转换为BOM单位和单位用量
            //fgUom,fgUnityQty代表接收一个orderDetail.Uom单位(等于订单的收货单位)的FG,等于单位(fgUom)有多少(fgUnityQty)值
            Uom     fgUom      = orderDetail.Uom;
            decimal fgUnityQty = 1;     //运输物品和生产的成品UnitQty默认为1
            //如果和Bom上的单位不一致,转化为Bom上的单位,不然会导致物料回冲不正确。
            if (orderDetail.Bom != null && orderDetail.Uom.Code.ToUpper() != orderDetail.Bom.Uom.Code.ToUpper())
            {
                fgUom      = orderDetail.Bom.Uom;
                fgUnityQty = this.uomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Uom, fgUnityQty, fgUom);
            }
            #endregion

            #region 创建OrderLocTrans

            if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            {
                //程序一般不会运行到这里,套件的拆分都在前台进行
                //用户在下订单的时候已经拆分了套件
                //2010-1-19 dingxin
                throw new BusinessErrorException("Order.Error.CreateOrder.ItemTypeK", orderDetail.Item.Code);
            }
            else
            {
                if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT ||
                    orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS ||
                    orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING)
                {
                    #region 采购,只需要记录入库事务RCT-PO
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, null,
                                                                                      fgUnityQty, orderDetail.DefaultLocationFrom,
                                                                                      false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgr.GetRejectLocation());

                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_PO,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgr.GetRejectLocation());
                    #endregion
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                {
                    #region 销售,只需要记录出库事务ISS-SO
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_SO,
                                                                                      fgUnityQty, orderDetail.DefaultLocationFrom,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());

                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, null,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                    #endregion
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
                {
                    #region 移库,需要记录出库事务ISS-TR和入库事务RCT-TR
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                                                                                      fgUnityQty, orderDetail.DefaultLocationFrom,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());

                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                    #endregion
                }
                //else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_INSPECTION)
                //{
                //    #region 检验,需要记录出库事务ISS-TR和入库事务RCT-TR
                //    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                //                fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                //                fgUnityQty, orderDetail.DefaultLocationFrom,
                //                false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());

                //    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                //                fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR,
                //                fgUnityQty, orderDetail.DefaultLocationTo,
                //                false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                //    #endregion
                //}
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                {
                    #region 创建生产物料的OrderLocTrans
                    //如果是生产订单,必须要有Bom
                    FillBomForOrderDetail(orderDetail);

                    IList <BomDetail> bomDetailList = this.bomDetailMgr.GetFlatBomDetail(orderDetail.Bom.Code, orderHead.StartTime);
                    foreach (BomDetail bomDetail in bomDetailList)
                    {
                        #region 记录最大工序号
                        //最大工序号是从Bom上取还是从Routing上取?
                        if (maxOp < bomDetail.Operation)
                        {
                            //记录最大工序号
                            maxOp = bomDetail.Operation;
                        }
                        #endregion

                        #region 记录最小工序号
                        //最小工序号是从Bom上取还是从Routing上取?
                        if (minOp > bomDetail.Operation || minOp == 0)
                        {
                            //记录最大工序号
                            minOp = bomDetail.Operation;
                        }
                        #endregion

                        #region 查找物料的来源库位
                        //来源库位查找逻辑BomDetail-->RoutingDetail-->FlowDetail-->Flow
                        Location bomLocFrom = bomDetail.Location;

                        if (orderHead.Routing != null)
                        {
                            //在Routing上查找,并检验Routing上的工序和BOM上的是否匹配
                            RoutingDetail routingDetail = routingDetailMgr.LoadRoutingDetail(orderHead.Routing, bomDetail.Operation, bomDetail.Reference);
                            if (routingDetail != null)
                            {
                                if (bomLocFrom == null)
                                {
                                    bomLocFrom = routingDetail.Location;
                                }

                                //if (maxOp < routingDetail.Operation)
                                //{
                                //    //记录最大工序号
                                //    maxOp = routingDetail.Operation;
                                //}

                                orderHead.AddOrderOperation(this.orderOperationMgr.GenerateOrderOperation(orderHead, routingDetail));
                            }
                            //else
                            //{
                            //    //没有找到和BOM上相匹配的工序
                            //    throw new BusinessErrorException("Order.Error.OpNotMatch", bomDetail.Bom.Code, bomDetail.Item.Code, routing.Code, bomDetail.Operation.ToString(), bomDetail.Reference);
                            //}
                        }

                        if (bomLocFrom == null)
                        {
                            //取默认库位FlowDetail-->Flow
                            bomLocFrom = orderDetail.DefaultLocationFrom;
                        }
                        //string bomLocFromType = bomLocFrom != null ? bomLocFrom.Type : null;
                        #endregion

                        #region 查找物料的目的库位
                        //目的库位,如果是生产类型,直接置为Null,其它情况FlowDetail-->Flow
                        Location bomLocTo = (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) ?
                                            orderDetail.DefaultLocationTo : null;
                        //string bomLocToType = bomLocTo != null ? bomLocTo.Type : null;
                        #endregion

                        #region 生产物料,只需要记录出库事务ISS-TR
                        this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, bomDetail.Item, bomDetail,
                                                                                          bomDetail.Uom, bomDetail.Operation, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO,
                                                                                          bomDetail.CalculatedQty * fgUnityQty, //返工,原材料数量默认等于0
                                                                                          bomLocFrom, bomDetail.IsShipScanHu, bomDetail.HuLotSize, bomDetail.NeedPrint, bomDetail.BackFlushMethod, null, this.locationMgr.GetRejectLocation());
                        #endregion
                    }
                    #endregion

                    #region 生产成品,只需要记录入库事务RCT-WO
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgr.GetRejectLocation());

                    //返工,把自己添加到物料中
                    if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
                    {
                        //Location loc = orderDetail.DefaultLocationTo.ActingLocation != null ? orderDetail.DefaultLocationTo.ActingLocation : orderDetail.DefaultLocationTo;
                        Location loc = this.locationMgr.GetRejectLocation();


                        //todo 处理返工的成品是否需要扫描Hu,现在不扫描
                        //返工对成品的投料记RCT-WO事务
                        this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                          fgUom, minOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                                                                                          fgUnityQty, loc,
                                                                                          false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                    }
                    #endregion
                }
            }
            #endregion

            #region 生产,给没有Op的OrderLocTrans赋值maxOp
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
            {
                if (maxOp == 0)
                {
                    EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL);
                    int seqInterval = int.Parse(entityPreference.Value);
                    maxOp = seqInterval; //默认工序号
                }

                if (orderDetail.OrderLocationTransactions != null && orderDetail.OrderLocationTransactions.Count > 0)
                {
                    foreach (OrderLocationTransaction orderLocationTransaction in orderDetail.OrderLocationTransactions)
                    {
                        if (orderLocationTransaction.Operation == 0)
                        {
                            orderLocationTransaction.Operation = maxOp;
                        }
                    }
                }
            }
            #endregion
        }
Exemplo n.º 14
0
        public IList <OrderDetail> GenerateOrderDetail(OrderHead orderHead, FlowDetail flowDetail, bool isReferencedFlow)
        {
            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL);
            int seqInterval = int.Parse(entityPreference.Value);

            IList <OrderDetail> orderDetailList = new List <OrderDetail>();
            OrderDetail         orderDetail     = new OrderDetail();

            orderDetail.FlowDetail = flowDetail;
            orderDetail.OrderHead  = orderHead;
            if (!isReferencedFlow)
            {
                CloneHelper.CopyProperty(flowDetail, orderDetail, FlowDetail2OrderDetailCloneFields);
            }
            else
            {
                CloneHelper.CopyProperty(flowDetail, orderDetail, ReferenceOrderDetailCloneFields);
            }

            #region 查找价格
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                if (orderDetail.DefaultPriceListFrom != null)
                {
                    PriceListDetail priceListDetailFrom = priceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListFrom, orderDetail.Item, orderHead.StartTime, orderHead.Currency, orderDetail.Uom);
                    if (priceListDetailFrom != null)
                    {
                        orderDetail.PriceListDetailFrom = priceListDetailFrom;
                    }
                }
                if (orderDetail.DefaultPriceListTo != null)
                {
                    PriceListDetail priceListDetailTo = priceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListTo, orderDetail.Item, orderHead.StartTime, orderHead.Currency, orderDetail.Uom);
                    if (priceListDetailTo != null)
                    {
                        orderDetail.PriceListDetailTo = priceListDetailTo;
                    }
                }
            }
            #endregion

            #region 设置退货和次品库位
            //if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN
            //    || orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            //{
            //    if (flowDetail.LocationFrom != null && flowDetail.LocationFrom.ActingLocation != null)
            //    {
            //        orderDetail.LocationFrom = flowDetail.LocationFrom.ActingLocation;
            //    }

            //    if (flowDetail.LocationTo != null && flowDetail.LocationTo.ActingLocation != null)
            //    {
            //        orderDetail.LocationTo = flowDetail.LocationTo.ActingLocation;
            //    }
            //}
            if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            {
                orderDetail.LocationTo = this.locationMgr.GetRejectLocation();
            }
            #endregion

            //if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            //{
            //    #region 处理套件
            //    IList<ItemKit> itemKitList = this.itemKitMgr.GetChildItemKit(orderDetail.Item.Code);

            //    if (itemKitList != null && itemKitList.Count > 0)
            //    {
            //        int count = 0;
            //        decimal? convertRate = null;
            //        foreach (ItemKit itemKit in itemKitList)
            //        {
            //            count++;

            //            if (!convertRate.HasValue)
            //            {
            //                if (itemKit.ParentItem.Uom.Code != orderDetail.Uom.Code)
            //                {
            //                    convertRate = this.uomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Uom, 1, itemKit.ParentItem.Uom);
            //                }
            //                else
            //                {
            //                    convertRate = 1;
            //                }
            //            }

            //            OrderDetail orderDetailOfChildKit = new OrderDetail();
            //            CloneHelper.CopyProperty(orderDetail, orderDetailOfChildKit, OrderDetailOfChildKitCloneFields);
            //            orderDetailOfChildKit.Sequence = orderDetailOfChildKit.Sequence + count;
            //            orderDetailOfChildKit.Item = itemKit.ChildItem;
            //            orderDetailOfChildKit.ReferenceItemCode = this.itemReferenceMgr.GetItemReferenceByItem(itemKit.ChildItem.Code, orderDetail.OrderHead.PartyFrom.Code, orderDetail.OrderHead.PartyTo.Code);
            //            orderDetailOfChildKit.Uom = itemKit.ChildItem.Uom;
            //            orderDetailOfChildKit.UnitCount = itemKit.ChildItem.UnitCount;
            //            //orderDetailOfChildKit.RequiredQty = orderDetailOfChildKit.RequiredQty * itemKit.Qty * convertRate;
            //            //orderDetailOfChildKit.OrderedQty = orderDetailOfChildKit.OrderedQty * itemKit.Qty * convertRate;
            //            orderDetailOfChildKit.GoodsReceiptLotSize = orderDetailOfChildKit.GoodsReceiptLotSize * itemKit.Qty * convertRate;
            //            orderDetailOfChildKit.BatchSize = orderDetailOfChildKit.BatchSize * itemKit.Qty * convertRate;
            //            if (orderDetailOfChildKit.HuLotSize.HasValue)
            //            {
            //                orderDetailOfChildKit.HuLotSize = int.Parse((orderDetailOfChildKit.HuLotSize.Value * itemKit.Qty * convertRate.Value).ToString("#"));
            //            }

            //            #region 计算价格
            //            if (orderDetailOfChildKit.DefaultPriceListFrom != null)
            //            {
            //                PriceListDetail priceListDetailFrom = priceListDetailMgr.GetLastestPriceListDetail(orderDetailOfChildKit.DefaultPriceListFrom, orderDetailOfChildKit.Item, orderHead.StartTime, orderHead.Currency, orderDetailOfChildKit.Uom);
            //                if (priceListDetailFrom != null)
            //                {
            //                    orderDetailOfChildKit.PriceListDetailFrom = priceListDetailFrom;
            //                }
            //            }
            //            if (orderDetailOfChildKit.DefaultPriceListTo != null)
            //            {
            //                PriceListDetail priceListDetailTo = priceListDetailMgr.GetLastestPriceListDetail(orderDetailOfChildKit.DefaultPriceListTo, orderDetailOfChildKit.Item, orderHead.StartTime, orderHead.Currency, orderDetailOfChildKit.Uom);
            //                if (priceListDetailTo != null)
            //                {
            //                    orderDetailOfChildKit.PriceListDetailTo = priceListDetailTo;
            //                }
            //            }
            //            #endregion

            //            //重新设置Sequence
            //            int detailCount = orderHead.OrderDetails != null ? orderHead.OrderDetails.Count : 0;
            //            orderDetail.Sequence = (detailCount + 1) * seqInterval;

            //            orderHead.AddOrderDetail(orderDetailOfChildKit);
            //            orderDetailList.Add(orderDetailOfChildKit);
            //        }
            //    }
            //    else
            //    {
            //        throw new BusinessErrorException("ItemKit.Error.NotFoundForParentItem", orderDetail.Item.Code);
            //    }
            //    #endregion
            //}
            //else
            //{
            //重新设置Sequence
            int detailCount = orderHead.OrderDetails != null ? orderHead.OrderDetails.Count : 0;
            orderDetail.Sequence = (detailCount + 1) * seqInterval;

            #region 参考零件号
            if (orderDetail.ReferenceItemCode == null || orderDetail.ReferenceItemCode == string.Empty)
            {
                string firstPartyCode  = string.Empty;
                string secondPartyCode = string.Empty;
                if (orderHead.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_DISTRIBUTION)
                {
                    firstPartyCode = orderHead.PartyTo.Code;
                }
                else
                {
                    firstPartyCode = orderHead.PartyFrom.Code;
                }
                orderDetail.ReferenceItemCode = itemReferenceMgr.GetItemReferenceByItem(orderDetail.Item.Code, firstPartyCode, secondPartyCode);
            }
            #endregion

            #region 设置默认库位
            orderDetail.LocationFrom = orderDetail.LocationFrom == null ? orderHead.LocationFrom : orderDetail.LocationFrom;
            orderDetail.LocationTo   = orderDetail.LocationTo == null ? orderHead.LocationTo : orderDetail.LocationTo;
            #endregion

            orderHead.AddOrderDetail(orderDetail);
            orderDetailList.Add(orderDetail);
            //}

            return(orderDetailList);
        }
Exemplo n.º 15
0
    private void CreateOrder(OrderHead orderHead)
    {
        IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>();

        foreach (OrderDetail orderDetail in orderHead.OrderDetails)
        {
            if (orderDetail.OrderedQty != 0)
            {
                if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
                {
                    IList <Item>    newItemList = new List <Item>(); //填充套件子件
                    decimal?        convertRate = null;
                    IList <ItemKit> itemKitList = null;

                    var maxSequence = orderHead.OrderDetails.Max(o => o.Sequence);
                    itemKitList = this.TheItemKitMgr.GetChildItemKit(orderDetail.Item);
                    for (int i = 0; i < itemKitList.Count; i++)
                    {
                        Item item = itemKitList[i].ChildItem;
                        if (!convertRate.HasValue)
                        {
                            if (itemKitList[i].ParentItem.Uom.Code != orderDetail.Item.Uom.Code)
                            {
                                convertRate = this.TheUomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Item.Uom, 1, itemKitList[i].ParentItem.Uom);
                            }
                            else
                            {
                                convertRate = 1;
                            }
                        }
                        OrderDetail newOrderDetail = new OrderDetail();

                        newOrderDetail.OrderHead     = orderDetail.OrderHead;
                        newOrderDetail.Sequence      = maxSequence + (i + 1);
                        newOrderDetail.IsBlankDetail = false;
                        newOrderDetail.Item          = item;
                        newOrderDetail.Uom           = item.Uom;
                        newOrderDetail.UnitCount     = orderDetail.Item.UnitCount * itemKitList[i].Qty * convertRate.Value;
                        newOrderDetail.OrderedQty    = orderDetail.OrderedQty * itemKitList[i].Qty * convertRate.Value;
                        newOrderDetail.PackageType   = orderDetail.PackageType;

                        #region 价格字段

                        //if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                        //{
                        //    if (orderDetail.PriceListFrom != null && orderDetail.PriceListFrom.Code != string.Empty)
                        //    {
                        //        newOrderDetail.PriceListFrom = ThePurchasePriceListMgr.LoadPurchasePriceList(orderDetail.PriceListFrom.Code);

                        //        if (newOrderDetail.PriceListFrom != null)
                        //        {
                        //            newOrderDetail.PriceListDetailFrom = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListFrom, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                        //        }
                        //    }
                        //}
                        //else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                        //{
                        //    if (orderDetail.PriceListTo != null && orderDetail.PriceListTo.Code != string.Empty)
                        //    {
                        //        newOrderDetail.PriceListTo = TheSalesPriceListMgr.LoadSalesPriceList(orderDetail.PriceListTo.Code);
                        //    }
                        //    if (newOrderDetail.PriceListTo != null)
                        //    {
                        //        newOrderDetail.PriceListDetailTo = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListTo, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                        //    }
                        //}

                        #endregion
                        resultOrderDetailList.Add(newOrderDetail);
                    }
                }
                else
                {
                    resultOrderDetailList.Add(orderDetail);
                }
            }
        }
        orderHead.OrderDetails = resultOrderDetailList;
        TheOrderMgr.CreateOrder(orderHead, this.CurrentUser);
    }
Exemplo n.º 16
0
 public ActionResult EditHead(OrderHead model)
 {
     //string result = OrderDAL.UpdateOcHead(model);
     return(View("Index"));
 }
Exemplo n.º 17
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        try
        {
            HSSFWorkbook excel = new HSSFWorkbook(fileUpload.PostedFile.InputStream);
            Sheet        sheet = excel.GetSheetAt(0);
            IEnumerator  rows  = sheet.GetRowEnumerator();
            ImportHelper.JumpRows(rows, 10);
            //供货路线	窗口时间	物料号	订单数

            #region 列定义
            int colFlow       = 1; //供货路线
            int colWindowTime = 2; //窗口时间
            int colItem       = 3; // 物料号
            int colQty        = 4; //订单数
            #endregion
            int rowCount = 10;
            //IList<Exception> exceptionList = new List<Exception>();
            //Exception exceptio = new Exception();
            string            errorMessage  = string.Empty;
            IList <OrderHead> orderHeadList = new List <OrderHead>();
            while (rows.MoveNext())
            {
                rowCount++;
                HSSFRow row = (HSSFRow)rows.Current;
                if (!TheImportMgr.CheckValidDataRow(row, 1, 4))
                {
                    break;//边界
                }
                string    flowCode    = string.Empty;
                DateTime  windowTime  = DateTime.Now;
                string    itemCode    = string.Empty;
                decimal   qty         = 0;
                OrderHead orderHead   = new OrderHead();
                Flow      currentFlow = new Flow();

                #region 读取数据
                #region 供货路线
                flowCode = row.GetCell(colFlow) != null?row.GetCell(colFlow).StringCellValue : string.Empty;

                if (string.IsNullOrEmpty(flowCode))
                {
                    //ShowErrorMessage(string.Format("第{0}行:供货路线不能为空。", rowCount));
                    errorMessage += string.Format("第{0}行:供货路线不能为空。<br/>", rowCount);
                    continue;
                }
                else
                {
                    currentFlow = TheFlowMgr.LoadFlow(flowCode, this.CurrentUser.Code, true);
                }
                #endregion

                #region 读取窗口时间
                try
                {
                    string readwindowTime = row.GetCell(colWindowTime).StringCellValue;
                    if (DateTime.TryParse(readwindowTime, out windowTime))
                    {
                        orderHead.WindowTime = windowTime;
                    }
                    else
                    {
                        errorMessage += string.Format("第{0}行:窗口时间填写有误。<br/>", rowCount);
                        continue;
                    }
                }
                catch
                {
                    errorMessage += string.Format("第{0}行:窗口时间填写有误。<br/>", rowCount);
                    //ShowErrorMessage(string.Format("第{0}行:窗口时间填写有误。", rowCount));
                    continue;
                }
                #endregion

                #region 读取物料代码
                itemCode = row.GetCell(colItem) != null?row.GetCell(colItem).StringCellValue : string.Empty;

                if (itemCode == null || itemCode.Trim() == string.Empty)
                {
                    errorMessage += string.Format("第{0}行:物料代码不能为空。<br/>", rowCount);
                    //ShowErrorMessage(string.Format("第{0}行:物料代码不能为空。", rowCount));
                    continue;
                }
                else
                {
                    currentFlow.FlowDetails = currentFlow.FlowDetails.Where(f => f.Item.Code == itemCode).ToList();
                    if (currentFlow.FlowDetails.Count == 0)
                    {
                        errorMessage += string.Format("第{0}行:物料代码{1}在路线{2}中不存在。<br/>", rowCount, itemCode, flowCode);
                        continue;
                    }
                }

                #endregion

                #region 读取数量
                try
                {
                    qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue);
                }
                catch
                {
                    //ShowErrorMessage(string.Format("第{0}行:订单数量填写有误。<br/>", rowCount));
                    errorMessage += string.Format("第{0}行:订单数量填写有误。<br/>", rowCount);
                    continue;
                }
                #endregion
                #endregion

                #region 填充数据
                orderHead            = TheOrderMgr.TransferFlow2Order(currentFlow);
                orderHead.SubType    = "Nml";
                orderHead.WindowTime = windowTime;
                orderHead.Priority   = "Normal";
                //orderHead.Type = "Procurement";
                orderHead.StartTime     = System.DateTime.Now;
                orderHead.IsAutoRelease = true;
                foreach (OrderDetail det in orderHead.OrderDetails)
                {
                    det.RequiredQty = qty;
                    det.OrderedQty  = qty;
                }
                orderHeadList.Add(orderHead);
                #endregion
            }
            if (!string.IsNullOrEmpty(errorMessage))
            {
                throw new Exception(errorMessage);
            }
            if (orderHeadList.Count == 0)
            {
                throw new Exception("导入的有效数据为0.");
            }
            var groups = (from tak in orderHeadList
                          group tak by new
            {
                tak.WindowTime,
                tak.Flow,
            }
                          into result
                          select new
            {
                WindowTime = result.Key.WindowTime,
                Flow = result.Key.Flow,
                list = result.ToList()
            }
                          ).ToList();
            string orderNos = "导入成功,生成单号:";
            foreach (var order in groups)
            {
                OrderHead           newOrderHead = order.list.First();
                IList <OrderDetail> detList      = new List <OrderDetail>();
                //OrderHead newOrderHead = new OrderHead();
                foreach (var d in order.list)
                {
                    OrderDetail det = d.OrderDetails.First();
                    det.OrderHead = newOrderHead;
                    detList.Add(det);
                }
                newOrderHead.OrderDetails = detList;
                CreateOrder(newOrderHead);
                orderNos += newOrderHead.OrderNo + ",";
            }
            ShowSuccessMessage(orderNos);
        }
        catch (BusinessErrorException ex)
        {
            ShowErrorMessage(ex);
        }
        catch (Exception ex)
        {
            ShowErrorMessage(ex.Message);
            return;
        }
    }
Exemplo n.º 18
0
        public ActionResult AddHead(OrderHead model)
        {
            string result = OrderDAL.UpdateOcHead(model);

            return(Json(result));
        }
Exemplo n.º 19
0
 public void InitPageParameter(OrderHead order)
 {
     this.ucOrderDetailList.InitPageParameter(order);
 }
Exemplo n.º 20
0
        /// <summary>
        /// 校验订单配置选项,是否允许同时发货
        /// </summary>
        /// <param name="orderNo"></param>
        /// <param name="originalOrderNo"></param>
        private void CheckOrderConfigValid(string orderNo, string originalOrderNo)
        {
            OrderHead originalOrderHead = orderHeadMgr.CheckAndLoadOrderHead(originalOrderNo);
            OrderHead orderHead         = orderHeadMgr.CheckAndLoadOrderHead(orderNo);
            Flow      flow         = this.flowMgr.LoadFlow(orderHead.Flow);
            Flow      originalFlow = this.flowMgr.LoadFlow(originalOrderHead.Flow);

            #region 合并发货校验
            if (flow.Code != originalFlow.Code || flow.Type != originalFlow.Type)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.OrderTypeNotEqual");
            }

            if (orderHead.PartyFrom.Code != originalOrderHead.PartyFrom.Code)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.PartyFromNotEqual");
            }

            if (orderHead.PartyTo.Code != originalOrderHead.PartyTo.Code)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.PartyToNotEqual");
            }

            string shipFromCode         = orderHead.ShipFrom != null ? orderHead.ShipFrom.Code : string.Empty;
            string originalShipFromCode = originalOrderHead.ShipFrom != null ? originalOrderHead.ShipFrom.Code : string.Empty;
            if (shipFromCode != originalShipFromCode)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.ShipFromNotEqual");
            }

            string shipToCode         = orderHead.ShipTo != null ? orderHead.ShipTo.Code : string.Empty;
            string originalShipToCode = originalOrderHead.ShipTo != null ? originalOrderHead.ShipTo.Code : string.Empty;
            if (shipToCode != originalShipToCode)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.ShipToNotEqual");
            }

            string routingCode         = orderHead.Routing != null ? orderHead.Routing.Code : string.Empty;
            string originalRoutingCode = originalOrderHead.Routing != null ? originalOrderHead.Routing.Code : string.Empty;
            if (routingCode != originalRoutingCode)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.RoutingNotEqual");
            }

            if (orderHead.IsShipScanHu != originalOrderHead.IsShipScanHu)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.IsShipScanHuNotEqual");
            }

            if (orderHead.IsReceiptScanHu != originalOrderHead.IsReceiptScanHu)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.IsReceiptScanHuNotEqual");
            }

            if (orderHead.IsAutoReceive != originalOrderHead.IsAutoReceive)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.IsAutoReceiveNotEqual");
            }

            if (orderHead.GoodsReceiptGapTo != originalOrderHead.GoodsReceiptGapTo)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.GoodsReceiptGapToNotEqual");
            }
            if (orderHead.AntiResolveHu != originalOrderHead.AntiResolveHu)
            {
                throw new BusinessErrorException("Order.Error.ShipOrder.AntiResolveHuNotEqual");
            }
            #endregion
        }
Exemplo n.º 21
0
    private void UpdateView()
    {
        if (this.OrderNo != null)
        {
            OrderHead orderHead   = TheOrderHeadMgr.LoadOrderHead(this.OrderNo);
            string    orderStatus = orderHead.Status;

            #region 只有Create状态,控件可以输入
            TextBox tbWinTime   = (TextBox)this.FV_Order.FindControl("tbWinTime");
            TextBox tbStartTime = (TextBox)this.FV_Order.FindControl("tbStartTime");
            if (orderStatus != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
            {
                TextBox tbExtOrderNo = (TextBox)this.FV_Order.FindControl("tbExtOrderNo");
                TextBox tbRefOrderNo = (TextBox)this.FV_Order.FindControl("tbRefOrderNo");
                TextBox tbMemo       = (TextBox)this.FV_Order.FindControl("tbMemo");


                if (tbExtOrderNo != null)
                {
                    tbExtOrderNo.Attributes.Add("onfocus", "this.blur();");
                }
                if (tbRefOrderNo != null)
                {
                    tbRefOrderNo.Attributes.Add("onfocus", "this.blur();");
                }
                if (tbMemo != null)
                {
                    tbMemo.Attributes.Add("onfocus", "this.blur();");
                }
                if (tbWinTime != null)
                {
                    tbWinTime.Attributes.Add("onfocus", "this.blur();");
                }
                if (tbStartTime != null)
                {
                    tbStartTime.Attributes.Add("onfocus", "this.blur();");
                }
            }
            else
            {
                string userLanguage = this.CurrentUser.UserLanguage;
                tbWinTime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',lang:'" + this.CurrentUser.UserLanguage + "'})");
                tbStartTime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',lang:'" + this.CurrentUser.UserLanguage + "'})");
            }

            #endregion

            #region 根据订单状态显示按钮
            if (orderStatus == BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
            {
                this.btnEdit.Visible     = true;
                this.btnSubmit.Visible   = true;
                this.btnCancel.Visible   = false;
                this.btnStart.Visible    = false;
                this.btnShip.Visible     = false;
                this.btnComplete.Visible = false;
                this.btnDelete.Visible   = true;
            }
            else if (orderStatus == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT)
            {
                this.btnEdit.Visible     = false;
                this.btnSubmit.Visible   = false;
                this.btnCancel.Visible   = true;
                this.btnStart.Visible    = true;
                this.btnShip.Visible     = false;
                this.btnComplete.Visible = false;
                this.btnDelete.Visible   = false;
            }
            else if (orderStatus == BusinessConstants.CODE_MASTER_STATUS_VALUE_CANCEL)
            {
                this.btnEdit.Visible     = false;
                this.btnSubmit.Visible   = false;
                this.btnCancel.Visible   = false;
                this.btnStart.Visible    = false;
                this.btnShip.Visible     = false;
                this.btnComplete.Visible = false;
                this.btnDelete.Visible   = false;
            }
            else if (orderStatus == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
            {
                this.btnEdit.Visible     = false;
                this.btnSubmit.Visible   = false;
                this.btnCancel.Visible   = false;
                this.btnStart.Visible    = false;
                this.btnShip.Visible     = true;
                this.btnComplete.Visible = true;
                this.btnDelete.Visible   = false;
            }

            else if (orderStatus == BusinessConstants.CODE_MASTER_STATUS_VALUE_COMPLETE)
            {
                this.btnEdit.Visible     = false;
                this.btnSubmit.Visible   = false;
                this.btnCancel.Visible   = false;
                this.btnStart.Visible    = false;
                this.btnShip.Visible     = false;
                this.btnComplete.Visible = false;
                this.btnDelete.Visible   = false;
            }
            else if (orderStatus == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
            {
                this.btnEdit.Visible     = false;
                this.btnSubmit.Visible   = false;
                this.btnCancel.Visible   = false;
                this.btnStart.Visible    = false;
                this.btnShip.Visible     = false;
                this.btnComplete.Visible = false;
                this.btnDelete.Visible   = false;
            }

            //如果可以通过订单发货而且发货不扫描Hu
            if (orderHead.IsShipByOrder && !orderHead.IsShipScanHu)
            {
                this.btnShip.Visible = true;
            }
            else
            {
                this.btnShip.Visible = false;
            }
            #endregion


            this.ucDetail.InitPageParameter(this.OrderNo);
        }
    }
Exemplo n.º 22
0
        protected override void SetBaseInfo(Resolver resolver)
        {
            if (resolver.CodePrefix == BusinessConstants.CODE_PREFIX_ORDER)
            {
                bool isHasOrderNo = false;
                if (resolver.Transformers != null)
                {
                    foreach (Transformer transformer in resolver.Transformers)
                    {
                        if (transformer.OrderNo == resolver.Code)
                        {
                            isHasOrderNo = true;
                            break;
                        }
                    }
                }
                if (!isHasOrderNo)
                {
                    #region 校验
                    OrderHead orderHead = orderHeadMgr.LoadOrderHead(resolver.Input);
                    if (!partyMgr.CheckPartyPermission(resolver.UserCode, orderHead.PartyFrom.Code))
                    {
                        throw new BusinessErrorException("Common.Error.NoRegionPermission", orderHead.PartyFrom.Code);
                    }

                    if (!orderHead.IsShipByOrder && resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_SHIPORDER)
                    {
                        throw new BusinessErrorException("Order.Error.NotShipByOrder", orderHead.OrderNo);
                    }

                    if (orderHead.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
                    {
                        throw new BusinessErrorException("Common.Business.Error.StatusError", orderHead.OrderNo, orderHead.Status);
                    }

                    if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT &&
                        orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION &&
                        orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
                    {
                        throw new BusinessErrorException("Order.Error.OrderShipIsNotProduction", orderHead.OrderNo, orderHead.Type);
                    }
                    #endregion

                    setBaseMgr.FillResolverByOrder(resolver);
                }
            }
            else if (resolver.CodePrefix == BusinessConstants.CODE_PREFIX_PICKLIST)
            {
                resolver.Transformers = null;

                PickList pickList = pickListMgr.LoadPickList(resolver.Input);
                if (!partyMgr.CheckPartyPermission(resolver.UserCode, pickList.PartyFrom.Code))
                {
                    throw new BusinessErrorException("Common.Error.NoRegionPermission", pickList.PartyFrom.Code);
                }

                if (pickList.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
                {
                    throw new BusinessErrorException("Common.Business.Error.StatusError", pickList.PickListNo, pickList.Status);
                }

                setBaseMgr.FillResolverByPickList(resolver);
            }
            else
            {
                throw new BusinessErrorException("Common.Business.Error.BarCodeInvalid");
            }
        }
Exemplo n.º 23
0
    private RequisitionOrder fillOrderHead(OrderHead orderHead)
    {
        RequisitionOrder order = new RequisitionOrder();

        com.Sconit.Entity.Svp.User createUser = new com.Sconit.Entity.Svp.User();
        createUser.name = orderHead.CreateUser.Name;

        com.Sconit.Entity.Svp.User planner = new com.Sconit.Entity.Svp.User();
        planner.name = orderHead.CreateUser.Name;

        com.Sconit.Entity.Svp.Party partyFrom = new com.Sconit.Entity.Svp.Party();
        partyFrom.id          = orderHead.PartyFrom.Code;
        partyFrom.code        = orderHead.PartyFrom.Code;
        partyFrom.description = orderHead.PartyFrom.Name;

        if (orderHead.ShipFrom != null)
        {
            partyFrom.address     = orderHead.ShipFrom.Address;
            partyFrom.contact     = orderHead.ShipFrom.ContactPersonName;
            partyFrom.telephone   = orderHead.ShipFrom.TelephoneNumber;
            partyFrom.mobilephone = orderHead.ShipFrom.MobilePhone;
            partyFrom.fax         = orderHead.ShipFrom.Fax;
            partyFrom.postCode    = orderHead.ShipFrom.PostalCode;
        }

        com.Sconit.Entity.Svp.Party partyTo = new com.Sconit.Entity.Svp.Party();
        partyTo.id          = orderHead.PartyTo.Code;
        partyTo.code        = orderHead.PartyTo.Code;
        partyTo.description = orderHead.PartyTo.Name;

        if (orderHead.ShipTo != null)
        {
            partyTo.address     = orderHead.ShipTo.Address;
            partyTo.contact     = orderHead.ShipTo.ContactPersonName;
            partyTo.telephone   = orderHead.ShipTo.TelephoneNumber;
            partyTo.mobilephone = orderHead.ShipTo.MobilePhone;
            partyTo.fax         = orderHead.ShipTo.Fax;
            partyTo.postCode    = orderHead.ShipTo.PostalCode;
        }

        order.id = orderHead.OrderNo;
        order.requisitionOrderNo = orderHead.OrderNo;
        order.type                       = orderHead.Type;
        order.orderType                  = orderHead.SubType;
        order.priority                   = orderHead.Priority;
        order.createUser                 = createUser;
        order.createDate                 = orderHead.CreateDate;
        order.createDateSpecified        = true;
        order.effectiveDate              = orderHead.StartTime;
        order.effectiveDateSpecified     = true;
        order.demandDeliverDate          = orderHead.WindowTime;
        order.demandDeliverDateSpecified = true;

        string t = (orderHead.DockDescription == null || orderHead.DockDescription == string.Empty) ?
                   orderHead.PartyTo.Code : orderHead.PartyTo.Code + "@" + orderHead.DockDescription;

        order.demandDeliverAddr = orderHead.PartyTo.Name + " " + t + " "
                                  + (orderHead.DockDescription != null ? orderHead.DockDescription : string.Empty);

        order.partyFrom = partyFrom;
        order.partyTo   = partyTo;
        if (orderHead.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
        {
            order.status = "In_Process";
        }
        else
        {
            order.status = orderHead.Status;
        }
        order.planner = planner;

        order.print          = orderHead.IsPrinted;
        order.printSpecified = true;

        return(order);
    }
Exemplo n.º 24
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.tbFlow.Text == string.Empty)
            {
                ShowErrorMessage("MRP.Schedule.Import.CustomerSchedule.Result.SelectFlow");
                return;
            }
            Flow flow = TheFlowMgr.CheckAndLoadFlow(this.tbFlow.Text);

            OrderHead orderHead = this.TheOrderMgr.TransferFlow2Order(flow);

            foreach (GridViewRow row in this.GV_Order.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    string  item   = row.Cells[1].Text;
                    string  uom    = row.Cells[4].Text;
                    string  qtyStr = ((TextBox)row.Cells[7].FindControl("tbQty")).Text;
                    decimal?qty    = null;
                    try
                    {
                        qty = decimal.Parse(qtyStr);
                    }
                    catch (Exception)
                    {
                        this.ShowErrorMessage("MasterData.MiscOrder.WarningMessage.InputQtyFormat.Error");
                        return;
                    }

                    if (qty.HasValue && qty > 0)
                    {
                        OrderDetail orderDetail = (from det in orderHead.OrderDetails
                                                   where det.Item.Code == item
                                                   select det).FirstOrDefault();

                        if (orderDetail != null)
                        {
                            orderDetail.OrderedQty = qty.Value;

                            if (orderDetail.Uom.Code != uom)
                            {
                                orderDetail.OrderedQty = this.TheUomConversionMgr.ConvertUomQty(item, uom, orderDetail.OrderedQty, orderDetail.Uom.Code);
                            }
                        }
                    }
                }
            }

            IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>();

            if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0)
            {
                foreach (OrderDetail orderDetail in orderHead.OrderDetails)
                {
                    if (orderDetail.OrderedQty != 0)
                    {
                        if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
                        {
                            IList <Item>    newItemList = new List <Item>(); //填充套件子件
                            decimal?        convertRate = null;
                            IList <ItemKit> itemKitList = null;

                            var maxSequence = orderHead.OrderDetails.Max(o => o.Sequence);
                            itemKitList = this.TheItemKitMgr.GetChildItemKit(orderDetail.Item);
                            for (int i = 0; i < itemKitList.Count; i++)
                            {
                                Item item = itemKitList[i].ChildItem;
                                if (!convertRate.HasValue)
                                {
                                    if (itemKitList[i].ParentItem.Uom.Code != orderDetail.Item.Uom.Code)
                                    {
                                        convertRate = this.TheUomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Item.Uom, 1, itemKitList[i].ParentItem.Uom);
                                    }
                                    else
                                    {
                                        convertRate = 1;
                                    }
                                }
                                OrderDetail newOrderDetail = new OrderDetail();

                                newOrderDetail.OrderHead     = orderDetail.OrderHead;
                                newOrderDetail.Sequence      = maxSequence + (i + 1);
                                newOrderDetail.IsBlankDetail = false;
                                newOrderDetail.Item          = item;

                                newOrderDetail.Uom         = item.Uom;
                                newOrderDetail.UnitCount   = orderDetail.Item.UnitCount * itemKitList[i].Qty * convertRate.Value;
                                newOrderDetail.OrderedQty  = orderDetail.OrderedQty * itemKitList[i].Qty * convertRate.Value;
                                newOrderDetail.PackageType = orderDetail.PackageType;

                                #region 价格字段
                                if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                                {
                                    if (orderDetail.PriceListFrom != null && orderDetail.PriceListFrom.Code != string.Empty)
                                    {
                                        //newOrderDetail.PriceListFrom = ThePurchasePriceListMgr.l
                                        //if (newOrderDetail.PriceList != null)
                                        //{
                                        //    PriceListDetail priceListDetail = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceList, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                                        //    newOrderDetail.IsProvisionalEstimate = priceListDetail == null ? true : priceListDetail.IsProvisionalEstimate;
                                        //    if (priceListDetail != null)
                                        //    {
                                        //        newOrderDetail.UnitPrice = priceListDetail.UnitPrice;
                                        //        newOrderDetail.TaxCode = priceListDetail.TaxCode;
                                        //        newOrderDetail.IsIncludeTax = priceListDetail.IsIncludeTax;
                                        //    }
                                        //}
                                    }
                                }
                                #endregion
                                resultOrderDetailList.Add(newOrderDetail);
                            }
                        }
                        else
                        {
                            resultOrderDetailList.Add(orderDetail);
                        }
                    }
                }
            }
            if (resultOrderDetailList.Count == 0)
            {
                this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required");
                return;
            }
            else
            {
                DateTime winTime   = this.tbWinTime.Text.Trim() == string.Empty ? DateTime.Now : DateTime.Parse(this.tbWinTime.Text);
                DateTime startTime = winTime;
                if (this.tbSettleTime.Text.Trim() != string.Empty)
                {
                    //orderHead.SettleTime = DateTime.Parse(this.tbSettleTime.Text);
                }

                if (this.tbStartTime.Text != string.Empty)
                {
                    startTime = DateTime.Parse(this.tbStartTime.Text.Trim());
                }
                else
                {
                    double leadTime = this.hfLeadTime.Value == string.Empty ? 0 : double.Parse(this.hfLeadTime.Value);
                    double emTime   = this.hfEmTime.Value == string.Empty ? 0 : double.Parse(this.hfEmTime.Value);
                    double lTime    = this.cbIsUrgent.Checked ? emTime : leadTime;
                    startTime = winTime.AddHours(0 - lTime);
                }

                if (orderHead.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
                {
                    if (this.ucShift.ShiftCode == string.Empty)
                    {
                        ShowErrorMessage("MasterData.Order.Shift.Empty");
                        return;
                    }
                    orderHead.Shift = TheShiftMgr.LoadShift(this.ucShift.ShiftCode);
                }

                orderHead.OrderDetails  = resultOrderDetailList;
                orderHead.WindowTime    = winTime;
                orderHead.StartTime     = startTime;
                orderHead.IsAutoRelease = this.cbReleaseOrder.Checked;

                if (this.cbIsUrgent.Checked)
                {
                    orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT;
                }
                else
                {
                    orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
                }
                if (this.tbRefOrderNo.Text.Trim() != string.Empty)
                {
                    orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim();
                }
                if (this.tbExtOrderNo.Text.Trim() != string.Empty)
                {
                    orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim();
                }
            }


            TheOrderMgr.CreateOrder(orderHead, this.CurrentUser);
            if (this.cbPrintOrder.Checked && false)//不要打印
            {
                IList <OrderDetail> orderDetails = orderHead.OrderDetails;
                IList <object>      list         = new List <object>();
                list.Add(orderHead);
                list.Add(orderDetails);

                IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo);
                list.Add(orderLocationTransactions);
                string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list);
                Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>");
            }
            this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo);

            //跳转到相应的订单查询一面
            string url = null;
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
            {
                url = "Main.aspx?mid=Order.OrderHead.Production__mp--ModuleType-Production_ModuleSubType-Nml_StatusGroupId-4__act--ListAction";
            }
            else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT ||
                     orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING ||
                     orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS)
            {
                url = "Main.aspx?mid=Order.OrderHead.Procurement__mp--ModuleType-Procurement_ModuleSubType-Nml_StatusGroupId-4__act--ListAction";
            }
            else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION ||
                     orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
            {
                url = "Main.aspx?mid=Order.OrderHead.Distribution__mp--ModuleType-Distribution_ModuleSubType-Nml_StatusGroupId-4__act--ListAction";
            }
            else
            {
                return;
            }

            Page.ClientScript.RegisterStartupScript(GetType(), "method",
                                                    " <script language='javascript' type='text/javascript'>timedMsg('" + url + "'); </script>");
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
        catch (Exception)
        {
        }
    }
Exemplo n.º 25
0
        public override bool FillValues(String templateFileName, IList <object> list)
        {
            try
            {
                this.init(templateFileName, ROW_COUNT);
                if (list == null || list.Count < 3)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);
                IList <OrderLocationTransaction> orderLocationTransactions = (IList <OrderLocationTransaction>)(list[2]);

                int pageIndex = 1;
                int pageCount = this.getPageCount(FIRST_PAGE_DETAIL_ROW_COUNT, NO_FIRST_PAGE_DETAIL_ROW_COUNT, orderLocationTransactions.Count);


                this.SetRowCellBarCode(1, 1, 6);
                //加页删页
                this.CopyPage(pageCount, 12);

                #region 物料信息  Material Information
                //物料信息  Material Information
                if (orderLocationTransactions == null || orderLocationTransactions.Count == 0)
                {
                    //填充第一页;
                    this.FillHead(pageIndex, orderHead, orderDetails);
                    this.FillFooter(pageIndex, orderHead);
                }
                else
                {
                    int i = 1;
                    foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactions)
                    {
                        if (orderLocationTransaction.IOType.Equals(BusinessConstants.IO_TYPE_OUT))
                        {
                            if (pageIndex == 1 && i == 1) //第一页,明细部分 第一行,不换页
                            {
                                this.FillHead(pageIndex, orderHead, orderDetails);
                                this.FillFooter(pageIndex, orderHead);
                            }

                            if ((pageIndex == 1 && i == 17) || //第一页,明细部分  16行换页
                                (pageIndex > 1 && ((i - 1 - 16) % 40) == 0))       //非第一页,明细部分 40行换页
                            {
                                pageIndex++;
                                this.FillHead(pageIndex, orderHead, orderDetails);
                                this.FillFooter(pageIndex, orderHead);
                            }

                            //零件号QAD Code
                            this.SetRowCell(pageIndex, 15 + i - 1, 1, orderLocationTransaction.Item.Code);
                            //零件名Description
                            this.SetRowCell(pageIndex, 15 + i - 1, 2, orderLocationTransaction.Item.Description);
                            // 单位Unit
                            this.SetRowCell(pageIndex, 15 + i - 1, 4, orderLocationTransaction.Uom.Code);

                            //"标准耗量Plan Qty.
                            this.SetRowCell(pageIndex, 15 + i - 1, 5, orderLocationTransaction.UnitQty.ToString("0.########"));

                            //"需求量Dmd Qty"
                            this.SetRowCell(pageIndex, 15 + i - 1, 6, orderLocationTransaction.OrderedQty.ToString("0.########"));


                            //领用数Request Qty.

                            //返回数Return Qty.

                            //废品数Scrap Qty.

                            //待处理Waiting Qty.

                            //备注Comment

                            i++;
                        }
                    }
                }
                #endregion

                //人员信息  People Information
                //空

                //生产记录  Production Information
                //空

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 26
0
        public object PlaceAnOrder(JToken jt)
        {
            var  model   = JsonConvert.DeserializeObject <PlaceAnOrder>(jt.ToString());
            bool AddDish = true;

            using (var db = new OrderDB())
            {
                db.BeginTransaction();
                try
                {
                    var shopId = (from p in db.Shops where p.ACCOUNT == model.Account select p).FirstOrDefault();
                    if (string.IsNullOrEmpty(model.OrderId))
                    {
                        AddDish = false;
                        var head = new OrderHead()
                        {
                            ID = Guid.NewGuid().ToString("N").ToUpper(),
                            DatetimeCreated = DateTime.Now,
                            UserCreated     = "custom",
                            ShopId          = shopId?.ID,
                            PersonNum       = model.PersonNum,
                            STATE           = 'A',
                            DescNum         = model.DescNum,
                            IsClose         = 'N',
                            IsPrint         = Convert.ToChar(model.IsPrint),
                            MEMO            = model.MEMO,
                            TEL             = model.TEL,
                            CustomName      = model.CUSTOM_NAME
                        };
                        db.Insert(head);
                        model.OrderId = head.ID;
                    }

                    var orderDetail = new OrderDetail()
                    {
                        ID = Guid.NewGuid().ToString("N").ToUpper(),
                        DatetimeCreated = DateTime.Now,
                        UserCreated     = "custom",
                        STATE           = 'A',
                        UserOrder       = model.User,
                        PrrentOrderId   = model.OrderId
                    };
                    db.Insert(orderDetail);

                    foreach (var item in model.Foods)
                    {
                        var detailName = (from p in db.FoodDetails where p.ID == item.DETAIL_ID select p).FirstOrDefault();

                        if (string.IsNullOrEmpty(item.DETAIL_ID))
                        {
                            throw new Exception("存在商品明细无ID");
                        }
                        var food = (from p in db.Foods where p.ID == detailName.FoodId && p.STATE == 'A' select p).FirstOrDefault();
                        if (food is null)
                        {
                            throw new Exception("当前商品不存在");
                        }
                        if (food.INVENTORY == 0)
                        {
                            throw new Exception($"商品{food.NAME}库存不足!");
                        }
                        var urls = (from p in db.Images where p.ConnectId == food.ID && p.STATE == 'A'
                                    select p).ToList();
                        var foodDetail = new OrderDetailFood()
                        {
                            ID = Guid.NewGuid().ToString("N").ToUpper(),
                            DatetimeCreated = DateTime.Now,
                            UserCreated     = "custom",
                            STATE           = 'A',
                            UserOrder       = model.User,
                            OrderDetailId   = orderDetail.ID,
                            FoodDetailName  = string.IsNullOrEmpty(detailName.NAME) ? food.NAME : food.NAME + "(" + detailName.NAME + ")",
                            QTY             = item.NUM,
                            Price           = detailName.PRICE ?? 0,
                            URL             = string.Join(";", urls.Select(x => x.URL))
                        };
                        db.Insert(foodDetail);

                        if (food.INVENTORY > 0)
                        {
                            food.INVENTORY -= 1;
                        }
                        db.Update(food);
                    }
                    db.CommitTransaction();
                    var msg = "";
                    if (!string.IsNullOrEmpty(shopId.PrinterCode) && model.IsPrint == "Y")
                    {
                        msg = PrinterDomain.Current.print(model, AddDish);
                    }
                    return(new
                    {
                        OrderId = model.OrderId,
                        PrintMsg = msg
                    });
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                    db.RollbackTransaction();
                }
            }
        }
Exemplo n.º 27
0
        public void CreateOrder(OrderHead order, string userCode)
        {
            if (order.OrderDetails == null || order.OrderDetails.Count == 0)
            {
                return;
            }

            IList <OrderHead> orderList = new List <OrderHead>();

            //OrderLotSize
            Flow flow = this.FlowMgr.LoadFlow(order.Flow);

            if (order.OrderDetails.Count == 1 && flow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
            {
                FlowDetail fd           = order.OrderDetails[0].FlowDetail;
                decimal    orderLotSize = fd.OrderLotSize.HasValue ? (decimal)fd.OrderLotSize : 0;
                decimal    reqQty       = order.OrderDetails[0].RequiredQty;
                decimal    remainReqQty = order.OrderDetails[0].RequiredQty;

                if (orderLotSize > 0)
                {
                    OrderDetail od = order.OrderDetails[0];

                    decimal oddQty = reqQty % orderLotSize;
                    if (oddQty > 0)
                    {
                        order.OrderDetails[0].RequiredQty = oddQty;
                        order.OrderDetails[0].OrderedQty  = oddQty;
                        orderList.Add(order);
                    }

                    int count = (int)Math.Floor(reqQty / orderLotSize);
                    for (int i = 0; i < count; i++)
                    {
                        OrderHead or = new OrderHead();
                        or = OrderMgr.TransferFlow2Order(order.Flow);
                        CloneHelper.CopyProperty(order, or, new string[] { "OrderNo", "OrderDetails" }, true);
                        if (or.OrderDetails != null && or.OrderDetails.Count > 0)
                        {
                            foreach (OrderDetail orderDetail in or.OrderDetails)
                            {
                                if (orderDetail.FlowDetail.Id == od.FlowDetail.Id && od.FlowDetail.Id > 0)
                                {
                                    orderDetail.RequiredQty = orderLotSize;
                                    orderDetail.OrderedQty  = orderLotSize;
                                }
                            }
                        }

                        orderList.Add(or);
                    }
                }
                else
                {
                    orderList.Add(order);
                }
            }
            else
            {
                orderList.Add(order);
            }

            //Write to DB
            if (orderList != null && orderList.Count > 0)
            {
                foreach (OrderHead oh in orderList)
                {
                    try
                    {
                        //all Empty check
                        bool isValid = false;
                        foreach (OrderDetail od in oh.OrderDetails)
                        {
                            if (od.RequiredQty > 0)
                            {
                                isValid = true;
                                break;
                            }
                        }

                        if (isValid)
                        {
                            //oh.Shift = shiftMgr.LoadShift("A");//temp,todo

                            log.Debug("Begin to create order," + oh.Flow);

                            this.OrderMgr.CreateOrder(oh, userCode);

                            log.Debug("End to create order," + oh.OrderNo);
                            log.Debug("----------------------------------Invincible's dividing line---------------------------------------");
                        }
                    }
                    catch (Exception ex)
                    {
                        this.OrderMgr.CleanSession();
                        log.Error("create order fail", ex);
                        log.Debug("----------------------------------Invincible's dividing line---------------------------------------");
                    }
                }
            }
        }
Exemplo n.º 28
0
    private void SaveRender(object sender, EventArgs e)
    {
        if (this.cvStartTime.IsValid)
        {
            IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>();
            OrderHead           orderHead             = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错

            if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0)
            {
                foreach (OrderDetail orderDetail in orderHead.OrderDetails)
                {
                    if (orderDetail.OrderedQty != 0)
                    {
                        if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
                        {
                            IList <Item>    newItemList = new List <Item>(); //填充套件子件
                            decimal?        convertRate = null;
                            IList <ItemKit> itemKitList = null;

                            var maxSequence = orderHead.OrderDetails.Max(o => o.Sequence);
                            itemKitList = this.TheItemKitMgr.GetChildItemKit(orderDetail.Item);
                            for (int i = 0; i < itemKitList.Count; i++)
                            {
                                Item item = itemKitList[i].ChildItem;
                                if (!convertRate.HasValue)
                                {
                                    if (itemKitList[i].ParentItem.Uom.Code != orderDetail.Item.Uom.Code)
                                    {
                                        convertRate = this.TheUomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Item.Uom, 1, itemKitList[i].ParentItem.Uom);
                                    }
                                    else
                                    {
                                        convertRate = 1;
                                    }
                                }
                                OrderDetail newOrderDetail = new OrderDetail();

                                newOrderDetail.OrderHead     = orderDetail.OrderHead;
                                newOrderDetail.Sequence      = maxSequence + (i + 1);
                                newOrderDetail.IsBlankDetail = false;
                                newOrderDetail.Item          = item;



                                newOrderDetail.Uom         = item.Uom;
                                newOrderDetail.UnitCount   = orderDetail.Item.UnitCount * itemKitList[i].Qty * convertRate.Value;
                                newOrderDetail.OrderedQty  = orderDetail.OrderedQty * itemKitList[i].Qty * convertRate.Value;
                                newOrderDetail.PackageType = orderDetail.PackageType;

                                #region 价格字段

                                if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                                {
                                    if (orderDetail.PriceListFrom != null && orderDetail.PriceListFrom.Code != string.Empty)
                                    {
                                        newOrderDetail.PriceListFrom = ThePurchasePriceListMgr.LoadPurchasePriceList(orderDetail.PriceListFrom.Code);

                                        if (newOrderDetail.PriceListFrom != null)
                                        {
                                            newOrderDetail.PriceListDetailFrom = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListFrom, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                                        }
                                    }
                                }
                                else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                                {
                                    if (orderDetail.PriceListTo != null && orderDetail.PriceListTo.Code != string.Empty)
                                    {
                                        newOrderDetail.PriceListTo = TheSalesPriceListMgr.LoadSalesPriceList(orderDetail.PriceListTo.Code);
                                    }
                                    if (newOrderDetail.PriceListTo != null)
                                    {
                                        newOrderDetail.PriceListDetailTo = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListTo, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                                    }
                                }

                                #endregion
                                resultOrderDetailList.Add(newOrderDetail);
                            }
                        }
                        else
                        {
                            resultOrderDetailList.Add(orderDetail);
                        }
                    }
                }
            }
            if (resultOrderDetailList.Count == 0)
            {
                this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required");
                return;
            }
            else
            {
                //重置resultOrderDetailList中的Sequence
                for (int i = 0; i < resultOrderDetailList.Count; i++)
                {
                    resultOrderDetailList[i].Sequence = i + 1;
                }

                Flow     currentFlow = TheFlowMgr.LoadFlow(CurrentFlowCode, true);
                DateTime winTime     = DateTime.Parse(this.tbWinTime.Text);
                DateTime startTime   = DateTime.Parse(this.tbWinTime.Text);

                if (this.tbStartTime.Text != string.Empty)
                {
                    startTime = DateTime.Parse(this.tbStartTime.Text.Trim());
                }
                else
                {
                    double leadTime = this.hfLeadTime.Value == string.Empty ? 0 : double.Parse(this.hfLeadTime.Value);
                    double emTime   = this.hfEmTime.Value == string.Empty ? 0 : double.Parse(this.hfEmTime.Value);
                    double lTime    = this.cbIsUrgent.Checked ? emTime : leadTime;
                    startTime = winTime.AddHours(0 - lTime);
                }

                orderHead.OrderDetails  = resultOrderDetailList;
                orderHead.WindowTime    = winTime;
                orderHead.StartTime     = startTime;
                orderHead.IsAutoRelease = this.cbReleaseOrder.Checked;
                orderHead.IsNewItem     = this.NewItem;
                if (this.cbIsUrgent.Checked)
                {
                    orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT;
                }
                else
                {
                    orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
                }
                if (this.tbRefOrderNo.Text.Trim() != string.Empty)
                {
                    orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim();
                }
                if (this.tbExtOrderNo.Text.Trim() != string.Empty)
                {
                    orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim();
                }

                if (this.IsQuick)
                {
                    orderHead.IsAutoRelease   = true;
                    orderHead.IsAutoStart     = true;
                    orderHead.IsAutoShip      = true;
                    orderHead.IsAutoReceive   = true;
                    orderHead.StartLatency    = 0;
                    orderHead.CompleteLatency = 0;
                }
            }

            //创建订单
            try
            {
                if (this.IsQuick)
                {
                    Receipt receipt = TheOrderMgr.QuickReceiveOrder(orderHead.Flow, orderHead.OrderDetails, this.CurrentUser.Code, this.ModuleSubType, orderHead.WindowTime, orderHead.StartTime, this.cbIsUrgent.Checked, orderHead.ReferenceOrderNo, orderHead.ExternalOrderNo);
                    if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0)
                    {
                        orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead;
                        if (this.cbPrintOrder.Checked)
                        {
                            IList <OrderDetail> orderDetails = orderHead.OrderDetails;
                            IList <object>      list         = new List <object>();
                            list.Add(orderHead);
                            list.Add(orderDetails);

                            IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo);
                            list.Add(orderLocationTransactions);

                            //TheReportProductionMgr.FillValues(orderHead.OrderTemplate,list);

                            string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list);

                            Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>");
                        }
                    }
                    this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo);

                    if (!this.cbContinuousCreate.Checked)
                    {
                        this.PageCleanup();

                        if (QuickCreateEvent != null)
                        {
                            QuickCreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e);
                        }
                    }
                    else
                    {
                        orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim());
                        InitDetailParamater(orderHead);
                    }
                }
                else
                {
                    TheOrderMgr.CreateOrder(orderHead, this.CurrentUser);
                    if (this.cbPrintOrder.Checked)
                    {
                        IList <OrderDetail> orderDetails = orderHead.OrderDetails;
                        IList <object>      list         = new List <object>();
                        list.Add(orderHead);
                        list.Add(orderDetails);

                        IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo);
                        list.Add(orderLocationTransactions);

                        //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list);
                        string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list);

                        Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>");
                    }
                    this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo);

                    if (!this.cbContinuousCreate.Checked)
                    {
                        this.PageCleanup();
                        if (CreateEvent != null)
                        {
                            CreateEvent(orderHead.OrderNo, e);
                        }
                    }
                    else
                    {
                        orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim());
                        InitDetailParamater(orderHead);
                    }
                }
            }
            catch (BusinessErrorException ex)
            {
                this.ShowErrorMessage(ex);
                return;
            }
        }
    }
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);


                if (orderHead == null ||
                    orderDetails == null || orderDetails.Count == 0)
                {
                    return(false);
                }

                this.barCodeFontName = this.GetBarcodeFontName(2, 8);
                //this.SetRowCellBarCode(0, 2, 8);
                this.CopyPage(orderDetails.Count);

                this.FillHead(orderHead);

                //自动换行
                //style.WrapText = true;

                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                foreach (OrderDetail orderDetail in orderDetails)
                {
                    // No.
                    this.SetRowCell(pageIndex, rowIndex, 0, "" + orderDetail.Sequence);

                    //零件号 Item Code
                    this.SetRowCell(pageIndex, rowIndex, 1, orderDetail.Item.Code);

                    //参考号 Ref No.
                    this.SetRowCell(pageIndex, rowIndex, 2, orderDetail.ReferenceItemCode);

                    //描述Description
                    this.SetRowCell(pageIndex, rowIndex, 3, orderDetail.Item.Description);

                    //单位Unit
                    this.SetRowCell(pageIndex, rowIndex, 4, orderDetail.Item.Uom.Code);

                    //单包装UC
                    this.SetRowCell(pageIndex, rowIndex, 5, orderDetail.UnitCount.ToString("0.########"));

                    //需求 Request	包装
                    int UCs = (int)Math.Ceiling(orderDetail.OrderedQty / orderDetail.UnitCount);
                    this.SetRowCell(pageIndex, rowIndex, 6, UCs.ToString());

                    //需求 Request	零件数
                    this.SetRowCell(pageIndex, rowIndex, 7, orderDetail.OrderedQty.ToString("0.########"));

                    //发货数
                    this.SetRowCell(pageIndex, rowIndex, 8, orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value.ToString("0.########") : string.Empty);

                    //实收 Received	包装
                    this.SetRowCell(pageIndex, rowIndex, 9, "");

                    //实收 Received	零件数
                    this.SetRowCell(pageIndex, rowIndex, 10, orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value.ToString("0.########") : string.Empty);

                    //批号/备注
                    this.SetRowCell(pageIndex, rowIndex, 11, "");

                    if (this.isPageBottom(rowIndex, rowTotal))    //页的最后一行
                    {
                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 30
0
 public IList <OrderOperation> GetOrderOperation(OrderHead orderHead)
 {
     return(GetOrderOperation(orderHead.OrderNo));
 }