Beispiel #1
0
        public bool ChangeStockGood(uint trackid, uint goodid, bool changedate, DateTime?newdate)
        {
            if (Monitor.TryEnter(_so, TimeSpan.FromSeconds(2)))
            {
                try
                {
                    List <Stock> stocks = StockList.FindAll(c => c.track_id == trackid);
                    foreach (Stock stock in stocks)
                    {
                        if (changedate && newdate != null)
                        {
                            stock.produce_time = newdate;
                        }
                        stock.goods_id = goodid;
                        PubMaster.Mod.GoodSql.EditStock(stock, StockUpE.Goods);
                    }

                    StockSumChangeGood(trackid, goodid);
                    SortSumList();
                    return(true);
                }
                finally { Monitor.Exit(_so); }
            }
            return(false);
        }
Beispiel #2
0
        private DateTime?GetEarliestTime(uint trackid)
        {
            Stock stock = StockList.Find(c => c.track_id == trackid && c.PosType == StockPosE.顶部);

            if (stock != null)
            {
                return(stock.produce_time);
            }
            DateTime?    earytime = null;
            List <Stock> list     = StockList.FindAll(c => c.track_id == trackid);

            foreach (Stock item in list)
            {
                if (earytime == null)
                {
                    earytime = item.produce_time;
                }

                if (earytime is DateTime areat && item.produce_time is DateTime stime)
                {
                    if (stime.CompareTo(areat) < 0)
                    {
                        earytime = stime;
                    }
                }
            }

            return(earytime);
        }
Beispiel #3
0
        public List <Goods> GetStockOutGoodsList(uint filterarea)
        {
            List <uint> goodsids = StockList.FindAll(c => c.area == filterarea &&
                                                     (c.TrackType == TrackTypeE.储砖_出 || c.TrackType == TrackTypeE.储砖_出入)).Select(t => t.goods_id).ToList();

            return(GoodsList.FindAll(c => c.area_id == filterarea && goodsids.Contains(c.id)));
        }
Beispiel #4
0
        /// <summary>
        /// 根据上砖机,品种,分配库存
        /// 1.优先分配,非满砖轨道
        /// 2.在满砖轨道中,分配时间最早的轨道
        /// </summary>
        /// <param name="tilelifterid"></param>
        /// <param name="goodsid"></param>
        /// <param name="stockid"></param>
        /// <param name="taketrackid"></param>
        /// <returns></returns>
        public bool GetStock(uint areaid, uint tilelifterid, uint goodsid, out List <Stock> allocatstocks)
        {
            allocatstocks = new List <Stock>();

            //1.找到上砖机配置的轨道
            List <AreaDeviceTrack> devtrack = PubMaster.Area.GetAreaDevTraList(areaid, tilelifterid);

            //2.根据优先级查看非空且是需求的品种的轨道
            List <Stock> stocks = StockList.FindAll(c => c.goods_id == goodsid &&
                                                    c.PosType == StockPosE.顶部 &&
                                                    devtrack.Exists(d => d.track_id == c.track_id));

            if (stocks.Count == 0)
            {
                //找不到库存
                return(false);
            }

            stocks.Sort((x, y) => x.pos.CompareTo(y.pos));
            //foreach (Stock stock in stocks)
            //{
            //    //优先取非满的轨道
            //    if (stock.pos > 1 && PubMaster.Track.IsTrackHaveStock(stock.track_id)
            //        && PubMaster.Track.IsTrackEnable(stock.track_id))
            //    {
            //        allocatstocks.Add(stock);
            //    }
            //}

            //全部都是满砖,则找时间最早的库存
            stocks.Sort(
                (x, y) =>
            {
                if (x.produce_time is DateTime xtime && y.produce_time is DateTime ytime)
                {
                    return(xtime.CompareTo(ytime));
                }
                return(0);
            }
                );

            int minStockTime = PubMaster.Dic.GetDtlIntCode("MinStockTime");

            foreach (Stock stock1 in stocks)
            {
                if ((DateTime.Now - (DateTime)stock1.produce_time).TotalHours >= minStockTime)
                {
                    if (PubMaster.Track.IsTrackFull(stock1.track_id) &&
                        PubMaster.Track.IsTrackEnable(stock1.track_id, TrackStatusE.仅上砖))
                    {
                        allocatstocks.Add(stock1);
                    }
                }
            }
            return(allocatstocks.Count > 0);
        }
Beispiel #5
0
        /// <summary>
        /// 空砖信号后,情况轨道库存
        /// </summary>
        /// <param name="take_track_id"></param>
        public void ClearTrackEmtpy(uint take_track_id)
        {
            List <Stock> stocks = StockList.FindAll(c => c.track_id == take_track_id);

            if (stocks.Count > 0)
            {
                PubMaster.Mod.GoodSql.DeleteStock(take_track_id);
                StockList.RemoveAll(c => c.track_id == take_track_id);
                RemoveTrackSum(take_track_id);
            }
        }
Beispiel #6
0
 public Stock CheckGetStockTop(uint trackid)
 {
     if (!StockList.Exists(c => c.track_id == trackid && c.PosType == StockPosE.顶部))
     {
         List <Stock> stocks = StockList.FindAll(c => c.track_id == trackid);
         if (stocks.Count > 0)
         {
             stocks.Sort((x, y) => x.pos.CompareTo(y.pos));
             SetStockTop(stocks[0]);
             return(stocks[0]);
         }
     }
     return(StockList.Find(c => c.track_id == trackid && c.PosType == StockPosE.顶部));
 }
