Пример #1
0
        private IList <Flow> GetReferenceFlow(FlowDetail flowDetail, string locTo)
        {
            IList <Flow>     refFlowList = new List <Flow>();
            DetachedCriteria criteria    = DetachedCriteria.For(typeof(Flow));

            criteria.Add(Expression.IsNotNull("ReferenceFlow"));
            IList <Flow> flowList = CriteriaMgr.FindAll <Flow>(criteria);

            if (flowList != null && flowList.Count > 0)
            {
                foreach (Flow flow in flowList)
                {
                    if (flow.LocationTo != null)
                    {
                        if (flow.LocationTo.Code == locTo && flowDetail.Flow.Code == flow.ReferenceFlow)
                        {
                            refFlowList.Add(flow);
                            break;
                        }
                    }
                }
            }

            return(refFlowList);
        }
Пример #2
0
        private OrderDetail RefreshOrderDetail(string flow, OrderDetail orderDetail)
        {
            OrderDetail        newOrderDetail = new OrderDetail();
            IList <FlowDetail> flowDetailList = base.genericMgr.FindAll <FlowDetail>(selectFlowDetailStatement, flow);
            FlowDetail         flowDetail     = flowDetailList.Where <FlowDetail>(q => q.Item == orderDetail.Item).SingleOrDefault();

            if (flowDetail != null)
            {
                Mapper.Map <FlowDetail, OrderDetail>(flowDetail, newOrderDetail);
                newOrderDetail.Sequence        = orderDetail.Sequence == 0 ? newOrderDetail.Sequence : orderDetail.Sequence;
                newOrderDetail.UnitCount       = orderDetail.UnitCount == 0 ? orderDetail.UnitCount : orderDetail.UnitCount;
                newOrderDetail.Uom             = String.IsNullOrWhiteSpace(orderDetail.Uom) ? orderDetail.Uom : orderDetail.Uom;
                newOrderDetail.ItemDescription = base.genericMgr.FindById <Item>(orderDetail.Item).Description;
            }
            else
            {
                Item item = base.genericMgr.FindById <Item>(orderDetail.Item);
                if (item != null)
                {
                    newOrderDetail.Item            = item.Code;
                    newOrderDetail.UnitCount       = newOrderDetail.UnitCount == 0 ? item.UnitCount : orderDetail.UnitCount;
                    newOrderDetail.Uom             = String.IsNullOrWhiteSpace(newOrderDetail.Uom) ? item.Uom : orderDetail.Uom;
                    newOrderDetail.ItemDescription = item.Description;
                    newOrderDetail.Sequence        = orderDetail.Sequence;
                }
            }

            newOrderDetail.OrderedQty = orderDetail.OrderedQty;
            if (!string.IsNullOrEmpty(orderDetail.LocationFrom))
            {
                newOrderDetail.LocationFrom     = orderDetail.LocationFrom;
                newOrderDetail.LocationFromName = base.genericMgr.FindById <Location>(orderDetail.LocationFrom).Name;
            }
            return(newOrderDetail);
        }
Пример #3
0
        public ActionResult _WebOrderDetail(string flow, string itemCode)
        {
            if (!string.IsNullOrEmpty(flow) && !string.IsNullOrEmpty(itemCode))
            {
                WebOrderDetail webOrderDetail = new WebOrderDetail();
                FlowDetail     flowDetail     = base.genericMgr.FindAll <FlowDetail>(selectOneFlowDetailStatement, new object[] { flow, itemCode }).SingleOrDefault <FlowDetail>();

                if (flowDetail != null)
                {
                    webOrderDetail.Item            = flowDetail.Item;
                    webOrderDetail.ItemDescription = base.genericMgr.FindById <Item>(flowDetail.Item).Description;
                    webOrderDetail.UnitCount       = flowDetail.UnitCount;
                    webOrderDetail.Uom             = flowDetail.Uom;
                    webOrderDetail.Sequence        = flowDetail.Sequence;
                    //默认库位
                    webOrderDetail.LocationFrom = flowDetail.LocationFrom;
                }
                else
                {
                    Item item = base.genericMgr.FindById <Item>(itemCode);
                    if (item != null)
                    {
                        webOrderDetail.Item            = item.Code;
                        webOrderDetail.ItemDescription = item.Description;
                        webOrderDetail.UnitCount       = item.UnitCount;
                        webOrderDetail.Uom             = item.Uom;
                    }
                }
                return(this.Json(webOrderDetail));
            }
            return(null);
        }
