From cb62fe00ff0c80bce983b0aa7a2b320fdc26f85f Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期一, 20 五月 2024 08:51:03 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/SuZhouGuanHong/TaiYuanTaiZhong

---
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/EmptyPalletTask.cs |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/EmptyPalletTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/EmptyPalletTask.cs"
new file mode 100644
index 0000000..ea0743b
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/EmptyPalletTask.cs"
@@ -0,0 +1,109 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Comm;
+using WIDESEA_Comm.LogInfo;
+using WIDESEA_Common;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_WCS.JobsPart.Common;
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_WMS.Repositories;
+using static System.Collections.Specialized.BitVector32;
+
+namespace WIDESEA_WMS.Common
+{
+    public partial class AGVServer
+    {
+        /// <summary>
+        /// 鏇存柊鍙栫┖鎵橀槦鍒椾换鍔�
+        /// </summary>
+        public static void UpdateEmptyPalletTask()
+        {
+            string tasknum = "";
+            try
+            {
+                VOLContext Context = new VOLContext();
+                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context);
+                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
+
+                #region 鍙犵洏鍖烘弧5涓叆搴� 闇�浼樺寲
+                var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.enable).ToList();
+                var EmptyD = EmptyStations.Where(x => x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 5).FirstOrDefault();
+                if (EmptyD != null) EmptyTray.CreateEmptyTrayIn(stationinfoRepository, EmptyD);
+                //EmptyD = EmptyStations.Where(x => x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0&&x.lastUpdateTime.).FirstOrDefault();//鏃堕棿瓒呰繃6灏忔椂鍏ュ簱
+                #endregion
+
+                var agv_tasks = agvtaskRepository.Find(x => x.agv_taskstate == AGVTaskStateEnum.Queue.ToString() && x.agv_tasktype == AGVTaskTypeEnum.TaskType_EmptyPallet.ToString() && string.IsNullOrEmpty(x.agv_toaddress)).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList();
+                foreach (var agv_task in agv_tasks)
+                {
+                    try
+                    {
+                        tasknum = agv_task.agv_tasknum;
+                        #region MyRegion
+                        //var task = agvtaskRepository.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == AGVTaskStateEnum.Queue.ToString() && x.agv_tasktype == AGVTaskTypeEnum.TaskType_EmptyPallet.ToString() && x.agv_Traytype == agv_task.agv_Traytype).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault();
+                        //if (task != null)
+                        //{
+                        //    task.agv_fromaddress = station.stationCode;
+                        //    task.StarQuantity = 0;
+                        //    task.agv_taskstate = "Create";
+                        //    if (station.stationCode.Contains("S0100100"))
+                        //        task.agv_grade = 3;
+                        //    agvtaskService.Update(task, true);
+                        //    station.location_state = LocationStateEnum.Busy.ToString();
+                        //    stationinfoRepository.Update(station, true);
+                        //    WriteDBLog.Success("鏇存柊琛ョ┖鎵橀槦鍒椾换鍔�", $"浠诲姟缂栧彿锛歿task.agv_tasknum}锛屾墭鐩樹俊鍙�:{PalletSignal},璐х墿淇″彿:{MaterialSignal}", "WMS");
+                        //    return;
+                        //}
+                        #endregion
+                        #region MyRegion
+                        //dt_stationinfo EmptyStation = null;
+                        //#region 妫�娴嬩笂鏂欑殑绌烘墭鍙犵洏
+                        //if (agv_task.agv_fromaddress.Contains("S"))
+                        //{
+                        //    //var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.quantity < 5 && x.enable).ToList();
+                        //    EmptyStation = EmptyStations.Where(x => x.tray_type == agv_task.agv_Traytype && x.quantity < 5 && x.location_state == LocationStateEnum.Stroge.ToString()).FirstOrDefault();
+                        //    if (EmptyStation == null)
+                        //        EmptyStation = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString() && x.quantity == 0).FirstOrDefault();
+                        //    if (EmptyStation == null)
+                        //    {
+                        //        EmptyD = EmptyStations.Where(x => x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderByDescending(x => x.quantity).FirstOrDefault();
+                        //        if (EmptyD != null) EmptyTray.CreateEmptyTrayIn(stationinfoRepository, EmptyD);
+                        //    }
+                        //}
+                        //#endregion
+                        //else
+                        //{
+                        //    EmptyStation = GetStation.EmptyPalletStation1(agv_task.agv_Traytype == "SmallTray" ? "11" : "10");
+                        //}
+
+                        #endregion
+
+                        var EmptyStation = EmptyTray.GetEmptyTrayStation(stationinfoRepository, agv_task);
+                        if (EmptyStation != null)
+                        {
+                            agv_task.agv_taskstate = AGVTaskStateEnum.Create.ToString();
+                            agv_task.EndQuantity = EmptyStation.quantity;
+                            agv_task.agv_toaddress = EmptyStation.stationCode;
+                            agvtaskRepository.Update(agv_task, true);
+                            EmptyStation.location_state = LocationStateEnum.Busy.ToString();
+                            stationinfoRepository.Update(EmptyStation, true);
+                            WriteDBLog.Success("鏇存柊鑷姩鍙栫┖鎵橀槦鍒椾换鍔�", $"浠诲姟缂栧彿锛歿agv_task.agv_tasknum}", "WMS");
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        WriteLog.Write_Log("鎶ラ敊鏃ュ織", "鏇存柊鑷姩鍙栫┖鎵橀槦鍒椾换鍔�", "閿欒淇℃伅锛�", $"{tasknum}锛涢敊璇俊鎭細{ex.Message}");
+                    }
+
+                }
+            }
+            catch (Exception ex)
+            {
+                WriteLog.Write_Log("鎶ラ敊鏃ュ織", "鏇存柊鑷姩鍙栫┖鎵橀槦鍒椾换鍔�", "閿欒淇℃伅锛�", $"{tasknum}锛涢敊璇俊鎭細{ex.Message}");
+            }
+        }
+    }
+}

--
Gitblit v1.9.3