| | |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_Core; |
| | | using Newtonsoft.Json; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.WMSInfo; |
| | | using WIDESEAWCS_Tasks.ShuttleCarJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | partial class CommonShuttleCarJob |
| | | { |
| | | private object _CarTaskObject = new object(); |
| | | #region å åæºç§»è½¦å®æ |
| | | /// <summary> |
| | | /// è·åå åæºç§»è½¦å®æä»»å¡ |
| | | /// </summary> |
| | | public void GetSC_CarFinish() |
| | | { |
| | | Dt_Task dt_Task = GetTask((int)TaskCarStatusEnum.SC_CarFinish, (int)TaskOtherTypeEnum.RelocationCar); |
| | | if (dt_Task != null) |
| | | { |
| | | var ShuttleCar = QueryCode(dt_Task.ShuttleCarCode); |
| | | ShuttleCar.ShuttleCarPosition = dt_Task.TargetAddress; |
| | | _shuttleCarService.UpdateData(ShuttleCar); |
| | | if (string.IsNullOrEmpty(dt_Task.Remark))//å®æç§»åºä»»å¡ |
| | | _taskService.AddTask_Hty(dt_Task, TaskOperateTypeEnum.AutoComplete); |
| | | else//ä¸åå
çµä»»å¡ |
| | | SendTask(dt_Task); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region è·åç§»è½¦ä»»å¡ |
| | | /// <summary> |
| | | /// è·å移车任å¡/åºå
¥åºä»»å¡ |
| | | /// </summary> |
| | | public void Get_CarTask(ShuttleCar shuttleCar, ShuttleCarTaskCommandR command) |
| | | { |
| | | lock (_CarTaskObject) |
| | | { |
| | | Dt_Task dt_Task = GetTask((int)TaskCarStatusEnum.CarNew, (int)TaskOtherTypeEnum.RelocationCar);//è·åæ°å»ºç§»è½¦ä»»å¡ |
| | | if (dt_Task != null) |
| | | { |
| | | if (string.IsNullOrEmpty(dt_Task.SourceAddress)) |
| | | { |
| | | if (command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command.Err_Status == (short)ShuttleCarErr.Normal) |
| | | { |
| | | UpdateSource(ref dt_Task, shuttleCar); |
| | | } |
| | | else |
| | | { |
| | | #region 夿æ¯å¦åå¨ç©ºé²ç©¿æ¢è½¦,å¦é½å¨å
çµ(éæ©çµéé«çå¹¶è¶
è¿50%çµéçç©¿æ¢è½¦éåºå
çµ) |
| | | QuitCharging(dt_Task, shuttleCar, command); |
| | | #endregion |
| | | } |
| | | } |
| | | else if (string.IsNullOrEmpty(dt_Task.TargetAddress)) |
| | | { |
| | | #region åWMSç³è¯· |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.GetPosition + $"?position={dt_Task.SourceAddress}", "", headers: new Dictionary<string, string>()); |
| | | if (ResultData.Result != null) |
| | | { |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); |
| | | if (content != null && content.Status) |
| | | { |
| | | dt_Task.TargetAddress = content.Message; |
| | | dt_Task.NextAddress = dt_Task.TargetAddress; |
| | | _taskService.UpdateData(dt_Task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(dt_Task.TaskNum, "æ´æ°ç§»è½¦ä»»å¡ç®æ å°å"); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | //ç©¿æ¢è½¦ç§»åºä»»å¡ä¸å |
| | | if (!string.IsNullOrEmpty(dt_Task.SourceAddress) && !string.IsNullOrEmpty(dt_Task.TargetAddress) && !string.IsNullOrEmpty(dt_Task.ShuttleCarCode)) |
| | | { |
| | | SendTask(dt_Task); |
| | | } |
| | | } |
| | | #region ç©¿æ¢è½¦åºå
¥åºä»»å¡ |
| | | else |
| | | { |
| | | var task = _taskService.QueryShuttleCarTask(shuttleCar.DeviceCode); |
| | | if (task != null) |
| | | { |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && !task.IsPickPlace) |
| | | { |
| | | var ShuttleCar = _shuttleCarService.QueryShuttleCar(task.SourceAddress);//åºåºä»»å¡å¤ææ¯å¦åå¨ç©¿æ¢è½¦ |
| | | if (ShuttleCar != null) SendTask(task); |
| | | else _taskService.AddRelocationCarTask("", task.SourceAddress); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æ´æ°ç§»è½¦ä»»å¡èµ·å§å°å |
| | | /// <summary> |
| | | /// æ´æ°ç§»è½¦ä»»å¡èµ·å§å°å |
| | | /// </summary> |
| | | /// <param name="dt_Task"></param> |
| | | /// <param name="shuttleCar"></param> |
| | | /// <param name="command"></param> |
| | | public void UpdateSource(ref Dt_Task dt_Task, ShuttleCar shuttleCar) |
| | | { |
| | | dt_Task.SourceAddress = QueryCode(shuttleCar._deviceCode).ShuttleCarPosition; |
| | | dt_Task.CurrentAddress = dt_Task.SourceAddress; |
| | | dt_Task.ShuttleCarCode = shuttleCar._deviceCode; |
| | | _taskService.UpdateData(dt_Task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(dt_Task.TaskNum, "æ´æ°ç§»è½¦ä»»å¡èµ·å§å°å"); |
| | | } |
| | | #endregion |
| | | |
| | | #region éåºå
çµä»»å¡ |
| | | public void QuitCharging(Dt_Task dt_Task, ShuttleCar shuttleCar, ShuttleCarTaskCommandR command) |
| | | { |
| | | List<string> shuttleCarCodes = new List<string>() { "RGV01", "RGV02" }; |
| | | string CarCode = shuttleCarCodes.Where(x => !x.Contains(shuttleCar.DeviceCode)).First(); |
| | | ShuttleCar shuttleCar1 = Storage.Devices.Where(x => x.DeviceCode.Equals(CarCode)).FirstOrDefault() as ShuttleCar; |
| | | if (shuttleCar1 != null) |
| | | { |
| | | var command1 = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar1, shuttleCar1.DeviceCode);//读åç©¿æ¢è½¦ä¿¡æ¯ |
| | | if (command1.Status == (short)ShuttleCarStatus.Standby && command1.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command1.Err_Status == (short)ShuttleCarErr.Normal) |
| | | { |
| | | UpdateSource(ref dt_Task, shuttleCar1); |
| | | } |
| | | else |
| | | { |
| | | //éæ©çµéé«çå¹¶è¶
è¿50%çµéçç©¿æ¢è½¦éåºå
çµ |
| | | command = command.ElectricQuantity > command1.ElectricQuantity ? command : command1; |
| | | shuttleCar = command.ElectricQuantity > command1.ElectricQuantity ? shuttleCar : shuttleCar1; |
| | | } |
| | | } |
| | | if (string.IsNullOrEmpty(dt_Task.SourceAddress)) |
| | | { |
| | | if (command.ElectricQuantity > 50) |
| | | { |
| | | ShuttleCarTaskCommandW shuttleCarTaskCommand = new ShuttleCarTaskCommandW(); |
| | | shuttleCarTaskCommand.Direction = command.Position; |
| | | shuttleCarTaskCommand.TaskNum = dt_Task.TaskNum; |
| | | shuttleCarTaskCommand.TaskType = (short)ShuttleCarTaskType.ExitCharge; |
| | | if (shuttleCar.SendCommand(shuttleCarTaskCommand, shuttleCar.DeviceCode)) |
| | | { |
| | | dt_Task.Remark = "éåºå
çµå·²ä¸å"; |
| | | UpdateSource(ref dt_Task, shuttleCar); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ä¸åç©¿æ¢è½¦ä»»å¡ |
| | | /// <summary> |
| | | /// ä¸åç©¿æ¢è½¦ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | private void SendTask(Dt_Task task) |
| | | { |
| | | ShuttleCar shuttleCar = Storage.Devices.FirstOrDefault(x => x.DeviceCode == task.ShuttleCarCode) as ShuttleCar; |
| | | if (shuttleCar != null) |
| | | { |
| | | ShuttleCarTaskCommandR command = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar, shuttleCar.DeviceCode);//读åç©¿æ¢è½¦ä¿¡æ¯ |
| | | if (command != null && command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command.Err_Status == (short)ShuttleCarErr.Normal) |
| | | { |
| | | //ä»»å¡è½¬æ¢ |
| | | ShuttleCarTaskCommandW shuttleCarTaskCommand = new ShuttleCarTaskCommandW(); |
| | | shuttleCarTaskCommand.Direction = command.Position; |
| | | shuttleCarTaskCommand.TaskNum = task.TaskNum; |
| | | if (task.TaskType == (int)TaskOtherTypeEnum.RelocationCar)//移车 |
| | | { |
| | | if (task.TaskState == (int)TaskCarStatusEnum.CarNew) |
| | | { |
| | | //if (task.Remark == ShuttleCarTaskType.ExitCharge.ToString()) shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.Remark); |
| | | //else |
| | | shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction); |
| | | } |
| | | else if (task.TaskState == (int)TaskCarStatusEnum.SC_CarFinish) |
| | | { |
| | | if (task.Remark == ShuttleCarTaskType.Charging.ToString()) shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.Remark); |
| | | //else |
| | | // shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction); |
| | | } |
| | | } |
| | | else |
| | | shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction); |
| | | //shuttleCarTaskCommand.TaskType = string.IsNullOrEmpty(task.Remark) ? (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction) : (short)GetCarTaskType(task.Remark); |
| | | //ä»»å¡ä¸å |
| | | if (shuttleCarTaskCommand.TaskType != null)//0 |
| | | { |
| | | if (shuttleCar.SendCommand(shuttleCarTaskCommand, shuttleCar.DeviceCode)) |
| | | { |
| | | if (!string.IsNullOrEmpty(task.Remark)) task.Remark = task.Remark + "å·²ä¸å"; |
| | | task.TaskState = GetTaskState(task.TaskType); |
| | | _taskService.UpdateData(task); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ä»»å¡ç¶æãç±»åè·åä»»å¡ |
| | | /// </summary> |