Пример #1
0
        /// <summary>
        /// 锁定订单。返回true表示同步锁定订单,false表示异步锁定订单
        /// </summary>
        /// <param name="soBaseInfo">订单基本信息</param>
        /// <returns>是不是已经同步锁定了订单,true 表示是,false 表示异步锁定订单(订单现在还没有锁定)</returns>
        public virtual bool Hold(SOHoldReason holdType, OPCCallBackType callBackType)
        {
            //  1.  锁定前的业务检查,订单处于以下状态时不能被锁定:1.已作废,已拆分,已出库;2.已经被锁定(前台网站和后台管理锁定后都不能再次锁定)
            HoldPreCheck(holdType);

            //  2.  判断WMS是否下载订单,如果下载则要Hold WMS
            bool wmsIsDownload = SODA.WMSIsDownloadSO(SOSysNo);

            //  3.  仓库锁定订单
            if (wmsIsDownload)
            {
                List <int> stockSysNoList = (from item in CurrentSO.Items
                                             where item.StockSysNo.HasValue && item.ProductType != SOProductType.Coupon && item.ProductType != SOProductType.ExtendWarranty
                                             select item.StockSysNo.Value).Distinct().ToList();
                try
                {
                    //同步锁定订单
                    WMSHoldMessage message = new WMSHoldMessage
                    {
                        SOSysNo            = SOSysNo,
                        ActionType         = ECCentral.Service.EventMessage.WMSActionType.Hold,
                        UserSysNo          = ServiceContext.Current.UserSysNo,
                        WarehouseSysNoList = stockSysNoList,
                        Reason             = CurrentSO.BaseInfo.HoldReason
                    };
                    EventPublisher.Publish <WMSHoldMessage>(message);
                }
                catch (ThirdPartBizException biz_ex)
                {
                    throw new BizException(biz_ex.Message);
                }
                catch
                {
                    //异步锁定订单
                    WMSAction action = WMSAction.Hold;
                    switch (holdType)
                    {
                    case SOHoldReason.AbandonOrder:
                        action = WMSAction.AbandonHold;
                        break;

                    case SOHoldReason.CancelAuditOrder:
                        action = WMSAction.CancelAuditHold;
                        break;
                    }
                    ObjectFactory <OPCProcessor> .Instance.SendMessageToWMS(CurrentSO, action, callBackType); //ExternalDomainBroker.SendMessageToWMS(CurrentSO, action, OPCCallBackType.HoldCallBack);

                    BizExceptionHelper.Throw("SO_Hold_NetErrorSysncHolding");
                }
            }
            //  3.  本地锁定订单
            DirectHoldSO();
            return(true);
        }
Пример #2
0
        private int SaveOPCMaster(SOInfo soInfo, WMSAction action, OPCCallBackType callBackType)
        {
            OPCOfflineInfo offlineInfo = new OPCOfflineInfo();

            offlineInfo.FromSystem    = "IPP_Order_System";
            offlineInfo.ActionType    = action;
            offlineInfo.CompanyCode   = soInfo.CompanyCode;
            offlineInfo.CustomerSysNo = soInfo.BaseInfo.CustomerSysNo.Value;
            offlineInfo.Indate        = DateTime.Now;

            offlineInfo.NeedResponse = true;
            offlineInfo.SentDate     = DateTime.Now;
            offlineInfo.SOSysNo      = soInfo.SysNo.Value;

            offlineInfo.Status          = OPCStatus.Open;
            offlineInfo.CallBackService = callBackType;
            offlineInfo.Body            = SerializationUtility.XmlSerialize(soInfo);

            return(OPCDA.InsertOPCOfflineInfo(offlineInfo));
        }
Пример #3
0
        private WMSActionType WMSActionToAction(WMSAction action)
        {
            switch (action)
            {
            case WMSAction.Abandon:
                return(WMSActionType.Abandon);

            case WMSAction.CancelAuditHold:
                return(WMSActionType.CancelAuditHold);

            case WMSAction.AbandonHold:
                return(WMSActionType.AbandonHold);

            case WMSAction.Hold:
                return(WMSActionType.Hold);

            case WMSAction.UnHold:
                return(WMSActionType.UnHold);
            }
            return(WMSActionType.Hold);
        }
Пример #4
0
        public void SendMessageToWMS(SOInfo soInfo, WMSAction action, OPCCallBackType callBackType)
        {
            object     mark           = new object();
            List <int> stockSysNoList = (from item in soInfo.Items
                                         where item.StockSysNo.HasValue && item.ProductType != SOProductType.Coupon && item.ProductType != SOProductType.ExtendWarranty
                                         select item.StockSysNo.Value).Distinct().ToList();

            lock (mark)
            {
                int masterID = this.SaveOPCMaster(soInfo, action, callBackType);
                foreach (int stockSysNo in stockSysNoList)
                {
                    WarehouseInfo wareInfo = ExternalDomainBroker.GetWarehouseInfo(stockSysNo);
                    string        stockID  = wareInfo == null ? "" : wareInfo.WarehouseID;
                    if (String.IsNullOrEmpty(stockID))
                    {
                        BizExceptionHelper.Throw("SO_Audit_StockIsNotExist", stockSysNo.ToString());
                    }

                    int transactionID = this.SaveOPCTransaction(soInfo.SysNo.Value, stockSysNo, masterID, soInfo.CompanyCode);
                    WMSSOActionRequestMessage requestEntity = new WMSSOActionRequestMessage
                    {
                        SOSysNo          = soInfo.SysNo.Value,
                        CompanyCode      = soInfo.CompanyCode,
                        ActionDate       = DateTime.Now,
                        ActionReason     = string.Format("{0} SO", action.ToDisplayText()),
                        StockSysNo       = stockSysNo,
                        TransactionSysNo = transactionID,
                        StockID          = stockID,
                        Language         = soInfo.BaseInfo.LanguageCode,
                        ActionType       = WMSActionToAction(action),
                        ActionUser       = ServiceContext.Current.UserSysNo
                    };
                    this.SaveOPCMessage(soInfo, transactionID, requestEntity);
                    EventPublisher.Publish <WMSSOActionRequestMessage>(requestEntity);
                }
            }
        }