ctu
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Security.Policy;
|
||||||
|
using Aop.Api.Domain;
|
||||||
using JNPF;
|
using JNPF;
|
||||||
using JNPF.Common.Contracts;
|
using JNPF.Common.Contracts;
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
@@ -15,14 +17,17 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using NetTaste;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NPOI.OpenXmlFormats.Dml;
|
using NPOI.OpenXmlFormats.Dml;
|
||||||
|
using Org.BouncyCastle.Crypto;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.Common.Extension;
|
using Tnb.Common.Extension;
|
||||||
using Tnb.Common.Redis;
|
using Tnb.Common.Redis;
|
||||||
using Tnb.Common.Utils;
|
using Tnb.Common.Utils;
|
||||||
|
using Tnb.ProductionMgr.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities.Configs;
|
using Tnb.WarehouseMgr.Entities.Configs;
|
||||||
using Tnb.WarehouseMgr.Entities.Consts;
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
@@ -50,10 +55,11 @@ namespace Tnb.WarehouseMgr
|
|||||||
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
|
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
|
||||||
private static Dictionary<string, object> locMap = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
private static Dictionary<string, object> locMap = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly RedisData _redisData;
|
||||||
public Func<string, int, Task> AddUnExecuteTask { get; set; }
|
public Func<string, int, Task> AddUnExecuteTask { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService,
|
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, RedisData redisData,
|
||||||
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService
|
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService
|
||||||
//IConfiguration configuration
|
//IConfiguration configuration
|
||||||
) : base(repository.AsSugarClient())
|
) : base(repository.AsSugarClient())
|
||||||
@@ -64,6 +70,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_cacheManager = cacheManager;
|
_cacheManager = cacheManager;
|
||||||
_elevatorControlService = elevatorControlService;
|
_elevatorControlService = elevatorControlService;
|
||||||
|
_redisData = redisData;
|
||||||
//_configuration = configuration;
|
//_configuration = configuration;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -270,11 +277,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
SqlSugarClient db = _db.CopyNew();
|
SqlSugarClient db = _db.CopyNew();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//一楼中储仓CTU
|
|
||||||
CTUTaskExecute(db);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//获取电梯数据
|
//获取电梯数据
|
||||||
/*List<WmsElevatorH> elevatorList = await db.Queryable<WmsElevatorH>().InnerJoin<WmsElevatorD>((a, b) => a.id == b.bill_id)
|
/*List<WmsElevatorH> elevatorList = await db.Queryable<WmsElevatorH>().InnerJoin<WmsElevatorD>((a, b) => a.id == b.bill_id)
|
||||||
.Where((a, b) => a.enabled == 1)
|
.Where((a, b) => a.enabled == 1)
|
||||||
@@ -328,7 +330,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
preTasks = normalPreTasks.Concat(agvElevatorTasks).Concat(elePreTasks).ToList();
|
preTasks = normalPreTasks.Concat(agvElevatorTasks).Concat(elePreTasks).ToList();
|
||||||
|
|
||||||
|
//一楼中储仓CTU
|
||||||
|
CTUTaskExecute();
|
||||||
List<string> ids = preTasks.Select(x => x.id).Distinct().ToList();
|
List<string> ids = preTasks.Select(x => x.id).Distinct().ToList();
|
||||||
List<WmsPretaskCode>? preTaskCodes = await db.Queryable<WmsPretaskCode>().Where(it => ids.Contains(it.bill_id)).ToListAsync();
|
List<WmsPretaskCode>? preTaskCodes = await db.Queryable<WmsPretaskCode>().Where(it => ids.Contains(it.bill_id)).ToListAsync();
|
||||||
if (preTasks.Count > 0)
|
if (preTasks.Count > 0)
|
||||||
@@ -501,6 +504,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) when (ex is HttpRequestException hReqEx)
|
catch (Exception ex) when (ex is HttpRequestException hReqEx)
|
||||||
{
|
{
|
||||||
@@ -519,30 +524,278 @@ namespace Tnb.WarehouseMgr
|
|||||||
agvCts.Dispose();
|
agvCts.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#region CTU
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成CTU任务执行
|
/// 生成CTU任务执行
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task CTUTaskExecute(SqlSugarClient db)
|
private async Task CTUTaskExecute()
|
||||||
{
|
{
|
||||||
List<WmsPretaskH> preTasks = await db.Queryable<WmsPretaskH>()
|
try
|
||||||
.InnerJoin<WmsCarryH>((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id)
|
{
|
||||||
.InnerJoin<WmsAreaH>((a, b, c) => a.area_id == c.id)
|
var db = _db.CopyNew();
|
||||||
.InnerJoin<BasLocation>((a, b, c, d) => a.endlocation_id == d.id && d.is_use == "0")
|
Logger.Information("进入CTUTaskExecute");
|
||||||
.Where(a => a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID && !string.IsNullOrWhiteSpace(a.startlocation_id))
|
List<WmsPretaskH> CTUTasks = await db.Queryable<WmsPretaskH>()
|
||||||
.OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code })
|
.InnerJoin<WmsAreaH>((a, b) => a.area_id == b.id)
|
||||||
.Select((a, b, c, d) => new WmsPretaskH
|
.Where(a => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID)
|
||||||
{
|
.Where((a, b) => b.code == "B")//一楼中储仓
|
||||||
move_num = c.move_num,
|
.OrderBy(a => a.create_id)
|
||||||
third_eqp_type = c.third_eqp_type,
|
.Select((a, b) => new WmsPretaskH
|
||||||
}, true)
|
{
|
||||||
.ToListAsync();
|
move_num = b.move_num,
|
||||||
List<WmsPretaskH> CTUTasks = preTasks
|
third_eqp_type = b.third_eqp_type,
|
||||||
.Where(it => it.endlocation_code.StartsWith("DT", StringComparison.OrdinalIgnoreCase) &&
|
}, true).ToListAsync();
|
||||||
!it.area_code.Contains("ELE", StringComparison.OrdinalIgnoreCase))
|
List<WmsPretaskCode> TaskCodes = await db.Queryable<WmsPretaskCode>().Where(it => CTUTasks.Select(p => p.id).ToList().Contains(it.bill_id)).ToListAsync();
|
||||||
.ToList();
|
var InTasks = CTUTasks.Where(a => a.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID).ToList();
|
||||||
}
|
var OutTasks = CTUTasks.Where(a => a.task_type == WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID).ToList();
|
||||||
|
var OriginDistaskHs = await db.Queryable<WmsDistaskH>()
|
||||||
|
.InnerJoin<WmsAreaH>((a, b) => a.area_id == b.id)
|
||||||
|
.Where((a, b) => b.code == "B" && a.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID)
|
||||||
|
.OrderBy(a => a.bill_code)
|
||||||
|
.ToListAsync();
|
||||||
|
List<WmsDistaskH> DistaskHs = new List<WmsDistaskH>();
|
||||||
|
List<WmsDistaskH> UpDistaskHs = new List<WmsDistaskH>();
|
||||||
|
List<WmsDistaskCode> DistaskCodes = new List<WmsDistaskCode>();
|
||||||
|
var inCtuExec = new List<WmsDistaskH>();
|
||||||
|
var outCtuExec = new List<WmsDistaskH>();
|
||||||
|
foreach (var item in InTasks)
|
||||||
|
{
|
||||||
|
WmsDistaskH distaskH = item.Adapt<WmsDistaskH>();
|
||||||
|
distaskH.id = SnowflakeIdHelper.NextId();
|
||||||
|
distaskH.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID;
|
||||||
|
distaskH.is_chain = 1;
|
||||||
|
distaskH.create_time = DateTime.Now;
|
||||||
|
var billcode = GetBillCode(OriginDistaskHs, DistaskHs, distaskH);
|
||||||
|
distaskH.groups = billcode.Substring(0, billcode.Length - 2);
|
||||||
|
distaskH.bill_code = billcode;
|
||||||
|
var num = int.Parse(distaskH.bill_code.Substring(billcode.Length - 1, 1));
|
||||||
|
if (num == item.move_num)
|
||||||
|
{
|
||||||
|
distaskH.status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID;
|
||||||
|
inCtuExec.Add(distaskH);
|
||||||
|
if (OriginDistaskHs.Where(p => p.groups == distaskH.groups).Any())
|
||||||
|
{
|
||||||
|
OriginDistaskHs.Where(p => p.groups == distaskH.groups).ToList().ForEach(p => p.status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID);
|
||||||
|
|
||||||
|
UpDistaskHs.AddRange(OriginDistaskHs.Where(p => p.groups == distaskH.groups).ToList());
|
||||||
|
inCtuExec.AddRange(OriginDistaskHs.Where(p => p.groups == distaskH.groups).ToList());
|
||||||
|
}
|
||||||
|
if (DistaskHs.Where(p => p.groups == distaskH.groups).Any())
|
||||||
|
{
|
||||||
|
DistaskHs.Where(p => p.groups == distaskH.groups).ToList().ForEach(p => p.status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID);
|
||||||
|
inCtuExec.AddRange(DistaskHs.Where(p => p.groups == distaskH.groups).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<WmsPretaskCode> preTaskCodes = TaskCodes.FindAll(x => x.bill_id == distaskH.pretask_id);
|
||||||
|
List<WmsDistaskCode> disTaskCodes = preTaskCodes.Adapt<List<WmsDistaskCode>>();
|
||||||
|
disTaskCodes.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
|
x.bill_id = distaskH.id;
|
||||||
|
x.create_time = DateTime.Now;
|
||||||
|
});
|
||||||
|
DistaskHs.Add(distaskH);
|
||||||
|
DistaskCodes.AddRange(disTaskCodes);
|
||||||
|
}
|
||||||
|
foreach (var item in OutTasks)
|
||||||
|
{
|
||||||
|
WmsDistaskH distaskH = item.Adapt<WmsDistaskH>();
|
||||||
|
distaskH.id = SnowflakeIdHelper.NextId();
|
||||||
|
distaskH.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID;
|
||||||
|
distaskH.is_chain = 1;
|
||||||
|
distaskH.create_time = DateTime.Now;
|
||||||
|
var billcode = GetBillCode(OriginDistaskHs, DistaskHs, distaskH);
|
||||||
|
distaskH.groups = billcode.Substring(0, billcode.Length - 2);
|
||||||
|
distaskH.bill_code = billcode;
|
||||||
|
var num = int.Parse(distaskH.bill_code.Substring(billcode.Length - 1, 1));
|
||||||
|
if (num == item.move_num)
|
||||||
|
{
|
||||||
|
distaskH.status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID;
|
||||||
|
outCtuExec.Add(distaskH);
|
||||||
|
if (OriginDistaskHs.Where(p => p.groups == distaskH.groups).Any())
|
||||||
|
{
|
||||||
|
OriginDistaskHs.Where(p => p.groups == distaskH.groups).ToList().ForEach(p => p.status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID);
|
||||||
|
|
||||||
|
UpDistaskHs.AddRange(OriginDistaskHs.Where(p => p.groups == distaskH.groups).ToList());
|
||||||
|
outCtuExec.AddRange(OriginDistaskHs.Where(p => p.groups == distaskH.groups).ToList());
|
||||||
|
}
|
||||||
|
if (DistaskHs.Where(p => p.groups == distaskH.groups).Any())
|
||||||
|
{
|
||||||
|
DistaskHs.Where(p => p.groups == distaskH.groups).ToList().ForEach(p => p.status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID);
|
||||||
|
outCtuExec.AddRange(DistaskHs.Where(p => p.groups == distaskH.groups).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<WmsPretaskCode> preTaskCodes = TaskCodes.FindAll(x => x.bill_id == distaskH.pretask_id);
|
||||||
|
List<WmsDistaskCode> disTaskCodes = preTaskCodes.Adapt<List<WmsDistaskCode>>();
|
||||||
|
disTaskCodes.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
|
x.bill_id = distaskH.id;
|
||||||
|
x.create_time = DateTime.Now;
|
||||||
|
});
|
||||||
|
DistaskHs.Add(distaskH);
|
||||||
|
DistaskCodes.AddRange(disTaskCodes);
|
||||||
|
}
|
||||||
|
await db.Ado.BeginTranAsync();
|
||||||
|
int row = 0;
|
||||||
|
if (UpDistaskHs.Count > 0)
|
||||||
|
{
|
||||||
|
await db.Updateable<WmsDistaskH>().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID }).Where(it => UpDistaskHs.Select(p => p.id).ToList().Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
if (DistaskHs.Count > 0)
|
||||||
|
{
|
||||||
|
row = await db.Insertable(DistaskHs).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
if (DistaskCodes.Count > 0)
|
||||||
|
{
|
||||||
|
await db.Insertable(DistaskCodes).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
if (row > 0)
|
||||||
|
{
|
||||||
|
List<string> preTaskIds = DistaskHs.Select(x => x.pretask_id).ToList();
|
||||||
|
await db.Updateable<WmsPretaskH>().SetColumns(it => new WmsPretaskH { status = WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID }).Where(it => preTaskIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
await db.Ado.CommitTranAsync();
|
||||||
|
//判断
|
||||||
|
if (DistaskHs.Where(p => p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID).Any())
|
||||||
|
{
|
||||||
|
timer = new Timer(TimerExec, null, TimeSpan.Zero, TimeSpan.FromMinutes(10));
|
||||||
|
}
|
||||||
|
if (inCtuExec.Count > 0)
|
||||||
|
{
|
||||||
|
//呼叫ctu入库
|
||||||
|
CancellationTokenSource Ctu = new();
|
||||||
|
await CallingCTU(inCtuExec, Ctu.Token, 1);
|
||||||
|
Ctu.Dispose();
|
||||||
|
}
|
||||||
|
if (outCtuExec.Count > 0)
|
||||||
|
{
|
||||||
|
//呼叫ctu出库
|
||||||
|
CancellationTokenSource Ctu = new();
|
||||||
|
await CallingCTU(outCtuExec, Ctu.Token, 0);
|
||||||
|
Ctu.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Information("CTUTaskExecute方法报错"+ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断生成bill_code
|
||||||
|
private string GetBillCode(List<WmsDistaskH> OriginDistaskH, List<WmsDistaskH> NewdistaskHs, WmsDistaskH distaskH)
|
||||||
|
{
|
||||||
|
string BillCode = string.Empty;
|
||||||
|
//入库
|
||||||
|
if (distaskH.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID)
|
||||||
|
{
|
||||||
|
var orgdistaskHs = OriginDistaskH.Where(p => p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID && p.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID && p.startpoint_id == distaskH.startpoint_id).ToList();
|
||||||
|
var newdistaskHs = NewdistaskHs = OriginDistaskH.Where(p => p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID && p.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID && p.startpoint_id == distaskH.startpoint_id).ToList();
|
||||||
|
if ((orgdistaskHs.Count + newdistaskHs.Count) == 0)
|
||||||
|
{
|
||||||
|
var groups = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TASK_EXECUTE_ENCODE).Result;
|
||||||
|
BillCode = $"{groups}-1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var groups = orgdistaskHs.Count > 0 ? orgdistaskHs.First().groups : newdistaskHs.First().groups;
|
||||||
|
BillCode = $"{groups}-" + (orgdistaskHs.Count + newdistaskHs.Count + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (distaskH.task_type == WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID)
|
||||||
|
{
|
||||||
|
var orgdistaskHs = OriginDistaskH.Where(p => p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID && p.task_type == WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID && p.endpoint_id == distaskH.endpoint_id).ToList();
|
||||||
|
var newdistaskHs = NewdistaskHs = OriginDistaskH.Where(p => p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID && p.task_type == WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID && p.endpoint_id == distaskH.endpoint_id).ToList();
|
||||||
|
if ((orgdistaskHs.Count + newdistaskHs.Count) == 0)
|
||||||
|
{
|
||||||
|
var groups = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TASK_EXECUTE_ENCODE).Result;
|
||||||
|
BillCode = $"{groups}-1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var groups = orgdistaskHs.Count > 0 ? orgdistaskHs.First().groups : newdistaskHs.First().groups;
|
||||||
|
BillCode = $"{groups}-" + (orgdistaskHs.Count + newdistaskHs.Count + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BillCode;
|
||||||
|
}
|
||||||
|
private Timer? timer;
|
||||||
|
private async void TimerExec(object e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Logger.Information("CTU任务执行TimerExec");
|
||||||
|
SqlSugarClient db = _db.CopyNew();
|
||||||
|
var list = db.Queryable<WmsDistaskH>().InnerJoin<WmsAreaH>((a, b) => a.area_id == b.id)
|
||||||
|
.Where((a, b) => b.code == "B" && a.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID)
|
||||||
|
.OrderBy(a => a.bill_code)
|
||||||
|
.ToList();
|
||||||
|
var data = list.GroupBy(p => p.groups).Select(p => new
|
||||||
|
{
|
||||||
|
groups = p.Key,
|
||||||
|
time = p.Max(a => a.create_time)
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
var date = DateTime.Now;
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
if (date.Subtract(item.time).Minutes >= 10)
|
||||||
|
{
|
||||||
|
var execlist = list.Where(p => p.groups == item.groups).ToList();
|
||||||
|
await db.Updateable<WmsDistaskH>().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID }).Where(it => execlist.Select(p => p.id).ToList().Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
await db.Updateable<WmsPretaskH>().SetColumns(it => new WmsPretaskH { status = WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID }).Where(it => execlist.Select(x => x.pretask_id).ToList().Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
CancellationTokenSource Ctu = new();
|
||||||
|
int type = execlist.First().task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID ? 1 : 0;
|
||||||
|
await CallingCTU(execlist, Ctu.Token, type);
|
||||||
|
Ctu.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Information("CTU任务执行TimerExec报错" + ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
timer?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private async Task CallingCTU(List<WmsDistaskH> distaskHs, CancellationToken token,int type)
|
||||||
|
{
|
||||||
|
Logger.Information("CTU任务执行请求第三方接口");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AgvRequestConfig requestCfg = App.Configuration.Build<AgvRequestConfig>();
|
||||||
|
string url = requestCfg.AgvRequestUrls.CreateTaskChainUrl;
|
||||||
|
var taskChainCodeDic = distaskHs.Where(t => !t.groups.IsNullOrWhiteSpace()).GroupBy(g => g.groups!)
|
||||||
|
.ToDictionary(x => x.Key, x => x.Select(it => new
|
||||||
|
{
|
||||||
|
taskCode = it.bill_code,
|
||||||
|
sourceName = it.startpoint_code,
|
||||||
|
targetName = it.endpoint_code,
|
||||||
|
containerCode = it.carry_code,
|
||||||
|
}));
|
||||||
|
|
||||||
|
foreach ((string k, object v) in taskChainCodeDic)
|
||||||
|
{
|
||||||
|
dynamic reqBody = new ExpandoObject();
|
||||||
|
reqBody.taskChainCode = k;
|
||||||
|
reqBody.type = (int)EnumTaskChainType.CTU;
|
||||||
|
reqBody.sequential = false;
|
||||||
|
reqBody.taskChainPriority = 0;
|
||||||
|
reqBody.taskList = v;
|
||||||
|
reqBody.inOut = type;
|
||||||
|
Logger.Information($"请求参数:{JsonConvert.SerializeObject(reqBody)}");
|
||||||
|
dynamic respBody = await HttpClientHelper.PostStreamAsync(url, reqBody, token);
|
||||||
|
Logger.Information($"调用Agv接口响应结果:{respBody}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Information("CTU任务执行请求第三方接口报错"+ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 呼梯操作
|
/// 呼梯操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user