| | |
| | | using HH.WCS.JiaTong.device; |
| | | using HH.WCS.JiaTong.dispatch; |
| | | using HH.WCS.JiaTong.LISTA.models; |
| | | using HH.WCS.JiaTong.process; |
| | | using HH.WCS.JiaTong.util; |
| | | using HH.WCS.JiaTong.wms; |
| | | using HH.WCS.JiaTong_DCJ.device; |
| | | using HH.WCS.JiaTong_DCJ.dispatch; |
| | | using HH.WCS.JiaTong_DCJ.LISTA.models; |
| | | using HH.WCS.JiaTong_DCJ.process; |
| | | using HH.WCS.JiaTong_DCJ.util; |
| | | using HH.WCS.JiaTong_DCJ.wms; |
| | | using Newtonsoft.Json; |
| | | using NLog.Fluent; |
| | | using S7.Net; |
| | |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Web.UI.WebControls; |
| | | using static HH.WCS.JiaTong.api.ApiModel; |
| | | using static HH.WCS.JiaTong.api.OtherModel; |
| | | using static HH.WCS.JiaTong.LISTA.process.HttpModel; |
| | | using static HH.WCS.JiaTong.util.Settings; |
| | | using static HH.WCS.JiaTong_DCJ.api.ApiModel; |
| | | using static HH.WCS.JiaTong_DCJ.api.OtherModel; |
| | | using static HH.WCS.JiaTong_DCJ.LISTA.process.HttpModel; |
| | | using static HH.WCS.JiaTong_DCJ.util.Settings; |
| | | |
| | | namespace HH.WCS.JiaTong.api |
| | | namespace HH.WCS.JiaTong_DCJ.api |
| | | { |
| | | /// <summary> |
| | | /// apiæ¥å£è¾
å©ç±» |
| | |
| | | n_type = 2; |
| | | Source = "é¢å¤åº"; |
| | | break; |
| | | |
| | | |
| | | } |
| | | Console.WriteLine($"Createtask==>任塿¥æº:{n_type}"); |
| | | if (n_type == 0) |
| | |
| | | Location startloc = null; |
| | | lock (_lockCreateTask) |
| | | { |
| | | if (taskData.taskType == 1) //åºåºæµç¨ï¼éè¿ç©ææºå°è®¡ç®çº¿è¾¹è´§ä½ |
| | | note = "åºåº"; |
| | | //å建æçç©æç»å®ä¿¡æ¯ï¼å¹¶è®¡ç®ç»ç¹è´§ä½ |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | note = "åºåº"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | //å建æçç©æç»å®ä¿¡æ¯ï¼å¹¶è®¡ç®ç»ç¹è´§ä½ |
| | | Start = taskData.pickStation; |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType); |
| | | if (endloc != null) |
| | | { |
| | | End = endloc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æºå°ç¼ç :{taskData.dropStation}ï¼æªæ¾å°å¯ç¨è´§ä½"; |
| | | AddErrorInfo("寻æ¾åºåºè´§ä½å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | //endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | //if (endloc != null) |
| | | //{ |
| | | // End = taskData.dropStation; |
| | | //} |
| | | //else |
| | | //{ |
| | | // result.code = "1"; |
| | | // result.msg = $"æ ¹æ®ç»ç¹{End},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | // AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | // return result; |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "å建æçç©æä¿¡æ¯å¤±è´¥"; |
| | | AddErrorInfo("å建æç失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"Putin==> ä»»å¡èµ·ç¹:{taskData.pickStation}æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | Start = taskData.pickStation; |
| | | } |
| | | else if (taskData.taskType == 2)//å
¥åºæµç¨ï¼ç´æ¥ä½¿ç¨èµ·ç¹è´§ä½åç»ç¹è´§ä½çæä»»å¡ï¼èµ·ç¹éè¦ææç |
| | | { |
| | | note = "å
¥åº"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | { |
| | | if (CntrRel.S_CNTR_CODE != partData.rfid) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®èµ·ç¹ï¼{Start}è·åæç:{CntrRel.S_CNTR_CODE}ä¸ä¸åæçï¼{partData.rfid}ä¸ä¸è´ï¼è¯·æ£æ¥æçç æ¯å¦æ£ç¡®"; |
| | | AddErrorInfo("æçç æ ¡æ£å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®èµ·ç¹{taskData.pickStation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | | End = taskData.dropStation; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®ç»ç¹{End},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else if (taskData.taskType == 3)//ç§»åºæµç¨ï¼ç´æ¥ä½¿ç¨èµ·ç¹è´§ä½åç»ç¹è´§ä½çæä»»å¡ï¼ |
| | | { |
| | | note = "åºåº"; |
| | | //å建æçç©æç»å®ä¿¡æ¯ï¼å¹¶è®¡ç®ç»ç¹è´§ä½ |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = taskData.pickStation; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®èµ·ç¹{taskData.pickStation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | | End = taskData.dropStation; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®ç»ç¹{taskData.dropStation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | else |
| | | { |
| | | LogHelper.Info($"Createtask==> ä»»å¡ç±»åæè¯¯"); |
| | | result.code = "1"; |
| | | result.msg = "ä»»å¡ç±»åï¼{taskData.taskType}ä¸å¨è§å®èå´å
"; |
| | | AddErrorInfo("ä»»å¡ç±»åé误", result.msg, Source); |
| | | result.msg = $"æ ¹æ®èµ·ç¹{taskData.pickStation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"å建任å¡å¤±è´¥ï¼èµ·ç¹{Start}æé"; |
| | | AddErrorInfo("è´§ä½æé", result.msg); |
| | | return result; |
| | | } |
| | | var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE.Trim()).First(); |
| | | var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE.Trim()).First(); |
| | | if (startArea == null || endArea == null) |
| | | { |
| | | LogHelper.Info($"èµ·ç¹ï¼{JsonConvert.SerializeObject(startArea)}"); |
| | | LogHelper.Info($"ç»ç¹ï¼{JsonConvert.SerializeObject(endArea)}"); |
| | | result.code = "1"; |
| | | result.msg = $"å建任å¡å¤±è´¥ï¼èµ·ç¹:{startloc.S_AREA_CODE},ç»ç¹{endloc.S_AREA_CODE}æªæ¾å°å¯¹åºåºåº"; |
| | | AddErrorInfo("åºåºæ¥æ¾å¤±è´¥", result.msg); |
| | | return result; |
| | | } |
| | | int pri = 1; |
| | | var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First(); |
| | | if (area != null) |
| | | { |
| | | if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE)) |
| | | { |
| | | pri = 2; |
| | | } |
| | | } |
| | | //å建wcsä»»å¡ |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = startArea.S_NAME + "->" + endArea.S_NAME, |
| | | S_EQ_NO = taskData.taskNum, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_PRIORITY = pri, |
| | | Z_TYPE = n_type, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | S_NOTE = note, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | | End = taskData.dropStation; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®ç»ç¹{taskData.dropStation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | }; |
| | | LogHelper.Info("å建任å¡ï¼" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"å建任å¡å¤±è´¥ï¼èµ·ç¹{Start}æé"; |
| | | AddErrorInfo("è´§ä½æé", result.msg); |
| | | return result; |
| | | } |
| | | var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE.Trim()).First(); |
| | | var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE.Trim()).First(); |
| | | if (startArea == null || endArea == null) |
| | | { |
| | | LogHelper.Info($"èµ·ç¹ï¼{JsonConvert.SerializeObject(startArea)}"); |
| | | LogHelper.Info($"ç»ç¹ï¼{JsonConvert.SerializeObject(endArea)}"); |
| | | result.code = "1"; |
| | | result.msg = $"å建任å¡å¤±è´¥ï¼èµ·ç¹:{startloc.S_AREA_CODE},ç»ç¹{endloc.S_AREA_CODE}æªæ¾å°å¯¹åºåºåº"; |
| | | AddErrorInfo("åºåºæ¥æ¾å¤±è´¥", result.msg); |
| | | return result; |
| | | } |
| | | int pri = 1; |
| | | var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First(); |
| | | if (area != null) |
| | | { |
| | | if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE)) |
| | | { |
| | | // LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("åå»ºä»»å¡æå"); |
| | | pri = 2; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"ä»»å¡å建失败"; |
| | | AddErrorInfo("ä»»å¡å建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | //å建wcsä»»å¡ |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = startArea.S_NAME + "->" + endArea.S_NAME, |
| | | S_EQ_NO = taskData.taskNum, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_PRIORITY = pri, |
| | | Z_TYPE = n_type, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | S_NOTE = note, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | |
| | | }; |
| | | LogHelper.Info("å建任å¡ï¼" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("åå»ºä»»å¡æå"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "å建任å¡å¤±è´¥ï¼æªæ¾å°å¯¹åºçåè´§ç¹æå¸è´§ç¹"; |
| | | result.msg = $"ä»»å¡å建失败"; |
| | | AddErrorInfo("ä»»å¡å建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "å建任å¡å¤±è´¥ï¼æªæ¾å°å¯¹åºçåè´§ç¹æå¸è´§ç¹"; |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | return result; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// è´§ä½ä¿¡æ¯ä¸ä¼ |
| | | /// </summary> |
| | |
| | | result1.UseToken = "iFQ5fExGrLYLXliHYWzs"; |
| | | upload.LocationNum = loc.S_CODE; |
| | | upload.Type = loc.S_TYPE; |
| | | upload.LockState =loc.S_LOCK_STATE; |
| | | upload.LockState = loc.S_LOCK_STATE; |
| | | upload.WorkCenter = loc.S_AREA_CODE; |
| | | upload.Warehouse = loc.S_AREA_CODE; |
| | | listuploadloc.Add(upload); |
| | |
| | | var db = new SqlHelper<HangChaAGV>().GetInstance(); |
| | | DeviceInfoModel device = new DeviceInfoModel(); |
| | | |
| | | // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//å çæºæ¥éä¿¡æ¯ |
| | | // List<AgvInfos> agvInfos = new List<AgvInfos>();//agvæ¥éä¿¡æ¯ |
| | | // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//å çæºæ¥éä¿¡æ¯ |
| | | // List<AgvInfos> agvInfos = new List<AgvInfos>();//agvæ¥éä¿¡æ¯ |
| | | |
| | | //è·åå
åä¸å çæºçæ¥éä¿¡æ¯ |
| | | //foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory) |
| | |
| | | // deviceInfos.Add(new DeviceInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo }); |
| | | //} |
| | | } |
| | | // device.DeviceInfos = deviceInfos; |
| | | // device.DeviceInfos = deviceInfos; |
| | | |
| | | return device; |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //internal static bool CreateCntrLoc(taskData taskData) |
| | | //{ |