This commit is contained in:
2024-03-04 08:55:49 +08:00
14 changed files with 237 additions and 82 deletions

View File

@@ -7,11 +7,13 @@ using JNPF.Common.Cache;
using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Dtos.VisualDev;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NetTaste; using NetTaste;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Qiniu.Util; using Qiniu.Util;
using SqlSugar; using SqlSugar;
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.ProductionMgr.Entities;
@@ -19,6 +21,7 @@ using Tnb.ProductionMgr.Entities.Dto;
using Tnb.ProductionMgr.Entities.Enums; using Tnb.ProductionMgr.Entities.Enums;
using Tnb.ProductionMgr.Interfaces; using Tnb.ProductionMgr.Interfaces;
using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Configs;
using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Interfaces; using Tnb.WarehouseMgr.Interfaces;
@@ -34,6 +37,7 @@ namespace Tnb.ProductionMgr
private readonly IPrdInstockService _prdInstockService; private readonly IPrdInstockService _prdInstockService;
private readonly ISqlSugarRepository<RedisReadConfig> _repository; private readonly ISqlSugarRepository<RedisReadConfig> _repository;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock; private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository<RedisReadConfig> repository, IWmsPDAScanInStockService wmsPDAScanInStock) public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository<RedisReadConfig> repository, IWmsPDAScanInStockService wmsPDAScanInStock)
{ {
_redisData = redisData; _redisData = redisData;
@@ -121,8 +125,7 @@ namespace Tnb.ProductionMgr
private void CheckGet(object state) private void CheckGet(object state)
{ {
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>(); Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "CS05", "FullBoxAllowGet", "Code" }); getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" });
getdic.Add("SSX-021-006", new string[] { "CS06", "FullBoxAllowGet", "Code" });
foreach (var key in getdic.Keys) foreach (var key in getdic.Keys)
{ {
try try
@@ -137,15 +140,18 @@ namespace Tnb.ProductionMgr
string codedata = _redisData.GetHash(strs[0], strs[2]).Result; string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata); JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : ""; string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID).First(); coderesult = coderesult.Replace("\r", "");
dynamic reqBody = new ExpandoObject(); var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID).First();
reqBody.taskCode = DistaskH.bill_code; if (DistaskH != null)
reqBody.slotCode = key; {
reqBody.containerCode = coderesult; dynamic reqBody = new ExpandoObject();
CancellationTokenSource Ctu = new(); reqBody.taskCode = DistaskH.bill_code;
//{"code":500,"msg":"成功!"} reqBody.slotCode = key;
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result; reqBody.containerCode = coderesult;
Ctu.Dispose(); CancellationTokenSource Ctu = new();
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
Ctu.Dispose();
}
} }
} }
catch (Exception) catch (Exception)
@@ -157,27 +163,66 @@ namespace Tnb.ProductionMgr
//扫码入库 //扫码入库
private void ScanInStock(object state) private void ScanInStock(object state)
{ {
var carry_code = "TestLX0001";//从数采读取载具 Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == carry_code); getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox","false" });
if (carry != null) foreach (var key in getdic.Keys)
{ {
var WmsCarryCode = _repository.AsSugarClient().Queryable<WmsCarryCode>().Single(it => it.carry_id == carry.id); try
{
var strs = getdic.Where(p => p.Key == key).First().Value;
bool flag = _redisData.HashExist(strs[0], strs[1]).Result;
string data = _redisData.GetHash(strs[0], strs[1]).Result;
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
if (result)
{
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strs[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strs[3],
["Value"] = strs[4],
};
HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand).Wait();
VisualDevModelDataCrInput input = new VisualDevModelDataCrInput();
input.data = new Dictionary<string, object>(); string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
input.data.Add("barcode", carry_code); JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量 string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
input.data.Add("material_code", WmsCarryCode.material_code); WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == coderesult);
input.data.Add("extras", carry.location_code!);//location_code if (carry != null)
input.data.Add("warehouse_id", WmsCarryCode.warehouse_id!); {
input.data.Add("bill_code", "");//采购收货单号 if (_repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && (p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID)).Any())
input.data.Add("code_batch", WmsCarryCode.code_batch!);//批次 continue;
input.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号 var WmsCarryCode = _repository.AsSugarClient().Queryable<WmsCarryCode>().Single(it => it.carry_id == carry.id);
input.data.Add("container_no", WmsCarryCode.container_no!);//箱号 if (WmsCarryCode != null)
input.data.Add("material_id", WmsCarryCode.material_id); {
input.data.Add("id", null); VisualDevModelDataCrInput input = new VisualDevModelDataCrInput();
_wmsPDAScanInStock.ScanInStockByRedis(input); input.data = new Dictionary<string, object>();
input.data.Add("barcode", coderesult);
input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
input.data.Add("material_code", WmsCarryCode.material_code);
input.data.Add("extras", key);//location_code
input.data.Add("warehouse_id", "1");//TEST
input.data.Add("bill_code", "");//采购收货单号
input.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
input.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
input.data.Add("container_no", WmsCarryCode.container_no!);//箱号
input.data.Add("material_id", WmsCarryCode.material_id);
input.data.Add("id", null);
_wmsPDAScanInStock.ScanInStockByRedis(input);
}
}
}
}
catch (Exception)
{
}
} }
} }
@@ -186,12 +231,13 @@ namespace Tnb.ProductionMgr
{ {
Readtimer?.Dispose(); Readtimer?.Dispose();
CheckGettimer?.Dispose(); CheckGettimer?.Dispose();
Scantimer?.Dispose();
} }
public Task StartAsync(CancellationToken cancellationToken) public Task StartAsync(CancellationToken cancellationToken)
{ {
// Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); // Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
// CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
// Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
return Task.CompletedTask; return Task.CompletedTask;
} }
public Task StopAsync(CancellationToken cancellationToken) public Task StopAsync(CancellationToken cancellationToken)

