From 6e9f630e4e12738d98241b684e6227e02010b6c5 Mon Sep 17 00:00:00 2001 From: Huangxiaoqiang-03 <1247017146@qq.com> Date: 星期五, 01 十一月 2024 17:30:30 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 174 insertions(+), 3 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs" index cf58bf1..a88d978 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs" @@ -1,16 +1,19 @@ -锘縰sing SqlSugar; +锘縰sing AutoMapper; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core; +using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Core.Enums; using WIDESEA_Core.Helper; using WIDESEA_Core.Utilities; using WIDESEA_DTO.Basic; using WIDESEA_IBasicRepository; +using WIDESEA_IRecordService; using WIDESEA_IBasicService; using WIDESEA_Model.Models; @@ -18,7 +21,12 @@ { 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; + } private Dictionary<string, OrderByType> _emptyAssignOrderBy = new Dictionary<string, OrderByType>() { { nameof(Dt_LocationInfo.Depth), OrderByType.Desc }, @@ -60,6 +68,10 @@ return null; } + public virtual Dt_LocationInfo? AssignLocation(string RoadwayNo) + { + return StoredAssignLocation(RoadwayNo); + } private Dt_LocationInfo EmptyAssignLocation(string roadway) { @@ -84,7 +96,7 @@ private Dt_LocationInfo StoredAssignLocation(string roadway) { List<LocationGroupDTO> locationGroups = BaseDal.GetLocationGroups(roadway, LocationStatusEnum.Free, LocationStatusEnum.InStock); - if (locationGroups != null) + if (locationGroups != null && locationGroups.Count > 0) { LocationGroupDTO? locationGroup = locationGroups.FirstOrDefault(x => x.EnableStatusA == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatusA == EnableStatusEnum.Normal.ObjToInt()); int id = locationGroup?.IdA ?? 0; @@ -111,5 +123,164 @@ { return BaseDal.QueryFirst(x => x.RoadwayNo == locationInfo.RoadwayNo && x.Column == locationInfo.Column && x.Layer == locationInfo.Layer && x.Depth != locationInfo.Depth && x.Row != locationInfo.Row && (SqlFunc.Abs(x.Row - locationInfo.Row) == 1)); } + public void UpdateLocationLock(Dt_LocationInfo locations, int TaskNum,int changType,bool black) + { + try + { + if (black) + { + (Dt_LocationInfo?, int?) result = isDepth(locations); + if (result.Item1 != null && (result.Item2 == LocationStatusEnum.Free.ObjToInt()|| result.Item2 == LocationStatusEnum.Lock.ObjToInt())) + { + int beforeStatusEnd = result.Item1.LocationStatus; + + result.Item1.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + + BaseDal.UpdateData(result.Item1); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result.Item1, beforeStatusEnd, changType, "", TaskNum); + } + } + else + { + (Dt_LocationInfo?, int?) result = isDepth(locations); + if (result.Item1 != null && result.Item2 == LocationStatusEnum.Free.ObjToInt()) + { + int beforeStatusEnd = result.Item1.LocationStatus; + + result.Item1.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + + BaseDal.UpdateData(result.Item1); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result.Item1, beforeStatusEnd, changType, "", TaskNum); + } + } + + } + catch (Exception ex) + { + throw ex; + } + + } + public void UpdateLocationFree(Dt_LocationInfo locations, int TaskNum, int changType,bool black) + { + try + { + (Dt_LocationInfo?, int?) result = isDepth(locations); + if (result.Item1 != null) + { + int beforeStatusEnd = result.Item1.LocationStatus; + + result.Item1.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + + BaseDal.UpdateData(result.Item1); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result.Item1, beforeStatusEnd, changType, "", TaskNum); + } + } + catch (Exception ex) + { + throw ex; + } + + } + public (Dt_LocationInfo?,int?) isDepth(Dt_LocationInfo locationInfo) + { + if (locationInfo.Depth == 2) + { + if (locationInfo.Row == 1 || locationInfo.Row == 5) + { + Dt_LocationInfo dt_LocationInfo = BaseDal.QueryFirst(x => x.Row == locationInfo.Row + 1 && x.Layer == locationInfo.Layer && x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo); + + if (dt_LocationInfo != null&& dt_LocationInfo.LocationStatus==LocationStatusEnum.InStock.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.InStock.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.Free.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.Lock.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.PalletLock.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.Pallet.ObjToInt()); + } + } + else if (locationInfo.Row == 4 || locationInfo.Row == 8) + { + Dt_LocationInfo dt_LocationInfo = BaseDal.QueryFirst(x => x.Row == locationInfo.Row + 1 && x.Layer == locationInfo.Layer && x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo); + + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.InStock.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.Free.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.Lock.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.PalletLock.ObjToInt()); + } + if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) + { + return (dt_LocationInfo, LocationStatusEnum.Pallet.ObjToInt()); + } + } + } + return (null, LocationStatusEnum.Free.ObjToInt()); + } + public void RelocationLock(Dt_LocationInfo locationInfo, Dt_LocationInfo locationInfos, int TaskNum) + { + int beforeStartStatus = locationInfo.LocationStatus; + int beforeEndStatus = locationInfos.LocationStatus; + + locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + + if (beforeStartStatus == LocationStatusEnum.Pallet.ObjToInt()) + { + locationInfos.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); + } + else + { + locationInfos.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + } + + BaseDal.UpdateData(locationInfo); + BaseDal.UpdateData(locationInfos); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStartStatus, StockChangeType.Relocation.ObjToInt(), "", TaskNum); + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, beforeEndStatus, StockChangeType.Relocation.ObjToInt(), "", TaskNum); + } + public void RelocationFree(Dt_LocationInfo locations, int TaskNum) + { + int beforeEndStatus = locations.LocationStatus; + + if(locations.LocationStatus== LocationStatusEnum.Lock.ObjToInt()) + { + locations.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + } + else + { + locations.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); + } + + + BaseDal.UpdateData(locations); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locations, beforeEndStatus, StockChangeType.Relocation.ObjToInt(), "", TaskNum); + } } } -- Gitblit v1.9.3