hutongqing
2024-12-10 8d341db9d2d5699d527c88c935f0c4ce255a57a4
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs
@@ -23,13 +23,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;
            _recordService = recordService;
        }
        double weightValue = 0.5;
        private readonly static object _locker = new object();
@@ -148,8 +141,9 @@
            return null;
        }
        public void UpdateLocationStatus(string locationCode, PalletTypeEnum palletType, LocationStatusEnum locationStatus, string taskNum = "", string orderNo = "")
        public void UpdateLocationStatus(string locationCode, PalletTypeEnum palletType, LocationStatusEnum locationStatus)
        {
            Dt_LocationInfo location = Repository.QueryFirst(x => x.LocationCode == locationCode);
            List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => x.RoadwayNo == location.RoadwayNo);
@@ -188,6 +182,47 @@
            Repository.UpdateData(locations);
        }
        public void UpdateLocationStatus(Dt_LocationInfo location, PalletTypeEnum palletType, LocationStatusEnum locationStatus)
        {
            List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => x.RoadwayNo == location.RoadwayNo);
            List<Dt_LocationInfo> locations = GetGroupLocations(locationInfos, location);
            if (locationInfos.Max(x => x.Depth) < 3)
            {
                for (int i = 0; i < locations.Count; i++)
                {
                    locations[i].LocationStatus = locationStatus.ObjToInt();
                    locations[i].LocationType = palletType.ObjToInt();
                }
                Dt_LocationInfo? nearLocation = locationInfos.FirstOrDefault(x => x.Row == location.Row && x.Layer == location.Layer && x.Depth == location.Depth && x.Column == location.Column + 1);
                if (nearLocation != null)
                {
                    List<Dt_LocationInfo> nearLocations = GetGroupLocations(locationInfos, nearLocation);
                    for (int i = 0; i < nearLocations.Count; i++)
                    {
                        nearLocations[i].LocationType = palletType.ObjToInt();
                        if (palletType == PalletTypeEnum.LargePallet)
                        {
                            nearLocations[i].LocationStatus = locationStatus.ObjToInt();
                        }
                    }
                    locations.AddRange(nearLocations);
                }
            }
            else
            {
                for (int i = 0; i < locations.Count; i++)
                {
                    locations[i].LocationStatus = locationStatus.ObjToInt();
                    locations[i].LocationType = palletType.ObjToInt();
                }
            }
            Repository.UpdateData(locations);
        }
        private List<Dt_LocationInfo> GetGroupLocations(List<Dt_LocationInfo> locationInfos, Dt_LocationInfo location)
        {
            List<Dt_LocationInfo> groupLocations = new List<Dt_LocationInfo>() { location };