Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Configs
|
||||
{
|
||||
public class AgvRequestConfig
|
||||
{
|
||||
public AgvRequestConfiguration AgvRequestUrls { get; set; }
|
||||
}
|
||||
|
||||
public class AgvRequestConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建任务链url请求地址
|
||||
/// </summary>
|
||||
public string CreateTaskChainUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 取消任务链url请求地址
|
||||
/// </summary>
|
||||
public string CancelTaskChainUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
private ISendMessageService? _sendService;
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken) => Task.Run(() =>
|
||||
{
|
||||
//_sendService = App.GetRequiredService<ISendMessageService>();
|
||||
List<string> toUserIds = new List<string>() { "25398501929509" };
|
||||
@@ -48,8 +46,8 @@ namespace Tnb.WarehouseMgr
|
||||
//齐套分拣
|
||||
var setSortingService = App.GetRequiredService<IWmsSetSortingService>();
|
||||
TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, toUserIds);
|
||||
});
|
||||
}
|
||||
}, stoppingToken);
|
||||
|
||||
private Task TimedTask(Func<CancellationTokenSource, Task> action, CancellationTokenSource cts, List<string>? toUserIds = default)
|
||||
{
|
||||
var token = cts.Token;
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Dm;
|
||||
using JNPF;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -27,6 +28,7 @@ using Mapster;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.HPSF;
|
||||
using NPOI.OpenXmlFormats.Wordprocessing;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
@@ -37,8 +39,10 @@ using Spire.Pdf.Widget;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Enums;
|
||||
using Tnb.Common.Extension;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Configs;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
@@ -193,7 +197,7 @@ namespace Tnb.WarehouseMgr
|
||||
.And((a, b, c) => c.wh_id == input.warehouse_id)
|
||||
.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
|
||||
.AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
|
||||
.AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a,b,c)=>a.carrystd_id == input.carrystd_id);
|
||||
.AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
|
||||
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
|
||||
? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
|
||||
: (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
|
||||
@@ -217,7 +221,6 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost]
|
||||
public async Task GenTaskExecute(CancellationTokenSource? cts = default)
|
||||
{
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
var db = _db.CopyNew();
|
||||
try
|
||||
@@ -313,7 +316,6 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
disTasks.AddRange(items);
|
||||
}
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
//disTasks.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
||||
@@ -328,7 +330,13 @@ namespace Tnb.WarehouseMgr
|
||||
row = await db.Updateable<WmsPretaskH>().SetColumns(it => new WmsPretaskH { status = WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID }).Where(it => preTaskIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
JNPF.Logging.Log.Information($"程序运行耗时{sw.ElapsedMilliseconds}ms");
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
|
||||
//调用AGV创建任务链接口
|
||||
var requestCfg = App.Configuration.Build<AgvRequestConfig>();
|
||||
var taskChainCodeDic = disTasks.Where(t => !t.groups.IsNullOrWhiteSpace()).GroupBy(g => g.groups!)
|
||||
.ToDictionary(x => x.Key, x => x.Select(it => new
|
||||
{
|
||||
@@ -336,18 +344,22 @@ namespace Tnb.WarehouseMgr
|
||||
sourceName = it.startlocation_code,
|
||||
targetName = it.endlocation_code
|
||||
}));
|
||||
|
||||
dynamic reqBody = new ExpandoObject();
|
||||
|
||||
sw.Stop();
|
||||
JNPF.Logging.Log.Information($"程序运行耗时{sw.ElapsedMilliseconds}ms");
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
foreach (var (k, v) in taskChainCodeDic)
|
||||
{
|
||||
dynamic reqBody = new ExpandoObject();
|
||||
reqBody.taskChainCode = k;
|
||||
reqBody.type = 3;
|
||||
reqBody.sequential = false;
|
||||
reqBody.taskChainPriority = 0;
|
||||
reqBody.taskList = v;
|
||||
await HttpClientHelper.PostStreamAsync(requestCfg.AgvRequestUrls.CreateTaskChainUrl, reqBody, CancellationToken.None);
|
||||
//await HttpClientHelper.HttpPostAsync(url, JsonConvert.SerializeObject(reqBody));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
JNPF.Logging.Log.Error("生成预任务执行时出现错误",ex);
|
||||
JNPF.Logging.Log.Error("生成预任务执行时出现错误", ex);
|
||||
await db.Ado.RollbackTranAsync();
|
||||
cts?.Cancel();
|
||||
throw;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"AgvRequestUrls": {
|
||||
"CreateTaskChainUrl": "http://localhost/api/task‑chain/create",
|
||||
"CancelTaskChainUrl": "http://localhost/api/task‑chain/cancel"
|
||||
}
|
||||
}
|
||||
24
common/Tnb.Common/Extension/ConfigurationExtensions.cs
Normal file
24
common/Tnb.Common/Extension/ConfigurationExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Tnb.Common.Extension
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用配置扩展
|
||||
/// added by ly on 20230807
|
||||
/// </summary>
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
public static T Build<T>(this IConfiguration configuration) where T : class, new()
|
||||
{
|
||||
T instance = new();
|
||||
configuration.Bind(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -129,10 +129,10 @@ namespace Tnb.Common.Utils
|
||||
}
|
||||
|
||||
|
||||
private static async Task PostStreamAsync(object content, CancellationToken cancellationToken)
|
||||
public static async Task<string> PostStreamAsync(string url,object content, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Post, Url))
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
|
||||
using (var httpContent = CreateHttpContent(content))
|
||||
{
|
||||
request.Content = httpContent;
|
||||
@@ -142,7 +142,9 @@ namespace Tnb.Common.Utils
|
||||
.ConfigureAwait(false))
|
||||
{
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user