zhaowc
2025-04-07 b9f7560cbe0e562a40e9515a0559a3e951f0fee6
Wms/WMS.BLL/DataServer/StockServer.cs
@@ -90,9 +90,27 @@
            //库存总量
            List<MateDataStockDto> StockListDto = new List<MateDataStockDto>();
            DataStockDetail detail = new DataStockDetail();
            foreach (var item in StockList)
            {
                detail = Db.Queryable<DataStockDetail>().First(w => w.SkuNo == item.SkuNo && w.LotNo == item.LotNo && w.IsDel == "0");
                if (detail != null)
                {
                    if (!string.IsNullOrEmpty(detail.ProductionTime.ToString()))
                    {
                        item.ProductionTime = (DateTime)detail.ProductionTime;
                    }
                    if (!string.IsNullOrEmpty(detail.ExpirationTime.ToString()))
                    {
                        item.ExpirationTime = (DateTime)detail.ExpirationTime;
                    }
                    item.InspectStatus = detail.InspectStatus;
                }
                StockListDto.Add(item);
                ////判断库存总量是否拥有物料
                //if (StockListDto.Count > 0)
@@ -238,10 +256,70 @@
                categoryNo = categoryNo,                //逻辑库区
                type = type
            });
            foreach (var item in stockDetailsList)
            {
                if (!string.IsNullOrEmpty(item.LocatNo))
                {
                    if (item.WareHouseNo == "W01")
                    {
                        item.PLCLocatNo = GetDjAdress(item.LocatNo.Substring(1, 2), item.LocatNo.Substring(0, 2), item.LocatNo.Substring(6, 2)).ToString() + item.LocatNo.Substring(2, 2) + item.LocatNo.Substring(4, 2);
                    }
                }
            }
            return stockDetailsList;
        }
        #endregion
        /// <summary>
        /// 根据储位排获取跺机对应的地址排03010302
        /// </summary>
        /// <param name="road">排02</param>
        /// <param name="pai">排03</param>
        /// <param name="dept">深度02</param>
        /// <returns></returns>
        public static int GetDjAdress(string road, string pai, string dept)
        {
            var roadNum = int.Parse(road);
            var paiNum = int.Parse(pai);
            var deptNum = int.Parse(dept);
            var paiVal = 0;
            // 判断排奇偶数
            if (paiNum % 2 == 0)
            {
                if (deptNum == 1)
                {
                    paiVal = 3;
                }
                else
                {
                    paiVal = 4;
                }
            }
            else
            {
                if (deptNum == 1)
                {
                    paiVal = 2;
                }
                else
                {
                    paiVal = 1;
                }
            }
            if (paiVal == 0)
            {
                throw new Exception("排转换失败");
            }
            return paiVal;
        }
        #region 低库存预警
@@ -365,9 +443,12 @@
                //startTime = startTime,
                //endTime = endTime
            });
            DataStock stock = new DataStock();
            stock = Db.Queryable<DataStock>().First();
            //合并数据
            int a = 0;
            decimal qty = 0;
            foreach (var h in totalHListData)
            {
                if (a >= totalCListData.Count)
@@ -376,16 +457,23 @@
                }
                foreach (var c in totalCListData)
                {
                    //判断出库是否拥有相同批次 且物料相同
                    if (h.LotNo == c.LotNo)
                    {
                        if (h.SkuNo == c.SkuNo && h.SkuName == c.SkuName)
                        {
                            stock = Db.Queryable<DataStock>().First(w=>w.SkuNo == h.SkuNo && w.SkuName == h.SkuName && w.LotNo == h.LotNo && w.IsDel == "0");
                            if (stock != null)
                            {
                                qty = stock.Qty;
                            }
                            h.CQty = c.CQty; //出库数量
                            h.CAllotQty = c.CAllotQty; //分配数量
                            h.CFactQty = c.CFactQty; //下架数量
                            h.CompleteQty = c.CompleteQty; //拣货数量
                            //h.SONo = c.SONo; //出库单号
                            h.Qty = qty;  //当前库存
                            a += 1;