| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | public partial class LocationInfoService : ServiceBase<Dt_LocationInfo, ILocationInfoRepository>, ILocationInfoService |
| | | { |
| | | |
| | | |
| | | private Dictionary<string, OrderByType> _emptyAssignOrderBy = new Dictionary<string, OrderByType>() |
| | | { |
| | | { nameof(Dt_LocationInfo.Depth), OrderByType.Desc }, |
| | |
| | | { nameof(Dt_LocationInfo.Column), OrderByType.Asc }, |
| | | { nameof(Dt_LocationInfo.Row), OrderByType.Asc }, |
| | | }; |
| | | /// <summary> |
| | | /// æ ¹æ®è´§ä½ç¼å·è·åè´§ä½ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="LocationCode"></param> |
| | | /// <returns></returns> |
| | | public Dt_LocationInfo GetLocation(string LocationCode) |
| | | { |
| | | return BaseDal.QueryData(x => x.LocationCode == LocationCode).FirstOrDefault(); |
| | | } |
| | | public WebResponseContent UpdateStatus(List<string> locationCodes, int Statu) |
| | | { |
| | | WebResponseContent content = new WebResponseContent().OK(); |
| | | try |
| | | { |
| | | List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => locationCodes.Contains(x.LocationCode)); |
| | | foreach (var locationCode in locationCodes.GroupBy(x => x)) |
| | | { |
| | | if (locationCode.Count() > 2) throw new Exception("è´§ä½ç»å®æå·è¿å¤"); |
| | | if (locationCode.Count() > 1) |
| | | { |
| | | var location = locationInfos.Where(x => x.LocationCode == locationCode.Key).FirstOrDefault(); |
| | | if (location != null && location.LocationStatus == Statu) throw new Exception("è´§ä½ç»å®æå·è¿å¤"); |
| | | if(locationCode.Count() == 2) location.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); |
| | | } |
| | | //else |
| | | //{ |
| | | // throw new Exception("è´§ä½ç»å®æå·è¿å¤"); |
| | | //} |
| | | } |
| | | locationInfos.ForEach(x => |
| | | { |
| | | if (x.MaxQty == 12 || x.LocationStatus == Statu) x.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); |
| | | x.LocationStatus = Statu;//LocationStatusEnum.PalletLock.ObjToInt() |
| | | }); |
| | | content = UpdateData(locationInfos); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åé
è´§ä½ |
| | | /// </summary> |
| | | /// <param name="stockInfo">ç»çä¿¡æ¯</param> |
| | | /// <param name="inboundOrder">å
¥åºå</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public Dt_LocationInfo AssignLocation(int inboundOrderCount) |
| | | { |
| | | Dt_LocationInfo locationInfo = BaseDal.QueryFirst(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.MaxQty == (inboundOrderCount > 1 ? 24 : 12), _emptyAssignOrderBy); |
| | | |
| | | if (locationInfo == null) locationInfo = BaseDal.QueryFirst(x => (x.LocationStatus == LocationStatusEnum.Free.ObjToInt() || x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() || x.LocationStatus == LocationStatusEnum.Inbounding.ObjToInt()) && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()), _emptyAssignOrderBy); |
| | | |
| | | return locationInfo; |
| | | } |
| | | |
| | | |
| | | public virtual Dt_LocationInfo? AssignLocation(string stationCode, int inboundType) |
| | | { |
| | |
| | | |
| | | private Dt_LocationInfo StoredAssignLocation(string roadway) |
| | | { |
| | | //List<LocationGroupDTO> locationGroups = BaseDal.GetLocationGroups(roadway, LocationStatusEnum.Free, LocationStatusEnum.InStock); |
| | | //if (locationGroups != null) |
| | | //{ |
| | | // 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.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()); |
| | | // int id = locationGroup?.IdB ?? 0; |
| | | // return BaseDal.QueryFirst(x => x.Id == id); |
| | | //} |
| | | List<LocationGroupDTO> locationGroups = BaseDal.GetLocationGroups(roadway, LocationStatusEnum.Free, LocationStatusEnum.InStock); |
| | | if (locationGroups != null) |
| | | { |
| | | 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.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()); |
| | | int id = locationGroup?.IdB ?? 0; |
| | | return BaseDal.QueryFirst(x => x.Id == id); |
| | | } |
| | | |
| | | return BaseDal.QueryFirst(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() || x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo == roadway), _emptyAssignOrderBy); |
| | | } |