From 63dcb7fc55d32960f643f4040900ce9a0e33536d Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期一, 20 十月 2025 17:25:56 +0800
Subject: [PATCH] 1

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs |   49 +++++++++++++------------------------------------
 1 files changed, 13 insertions(+), 36 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs"
index 05f4ba4..f3d46da 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs"
@@ -1,6 +1,7 @@
 锘縰sing AngleSharp.Dom;
 using Mapster;
 using Masuit.Tools;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
 using SqlSugar;
 using System.Collections;
 using System.Collections.Generic;
@@ -10,17 +11,15 @@
 using WIDESEA_Cache;
 using WIDESEA_Common;
 using WIDESEA_Core;
+using WIDESEA_Model.Models;
 
 namespace WIDESEA_StorageBasicService;
 
 public class StockInfoService : ServiceBase<DtStockInfo, IStockInfoRepository>, IStockInfoService
 {
-
-    private readonly ISimpleCacheService _simpleCacheService;
     private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
-    public StockInfoService(IStockInfoRepository BaseDal, ISimpleCacheService simpleCacheService, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal)
+    public StockInfoService(IStockInfoRepository BaseDal, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal)
     {
-        _simpleCacheService = simpleCacheService;
         _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository;
     }
 
@@ -33,7 +32,7 @@
     {
         string wheres = ValidatePageOptions(options);
         //鑾峰彇鎺掑簭瀛楁
-        Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+        Dictionary<string, OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
         List<OrderByModel> orderByModels = new List<OrderByModel>();
         foreach (var item in orderbyDic)
         {
@@ -59,21 +58,16 @@
         }
 
         Expression<Func<DtStockInfo, bool>> locationStatus = null;
-        Expression<Func<DtStockInfo, bool>> roadwayNo = null;
-        Expression<Func<DtStockInfo, bool>> materielCode = null;
+        Expression<Func<DtStockInfo, bool>> floor = null;
         foreach (var item in searchParametersList)
         {
             if (item.Name.Contains("locationStatus"))
             {
                 locationStatus = x => x.LocationInfo.LocationStatus == Convert.ToInt32(item.Value);
             }
-            else if (item.Name.Contains("roadwayNo"))
+            else if (item.Name.Contains("floor"))
             {
-                roadwayNo = x => x.LocationInfo.RoadwayNo.Contains(item.Value);
-            }
-            else if (item.Name.Contains("materielCode"))
-            {
-                materielCode = x => x.StockInfoDetails.Any(d => d.MaterielCode.Contains(item.Value));
+                floor = x => x.LocationInfo.Floor.Contains(item.Value);
             }
         }
         //.IncludesAllFirstLayer()
@@ -82,8 +76,7 @@
             .Includes(x => x.LocationInfo)
             .WhereIF(!wheres.IsNullOrEmpty(), wheres)
             .WhereIF(locationStatus != null, locationStatus)
-            .WhereIF(roadwayNo != null, roadwayNo)
-            .WhereIF(materielCode != null, materielCode)
+            .WhereIF(floor != null, floor)
             .OrderBy(orderByModels)
             .ToPageList(options.Page, options.Rows, ref totalCount);
         new PageGridData<DtStockInfo>(totalCount, data);
@@ -108,15 +101,16 @@
                 var stockHty = stock.Adapt<DtStockInfo_Hty>();
                 stockInfos.Add(stockHty);
 
-                var location = SqlSugarHelper.DbWMS.Queryable<DtLocationInfo>().FirstAsync(x => x.Id == stock.LocationId).Result;
+                var location = SqlSugarHelper.DbWMS.Queryable<DtLocationInfo>().FirstAsync(x => x.LocationCode == stock.LocationCode).Result;
                 var lastStatus = location.LocationStatus;
                 location.LocationStatus = (int)LocationEnum.Free;
                 locationInfos.Add(location);
                 _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0);
             }
-            var hty = BaseDal.Db.InsertNav(stockInfos)
-                .Include(x => x.StockInfoDetails)
-                .ExecuteCommand();
+            //var hty = BaseDal.Db.InsertNav(stockInfos)
+            //    .Include(x => x.StockInfoDetails)
+            //    .ExecuteCommand();
+            var isStockAdd = SqlSugarHelper.DbWMS.InsertNav(stockInfos).IncludesAllFirstLayer().ExecuteCommandAsync();
 
             var locationd = SqlSugarHelper.DbWMS.Updateable(locationInfos).ExecuteCommandHasChange();
             return base.DeleteData(keys);
@@ -126,21 +120,4 @@
             return WebResponseContent.Instance.Error(ex.Message);
         }
     }
-
-    // 鏍规嵁浼犲叆搴撳瓨绫诲瀷鑾峰彇涓嶅悓宸烽亾鐨勫簱瀛�
-    public async Task<Dictionary<string, int>> GetLocationByStockType(bool stockType, string areaCode)
-    {
-        var stockInfos = await BaseDal.Db.Queryable<DtStockInfo>().Where(x => x.IsFull == stockType && x.AreaCode == areaCode)
-            .Includes(x => x.LocationInfo).ToListAsync();
-
-        var result = stockInfos
-            .GroupBy(x => x.LocationInfo.RoadwayNo)
-            .ToDictionary(x => x.Key, x => x.Count());
-        return result;
-    }
-
-    //public override WebResponseContent UpdateData(DtStockInfo entity)
-    //{
-    //    return base.UpdateData(entity);
-    //}
 }
\ No newline at end of file

--
Gitblit v1.9.3