Beispiel #7
0
        public void DeleteStockByGid(uint goodid)
        {
            List <Stock> stocks = StockList.FindAll(c => c.goods_id == goodid);

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

            foreach (Stock s in stocks)
            {
                StockList.Remove(s);
                PubMaster.Mod.GoodSql.DeleteStock(s);
                StockSumChange(s, 0);
            }
        }
Beispiel #8
0
        public List <StockGoodPack> GetStockOutGoodsInsList()
        {
            List <StockGoodPack> list = new List <StockGoodPack>();

            foreach (Stock stock in StockList.FindAll(c => c.TrackType == TrackTypeE.储砖_出 || c.TrackType == TrackTypeE.储砖_出入))
            {
                if (!list.Exists(c => c.Area == stock.area && c.GoodsId == stock.goods_id))
                {
                    list.Add(new StockGoodPack()
                    {
                        Area    = stock.area,
                        GoodsId = stock.goods_id
                    });
                }
            }
            return(list);
        }
Beispiel #9
0
        /// <summary>
        /// 倒库/库存信息调整
        /// </summary>
        /// <param name="taketrackid"></param>
        public bool ShiftStock(uint taketrackid, uint givetrackid)
        {
            if (Monitor.TryEnter(_so, TimeSpan.FromSeconds(2)))
            {
                try
                {
                    if (!PubMaster.Track.IsBrotherTrack(taketrackid, givetrackid))
                    {
                        return(false);
                    }

                    //if (PubMaster.Track.IsTrackFull(givetrackid)
                    //    && PubMaster.Track.IsTrackEmtpy(taketrackid))
                    //{
                    //    return true;
                    //}

                    Track givetrack = PubMaster.Track.GetTrack(givetrackid);
                    Track taketrack = PubMaster.Track.GetTrack(taketrackid);
                    if (givetrack != null && taketrack != null &&
                        givetrack.StockStatus == TrackStockStatusE.空砖
                        //&& taketrack.StockStatus == TrackStockStatusE.满砖
                        )
                    {
                        List <Stock> stocks = StockList.FindAll(c => c.track_id == taketrack.id);
                        foreach (Stock stock in stocks)
                        {
                            stock.track_id   = givetrack.id;
                            stock.area       = givetrack.area;
                            stock.track_type = givetrack.type;
                            PubMaster.Mod.GoodSql.EditStock(stock, StockUpE.Track);
                        }

                        PubMaster.Track.ShiftTrack(taketrack.id, givetrack.id);
                        UpdateShiftStockSum(taketrackid, givetrackid, givetrack.type);
                        return(true);
                    }
                }
                finally
                {
                    Monitor.Exit(_so);
                }
            }
            return(false);
        }
Beispiel #10
0
        /// <summary>
        /// 根据上砖机,品种,分配库存
        /// 1.优先分配,非满砖轨道
        /// 2.在满砖轨道中,分配时间最早的轨道
        /// </summary>
        /// <param name="tilelifterid"></param>
        /// <param name="goodsid"></param>
        /// <param name="stockid"></param>
        /// <param name="taketrackid"></param>
        /// <returns></returns>
        public List <Stock> GetStock(uint areaid, uint tilelifterid, uint goodsid)
        {
            //1.找到上砖机配置的轨道
            List <AreaDeviceTrack> devtrack = PubMaster.Area.GetAreaDevTraList(areaid, tilelifterid);

            //2.根据优先级查看非空且是需求的品种的轨道
            List <Stock> stocks = StockList.FindAll(c => c.goods_id == goodsid &&
                                                    c.PosType == StockPosE.顶部 &&
                                                    devtrack.Exists(d => d.track_id == c.track_id));

            if (stocks.Count == 0)
            {
                return(new List <Stock>());
            }

            stocks.Sort((x, y) => x.pos.CompareTo(y.pos));
            //foreach (Stock stock in stocks)
            //{
            //    //优先取非满的轨道
            //    if (stock.pos > 1 && PubMaster.Track.IsTrackHaveStock(stock.track_id)
            //        && PubMaster.Track.IsTrackEnable(stock.track_id))
            //    {
            //        return new List<Stock>() { stock };
            //    }
            //}

            //全部都是满砖,则找时间最早的库存
            stocks.Sort(
                (x, y) =>
            {
                if (x.produce_time is DateTime xtime && y.produce_time is DateTime ytime)
                {
                    return(xtime.CompareTo(ytime));
                }
                return(0);
            }
                );

            return(stocks.FindAll(c => PubMaster.Track.IsTrackEnable(c.track_id)));
        }
Beispiel #11
0
        /// <summary>
        /// 获取轨道库存最大规格
        /// </summary>
        /// <param name="trackid"></param>
        /// <returns></returns>
        private Goods GetTrackGoods(uint trackid)
        {
            uint goodsid = StockList.Find(c => c.track_id == trackid)?.goods_id ?? 0;

            if (goodsid != 0)
            {
                //是否存在不同规格的库存在同一个轨道
                if (StockList.Exists(c => c.track_id == trackid && c.goods_id != goodsid))
                {
                    var goodsids = StockList.FindAll(c => c.track_id == trackid)
                                   .GroupBy(x => new { x.goods_id })
                                   .Select(t => t.Key.goods_id);
                    foreach (var goodid in goodsids)
                    {
                        if (CampareGoodWidth(goodsid, goodid))
                        {
                            goodsid = goodid;
                        }
                    }
                }
                return(GoodsList.Find(c => c.id == goodsid));
            }
            return(null);
        }
Beispiel #12
0
 public List <Stock> GetStocks(uint traid)
 {
     return(StockList.FindAll(c => c.track_id == traid));
 }