using HslCommunication;
|
using Mapster;
|
using Newtonsoft.Json;
|
using System.Text.RegularExpressions;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_Model.BasicInfo;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_Tasks.ConveyorLineJob;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
public partial class CommonConveyorLineJob
|
{
|
public async Task HandleNewTaskAsync(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 1:
|
await RequestTask(conveyorLine, command, childDeviceCode, stationManager);
|
break;
|
|
case 2:
|
case 3:
|
RequestInOrOutbound(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);
|
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);
|
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" });
|
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)
|
{
|
RGVName = "RGV01";
|
}
|
else
|
{
|
RGVName = "RGV02";
|
}
|
}
|
|
Dt_Task task = new Dt_Task()
|
{
|
TaskNum = _taskRepository.GetTaskNo().Result,
|
TaskType = (int)TaskInboundTypeEnum.Inbound,
|
TaskState = (int)TaskInStatusEnum.InNew,
|
SourceAddress = childDeviceCode,
|
Dispatchertime = DateTime.Now,
|
Grade = 1, // 设置默认优先级为1
|
Creater = "System",
|
Floor = stationManager.stationFloor,
|
RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName,
|
};
|
_taskRepository.AddData(task);
|
}
|
}
|
}
|