分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-04-06 dd2b970907682890ab0f16c6efc7c04edfe1598f
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs
@@ -29,8 +29,9 @@
            {
                VOLContext Context = new VOLContext();
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
                Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context);
                var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList();
                var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList();
                foreach (var task in tasks)
                {
                    if (task.agv_tasktype == "TaskType_EmptyPallet")//空托任务
@@ -42,9 +43,9 @@
                            if (!Pipeline_client.IsConnected) throw new Exception("与链条机连接超时!");
                            var area = task.agv_Traytype == "SmallTray" ? "11" : "10";
                            //找1库区的空托位
                            var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.location_state == "Stroge"/*LocationStateEnum.Stroge.ToString()*/ && x.enable)
                                .OrderBy(x => x.line).OrderByDescending(x => x.column).FirstOrDefault();
                            var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") /*&& x.location_state == "Stroge"*//*LocationStateEnum.Stroge.ToString()*/ && x.enable).OrderBy(x => x.column).ThenBy(x => x.line).FirstOrDefault();
                            if (EmptyStation != null)
                                if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) EmptyStation = null;
                            #region ä¸€ä¸ªåŒºåŸŸåªèƒ½æœ‰ä¸€ä¸ªç©ºæ‰˜ä»»åŠ¡
                            //bool ok = false;
                            //if (EmptyStation != null)
@@ -55,6 +56,7 @@
                            #endregion
                            if (EmptyStation == null)
                                EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.enable).OrderByDescending(x => x.column).FirstOrDefault();
                            if (EmptyStation == null) continue;
                            #region åº“内存在任务占用
                            if (EmptyStation.location_state == LocationStateEnum.Busy.ToString())
                                continue;
@@ -106,6 +108,26 @@
                            }
                        }
                    }
                    else if (task.agv_tasktype == "TaskType_OutsourceCarry")//外协移库
                    {
                        if (task.agv_toaddress == "")
                        {
                            var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository);
                            if (TargetLocation != null)
                            {
                                if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue;
                                task.agv_taskstate = "Create";
                                task.agv_toaddress = TargetLocation.stationCode;
                                TargetLocation.location_state = LocationStateEnum.OutBusy.ToString();
                                TargetLocation.stationType = task.agv_materielid;
                                stationinfoRepository.Update(TargetLocation, true);
                                agvtaskService.Update(task, true);
                                WriteDBLog.Success("更新出库队列任务", $"任务编号:{task.agv_tasknum}", "PCS");
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)