Пример #4
0
        public FlowDetail LoadFlowDetail(string flowCode, string itemCode, int seq)
        {
            FlowDetail       flowDetail = null;
            DetachedCriteria criteria   = DetachedCriteria.For(typeof(FlowDetail));

            criteria.Add(Expression.Eq("Flow.Code", flowCode));
            criteria.Add(Expression.Eq("Item.Code", itemCode));
            IList <FlowDetail> flowDetailList = criteriaMgr.FindAll <FlowDetail>(criteria);

            if (flowDetailList != null && flowDetailList.Count > 0)
            {
                if (flowDetailList.Count == 1)
                {
                    flowDetail = flowDetailList[0];
                }
                else
                {
                    foreach (FlowDetail fd in flowDetailList)
                    {
                        if (fd.Sequence == seq)
                        {
                            flowDetail = fd;
                            break;
                        }
                    }
                }
            }

            return(flowDetail);
        }
Пример #5
0
        public SupplyChain GenerateSupplyChain(Flow flow, FlowDetail flowDetail)
        {
            SupplyChain supplyChain = new SupplyChain();

            supplyChain.Flow       = flow;
            supplyChain.FlowDetail = flowDetail;

            SupplyChainDetail supplyChainDetail = new SupplyChainDetail();

            supplyChainDetail.SupplyChain = supplyChain;
            supplyChainDetail.Id          = 1;
            supplyChainDetail.ParentId    = 0;
            supplyChainDetail.Flow        = flow;
            supplyChainDetail.FlowDetail  = flowDetail;
            supplyChainDetail.LocationTo  = flowDetail.DefaultLocationTo == null ? null : flowDetail.DefaultLocationTo;
            supplyChainDetail.QuantityPer = 1;

            IList <SupplyChainDetail> supplyChainDetailList = new List <SupplyChainDetail>();

            supplyChainDetailList.Add(supplyChainDetail);
            this.GetSupplyChainDetail(supplyChainDetailList, supplyChainDetail);

            supplyChain.AddRangeSupplyChainDetail(supplyChainDetailList);
            return(supplyChain);
        }
Пример #6
0
        public override void DeleteFlowDetail(int id)
        {
            FlowDetail flowDetail = this.LoadFlowDetail(id);

            flowDetailTrackMgr.CreateFlowDetailTrack(flowDetail, BusinessConstants.TRACK_EVENT_DELETE);
            base.DeleteFlowDetail(id);
        }
Пример #7
0
        public FlowView CheckAndLoadFlowView(string flowCode, string userCode, string locationFromCode, string locationToCode, Hu hu, List <string> flowTypes)
        {
            //按物料号,单位,单包装
            FlowView flowView = LoadFlowView(flowCode, userCode, locationFromCode, locationToCode, hu, flowTypes);

            //看是否允许新建明细
            if (flowView == null)
            {
                IList <Flow> flowList = this.GetFlows(flowCode, locationFromCode, locationToCode, true, userCode, flowTypes);
                if (flowList != null && flowList.Count > 0)
                {
                    flowView      = new FlowView();
                    flowView.Flow = flowList[0];
                    FlowDetail flowDetail = new FlowDetail();
                    flowDetail.Item       = hu.Item;
                    flowDetail.Uom        = hu.Uom;
                    flowDetail.UnitCount  = hu.UnitCount;
                    flowView.LocationFrom = flowView.Flow.LocationFrom;
                    flowView.LocationTo   = flowView.Flow.LocationTo;
                }
            }
            if (flowView != null)
            {
                return(flowView);
            }
            else
            {
                throw new BusinessErrorException("Flow.Error.NotFoundMacthFlow", hu.HuId, flowCode);
            }
        }
Пример #8
0
        public OrderDetail TransferFlowDetail2OrderDetail(FlowDetail flowDetail)
        {
            OrderDetail orderDetail = new OrderDetail();

            CloneHelper.CopyProperty(flowDetail, orderDetail, FlowDetail2OrderDetailCloneFields);
            return(orderDetail);
        }
