| | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç¹å¯¹ç¹ä»»å¡å建 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result CreatTask(CreatTask model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "ç¹å¯¹ç¹ä»»å¡å建æå" }; |
| | | string Source = "MES"; |
| | | if (model == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "åæ°ä¸ºnull"; |
| | | AddErrorInfo("åæ°ä¸ºç©º", result.msg, Source); |
| | | return result; |
| | | } |
| | | string Start = ""; //åè´§ç¹ |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | // string CntrCode = model.partData.rfid;//æçç¼ç |
| | | // string ItemCode = model.partData.partNumber;//ç©æç¼ç |
| | | string End = ""; |
| | | string CntrCode = ""; |
| | | Location endloc = new Location(); |
| | | Location startloc = new Location(); |
| | | try |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.InitialLocation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = model.InitialLocation; |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®èµ·ç¹{model.InitialLocation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | |
| | | } |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.TargetLocation).First(); |
| | | if (endloc != null) |
| | | { |
| | | End = model.TargetLocation; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"æ ¹æ®ç»ç¹{model.TargetLocation},æ¾ä¸å°å¯¹åºè´§ä½ï¼è¯·æ£æ¥è´§ä½è¡¨"; |
| | | AddErrorInfo("è´§ä½æ¥æ¾å¤±è´¥", result.msg, Source); |
| | | return result; |
| | | } |
| | | #region åå»ºä»»å¡ |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"å建任å¡å¤±è´¥ï¼èµ·ç¹{Start}æé"; |
| | | AddErrorInfo("è´§ä½æé", result.msg); |
| | | return result; |
| | | } |
| | | //å建wcsä»»å¡ |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | // S_TYPE = model.taskData.taskType.ToString(), |
| | | // S_EQ_NO = model.taskData.taskNum, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | N_PRIORITY = 1, |
| | | // N_TYPE = n_type |
| | | |
| | | |
| | | }; |
| | | 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; |
| | | } |
| | | #endregion |
| | | |
| | | return result; |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"ç©æä¸»æ°æ®å建失败 é误信æ¯ï¼{ex}"; |
| | | LogHelper.Error("ç¹å¯¹ç¹ä»»å¡ Errorï¼" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | public static object _Point = new object(); |
| | | /// <summary> |