分支自 SuZhouGuanHong/TaiYuanTaiZhong

huanghongfeng
2024-07-08 32678f5c24c7681a198b517fa72db1de2e98646d
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/OutboundTask.cs
@@ -7,6 +7,7 @@
using WIDESEA_Comm;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Comm.TaskNo;
using WIDESEA_Common;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Extensions;
using WIDESEA_Entity.DomainModels;
@@ -50,7 +51,7 @@
                            //鏌ユ壘褰撳墠璐т綅鍚岃鏄惁瀛樺湪鍏ュ簱浠诲姟
                            if (GetStation.InBusyStation(Station.stationCode)) continue;
                            stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault();
                            stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.tray_status == "StrogeTray" && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault();
                            if (stationinfo != null)
                            {
                                if (agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).Any()) continue;
@@ -122,5 +123,53 @@
                WriteDBLog.Error("鍒涘缓鍑哄簱浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
            }
        }
        /// <summary>
        /// 澶勭悊浜哄伐鍑哄簱绌烘墭
        /// </summary>
        public static void Outkongtuo()
        {
            try
            {
                VOLContext context = new VOLContext();
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                Idt_agvtaskRepository agvdb = new dt_agvtaskRepository(context);
                var Station = stationinfoRepository.Find(x => x.tray_status == "EmptyTrayss" && x.enable && x.location_state== LocationStateEnum.Stroge.ToString() && x.quantity==1).ToList();
                foreach (var station in Station)
                {
                    var EmptyStations = stationinfoRepository.Find(x => x.area == station.area && x.line == station.line && x.column > station.column && x.location_state != LocationStateEnum.Empty.ToString()).Any();
                    if (!EmptyStations)
                    {
                        dt_agvtask agvtask = new dt_agvtask()
                        {
                            agv_fromaddress = station.stationCode,
                            agv_id = Guid.NewGuid(),
                            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                            agv_grade = 3,
                            agv_createtime = DateTime.Now,
                            agv_taskstate = "Queue",
                            agv_qty = station.quantity,
                            agv_Traytype = station.tray_type,
                            agv_tasktype = AGVTaskTypeEnum.TaskType_EmptyPallet.ToString(),
                            //agv_toaddress = TargetLocation.stationCode,
                            agv_toaddress = "",
                            agv_userid = "绯荤粺",
                            agv_TrayStatus = "EmptyTray",
                        };
                        agvdb.Add(agvtask, true);
                        station.location_state = LocationStateEnum.OutBusy.ToString();
                        stationinfoRepository.Update(station, x => new { x.location_state }, true);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("鍒涘缓浜哄伐鍑哄簱鍚庣殑绌烘墭鍑哄簱", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
            }
        }
    }
}