using HslCommunication;
|
using HslCommunication.WebSocket;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
|
using Quartz;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_DTO.AGV;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_DTO.WMS;
|
using WIDESEAWCS_ISystemServices;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_TaskInfoRepository;
|
using WIDESEAWCS_Tasks.ConveyorLineJob;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
[DisallowConcurrentExecution]
|
public class CommonAGVJob : JobBase, IJob
|
{
|
private readonly ITaskRepository _taskRepository;
|
private readonly ITaskService _taskService;
|
private readonly ISys_ConfigService _sys_ConfigService;
|
public CommonAGVJob(ITaskRepository taskRepository, ITaskService taskService, ISys_ConfigService configService)
|
{
|
_taskRepository = taskRepository;
|
_taskService = taskService;
|
_sys_ConfigService = configService;
|
}
|
|
public Task Execute(IJobExecutionContext context)
|
{
|
var tasks = _taskRepository.QueryData(x => x.TaskState == (int)TaskInStatusEnum.InNew || x.TaskState == (int)TaskOutStatusEnum.OutNew).ToList();
|
foreach (var item in tasks)
|
{
|
TaskModel taskModel = new TaskModel()
|
{
|
taskType = item.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup ? "putaway" : "carry",
|
taskGroupCode = "taskGroupCode-001",
|
groupPriority = 0,
|
tasks = new List<TasksType>
|
{
|
new()
|
{
|
taskCode="KH"+item.TaskNum.ToString(),
|
taskPriority=0,
|
taskDescribe = new TaskDescribeType
|
{
|
containerCode = item.PalletCode,
|
containerType = "CT_KUBOT_STANDARD",
|
fromLocationCode = item.SourceAddress,
|
toStationCode = "",
|
toLocationCode = item.TargetAddress,
|
deadline = 0,
|
}
|
}
|
}
|
};
|
var wmsIpAddress = GetIpAddress(SysConfigKeyConst.ESSIP_BASE, SysConfigKeyConst.SendTask);
|
var result = HttpHelper.PostAsync(wmsIpAddress, taskModel.ToJsonString()).Result;
|
var response = JsonConvert.DeserializeObject<Response>(result);
|
if (response != null && response.Msg == "success")
|
{
|
//item.TaskState = item.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup ? (int)TaskInStatusEnum.HasSend : (int)TaskOutStatusEnum.HasSend;
|
//_taskRepository.Db.Updateable(item).ExecuteCommandAsync();
|
_taskService.UpdateTaskStatusToNext(item.TaskNum);
|
}
|
}
|
return Task.CompletedTask;
|
}
|
|
private string GetIpAddress(string baseIp, string name)
|
{
|
var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
|
var wcsBasez = configz.Where(x => x.ConfigKey == baseIp).FirstOrDefault()?.ConfigValue;
|
var address = configz.Where(x => x.ConfigKey == name).FirstOrDefault()?.ConfigValue;
|
if (wcsBasez == null || address == null)
|
{
|
throw new InvalidOperationException("WMS IP 未配置");
|
}
|
return wcsBasez + address;
|
}
|
}
|
}
|