| | |
| | | void UpdateTask(Dt_Task task, TaskStatusEnum taskStatus, string deviceCode = "", string sourceAddress = "", string targetAddress = "", string currentAddress = "", string nextAddress = "", string roadwayNo = "", int heightType = 0); |
| | | |
| | | /// <summary> |
| | | /// 请æ±åé
å··é |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent RequestWMSAssignRoadway(int taskNum, List<string> roadwayNos); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent RequestWMSAssignRoadway(List<string> roadwayNos, string palletCode, int heightType); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent RequestWMSAssignRoadway(List<string> roadwayNos, int taskNum, int heightType); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent RequestWMSAssignRoadway(List<string> roadwayNos); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="agvPodModel"></param> |
| | |
| | | // return content; |
| | | //} |
| | | |
| | | |
| | | /// <summary> |
| | | /// åé
å··é |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSAssignRoadway(int taskNum, List<string> roadwayNos) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string address = AppSettings.Get("WMSApiAddress"); |
| | | if (string.IsNullOrEmpty(address)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | } |
| | | string responseStr = HttpHelper.Post($"{address}/api/Task/AssignRoadway?taskNum={taskNum}", roadwayNos.Serialize()); |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | { |
| | | return responseContent; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSAssignRoadway(List<string> roadwayNos, string palletCode, int heightType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string address = AppSettings.Get("WMSApiAddress"); |
| | | if (string.IsNullOrEmpty(address)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | } |
| | | string responseStr = HttpHelper.Post($"{address}/api/Task/AssignRoadwayByHeightAndCode?palletCode={palletCode}&heightType={heightType}", roadwayNos.Serialize()); |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | { |
| | | return responseContent; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
å··é |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSAssignRoadway(List<string> roadwayNos, int taskNum, int heightType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string address = AppSettings.Get("WMSApiAddress"); |
| | | if (string.IsNullOrEmpty(address)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | } |
| | | string responseStr = HttpHelper.Post($"{address}/api/Task/AssignRoadway?taskNum={taskNum}&heightType={heightType}", roadwayNos.Serialize()); |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | { |
| | | return responseContent; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
å··é |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSAssignRoadway(List<string> roadwayNos) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string address = AppSettings.Get("WMSApiAddress"); |
| | | if (string.IsNullOrEmpty(address)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | } |
| | | string responseStr = HttpHelper.Post($"{address}/api/Task/SingleAssignRoadway", roadwayNos.Serialize()); |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | { |
| | | return responseContent; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åWMSç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | |
| | | { |
| | | device.SetValue(WR_CLineYLDB.WR_Task, task.TaskNum, item.StationCode); |
| | | device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode); |
| | | device.SetValue(WR_CLineYLDB.WR_Width, task.TaskLength, item.StationCode); |
| | | device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing); |
| | | WriteInfo(item.StationCode, $"{conveyorLineInfoRead.Serialize()}"); |
| | |
| | | } |
| | | } |
| | | else if (item.StationType == StationTypeEnum.StationType_StackingPlates.ObjToInt() && deviceProRead != null && deviceProWrite != null) |
| | | { |
| | | {//å çæºå·¥ä½å«æ |
| | | R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress); |
| | | //å çæºå·¥ä½å«æ |
| | | |
| | | if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 7 && conveyorLineInfoRead.TaskNo <= 0) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType)); |
| | |
| | | return BaseDal.QueryFirst(x => x.RoadwayNo == roadwayNo && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt() && !lockLocations.Contains(x.LocationCode), orderBy);//æ¥è¯¢ç©ºè´§ä½ä¿¡æ¯å¹¶æé¤5åéå
åé
çè´§ä½,æ ¹æ®å±ãåãæ·±åº¦ãè¡æåº |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// åæåé
è´§ä½ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Dt_LocationInfo? AssignLocationYL(string roadwayNo, Dt_PalletTypeInfo palletTypeInfo) |
| | | { |
| | | lock (_AssignLocationYL) |
| | |
| | | if (nearLocation1!=null && nearLocation2!=null) |
| | | { |
| | | locationInfo = item; |
| | | break; |
| | | } |
| | | } |
| | | return locationInfo; |
| | |
| | | /// <param name="palletType">æçç±»å</param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignInboundTaskLocation(int taskNum, string roadwayNo); |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// ä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | |
| | | WebResponseContent Outbound(int id); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignRoadwayByHeight(List<string> roadwayNos, int taskNum, int heightType = 0); |
| | | |
| | | /// <summary> |
| | | /// åé
å··é |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignRoadway(int taskNum, List<string> roadwayNos, int heightType); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent SingleAssignRoadway(List<string> roadwayNos); |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹ä»»å¡ç¶æ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | |
| | | WebResponseContent EmptyBackTask(string barCode, string startPoint); |
| | | |
| | | /// <summary> |
| | | /// è¾
æå
¥åº |
| | | /// è¾
æ/æå临æ¶å
¥åº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | WebResponseContent InboundFLOrCPTask(string barCode, string startPoint, string matCode, int matCount); |
| | |
| | | { |
| | | public partial class TaskService |
| | | { |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <param name="roadwayNos">å··éå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignRoadwayByHeight(List<string> roadwayNos, int taskNum, int heightType = 0) |
| | | { |
| | | try |
| | | { |
| | | if (heightType == 0 || heightType > 3) |
| | | { |
| | | return WebResponseContent.Instance.Error($"é«åº¦é误"); |
| | | } |
| | | |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | |
| | | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | string roadwayNo = ""; |
| | | if (heightType == 1) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | else if (heightType == 2) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | else if (heightType == 3) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | |
| | | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <param name="roadwayNos">å··éå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignRoadway(int taskNum, List<string> roadwayNos, int heightType) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | |
| | | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | bool IsBCS = task.PalletType == PalletTypeEnum.SmallPallet.ObjToInt(); |
| | | //è·åæ¯ä¸ªå··é1-3å±ï¼4å±ï¼5å±çè´§ä½ |
| | | List<LocationCount> locationCounts = new List<LocationCount>(); |
| | | if (heightType == 1) |
| | | { |
| | | locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || (IsBCS ? false : x.LocationType == LocationTypeEnum.Undefined.ObjToInt())) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && (IsBCS ? !IsBCS : ("SC01_BC".Contains(x.RoadwayNo) ? x.Column % 2 == 0 : x.Column % 2 == 1)) && x.Layer <= 3 && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | } |
| | | else if(heightType == 2) |
| | | { |
| | | locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || (IsBCS ? false : x.LocationType == LocationTypeEnum.Undefined.ObjToInt())) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && (IsBCS ? !IsBCS : ("SC01_BC".Contains(x.RoadwayNo) ? x.Column % 2 == 0 : x.Column % 2 == 1)) && x.Layer == 4 && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | } |
| | | else if(heightType == 3) |
| | | { |
| | | locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || (IsBCS ? false : x.LocationType == LocationTypeEnum.Undefined.ObjToInt())) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && (IsBCS ? !IsBCS : ("SC01_BC".Contains(x.RoadwayNo) ? x.Column % 2 == 0 : x.Column % 2 == 1)) && x.Layer == 5 && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | } |
| | | string roadwayNo=string.Empty; |
| | | foreach (var location in locationCounts.OrderBy(x => x.Count)) |
| | | { |
| | | if (location.Count <= 2) |
| | | continue; |
| | | roadwayNo = location?.RoadwayNo ?? ""; |
| | | break; |
| | | } |
| | | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"+ $"ï¼{locationCounts.Serialize()}"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | | /// <param name="roadwayNos">å··éå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent SingleAssignRoadway(List<string> roadwayNos) |
| | | { |
| | | try |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | |
| | | string roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | |
| | | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public class LocationCount |
| | |
| | | { |
| | | return content.Error($"æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | //çæä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | TaskLength = (int)stockInfo.MaterielWide |
| | | }; |
| | | |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | |
| | | if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.æ°å.ObjToInt()) |
| | | { |
| | | //éå¶ç´å¾ |
| | | if (stockInfo.MaterielThickness <= 1200) |
| | | if (stockInfo.MaterielThickness <= 1250) |
| | | { |
| | | //è·ååé
|
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YLDual")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | |
| | | //å··éä»»å¡åé
æ°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId |
| | | && locationCounts.Select(j => j.RoadwayNo).Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count != null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | roadwayNo = HandleRoadway(locationCounts, warehouse); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //éå¶ç´å¾ |
| | | if (stockInfo.MaterielThickness >= 800 && stockInfo.MaterielThickness <= 1500) |
| | | if (stockInfo.MaterielThickness >= 800 && stockInfo.MaterielThickness <= 1450) |
| | | { |
| | | //è·ååé
|
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YL") && !x.RoadwayNo.Contains("YLDual")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | |
| | | locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo == "SC02_YL").GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | } |
| | | |
| | | //å··éä»»å¡åé
æ°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId |
| | | && locationCounts.Select(j => j.RoadwayNo).Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count != null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | roadwayNo = HandleRoadway(locationCounts, warehouse); |
| | | } |
| | | } |
| | | |
| | |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | //å¤çåé
å··é 任塿°é |
| | | public string HandleRoadway(List<LocationCount> locationCounts, Dt_Warehouse warehouse) |
| | | { |
| | | //å··éä»»å¡åé
æ°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId |
| | | && locationCounts.Select(j => j.RoadwayNo).Distinct().Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count != null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | return locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | /// <summary> |
| | | /// å
¥åºå®æ |
| | |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | } |
| | | |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | //æ´æ°éå®è´§ä½ |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | |
| | | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, heightType: heightType); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | task.Roadway = roadwayNo; |
| | | task.TargetAddress = locationInfo.LocationCode; |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId); |
| | | BaseDal.UpdateData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(data: locationInfo.LocationCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 空æ¡ååº |
| | | /// </summary> |
| | |
| | | } |
| | | private readonly static object _lockerFLorCP = new object(); |
| | | /// <summary> |
| | | /// è¾
ææåå
¥åº |
| | | /// è¾
æ/æå临æ¶å
¥åº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent InboundFLOrCPTask(string barCode, string startPoint,string matCode,int matCount) |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// æ 纺å¸åºåº |
| | | /// </summary> |
| | | /// <param name="Count"></param> |
| | | /// <returns></returns> |
| | | //public WebResponseContent RequestWFBWMSTaskOut(int Count) |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x => x.StationArea == AGVStationAreaEnum.AreaC.ObjToInt() && x.IsOccupied == WhetherEnum.False.ObjToInt()); |
| | | // if (aGVStationInfos.Count < Count) |
| | | // { |
| | | // return content.Error($"å¯ç¨ç¼åæ°ä¸è¶³"); |
| | | // } |
| | | // List<Dt_ProStockInfo> stockInfos = _stockRepository.ProStockInfoRepository.QueryData(x => x.ProStockAttribute == ProStockAttributeEnum.è¾
æå¤ä»¶.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt()).OrderBy(x => x.CreateDate).Take(Count).ToList(); |
| | | // List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode)); |
| | | // if (stockInfos.Count < Count) |
| | | // { |
| | | // return content.Error($"åºåæ°éä¸è¶³"); |
| | | // } |
| | | // foreach (var item in stockInfos) |
| | | // { |
| | | // Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode); |
| | | // if (locationInfo != null && (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | // { |
| | | // item.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | // } |
| | | // else |
| | | // { |
| | | // return content.Error($"è´§ä½ç¶æä¸æ£ç¡®"); |
| | | // } |
| | | // } |
| | | // List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutWFB); |
| | | // if (tasks == null || tasks.Count <= 0) |
| | | // { |
| | | // return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | // } |
| | | // for (int i = 0; i < tasks.Count; i++) |
| | | // { |
| | | // aGVStationInfos[i].IsOccupied = WhetherEnum.True.ObjToInt(); |
| | | // tasks[i].TargetAddress = aGVStationInfos[i].AGVStationCode; |
| | | // } |
| | | // //夿æ¯å¦æåºåºåä¿¡æ¯ |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // //æ´æ°åºåç¶æ |
| | | // _stockRepository.ProStockInfoRepository.UpdateData(stockInfos); |
| | | // _agvStationInfoRepository.UpdateData(aGVStationInfos); |
| | | // //æ´æ°è´§ä½ç¶æ |
| | | // _basicRepository.LocationInfoRepository.UpdateLocationStatus(locationInfos, LocationStatusEnum.Lock); |
| | | // //å å
¥è´§ä½åå¨è®°å½ |
| | | // _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, taskNums: tasks.Select(x => x.TaskNum).ToList()); |
| | | // //æ°å»ºä»»å¡ |
| | | // BaseDal.AddData(tasks); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // PushTasksToWCS(tasks); |
| | | // content.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// åæåºåºä»»å¡ |
| | | /// </summary> |
| | |
| | | public TaskController(ITaskService service) : base(service) |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WCSç³è¯·å
¥åºä»»å¡(ä¸åé
è´§ä½) |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.AssignInboundTaskLocation(taskNum, roadwayNo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AssignInboundTaskLocationByHeight"), AllowAnonymous] |
| | | public WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType) |
| | | { |
| | | return Service.AssignInboundTaskLocationByHeight(taskNum, roadwayNo, heightType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æå空æ¡ååº |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾
æå
¥åº |
| | | /// è¾
æ/æå临æ¶å
¥åº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("InboundFLTask"), AllowAnonymous] |
| | |
| | | { |
| | | return Service.PushTasksToWCSSingle(taskNum, agvDescription); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éæ©åºåçæåºåºä»»å¡ |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
å··é(带任å¡å·åé«åº¦) |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("AssignRoadwayByHeight"), AllowAnonymous] |
| | | public WebResponseContent AssignRoadwayByHeight([FromBody] List<string> roadwayNos, int taskNum, int heightType = 0) |
| | | { |
| | | return Service.AssignRoadwayByHeight(roadwayNos, taskNum, heightType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
å··é(带任å¡å·) |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("AssignRoadway"), AllowAnonymous] |
| | | public WebResponseContent AssignRoadway(int taskNum, [FromBody] List<string> roadwayNos,int heightType) |
| | | { |
| | | return Service.AssignRoadway(taskNum, roadwayNos, heightType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
å··é |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("SingleAssignRoadway"), AllowAnonymous] |
| | | public WebResponseContent SingleAssignRoadway([FromBody] List<string> roadwayNos) |
| | | { |
| | | return Service.SingleAssignRoadway(roadwayNos); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹ä»»å¡ç¶æ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | |
| | | { |
| | | return Service.UpdateTaskInfo(task); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åæå
¥åºä»»å¡è¯·æ± |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.RequestYLWMSTaskSimple(stationCode,palletCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åæå
¥åºç³è¯· |
| | | /// åæå
¥åºç³è¯·(å¹³å°/èååº) |
| | | /// </summary> |
| | | /// <param name="palletCode">æ¡ç </param> |
| | | /// <returns></returns> |
| | |
| | | { |
| | | return Service.YLPurchaseBoxing(palletCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
åæå
¥åºå··é |
| | | /// </summary> |
| | |
| | | return Service.RequestCPWMSTaskOut(materialCode, Count, targetId); |
| | | } |
| | | |
| | | ///// <summary> |
| | | ///// æ 纺å¸åºåº |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //[HttpPost, HttpGet, Route("RequestWFBWMSTaskOut"), AllowAnonymous] |
| | | //public WebResponseContent RequestWFBWMSTaskOut(int Count) |
| | | //{ |
| | | // return Service.RequestWFBWMSTaskOut(Count); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// åæåºåºä»»å¡ |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.RequestYLWMSTaskOut(materielCode, materielWide, count, address); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åæç§»åºä»»å¡ |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.RelocationRoadWay(roadWay, Count); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
æåå··é |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.AssignCPRoadwayNo(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å°å·ä½æéæä»»å¡ |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.PrintBackInbound(saveModel); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å°å·ä¸æä»»å¡ |
| | | /// </summary> |
| | |
| | | { |
| | | return Service.PrintInbound(saveModel); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建å纸ç产æç¨åºåºä»»å¡ |
| | | /// </summary> |