From 2ae5aa151f7b40a082e34aa7ed22b4b64edd1d3c Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期三, 11 六月 2025 17:13:56 +0800 Subject: [PATCH] 修改堆垛机通讯协议及交互逻辑 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService.cs | 189 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 177 insertions(+), 12 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 cfdfdeb..c2016d0 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 }, @@ -31,17 +39,17 @@ { try { - Dt_RoadwayInfo roadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.InStationCode == stationCode) ?? throw new Exception("鏈壘鍒拌绔欏彴瀵瑰簲鐨勫贩閬擄紝璇锋鏌ュ熀纭�閰嶇疆淇℃伅"); + Dt_RoadwayInfo roadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.InStationCode == stationCode) ?? throw new Exception("鏈壘鍒拌绔欏彴瀵瑰簲鐨勫贩閬擄紝璇锋鏌ュ熀纭�閰嶇疆淇℃伅!"); if (roadwayInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt() && roadwayInfo.EnableStatus != EnableStatusEnum.OnlyIn.ObjToInt()) { - throw new Exception("璇ュ贩閬撲笉鍙叆搴擄紝璇锋鏌ュ贩閬撶鐢ㄤ俊鎭�"); + throw new Exception("璇ュ贩閬撲笉鍙叆搴擄紝璇锋鏌ュ贩閬撶鐢ㄤ俊鎭�!"); } if (roadwayInfo.AreaId > 0) { Dt_AreaInfo areaInfo = _basicRepository.AreaInfoRepository.QueryFirst(x => x.Id == roadwayInfo.AreaId); if (areaInfo != null && areaInfo.AreaStatus == EnableEnum.Disable.ObjToInt()) { - throw new Exception("鍖哄煙琚鐢紝涓嶅彲鍏ュ簱"); + throw new Exception("鍖哄煙琚鐢紝涓嶅彲鍏ュ簱!"); } } if (inboundType == TaskTypeEnum.PalletInbound.ObjToInt())//绌虹洏鍏ュ簱鍒嗛厤閫昏緫 @@ -55,35 +63,41 @@ } catch (Exception ex) { - + throw new Exception(ex.Message); } return null; + } + public virtual Dt_LocationInfo? AssignLocation(string RoadwayNo) + { + return StoredAssignLocation(RoadwayNo); } private Dt_LocationInfo EmptyAssignLocation(string roadway) { List<LocationGroupDTO> locationGroups = BaseDal.GetLocationGroups(roadway, LocationStatusEnum.Free, LocationStatusEnum.Pallet); + ///鏍规嵁宸烽亾杩涜鎺掑簭 if (locationGroups != null && locationGroups.Count > 0) { - LocationGroupDTO? locationGroup = locationGroups.FirstOrDefault(x => x.EnableStatusA == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatusA == EnableStatusEnum.Normal.ObjToInt()); + LocationGroupDTO? locationGroup = locationGroups.FirstOrDefault(x => x.EnableStatusA == EnableStatusEnum.Normal.ObjToInt()|| x.EnableStatusA == EnableStatusEnum.OnlyIn.ObjToInt()); int id = locationGroup?.IdA ?? 0; return BaseDal.QueryFirst(x => x.Id == id); } locationGroups = BaseDal.GetLocationGroups(roadway, LocationStatusEnum.Free, LocationStatusEnum.Free); if (locationGroups != null && locationGroups.Count > 0) { - LocationGroupDTO? locationGroup = locationGroups.FirstOrDefault(x => x.EnableStatusB == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatusB == EnableStatusEnum.Normal.ObjToInt()); + LocationGroupDTO? locationGroup = locationGroups.FirstOrDefault(x => x.EnableStatusB == EnableStatusEnum.Normal.ObjToInt()||x.EnableStatusB == EnableStatusEnum.OnlyIn.ObjToInt()); int id = locationGroup?.IdB ?? 0; return BaseDal.QueryFirst(x => x.Id == id); } - return BaseDal.QueryFirst(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo == roadway), _emptyAssignOrderBy); + return BaseDal.QueryFirst(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()||x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() && x.RoadwayNo == roadway), _emptyAssignOrderBy); } private Dt_LocationInfo StoredAssignLocation(string roadway) { List<LocationGroupDTO> locationGroups = BaseDal.GetLocationGroups(roadway, LocationStatusEnum.Free, LocationStatusEnum.InStock); + ///鏍规嵁宸烽亾杩涜鎺掑簭 if (locationGroups != null && locationGroups.Count > 0) { LocationGroupDTO? locationGroup = locationGroups.FirstOrDefault(x => x.EnableStatusA == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatusA == EnableStatusEnum.Normal.ObjToInt()); @@ -103,13 +117,164 @@ public Dt_LocationInfo AdjacentDepthLocation(string locationCode) { - Dt_LocationInfo locationInfo = BaseDal.QueryFirst(x => x.LocationCode == locationCode); - return AdjacentDepthLocation(locationInfo); + return AdjacentDepthLocation(BaseDal.QueryFirst(x => x.LocationCode == locationCode)); } public Dt_LocationInfo AdjacentDepthLocation(Dt_LocationInfo locationInfo) { - 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)); + return BaseDal.QueryFirst(x => x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo && 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 new Exception(ex.Message); + } + + } + 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); + } + } + else + { + if (result != null&&(result.LocationStatus== LocationStatusEnum.Lock.ObjToInt()|| result.LocationStatus==LocationStatusEnum.PalletLock.ObjToInt())) + { + int beforeStatusEnd = result.LocationStatus; + + result.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + + BaseDal.UpdateData(result); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(result, beforeStatusEnd, changType, "", TaskNum); + } + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + } + public Dt_LocationInfo isDepth(Dt_LocationInfo locationInfo) + { + try + { + if (locationInfo.Depth == 2) + { + return AdjacentDepthLocation(locationInfo.LocationCode); + } + else + { + return null; + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + public void RelocationLock(Dt_LocationInfo locationInfo, Dt_LocationInfo locationInfos, int TaskNum) + { + try + { + 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); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + public void RelocationFree(Dt_LocationInfo locations, int TaskNum) + { + try + { + 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); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } } } } -- Gitblit v1.9.3