分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-25 8554717a7abbe2889ae1d835857661dc8b91aa68
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs
@@ -111,20 +111,25 @@
            VOLContext context = new VOLContext();
            Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
            IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
            string completor = UserContext.Current.UserName;
            foreach (var Key in saveModel.DelKeys)
            {
                try
                {
                    var station = repository.Find(x => x.id.ToString() == Key.ToString()).FirstOrDefault();
                    if (!station.stationCode.Contains("X")) throw new Exception($"无{station.stationCode}使用权限!");
                    if (!station.stationCode.Contains("X") && !station.stationCode.Contains("W01001004") && !station.stationCode.Contains("W01001005")) throw new Exception($"无{station.stationCode}使用权限!");
                    if (!station.enable) throw new Exception($"{station.stationCode}未启用!");
                    if (station.location_state == LocationStateEnum.Abnormal.ToString()) throw new Exception($"{station.stationCode}状态异常!");
                    if (station.location_state == LocationStateEnum.Empty.ToString()) throw new Exception($"{station.stationCode}状态为空!");
                    if (station.remark == "桁架下料") throw new Exception($"{station.stationCode}桁架正在下料!");
                    if (agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).Any()) throw new Exception($"{station.stationCode}存在任务!");
                    
                    if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                    var task = agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).FirstOrDefault();
                    if (task != null)
                    {
                        if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) throw new Exception($"{station.stationCode}存在任务!");
                        task.agv_Traytype = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
                        agvtaskRepository.Update(task, x => new { x.agv_Traytype }, true);
                    }
                    else if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                    {
                        #region ä¸ºç©ºæ‰˜å¹¶ä¸”数量为0,创建取空托任务
                        if (station.tray_status == TrayStateEnum.EmptyTray.ToString() && station.quantity == 0)