1
yangpeixing
2026-04-01 f1bf3ef09713182d434e22dfd8623ea73e02d6d3
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs
@@ -1,6 +1,8 @@
using AutoMapper;
using Microsoft.AspNetCore.Http.Metadata;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -13,8 +15,8 @@
using WIDESEA_Core.Utilities;
using WIDESEA_DTO.Basic;
using WIDESEA_IBasicRepository;
using WIDESEA_IRecordService;
using WIDESEA_IBasicService;
using WIDESEA_IRecordService;
using WIDESEA_Model.Models;
namespace WIDESEA_BasicService
@@ -22,7 +24,6 @@
    public partial class LocationInfoService : ServiceBase<Dt_LocationInfo, ILocationInfoRepository>, ILocationInfoService
    {
        private readonly IRecordService _recordService;
        public LocationInfoService(ILocationInfoRepository BaseDal, IBasicRepository basicRepository, IRecordService recordService) : base(BaseDal)
        {
            _basicRepository = basicRepository;
@@ -54,7 +55,7 @@
                        throw new Exception("区域被禁用,不可入库");
                    }
                }
                if (inboundType == TaskTypeEnum.PalletInbound.ObjToInt())//空盘入库分配逻辑
                if (inboundType == TaskTypeEnum.Inbound.ObjToInt())//空盘入库分配逻辑
                {
                    return EmptyAssignLocation(roadwayInfo.RoadwayNo);
                }
@@ -276,5 +277,50 @@
            _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locations, beforeEndStatus, StockChangeType.Relocation.ObjToInt(), "", TaskNum);
        }
        /// <summary>
        /// 货位警告
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent LocationWarning()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<Dt_Warehouse> warehouses = BaseDal.Db.Queryable<Dt_Warehouse>().ToList();
                List<string> locationWarning = new List<string>();
                foreach (var item in warehouses)
                {
                    for(var i = 1; i < 3; i++)
                    {
                        int inStockNum = 0;
                        List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.WarehouseId == item.WarehouseId && x.Row == i);
                        if(locationInfos != null && locationInfos.Count() != 0)
                        {
                            foreach (var item1 in locationInfos)
                            {
                                if (item1.LocationStatus == 2)
                                {
                                    inStockNum++;
                                }
                            }
                            if (inStockNum != 0 && (double)inStockNum/locationInfos.Count() >= 0.8)
                            {
                                var locationName = $"{item.WarehouseName},第{i}排";
                                locationWarning.Add(locationName);
                            }
                        }
                    }
                }
                return content.OK(data: locationWarning);
            }
            catch (Exception ex)
            {
                return content.Error();
            }
        }
    }
}