#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;
|
}
|
|
/// <summary>
|
/// 输送线请求入库
|
/// </summary>
|
/// <param name="conveyorLine">输送线实例对象</param>
|
/// <param name="command">读取的请求信息</param>Request outbound
|
/// <param name="childDeviceCode">子设备编号</param>
|
public void RequestInbound(CommonConveyorLine conveyorLine)
|
{
|
List<string> _Task = _taskService.QueryConveyorLineTaskSourceAddress();
|
List<AGVStation> childDeviceCodes = _agvStationService.QuerypLatform(conveyorLine.DeviceCode, _Task); //对应每个ip找全部的下料站点与垫板回收点站台点
|
foreach (var childDeviceCode in childDeviceCodes)
|
{
|
ConveyorLineCommand command = conveyorLine.ReadCustomer<ConveyorLineCommand>(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, "读取信息", $"通讯连接错误,未找到读取模块地址");
|
}
|
}
|
}
|
|
/// <summary>
|
/// 输送线请求出站
|
/// </summary>
|
/// <param name="conveyorLine">输送线实例对象</param>
|
/// <param name="command">读取的请求信息</param>
|
/// <param name="childDeviceCode">子设备编号</param>
|
public void RequestOutbound(CommonConveyorLine conveyorLine)
|
{
|
List<AGVStation> AGVStationListdata = _agvStationService.QuerypLatformarer(conveyorLine.DeviceCode);
|
foreach (var AGVStationitem in AGVStationListdata)
|
{
|
ConveyorLineCommand command = conveyorLine.ReadCustomer<ConveyorLineCommand>(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<AGVStation> AGVStationListdata = _agvStationService.QuerypLatformmaterial(Station_Area); //查出缓存位
|
if (Station_remark != null) //找寻对应的放货站台
|
{
|
AGVStationListdata = _agvStationService.QuerypStation_Area2(Station_remark);
|
}
|
foreach (var AGVStationitem in AGVStationListdata)
|
{
|
ConveyorLineCommand command = conveyorLine.ReadCustomer<ConveyorLineCommand>(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<AGVStation> 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<ConveyorLineCommand>(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}");
|
}
|
}
|
}
|
}
|
|
|
|
/// <summary>
|
/// 读取信息记录
|
/// </summary>
|
/// <param name="SCLLinStack"></param>
|
/// <param name="Logtype"></param>
|
/// <param name="Magessadd"></param>
|
public void wcsWriteLog(string SCLLinStack,string Logtype,string Magessadd)
|
{
|
WriteLog.Write_Log("站台读取信息记录", SCLLinStack+"站台", Logtype, new{信息 = Magessadd });
|
}
|
|
}
|
}
|