Esempio n. 1
0
        public bool EditGood(Goods good, out string result)
        {
            if (!Monitor.TryEnter(_go, TimeSpan.FromSeconds(2)))
            {
                result = "";
                return(false);
            }
            try
            {
                Goods g = GoodsList.Find(c => c.id == good.id);
                if (g != null)
                {
                    g.name        = good.name;
                    g.color       = good.color;
                    g.width       = good.width;
                    g.length      = good.length;
                    g.oversize    = good.oversize;
                    g.memo        = good.memo;
                    g.stack       = good.stack;
                    g.pieces      = good.pieces;
                    g.carriertype = good.carriertype;
                    g.updatetime  = DateTime.Now;
                    PubMaster.Mod.GoodSql.EditGoods(g);
                    SendMsg(g, ActionTypeE.Update);
                    PubMaster.Dic.UpdateVersion(DicTag.PDA_GOOD_VERSION);
                    result = "";
                    return(true);
                }
            }
            finally { Monitor.Exit(_go); }

            result = "找不到该品种信息:" + good.name;
            return(false);
        }
Esempio n. 2
0
        public void CheckTrackSum(uint trackId)
        {
            StockSum sum = StockSumList.Find(c => c.track_id == trackId);

            uint goodsid = StockList.Find(c => c.track_id == trackId && c.goods_id != 0)?.goods_id ?? 0;

            if (sum == null)
            {
                Track track = PubMaster.Track.GetTrack(trackId);
                sum = new StockSum()
                {
                    track_id     = trackId,
                    goods_id     = goodsid,
                    produce_time = StockList.Find(c => trackId == c.track_id).produce_time,
                    area         = track.area,
                    track_type   = track.type
                };
                StockSumList.Add(sum);
                SortSumList();
            }
            if (goodsid > 0)
            {
                Goods goods = GoodsList.Find(c => c.id == goodsid);
                if (goods != null)
                {
                    sum.count  = (uint)StockList.Count(c => c.track_id == trackId);
                    sum.stack  = sum.count * goods.stack;
                    sum.pieces = sum.stack * goods.pieces;
                    SendSumMsg(sum, ActionTypeE.Update);
                }
            }
        }
Esempio n. 3
0
        private bool CampareGoodWidth(uint one, uint two)
        {
            Goods goodonw = GoodsList.Find(c => c.id == one);
            Goods goodtwo = GoodsList.Find(c => c.id == two);

            if (goodonw != null && goodtwo != null)
            {
                return(goodonw.width < goodtwo.width);
            }
            return(false);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public CarrierTypeE GetGoodsCarrierType(uint goods_id)
 {
     return(GoodsList.Find(c => c.id == goods_id).GoodCarrierType);
 }
Esempio n. 6
0
 public Goods GetGoods(uint id)
 {
     return(GoodsList.Find(c => c.id == id));
 }
Esempio n. 7
0
 private byte GetGoodStack(uint goodid)
 {
     return(GoodsList.Find(c => c.id == goodid)?.stack ?? 1);
 }
Esempio n. 8
0
 public bool IsGoodsOverSize(uint goods_id)
 {
     return(GoodsList.Find(c => c.id == goods_id)?.oversize ?? true);
 }
Esempio n. 9
0
 public byte GetGoodsPieces(uint goodid)
 {
     return((byte)(GoodsList.Find(c => c.id == goodid)?.pieces ?? 0));
 }
Esempio n. 10
0
 public string GetGoodsName(uint Goods_id)
 {
     return(GoodsList.Find(c => c.id == Goods_id)?.name ?? "");
 }
Esempio n. 11
0
        public bool IsTrackOkForGoods(uint trackid, uint goodsid)
        {
            Goods goods = GoodsList.Find(c => c.id == goodsid);

            if (goods == null)
            {
                return(false);
            }

            Track track = PubMaster.Track.GetTrack(trackid);

            if (track == null)
            {
                return(false);
            }

            bool isleftok = true, isrightok = true;

            #region [判断轨道能不能放砖]

            if (track.left_track_id == 0)
            {
                if (CheckTrackAndGood(track.width, goods.width, track.left_distance))
                {
                    return(false);
                }
            }

            if (track.right_track_id == 0)
            {
                if (CheckTrackAndGood(track.width, goods.width, track.right_distance))
                {
                    return(false);
                }
            }

            #endregion

            #region [判断隔壁轨道是否碰撞]

            Track ltrack = PubMaster.Track.GetTrack(track.left_track_id);
            Track rtrack = PubMaster.Track.GetTrack(track.right_track_id);

            if (ltrack != null)
            {
                //判断左兄弟轨道
                Goods leftgoods = GetTrackGoods(ltrack.id);
                if (leftgoods == null && ltrack.StockStatus == TrackStockStatusE.砖)
                {
                    leftgoods = PubMaster.Goods.GetGoods(ltrack.recent_goodid);
                }
                if (leftgoods != null)
                {
                    isleftok = IsGoodsDistanceOk(ltrack, leftgoods, track, goods);
                }
            }

            if (rtrack != null)
            {
                Goods rightgoods = GetTrackGoods(rtrack.id);
                if (rightgoods == null && rtrack.StockStatus == TrackStockStatusE.砖)
                {
                    rightgoods = PubMaster.Goods.GetGoods(rtrack.recent_goodid);
                }
                if (rightgoods != null)
                {
                    isrightok = IsGoodsDistanceOk(track, goods, rtrack, rightgoods);
                }
            }
            #endregion

            return(isleftok && isrightok);
        }