View File

@@ -17,7 +17,7 @@ public partial class WmsEmptyOutstockD : BaseEntity<string>
/// <summary> /// <summary>
/// 行号 /// 行号
/// </summary> /// </summary>
public int? no { get; set; } public string? no { get; set; }
/// <summary> /// <summary>
/// 所属组织ID /// 所属组织ID

View File

@@ -74,6 +74,7 @@ namespace Tnb.WarehouseMgr.Interfaces
/// <param name="ele"></param> /// <param name="ele"></param>
/// <returns></returns> /// <returns></returns>
Task<List<WmsPointH>> PathAlgorithmsEle(string pStartId, string pEndId, int ele); Task<List<WmsPointH>> PathAlgorithmsEle(string pStartId, string pEndId, int ele);
Task SsxControl(WmsDistaskH disTask, string action);
Func<string, int, Task> AddUnExecuteTask { get; set; } Func<string, int, Task> AddUnExecuteTask { get; set; }
} }
} }

View File

@@ -403,7 +403,7 @@ namespace Tnb.WarehouseMgr
{ {
_ = await _db.Deleteable(elevatorQueueItem).ExecuteCommandAsync(); _ = await _db.Deleteable(elevatorQueueItem).ExecuteCommandAsync();
} }
await _wareHouseService.SsxControl(disTask, "LOAD");
} }
else if (input.action == "UNLOAD") else if (input.action == "UNLOAD")
{ {
@@ -414,7 +414,7 @@ namespace Tnb.WarehouseMgr
}; };
Logger.Information($"taskCompleUpInput json parameter:{JsonConvert.SerializeObject(taskCompleUpInput)}"); Logger.Information($"taskCompleUpInput json parameter:{JsonConvert.SerializeObject(taskCompleUpInput)}");
await _wareHouseService.TaskComplate(taskCompleUpInput); await _wareHouseService.TaskComplate(taskCompleUpInput);
await _wareHouseService.SsxControl(disTask, "UNLOAD");
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -57,6 +57,7 @@ namespace Tnb.WarehouseMgr
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; private readonly RedisData _redisData;
public Func<string, int, Task> AddUnExecuteTask { get; set; } public Func<string, int, Task> AddUnExecuteTask { get; set; }
@@ -247,11 +248,9 @@ namespace Tnb.WarehouseMgr
public async Task CheckPut(CheckPutInput input) public async Task CheckPut(CheckPutInput input)
{ {
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>(); Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
putdic.Add("SSX-021-005", new string[] { "CS05", "ConveyorAllowPutEmptyBox" });
putdic.Add("SSX-021-006", new string[] { "CS06", "ConveyorAllowPutEmptyBox" }); putdic.Add("SSX-011-006", new string[] { "YTCS", "AllowEmptyIn_CS06" });
// Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
// getdic.Add("SSX-021-005", new string[] { "CS05", "FullBoxAllowGet" });
// getdic.Add("SSX-021-006", new string[] { "CS06", "FullBoxAllowGet" });
var strs = new string[] { }; var strs = new string[] { };
if (!putdic.ContainsKey(input.targetName)) if (!putdic.ContainsKey(input.targetName))
@@ -270,6 +269,63 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("点位" + input.targetName + "不可放", 500); throw new AppFriendlyException("点位" + input.targetName + "不可放", 500);
} }
/// <summary>
/// 判断CTU是否可以取货
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task Test()
{
var a = _db.Queryable<WmsDistaskH>().Where(p => p.id == "31900194166806").First();
await SsxControl(a, "UNLOAD");
}
public async Task SsxControl(WmsDistaskH disTask, string action)
{
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" });
putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" });
putdic.Add("YCLCKBGW", new string[] { "CP8", "PutDoneEmptyBox", "true" });
if (action == "LOAD")//取货
{
if (getdic.Keys.Contains(disTask.startlocation_code))
{
var strarr = getdic.Where(p => p.Key == disTask.startlocation_code).First().Value;
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strarr[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strarr[1],
["Value"] = strarr[2],
};
Logger.Information($"SsxControlLOAD:{dicCommand}");
var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand);
Logger.Information($"SsxControlLOAD:{str}");
}
}
else if (action == "UNLOAD")//放货
{
if (putdic.Keys.Contains(disTask.endlocation_code))
{
var strarr = putdic.Where(p => p.Key == disTask.endlocation_code).First().Value;
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strarr[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strarr[1],
["Value"] = strarr[2],
};
Logger.Information($"SsxControlUNLOAD:{dicCommand}");
var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand);
Logger.Information($"SsxControlUNLOAD:{str}");
}
}
}
/// <summary> /// <summary>
/// 生成任务执行 /// 生成任务执行
/// </summary> /// </summary>
@@ -1058,6 +1114,8 @@ namespace Tnb.WarehouseMgr
} }
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -71,8 +71,13 @@ namespace Tnb.WarehouseMgr
carryOutPut.carryMats = await _db.Queryable<WmsCarryMat>().Where(it => it.carry_id == carryId).ToListAsync(); carryOutPut.carryMats = await _db.Queryable<WmsCarryMat>().Where(it => it.carry_id == carryId).ToListAsync();
return carryOutPut; return carryOutPut;
} }
[HttpGet]
public async Task<dynamic> GetCarryInfoByCode([FromRoute] string carrycode)
{
var carryOutPut = await _db.Queryable<WmsCarryH>().Where(it => it.carry_code == carrycode).FirstAsync();
return carryOutPut;
}
/// <summary> /// <summary>
/// 更换载具 /// 更换载具
/// </summary> /// </summary>

