using Masuit.Tools;
|
using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
using WIDESEA_Comm;
|
using WIDESEA_Comm.WCSInterface.Requst;
|
using WIDESEA_Common;
|
using WIDESEA_Core;
|
using WIDESEA_Core.Const;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_DTO;
|
using WIDESEA_Model.Models;
|
using WIDESEA_StorageTaskRepository;
|
|
|
namespace WIDESEA_StoragIntegrationServices
|
{
|
public partial class ToAGVService
|
{
|
/// <summary>
|
/// 下发AGV任务 --待测试完善
|
/// </summary>
|
/// <param name="jsondata"></param>
|
/// <returns></returns>
|
public WebResponseContent genAgvSchedulingTask(RequestTaskDto input)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
if (input.RequestType == "999")
|
{
|
int CZInfotli = _task_CZInfoRepository.QueryData(x => x.CurrentStatue == "3").Count();
|
if (CZInfotli == 0)
|
{
|
return content.Error($"没有自动取轴任务,无自动任务");
|
}
|
}
|
|
if (string.IsNullOrEmpty(input.Position)) { return content.Error($"agv任务下发申请目标地址为空!!!请检查"); }
|
|
//查找当前在车轴线末端需要agv搬运的车轴
|
|
List<Dt_CZInfo_mes> CZInfotlist = _task_CZInfoRepository.QueryData(x => x.CurrentStatue == "3" /*|| x.CurrentStatue == "4" || x.CurrentStatue == "5"*/ || x.CurrentStatue == "13");
|
|
if (CZInfotlist.Count >= 2) { return content.Error($"已有agv任务正在进行中,下发失败!!!"); }
|
|
Dt_CZInfo_mes CZInfot = CZInfotlist.FirstOrDefault(x => x.CurrentStatue == "3" || x.CurrentStatue == "13");
|
if (CZInfot == null) { return content.Error($"未找到现有输送线完成的车轴信息"); }
|
|
CZInfot.CurrentStatue = "4";
|
|
|
//查找车轴对应的车轮信息
|
List<Dt_Task> tasks=_taskRepository.QueryData(x => x.task_CZInfo == CZInfot.CZH).ToList();
|
if (tasks.Count > 0)
|
{
|
foreach (var task in tasks)
|
{
|
task.Towhereabouts = input.Position;
|
}
|
}
|
|
string agvtarget = "F1";
|
if (input.Position == "2033")
|
{
|
agvtarget = "F2";
|
}
|
|
//agv参数调取
|
genAgvSchedulingTask schedulingTask = new genAgvSchedulingTask
|
{
|
reqCode = $"{DateTime.Now:yyyyMMddHHmmss}",
|
clientCode = "WMS",
|
taskTyp = "BY",
|
ctnrTyp = "1",
|
//data = taskinfo.task_barcode,
|
positionCodePath = new List<position>
|
{
|
new position { positionCode = "Q", type = "00" },
|
new position { positionCode = agvtarget, type = "00" }, //地址待更改为 F1 左边 F2 右边
|
},
|
};
|
|
CZInfot.AGVaddres = input.Position;
|
|
//编写调取agv接口
|
string ipaddress = AGV_Interface;
|
|
var requestBindInfo = schedulingTask.ToDictionary();
|
|
var respon = HttpHelper.Post(ipaddress, JsonConvert.SerializeObject(schedulingTask));
|
|
|
var responBase = JsonConvert.DeserializeObject<AGVResponBase>(respon);
|
|
|
|
|
if (responBase.code == "0")
|
{
|
_task_CZInfoRepository.UpdateData(CZInfot);
|
if (tasks.Count > 0)
|
{
|
_taskRepository.UpdateData(tasks);
|
}
|
|
LogFactory.GetLog("下发AGV任务").Info(true, $"调取agv任务成功,修改了车轴条码:{CZInfot.CZTM}的状态改至:{CZInfot.CurrentStatue}");
|
content.OK($"agv任务下发成功.");
|
return content;
|
}
|
else
|
{
|
LogFactory.GetLog("下发AGV任务").Error(true, $"调取agv任务失败,返回信息:{responBase.message}");
|
return content.Error($"请求异常:{responBase.message}");
|
}
|
|
}
|
catch (Exception ex)
|
{
|
LogFactory.GetLog("下发AGV任务").Error(true, ex.Message);
|
return content.Error($"下发任务接口异常:{ex.Message}");
|
}
|
}
|
}
|
}
|