| | |
| | | } |
| | | 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}ï¼SNå·ï¼{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}ï¼SNå·ï¼{str}", LogState.Sucess, "PDA", user); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |