| | |
| | | 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æ¥å£è¾
å©ç±» |
| | |
| | | |
| | | |
| | | public static object _lockCreateTask = new object(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// ç«åºä»»å¡ä¸å=ãåå»ºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result Createtask(CreateTask model) |
| | | { |
| | | |
| | | Result result = new Result() { code = "0", msg = "å建æå" }; |
| | | if (model == null) |
| | | { |
| | | LogHelper.Info($"Createtask==> åæ°ä¸ºnull"); |
| | | result.code = "1"; |
| | | result.msg = "åæ°ä¸ºnullå¼ï¼è¯·æ£æ¥åæ°æ ¼å¼"; |
| | | AddErrorInfo("ä¸ååæ°ä¸ºnull", result.msg); |
| | | return result; |
| | | } |
| | | partData partData = model.partData; |
| | | taskData taskData = model.taskData; |
| | | |
| | | try |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | string CntrCode = "";//æçç¼ç |
| | | string ItemCode = "";//ç©æç¼ç |
| | | if (partData != null) |
| | | { |
| | | CntrCode = partData.rfid;//æçç¼ç |
| | | ItemCode = partData.partNumber;//ç©æç¼ç |
| | | } |
| | | string Start = ""; //åè´§ç¹ |
| | | string End = ""; |
| | | string note = ""; //ç«åºä¸åä»»å¡éè¦éç¥mesæ¥å£ç©æå°ä½ï¼ç¨å¤æ³¨èªå¨è¿è¡åºå |
| | | //æ ¹æ®ç©æè·å对åºåºåº |
| | | #region æ ¹æ®ä»»å¡æ¥æºåæ®µå¤æåºåºæ¥æºæ¥æº |
| | | //var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First(); |
| | | //if (iteminfo != null) |
| | | //{ |
| | | // //LogHelper.Info($"Createtask==>ç©ææ°æ®:{JsonConvert.SerializeObject(iteminfo)}"); |
| | | // areacode = iteminfo.S_WH_CODE; |
| | | //} |
| | | |
| | | //if (string.IsNullOrEmpty(areacode)) |
| | | //{ |
| | | // LogHelper.Info($"Createtask==>æ ¹æ®ç©æç¼ç :{ItemCode}æªè½æ¾å°ç©ææ¥æºï¼éåæ¥ç©ææ°æ®"); |
| | | // result.code = "1"; |
| | | // result.msg = $"æ ¹æ®ç©æç¼ç :{ItemCode}æªè½æ¾å°ç©ææ¥æºï¼éåæ¥ç©ææ°æ®"; |
| | | // AddErrorInfo("寻æ¾åºåºåºå¤±è´¥", result.msg); |
| | | // return result; |
| | | //} |
| | | string state = "çå¾
"; |
| | | int n_type = 0; //任塿¥æº 1.å¯ç¼ç«åº 3.é¢å¤åº ,4.åææåº |
| | | string Source = ""; |
| | | switch (taskData.source) |
| | | { |
| | | case "ML": |
| | | n_type = 1; |
| | | Source = "å¯ç¼"; |
| | | break; |
| | | case "YBK": |
| | | n_type = 2; |
| | | Source = "é¢å¤åº"; |
| | | state = "çå¾
æ¨é"; |
| | | break; |
| | | |
| | | } |
| | | Console.WriteLine($"Createtask==>任塿¥æº:{n_type}"); |
| | | if (n_type == 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任塿¥æº:{taskData.source}å±äºæªå®ä¹åºåºï¼è¯·æ£æ¥ç©ææ¥æºæ¯å¦å±äºçº¦å®å段"; |
| | | AddErrorInfo("任塿¥æºæªå®ä¹", result.msg); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | Location endloc = null; |
| | | Location startloc = null; |
| | | lock (_lockCreateTask) |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | //å建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 = 1, |
| | | Z_TYPE = n_type, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | S_NOTE = note, |
| | | S_B_STATE = state, |
| | | 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 = $"ä»»å¡å建失败"; |
| | | AddErrorInfo("ä»»å¡å建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "å建任å¡å¤±è´¥ï¼æªæ¾å°å¯¹åºçåè´§ç¹æå¸è´§ç¹"; |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = ex.ToString(); |
| | | LogHelper.Error("Createtask Errorï¼" + ex.ToString() + "è¡å·:" + ex.StackTrace, ex); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// é¢å¤åºä»»å¡ç¶æä¸å |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result MstStateInquire(MstStateInquire model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "ç¶æä¸åæå" }; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | if (model == null) |
| | | { |
| | | LogHelper.Info($"MstStateInquire==> åæ°ä¸ºnull"); |
| | | result.code = "1"; |
| | | result.msg = "åæ°ä¸ºnullå¼ï¼è¯·æ£æ¥åæ°æ ¼å¼"; |
| | | AddErrorInfo("åæ°ä¸ºç©º", result.msg); |
| | | return result; |
| | | } |
| | | try |
| | | { |
| | | //æ¾å°ä»»å¡ï¼ä¿®æ¹ä»»å¡ç¶æ |
| | | var task = db.Queryable<WCSTask>().Where(a => a.S_EQ_NO.Trim() == model.taskNum).First(); |
| | | if (task != null) |
| | | { |
| | | task.S_B_STATE ="çå¾
"; |
| | | db.Updateable(task).UpdateColumns(a => new { a.S_B_STATE}).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®ä¸åä»»å¡å·{model.taskNum}æªæ¾å°å¯¹åºä»»å¡"; |
| | | AddErrorInfo("æªæ¾å°ä»»å¡", result.msg); |
| | | return result; |
| | | } |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = ex.ToString(); |
| | | LogHelper.Error("TrayItembind Errorï¼" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static object _Point = new object(); |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | internal static Result Point(PointModel model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "å
¥å¹³åºä»»å¡ä¸åæå" }; |
| | | Result result = new Result() { code = "200", msg = "ä»»å¡ä¸åæå" }; |
| | | string Source = "Mes"; |
| | | |
| | | if (model == null) |
| | |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | //å¤æèµ·ç¹æ¯å¦ç»å®å
¶ä»æç |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | { |
| | | if (CntrRel.S_CNTR_CODE != model.Rfid) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®èµ·ç¹ï¼{model.InitialLocation}è·åæç:{CntrRel.S_CNTR_CODE}ä¸ä¸åæçï¼{model.Rfid}ä¸ä¸è´ï¼è¯·æ£æ¥æçç æ¯å¦æ£ç¡®"; |
| | | AddErrorInfo("æçç æ ¡æ£å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocationHelper.BindingLoc(startloc.S_CODE, new List<string> { model.Rfid }); |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // //å¤æèµ·ç¹æ¯å¦ç»å®å
¶ä»æç |
| | | // var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); |
| | | // if (CntrRel != null) |
| | | // { |
| | | // if (CntrRel.S_CNTR_CODE != model.Rfid) |
| | | // { |
| | | // result.code = "1"; |
| | | // result.msg = $"æ ¹æ®èµ·ç¹ï¼{model.InitialLocation}è·åæç:{CntrRel.S_CNTR_CODE}ä¸ä¸åæçï¼{model.Rfid}ä¸ä¸è´ï¼è¯·æ£æ¥æçç æ¯å¦æ£ç¡®"; |
| | | // AddErrorInfo("æçç æ ¡æ£å¤±è´¥", result.msg, Source); |
| | | // return result; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // LocationHelper.BindingLoc(startloc.S_CODE, new List<string> { model.Rfid }); |
| | | // } |
| | | //} |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.TargetLocation).First(); |
| | | if (endloc == null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <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 url = Settings.tableUrls.Find(a => a.id == 3); |
| | | if (url != null) |
| | | { |
| | | LogHelper.Info($"è´§ä½ä¸æ¥ä¸æ¥ï¼å°å:{url}ï¼å
容ï¼{date}"); |
| | | LogHelper.Info($"è´§ä½ä¸æ¥ä¸æ¥ï¼å°å:{url.url}ï¼å
容ï¼{date}"); |
| | | var r = httpHelper.MesWebPost(url.url, date); |
| | | result = JsonConvert.DeserializeObject<Result>(r); |
| | | if (result.code == "200") |
| | |
| | | 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; |
| | | } |
| | |
| | | #endregion |
| | | |
| | | #region åè¥ä½³éä¸å¡æ¹æ³ |
| | | /// <summary> |
| | | /// ç«åºä»»å¡ä¸åå建æçç©æç»å®å
³ç³» |
| | | /// </summary> |
| | | internal static bool CreateCntrIteminfo(partData partData, taskData taskData) |
| | | { |
| | | if (partData == null && taskData == null) |
| | | { |
| | | LogHelper.Info($"CreateCntrIteminfo==> ç«åºä»»å¡ä¸ååæ°æç©ºï¼åå»ºç©ææçç»å®å
³ç³»å¤±è´¥"); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return ContainerHelper.CreateCntrItem(taskData.pickStation, partData.rfid, partData.partNumber, partData.partDesc, partData.partType, taskData.carrierType, partData.lotNumber, taskData.wmsLot, partData.weight, partData.unit, |
| | | taskData.tyreType, taskData.supplier, taskData.receiveLot, taskData.subpool, partData.productionTime, partData.maturityTime, taskData.level, partData.qty, partData.qtyCfg); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æçå
¥åºç®æ³ |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //internal static bool CreateCntrLoc(taskData taskData) |
| | | //{ |