| | |
| | | using HslCommunication; |
| | | using Mapster; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | |
| | | using WIDESEAWCS_Model.BasicInfo; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | case 1: |
| | | await RequestTask(conveyorLine, command, childDeviceCode, stationManager); |
| | | break; |
| | | |
| | | case 9: |
| | | RequestWMSTask(conveyorLine, stationManager); |
| | | break; |
| | | case 2: |
| | | case 3: |
| | | RequestInOrOutbound(command, conveyorLine, stationManager, task); |
| | | RequestNextAddress(command, conveyorLine, stationManager, task); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public void HandleFinishTaskAsync(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, Dt_Task task=null) |
| | | { |
| | | var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationPLC == conveyorLine.DeviceCode); |
| | | |
| | | switch (stationManager.stationType) |
| | | { |
| | | case 4: |
| | | case 5: |
| | | ConveyorLineInOrOutFinish(conveyorLine, command, stationManager, task); |
| | | break; |
| | | case 7: |
| | | ConveyorLineOutFinish(conveyorLine, command, stationManager, task); |
| | | task = _taskService.QueryConveyorLineFinishTask(stationManager.stationChildCode, command.TaskNum); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | |
| | | private async Task RequestTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, Dt_StationManager stationManager) |
| | | { |
| | | var hasTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == childDeviceCode); |
| | | var hasTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == childDeviceCode && x.TaskState < (int)TaskInStatusEnum.RGV_InExecutingFinish && x.TaskState >= (int)TaskInStatusEnum.InNew); |
| | | if (hasTask != null) |
| | | { |
| | | var log = $"ã{conveyorLine._deviceName}ãä»»å¡å·ï¼ã{hasTask.TaskNum}ã,æçæ¡ç ï¼ã{hasTask.PalletCode}ãå·²å°è¾¾ã{childDeviceCode}ãè¾é线åå¨ä»»å¡"; |
| | | ConsoleHelper.WriteWarningLine(log); |
| | | |
| | | await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | return; |
| | | } |
| | | var RGVName = string.Empty; |
| | | if (stationManager.stationFloor == "1F") |
| | | { |
| | | var RGVOne = _taskRepository.QueryData(x => x.RGVName == "RGV01").ToList(); |
| | | var RGVTwo = _taskRepository.QueryData(x => x.RGVName == "RGV02").ToList(); |
| | | if (RGVOne.Count > RGVTwo.Count) |
| | | var deviceCode = _deviceInfoRepository.Db.Queryable<Dt_DeviceInfo>().Where(x => x.DeviceStatus == "1" && x.DeviceRemark == "1F").Where(x => x.DeviceCode.Contains("RGV")).ToList().Select(x => x.DeviceCode).ToList(); |
| | | if (deviceCode != null && deviceCode.Count() > 0) |
| | | { |
| | | RGVName = "RGV01"; |
| | | if (deviceCode.Contains("RGV01") && deviceCode.Contains("RGV02")) |
| | | { |
| | | var RGVOne = _taskRepository.QueryData(x => x.RGVName == "RGV01").ToList(); |
| | | var RGVTwo = _taskRepository.QueryData(x => x.RGVName == "RGV02").ToList(); |
| | | if (RGVOne.Count > RGVTwo.Count) |
| | | { |
| | | RGVName = "RGV01"; |
| | | } |
| | | else |
| | | { |
| | | RGVName = "RGV02"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | RGVName = deviceCode[0]; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | RGVName = "RGV02"; |
| | | RGVName = "RGV01"; |
| | | } |
| | | } |
| | | |
| | | else |
| | | { |
| | | RGVName = "RGV03"; |
| | | } |
| | | Dt_Task task = new Dt_Task() |
| | | { |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | |
| | | }; |
| | | _taskRepository.AddData(task); |
| | | } |
| | | private void RequestWMSTask(CommonConveyorLine conveyorLine, Dt_StationManager stationManager) |
| | | { |
| | | var Barcode = conveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.ConveyorLineBarcode, stationManager.stationNextChildCode); |
| | | |
| | | if (Barcode == "") |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal,Convert.ToSByte(3), stationManager.stationChildCode); |
| | | } |
| | | var task = _taskRepository.QueryFirst(x => x.PalletCode == Barcode); |
| | | if (task != null) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | //var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | //var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; |
| | | //var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue; |
| | | //var keys = new Dictionary<string, object>() |
| | | //{ |
| | | // {"TPbarcode", Barcode}, |
| | | // {"WhCode", "1001"}, |
| | | // {"BeginPoint", stationManager.stationChildCode} |
| | | //}; |
| | | //if (wmsBase == null || requestTask == null) |
| | | //{ |
| | | // throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | //} |
| | | //var wmsIpAddress = wmsBase + requestTask; |
| | | //var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, keys.ToString()).Result; |
| | | } |
| | | } |
| | | } |
| | | } |