View File

@@ -65,19 +65,23 @@ namespace Tnb.WarehouseMgr
try try
{ {
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
var Location = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == input.data["location_code"].ToString());
input.data.Add("warehouse_id", Location.wh_id);
input.data.Add("location_id", Location.id);
input.data.Add("status", "25065138925589");
//入库取终点 //出库起点 //入库取终点 //出库起点
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH? sPoint = null; WmsPointH? sPoint = null;
WmsPointH? ePoint = null; WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id))) if (input.data.ContainsKey("location_code"))
{ {
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_code == input.data["location_code"].ToString());
} }
if (endLocations?.Count > 0) if (endLocations?.Count > 0)
{ {
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.data["carry_code"].ToString());
input.data.Add("carry_id", carry.id);
BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id); BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch) if (!isMatch)
@@ -93,10 +97,19 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); List<WmsPointH> points = new List<WmsPointH>();
if (points.Count <= 2) if (sPoint.area_code != ePoint.area_code)
{ {
throw new AppFriendlyException("该路径不存在", 500); points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2)
{
throw new AppFriendlyException("该路径不存在", 500);
}
}
else
{
points.Add(sPoint);
points.Add(ePoint);
} }
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0) if (points?.Count > 0)
@@ -132,8 +145,8 @@ namespace Tnb.WarehouseMgr
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
preTask.create_id = _userManager.UserId; preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now; preTask.create_time = DateTime.Now;
preTask.source_id = input.data[nameof(WmsKittingInstock.source_id)].ToString(); preTask.source_id = "";
preTask.source_code = input.data[nameof(WmsKittingInstock.source_code)].ToString(); preTask.source_code = "";
return preTask; return preTask;
}).ToList(); }).ToList();
List<WmsCarryCode> carryCodes = new(); List<WmsCarryCode> carryCodes = new();
@@ -211,8 +224,8 @@ namespace Tnb.WarehouseMgr
location_id = preTaskUpInput.CarryStartLocationId, location_id = preTaskUpInput.CarryStartLocationId,
location_code = preTaskUpInput.CarryStartLocationCode, location_code = preTaskUpInput.CarryStartLocationCode,
carry_status = ((int)EnumCarryStatus.).ToString(), carry_status = ((int)EnumCarryStatus.).ToString(),
collocation_scheme_id = input.data[nameof(WmsKittingInstock.collocation_scheme_id)].ToString(), // collocation_scheme_id = input.data[nameof(WmsKittingInstock.collocation_scheme_id)].ToString(),
collocation_scheme_code = input.data[nameof(WmsKittingInstock.collocation_scheme_code)].ToString() // collocation_scheme_code = input.data[nameof(WmsKittingInstock.collocation_scheme_code)].ToString()
}, },
it => new BasLocation { is_lock = 1 }); it => new BasLocation { is_lock = 1 });
} }

