From 01a80700ea03a332785fb8cbd16aecaf7cce2ccb Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 30 五月 2024 10:29:18 +0800
Subject: [PATCH] 添加人工下料和切换托盘日志

---
 代码管理/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs |   84 ++++++++++++++++++++---------------------
 1 files changed, 41 insertions(+), 43 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
index 332d8f8..aa074ec 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
@@ -63,62 +63,60 @@
                         }
                         agvInWarehousePara outWarehousePara = new agvInWarehousePara()
                         {
-                            //WorkOrder = task.jobID,
                             zoneID = inventorys.Key,
-                            //processCode = task.agv_worktype.ToString(),
                             details = lists,
                             layerNo = 1,
                             stackID = "1",
                             warehouseName = "Agv搴�",
                             Operator = UserContext.Current.UserName,
                         };
+
+                        Idt_info_to_mesRepository mesRepository = new dt_info_to_mesRepository(context);
                         var postJson = JsonConvert.SerializeObject(outWarehousePara);
-                        var mesData = Request.RequestData(postJson, MESAPIAddress.IPAddress_MES + "agvOutWarehouse");
-                        if (mesData.Contains("杩炴帴灏濊瘯澶辫触")) throw new Exception(mesData);
-                        MES_Response requestMes = JsonConvert.DeserializeObject<MES_Response>(mesData);
-                        if (requestMes.code == "200" && requestMes.Type == "success")
+                        dt_info_to_mes info_To_Mes = new dt_info_to_mes()
                         {
-                            //鏃ュ織璁板綍涓婁紶鏁版嵁鎴愬姛
-                            WriteWMSLog.LogAdd("", "鎴愬姛", "MES", "PDA", postJson, mesData, "浜哄伐鍚屾MES杞﹁疆鍑哄簱", "agvOutWarehouse", requestMes.message);
+                            Info = postJson,
+                            ActionName = "agvOutWarehouse",
+                            Createtime = DateTime.Now,
+                            Remark = "浜哄伐鍚屾MES杞﹁疆鍑哄簱",
+                            State = false
+                        };
+                        mesRepository.Add(info_To_Mes, true);
 
-                            foreach (var inventory in inventorys)
+                        foreach (var inventory in inventorys)
+                        {
+                            var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
+                            station.quantity = station.quantity - 1;
+                            if (station.quantity < 1)
                             {
-                                var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
-                                station.quantity = station.quantity - 1;
-                                if (station.quantity == 0)
-                                {
-                                    station.stationType = string.Empty;
-                                    station.heatNumber = string.Empty;
-                                    station.Number = string.Empty;
-                                    station.billetID = string.Empty;
-                                    station.bindSN = string.Empty;
-                                    station.enable = false;
-                                    station.tray_status = string.Empty;
-                                    station.location_state = LocationStateEnum.Empty.ToString();
-                                }
-                                else
-                                {
-                                    var bindSNS = station.bindSN.Split(",");
-                                    station.bindSN = OperStr(bindSNS, inventory.SN);
-                                    var billetS = station.billetID.Split(",");
-                                    station.billetID = OperStr(billetS, inventory.BilletNumber.ToString());
-                                }
-
-                                #region 鍙栨秷璺熻釜DbContext涓璺熻釜鐨勫疄浣�
-                                var currentEntry = stationinfoRepository.DbContext.ChangeTracker.Entries<dt_stationinfo>().FirstOrDefault();
-                                if (currentEntry != null) currentEntry.State = EntityState.Detached;
-                                #endregion
-
-                                stationinfoRepository.Update(station, true);
-                                inventoryRepository.Delete(inventory, true);
+                                station.quantity = 0;
+                                station.stationType = string.Empty;
+                                station.heatNumber = string.Empty;
+                                station.Number = string.Empty;
+                                station.billetID = string.Empty;
+                                station.bindSN = string.Empty;
+                                station.enable = false;
+                                station.tray_status = string.Empty;
+                                station.location_state = LocationStateEnum.Empty.ToString();
                             }
-                            WriteDBLog.Write($"浜哄伐鍑哄簱鎴愬姛 ", $"璐т綅缂栧彿锛歿inventorys.Key}锛汼N鍙凤細{str}", LogState.Sucess, "PDA", user);
+                            else
+                            {
+                                var bindSNS = station.bindSN.Split(",");
+                                station.bindSN = OperStr(bindSNS, inventory.SN);
+                                var billetS = station.billetID.Split(",");
+                                station.billetID = OperStr(billetS, inventory.BilletNumber.ToString());
+                            }
+
+                            #region 鍙栨秷璺熻釜DbContext涓璺熻釜鐨勫疄浣�
+                            var currentEntry = stationinfoRepository.DbContext.ChangeTracker.Entries<dt_stationinfo>().FirstOrDefault();
+                            if (currentEntry != null) currentEntry.State = EntityState.Detached;
+                            #endregion
+
+                            stationinfoRepository.Update(station, true);
+                            inventoryRepository.Delete(inventory, true);
                         }
-                        else
-                        {
-                            WriteWMSLog.LogAdd("", "澶辫触", "MES", "PDA", postJson, mesData, "浜哄伐鍚屾MES杞﹁疆鍑哄簱", "agvOutWarehouse", requestMes.message);
-                            throw new Exception("浜哄伐鍑哄簱鍚屾MES杞﹁疆鍑哄簱澶辫触锛�" + requestMes.message);
-                        }
+                        WriteDBLog.Write($"浜哄伐鍑哄簱鎴愬姛 ", $"璐т綅缂栧彿锛歿inventorys.Key}锛汼N鍙凤細{str}", LogState.Sucess, "PDA", user);
+
                     }
                     catch (Exception ex)
                     {

--
Gitblit v1.9.3