二楼料箱下到一楼生成ctu任务和空载具入库单

This commit is contained in:
2024-05-23 00:33:23 +08:00
parent a53623823c
commit af6a562211
7 changed files with 247 additions and 203 deletions

View File

@@ -62,7 +62,7 @@ namespace Tnb.ProductionMgr
private Timer? Floor2UpMachinecodetimer;
// 二楼料架配送
private Timer? Floor2RackDeliverytimer;
public static SemaphoreSlim s_taskExecuteRackDelivery = new(1);
private readonly RedisData _redisData;
@@ -75,6 +75,7 @@ namespace Tnb.ProductionMgr
private readonly IWmsCarryBindService _wmsCarryBindService;
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository<RedisReadConfig> repository, IWmsPDAScanInStockService wmsPDAScanInStock
, IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, IWmsCarryBindService wmsCarryBindService)
{
@@ -182,7 +183,7 @@ namespace Tnb.ProductionMgr
getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03", "" });
getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01", "" });
foreach (var key in getdic.Keys)
{
try
@@ -195,7 +196,7 @@ namespace Tnb.ProductionMgr
continue;
}
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
if (result)
{
@@ -224,7 +225,7 @@ namespace Tnb.ProductionMgr
CancellationTokenSource Ctu = new();
if (strs[0] == "东面提升机输送线")
{
Logger.LogInformation($"【定时任务CheckGet】 开始发送请求到 http://192.168.11.104:1880/wcs/notify/cargo ");
Logger.LogInformation($"【定时任务CheckGet】 开始发送请求到 http://192.168.11.104:1880/wcs/notify/cargo 载具:{coderesult}");
}
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
if (strs[0] == "东面提升机输送线")
@@ -238,10 +239,10 @@ namespace Tnb.ProductionMgr
else
{
LoggerSSX.LogInformation($@"【定时任务CheckGet】 {key}->{strs[0]} {strs[2]}
采集结果:{ $@"(wms_distask_h) (carry_code){coderesult}
采集结果:{$@"(wms_distask_h) (carry_code){coderesult}
(status)(26126853976101) (extras)
select extras,* from wms_distask_h
where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID}' " }");
where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID}' "}");
}
}
@@ -256,7 +257,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
reqBody.slotCode = key;
reqBody.containerCode = DistaskH.carry_code;
CancellationTokenSource Ctu = new();
Logger.LogInformation($"【定时任务CheckGet】 开始发送请求到 http://192.168.11.104:1880/wcs/notify/cargo ");
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
Logger.LogInformation($"【定时任务CheckGet】 接收请求 http://192.168.11.104:1880/wcs/notify/cargo 结果 {respBody} ");
DistaskH.extras = respBody;
_repository.AsSugarClient().Updateable(DistaskH).ExecuteCommand();
Ctu.Dispose();
@@ -397,7 +400,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
};
})).CreateLogger(this.GetType());
protected ILogger LoggerYCLGLDPJInstock => LoggerFactory.Create(builder => builder.AddFile($"{AppContext.BaseDirectory}/logs/customBGWCarrySupplement{DateTime.Now:yyyyMMdd}.log", cfgOpts =>
{
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
@@ -807,7 +810,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == result && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).OrderByDescending(p => p.create_time).First();
if (DistaskH != null)
{
Logger.LogInformation($"【定时任务SSXcode】DistaskH != null putdic.Keys.Contains(DistaskH.startlocation_code):{putdic.Keys.Contains(DistaskH.startlocation_code)}");
Logger.LogInformation($"【定时任务SSXcode】DistaskH != null putdic.Keys.Contains(DistaskH.startlocation_code):{putdic.Keys.Contains(DistaskH.startlocation_code)} {result}");
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
{
@@ -869,7 +872,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
BGWCarrySupplementtimer?.Dispose();
YCLGLDPJInstocktimer?.Dispose();
YCLWXDPJInstocktimer?.Dispose();
}
}
#region
// 上升降机
@@ -877,7 +880,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
using (var db = _repository.AsSugarClient().CopyNew())
{
string barcode = Floor2UpDownMachinecode_GetTag<string>(MechanicalArmConsts.).ToString();
string barcode = await Floor2UpDownMachinecode_GetTag<string>(MechanicalArmConsts.);
if (string.IsNullOrEmpty(barcode))
{
LoggerFloor2UpDownMachine.LogError($@"【上升降机】未取到条码数据");
@@ -1008,13 +1011,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
// 绑定料箱到料架
CarryBindFloor2UpDownMachineInput carryBindFloor2UpDownMachineInput = new() { };
carryBindFloor2UpDownMachineInput.carry_id = target.rackid;
carryBindFloor2UpDownMachineInput.carry_code= target.rackcode;
carryBindFloor2UpDownMachineInput.carry_code = target.rackcode;
carryBindFloor2UpDownMachineInput.membercarry_id = LX.id;
carryBindFloor2UpDownMachineInput.membercarry_code = LX.carry_code;
carryBindFloor2UpDownMachineInput.carrystd_id = rack.carrystd_id;
await _wmsCarryBindService.CarryBindFloor2UpDownMachine(carryBindFloor2UpDownMachineInput);
await db.Ado.CommitTranAsync();
@@ -1033,69 +1036,88 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
/// 检查机械臂料架区信号(下升降机满托1送到)
/// </summary>
/// <returns></returns>
public async Task<bool> _下升降机满托1送到()
//public async Task<bool> 检查机械臂料架区信号_下升降机满托1送到()
//{
// using (var db = _repository.AsSugarClient().CopyNew())
// {
// string[] configs_upMachine = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
// // 找到AGV已到货没有机械臂确认的数据
// ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>()
// .Where(r => r.agvconfirm == 1 && r.mechanicalconfirm == 0 && configs_upMachine.Contains(r.name));
// LoggerFloor2UpDownMachine.LogInformation($@"【检查机械臂料架区信号_下升降机满托1送到】 {WmsMechanicalArmHsuagar.Count()}");
// foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHsuagar.ToList())
// {
// int LXCount = db.Queryable<WmsCarryD>().Where(a => a.carry_id == wmsMechanicalArmH.rackid).Count();
// bool result = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}数量", LXCount.ToString());
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】设定下升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
// if (!result)
// {
// throw new Exception($@"【送满托到下升降区】设定升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
// }
// // 尝试写入满托送到信号
// bool result下升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}送到", "true");
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】回写 下升降机满托{wmsMechanicalArmH.stackingposition}送到 结果为{result下升降机空托送到}");
// if (!result下升降机空托送到)
// {
// return false;
// }
// // 绑定料架
// await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
// {
// mechanicalconfirm = 1,
// maxnum = LXCount
// }).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱开始生成预任务");
// bool pretask_result = await _wareHouseService.Floor2EmptyCarryCreateZZCPretask(wmsMechanicalArmH.rackid);
// if (pretask_result)
// {
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务完成");
// }
// else
// {
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务失败");
// }
// }
// return true;
// }
//}
// 二楼机械臂信号对应机械臂字典
Dictionary<string, string> floor2mechanicalAtmDic = new Dictionary<string, string>()
{
using (var db = _repository.AsSugarClient().CopyNew())
{
string[] configs_upMachine = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
// 找到AGV已到货没有机械臂确认的数据
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>()
.Where(r => r.agvconfirm == 1 && r.mechanicalconfirm == 0 && configs_upMachine.Contains(r.name));
LoggerFloor2UpDownMachine.LogInformation($@"【检查机械臂料架区信号_下升降机满托1送到】 {WmsMechanicalArmHsuagar.Count()}");
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHsuagar.ToList())
{
int LXCount = db.Queryable<WmsCarryD>().Where(a => a.carry_id == wmsMechanicalArmH.rackid).Count();
bool result = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}数量", LXCount.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】设定下升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
if (!result)
{
throw new Exception($@"【送满托到下升降区】设定升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
}
// 尝试写入满托送到信号
bool result下升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}送到", "true");
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】回写 下升降机满托{wmsMechanicalArmH.stackingposition}送到 结果为{result下升降机空托送到}");
if (!result下升降机空托送到)
{
return false;
}
// 绑定料架
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
{
mechanicalconfirm = 1,
maxnum = LXCount
}).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱开始生成预任务");
bool pretask_result = await _wareHouseService.Floor2EmptyCarryCreateZZCPretask(wmsMechanicalArmH.rackid);
if (pretask_result)
{
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务完成");
}
else
{
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务失败");
}
}
return true;
}
}
{"上升降机请求送空托1","二楼上升降机机械臂左"},
{"上升降机请求送空托2","二楼上升降机机械臂右"},
};
/// <summary>
/// 送空托到上升降区
/// </summary>
/// <returns></returns>
public async Task<bool> ()
{
#region
List<string> configs_upMachine = new List<string>();
bool 1 = await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托1");
bool 2 = await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托2");
if (await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托1"))
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托1"]);
if (await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托2"))
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托2"]);
// 没有有效信号
if (configs_upMachine.Count == 0)
return false;
#endregion
using (var db = _repository.AsSugarClient().CopyNew())
{
string[] configs_upMachine = new string[2] { "二楼上升降机机械臂左", "二楼上升降机机械臂右" };
// 找到没有绑定料架的且库位未锁定的料架区
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>().
@@ -1224,7 +1246,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
{
bool = (bool)Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求送满托{wmsMechanicalArmH.stackingposition}");
bool = await Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求送满托{wmsMechanicalArmH.stackingposition}");
if (!)
{
LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 料架区 {wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 下升降机请求送满托{wmsMechanicalArmH.stackingposition}信号不为true");
@@ -1357,11 +1379,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
try
{
// 判断是否 上升降机请求取满托
bool = (bool)Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求取满托{wmsMechanicalArmH.stackingposition}");
bool = await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求取满托{wmsMechanicalArmH.stackingposition}");
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】上升降机请求取满托{wmsMechanicalArmH.stackingposition} {上升降机请求取满托}");
if (!)
{
return false;
continue;
}
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
@@ -1376,7 +1398,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (startPoints.Count == 0)
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 起点{wmsMechanicalArmH.point_id} {wmsMechanicalArmH.point_code}未在点位表维护对应的点位");
return false;
continue;
}
WmsPointH startPoint = startPoints.First();
@@ -1390,7 +1412,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (rackEndLocations.Count() == 0)
{
LoggerFloor2RackDelivery.LogWarning($"【移走上升降区满托的料架】 暂存仓中没有可用的空库位 {rackEndLocations.ToSqlString()}");
return false;
continue;
}
BasLocation endLocation = rackEndLocations.First();
@@ -1400,7 +1422,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (endPoints.Count == 0)
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 终点库位{endLocation.location_code}未在点位表维护对应的点位");
return false;
continue;
}
WmsPointH endPoint = endPoints.First();
@@ -1421,7 +1443,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Tuple<bool, WmsPretaskH> result = await createPretask(points, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery);
if (!result.Item1)
{
throw new Exception("未成功生成预任务");
LoggerFloor2RackDelivery.LogInformation($"未成功生成预任务");
continue;
}
LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 成功生成预任务 {result.Item2}");
@@ -1460,7 +1483,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
try
{
// 判断是否 上升降机请求取满托
bool = (bool)Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求取空托{wmsMechanicalArmH.stackingposition}");
bool = await Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求取空托{wmsMechanicalArmH.stackingposition}");
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】下升降机请求取空托{wmsMechanicalArmH.stackingposition} {下升降机请求取空托}" );
if (!)
{
@@ -1553,11 +1576,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
try
{
// 检查机械臂料架区信号(上升降机空托1送到)
//await 检查机械臂料架区信号_上升降机空托1送到();
// 检查机械臂料架区信号(下升降机满托1送到)
await _下升降机满托1送到();
//await 检查机械臂料架区信号_下升降机满托1送到();
// 送空托到上升降区
await ();
@@ -1637,30 +1657,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
return new Tuple<bool, WmsPretaskH>(false, null);
}
private object Floor2UpDownMachinecode_GetTag<T>(string tag)
private async Task<T> Floor2UpDownMachinecode_GetTag<T>(string tag)
{
string key = "东面提升机输送线";
string data = _redisData.GetHash(key, tag.ToString()).Result;
if (data == null)
{
LoggerFloor2UpDownMachine.LogError($@"{key} {tag} 未取到数值!");
return "";
}
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
switch (typeof(T).ToString())
{
case "System.Boolean":
{
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
return result;
}
case "System.String":
{
string? result = res != null && res["Value"] != null ? res.Value<string>("Value") : "";
return result;
}
}
return "wrong type";
return await _redisData.TryGetValueByKeyField<T>(key, tag.ToString());
}
private async Task<bool> Floor2UpDownMachinecode_SetTag(string tag, string value)

View File

@@ -4,6 +4,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Dtos.VisualDev;
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
{
@@ -22,7 +23,20 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
public string task_type { get; set; }
public string require_id { get; set; }
public string require_code { get; set; }
/// <summary>
/// 如果要生成业务表,传入此对象以及对应业务表单的自定义字段
/// </summary>
public VisualDevModelDataCrInput visualDevInput { get; set; }
/// <summary>
/// 是否在最后调用任务执行
/// </summary>
public bool isExcuteMission { get; set; } = true;
}
}

View File

@@ -120,5 +120,6 @@ namespace Tnb.WarehouseMgr.Interfaces
/// <returns></returns>
[HttpPost, NonUnify, AllowAnonymous]
Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> CommonCreatePretask(CommonCreatePretaskInput input);
}
}

View File

@@ -1,4 +1,5 @@
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using JNPF.Common.Dtos.VisualDev;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
namespace Tnb.WarehouseMgr.Interfaces
{
@@ -13,5 +14,7 @@ namespace Tnb.WarehouseMgr.Interfaces
/// <param name="input"></param>
/// <returns></returns>
Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input);
Task<dynamic> WmsEmptyIn(VisualDevModelDataCrInput input);
}
}

View File

@@ -12,12 +12,15 @@ using Aspose.Cells;
using JNPF;
using JNPF.Common.Contracts;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Manager;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -48,6 +51,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Queries;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
using static NPOI.HSSF.Util.HSSFColor;
namespace Tnb.WarehouseMgr
{
@@ -68,6 +72,8 @@ namespace Tnb.WarehouseMgr
private static Dictionary<string, object> locMap = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
private readonly IConfiguration _configuration;
private readonly RedisData _redisData;
private readonly IVisualDevService _visualDevService;
private readonly IRunService _runService;
public static SemaphoreSlim s_floor2CreatePretask = new(1);
@@ -76,7 +82,9 @@ namespace Tnb.WarehouseMgr
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, RedisData redisData,
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,
IWmsCarryBindService wmsCarryBindService
IWmsCarryBindService wmsCarryBindService,
IRunService runService,
IVisualDevService visualDevService
//IConfiguration configuration
) : base(repository.AsSugarClient())
{
@@ -88,6 +96,8 @@ namespace Tnb.WarehouseMgr
_elevatorControlService = elevatorControlService;
_redisData = redisData;
_wmsCarryBindService = wmsCarryBindService;
_runService = runService;
_visualDevService = visualDevService;
//_configuration = configuration;
}
@@ -530,12 +540,14 @@ namespace Tnb.WarehouseMgr
/// <returns></returns>
public async Task<bool> Floor2MechanicalComplete(WmsDistaskH disTask, string action)
{
List<string> rackAreaPoints = new List<string>();
// 二楼料架区点位
rackAreaPoints.Add("AS01");
rackAreaPoints.Add("AS02");
rackAreaPoints.Add("AX01");
rackAreaPoints.Add("AX02");
List<string> rackAreaPointsUp = new List<string>();
List<string> rackAreaPointsDown = new List<string>();
// 二楼上升降区料架区点位
rackAreaPointsUp.Add("AS01");
rackAreaPointsUp.Add("AS02");
// 二楼下升降区料架区点位
rackAreaPointsDown.Add("AX01");
rackAreaPointsDown.Add("AX02");
if (disTask.area_code == "E")
{
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】收到到货完成信号 传入参数: {disTask.bill_code} {action}");
@@ -544,7 +556,7 @@ namespace Tnb.WarehouseMgr
if (action == "UNLOAD")
{
// 去料架区放货
if (rackAreaPoints.Contains(disTask.endlocation_code))
if (rackAreaPointsUp.Contains(disTask.endlocation_code) || rackAreaPointsDown.Contains(disTask.endlocation_code))
{
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHs = db.Queryable<WmsMechanicalArmH>().Where(r => r.point_code == disTask.endpoint_code);
if (WmsMechanicalArmHs.Count() == 0)
@@ -561,7 +573,46 @@ namespace Tnb.WarehouseMgr
rackid = disTask.carry_id,
rackcode = disTask.carry_code
}).Where(r => r.id == target.id).ExecuteCommandAsync();
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】{disTask.bill_code} AGV已到货");
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】{disTask.bill_code} AGV已到货 {disTask.endpoint_code} 更新缓存表{target.id}");
// 下升降机写满托数量和送到信号
if (rackAreaPointsDown.Contains(disTask.endlocation_code))
{
int LXCount = db.Queryable<WmsCarryD>().Where(a => a.carry_id == disTask.carry_id).Count();
bool result = await Floor2UpDownMachinecode_SetTag($"下升降机满托{target.stackingposition}数量", LXCount.ToString());
Logger.LogInformation($@"【送满托到下升降区】设定下升降机满托{target.stackingposition}满托数量为 {LXCount} 结果为 {result}");
if (!result)
{
return false;
}
// 尝试写入满托送到信号
bool result下升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{target.stackingposition}送到", "true");
Logger.LogInformation($@"【送满托到下升降区】回写 下升降机满托{target.stackingposition}送到 结果为{result下升降机空托送到}");
if (!result下升降机空托送到)
{
return false;
}
// 绑定料架
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
{
mechanicalconfirm = 1,
maxnum = LXCount
}).Where(r => r.id == target.id).ExecuteCommandAsync();
Logger.LogInformation($@"【送满托到下升降区】 料架{target.rackid}下的料箱开始生成预任务");
bool pretask_result = await Floor2EmptyCarryCreateZZCPretask(disTask.carry_id);
if (pretask_result)
{
Logger.LogInformation($@"【送满托到下升降区】 料架{target.rackid}下的料箱生成预任务完成");
}
else
{
Logger.LogInformation($@"【送满托到下升降区】 料架{target.rackid}下的料箱生成预任务失败");
}
}
}
else // 去暂存仓放货
{
@@ -581,7 +632,7 @@ namespace Tnb.WarehouseMgr
else
{
// 去暂存仓取货
if (rackAreaPoints.Contains(disTask.endlocation_code))
if (rackAreaPointsUp.Contains(disTask.endlocation_code) || rackAreaPointsDown.Contains(disTask.endlocation_code))
{
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】{disTask.bill_code} AGV在暂存仓取货完成");
@@ -1150,7 +1201,7 @@ namespace Tnb.WarehouseMgr
}
await db.Ado.CommitTranAsync();
//判断
Logger.Information($"【CTUTaskExecute】 判断单据状态(status)是否为26126851525157 {JsonConvert.SerializeObject(DistaskHs)}");
Logger.Information($"【CTUTaskExecute】 判断单据状态(status)是否为待执行 {JsonConvert.SerializeObject(DistaskHs)}");
if (DistaskHs.Where(p => p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID).Any())
{
var time = int.Parse(db.Queryable<BasFactoryConfig>().Where(P => P.key == "getinterval").First().value);
@@ -2250,6 +2301,7 @@ namespace Tnb.WarehouseMgr
foreach (WmsCarryD wmsCarryD in wmsCarryCodes)
{
await s_floor2CreatePretask.WaitAsync();
//入库取终点 //出库起点
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID, Size = 1 };
List<BasLocation> endLocations = await InStockStrategy(inStockStrategyInput);
@@ -2258,107 +2310,69 @@ namespace Tnb.WarehouseMgr
Logger.LogWarning("没有可用的入库库位");
continue;
}
WmsPointH sPoint = null!;
WmsPointH ePoint = null!;
// todo 11、12线 分配方式暂定,待更改
BasLocation basLocation011 = _db.Queryable<BasLocation>().Where(r => r.id == WmsWareHouseConst.ZZCSSX111011).First();
BasLocation basLocation012 = _db.Queryable<BasLocation>().Where(r => r.id == WmsWareHouseConst.ZZCSSX111012).First();
BasLocation startLocation = basLocation011.task_nums >= basLocation012.task_nums ? basLocation012 : basLocation011;
BasLocation endLocation = endLocations[0];
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == startLocation.id);
if (endLocations?.Count > 0)
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == wmsCarryD.membercarry_code);
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == wmsCarryD.membercarry_code);
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
location_id = startLocation.id,
location_code = startLocation.location_code,
}).Where(r => r.id == carry.id).ExecuteCommandAsync();
//if (carry.carry_status == "1")
//{
// throw new AppFriendlyException("载具已占用!", 500);
//}
//if (carry.is_lock == 1)
//{
// throw new AppFriendlyException("载具已锁定!", 500);
//}
BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch)
{
Logger.LogWarning("库位与载具规格不匹配");
continue;
}
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}
else
location_id = startLocation.id,
location_code = startLocation.location_code,
}).Where(r => r.id == carry.id).ExecuteCommandAsync();
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, endLocation);
if (!isMatch)
{
Logger.LogWarning($"库位{endLocations[0].location_code}未在点位表中维护对应点位");
Logger.LogWarning("库位与载具规格不匹配");
continue;
}
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
commonCreatePretaskInput.startlocation_id = startLocation.id;
commonCreatePretaskInput.endlocation_id = endLocation.id;
commonCreatePretaskInput.carry_id = wmsCarryD.membercarry_id;
commonCreatePretaskInput.carry_code = wmsCarryD.membercarry_code;
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
commonCreatePretaskInput.isExcuteMission = false;
VisualDevModelDataCrInput visualDevInput = new VisualDevModelDataCrInput();
visualDevInput.data = new Dictionary<string, object>();
visualDevInput.data.Add("bill_code", "");
visualDevInput.data.Add("biz_type", WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID);
visualDevInput.data.Add("carry_code", wmsCarryD.membercarry_code);
visualDevInput.data.Add("carry_id", wmsCarryD.membercarry_id);
//visualDevInput.data.Add("create_id", "");
visualDevInput.data.Add("create_time", "");
visualDevInput.data.Add("flowId", "");
visualDevInput.data.Add("id", "");
visualDevInput.data.Add("location_id", startLocation.id);
visualDevInput.data.Add("modify_id", "");
visualDevInput.data.Add("modify_time", "");
//visualDevInput.data.Add("org_id", "");
visualDevInput.data.Add("status", WmsWareHouseConst.BILLSTATUS_ADD_ID);
visualDevInput.data.Add("warehouse_id", WmsWareHouseConst.WAREHOUSE_ZC_ID);
commonCreatePretaskInput.visualDevInput = visualDevInput;
Logger.LogInformation($"【送满托到下升降区】 开始生成一楼CTU'预任务 起点{sPoint.point_code} 终点{ePoint.point_code} 料箱 {wmsCarryD.membercarry_code}");
List<WmsPointH> points = new List<WmsPointH>();
points.Add(sPoint);
points.Add(ePoint);
Logger.LogInformation($"【送满托到下升降区】 开始生成一楼CTU预任务 起点{startLocation.location_code} 终点{endLocation.location_code} 料箱 {wmsCarryD.membercarry_code}");
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
WmsPretaskH preTask = null;
string bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
await _db.Updateable<BasLocation>().SetColumns(it => it.is_lock == 1).Where(r => r.id == endLocations[0].id).ExecuteCommandAsync();
await _db.Updateable<BasLocation>().SetColumns(it => it.task_nums == it.task_nums + 1).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
Entities.Dto.Outputs.Result res = await CommonCreatePretask(commonCreatePretaskInput);
if (res.code == JNPF.Common.Enums.HttpStatusCode.OK)
{
WmsPointH? sPoint = it.FirstOrDefault();
WmsPointH? ePoint = it.LastOrDefault();
preTask = new()
{
org_id = "",
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
endlocation_code = ePoint?.location_code!,
start_floor = sPoint?.floor.ToString(),
end_floor = ePoint?.floor.ToString(),
startpoint_id = sPoint?.id!,
startpoint_code = sPoint?.point_code!,
endpoint_id = ePoint?.id!,
endpoint_code = ePoint?.point_code!,
bill_code = bill_code,
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID,
task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
carry_id = wmsCarryD.membercarry_id,
carry_code = wmsCarryD.membercarry_code,
area_id = sPoint?.area_id!,
area_code = it.Key,
require_id = "",
require_code = "",
create_id = "",
create_time = DateTime.Now
};
return preTask;
}).ToList();
//更新页面
//赋值签收状态
Logger.LogInformation($"开始执行 GenPreTask {JsonConvert.SerializeObject(preTasks)}");
bool result = await GenPreTask(preTasks, null!);
Logger.LogInformation($"GenPreTask 结果 {result}");
if (result)
{
_ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_lock = 1 }).Where(r => r.id == endLocations[0].id).ExecuteCommandAsync();
_ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { task_nums = it.task_nums + 1 }).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
Logger.LogInformation($"成功生成预任务:{preTasks.First().bill_code}");
}
else
{
Logger.LogInformation($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】 未成功生成预任务 起点{sPoint.point_code} 终点{ePoint.point_code} 料箱 {wmsCarryD.membercarry_code}");
Logger.LogInformation($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】 未成功生成预任务 起点{startLocation.location_code} 终点{endLocation.location_code} 料箱 {wmsCarryD.membercarry_code}");
}
s_floor2CreatePretask.Release();
}
return true;
@@ -2419,7 +2433,7 @@ namespace Tnb.WarehouseMgr
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
WmsPretaskH preTask = null;
string bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
string bill_code = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE);
string carry_id = "";
string carry_code = "";
@@ -2459,6 +2473,15 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("起点库位上没有载具", 500);
}
if (input.visualDevInput != null)
{
//在线开发
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true);
await _runService.Create(templateEntity, input.visualDevInput);
input.require_id = input.visualDevInput.data["ReturnIdentity"].ToString() ?? "";
input.require_code = input.visualDevInput.data["bill_code"].ToString() ?? "";
}
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
@@ -2468,7 +2491,7 @@ namespace Tnb.WarehouseMgr
preTask = new()
{
org_id = _userManager.User.OrganizeId,
org_id = _userManager.User?.OrganizeId,
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
@@ -2488,7 +2511,7 @@ namespace Tnb.WarehouseMgr
area_id = sPoint?.area_id!,
area_code = it.Key,
require_id = input.require_id,
require_code = "",
require_code = input.require_code,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
@@ -2498,12 +2521,12 @@ namespace Tnb.WarehouseMgr
//更新页面
//赋值签收状态
Logger.LogInformation($"【createPretask】 开始执行 GenPreTask {JsonConvert.SerializeObject(preTasks)}");
Logger.LogInformation($"【CommonCreatePretask】 开始执行 GenPreTask {JsonConvert.SerializeObject(preTasks)}");
bool result = await GenPreTask(preTasks, null!);
Logger.LogInformation($"【createPretask】 GenPreTask 结果 {result}");
Logger.LogInformation($"【CommonCreatePretask】 GenPreTask 结果 {result}");
if (result)
{
Logger.LogInformation($"【createPretask】 成功生成预任务:{preTasks.First().bill_code}");
Logger.LogInformation($"【CommonCreatePretask】 成功生成预任务:{preTasks.First().bill_code}");
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功");
}
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, "生成预任务失败");
@@ -2514,7 +2537,10 @@ namespace Tnb.WarehouseMgr
}
finally
{
GenTaskExecute();
if (input.isExcuteMission)
{
GenTaskExecute();
}
}
}

View File

@@ -66,7 +66,7 @@ namespace Tnb.WarehouseMgr
OverideFuncs.CreateAsync = WmsEmptyIn;
}
private async Task<dynamic> WmsEmptyIn(VisualDevModelDataCrInput input)
public async Task<dynamic> WmsEmptyIn(VisualDevModelDataCrInput input)
{
try
{

View File

@@ -252,7 +252,7 @@ namespace Tnb.Common.Redis
string data = await GetHash(key, field);
Dictionary<String, String> json = JsonConvert.DeserializeObject<Dictionary<String, String>>(data);
Type type = typeof(T);
if (!type.IsValueType || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)))
if ((!type.IsValueType && type.GetGenericArguments().Length > 0) || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)))
{
return (T)Convert.ChangeType(json["Value"],type.GetGenericArguments()[0]);
}