Пример #9
0
        public string GenerateRMHuId(FlowDetail flowDetail, string lotNo, decimal qty, string idMark)
        {
            #region 物料条码
            //if (flowDetail.BarCodeType == BusinessConstants.CODE_MASTER_RAW_MATERIAL_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //ItemCode+供应商标识(1位)+年 月 日4位 + 数量(4位,不足4位以0补齐)+生产序号(3位,不足3位以0补齐)
            string itemCode  = flowDetail.Item.Code;
            string supIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                               (flowDetail.IdMark != null && flowDetail.IdMark.Trim() != string.Empty
                ? flowDetail.IdMark.Trim() : BusinessConstants.DEFAULT_SUPPLIER_ID_MARK);
            if (lotNo != null && lotNo.Trim().Length != 0)
            {
                LotNoHelper.validateLotNo(lotNo);
            }
            else
            {
                lotNo = LotNoHelper.GenerateLotNo();
            }
            if (flowDetail.Item.Uom.Code != flowDetail.Uom.Code)
            {
                qty = qty * this.uomConversionMgr.ConvertUomQty(flowDetail.Item, flowDetail.Uom, 1, flowDetail.Item.Uom);   //单位用量
            }
            string qtyStr = qty.ToString().PadLeft(4, '0');

            string barCodePrefix = itemCode + supIdMark + lotNo + qtyStr;
            return(GenerateNumber(barCodePrefix, 3));

            #endregion
        }
Пример #10
0
        public override void UpdateFlowDetail(FlowDetail entity)
        {
            base.UpdateFlowDetail(entity);
            flowDetailTrackMgr.CreateFlowDetailTrack(entity, BusinessConstants.TRACK_EVENT_UPDATE);

            //Flow flow = entity.Flow;
            //flow.LastModifyDate = DateTime.Now;
            //flowDao.UpdateFlow(flow);
        }
Пример #11
0
        private decimal GetFinalPlanQty(decimal planQty, FlowDetail flowDetail)
        {
            decimal finalPlanQty = planQty;

            //批量
            decimal batchSize = flowDetail.BatchSize == null ? 0 : (decimal)(flowDetail.BatchSize);

            if (batchSize > 0)
            {
                finalPlanQty = Math.Ceiling(planQty / batchSize) * batchSize;
            }

            return(finalPlanQty);
        }
Пример #12
0
    public void InitPageParameter(Flow flow)
    {
        this.PartyFromCode = flow.PartyFrom.Code;
        this.PartyToCode   = flow.PartyTo.Code;
        this.FlowType      = flow.Type;
        this.FlowCode      = flow.Code;

        int seqInterval = int.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);

        if (flow.AllowCreateDetail && false) //新增的Detail打印有问题,暂时不支持
        {
            FlowDetail blankFlowDetail = new FlowDetail();
            if (flow.FlowDetails == null || flow.FlowDetails.Count == 0)
            {
                blankFlowDetail.Sequence = seqInterval;
            }
            else
            {
                int CurrentSeq = flow.FlowDetails.Last <FlowDetail>().Sequence + seqInterval;
                blankFlowDetail.Sequence = CurrentSeq;
            }
            blankFlowDetail.IsBlankDetail = true;
            flow.AddFlowDetail(blankFlowDetail);
        }

        #region 设置默认LotNo
        string lotNo = LotNoHelper.GenerateLotNo();
        foreach (FlowDetail flowDetail in flow.FlowDetails)
        {
            flowDetail.HuLotNo = lotNo;
        }
        #endregion

        this.GV_List.DataSource = flow.FlowDetails;
        this.GV_List.DataBind();

        BindShift();

        if (flow.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
        {
            this.TabProd.Visible            = false;
            this.GV_List.Columns[8].Visible = true;
        }
        else
        {
            this.TabProd.Visible            = true;
            this.GV_List.Columns[8].Visible = false;
        }
    }
Пример #13
0
        private string GetBomCode(FlowDetail flowDetail)
        {
            string bomCode = string.Empty;

            if (flowDetail.Bom != null)
            {
                bomCode = flowDetail.Bom.Code;
            }
            else
            {
                bomCode = flowDetail.Item.Bom == null ? flowDetail.Item.Code : flowDetail.Item.Bom.Code;
            }

            return(bomCode);
        }
