| | |
| | | /// <returns></returns> |
| | | public Dt_Task QueryExecutingConveyorLineTask(int taskNum, string nextAddress) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish), TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && (x.NextAddress == nextAddress && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish && x.TargetAddress == nextAddress), TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | Dt_Task task = null; |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | tasks = BaseDal.QueryData(x => x.Roadway == deviceNo && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState < TaskRelocationStatusEnum.SC_RelocationFinish.ObjToInt()).OrderBy(x => x.TaskNum).ToList(); |
| | | tasks = BaseDal.QueryData(x => x.Roadway == deviceNo && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState < TaskRelocationStatusEnum.SC_RelocationExecuting.ObjToInt()).OrderBy(x => x.TaskNum).ToList(); |
| | | else |
| | | tasks = BaseDal.QueryData(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState < TaskRelocationStatusEnum.SC_RelocationFinish.ObjToInt()).OrderBy(x => x.TaskNum).ToList(); |
| | | tasks = BaseDal.QueryData(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState < TaskRelocationStatusEnum.SC_RelocationExecuting.ObjToInt()).OrderBy(x => x.TaskNum).ToList(); |
| | | if (tasks != null && tasks.Count > 0) |
| | | { |
| | | task = tasks.First(); |
| | |
| | | /// <returns>è¿åä»»å¡å®ä½å¯¹è±¡ï¼å¯è½ä¸ºnull</returns> |
| | | public Dt_Task QueryStackerCraneTask(string deviceNo, string currentAddress = "") |
| | | { |
| | | Dt_Task? _Task = null; |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && !string.IsNullOrEmpty(x.NextAddress) || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | { |
| | | _Task = BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && !string.IsNullOrEmpty(x.NextAddress) || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState <= (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | if (_Task != null && TaskOutboundTypes.Contains(_Task.TaskType)) |
| | | { |
| | | if (_Task.TaskState != TaskOutStatusEnum.Car_OutFinish.ObjToInt()) _Task = null; |
| | | } |
| | | } |
| | | else |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | { |
| | | _Task = BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState <= (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | if (_Task != null && TaskOutboundTypes.Contains(_Task.TaskType)) |
| | | { |
| | | if (_Task.TaskState != TaskOutStatusEnum.Car_OutFinish.ObjToInt()) _Task = null; |
| | | } |
| | | } |
| | | return _Task; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>è¿åä»»å¡å®ä½å¯¹è±¡ï¼å¯è½ä¸ºnull</returns> |
| | | public Dt_Task QueryStackerCraneOutTask(string deviceNo, string currentAddress = "") |
| | | { |
| | | Dt_Task? _Task = null; |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish, TaskOrderBy); |
| | | _Task = BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState <= (int)TaskOutStatusEnum.Car_OutFinish, TaskOrderBy); |
| | | else |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | _Task = BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState <= (int)TaskOutStatusEnum.Car_OutFinish && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | if (_Task != null && _Task.TaskState != TaskOutStatusEnum.Car_OutFinish.ObjToInt()) _Task = null; |
| | | return _Task; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | task = BaseDal.QueryFirst(x => x.TaskType == TaskType); |
| | | return task; |
| | | } |
| | | |
| | | private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); |
| | | /// <summary> |
| | | /// æ·»å ç§»è½¦ä»»å¡ |
| | | /// </summary> |
| | |
| | | /// <param name="ShuttleCarCode">ç©¿æ¢è½¦å·</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent AddRelocationCarTask(string SourceAddress, string TargetAddress, string ShuttleCarCode = "", string remark = "") |
| | | public async Task AddRelocationCarTask(string SourceAddress, string TargetAddress, string ShuttleCarCode = "", string remark = "") |
| | | { |
| | | await _semaphore.WaitAsync(); |
| | | try |
| | | { |
| | | if (!string.IsNullOrEmpty(SourceAddress) && SourceAddress != "") |
| | | { |
| | | Dt_Task? task = BaseDal.QueryFirst(x => x.SourceAddress == SourceAddress && x.TaskType == TaskOtherTypeEnum.RelocationCar.ObjToInt()); |
| | | if (task != null) return WebResponseContent.Instance.Error(); |
| | | if (task != null) return; |
| | | } |
| | | if (!string.IsNullOrEmpty(TargetAddress) && TargetAddress != "") |
| | | { |
| | | Dt_Task? task = BaseDal.QueryFirst(x => x.TargetAddress == TargetAddress && x.TaskType == TaskOtherTypeEnum.RelocationCar.ObjToInt()); |
| | | if (task != null) return WebResponseContent.Instance.Error(); |
| | | if (task != null) return; |
| | | } |
| | | #region å建å åæºç§»è½¦ä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | |
| | | Remark = remark |
| | | }; |
| | | if (SourceAddress == TargetAddress) dt_Task.TaskState = (int)CarChargingTaskEnum.SC_CarFinish; |
| | | return AddData(dt_Task); |
| | | AddData(dt_Task); |
| | | #endregion |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | } |
| | | finally |
| | | { |
| | | _semaphore.Release(); |
| | | } |
| | | } |
| | | } |
| | | } |