| | |
| | | 锘縰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; |
| | | |
| | |
| | | { |
| | | 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 }, |
| | |
| | | |
| | | return null; |
| | | } |
| | | public virtual Dt_LocationInfo? AssignLocation(string RoadwayNo) |
| | | { |
| | | return StoredAssignLocation(RoadwayNo); |
| | | } |
| | | |
| | | private Dt_LocationInfo EmptyAssignLocation(string roadway) |
| | | { |
| | |
| | | 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; |
| | |
| | | { |
| | | 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 |
| | | { |
| | | Dt_LocationInfo result = isDepth(locations); |
| | | int beforeStatusEnd = 0; |
| | | if (black) |
| | | { |
| | | if (result != null && (result.LocationStatus == LocationStatusEnum.Free.ObjToInt()|| result.LocationStatus == LocationStatusEnum.Lock.ObjToInt())) |
| | | { |
| | | beforeStatusEnd = result.LocationStatus; |
| | | |
| | | result.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | |
| | | BaseDal.UpdateData(result); |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result, beforeStatusEnd, changType, "", TaskNum); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (result != null && result.LocationStatus == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | beforeStatusEnd = result.LocationStatus; |
| | | |
| | | result.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | |
| | | BaseDal.UpdateData(result); |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result, beforeStatusEnd, changType, "", TaskNum); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | public void UpdateLocationFree(Dt_LocationInfo locations, int TaskNum, int changType,bool black) |
| | | { |
| | | try |
| | | { |
| | | Dt_LocationInfo result = isDepth(locations); |
| | | if (!black) |
| | | { |
| | | if (result != null) |
| | | { |
| | | int beforeStatusEnd = result.LocationStatus; |
| | | |
| | | result.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | |
| | | BaseDal.UpdateData(result); |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result, beforeStatusEnd, changType, "", TaskNum); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | public Dt_LocationInfo isDepth(Dt_LocationInfo locationInfo) |
| | | { |
| | | if (locationInfo.Depth == 2) |
| | | { |
| | | return AdjacentDepthLocation(locationInfo.LocationCode); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | 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(); |
| | | locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | locationInfos.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | locationInfo.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); |
| | | } |
| | | } |
| | | } |