Exemplo n.º 1
0
        /// <summary>
        /// AssignPallet
        /// </summary>
        /// <param name="plt">plt</param>
        /// <param name="editor">editor</param>
        public S_common_ret AssignPallet(string plt, string editor)
        {
            try
            {

                Pallet curPallet = palletRepository.Find(plt);
                if (null != curPallet)
                {
                    curPallet.Station = "WH";
                    curPallet.Editor = editor;
                    curPallet.Udt = DateTime.Now;
                    PalletLog newPalletLog = new PalletLog();
                    newPalletLog.Editor = editor;
                    newPalletLog.Line = "";
                    newPalletLog.Station = "WH";
                    newPalletLog.Cdt = DateTime.Now;
                    curPallet.AddLog(newPalletLog);

                    IUnitOfWork uow = new UnitOfWork();
                    palletRepository.Update(curPallet, uow);
                    uow.Commit();
                }
                              
                
                S_common_ret ret = new S_common_ret();
                ret.state = 0;
                WhPltLogInfo newLog = new WhPltLogInfo();
                newLog.plt = plt;
                newLog.editor = editor;
                newLog.wc = "IN";
                newLog.cdt = DateTime.Now;
                palletRepository.InsertWhPltLog(newLog);
                WhPltMasInfo haveRecord = palletRepository.GetWHPltMas(plt);
                if (null != haveRecord)
                {
                    WhPltMasInfo newMasInfo = new WhPltMasInfo();
                    newMasInfo.plt = plt;
                    newMasInfo.editor = editor;
                    newMasInfo.wc = "IN";
                    newMasInfo.udt = DateTime.Now;
                    palletRepository.UpdateWhPltMas(newMasInfo, plt);
                }
                else
                {
                    WhPltMasInfo newMasInfo = new WhPltMasInfo();
                    newMasInfo.plt = plt;
                    newMasInfo.editor = editor;
                    newMasInfo.wc = "IN";
                    newMasInfo.cdt = DateTime.Now;
                    newMasInfo.udt = DateTime.Now;
                    palletRepository.InsertWhPltMas(newMasInfo);
                }

                IList<PakWhPltTypeInfo> reGetTypeList = palletRepository.GetPakWhPltTypeListByPlt(plt);
                string bol = "";
                string carrier = "";
                string tp = "";
                foreach (PakWhPltTypeInfo tmp in reGetTypeList)
                {
                    if (null != tmp)
                    {
                        if (tmp.bol != null && tmp.bol.Length > 0
                            || tmp.carrier != null && tmp.carrier.Length > 0
                            || tmp.tp != null && tmp.tp.Length > 0)
                        {
                            if (bol == "" || tmp.bol != null)
                            {
                                bol = tmp.bol;
                            }
                            if (carrier == "" || tmp.carrier != null)
                            {
                                carrier = tmp.carrier;
                            }
                            if (tp == "" || tmp.tp != null)
                            {
                                tp = tmp.tp;
                            }
                        }
                    }
                }
                if (bol == "")
                {
                    ret.state = 30;
                    return ret;
                }
                
                
                
                
                /*S_DN_Extended value = GetDN(plt);
                
                
                
                
                
                if (value.success == 0)
                {
                    ret.state = 3;
                    return ret;
                }*/
                string col = "";
                int loc = 0;
                IList<PakWhLocMasInfo> getLocList = palletRepository.GetPakWhLocMasListByBolAndPlt1(bol, "");
                if (null == getLocList ||
                    getLocList.Count == 0)
                {
                    ret.state = 3;
                    return ret;
                }
                foreach (PakWhLocMasInfo aLoc in getLocList)
                {
                    if (aLoc.col == "")
                    {
                        //此貨代庫位已滿,請自行處理擺放
                        ret.state = 2;
                        return ret;
                    }
                    else
                    {
                        col = aLoc.col;
                        loc = aLoc.loc;
                    }
                    break;
                }
                WhPltLocLogInfo item = new WhPltLocLogInfo();
                item.plt = plt;
                item.loc = col + loc.ToString();
                palletRepository.InsertWhPltLocLogInfo(item);
                PakWhLocMasInfo newLoc = new PakWhLocMasInfo();
                newLoc.plt1 = plt;
                newLoc.udt = DateTime.Now;
                palletRepository.UpdatePakWhLocByColAndLoc(newLoc, col, loc);
                ret.describe = col;
                ret.describe = ret.describe + "#@#";
                ret.describe = ret.describe + loc.ToString();
                //成功结束,請將此棧板放入'+@col+'區'+@loc+'庫位”
                ret.state = 101;
                return ret;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// RemovePallet
        /// </summary>
        /// <param name="plt">plt</param>
        /// <param name="editor">editor</param>
        public void RemovePallet(string plt, string editor)
        {
            try
            {
                palletRepository.UpdatePakWhLocByPltForClearPlt1AndPlt2(plt);
                WhPltMasInfo newMasInfo = new WhPltMasInfo();
                newMasInfo.plt = plt;
                newMasInfo.editor = editor;
                newMasInfo.wc = "RW";
                newMasInfo.udt = DateTime.Now;
                palletRepository.UpdateWhPltMas(newMasInfo, plt);
                WhPltLogInfo newLog = new WhPltLogInfo();
                newLog.plt = plt;
                newLog.editor = editor;
                newLog.wc = "RW";
                newLog.cdt = DateTime.Now;
                palletRepository.InsertWhPltLog(newLog);

                Pallet curPallet = palletRepository.Find(plt);
                if (null != curPallet)
                {
                    curPallet.Station = "RW";
                    curPallet.Editor = editor;
                    curPallet.Udt = DateTime.Now;
                    PalletLog newPalletLog = new PalletLog();
                    newPalletLog.Editor = editor;
                    newPalletLog.Line = "";
                    newPalletLog.Station = "RW";
                    newPalletLog.Cdt = DateTime.Now;
                    curPallet.AddLog(newPalletLog);

                    IUnitOfWork uow = new UnitOfWork();
                    palletRepository.Update(curPallet, uow);
                    uow.Commit();
                }

            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// AssignBol
        /// </summary>
        /// <param name="plt">plt</param>
        /// <param name="editor">editor</param>
        public S_common_ret AssignBol(string plt, string editor)
        {
            try
            {
                S_common_ret ret = new S_common_ret();
                ret.state = 0;
                IList<PakWhPltTypeInfo> reGetTypeList = palletRepository.GetPakWhPltTypeListByPlt(plt);
                string bol = "";
                string carrier = "";
                string tp = "";
                foreach (PakWhPltTypeInfo tmp in reGetTypeList)
                {
                    if (null != tmp)
                    {
                        if (tmp.bol != null && tmp.bol.Length > 0
                            || tmp.carrier != null && tmp.carrier.Length > 0
                            || tmp.tp != null && tmp.tp.Length > 0)
                        {
                            if (bol == "" || tmp.bol != null)
                            {
                                bol = tmp.bol;
                            }
                            if (carrier == "" || tmp.carrier != null)
                            {
                                carrier = tmp.carrier;
                            }
                            if (tp == "" || tmp.tp != null)
                            {
                                tp = tmp.tp;
                            }
                        }
                    }
                }
                if (bol == ""
                    && carrier == ""
                    && tp == "")
                {
                    ret.state = -4;
                    return ret;
                }
                if (bol != carrier)
                {
                    IList<PakWhLocMasInfo> getLocList = palletRepository.GetPakWhLocMasListByBolAndPlt1(bol, "");
                    if (getLocList.Count > 0)
                    {
                        //成功不需要做分配
                        ret.state = 101;
                        return ret; ;
                    }
                    IList<PakWhLocMasInfo> locList = palletRepository.GetPakWhLocMasListByBolAndPlt1AndCarrier("", "", carrier);
                    if (null == locList ||
                       locList.Count == 0)
                    {
                        ret.state = 3;
                        return ret;
                    }

                    int pltCount=palletRepository.GetCountOfPakWhPltType(bol, "F");
                    foreach (PakWhLocMasInfo aLoc in locList)
                    {
                        if (pltCount == 0)
                            break;
                        palletRepository.UpdatePakWhLocBolByColAndLoc(bol, aLoc.col, aLoc.loc);
                        //Vincent add jaust assign one location for pallet
                        pltCount--;
                    }

                    //成功结束
                    ret.state = 102;
                    return ret;
                }
                else
                {
                    //没有BOL号码,直接分配库位
                    WhPltLogInfo newLog = new WhPltLogInfo();
                    newLog.plt = plt;
                    newLog.editor = editor;
                    newLog.wc = "IN";
                    newLog.cdt = DateTime.Now;
                    palletRepository.InsertWhPltLog(newLog);
                    WhPltMasInfo haveRecord = palletRepository.GetWHPltMas(plt);
                    if (null != haveRecord)
                    {
                        WhPltMasInfo newMasInfo = new WhPltMasInfo();
                        newMasInfo.plt = plt;
                        newMasInfo.editor = editor;
                        newMasInfo.wc = "IN";
                        newMasInfo.udt = DateTime.Now;
                        palletRepository.UpdateWhPltMas(newMasInfo, plt);
                    }
                    else
                    {
                        WhPltMasInfo newMasInfo = new WhPltMasInfo();
                        newMasInfo.plt = plt;
                        newMasInfo.editor = editor;
                        newMasInfo.wc = "IN";
                        newMasInfo.cdt = DateTime.Now;
                        newMasInfo.udt = DateTime.Now;
                        palletRepository.InsertWhPltMas(newMasInfo);
                    }
                    IList<PakWhLocMasInfo> locList = palletRepository.GetPakWhLocMasListByBolAndPlt1AndCarrier("", "", carrier);
                    if (locList.Count == 0)
                    {
                        //此貨代庫位已滿,請自行處理擺放
                        ret.state = 201;
                        return ret;
                    }
                    foreach (PakWhLocMasInfo aLoc in locList)
                    {
                        WhPltLocLogInfo item = new WhPltLocLogInfo();
                        item.plt = plt;
                        item.loc = aLoc.col + aLoc.loc.ToString();
                        palletRepository.InsertWhPltLocLogInfo( item);
                        PakWhLocMasInfo newLoc = new PakWhLocMasInfo();
                        newLoc.plt1 = plt;
                        newLoc.udt = DateTime.Now;
                        newLoc.bol = bol;
                        palletRepository.UpdatePakWhLocByColAndLoc(newLoc, aLoc.col, aLoc.loc);
                        ret.describe = aLoc.col;
                        ret.describe = ret.describe + "#@#";
                        ret.describe = ret.describe + aLoc.loc.ToString();
                        //成功结束,請將此棧板放入'+@col+'區'+@loc+'庫位”
                        ret.state = 103;
                        return ret;
                    }
                    return ret;
                 }
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// not AssignDelivery return > 0
        /// </summary>
        /// <param name="plt">plt</param>
        /// <param name="editor">editor</param>
        public int NonAssignDelivery(string plt, string editor)
        {
            try
            {
                int ret = 0;
                int qty = GetQty(plt);
                if (qty < 5)
                {
                    WhPltLogInfo newLog = new WhPltLogInfo();
                    newLog.plt = plt;
                    newLog.editor = editor;
                    newLog.wc = "IN";
                    newLog.cdt = DateTime.Now;
                    palletRepository.InsertWhPltLog(newLog);
                    WhPltMasInfo haveRecord = palletRepository.GetWHPltMas(plt);
                    if (null != haveRecord)
                    {
                        WhPltMasInfo newMasInfo = new WhPltMasInfo();
                        newMasInfo.plt = plt;
                        newMasInfo.editor = editor;
                        newMasInfo.wc = "IN";
                        newMasInfo.udt = DateTime.Now;
                        palletRepository.UpdateWhPltMas(newMasInfo, plt);
                    }
                    else
                    {
                        WhPltMasInfo newMasInfo = new WhPltMasInfo();
                        newMasInfo.plt = plt;
                        newMasInfo.editor = editor;
                        newMasInfo.wc = "IN";
                        newMasInfo.cdt = DateTime.Now;
                        newMasInfo.udt = DateTime.Now;
                        palletRepository.InsertWhPltMas(newMasInfo);
                    }
                    ret = 1;
                    return ret;
                }
                IList<DummyShipDetInfo> retDummy = palletRepository.GetDummyShipDetListByPlt(plt);
                if (retDummy != null &&
                    retDummy.Count > 0)
                {
                    ret = 2;
                    return ret;
                }
                S_DN_Extended value = GetDN(plt);
                if (value.success == 0)
                {
                    //得不到数据
                    ret = -1;
                    return ret;
                }
                string model = "";
                model = value.modelName;
                if (model == "")
                {
                    ret = -1;
                    return ret;
                }
                if (model != null
                    && model.Length > 2
                    && !model.Substring(0, 2).Equals("PC"))
                {
                    WhPltLogInfo newLog = new WhPltLogInfo();
                    newLog.plt = plt;
                    newLog.editor = editor;
                    newLog.wc = "IN";
                    newLog.cdt = DateTime.Now;
                    palletRepository.InsertWhPltLog(newLog);
                    WhPltMasInfo haveRecord = palletRepository.GetWHPltMas(plt);
                    if (null != haveRecord)
                    {
                        WhPltMasInfo newMasInfo = new WhPltMasInfo();
                        newMasInfo.plt = plt;
                        newMasInfo.editor = editor;
                        newMasInfo.wc = "IN";
                        newMasInfo.udt = DateTime.Now;
                        palletRepository.UpdateWhPltMas(newMasInfo, plt);
                    }
                    else
                    {
                        WhPltMasInfo newMasInfo = new WhPltMasInfo();
                        newMasInfo.plt = plt;
                        newMasInfo.editor = editor;
                        newMasInfo.wc = "IN";
                        newMasInfo.cdt = DateTime.Now;
                        newMasInfo.udt = DateTime.Now;
                        palletRepository.InsertWhPltMas(newMasInfo);
                    }
                    ret = 3;
                    return ret;
                }

                return ret;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Pallet CurrentPallet = (Pallet)CurrentSession.GetValue(Session.SessionKeys.Pallet);
            string palletType = (string)CurrentSession.GetValue("PalletType");
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();

            decimal standWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.StandardWeight);
            decimal acturalWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight); 
            WhPltWeightInfo setValue = new WhPltWeightInfo() ; 
            WhPltWeightInfo condition = new WhPltWeightInfo();

            //4.Update WH_PltWeight
            //ActualPltWeight – 实际重量 (From UI)
           //PltWeightInaccuracy – ABS((实际重量 – 标准重量(ForecasetPltWeight))/ 实际重量)

            setValue.actualPltWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
            setValue.pltWeightInaccuracy = Math.Abs(acturalWeight - standWeight) / acturalWeight;

            condition.plt = CurrentPallet.PalletNo;
            palletRep.UpdateWhPltWeight(setValue, condition);

            //5.Update Pallet
            //Weight – 实际重量
            //Weight_L – (实际重量 – 栈板重量)
            //Station – Pallet Weight 站号
            
            //栈板重量是根据用户选择的[Pallet Type] 查询IMES_GetData..ConstValue 表,得到记录的Value 字段值
            //Condition: IMES_GetData..ConstValue.Name = @PalletType and [Type] = 'PT'
            //当用户没有选择[Pallet Type] 的时候,栈板重量视为0.0
            //Remark: @PalletType – UI 上选择的Pallet Type
            IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            
            ConstValueInfo info = new ConstValueInfo();
            info.type ="PT";
            info.name = palletType;
            
            decimal pweight =0.0m;
            if (CurrentSession.GetValue("Site") != null && CurrentSession.GetValue("Site").ToString() == "ICC")
            {
                pweight = Convert.ToDecimal(CurrentSession.GetValue(Session.SessionKeys.PalletWeight));
            }
            else
            {
                if (!string.IsNullOrEmpty(palletType))
                {
                    IList<ConstValueInfo> retList = partRepository.GetConstValueInfoList(info);
                    pweight = Convert.ToDecimal(retList[0].value);
                }
            }

            if (NeedUpdatePltWeight(CurrentPallet, acturalWeight))
            {
                CurrentPallet.Weight = acturalWeight;
                CurrentPallet.Weight_L = acturalWeight - pweight;
                CurrentPallet.Station = this.Station;
                CurrentPallet.Editor = this.Editor;
                CurrentPallet.Udt = DateTime.Now;

                IPalletRepository PalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                PalletRepository.Update(CurrentPallet, CurrentSession.UnitOfWork);

                //Vincent: Add or Update PalletAttr.Name="SendStatus", PalletAttr.Value=""
                PalletRepository.UpdateAttrDefered(CurrentSession.UnitOfWork, CurrentPallet.PalletNo, "SendStatus", "", "", this.Editor);
            }
            //7.Insert WH_PLTLog
            WhPltLogInfo newLog = new WhPltLogInfo();
            newLog.plt = CurrentPallet.PalletNo;
            newLog.editor = this.Editor;
            newLog.wc = "99";
            newLog.cdt = DateTime.Now;

            palletRep.InsertWhPltLogDefered(CurrentSession.UnitOfWork, newLog);

            return base.DoExecute(executionContext);
        }
Exemplo n.º 6
0
        /// <summary>
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Pallet CurrentPallet = (Pallet)CurrentSession.GetValue(Session.SessionKeys.Pallet);
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();

            decimal standWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.StandardWeight);
            decimal acturalWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
            decimal palletWeight = (decimal)CurrentSession.GetValue("PalletWeight");

            //Update Pallet
            //Weight – 实际重量
            //Weight_L – (实际重量 – 栈板重量)
            //Station – Pallet Weight 站号
           
            CurrentPallet.Weight = acturalWeight;
            CurrentPallet.Weight_L = acturalWeight - palletWeight;
            CurrentPallet.Station = this.Station;
            CurrentPallet.Editor = this.Editor;
            CurrentPallet.Udt = DateTime.Now;

            IPalletRepository PalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            PalletRepository.Update(CurrentPallet, CurrentSession.UnitOfWork);

            //7.Insert WH_PLTLog
            WhPltLogInfo newLog = new WhPltLogInfo();
            newLog.plt = CurrentPallet.PalletNo;
            newLog.editor = this.Editor;
            newLog.wc = "99";
            newLog.cdt = DateTime.Now;

            palletRep.InsertWhPltLogDefered(CurrentSession.UnitOfWork, newLog);

            return base.DoExecute(executionContext);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Write whpltlog
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            if (string.IsNullOrEmpty(PltFromSessionKey))
            {
                PltFromSessionKey = Session.SessionKeys.PalletNo;
            }
            string CurrentPalletNo = CurrentSession.GetValue(PltFromSessionKey) as string;
            
            WhPltLogInfo newLog =  new WhPltLogInfo();
            newLog.plt = CurrentPalletNo;
            newLog.editor = Editor;
            newLog.wc = Station;
            newLog.cdt = DateTime.Now;

            IPalletRepository CurrentRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            CurrentRepository.InsertWhPltLogDefered(CurrentSession.UnitOfWork,newLog);
            return base.DoExecute(executionContext);
        }