Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2024-06-29 14:00:46 +08:00
13 changed files with 209 additions and 77 deletions

View File

@@ -96,7 +96,7 @@ namespace Tnb.ProductionMgr
private readonly ISqlSugarClient db_BGWCarrySupplementtimer;
private readonly ISqlSugarClient db_YCLGLDPJInstocktimer;
private readonly ISqlSugarClient db_YCLWXDPJInstocktimer;
private readonly ISqlSugarClient db_Floor2UpMachinecodetimer;
private ISqlSugarClient db_Floor2UpMachinecodetimer;
private readonly ISqlSugarClient db_Floor2timer送空托到上升降区;
private readonly ISqlSugarClient db_Floor2timer送满托到下升降区;
private readonly ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架;
@@ -518,7 +518,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (!result_createPretask)
{
LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败 ");
continue;
throw new Exception($"【BGWCarrySupplementtimer】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败");
}
LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成成功");
@@ -611,7 +611,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (!result_createPretask)
{
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败");
continue;
throw new Exception($"【YCLGLDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败");
}
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成成功");
@@ -699,7 +699,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (!result_createPretask)
{
LoggerYCLGLDPJInstock.LogWarning($"【YCLWXDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败");
continue;
throw new Exception($"【YCLWXDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败");
}
LoggerYCLGLDPJInstock.LogWarning($"【YCLWXDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成成功");
@@ -941,6 +941,21 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
// 料箱信息
WmsCarryH LX = db_Floor2UpMachinecodetimer.Queryable<WmsCarryH>().Where(r => r.carry_code == barcode).ToList()[0];
// 绑定料箱到料架
CarryBindInput carryBindInput = new();
carryBindInput.carry_id = target.rackid;
carryBindInput.carry_code = target.rackcode;
carryBindInput.membercarry_id = LX.id;
carryBindInput.membercarry_code = LX.carry_code;
carryBindInput.carrystd_id = rack.carrystd_id;
carryBindInput.source_code = target.outbill;
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result bindResult = await _wmsCarryBindService.CarryBind(carryBindInput);
if (bindResult.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw new Exception(bindResult.msg);
}
// 开始码垛
bool result_开始码垛 = await Floor2UpDownMachinecode_SetTag(MechanicalArmConsts., target.stackingposition.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】码垛结果 {result_开始码垛}");
@@ -964,22 +979,18 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}).Where(r => r.id == WmsMaterialTransfer.id).ExecuteCommandAsync();
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】回写转库单的剩余可绑定料架数量");
// 绑定料箱到料架
CarryBindInput carryBindInput = new();
carryBindInput.carry_id = target.rackid;
carryBindInput.carry_code = target.rackcode;
carryBindInput.membercarry_id = LX.id;
carryBindInput.membercarry_code = LX.carry_code;
carryBindInput.carrystd_id = rack.carrystd_id;
carryBindInput.source_code = target.outbill;
await _wmsCarryBindService.CarryBind(carryBindInput);
await db_Floor2UpMachinecodetimer.Ado.CommitTranAsync();
}
}
catch (Exception ex)
{
// 测试代码 无问题后期删
if (ex.Message.Contains("Connection is busy"))
{
db_Floor2UpMachinecodetimer = db_Floor2UpMachinecodetimer.CopyNew();
}
LoggerFloor2UpDownMachine.LogError(ex.ToString());
LoggerFloor2UpDownMachine.LogError(ex.StackTrace);
await db_Floor2UpMachinecodetimer.Ado.RollbackTranAsync();
@@ -987,6 +998,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
finally
{
s_taskExecuteFloor2UpMachinecodetimer.Release();
if (!db_Floor2UpMachinecodetimer.Ado.Transaction.IsNull())
await db_Floor2UpMachinecodetimer.Ado.CommitTranAsync();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行Floor2UpMachinecode {stopwatch.ElapsedMilliseconds} ms");
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行Floor2UpMachinecode {stopwatch.ElapsedMilliseconds} ms");
@@ -1121,6 +1135,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
finally
{
s_task送空托到上升降区.Release();
if (!db_Floor2timer送空托到上升降区.Ado.Transaction.IsNull())
await db_Floor2timer送空托到上升降区.Ado.CommitTranAsync();
_wareHouseService.GenTaskExecute();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行送空托到上升降区 {stopwatch.ElapsedMilliseconds} ms");
@@ -1190,13 +1206,15 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
.Where((a, b, c, d) => a.wh_id == "33780009364245" && a.is_use == "1" && a.is_lock == 0 && a.is_type == "0" && !string.IsNullOrEmpty(c.id)
&& b.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID).OrderBy((a, b, c, d) => d.id).Select((a, b, c, d) => new // 关联载具物料明细表
{
wmsCarryH = b,
basLocation = a,
WmsCarryCode_id = d.id
}).ToList().GroupBy(r => r.basLocation.location_code).Select(r =>
{
var item = r.FirstOrDefault();
// 前面通过OrderBy(d => d.id)对WmsCarryCode_id进行了排序 那么如果第一行有数据则说明存在非空料箱
if (!string.IsNullOrEmpty(item.WmsCarryCode_id))
// 空载具入库: 前面通过OrderBy(d => d.id)对WmsCarryCode_id进行了排序 那么如果第一行有数据则说明存在非空料箱
// 没有物料且没有退料标记的不满足出库条件
if (!string.IsNullOrEmpty(item.WmsCarryCode_id) && (item.wmsCarryH.need_return == 0 || item.wmsCarryH.need_return == null))
{
return new BasLocation();
}
@@ -1257,11 +1275,16 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 开始生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}");
await db_Floor2timer送满托到下升降区.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
need_return = 0
}).Where(r => r.id == targetCarry.id).ExecuteCommandAsync();
bool result = await createPretask(startLocation.id, wmsMechanicalArmH.location_id, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery, db_Floor2timer送满托到下升降区);
if (!result)
{
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 未成功生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}");
continue;
throw new Exception($"【送满托到下升降区】 未成功生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}");
}
}
await db_Floor2timer送满托到下升降区.Ado.CommitTranAsync();
@@ -1276,6 +1299,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
finally
{
s_task送满托到下升降区.Release();
if (!db_Floor2timer送满托到下升降区.Ado.Transaction.IsNull())
await db_Floor2timer送满托到下升降区.Ado.CommitTranAsync();
_wareHouseService.GenTaskExecute();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行送满托到下升降区 {stopwatch.ElapsedMilliseconds} ms");
@@ -1380,6 +1405,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
finally
{
s_task移走上升降区未生成预任务且满托的料架.Release();
if (!db_Floor2timer移走上升降区未生成预任务且满托的料架.Ado.Transaction.IsNull())
await db_Floor2timer移走上升降区未生成预任务且满托的料架.Ado.CommitTranAsync();
_wareHouseService.GenTaskExecute();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行移走上升降区未生成预任务且满托的料架 {stopwatch.ElapsedMilliseconds} ms");
@@ -1459,7 +1486,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
carryBindInput.carry_code = wmsMechanicalArmH.rackcode;
carryBindInput.source_code = wmsMechanicalArmH.outbill;
await _wmsCarryUnbindService.CarryUnbind(carryBindInput);
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result unbindResult = await _wmsCarryUnbindService.CarryUnbind(carryBindInput);
if (unbindResult.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw new Exception(unbindResult.msg);
}
// 锁住终点库位
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Updateable<BasLocation>(r => new BasLocation
@@ -1473,7 +1504,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (!result)
{
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}");
continue;
throw new Exception($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}");
}
}
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.CommitTranAsync();
@@ -1488,6 +1519,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
finally
{
s_task移走下升降区未生成预任务且空托的料架.Release();
if (!db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.Transaction.IsNull())
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.CommitTranAsync();
_wareHouseService.GenTaskExecute();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行移走下升降区未生成预任务且空托的料架 {stopwatch.ElapsedMilliseconds} ms");

View File

@@ -227,7 +227,7 @@ public class ModuleConsts
/// <summary>
/// 模块标识-原材料转库单
/// </summary>
public const string MODULE_WMSMATERIALTRANSFER_ID = "34354738929685";
public const string MODULE_WMSMATERIALTRANSFER_ID = "35129233455125";
/// <summary>
/// 模块标识-生产入库单
/// </summary>

View File

@@ -28,5 +28,18 @@
/// 生产退料单id
/// </summary>
public string source_id { get; set; }
/// <summary>
/// 空料箱
/// </summary>
public List<PrdReturnDetail> details { get; set; }
}
public class PrdReturnDetail
{
/// <summary>
/// 料箱号
/// </summary>
public string? carry_code { get; set; }
}
}