View File

@@ -198,7 +198,8 @@ namespace Tnb.WarehouseMgr
} }
catch (Exception) catch (Exception)
{ {
return await Task.FromResult(false); await _db.Ado.RollbackTranAsync();
throw;
} }
finally finally
{ {

View File

@@ -98,11 +98,19 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
List<WmsPointH>? points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); List<WmsPointH> points = new List<WmsPointH>();
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (sPoint.area_code != ePoint.area_code)
if (points?.Count <= 2)
{ {
throw new AppFriendlyException("该路径不存在", 500); points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2)
{
throw new AppFriendlyException("该路径不存在", 500);
}
}
else
{
points.Add(sPoint);
points.Add(ePoint);
} }
if (points?.Count > 0) if (points?.Count > 0)

View File

@@ -88,16 +88,22 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); List<WmsPointH> points = new List<WmsPointH>();
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (sPoint.area_code != ePoint.area_code)
if (points?.Count > 0)
{ {
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) if (points.Count <= 2)
{ {
throw new AppFriendlyException("该路径不存在", 500); throw new AppFriendlyException("该路径不存在", 500);
} }
}
else
{
points.Add(sPoint);
points.Add(ePoint);
}
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{ {
WmsPointH? sPoint = it.FirstOrDefault(); WmsPointH? sPoint = it.FirstOrDefault();
WmsPointH? ePoint = it.LastOrDefault(); WmsPointH? ePoint = it.LastOrDefault();
@@ -167,8 +173,6 @@ namespace Tnb.WarehouseMgr
//((int)EnumCarryStatus.寄存).ToString() //((int)EnumCarryStatus.寄存).ToString()
} }
} }
}
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }
catch (Exception) catch (Exception)

View File

