From fe256a7afaa132910875d3dc73783d9ab2d7ace5 Mon Sep 17 00:00:00 2001
From: liulijun <liulijun@hnkhzn.com>
Date: 星期四, 12 三月 2026 18:57:44 +0800
Subject: [PATCH] 老厂排程单页面增加用纸顺序号和是否缺料

---
 项目代码/WMS/WMSServices/WIDESEA_BasicService/Base/LocationInfoService.cs |  176 ++++++++++++++++++----------------------------------------
 1 files changed, 56 insertions(+), 120 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/Base/LocationInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/Base/LocationInfoService.cs"
index b291525..0f6bef4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/Base/LocationInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/Base/LocationInfoService.cs"
@@ -32,13 +32,65 @@
         private readonly IUnitOfWorkManage _unitOfWorkManage;
         private readonly IBasicRepository _basicRepository;
         private readonly IStockInfoRepository _stockInfoRepository;
+        private readonly IProStockInfoRepository _proStockInfoRepository;
         public ILocationInfoRepository Repository => BaseDal;
 
-        public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository, IStockInfoRepository stockInfoRepository) : base(BaseDal)
+        public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository, IStockInfoRepository stockInfoRepository, IProStockInfoRepository proStockInfoRepository) : base(BaseDal)
         {
             _unitOfWorkManage = unitOfWorkManage;
             _basicRepository = basicRepository;
             _stockInfoRepository = stockInfoRepository;
+            _proStockInfoRepository = proStockInfoRepository;
+        }
+
+        /// <summary>
+        /// 鏌ヨ璐т綅瀵瑰簲鐨凴FID
+        /// </summary>
+        /// <param name="locationCodes"></param>
+        /// <returns></returns>
+        public WebResponseContent GetRfid(string[] locationCodes, int warehouseId = 0)
+        {
+            try
+            {
+                // 鍙傛暟楠岃瘉
+                if (locationCodes == null || locationCodes.Length == 0)
+                {
+                    return WebResponseContent.Instance.Error("璐т綅缂栧彿涓嶈兘涓虹┖");
+                }
+
+                if (warehouseId == 1)
+                {
+                    // 鏌ヨ鍘熸枡搴揇t_StockInfo琛紝鑾峰彇RFID淇℃伅
+                    var rawMaterialRfidList = _stockInfoRepository.QueryData()
+                        .Where(x => locationCodes.Contains(x.LocationCode))
+                        .Select(x => new { x.LocationCode, x.RfidCode })
+                        .ToList();
+
+                    var rfidList = rawMaterialRfidList.ToList();
+                    // 杩斿洖缁撴灉
+                    return WebResponseContent.Instance.OK(data: rfidList);
+                }
+
+                if (warehouseId == 2)
+                {
+                    // 鏌ヨ鎴愬搧搴揇t_ProStockInfo琛紝鑾峰彇PalletCode淇℃伅
+                    var finishedProductRfidList =_proStockInfoRepository.QueryData()
+                        .Where(x => locationCodes.Contains(x.LocationCode))
+                        .Select(x => new { x.LocationCode, RfidCode = x.PalletCode })
+                        .ToList();
+
+                    var rfidList = finishedProductRfidList.ToList();
+                    // 杩斿洖缁撴灉
+                    return WebResponseContent.Instance.OK(data: rfidList);
+                }
+                // 濡傛灉娌℃湁鍖归厤鐨勪粨搴揑D锛岃繑鍥炵┖鍒楄〃
+                return WebResponseContent.Instance.OK(data: new List<object>());
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"GetRfid 寮傚父: {ex.Message}");
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
         }
 
         /// <summary>
@@ -94,122 +146,6 @@
         {
             return LocationDisableStatus(new int[] { key });
         }
