using Autofac.Core;
|
using Microsoft.AspNetCore.Components.Routing;
|
using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
using Quartz;
|
using System;
|
using System.Collections.Generic;
|
using System.IdentityModel.Tokens.Jwt;
|
using System.Linq;
|
using System.Reflection.Metadata;
|
using System.Text;
|
using System.Text.Unicode;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.Helper;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Communicator;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_IBasicInfoRepository;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
|
using WIDESEAWCS_QuartzJob.DTO;
|
using WIDESEAWCS_QuartzJob.Models;
|
using WIDESEAWCS_QuartzJob.Repository;
|
using WIDESEAWCS_QuartzJob.Service;
|
using WIDESEAWCS_Tasks.DBNames;
|
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
[DisallowConcurrentExecution]
|
public class ConveyorLineJob1 : JobBase, IJob
|
{
|
private readonly ICacheService _cacheService;
|
private readonly ITaskService _taskService;
|
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
|
private readonly ITaskRepository _taskRepository;
|
private readonly IStationMangerRepository _stationMangerRepository;
|
private readonly IRouterRepository _routerRepository;
|
private readonly IRouterService _routerService;
|
private readonly IRouterExtension _routerExtension;
|
|
public ConveyorLineJob1(ICacheService cacheService, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IRouterService routerService, IRouterExtension routerExtension)
|
{
|
_cacheService = cacheService;
|
_taskService = taskService;
|
_taskExecuteDetailService = taskExecuteDetailService;
|
_taskRepository = taskRepository;
|
_stationMangerRepository = stationMangerRepository;
|
_routerRepository = routerRepository;
|
_routerService = routerService;
|
_routerExtension = routerExtension;
|
}
|
/*
|
1号位出库口允许放箱 0
|
1号位放箱完成信号 21
|
6号位拣选位料箱到达 1
|
6号位拣选位料箱条码 2
|
6号位拣选位料箱流动 22
|
8号位入库口允许取箱 11
|
8号位入库口料箱条码 12
|
8号位机器人取箱完成 23
|
*/
|
public Task Execute(IJobExecutionContext context)
|
{
|
try
|
{
|
bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
|
if (flag && value != null)
|
{
|
OtherDevice device = (OtherDevice)value;
|
List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
|
|
foreach (var station in stationMangers)
|
{
|
if (station.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
|
{
|
|
//拣选申请
|
short pickArrived = device.Communicator.Read<short>("1");
|
if (pickArrived == 256)
|
{
|
byte[] bytesPick = device.Communicator.Read("2", 5);
|
string pickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", "");
|
//上报WMS料箱到达
|
if (pickBarCode.IsNotEmptyOrNull())
|
{
|
WebResponseContent content = _taskService.WMSPickUp(station.PickStationCode, pickBarCode);
|
if (content.Status)
|
{
|
WriteInfo(device.DeviceCode, $"{station.PickStationCode}拣选申请上报成功{pickBarCode}");
|
}
|
else
|
{
|
WriteError(device.DeviceCode, $"{station.PickStationCode}拣选申请上报WMS错误{pickBarCode},信息{content.Message}");
|
}
|
}
|
else
|
{
|
WriteError(device.DeviceCode, $"{station.PickStationCode}拣选申请为{pickArrived}条码为空值");
|
}
|
}
|
}
|
else
|
{
|
//入库申请
|
short InTake = device.Communicator.Read<short>("11");
|
byte[] bytesIn = device.Communicator.Read("12", 5);
|
string InBarCode = Encoding.UTF8.GetString(bytesIn).Replace("\0", "").Replace("\\0", "");
|
if (InTake==256 && InBarCode.IsNotEmptyOrNull())
|
{
|
//申请入库任务
|
Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == InBarCode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt() && x.TaskState != TaskStatusEnum.CL_Executing.ObjToInt());
|
if (task != null) continue;
|
|
WebResponseContent content = _taskService.RequestInTask(station.StationCode, InBarCode);
|
if (content.Status)
|
{
|
WriteInfo(device.DeviceCode, $"站台{station.StationCode}料箱{InBarCode}申请入库成功");
|
}
|
else
|
{
|
WriteError(device.DeviceCode, $"站台{station.StationCode}料箱{InBarCode}申请入库任务错误,信息{content.Message}");
|
}
|
}
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteError(nameof(ConveyorLineJob1), ex.Message);
|
}
|
return Task.CompletedTask;
|
}
|
}
|
}
|