Example #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);
            }
        }
Example #2
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);
            }
        }