Пример #14
0
    protected void ODS_FlowDetail_Updated(object sender, ObjectDataSourceStatusEventArgs e)
    {
        EditEvent(sender, e);

        FlowDetail flowDetail   = TheFlowDetailMgr.LoadFlowDetail(this.FlowDetailId);
        decimal    unitCount    = flowDetail.UnitCount;
        decimal    orderLotSize = flowDetail.OrderLotSize == null ? 0 : (decimal)flowDetail.OrderLotSize;

        if (unitCount != 0 && orderLotSize != 0 && orderLotSize % unitCount != 0)
        {
            ShowWarningMessage("MasterData.Flow.FlowDetail.AddFlowDetail.Successfully.UC.Not.Divisible", flowDetail.Sequence.ToString());
        }
        else
        {
            ShowSuccessMessage("MasterData.Flow.FlowDetail.UpdateFlowDetail.Successfully", flowDetail.Sequence.ToString());
        }
    }
Пример #15
0
        public static Transformer ConvertFlowDetailToTransformer(FlowDetail flowDetail)
        {
            if (flowDetail == null)
            {
                return(null);
            }

            Transformer transformer = new Transformer();

            transformer.ItemCode          = flowDetail.Item.Code;
            transformer.ItemDescription   = flowDetail.Item.Description;
            transformer.ReferenceItemCode = flowDetail.ReferenceItemCode;
            transformer.UomCode           = flowDetail.Uom.Code;
            transformer.UnitCount         = flowDetail.UnitCount;
            transformer.LocationFromCode  = flowDetail.DefaultLocationFrom != null ? flowDetail.DefaultLocationFrom.Code : null;
            transformer.LocationToCode    = flowDetail.DefaultLocationTo != null ? flowDetail.DefaultLocationTo.Code : null;

            return(transformer);
        }
Пример #16
0
 protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         FlowDetail flowDetail = (FlowDetail)e.Row.DataItem;
         if (flowDetail.Flow.Code != this.FlowCode)
         {
             //引用明细,隐藏Edit和Delete Link
             LinkButton lbtnEdit   = (LinkButton)e.Row.Cells[e.Row.Cells.Count - 1].FindControl("lbtnEdit");
             LinkButton lbtnDelete = (LinkButton)e.Row.Cells[e.Row.Cells.Count - 1].FindControl("lbtnDelete");
             lbtnEdit.Visible   = false;
             lbtnDelete.Visible = false;
         }
         else
         {
             //非引用明细,隐藏View Link
             LinkButton lbtnView = (LinkButton)e.Row.Cells[e.Row.Cells.Count - 1].FindControl("lbtnView");
             lbtnView.Visible = false;
         }
     }
 }
Пример #17
0
        public string GenerateFGHuId(FlowDetail flowDetail, string shiftCode, decimal qty, string idMark)
        {
            #region 成品条码
            //if (flowDetail.BarCodeType == BusinessConstants.CODE_MASTER_FINISH_GOODS_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //生产线识别码2位+产品识别码(1位) +生产日期4位 (规则同5.5.1.2中的供货日期编码) +班别号1位 (以大写字母表示) +3位顺序号
            string pl = flowDetail.Flow.Code;
            if (pl.Length > 2)
            {
                //如果生产线代码长度大于2,取后两位
                pl = pl.Substring(pl.Length - 2);
            }

            string pIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                             (flowDetail.IdMark != null && flowDetail.IdMark.Trim() != string.Empty
                ? flowDetail.IdMark.Trim() : BusinessConstants.DEFAULT_FINISHI_GOODS_ID_MARK);
            string lotNo = flowDetail.HuLotNo;
            if (lotNo != null && lotNo.Trim().Length != 0)
            {
                LotNoHelper.validateLotNo(lotNo);
            }
            else
            {
                lotNo = LotNoHelper.GenerateLotNo();
            }
            string shift = shiftCode;

            string barCodePrefix = pl + pIdMark + lotNo + shift;
            return(GenerateNumber(barCodePrefix, 3));

            #endregion
        }
