using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Xml.Linq;
|
using WIDESEA_Comm;
|
using WIDESEA_Comm.LogInfo;
|
using WIDESEA_Core.BaseProvider;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_WCS.IRepositories;
|
using WIDESEA_WCS.Repositories;
|
using WIDESEA_WCS.WCSClient;
|
using WIDESEA_WMS.IRepositories;
|
using WIDESEA_WMS.IServices;
|
using WIDESEA_WMS.Repositories;
|
|
namespace WIDESEA_WCS.JobsPart.Common
|
{
|
public class RestockHCJ_a
|
{
|
/// <summary>
|
/// 更新队列任务
|
/// </summary>
|
public static void HCJGetBarcode()
|
{
|
try
|
{
|
VOLContext Context = new VOLContext();
|
Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
|
Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context);
|
var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList();
|
foreach (var task in tasks)
|
{
|
if (task.agv_tasktype == "TaskType_EmptyPallet")//空托任务
|
{
|
if (task.agv_fromaddress == "")
|
{
|
var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "链条机");
|
if (Pipeline_client == null) throw new Exception("链条机调度服务未开启!");
|
if (!Pipeline_client.IsConnected) throw new Exception("与链条机连接超时!");
|
var area = task.agv_Traytype == "SmallTray" ? "11" : "10";
|
|
#region 查找一库区的空托盘库位
|
var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.enable).OrderBy(x => x.column).OrderBy(x => x.line).FirstOrDefault();
|
if (EmptyStation == null) return;
|
if (EmptyStation == null)
|
EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable).OrderBy(x => x.line).OrderBy(x => x.column).FirstOrDefault();
|
#endregion
|
|
}
|
}
|
else if (task.agv_tasktype == "TaskType_OutsourceOutbound" || task.agv_tasktype == "TaskType_Outbound")//外协库出库/AB库出库
|
{
|
if (task.agv_toaddress == "")
|
{
|
var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && x.location_state == "Empty" && x.enable).ToList();
|
foreach (var EmptyStation in EmptyStations)
|
{
|
if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue;
|
task.agv_taskstate = "Create";
|
task.agv_toaddress = EmptyStation.stationCode;
|
EmptyStation.location_state = LocationStateEnum.Busy.ToString();
|
stationinfoRepository.Update(EmptyStation, true);
|
agvtaskService.Update(task, true);
|
WriteDBLog.Success("更新出库队列任务", $"任务编号:{task.agv_tasknum}", "PCS");
|
return;
|
}
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteDBLog.Error("更新队列任务", $"错误信息:{ex.Message}", "PCS");
|
}
|
}
|
}
|
}
|