#region << 版 本 注 释 >> /*---------------------------------------------------------------- * 命名空间:WIDESEAWCS_Tasks.ConveyorLineJob * 创建者:胡童庆 * 创建时间:2024/8/2 16:13:36 * 版本:V1.0.0 * 描述: * * ---------------------------------------------------------------- * 修改人: * 修改时间: * 版本:V1.0.1 * 修改说明: * *----------------------------------------------------------------*/ #endregion << 版 本 注 释 >> using AutoMapper; using Quartz; using WIDESEA_Common.Log; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_DTO.Enum; using WIDESEAWCS_ISystemServices; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_Model.Models.System; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_Tasks.ConveyorLineJob; namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] public class CommonConveyorLineJob : IJob { private readonly ITaskService _taskService; private readonly ITaskExecuteDetailService _taskExecuteDetailService; private readonly IRouterService _routerService; private readonly IAgvStationService _agvStationService; private readonly IMapper _mapper; public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IAgvStationService agvStation, IMapper mapper) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; _routerService = routerService; _agvStationService = agvStation; _mapper = mapper; } public Task Execute(IJobExecutionContext context) { try { wcsWriteLog("LineJob", "运行状态", $"开始时间:{DateTime.Now}"); CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); if (conveyorLine != null) { //生成取货任务,放至上料位 RequestInbound(conveyorLine); //根据agv下料任务,把料放至上料口或缓存位 RequestOutbound(conveyorLine); //上料口需要找任务,找缓存区 } } catch (Exception ex) { //Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); wcsWriteLog("LineJob错误信息", "异常信息", ex.ToString()); } wcsWriteLog("LineJob", "运行状态", $"结束时间:{DateTime.Now}"); return Task.CompletedTask; } /// /// 输送线请求入库 /// /// 输送线实例对象 /// 读取的请求信息Request outbound /// 子设备编号 public void RequestInbound(CommonConveyorLine conveyorLine) { List _Task = _taskService.QueryConveyorLineTaskSourceAddress(); List childDeviceCodes = _agvStationService.QuerypLatform(conveyorLine.DeviceCode, _Task); //对应每个ip找全部的下料站点与垫板回收点站台点 foreach (var childDeviceCode in childDeviceCodes) { ConveyorLineCommand command = conveyorLine.ReadCustomer(childDeviceCode.Station_name); if (command != null) { if (command.R_Releasespermitted == 1) { if (childDeviceCode.Station_material==(int)AgvStationEnum.PadRecycle) { RequestHcdbst(conveyorLine, childDeviceCode.Station_Area, childDeviceCode.Station_name, childDeviceCode.Station_remark); } else { Dt_Task taskDTO = new Dt_Task() { TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")) + childDeviceCode.Station_code, Grade = 1, Roadway = childDeviceCode.Station_Area.ToString(), SourceAddress = childDeviceCode.Station_name, CurrentAddress = childDeviceCode.Station_name, TaskState = (int)TaskInStatusEnum.InNew, TaskType = (int)childDeviceCode.Station_material, }; _taskService.ReceiveWMSTask(taskDTO); } } else { wcsWriteLog(childDeviceCode.Station_name, "读取信息", $"未找到该读取模块"); } } else { wcsWriteLog(childDeviceCode.Station_name, "读取信息", $"通讯连接错误,未找到读取模块地址"); } } } /// /// 输送线请求出站 /// /// 输送线实例对象 /// 读取的请求信息 /// 子设备编号 public void RequestOutbound(CommonConveyorLine conveyorLine) { List AGVStationListdata = _agvStationService.QuerypLatformarer(conveyorLine.DeviceCode); foreach (var AGVStationitem in AGVStationListdata) { ConveyorLineCommand command = conveyorLine.ReadCustomer(AGVStationitem.Station_name); if (command != null) { if (command.R_Pickuppermitted == 1) { if (AGVStationitem.Station_material == (int)AgvStationEnum.BoardLoad) { Dt_Task agvstack= _taskService.QueryConveyorLineTaskRoadway(AGVStationitem.Station_Area); if(agvstack != null) { _taskService.UpdateTargetAddress(agvstack.TaskId, AGVStationitem.Station_name); } else { //去找缓存区库存 RequestHcst(conveyorLine, AGVStationitem.Station_Area, AGVStationitem.Station_name, AGVStationitem.Station_remark); } } } else { wcsWriteLog(AGVStationitem.Station_name, "读取信息", $"通讯连接错误,未找到读取模块地址"); } } } } public void RequestHcst(CommonConveyorLine conveyorLine,int Station_Area,string Station_names,string Station_remark) { List AGVStationListdata = _agvStationService.QuerypLatformmaterial(Station_Area); //查出缓存位 if (Station_remark != null) //找寻对应的放货站台 { AGVStationListdata = _agvStationService.QuerypStation_Area2(Station_remark); } foreach (var AGVStationitem in AGVStationListdata) { ConveyorLineCommand command = conveyorLine.ReadCustomer(AGVStationitem.Station_name); if (command != null) { if (command.R_Releasespermitted == 1) { if (_taskService.QueryConveyorLinetaeersuadd(AGVStationitem.Station_name)) { Dt_Task taskDTO = new Dt_Task() { TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")) + AGVStationitem.Station_code, Grade = 1, Roadway = AGVStationitem.Station_Area.ToString(), SourceAddress = AGVStationitem.Station_name, CurrentAddress = AGVStationitem.Station_name, TaskState = (int)TaskInStatusEnum.InNew, TaskType = (int)AGVStationitem.Station_material, TargetAddress = Station_names, NextAddress = Station_names, }; _taskService.ReceiveWMSTask(taskDTO); } } else { wcsWriteLog(AGVStationitem.Station_name, "读取信息", $"通讯连接错误,未找到读取模块地址"); } } } } public void RequestHcdbst(CommonConveyorLine conveyorLine, int Station_Area, string Station_names,string Station_remark) { List AGVStationListdata = _agvStationService.QuerypStation_Area(Station_Area); //查出缓存位 if(Station_remark !=null) //找寻对应的放货站台 { AGVStationListdata= _agvStationService.QuerypStation_Area2(Station_remark); } foreach (var AGVStationitem in AGVStationListdata) { ConveyorLineCommand command = conveyorLine.ReadCustomer(AGVStationitem.Station_name); if (command != null) { if (command.R_Releasespermitted == 1) { if (_taskService.QueryConveyorLinetaeersuadd(AGVStationitem.Station_name)) { Dt_Task taskDTO = new Dt_Task() { TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")) + AGVStationitem.Station_code, Grade = 1, Roadway = AGVStationitem.Station_Area.ToString(), SourceAddress = Station_names, CurrentAddress = Station_names, TaskState = (int)TaskInStatusEnum.InNew, TaskType = (int)AGVStationitem.Station_material, TargetAddress = AGVStationitem.Station_name, NextAddress = AGVStationitem.Station_name, }; _taskService.ReceiveWMSTask(taskDTO); } } else { wcsWriteLog(AGVStationitem.Station_name, "读取信息", $"读取放货信号为:{command.R_Releasespermitted}"); } } } } /// /// 读取信息记录 /// /// /// /// public void wcsWriteLog(string SCLLinStack,string Logtype,string Magessadd) { WriteLog.Write_Log("站台读取信息记录", SCLLinStack+"站台", Logtype, new{信息 = Magessadd }); } } }