diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 5e8fb7db..7048b44d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -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().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().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(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"); diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index 0486c45f..97161545 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -227,7 +227,7 @@ public class ModuleConsts /// /// 模块标识-原材料转库单 /// - public const string MODULE_WMSMATERIALTRANSFER_ID = "34354738929685"; + public const string MODULE_WMSMATERIALTRANSFER_ID = "35129233455125"; /// /// 模块标识-生产入库单 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs index 86b1812f..e803826c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs @@ -28,5 +28,18 @@ /// 生产退料单id /// public string source_id { get; set; } + + /// + /// 空料箱 + /// + public List details { get; set; } + } + + public class PrdReturnDetail + { + /// + /// 料箱号 + /// + public string? carry_code { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs index c83331eb..f4725c05 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs @@ -139,5 +139,10 @@ public partial class WmsCarryH : BaseEntity /// 配送工位 /// public string? work_station { get; set; } + + /// + /// 需要退料 + /// + public int need_return { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DevServBase`1.cs b/WarehouseMgr/Tnb.WarehouseMgr/DevServBase`1.cs index 96e383a2..c2e188f2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DevServBase`1.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DevServBase`1.cs @@ -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("ConnectionStrings", true); ConnectionConfig cfg = new() { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index 6810e155..3b94f7c9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -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().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 TaskCallback(TaskCallBackInput input) { var disTask = await _db.Queryable().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().ToString()}"); if (doorStatus.ToEnum() != EnumDoorStatus.关门到位保持 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 1079447b..c195df5f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -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()}"); await Task.Delay(1000); } while (eleStatusMulti.agvStatus != (int)EnumAgvStatus.AGV运行状态 ); Logger.Information($"{devName.Match(@"\d+")}#, 当前Agv状态:{eleStatusMulti.agvStatus.ToEnum()}"); @@ -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.空闲) { @@ -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().SetColumns(r => r.work_station == "").Where(r => r.id == dt.carry_id).ExecuteCommandAsync(); + await _db.Updateable().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) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 33ff504f..cf5c3a07 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -215,6 +215,20 @@ namespace Tnb.WarehouseMgr WmsCarryH? subCarry = await _db.Queryable().SingleAsync(it => it.id == input.membercarry_id); if (carry != null && subCarry != null) { + // 插入子载具绑定记录 + VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary() }; + 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() }; - 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}"); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 7e5bbd68..ca0895b7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -152,20 +152,20 @@ namespace Tnb.WarehouseMgr // 插入子载具绑定记录 - VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary() }; - 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() }; + //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(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index c88b7d33..8008fbd9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -89,14 +89,23 @@ namespace Tnb.WarehouseMgr { try { + JObject queryJson = null; + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JObject.Parse(input.queryJson); + } + + SqlSugarPagedList result = await _db.Queryable() .InnerJoin((a, b) => a.status == b.Id) .InnerJoin((a, b, c) => c.Id == a.create_id) .InnerJoin((a, b, c, d) => d.id == a.warehouse_outstock) .InnerJoin((a, b, c, d, e) => e.id == a.warehouse_instock) + .InnerJoin((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 wmsCarryDs = _db.Queryable().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().Where(r => r.id == input.startlocation_id).First(); if (startlocation == null) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs index 1e0d2d0f..fae9cec3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs @@ -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(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs index a1d69bb7..b4f9b33f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs @@ -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 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; } /// @@ -101,6 +104,13 @@ namespace Tnb.WarehouseMgr { try { + List wmsCarryDs = _db.Queryable().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().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().SetColumns(r => r.need_return == 1).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync(); + + Logger.LogWarning($"【RackEmptyInstock】绑定料箱到料架"); + + List membercarrys = _db.Queryable().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().SetColumns(r => r.need_return == 1).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync(); Logger.LogWarning($"【PrdReturn】开始生成预任务"); CommonCreatePretaskInput commonCreatePretaskInput = new(); diff --git a/system/Tnb.Systems/System/BillRuleService.cs b/system/Tnb.Systems/System/BillRuleService.cs index 07e3b943..bd3dd45a 100644 --- a/system/Tnb.Systems/System/BillRuleService.cs +++ b/system/Tnb.Systems/System/BillRuleService.cs @@ -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 /// @@ -272,27 +276,42 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie [NonAction] public async Task 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