| | |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Threading.Tasks; |
| | | using System.Xml.Linq; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Comm.LogInfo; |
| | | using WIDESEA_Comm.MES_Info; |
| | | using WIDESEA_Comm.MES_Info.Request; |
| | | using WIDESEA_Comm.TaskNo; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_Core.ManageUser; |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_Entity.DomainModels; |
| | | using WIDESEA_Entity.DomainModels.Mes; |
| | | using WIDESEA_WMS.Common; |
| | | using WIDESEA_WMS.IRepositories; |
| | | using WIDESEA_WMS.Repositories; |
| | | using static WIDESEA_Comm.MES_Info.BasicSN; |
| | | |
| | | namespace WIDESEA_WMS |
| | |
| | | { |
| | | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | string postJson = ""; |
| | | string mesData = ""; |
| | | try |
| | | { |
| | | string sn = saveModel.MainData["sn"].ToString(); |
| | | string user = saveModel.MainData["creator"].ToString(); |
| | | |
| | | return content.Error($"{user}æ æä½æé!"); |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(Context); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context); |
| | | //return content.Error($"{user}æ æä½æé!"); |
| | | //å·¥åå·çæ |
| | | string jobID = "TW" + DateTime.Now.ToString("HH-mm-ss-ff"); |
| | | |
| | | //æ ¹æ®åºåæ¥è¯¢è½¦è½®ä¿¡æ¯ |
| | | dt_inventory inventory = freeDB.Select<dt_inventory>().Where(x => x.SN.Contains(sn)).First(); |
| | | dt_inventory inventory = inventoryRepository.Find(x => x.SN.Contains(sn)).FirstOrDefault(); |
| | | if (inventory == null) |
| | | { |
| | | return content.Error($"æ æ¤è½¦è½®{sn}SNå·,è¯·æ ¸æ¥åºåè®°å½!"); |
| | | } |
| | | |
| | | var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault(); |
| | | //if (!station.enable) return content.Error($"åºä½{station.stationCode}æªå¯ç¨ï¼è¯·æ ¸å®ï¼"); |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode || x.agv_toaddress == station.stationCode).Any()) |
| | | return content.Error($"åºä½{station.stationCode}åå¨AGVä»»å¡ï¼è¯·æ ¸å®ï¼"); |
| | | List<detail> list = new List<detail>(); //è½¦è½®ä¿¡æ¯ |
| | | foreach (var item in inventory.SN.Split(",")) |
| | | foreach (var item in station.bindSN.Split(",")) |
| | | { |
| | | detail detail = new detail(); |
| | | detail.sn = item; |
| | |
| | | agvTransferListPara listPara = new agvTransferListPara |
| | | { |
| | | details = list, |
| | | transferListID = jobID, |
| | | transferListID = jobID,// station.Number, |
| | | toWarehouse = "æ¯è½®åº", |
| | | fromWarehouse = "AGVåº", |
| | | updateTime = DateTime.Now.ToString(), |
| | | drawingNoVer = "", |
| | | materialCode = "", |
| | | drawingNoVer = inventory.drawingNoVer, |
| | | materialCode = inventory.materialCode, |
| | | Operator = user == null ? "admin" : user |
| | | }; |
| | | |
| | | var postJson = JsonConvert.SerializeObject(listPara); |
| | | string mesData = Request.RequestData(postJson, MESAPIAddress.IPAddress_MES + "agvTransferList"); |
| | | postJson = JsonConvert.SerializeObject(listPara); |
| | | mesData = Request.RequestData(postJson, MESAPIAddress.IPAddress_MES + "agvTransferList"); |
| | | if (mesData.Contains("è¿æ¥å°è¯å¤±è´¥")) |
| | | throw new Exception(mesData); |
| | | var requestMes = JsonConvert.DeserializeObject<MES_Response>(mesData); |
| | | |
| | | if (requestMes.code == "200" && requestMes.Type == "success") |
| | | { |
| | | return content.OK("ç§»åºäº¤æ¥æåï¼"); |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_materielid = station.stationType, |
| | | agv_qty = station.quantity, |
| | | agv_tasktype = "TaskType_OutsourceCarry", |
| | | agv_toaddress = "", |
| | | agv_userid = user,//"ç³»ç»", |
| | | jobID = jobID,// mes_head.jobID, |
| | | bindSN = station.bindSN, |
| | | agv_worktype = 101, //Convert.ToInt32(mes_head.processCode), |
| | | agv_materbarcode = inventory.materialCode, |
| | | agv_Traytype = station.tray_type, |
| | | agv_TrayStatus = station.tray_status |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.OutBusy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | content.OK("ä¸åç§»åºå¤åæåï¼"); |
| | | //æ¥å¿è®°å½ä¸ä¼ æ°æ®æå |
| | | WriteWMSLog.LogAdd("", "æå", "MES", "WMS", postJson, mesData, "ABåºç§»åºå¤å", "agvTransferList", requestMes.message); |
| | | } |
| | | else |
| | | throw new Exception(requestMes.message); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | WriteWMSLog.LogAdd("", "失败", "MES", "WMS", postJson, mesData, "ABåºç§»åºå¤å", "agvTransferList", ex.Message); |
| | | } |
| | | return content; |
| | | } |