View File

@@ -139,5 +139,10 @@ public partial class WmsCarryH : BaseEntity<string>
/// 配送工位
/// </summary>
public string? work_station { get; set; }
/// <summary>
/// 需要退料
/// </summary>
public int need_return { get; set; }
}

View File

@@ -1,9 +1,11 @@
using System.Text;
using JNPF;
using JNPF.Common.Extension;
using JNPF.Logging;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto.Queries;
@@ -35,7 +37,6 @@ namespace Tnb.WarehouseMgr
private static async Task InitializeAsync()
{
ConnectionStringsOptions connectionOpts = App.GetConfig<ConnectionStringsOptions>("ConnectionStrings", true);
ConnectionConfig cfg = new()
{

View File

@@ -342,9 +342,9 @@ namespace Tnb.WarehouseMgr
if (sysStatus == (int)EnumSysStatus. && runStatus == (int)EnumRunStatus.
&& doorStatus == (int)EnumDoorStatus. && s_eleUseStatusDic[elevator.device_id] == (int)EnumElevatorUseStatus.)
{
Logger.Information($"【UnloadConfirm】 {devName}放货成功 状态变更为占用");
await _db.Updateable<WmsElevatorH>().SetColumns(r => r.is_use == (int)EnumElevatorUseStatus.).Where(r => r.elevator_id == elevator.device_id).ExecuteCommandAsync();
s_eleUseStatusDic[elevator.device_id] = (int)EnumElevatorUseStatus.;
Logger.Information($"【UnloadConfirm】 {devName}放货成功 状态变更为占用 {s_eleUseStatusDic.GetHashCode()} {s_eleUseStatusDic[elevator.device_id]}");
return await ToApiResult(HttpStatusCode.OK, "成功");
}
Logger.Information($"【UnloadConfirm】 电梯还未开门请重试sysStatus: {sysStatus} runStatus:{runStatus} doorStatus: {doorStatus} s_eleUseStatusDic[elevator.device_id]: {s_eleUseStatusDic[elevator.device_id]}");
@@ -521,10 +521,14 @@ namespace Tnb.WarehouseMgr
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> TaskCallback(TaskCallBackInput input)
{
var disTask = await _db.Queryable<WmsDistaskH>().FirstAsync(it => it.bill_code == input.taskCode);
/* 20240627 记录异常情况: WCS给我们发取货完成信号之后如果我们返回了异常 WCS会一直重试20次但是AGV已经取货走了并成功送到库位此时会给我们反馈放货信号
* 但是由于取货信号一直返回异常WCS还是会一直重试,会出现我们收到到货信号后又会收到取货信号的异常情况,这里加个任务执行状态判断,用于避免这种情况
*/
//if (disTask.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID)
//{
// return await ToApiResult(HttpStatusCode.OK, "此任务");
//}
Logger.Information($"【TaskCallback】 【接收】{input.taskCode} WCS信号 任务状态上报->接收参数:{JsonConvert.SerializeObject(input)}");
try
@@ -559,7 +563,7 @@ namespace Tnb.WarehouseMgr
s_eleUseStatusDic[elevator.device_id] = (int)EnumElevatorUseStatus.;
// 根据disTask StartLocationId 起始库位关联电梯获取设备ID location_code.Continas("")
var devName = s_elevatorMap[elevator.device_id]?.ToString();
Logger.Information($"【TaskCallback】 {devName.Match(@"\d+")}#梯,设备名称:{devName},开始进入关门流程 {devName} 变更为空闲");
Logger.Information($"【TaskCallback】 {devName.Match(@"\d+")}#梯,设备名称:{devName},开始进入关门流程 {devName} 变更为空闲 {s_eleUseStatusDic.GetHashCode()} {s_eleUseStatusDic[elevator.device_id]}");
int doorStatus = await _elevatorControlService.GetTagAsync(devName, ElevatorConsts.DoorStatus);
Logger.Information($"【TaskCallback】 设备:{devName},门状态:{doorStatus.ToEnum<EnumDoorStatus>().ToString()}");
if (doorStatus.ToEnum<EnumDoorStatus>() != EnumDoorStatus.

View File

@@ -1222,7 +1222,7 @@ namespace Tnb.WarehouseMgr
foreach (var task in agvDTTasks)
{
ElevagorInfoQuery q = new() { endlocation_id = task.endlocation_id };
ElevagorInfoQuery q = new() { endlocation_id = task.endlocation_id, taskCode = task.bill_code };
Logger.Information($"【GenTaskExecute】呼梯时 根据任务单号获取电梯参数 {JsonConvert.SerializeObject(q)}");
var e = await FindElevatorFromPars(q);
Logger.Information($"【GenTaskExecute】呼梯时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
@@ -1266,7 +1266,7 @@ namespace Tnb.WarehouseMgr
{
foreach (WmsDistaskH? elevatorTask in elevatorTasks)
{
ElevagorInfoQuery q = new() { endlocation_id = elevatorTask.endlocation_id };
ElevagorInfoQuery q = new() { endlocation_id = elevatorTask.endlocation_id, taskCode = elevatorTask.bill_code};
Logger.Information($"【GenTaskExecute】执行电梯任务时 根据任务单号获取电梯参数 {JsonConvert.SerializeObject(q)}");
var e = await FindElevatorFromPars(q);
Logger.Information($"【GenTaskExecute】执行电梯任务时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
@@ -1810,6 +1810,7 @@ namespace Tnb.WarehouseMgr
do
{
eleStatusMulti = await _elevatorControlService.GetElevatorStatus(devName, tags, CancellationToken.None);
Logger.Information($"{devName.Match(@"\d+")}#, 当前Agv状态:{eleStatusMulti.agvStatus.ToEnum<EnumAgvStatus>()}");
await Task.Delay(1000);
} while (eleStatusMulti.agvStatus != (int)EnumAgvStatus.AGV运行状态 );
Logger.Information($"{devName.Match(@"\d+")}#, 当前Agv状态:{eleStatusMulti.agvStatus.ToEnum<EnumAgvStatus>()}");
@@ -1835,8 +1836,8 @@ namespace Tnb.WarehouseMgr
Logger.Information($"开始呼梯 {devName}到{floor}");
//发送到目标楼的指令
dynamic reuslt = await _elevatorControlService.WriteTagAsync(devName, ElevatorConsts.FloorExecute, floor);
dynamic result = await _elevatorControlService.WriteTagAsync(devName, ElevatorConsts.FloorExecute, floor);
do
{
tuple = await _elevatorControlService.GetElevatorStatus(devName, tags, CancellationToken.None);
@@ -2098,7 +2099,7 @@ namespace Tnb.WarehouseMgr
{
id = multiList[i].endlocation_id,
is_lock = 0,
is_use = multiList[i].carry_status
is_use = string.IsNullOrEmpty(multiList[i].carry_status) ? ((int)EnumCarryStatus.).ToString() : multiList[i].carry_status
};
if (!string.IsNullOrEmpty(multiList[i].carry_status) && multiList[i].carry_status.ToEnum<EnumCarryStatus>() == EnumCarryStatus.)
{
@@ -2119,6 +2120,7 @@ namespace Tnb.WarehouseMgr
_ = await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => multiList.Select(x => x.carry_id).Contains(it.carry_id)).ExecuteCommandAsync();
//更新库位信息,使用状态为 使用,锁定状态为未锁定
_ = await _db.Updateable(locIts).UpdateColumns(it => new { it.is_use, it.is_lock }).ExecuteCommandAsync();
Logger.Information($"【TaskComplate】 更新库位 {JsonConvert.SerializeObject(locIts)}");
/* var loginType= _userManager?.LoginType ?? "web";
Log.Information($"_userManager.LoginType={loginType}");
*/ //更新业务主表的单据状态
@@ -2151,11 +2153,13 @@ namespace Tnb.WarehouseMgr
// 二楼物料呼叫任务结束后清空工位信息
else if (dt.biz_type == "FloorCallMaterial")
{
await _db.Updateable<WmsCarryH>().SetColumns(r => r.work_station == "").Where(r => r.id == dt.carry_id).ExecuteCommandAsync();
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
work_station = ""
}).Where(r => r.id == dt.carry_id).ExecuteCommandAsync();
// require_code是任务单
//string mo_task_code = dt.require_code;
}
#endregion
@@ -2971,7 +2975,7 @@ namespace Tnb.WarehouseMgr
}
else
{
throw new AppFriendlyException("生成预任务失败", 500);
throw new AppFriendlyException("生成预任务失败(可能是因为预任务起点与终点相同)", 500);
}
}
catch (Exception ex)

View File

@@ -215,6 +215,20 @@ namespace Tnb.WarehouseMgr
WmsCarryH? subCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.membercarry_id);
if (carry != null && subCarry != null)
{
// 插入子载具绑定记录
VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1;
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYBIND_ID, true);
await _runService.Create(templateEntity, visualDevModelCrInput);
WmsCarryD wmsCarryD = new()
{
carry_id = input.carry_id,
@@ -230,20 +244,6 @@ namespace Tnb.WarehouseMgr
throw Oops.Oh(ErrorCode.COM1001);
}
// 插入子载具绑定记录
VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1;
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYBIND_ID, true);
await _runService.Create(templateEntity, visualDevModelCrInput);
await _db.Ado.CommitTranAsync();
Logger.LogError($"【CarryBind】 {input.membercarry_code}成功绑定到{input.carry_code}");
}

View File

@@ -152,20 +152,20 @@ namespace Tnb.WarehouseMgr
// 插入子载具绑定记录
VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
if (!string.IsNullOrEmpty(input.create_id))
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id;
//VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
//visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
//if (!string.IsNullOrEmpty(input.create_id))
// visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1;
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBIND_ID, true);
await _runService.Create(templateEntity, visualDevModelCrInput);
//visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1;
//VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBIND_ID, true);
//await _runService.Create(templateEntity, visualDevModelCrInput);
await _db.Ado.CommitTranAsync();
}

View File

@@ -89,14 +89,23 @@ namespace Tnb.WarehouseMgr
{
try
{
JObject queryJson = null;
if (!string.IsNullOrEmpty(input.queryJson))
{
queryJson = JObject.Parse(input.queryJson);
}
SqlSugarPagedList<WmsMaterialTransfer> result = await _db.Queryable<WmsMaterialTransfer>()
.InnerJoin<DictionaryDataEntity>((a, b) => a.status == b.Id)
.InnerJoin<UserEntity>((a, b, c) => c.Id == a.create_id)
.InnerJoin<BasWarehouse>((a, b, c, d) => d.id == a.warehouse_outstock)
.InnerJoin<BasWarehouse>((a, b, c, d, e) => e.id == a.warehouse_instock)
.InnerJoin<DictionaryDataEntity>((a, b, c, d, e, f) => a.type == f.EnCode)
// 只显示未完成的单据
.Where( a => a.status != "25065149810453")
.Select((a, b, c, d, e) => new WmsMaterialTransfer
.Where(a => a.status != "25065149810453")
.WhereIF(queryJson != null, a => a.type == queryJson["type"].ToString())
.Select((a, b, c, d, e, f) => new WmsMaterialTransfer
{
id = a.id,
create_id = c.RealName,
@@ -111,7 +120,7 @@ namespace Tnb.WarehouseMgr
bill_date = a.bill_date,
warehouse_outstock = d.whname,
warehouse_instock = e.whname,
type = a.type,
type = f.FullName,
biller_out = a.biller_out,
depart_out = a.depart_out,
biller_in = a.biller_in,
@@ -967,6 +976,13 @@ namespace Tnb.WarehouseMgr
{
try
{
List<WmsCarryD> wmsCarryDs = _db.Queryable<WmsCarryD>().Where(r => r.carry_id == wmsCarryH.id).ToList();
if (wmsCarryDs.Count > 0)
{
Logger.LogWarning($"【RackInstock】料架{wmsCarryH.carry_code}下有料箱未解绑!");
throw new AppFriendlyException($"【RackInstock】料架{wmsCarryH.carry_code}下有料箱未解绑!", 500);
}
BasLocation startlocation = _db.Queryable<BasLocation>().Where(r => r.id == input.startlocation_id).First();
if (startlocation == null)
{

View File

@@ -636,6 +636,8 @@ namespace Tnb.WarehouseMgr
catch (Exception ex)
{
Logger.LogInformation($"【ScanInStockByRedis】 八工位扫到码发送入库请求发生异常:{ex.Message}");
// 测试代码
if (ex.Message.Contains("Connection is busy"))
_dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew();

View File

@@ -38,18 +38,21 @@ namespace Tnb.WarehouseMgr
private readonly IVisualDevService _visualDevService;
private readonly IUserManager _userManager;
private readonly IWareHouseService _wareHouseService;
private readonly IWmsCarryBindService _wmsCarryBindService;
public WmsPrdReturnService(
ISqlSugarRepository<WmsCarryH> repository,
IRunService runService,
IVisualDevService visualDevService,
IWareHouseService wareHouseService,
IUserManager userManager)
IUserManager userManager,
IWmsCarryBindService wmsCarryBindService)
{
_db = repository.AsSugarClient();
_runService = runService;
_visualDevService = visualDevService;
_userManager = userManager;
_wareHouseService = wareHouseService;
_wmsCarryBindService = wmsCarryBindService;
}
/// <summary>
@@ -101,6 +104,13 @@ namespace Tnb.WarehouseMgr
{
try
{
List<WmsCarryD> wmsCarryDs = _db.Queryable<WmsCarryD>().Where(r => r.carry_id == wmsCarryH.id).ToList();
if (wmsCarryDs.Count > 0)
{
Logger.LogWarning($"【PrdReturn】料架{wmsCarryH.carry_code}下有料箱未解绑!");
throw new AppFriendlyException($"【PrdReturn】料架{wmsCarryH.carry_code}下有料箱未解绑!", 500);
}
BasLocation startlocation = _db.Queryable<BasLocation>().Where(r => r.id == input.startlocation_id).First();
if (startlocation == null)
{
@@ -169,6 +179,29 @@ namespace Tnb.WarehouseMgr
await _db.Ado.BeginTranAsync();
// 标记为退料
await _db.Updateable<WmsCarryH>().SetColumns(r => r.need_return == 1).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync();
Logger.LogWarning($"【RackEmptyInstock】绑定料箱到料架");
List<WmsCarryH> membercarrys = _db.Queryable<WmsCarryH>().Where(r => input.details.Select(r => r.carry_code).Contains(r.carry_code)).ToList();
foreach (WmsCarryH membercarry in membercarrys)
{
// 绑定料箱到料架
CarryBindInput _carryBindInput = new();
_carryBindInput.carry_id = wmsCarryH.id;
_carryBindInput.carry_code = wmsCarryH.carry_code;
_carryBindInput.membercarry_id = membercarry.id;
_carryBindInput.membercarry_code = membercarry.carry_code;
_carryBindInput.carrystd_id = wmsCarryH.carrystd_id;
var resCarrybind = await _wmsCarryBindService.CarryBind(_carryBindInput);
if (resCarrybind.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw new AppFriendlyException($"绑定料箱到料架失败 载具 {input.carry_code}", 500);
}
}
Logger.LogWarning($"【PrdReturn】开始生成预任务");
CommonCreatePretaskInput commonCreatePretaskInput = new();
commonCreatePretaskInput.startlocation_id = startlocation.id;
@@ -268,6 +301,8 @@ namespace Tnb.WarehouseMgr
}
await _db.Ado.BeginTranAsync();
// 标记为退料
await _db.Updateable<WmsCarryH>().SetColumns(r => r.need_return == 1).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync();
Logger.LogWarning($"【PrdReturn】开始生成预任务");
CommonCreatePretaskInput commonCreatePretaskInput = new();

View File

@@ -1,4 +1,5 @@
using System.Text;
using Aop.Api.Domain;
using JNPF.Common.Const;
using JNPF.Common.Core.Manager;
using JNPF.Common.Core.Manager.Files;
@@ -19,6 +20,7 @@ using JNPF.Systems.Interfaces.System;
using Mapster;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;
using SqlSugar;
namespace JNPF.Systems;
@@ -65,6 +67,8 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
_fileManager = fileManager;
}
public SemaphoreSlim s_getBillNumber = new(1);
#region Get
/// <summary>
@@ -272,27 +276,42 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
[NonAction]
public async Task<string> GetBillNumber(string enCode, bool isCache = false)
{
string cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYBILLRULE, _userManager.TenantId, _userManager.UserId + enCode);
string strNumber = string.Empty;
if (isCache)
try
{
if (!_cacheManager.Exists(cacheKey))
s_getBillNumber.WaitAsync();
string cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYBILLRULE, _userManager.TenantId, _userManager.UserId + enCode);
string strNumber = string.Empty;
if (isCache)
{
strNumber = await GetNumber(enCode);
await _cacheManager.SetAsync(cacheKey, strNumber, new TimeSpan(0, 3, 0));
if (!_cacheManager.Exists(cacheKey))
{
strNumber = await GetNumber(enCode);
await _cacheManager.SetAsync(cacheKey, strNumber, new TimeSpan(0, 3, 0));
}
else
{
strNumber = await _cacheManager.GetAsync(cacheKey);
}
}
else
{
strNumber = await _cacheManager.GetAsync(cacheKey);
strNumber = await GetNumber(enCode);
_cacheManager.Set(cacheKey, strNumber, new TimeSpan(0, 3, 0));
}
}
else
{
strNumber = await GetNumber(enCode);
_cacheManager.Set(cacheKey, strNumber, new TimeSpan(0, 3, 0));
}
return strNumber;
return strNumber;
}
catch(Exception ex)
{
Logging.Log.Error("【GetBillNumber】" + ex.Message);
Logging.Log.Error("【GetBillNumber】" + ex.StackTrace);
throw;
}
finally
{
s_getBillNumber.Release();
}
}
#endregion