xiazhengtongxue
2026-02-09 e81c782b3e7a632ffb8e32be56fce931a8c89ae6
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_BasicInfoService/LocationInfoService.cs
@@ -1,22 +1,17 @@
using HslCommunication.WebSocket;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using NPOI.SS.UserModel;
using NPOI.Util.Collections;
using NPOI.XSSF.UserModel;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using System.Reflection;
using WIDESEA_DTO.Basic;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.WareHouseEnum;
using WIDESEAWCS_Common.Helper;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.Utilities;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
@@ -29,7 +24,7 @@
        public DateTime DateTime { get; set; }
    }
    public partial class LocationInfoService : ServiceBase<Dt_LocationInfo, ILocationInfoRepository>, ILocationInfoService
    public class LocationInfoService : ServiceBase<Dt_LocationInfo, ILocationInfoRepository>, ILocationInfoService
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        public ILocationInfoRepository Repository => BaseDal;
@@ -112,12 +107,26 @@
                Dictionary<string, OrderByType> orderBy = new Dictionary<string, OrderByType>()
                {
                    { nameof(Dt_LocationInfo.Row),OrderByType.Asc },
                    { nameof(Dt_LocationInfo.Layer),OrderByType.Asc },
                    { nameof(Dt_LocationInfo.Row),OrderByType.Asc },
                    { nameof(Dt_LocationInfo.Columns),OrderByType.Desc },
                };
                Dt_LocationInfo locationInfo = BaseDal.QueryFirst(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt() && !lockLocations.Contains(x.LocationCode), orderBy);//查询空货位信息并排除5分钟内分配的货位,根据层、列、深度、行排序
                //Dt_LocationInfo locationInfo = BaseDal.QueryFirst(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt() && !lockLocations.Contains(x.LocationCode), orderBy);//查询空货位信息并排除5分钟内分配的货位,根据层、列、深度、行排序
                // åˆå¹¶æŸ¥è¯¢æ¡ä»¶ï¼Œä¼˜å…ˆ44~48列,若无则查全部
                Dt_LocationInfo locationInfo = BaseDal.QueryFirst(
                    x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()
                        && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt()
                        && !lockLocations.Contains(x.LocationCode)
                        && (x.Columns >= 44 && x.Columns <= 48), // ä¼˜å…ˆ44~48列的条件
                    orderBy)
                    ??
                    BaseDal.QueryFirst(
                        x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()
                            && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt()
                            && !lockLocations.Contains(x.LocationCode),
                        orderBy);
                if (locationInfo!=null)
                {
                    LocationCache locationCache = new LocationCache()
@@ -188,5 +197,30 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public override WebResponseContent Export(PageDataOptions options)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport";
                // ç¡®ä¿ç›®å½•存在
                if (!Directory.Exists(savePath))
                    Directory.CreateDirectory(savePath);
                // èŽ·å–æ•°æ®
                ISugarQueryable<Dt_LocationInfo> query = BaseDal.Db.Queryable<Dt_LocationInfo>();
                var dataList = query.ToList();
                var properties = typeof(Dt_LocationInfo).GetProperties();
                string filePath = TExportHelper.GetExport(savePath, properties, dataList);
                return WebResponseContent.Instance.OK(data: filePath);
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
    }
}