| | |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.WareHouseEnum; |
| | | 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; |
| | | |
| | | namespace WIDESEAWCS_BasicInfoService |
| | | { |
| | | public class LocationCache |
| | | { |
| | | public string LocationCode { get; set; } |
| | | |
| | | public DateTime DateTime { get; set; } |
| | | } |
| | | public partial class LocationInfoService : ServiceBase<Dt_LocationInfo, ILocationInfoRepository>, ILocationInfoService |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | |
| | | { |
| | | return LocationDisableStatus(new int[] { key }); |
| | | } |
| | | |
| | | private readonly static object _locker = new object(); |
| | | private static List<LocationCache> locationCaches = new List<LocationCache>(); |
| | | /// <summary> |
| | | /// åé
è´§ä½ |
| | | /// </summary> |
| | | public Dt_LocationInfo? AssignLocation(string roadwayNo, int palletType, int warehouseId) |
| | | public Dt_LocationInfo? AssignLocation() |
| | | { |
| | | return new Dt_LocationInfo(); |
| | | lock (_locker) |
| | | { |
| | | List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 5).ToList();//æ¥è¯¢æ·»å éæåéè¶
è¿5åéçè´§ä½ |
| | | int count = removeItems.Count; |
| | | for (int i = 0; i < count; i++) |
| | | { |
| | | locationCaches.Remove(removeItems[i]);//ç§»é¤æ¥è¯¢æ·»å éæåéè¶
è¿5åéçè´§ä½ |
| | | } |
| | | |
| | | List<string> lockLocations = locationCaches.Select(x => x.LocationCode).ToList(); |
| | | |
| | | Dictionary<string, OrderByType> orderBy = new Dictionary<string, OrderByType>() |
| | | { |
| | | { nameof(Dt_LocationInfo.Row),OrderByType.Asc }, |
| | | { nameof(Dt_LocationInfo.Layer),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åéå
åé
çè´§ä½,æ ¹æ®å±ãåãæ·±åº¦ãè¡æåº |
| | | if (locationInfo!=null) |
| | | { |
| | | LocationCache locationCache = new LocationCache() |
| | | { |
| | | LocationCode = locationInfo.LocationCode, |
| | | DateTime = DateTime.Now, |
| | | }; |
| | | locationCaches.Add(locationCache); |
| | | } |
| | | return locationInfo; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åå§åè´§ä½ |
| | | /// </summary> |
| | | /// <param name="initializationLocationDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent InitializationLocation(InitializationLocationDTO initializationLocationDTO) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | for (int i = 0; i < initializationLocationDTO.MaxRow; i++) |
| | | { |
| | | for (int j = 0; j < initializationLocationDTO.MaxColumn; j++) |
| | | { |
| | | for (int k = 0; k < initializationLocationDTO.MaxLayer; k++) |
| | | { |
| | | Dt_LocationInfo locationInfo = new Dt_LocationInfo() |
| | | { |
| | | WarehouseId = 0, |
| | | Columns = j + 1, |
| | | EnableStatus = EnableStatusEnum.Normal.ObjToInt(), |
| | | Layer = k + 1, |
| | | LocationStatus = LocationStatusEnum.Free.ObjToInt(), |
| | | RoadwayNo = $"{initializationLocationDTO.Roadway}", |
| | | Row = i + 1, |
| | | }; |
| | | locationInfo.LocationCode = $"{locationInfo.RoadwayNo}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Columns.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}"; |
| | | locationInfo.LocationName = $"{locationInfo.RoadwayNo}å··é{locationInfo.Row.ToString().PadLeft(3, '0')}è¡{locationInfo.Columns.ToString().PadLeft(3, '0')}å{locationInfo.Layer.ToString().PadLeft(3, '0')}å±"; |
| | | int point = 0; |
| | | if (locationInfo.Row%2==0) |
| | | { |
| | | point = locationInfo.Row / 2; |
| | | } |
| | | else |
| | | { |
| | | if (locationInfo.Row==1) |
| | | { |
| | | point = 1; |
| | | } |
| | | else |
| | | { |
| | | point = (locationInfo.Row / 2)+1; |
| | | } |
| | | } |
| | | locationInfo.AgvPoint = $"{point.ToString().PadLeft(2, '0')}-{locationInfo.Columns.ToString().PadLeft(2, '0')}"; |
| | | locationInfos.Add(locationInfo); |
| | | } |
| | | } |
| | | } |
| | | BaseDal.AddData(locationInfos); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |