| | |
| | | using SqlSugar; |
| | | using System.ComponentModel.Design; |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using System.Threading; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Communicator; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.HttpContextUser; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO.MOM; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IProcessRepository; |
| | |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_SignalR; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using static Quartz.Logging.OperationName; |
| | | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; |
| | | using Platform = WIDESEAWCS_Model.Models.Platform; |
| | | |
| | |
| | | private readonly IDeviceInfoRepository _deviceInfoRepository; |
| | | private static List<string>? userTokenIds; |
| | | private static List<int>? userIds; |
| | | private static List<string> childCodeList = new List<string>(); |
| | | private static DateTime? lastUpdateTime; |
| | | |
| | | public CommonConveyorLine_CWJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ICacheService cacheService, INoticeService noticeService, IDt_needBarcodeRepository needBarcodeRepository, IDeviceInfoRepository deviceInfoRepository) |
| | | { |
| | |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | #region 站台方式 |
| | | |
| | | //List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | | |
| | | //foreach (var station in stationManagers) |
| | | //{ |
| | | // ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationChildCode); |
| | | |
| | | // DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString()); |
| | | // if (deviceProtocolDetails != null) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType); |
| | | // if (method != null) |
| | | // { |
| | | // method.Invoke(this, new object[] { conveyorLine, command, station }); |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | #endregion 站台方式 |
| | | |
| | | #region 路由方式 |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | |
| | | var chunks = childDeviceCodes.Chunk(10); |
| | | |
| | | //if (conveyorLine.DeviceCode == "1024") |
| | | //{ |
| | | // childDeviceCodes.Add("4000"); |
| | | //} |
| | | |
| | | //var options = new ParallelOptions |
| | | //{ |
| | | // MaxDegreeOfParallelism = 10 |
| | | // //MaxDegreeOfParallelism = Environment.ProcessorCount |
| | | //}; |
| | | |
| | | //{ |
| | | // SiemensS7 siemensS7 = new SiemensS7(conveyorLine.Communicator.IpAddress, conveyorLine.Communicator.Port, conveyorLine.DeviceName); |
| | | // siemensS7.Connect(); |
| | | // tasks.Add(Task.Run(() => |
| | | // { |
| | | |
| | | // })); |
| | | //} |
| | | //Parallel.For(0, childDeviceCodes.Count, options, i => |
| | | //Parallel.ForEach(childDeviceCodes, options, childDeviceCode => |
| | | var tasks = new List<Task>(); |
| | | |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | foreach (var item in chunks) |
| | | { |
| | | |
| | | ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); |
| | | |
| | | if (command == null) continue; |
| | | //if (command.InteractiveSignal == 0 && command.HasPallet != 1) continue; |
| | | if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = ""; |
| | | |
| | | DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString()); |
| | | if (deviceProtocolDetails != null) |
| | | tasks.Add(Task.Run(() => |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType); |
| | | if (method != null) |
| | | foreach (string childDeviceCode in item) |
| | | { |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode }); |
| | | } |
| | | } |
| | | ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); |
| | | |
| | | if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") |
| | | { |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null) |
| | | { |
| | | if (command.HasPallet != 1) |
| | | if (command != null) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = ""; |
| | | |
| | | DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString()); |
| | | if (deviceProtocolDetails != null) |
| | | { |
| | | //var strings = platform.Location.Split(',').ToList(); |
| | | int count = 1; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode }); |
| | | } |
| | | } |
| | | |
| | | if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") |
| | | { |
| | | if (lastUpdateTime > DateTime.Now.AddMinutes(1)) |
| | | { |
| | | lastUpdateTime = DateTime.Now; |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null) |
| | | { |
| | | if (command.HasPallet != 1) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | { |
| | | int count = 1; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos != null || tokenInfos.Any()) |
| | | { |
| | | |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | childDeviceCode, |
| | | commandAfter = command, |
| | | }; |
| | | _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); |
| | | |
| | | } |
| | | #endregion 调用事件总线通知前端 |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos == null || !tokenInfos.Any()) |
| | | { |
| | | //throw new Exception(conveyorLine.DeviceName + "缓存中未找到Token缓存"); |
| | | continue; |
| | | } |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | childDeviceCode, |
| | | commandAfter = command, |
| | | }; |
| | | _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | |
| | | })); |
| | | } |
| | | //Task.WaitAll(tasks.ToArray()); |
| | | |
| | | #endregion 路由方式 |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.Out.WriteLine(nameof(CommonConveyorLine_CWJob) + ":" + DateTime.Now + ":" + ex.ToString(),ex.StackTrace); |
| | | Console.Out.WriteLine(nameof(CommonConveyorLine_CWJob) + ":" + DateTime.Now + ":" + ex.ToString(), ex.StackTrace); |
| | | } |
| | | finally |
| | | { |
| | |
| | | var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】任务号:【{command.ConveyorLineTaskNum}】设备编码:【{childDeviceCode}】"; |
| | | ConsoleHelper.WriteSuccessLine(log); |
| | | |
| | | //_noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | |
| | | if (childDeviceCode == "4000") |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(1601), childDeviceCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 9999, childDeviceCode); |
| | | } |
| | | |
| | | if (task == null) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | if (childDeviceCode == "1039") |
| | | { |
| | | var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); |
| | | if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"时间:【{DateTime.Now}】托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发"); |
| | | return; |
| | | } |
| | | } |
| | | //if (childDeviceCode == "1039") |
| | | //{ |
| | | // var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); |
| | | // if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) |
| | | // { |
| | | // ConsoleHelper.WriteErrorLine($"时间:【{DateTime.Now}】托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发"); |
| | | // return; |
| | | // } |
| | | //} |
| | | |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // //当前地址请求 寻找当前地址的托盘号 任务号的任务,如存在任务则重新再次写入新目标地址 |
| | | // Dt_Task currentTask = _taskService.QueryExecutingCurrentConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); |
| | | // if (currentTask != null) |
| | | // { |
| | | // conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(currentTask.TargetAddress), childDeviceCode); |
| | | // } |
| | | //} |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param> |
| | | /// <summary> |
| | | /// 触发输送线出库请求处理 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例(CommonConveyorLine_CW类型),包含输送线设备基础信息和操作方法</param> |
| | | /// <param name="command">输送线任务指令对象(后续版本),暂未直接使用,预留指令上下文</param> |
| | | /// <param name="childDeviceCode">子设备编码,用于定位输送线的具体子设备</param> |
| | | public void RequestOutbound(CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) |
| | | { |
| | | // 根据主输送线设备编码和子设备编码,查询对应的输送线任务 |
| | | var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | |
| | | // 若查询到有效任务,则执行后续指令发送和状态更新逻辑 |
| | | if (task != null) |
| | | { |
| | | // 将数据库查询到的任务对象映射为指令对象(适配指令发送的数据结构) |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | // 发送任务指令到指定输送线子设备,并获取发送结果(原注释掉的conveyorLine.SendCommand已替换为封装后的方法) |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | |
| | | // 若指令发送成功,执行状态更新操作 |
| | | if (sendFlag) |
| | | { |
| | | // 更新输送线子设备的响应状态为1(1代表指令已响应/处理成功,对应数据库字段ConveyorLineDBName_After.ResponState) |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); |
| | | |
| | | // 将任务状态更新到下一个阶段(通用任务状态流转) |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | |
| | | // 特殊处理:若任务类型为出托盘(OutTray),额外再执行一次任务状态更新(适配出托盘任务的特殊状态流转逻辑) |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray) |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | /// <summary> |
| | | /// 处理输送线下一地址请求(核心逻辑:查询执行中任务→获取MOM配置→调用MOM接口校验→根据校验结果/任务状态发送指令并更新任务) |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例(CommonConveyorLine_CW类型),包含输送线设备基础信息和操作方法</param> |
| | | /// <param name="command">输送线任务指令对象(后续版本),携带任务编号、条码、子设备编码等关键指令参数</param> |
| | | /// <param name="childDeviceCode">子设备编码,用于定位输送线的具体子设备</param> |
| | | public void RequestOutNextAddress(CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) |
| | | { |
| | | // 1. 查询指定条件下正在执行的输送线任务(任务编号+子设备编码+输送线条码) |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); |
| | | |
| | | // 仅当查询到有效执行中任务时,执行后续逻辑 |
| | | if (task != null) |
| | | { |
| | | // 2. 获取系统配置中「IP地址」分类下的配置项(用于拼接MOM接口地址) |
| | | var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | // 提取MOM基础IP配置值 |
| | | var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue; |
| | | // 提取托盘格口状态接口的IP路径配置值 |
| | | var ipAddress = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.TrayCellsStatus)?.ConfigValue; |
| | | |
| | | // 校验MOM IP配置完整性,缺失则抛出异常终止流程 |
| | | if (wmsBase == null || ipAddress == null) |
| | | { |
| | | throw new InvalidOperationException("MOM IP 未配置"); |
| | | } |
| | | |
| | | // 3. 查询当前输送线设备+子设备对应的工位配置信息(关联PLC编码、子编码与MOM设备编码) |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode); |
| | | |
| | | // 4. 构建托盘格口状态校验的请求DTO(适配MOM接口入参格式) |
| | | TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = "WMS", |
| | | TrayBarcode = command.ConveyorLineBarcode, |
| | | EquipmentCode = stationManager.stationEquipMOM, |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | EmployeeNo = "MITest", |
| | | SceneType = "1", |
| | | RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") |
| | | Software = "WMS", // 调用方系统标识(固定为WMS) |
| | | TrayBarcode = command.ConveyorLineBarcode, // 输送线条码(托盘条码) |
| | | EquipmentCode = stationManager.stationEquipMOM, // MOM系统对应的设备编码 |
| | | SessionId = Guid.NewGuid().ToString(), // 唯一会话ID(防止重复请求) |
| | | EmployeeNo = "MITest", // 操作员工编号(测试固定值) |
| | | SceneType = "1", // 场景类型(1代表入站校验场景) |
| | | RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") // UTC格式请求时间 |
| | | }; |
| | | |
| | | // 拼接完整的MOM接口地址(基础IP + 接口路径) |
| | | var MOMIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result; |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验请求参数【{trayCells.Serialize()}】"); |
| | | WriteInfo("入站校验", ""); |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result; |
| | | |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验返回参数【{result}】"); |
| | | |
| | | // 6. 解析MOM接口返回结果为实体对象 |
| | | ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); |
| | | |
| | | // 7. 分支1:接口校验成功 或 任务备注非NG(正常流程) |
| | | if (result1.Success || task.Remark != "NG") |
| | | { |
| | | // 更新任务的位置信息(任务编号+当前地址),返回更新后的任务对象 |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | |
| | | if (newTask != null) |
| | | { |
| | | // 将更新后的任务对象映射为输送线指令对象(适配指令发送结构) |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | // 发送指令到输送线子设备,获取发送结果(封装后的SendCommand方法) |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | |
| | | // 指令发送成功则更新设备响应状态和任务数据 |
| | | if (sendFlag) |
| | | { |
| | | // 更新输送线子设备响应状态为1(代表指令处理成功) |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); |
| | | // 持久化更新后的任务数据到数据库 |
| | | _taskService.UpdateData(newTask); |
| | | } |
| | | } |
| | | } |
| | | // 8. 分支2:接口校验失败 且 任务备注为NG(异常流程,发送NG地址指令) |
| | | else |
| | | { |
| | | // 将原任务对象映射为输送线指令对象 |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | // 设置指令的目标地址为工位配置中的NG子编码(导向异常处理工位) |
| | | taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode); |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | // 发送NG地址指令到输送线子设备,获取发送结果 |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | |
| | | // 指令发送成功则更新设备响应状态和任务状态 |
| | | if (sendFlag) |
| | | { |
| | | // 更新输送线子设备响应状态为1 |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); |
| | | // 将任务状态流转到下一个阶段(适配NG任务的状态逻辑) |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | if (sendFlag) |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); |
| | | content = _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationArea == "Call" && x.stationType == 12); |
| | | if (station == null) |
| | | { |
| | | return; |
| | | } |
| | | CommonConveyorLine_BZ? commonConveyorBZ = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC) as CommonConveyorLine_BZ; |
| | | if (commonConveyorBZ != null) |
| | | { |
| | | ConveyorLineTaskCommand_After readSignal = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationLocation); |
| | | if (readSignal.Reserved5 == 1) |
| | | { |
| | | var tasks = _taskRepository.QueryData(x => x.TargetAddress == childDeviceCode); |
| | | if (tasks.Count == 0) |
| | | { |
| | | commonConveyorBZ.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), station.stationLocation); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | } |
| | | |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | if (sendFlag) |
| | | { |
| | |
| | | |
| | | taskNext.ExceptionMessage = log; |
| | | content = _taskService.UpdateTaskStatusToNext(taskNext); |
| | | } |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationArea == "Call" && x.stationType == 12); |
| | | CommonConveyorLine_BZ? commonConveyorBZ = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC) as CommonConveyorLine_BZ; |
| | | if (commonConveyorBZ != null) |
| | | { |
| | | ConveyorLineTaskCommand_After readSignal = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationLocation); |
| | | if (readSignal.Reserved5 == 1) |
| | | { |
| | | var tasks = _taskRepository.QueryData(x => x.TargetAddress == childDeviceCode); |
| | | if (tasks.Count == 0) |
| | | { |
| | | commonConveyorBZ.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), station.stationLocation); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | var wmsIpAddress = wmsBase + requestTrayOutTask; |
| | | |
| | | |
| | | |
| | | List<string> strings = platform.Location.Split(',').ToList(); |
| | | |
| | | WriteInfo("调度执行时间记录", "【调取WMS出库接口开始时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.Serialize()); |
| | | |
| | | WriteInfo("调度执行时间记录", "【调取WMS出库接口结束时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); |
| | | WriteInfo("OCV请求返回参数", $"时间:【{DateTime.Now}】请求点位【{childDeviceCode}】返回参数【{JsonConvert.SerializeObject(result)}】"); |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | |
| | | public WebResponseContent CreateAndSendTask(WMSTaskDTO taskDTO) |
| | | { |
| | | var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | |
| | | if (content.Status) |
| | | { |
| | | Console.WriteLine($"{taskDTO.TaskType}呼叫成功"); |