| | |
| | | using static System.Collections.Specialized.BitVector32; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_WMS.Repositories; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Comm.TaskNo; |
| | | using WIDESEA_Common; |
| | | |
| | | namespace WIDESEA_WMS.Services |
| | | { |
| | |
| | | } |
| | | return webResponse; |
| | | } |
| | | |
| | | public WebResponseContent SendAGVTask(object json) |
| | | /// <summary> |
| | | /// 忢æç |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent Trayswitching(SaveModel saveModel) |
| | | { |
| | | WebResponseContent webResponse = new WebResponseContent(); |
| | | try |
| | | VOLContext context = new VOLContext(); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context); |
| | | IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context); |
| | | string completor = UserContext.Current.UserName; |
| | | foreach (var Key in saveModel.DelKeys) |
| | | { |
| | | try |
| | | { |
| | | var station = repository.Find(x => x.id.ToString() == Key.ToString()).FirstOrDefault(); |
| | | if (!station.stationCode.Contains("X")) throw new Exception($"æ {station.stationCode}ä½¿ç¨æéï¼"); |
| | | if (!station.enable) throw new Exception($"{station.stationCode}æªå¯ç¨ï¼"); |
| | | if (station.location_state == LocationStateEnum.Abnormal.ToString()) throw new Exception($"{station.stationCode}ç¶æå¼å¸¸ï¼"); |
| | | if (station.location_state == LocationStateEnum.Empty.ToString()) throw new Exception($"{station.stationCode}ç¶æä¸ºç©ºï¼"); |
| | | if (station.remark == "æ¡æ¶ä¸æ") throw new Exception($"{station.stationCode}æ¡æ¶æ£å¨ä¸æï¼"); |
| | | if (agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).Any()) throw new Exception($"{station.stationCode}åå¨ä»»å¡ï¼"); |
| | | |
| | | if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any()) |
| | | { |
| | | #region 为空æå¹¶ä¸æ°é为0,å建å空æä»»å¡ |
| | | if (station.tray_status == TrayStateEnum.EmptyTray.ToString() && station.quantity == 0) |
| | | { |
| | | 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 = AGVTaskStateEnum.Queue.ToString(), |
| | | agv_qty = 1, |
| | | StarQuantity = 0, |
| | | EndQuantity = 0,//EmptyStation.quantity, |
| | | agv_tasktype = AGVTaskTypeEnum.TaskType_EmptyPallet.ToString(), |
| | | agv_toaddress = "", |
| | | agv_userid = UserContext.Current.UserName, |
| | | agv_TrayStatus = station.tray_status, |
| | | agv_Traytype = station.tray_type |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | } |
| | | #endregion |
| | | |
| | | #region å建å
¥åºä»»å¡ |
| | | else if (station.location_state == LocationStateEnum.Stroge.ToString() && station.quantity > 0) |
| | | { |
| | | var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault(); |
| | | if (Work == null) throw new Exception($"æªæ¾å°è´§ä½{station.stationCode}çæºå 工工åä¿¡æ¯ï¼"); |
| | | 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 = AGVTaskStateEnum.Queue.ToString(), |
| | | agv_materielid = station.stationType, |
| | | agv_qty = station.quantity, |
| | | agv_tasktype = station.stationCode.Contains("3") ? AGVTaskTypeEnum.TaskType_OutsourceInbound.ToString() : AGVTaskTypeEnum.TaskType_Inbound.ToString(), |
| | | agv_toaddress = "", |
| | | agv_userid = UserContext.Current.UserName, |
| | | bindSN = station.bindSN, |
| | | agv_worktype = Convert.ToInt32(Work.processCode), |
| | | agv_materbarcode = Work.materialCode, |
| | | agv_Traytype = station.tray_type, |
| | | jobID = station.Number, |
| | | agv_TrayStatus = station.tray_status |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | |
| | | station.location_state = LocationStateEnum.InBusy.ToString(); |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | station.tray_type = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString(); |
| | | repository.Update(station, x => new { x.location_state, x.tray_type }, true); |
| | | |
| | | webResponse.OK(webResponse.Message += $"{station.stationCode}忢æå!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | webResponse.Error(webResponse.Message += ex.Message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | return webResponse; |
| | | } |
| | | /// <summary> |
| | | /// ä¸æä»»å¡ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent SendAGVTask(SaveModel saveModel) |
| | | { |
| | | WebResponseContent webResponse = new WebResponseContent(); |
| | | VOLContext context = new VOLContext(); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context); |
| | | IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context); |
| | | string completor = UserContext.Current.UserName; |
| | | foreach (var Key in saveModel.DelKeys) |
| | | { |
| | | |
| | | try |
| | | { |
| | | var station = repository.Find(x => x.id.ToString() == Key.ToString()).FirstOrDefault(); |
| | | if (!station.stationCode.Contains("X")) throw new Exception($"æ {station.stationCode}ä½¿ç¨æéï¼"); |
| | | if (!station.enable) throw new Exception($"{station.stationCode}æªå¯ç¨ï¼"); |
| | | if (station.location_state == LocationStateEnum.Abnormal.ToString()) throw new Exception($"{station.stationCode}ç¶æå¼å¸¸ï¼"); |
| | | if (station.location_state == LocationStateEnum.Empty.ToString()) throw new Exception($"{station.stationCode}ç¶æä¸ºç©ºï¼"); |
| | | if (station.tray_status == TrayStateEnum.EmptyTray.ToString()) throw new Exception($"{station.stationCode}为空æçï¼"); |
| | | if (station.quantity < 1) throw new Exception($"{station.stationCode}æ°éå°äº1ï¼"); |
| | | if (station.remark == "æ¡æ¶ä¸æ") throw new Exception($"{station.stationCode}æ¡æ¶æ£å¨ä¸æï¼"); |
| | | //if (station.location_state.Contains("Busy")) throw new Exception($"{station.stationCode}å ç¨ï¼"); |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode || x.agv_fromaddress == station.stationCode).Any()) throw new Exception($"{station.stationCode}åå¨ä»»å¡ï¼"); |
| | | var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault(); |
| | | if (Work == null) throw new Exception($"æªæ¾å°è´§ä½{station.stationCode}çæºå 工工åä¿¡æ¯ï¼"); |
| | | 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 = AGVTaskStateEnum.Queue.ToString(), |
| | | agv_materielid = station.stationType, |
| | | agv_qty = station.quantity, |
| | | agv_tasktype = station.stationCode.Contains("3") ? AGVTaskTypeEnum.TaskType_OutsourceInbound.ToString() : AGVTaskTypeEnum.TaskType_Inbound.ToString(), |
| | | agv_toaddress = "", |
| | | agv_userid = UserContext.Current.UserName, |
| | | bindSN = station.bindSN, |
| | | agv_worktype = Convert.ToInt32(Work.processCode), |
| | | agv_materbarcode = Work.materialCode, |
| | | agv_Traytype = station.tray_type, |
| | | jobID = station.Number, |
| | | agv_TrayStatus = station.tray_status |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.InBusy.ToString(); |
| | | repository.Update(station, x => new { x.location_state }, true); |
| | | webResponse.OK(webResponse.Message += $"{station.stationCode}任塿·»å æå!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | webResponse.Error(webResponse.Message += ex.Message); |
| | | } |
| | | } |
| | | return webResponse; |
| | | } |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | VOLContext volContext = new VOLContext(); |
| | | Idt_stationinfoRepository dsta = new dt_stationinfoRepository(volContext); |
| | | string[] stationCodes = { "A","S", "X", "W", "DD","B", "C", "D01"}; |
| | | string[] stationCodes = { "A", "S", "X", "W", "DD", "B", "C", "D01" }; |
| | | List<Tuple<List<dt_stationinfo>, int>> responseData = new List<Tuple<List<dt_stationinfo>, int>>(); |
| | | foreach (string code in stationCodes) |
| | | { |