-
-        /// <summary>
-        /// 鑾峰彇杈呮枡浠撳簱瀛�
-        /// </summary>
-        /// <returns></returns>
-        public WebResponseContent GetContainerInfo()
-        {
-            try
-            {
-                SqlSugarClient TesugarClient = new SqlSugarClient(new ConnectionConfig
-                {
-                    ConfigId = MainDb.CurrentDbConnId,
-                    ConnectionString = AppSettings.Get("TeConnectionString").DecryptDES(AppSecret.DB),
-                    IsAutoCloseConnection = true,
-                    DbType = MainDb.DbType,
-                });
-
-                var ContainerInfos = TesugarClient.Queryable("ContainerInfo", "x").Where("WaId", "=", 8).Where("UpState", "=", 2).ToList();
-                if (ContainerInfos != null)
-                {
-                    List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
-                    foreach (var item in ContainerInfos)
-                    {
-                        dynamic ruleConfig = item;
-                        int id = ruleConfig.CId;//涓婚敭
-                        string BoxNo = ruleConfig.BoxNo;//绠卞彿
-                        string LNo = ruleConfig.LNo;//璐т綅缂栧彿
-                        Dt_StockInfo stockInfo = new Dt_StockInfo()
-                        {
-                            LocationCode = LNo == "骞冲簱浣�" ? LNo : GetLocationCode(LNo),
-                            PalletCode = BoxNo,
-                            StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(),
-                            WarehouseId = 5,
-                            PalletType = PalletTypeEnum.LargestPallet.ObjToInt(),
-                            Details = new List<Dt_StockInfoDetail>()
-                        };
-                        var ContainerDetailsInfos = TesugarClient.Queryable("ContainerDetailsInfo", "x").Where("CId", "=", id).ToList();
-                        if (ContainerDetailsInfos.Count < 1) stockInfo.PalletType = PalletTypeEnum.Empty.ObjToInt();
-                        foreach (var ContainerDetailsInfo in ContainerDetailsInfos)
-                        {
-                            dynamic ruleConfig1 = ContainerDetailsInfo;
-                            string MaterialCode = ruleConfig1.MaterialCode;//鐗╂枡缂栧彿
-                            string MaterialName = ruleConfig1.MaterialName;//鐗╂枡鍚嶇О
-                            string MaterialLot = ruleConfig1.MaterialLot;//鐗╂枡鎵瑰彿
-                            var PackQty = ruleConfig1.PackQty;//鏁伴噺
-                            string ProduceData = ruleConfig1.ProduceData;//鐢熸垚鏃ユ湡
-                            string ValidData = ruleConfig1.ValidData;//鏈夋晥鏈�
-                            string Unit = ruleConfig1.Unit;//鍗曚綅
-                            string Standard = ruleConfig1.Standard;//澶囨敞
-                            int MId = ruleConfig1.MId;//鍏ュ簱鍗曟槑缁嗚鍙�
-                            string Model = ruleConfig1.Model;//鍗曟嵁缂栧彿
-                            Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
-                            {
-                                MaterielCode = MaterialCode,
-                                MaterielName = MaterialName,
-                                BatchNo = MaterialLot,
-                                OrderNo = Model,
-                                SerialNumber = "",
-                                StockQuantity = (float)PackQty,
-                                OutboundQuantity = 0,
-                                Unit = Unit,
-                                Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(),
-                                ProductionDate = ProduceData,
-                                EffectiveDate = ValidData ?? DateTime.Parse(ProduceData).AddYears(2).ToString("yyyy-MM-dd"),
-                                Remark = Standard,
-                                InboundOrderRowNo = MId,
-                            };
-                            stockInfo.Details.Add(stockInfoDetail);
-                        }
-                        stockInfos.Add(stockInfo);
-                    }
-                    var LocationCodes = stockInfos.Where(x => x.LocationCode != "骞冲簱浣�").Select(stockInfo => stockInfo.LocationCode).ToList();
-                    List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => LocationCodes.Contains(x.LocationCode));
-                    locationInfos.ForEach(x =>
-                    {
-                        x.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
-                        x.EnableStatus = EnableStatusEnum.Normal.ObjToInt();
-                    });
-                    _unitOfWorkManage.BeginTran();
-                    _stockInfoRepository.Db.InsertNav(stockInfos).Include(x => x.Details).ExecuteCommand();
-                    Repository.UpdateData(locationInfos);
-                    _unitOfWorkManage.CommitTran();
-                }
-            }
-            catch (Exception ex)
-            {
-                _unitOfWorkManage.RollbackTran();
-                return WebResponseContent.Instance.Error(ex.Message);
-            }
-            return WebResponseContent.Instance.OK();
-        }
-        /// <summary>
-        /// 鑾峰彇璐т綅缂栧彿
-        /// </summary>
-        /// <param name="locationCode"></param>
-        /// <returns></returns>
-        string GetLocationCode(string locationCode)
-        {
-            var a = locationCode.Substring(0, 1);
-            var Row = a switch
-            {
-                "A" => "001",
-                "B" => "002",
-                "C" => "003",
-                "D" => "004",
-                "E" => "005",
-                _ => throw new Exception($"鏈畾涔夌殑鎺�,鍦板潃:銆恵locationCode}銆�"),
-            };
-            var Column = locationCode.Substring(4, 2);
-            if (locationCode.Length == 7)
-                Column = locationCode.Substring(5, 2);
-            var Layer = locationCode.Substring(2, 2);
-            locationCode = "AGV_FL-" + Row + "-0" + Column + "-0" + Layer + "-01";
-            return locationCode;
-        }
-
         /// <summary>
         /// 鍒濆鍖栬揣浣�
         /// </summary>
@@ -249,7 +185,7 @@
                             Dt_LocationInfo locationInfo = new Dt_LocationInfo()
                             {
                                 WarehouseId = 0,
-                                Column = j + 1,
+                                Columns = j + 1,
                                 EnableStatus = EnableStatusEnum.Normal.ObjToInt(),
                                 Layer = k + 1,
                                 LocationStatus = LocationStatusEnum.Free.ObjToInt(),
@@ -258,8 +194,8 @@
                                 Row = i + 1,
                                 Depth = depth,
                             };
-                            locationInfo.LocationCode = $"{locationInfo.RoadwayNo}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Column.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
-                            locationInfo.LocationName = $"{locationInfo.RoadwayNo}宸烽亾{locationInfo.Row.ToString().PadLeft(3, '0')}琛寋locationInfo.Column.ToString().PadLeft(3, '0')}鍒梴locationInfo.Layer.ToString().PadLeft(3, '0')}灞倇locationInfo.Depth.ToString().PadLeft(2, '0')}娣�";
+                            locationInfo.LocationCode = $"{locationInfo.RoadwayNo}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Columns.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
+                            locationInfo.LocationName = $"{locationInfo.RoadwayNo}宸烽亾{locationInfo.Row.ToString().PadLeft(3, '0')}琛寋locationInfo.Columns.ToString().PadLeft(3, '0')}鍒梴locationInfo.Layer.ToString().PadLeft(3, '0')}灞倇locationInfo.Depth.ToString().PadLeft(2, '0')}娣�";
                             locationInfos.Add(locationInfo);
                         }
                     }

--
Gitblit v1.9.3