Пример #18
0
        public void CreateFlowDetailTrack(FlowDetail flowDetail, string eventCode)
        {
            FlowDetailTrack flowDetailTrack = new FlowDetailTrack();

            CloneHelper.CopyProperty(flowDetail, flowDetailTrack, FlowDetail2FlowDetailTrackCloneFields);
            flowDetailTrack.FlowDetailId   = flowDetail.Id;
            flowDetailTrack.Flow           = flowDetail.Flow.Code;
            flowDetailTrack.Item           = flowDetail.Item.Code;
            flowDetailTrack.Customer       = flowDetail.Customer != null ? flowDetail.Customer.Code : string.Empty;
            flowDetailTrack.Uom            = flowDetail.Uom != null ? flowDetail.Uom.Code : string.Empty;
            flowDetailTrack.Bom            = flowDetail.Bom != null ? flowDetail.Bom.Code : string.Empty;
            flowDetailTrack.BillFrom       = flowDetail.BillFrom != null ? flowDetail.BillFrom.Code : string.Empty;
            flowDetailTrack.BillTo         = flowDetail.BillTo != null ? flowDetail.BillTo.Code : string.Empty;
            flowDetailTrack.LocationFrom   = flowDetail.LocationFrom != null ? flowDetail.LocationFrom.Code : string.Empty;
            flowDetailTrack.LocationTo     = flowDetail.LocationTo != null ? flowDetail.LocationTo.Code : string.Empty;
            flowDetailTrack.LastModifyUser = flowDetail.LastModifyUser.Code;
            flowDetailTrack.LastModifyDate = DateTime.Now;
            flowDetailTrack.PriceListFrom  = flowDetail.PriceListFrom != null ? flowDetail.PriceListFrom.Code : string.Empty;
            flowDetailTrack.PriceListTo    = flowDetail.PriceListTo != null ? flowDetail.PriceListTo.Code : string.Empty;
            flowDetailTrack.EventCode      = eventCode;

            base.CreateFlowDetailTrack(flowDetailTrack);
        }
Пример #19
0
        public FlowDetail GetFlowDetailBySeq(string flowCode, int seq)
        {
            Flow             flow       = flowDao.LoadFlow(flowCode);
            FlowDetail       flowDetail = null;
            DetachedCriteria criteria   = DetachedCriteria.For(typeof(FlowDetail));

            criteria.Add(Expression.Eq("Sequence", seq));
            if (flow.ReferenceFlow != null && flow.ReferenceFlow.Trim() != string.Empty)
            {
                criteria.Add(Expression.Or(Expression.Eq("Flow.Code", flowCode), Expression.Eq("Flow.Code", flow.ReferenceFlow)));
            }
            else
            {
                criteria.Add(Expression.Eq("Flow.Code", flowCode));
            }
            List <FlowDetail> flowDetailList = (List <FlowDetail>)criteriaMgr.FindAll <FlowDetail>(criteria);

            if (flowDetailList.Count > 0)
            {
                flowDetail = flowDetailList[0];
            }
            return(flowDetail);
        }
Пример #20
0
 public decimal ConvertUomQtyInvToOrder(FlowDetail flowDetail, decimal invQty)
 {
     return(this.ConvertUomQty(flowDetail.Item, flowDetail.Item.Uom, invQty, flowDetail.Uom));
 }
Пример #21
0
 public virtual void DeleteFlowDetail(FlowDetail entity)
 {
     entityDao.DeleteFlowDetail(entity);
 }
Пример #22
0
 public virtual void CreateFlowDetail(FlowDetail entity)
 {
     entityDao.CreateFlowDetail(entity);
 }
Пример #23
0
 public virtual void UpdateFlowDetail(FlowDetail entity)
 {
     entityDao.UpdateFlowDetail(entity);
 }
Пример #24
0
 public string GenerateFGHuId(FlowDetail flowDetail, string shiftCode, decimal qty)
 {
     return(GenerateFGHuId(flowDetail, shiftCode, qty, null));
 }
Пример #25
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);
            }
        }
Пример #26
0
 public virtual void DeleteFlowDetail(FlowDetail entity)
 {
     Delete(entity);
 }
Пример #27
0
 public virtual void UpdateFlowDetail(FlowDetail entity)
 {
     Update(entity);
 }
Пример #28
0
 public virtual void CreateFlowDetail(FlowDetail entity)
 {
     Create(entity);
 }
Пример #29
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---------------------------------------");
                    }
                }
            }
        }
Пример #30
0
 public string GenerateRMHuId(FlowDetail flowDetail, string lotNo, decimal qty)
 {
     return(GenerateRMHuId(flowDetail, lotNo, qty, null));
 }