@@ -60,11 +60,12 @@ namespace Tnb.WarehouseMgr
try try
{ {
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALEPDA_ID, true);
await _runService.Create(templateEntity, input);
//出库取起点 //出库取起点
WmsCarryH carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString()); WmsCarryH carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString());
if (carry == null)
{
throw new AppFriendlyException("请选择载具", 500);
}
WmsPointH? sPoint = null; WmsPointH? sPoint = null;
WmsPointH? ePoint = null; WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id))) if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
@@ -75,19 +76,26 @@ namespace Tnb.WarehouseMgr
{ {
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id); sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
} }
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); var points=new List<WmsPointH>();
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (sPoint.area_code != ePoint.area_code)
if (points?.Count > 0)
{ {
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) if (points.Count <= 2)
{ {
throw new AppFriendlyException("该路径不存在", 500); throw new AppFriendlyException("该路径不存在", 500);
} }
}
else
{
points.Add(sPoint);
points.Add(ePoint);
}
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
{
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{ {
WmsPointH? sPoint = it.FirstOrDefault(); WmsPointH? sPoint = it.FirstOrDefault();
@@ -150,7 +158,8 @@ namespace Tnb.WarehouseMgr
} }
} }
} }
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALEPDA_ID, true);
await _runService.Create(templateEntity, input);
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }
catch (Exception) catch (Exception)

View File

@@ -79,14 +79,24 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); List<WmsPointH> points = new List<WmsPointH>();
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (sPoint.area_code != ePoint.area_code)
if (points?.Count > 0)
{ {
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) if (points.Count <= 2)
{ {
throw new AppFriendlyException("该路径不存在", 500); throw new AppFriendlyException("该路径不存在", 500);
} }
}
else
{
points.Add(sPoint);
points.Add(ePoint);
}
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
{
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{ {

View File

@@ -2,14 +2,14 @@
"ConnectionStrings": { "ConnectionStrings": {
"ConfigId": "default", "ConfigId": "default",
"DBType": "PostgreSQL", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp;Sqlite; "DBType": "PostgreSQL", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp;Sqlite;
"Host": "localhost", "Host": "192.168.11.109",
"Port": "5432", "Port": "5432",
//"DBName": "tianyi_db", //"DBName": "tianyi_db",
//"UserName": "postgres", //"UserName": "postgres",
//"Password": "pass@word123", //"Password": "pass@word123",
"DBName": "tianyi_bas", "DBName": "tianyi",
"UserName": "totong", "UserName": "postgres",
"Password": "IPANyxGSKxIXg0dBM", "Password": "pass@word123",
//SqlServer //SqlServer
//"DefaultConnection": "server={0},{1};database={2};uid={3};pwd={4};MultipleActiveResultSets=true" //"DefaultConnection": "server={0},{1};database={2};uid={3};pwd={4};MultipleActiveResultSets=true"
//Kdbndp //Kdbndp

View File

@@ -57,12 +57,13 @@ public class Startup : AppStartup
services.AddOverideVisualDev(); services.AddOverideVisualDev();
//定时任务 //定时任务
SnowflakeIdHelper.InitYitIdWorker();
services.AddHostedService<TimedTaskBackgroundService>(); services.AddHostedService<TimedTaskBackgroundService>();
services.AddSingleton<BackgroundService, TimedTaskBackgroundService>(sp => new TimedTaskBackgroundService()); services.AddSingleton<BackgroundService, TimedTaskBackgroundService>(sp => new TimedTaskBackgroundService());
//var bgSvc = App.GetRequiredService<BackgroundService>(); //var bgSvc = App.GetRequiredService<BackgroundService>();
//bgSvc.StartAsync(CancellationToken.None); //bgSvc.StartAsync(CancellationToken.None);
//services.AddHostedService<RedisBackGround>(); // services.AddHostedService<RedisBackGround>();
} }
@@ -112,7 +113,6 @@ public class Startup : AppStartup
endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
}); });
SnowflakeIdHelper.InitYitIdWorker();
bool isStartTimeJob = App.GetConfig<bool>("IsStartTimeJob"); bool isStartTimeJob = App.GetConfig<bool>("IsStartTimeJob");
if (isStartTimeJob) if (isStartTimeJob)