二楼细节完善 bug处理

This commit is contained in:
2024-07-03 17:06:02 +08:00
parent 7fa009d599
commit 1b564293d1
16 changed files with 194 additions and 104 deletions

View File

@@ -26,6 +26,7 @@ using Microsoft.Extensions.Logging;
using NetTaste; using NetTaste;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Npgsql;
using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Asn1.X509.Qualified; using Org.BouncyCastle.Asn1.X509.Qualified;
using Qiniu.Util; using Qiniu.Util;
@@ -91,16 +92,16 @@ namespace Tnb.ProductionMgr
private readonly IPrdInstockService _prdInstockService; private readonly IPrdInstockService _prdInstockService;
private readonly ISqlSugarRepository<RedisReadConfig> _repository; private readonly ISqlSugarRepository<RedisReadConfig> _repository;
private ISqlSugarClient db_Scantimer; private ISqlSugarClient db_Scantimer;
private readonly ISqlSugarClient db_CheckGettimer; private ISqlSugarClient db_CheckGettimer;
private readonly ISqlSugarClient db_SSXcodetimer; private ISqlSugarClient db_SSXcodetimer;
private readonly ISqlSugarClient db_BGWCarrySupplementtimer; private ISqlSugarClient db_BGWCarrySupplementtimer;
private readonly ISqlSugarClient db_YCLGLDPJInstocktimer; private ISqlSugarClient db_YCLGLDPJInstocktimer;
private readonly ISqlSugarClient db_YCLWXDPJInstocktimer; private ISqlSugarClient db_YCLWXDPJInstocktimer;
private ISqlSugarClient db_Floor2UpMachinecodetimer; private ISqlSugarClient db_Floor2UpMachinecodetimer;
private readonly ISqlSugarClient db_Floor2timer送空托到上升降区; private ISqlSugarClient db_Floor2timer送空托到上升降区;
private readonly ISqlSugarClient db_Floor2timer送满托到下升降区; private ISqlSugarClient db_Floor2timer送满托到下升降区;
private readonly ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架; private ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架;
private readonly ISqlSugarClient db_Floor2timer移走下升降区未生成预任务且空托的料架; private ISqlSugarClient db_Floor2timer移走下升降区未生成预任务且空托的料架;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock; private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService; private readonly IBillRullService _billRullService;
@@ -111,6 +112,14 @@ namespace Tnb.ProductionMgr
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>(); private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
static ConnectionStringsOptions connectionOpts = App.GetConfig<ConnectionStringsOptions>("ConnectionStrings", true);
static ConnectionConfig cfg = new()
{
ConfigId = connectionOpts.ConfigId,
ConnectionString = connectionOpts.ConnectString,
DbType = SqlSugar.DbType.PostgreSQL,
IsAutoCloseConnection = true,
};
#endregion #endregion
#region #region
@@ -226,6 +235,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
} }
} }
} }
catch(NpgsqlException ex)
{
Console.WriteLine("【CheckGet】" + ex.Message);
LoggerSSX.LogError(ex.ToString());
//db_CheckGettimer = new SqlSugarClient(cfg);
}
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("【CheckGet】" + ex.Message); Console.WriteLine("【CheckGet】" + ex.Message);
@@ -950,19 +965,18 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
carryBindInput.carrystd_id = rack.carrystd_id; carryBindInput.carrystd_id = rack.carrystd_id;
carryBindInput.source_code = target.outbill; carryBindInput.source_code = target.outbill;
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result bindResult = await _wmsCarryBindService.CarryBind(carryBindInput); int row = await db_Floor2UpMachinecodetimer.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == ((int)(EnumCarryStatus.)).ToString()).Where(r => r.id == target.rackid).ExecuteCommandAsync();
if (row == 0)
{
throw new Exception($"【上升降机】料架{target.rackcode}状态回写失败");
}
WarehouseMgr.Entities.Dto.Outputs.Result bindResult = await _wmsCarryBindService.CarryBind(carryBindInput, db_Floor2UpMachinecodetimer);
if (bindResult.code != JNPF.Common.Enums.HttpStatusCode.OK) if (bindResult.code != JNPF.Common.Enums.HttpStatusCode.OK)
{ {
throw new Exception(bindResult.msg); throw new Exception(bindResult.msg);
} }
// 开始码垛
bool result_开始码垛 = await Floor2UpDownMachinecode_SetTag(MechanicalArmConsts., target.stackingposition.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】码垛结果 {result_开始码垛}");
if (!result_开始码垛)
{
throw new Exception($@"【上升降机】码垛结果 {result_开始码垛}");
}
// 回写料箱条码、码垛计数 // 回写料箱条码、码垛计数
await db_Floor2UpMachinecodetimer.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH await db_Floor2UpMachinecodetimer.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
{ {
@@ -980,13 +994,21 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】回写转库单的剩余可绑定料架数量"); LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】回写转库单的剩余可绑定料架数量");
// 开始码垛
bool result_开始码垛 = await Floor2UpDownMachinecode_SetTag(MechanicalArmConsts., target.stackingposition.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】码垛结果 {result_开始码垛}");
if (!result_开始码垛)
{
throw new Exception($@"【上升降机】码垛结果 {result_开始码垛}");
}
await db_Floor2UpMachinecodetimer.Ado.CommitTranAsync(); await db_Floor2UpMachinecodetimer.Ado.CommitTranAsync();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
// 测试代码 无问题后期删 // 测试代码 无问题后期删
if (ex.Message.Contains("Connection is busy") || ex.Message.Contains("Exception while reading from stream")) if (ex.Message.Contains("Exception while reading from stream"))
{ {
LoggerFloor2UpDownMachine.LogError("【测试】重置连接"); LoggerFloor2UpDownMachine.LogError("【测试】重置连接");
db_Floor2UpMachinecodetimer.Close(); db_Floor2UpMachinecodetimer.Close();
@@ -1195,6 +1217,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
return; return;
} }
await db_Floor2timer送满托到下升降区.Ado.BeginTranAsync(); await db_Floor2timer送满托到下升降区.Ado.BeginTranAsync();
// 料架区 // 料架区
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs) foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
@@ -1216,7 +1239,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
var item = r.FirstOrDefault(); var item = r.FirstOrDefault();
// 空载具入库: 前面通过OrderBy(d => d.id)对WmsCarryCode_id进行了排序 那么如果第一行有数据则说明存在非空料箱 // 空载具入库: 前面通过OrderBy(d => d.id)对WmsCarryCode_id进行了排序 那么如果第一行有数据则说明存在非空料箱
// 没有物料且没有退料标记的不满足出库条件 // 没有物料且没有退料标记的不满足出库条件
if (!string.IsNullOrEmpty(item.WmsCarryCode_id) && (item.wmsCarryH.need_return == 0 || item.wmsCarryH.need_return == null)) if (!string.IsNullOrEmpty(item.WmsCarryCode_id) && item.wmsCarryH.carry_status != ((int)(EnumCarryStatus.退)).ToString())
{ {
return new BasLocation(); return new BasLocation();
} }
@@ -1277,11 +1300,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 开始生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}"); 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送满托到下升降区); bool result = await createPretask(startLocation.id, wmsMechanicalArmH.location_id, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery, db_Floor2timer送满托到下升降区);
if (!result) if (!result)
{ {
@@ -1482,13 +1500,20 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
BasLocation endLocation = rackEndLocations.First(); BasLocation endLocation = rackEndLocations.First();
int row = await db_Floor2timer移走下升降区未生成预任务且空托的料架.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == "0").Where(r => r.id == wmsMechanicalArmH.rackid).ExecuteCommandAsync();
if (row == 0)
{
throw new Exception($"【移走下升降区空托的料架】料架{wmsMechanicalArmH.rackcode}状态回写失败");
}
// 解除绑定料箱到料架 // 解除绑定料箱到料架
CarryBindInput carryBindInput = new() { }; CarryBindInput carryBindInput = new() { };
carryBindInput.carry_id = wmsMechanicalArmH.rackid; carryBindInput.carry_id = wmsMechanicalArmH.rackid;
carryBindInput.carry_code = wmsMechanicalArmH.rackcode; carryBindInput.carry_code = wmsMechanicalArmH.rackcode;
carryBindInput.source_code = wmsMechanicalArmH.outbill; carryBindInput.source_code = wmsMechanicalArmH.outbill;
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result unbindResult = await _wmsCarryUnbindService.CarryUnbind(carryBindInput); Tnb.WarehouseMgr.Entities.Dto.Outputs.Result unbindResult = await _wmsCarryUnbindService.CarryUnbind(carryBindInput, db_Floor2timer移走下升降区未生成预任务且空托的料架);
if (unbindResult.code != JNPF.Common.Enums.HttpStatusCode.OK) if (unbindResult.code != JNPF.Common.Enums.HttpStatusCode.OK)
{ {
throw new Exception(unbindResult.msg); throw new Exception(unbindResult.msg);
@@ -1668,6 +1693,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
#endregion #endregion
#endregion #endregion
public Task StartAsync(CancellationToken cancellationToken) public Task StartAsync(CancellationToken cancellationToken)
@@ -1694,6 +1720,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@@ -16,7 +16,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
/// <summary> /// <summary>
/// 单据状态 /// 单据状态
/// </summary> /// </summary>
public string? biil_status { get; set; } public string? bill_status { get; set; }
/// <summary> /// <summary>
/// 入库单创建日期 /// 入库单创建日期

View File

@@ -38,6 +38,14 @@
/// 载具 /// 载具
/// </summary> /// </summary>
public List<String> carryIds { get; set; } public List<String> carryIds { get; set; }
/// <summary>
/// 任务执行单号
/// </summary>
public string bill_code { get; set; }
/// <summary>
/// 任务执行区域
/// </summary>
public string area_code { get; set; }

View File

@@ -140,9 +140,4 @@ public partial class WmsCarryH : BaseEntity<string>
/// </summary> /// </summary>
public string? work_station { get; set; } public string? work_station { get; set; }
/// <summary>
/// 需要退料
/// </summary>
public int need_return { get; set; }
} }

View File

@@ -10,5 +10,6 @@
= 3, = 3,
= 4, = 4,
= 5, = 5,
退 = 6,
} }
} }

View File

@@ -133,7 +133,7 @@ namespace Tnb.WarehouseMgr.Interfaces
/// // 二楼机械臂 /// // 二楼机械臂
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task Floor2MechanicalComplete(WmsDistaskH disTask, string action); Task Floor2MechanicalConfirm(WmsDistaskH disTask, string action);
/// <summary> /// <summary>
/// 二楼kiva把料架送到下升降机后生成中储仓入库任务 /// 二楼kiva把料架送到下升降机后生成中储仓入库任务

View File

@@ -1,4 +1,5 @@
using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Dtos.VisualDev;
using SqlSugar;
using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.WarehouseMgr.Entities.Dto.Outputs;
@@ -11,6 +12,6 @@ namespace Tnb.WarehouseMgr.Interfaces
{ {
Task<dynamic> CarryBind(VisualDevModelDataCrInput input); Task<dynamic> CarryBind(VisualDevModelDataCrInput input);
Task<Result> CarryBind(CarryBindInput input); Task<Result> CarryBind(CarryBindInput input, ISqlSugarClient dbConn = null);
} }
} }

View File

@@ -1,4 +1,5 @@
using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Dtos.VisualDev;
using SqlSugar;
using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.WarehouseMgr.Entities.Dto.Outputs;
@@ -9,7 +10,7 @@ namespace Tnb.WarehouseMgr.Interfaces
/// </summary> /// </summary>
public interface IWmsCarryUnbindService public interface IWmsCarryUnbindService
{ {
Task<Result> CarryUnbind(CarryBindInput input); Task<Result> CarryUnbind(CarryBindInput input, ISqlSugarClient dbConn = null);
Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input); Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input);
} }
} }

View File

@@ -106,6 +106,20 @@ namespace Tnb.WarehouseMgr
return await ToApiResult(HttpStatusCode.InternalServerError, "失败"); return await ToApiResult(HttpStatusCode.InternalServerError, "失败");
} }
} }
// 机械臂边取货确认
else if (dis.area_code == "E")
{
if (dis.startlocation_code.Contains("AS") || dis.startlocation_code.Contains("AX"))
{
// 二楼机械臂
await _wareHouseService.Floor2MechanicalConfirm(dis, "LOAD");
return await ToApiResult(HttpStatusCode.OK, "成功");
}
else
{
return await ToApiResult(HttpStatusCode.OK, "成功");
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -255,6 +269,9 @@ namespace Tnb.WarehouseMgr
{ {
Logger.Information("【UnloadConfirm】 接收到WCS放货确认信号.................."); Logger.Information("【UnloadConfirm】 接收到WCS放货确认信号..................");
Logger.Information($"【UnloadConfirm】 当前放货,任务编号:{input.taskCode}"); Logger.Information($"【UnloadConfirm】 当前放货,任务编号:{input.taskCode}");
try
{
var dis = _db.Queryable<WmsDistaskH>().Where(P => P.bill_code == input.taskCode).First(); var dis = _db.Queryable<WmsDistaskH>().Where(P => P.bill_code == input.taskCode).First();
if (dis.area_code == "ZSCJ001") if (dis.area_code == "ZSCJ001")
{ {
@@ -269,6 +286,32 @@ namespace Tnb.WarehouseMgr
return await ToApiResult(HttpStatusCode.InternalServerError, "失败"); return await ToApiResult(HttpStatusCode.InternalServerError, "失败");
} }
} }
// 机械臂边放货确认
else if (dis.area_code == "E")
{
if (dis.endlocation_code.Contains("AS") || dis.endlocation_code.Contains("AX"))
{
// 二楼机械臂
await _wareHouseService.Floor2MechanicalConfirm(dis, "UNLOAD");
return await ToApiResult(HttpStatusCode.OK, "成功");
}
else
{
return await ToApiResult(HttpStatusCode.OK, "成功");
}
}
}
catch (Exception ex)
{
Logger.LogError(ex.Message);
Logger.LogError(ex.StackTrace);
return await ToApiResult(HttpStatusCode.InternalServerError, $"放货确认..................失败 原因是{ex.Message}");
throw;
}
try try
{ {
/*var whereExp = Expressionable.Create<WmsElevatorH, WmsElevatorD, WmsDistaskH>() /*var whereExp = Expressionable.Create<WmsElevatorH, WmsElevatorD, WmsDistaskH>()
@@ -598,8 +641,6 @@ namespace Tnb.WarehouseMgr
else else
{ {
await _wareHouseService.SsxControl(disTask, "LOAD"); await _wareHouseService.SsxControl(disTask, "LOAD");
// 二楼机械臂
await _wareHouseService.Floor2MechanicalComplete(disTask, "LOAD");
} }
} }
else if (input.action == "UNLOAD") else if (input.action == "UNLOAD")
@@ -612,8 +653,6 @@ 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"); await _wareHouseService.SsxControl(disTask, "UNLOAD");
// 二楼机械臂
await _wareHouseService.Floor2MechanicalComplete(disTask, "UNLOAD");
Logger.Information($"【TaskCallback】 Agv放货完成,任务编号:{string.Join(",", disTasks.Select(x => x.bill_code))}"); Logger.Information($"【TaskCallback】 Agv放货完成,任务编号:{string.Join(",", disTasks.Select(x => x.bill_code))}");
} }

View File

@@ -867,7 +867,7 @@ namespace Tnb.WarehouseMgr
/// 二楼机械臂 /// 二楼机械臂
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Floor2MechanicalComplete(WmsDistaskH disTask, string action) public async Task Floor2MechanicalConfirm(WmsDistaskH disTask, string action)
{ {
List<string> rackAreaPointsUp = new List<string>(); List<string> rackAreaPointsUp = new List<string>();
List<string> rackAreaPointsDown = new List<string>(); List<string> rackAreaPointsDown = new List<string>();
@@ -2221,7 +2221,9 @@ namespace Tnb.WarehouseMgr
List<WmsDistaskCode> disTaskCodes = await _db.Queryable<WmsDistaskCode>().Where(it => it.bill_id == dt.id).ToListAsync(); List<WmsDistaskCode> disTaskCodes = await _db.Queryable<WmsDistaskCode>().Where(it => it.bill_id == dt.id).ToListAsync();
WareHouseUpInput upInput = new() { bizTypeId = dt.biz_type, requireId = dt.require_id!, require_code = dt.require_code!, source_id = dt.source_id! WareHouseUpInput upInput = new() { bizTypeId = dt.biz_type, requireId = dt.require_id!, require_code = dt.require_code!, source_id = dt.source_id!
, source_code = dt.source_code!, distaskCodes = disTaskCodes, carryIds = disTasks.Select(x => x.carry_id).ToList() }; , source_code = dt.source_code!, distaskCodes = disTaskCodes, carryIds = disTasks.Select(x => x.carry_id).ToList(),
bill_code = dt.bill_code!,area_code= dt.area_code!
};
/*if (!_userManager?.LoginType.IsNullOrEmpty() ?? false) /*if (!_userManager?.LoginType.IsNullOrEmpty() ?? false)
{ {

View File

@@ -199,10 +199,14 @@ namespace Tnb.WarehouseMgr
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception> /// <exception cref="AppFriendlyException"></exception>
[NonAction] [NonAction]
public async Task<Result> CarryBind(CarryBindInput input) public async Task<Result> CarryBind(CarryBindInput input, ISqlSugarClient dbConn = null)
{ {
bool isOk = false; bool isOk = false;
var db = _db;
if (dbConn != null)
db = dbConn;
try try
{ {
if (input == null) if (input == null)
@@ -210,24 +214,24 @@ namespace Tnb.WarehouseMgr
throw new ArgumentNullException(nameof(input)); throw new ArgumentNullException(nameof(input));
} }
await _db.Ado.BeginTranAsync(); await db.Ado.BeginTranAsync();
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id); WmsCarryH? carry = await db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
WmsCarryH? subCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.membercarry_id); WmsCarryH? subCarry = await db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.membercarry_id);
if (carry != null && subCarry != null) if (carry != null && subCarry != null)
{ {
// 插入子载具绑定记录 // 插入子载具绑定记录
VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() }; //VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id; //visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code; //visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id; //visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code; //visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0; //visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id; //visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
//visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id; ////visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id;
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now; //visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1; //visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1;
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYBIND_ID, true); //VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYBIND_ID, true);
await _runService.Create(templateEntity, visualDevModelCrInput); //await _runService.Create(templateEntity, visualDevModelCrInput);
WmsCarryD wmsCarryD = new() WmsCarryD wmsCarryD = new()
{ {
@@ -237,14 +241,14 @@ namespace Tnb.WarehouseMgr
loc = 1, loc = 1,
create_time = DateTime.Now create_time = DateTime.Now
}; };
int row = await _db.Insertable(wmsCarryD).ExecuteCommandAsync(); int row = await db.Insertable(wmsCarryD).ExecuteCommandAsync();
isOk = row > 0; isOk = row > 0;
if (!isOk) if (!isOk)
{ {
throw Oops.Oh(ErrorCode.COM1001); throw Oops.Oh(ErrorCode.COM1001);
} }
await _db.Ado.CommitTranAsync(); await db.Ado.CommitTranAsync();
Logger.LogError($"【CarryBind】 {input.membercarry_code}成功绑定到{input.carry_code}"); Logger.LogError($"【CarryBind】 {input.membercarry_code}成功绑定到{input.carry_code}");
} }
else else
@@ -259,7 +263,7 @@ namespace Tnb.WarehouseMgr
{ {
Logger.LogError($"【CarryBind】 {ex.Message}"); Logger.LogError($"【CarryBind】 {ex.Message}");
Logger.LogError($"【CarryBind】 {ex.StackTrace}"); Logger.LogError($"【CarryBind】 {ex.StackTrace}");
await _db.Ado.RollbackTranAsync(); await db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message); return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
} }

View File

@@ -129,9 +129,14 @@ namespace Tnb.WarehouseMgr
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception> /// <exception cref="AppFriendlyException"></exception>
[NonAction] [NonAction]
public async Task<Result> CarryUnbind(CarryBindInput input) public async Task<Result> CarryUnbind(CarryBindInput input, ISqlSugarClient dbConn = null)
{ {
bool isOk = false; bool isOk = false;
var db = _db;
if (dbConn != null)
db = dbConn;
try try
{ {
if (input == null) if (input == null)
@@ -139,7 +144,7 @@ namespace Tnb.WarehouseMgr
throw new ArgumentNullException(nameof(input)); throw new ArgumentNullException(nameof(input));
} }
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id); WmsCarryH? carry = await db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
if (carry != null) if (carry != null)
{ {
@@ -160,7 +165,7 @@ namespace Tnb.WarehouseMgr
//await _runService.Create(templateEntity, visualDevModelCrInput); //await _runService.Create(templateEntity, visualDevModelCrInput);
int row = await _db.Deleteable<WmsCarryD>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); int row = await db.Deleteable<WmsCarryD>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
//isOk = row > 0; //isOk = row > 0;
//if (!isOk) //if (!isOk)
@@ -170,7 +175,7 @@ namespace Tnb.WarehouseMgr
Logger.LogInformation($"【CarryUnbind】料架{carry.carry_code}已解绑,解绑条数{row}"); Logger.LogInformation($"【CarryUnbind】料架{carry.carry_code}已解绑,解绑条数{row}");
await _db.Ado.CommitTranAsync(); await db.Ado.CommitTranAsync();
} }
else else
{ {
@@ -184,7 +189,7 @@ namespace Tnb.WarehouseMgr
{ {
Logger.LogError($"【CarryUnbind】 {ex.Message}"); Logger.LogError($"【CarryUnbind】 {ex.Message}");
Logger.LogError($"【CarryUnbind】 {ex.StackTrace}"); Logger.LogError($"【CarryUnbind】 {ex.StackTrace}");
await _db.Ado.RollbackTranAsync(); await db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message); return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
} }

View File

@@ -196,10 +196,10 @@ namespace Tnb.WarehouseMgr
//更新页面 //更新页面
//赋值签收状态 //赋值签收状态
Logger.Information($"空载具出库生成的预任务数量:{preTasks.Count}"); Logger.Information($"空载具出库生成的预任务数量:{preTasks.Count}");
if (loc.is_sign == 0) //if (loc.is_sign == 0)
{ //{
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 // preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
} //}
isOk = await _wareHouseService.GenPreTask(preTasks, null!); isOk = await _wareHouseService.GenPreTask(preTasks, null!);
if (isOk) if (isOk)

View File

@@ -594,6 +594,7 @@ namespace Tnb.WarehouseMgr
return; return;
} }
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
// 更新已转数量 // 更新已转数量
bool isOk = await _db.Updateable<WmsMaterialTransferD>().SetColumns(it => new WmsMaterialTransferD { yzqty = it.yzqty + wmsCarryCodes.Sum(r => r.codeqty) }) bool isOk = await _db.Updateable<WmsMaterialTransferD>().SetColumns(it => new WmsMaterialTransferD { yzqty = it.yzqty + wmsCarryCodes.Sum(r => r.codeqty) })
.Where(it => it.id == input.source_id).ExecuteCommandHasChangeAsync(); .Where(it => it.id == input.source_id).ExecuteCommandHasChangeAsync();
@@ -616,13 +617,16 @@ namespace Tnb.WarehouseMgr
{ {
throw Oops.Oh(ErrorCode.COM1001); throw Oops.Oh(ErrorCode.COM1001);
} }
if (input.area_code == "E")
await sign(input); await sign(input);
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }
catch(Exception ex) catch(Exception ex)
{ {
Logger.LogError("【WmsPrdReturnService ModifyAsync】" + ex.Message); Logger.LogError("【WmsMaterialTransferService ModifyAsync】" + ex.Message);
Logger.LogError("【WmsPrdReturnService ModifyAsync】" + ex.StackTrace); Logger.LogError("【WmsMaterialTransferService ModifyAsync】" + ex.StackTrace);
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
} }
} }
@@ -709,7 +713,7 @@ namespace Tnb.WarehouseMgr
Logger.LogInformation($"【DistributeToZCC】更新转库单{wmsMaterialTransfer.bill_code}主表的数据"); Logger.LogInformation($"【DistributeToZCC】更新转库单{wmsMaterialTransfer.bill_code}主表的数据");
await _db.Insertable(wmsMaterialTransferCarrys).ExecuteCommandAsync(); await _db.Insertable(wmsMaterialTransferCarrys).ExecuteCommandAsync();
Logger.LogInformation($"【DistributeToZCC插入转库单{wmsMaterialTransfer.bill_code}载具表的数据"); Logger.LogInformation($"【DistributeToZCC插入转库单{wmsMaterialTransfer.bill_code}载具表的数据");
foreach (WmsMaterialTransferCarry wmsMaterialTransferCarry in wmsMaterialTransferCarrys) foreach (WmsMaterialTransferCarry wmsMaterialTransferCarry in wmsMaterialTransferCarrys)
{ {
@@ -831,7 +835,7 @@ namespace Tnb.WarehouseMgr
//BasLocation endlocation = _db.Queryable<BasLocation>().Where(r => r.location_code == wmsCarryH.work_station).First(); //BasLocation endlocation = _db.Queryable<BasLocation>().Where(r => r.location_code == wmsCarryH.work_station).First();
WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID).First(); WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
if (wmsPretaskH != null) if (wmsPretaskH != null)
{ {
Logger.LogWarning($"【CallRackToProductionLine】此料架{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}"); Logger.LogWarning($"【CallRackToProductionLine】此料架{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}");
@@ -878,7 +882,8 @@ namespace Tnb.WarehouseMgr
{ {
try try
{ {
List<WmsCarryH> wmsCarryHs = _db.Queryable<WmsCarryH>().Where(r => r.work_station == input.work_station).ToList(); List<WmsCarryH> wmsCarryHs = _db.Queryable<WmsCarryH>().Where(r => r.work_station == input.work_station && r.is_lock == 0
&& (r.carry_status == ((int)(EnumCarryStatus.)).ToString() || r.carry_status == ((int)(EnumCarryStatus.)).ToString())).ToList();
if (string.IsNullOrEmpty(input.work_station)) if (string.IsNullOrEmpty(input.work_station))
{ {
Logger.LogWarning($"【RackAndMatByWorkstation】工位不能为空"); Logger.LogWarning($"【RackAndMatByWorkstation】工位不能为空");
@@ -1038,7 +1043,7 @@ namespace Tnb.WarehouseMgr
_carryBindInput.membercarry_id = membercarry.id; _carryBindInput.membercarry_id = membercarry.id;
_carryBindInput.membercarry_code = membercarry.carry_code; _carryBindInput.membercarry_code = membercarry.carry_code;
_carryBindInput.carrystd_id = wmsCarryH.carrystd_id; _carryBindInput.carrystd_id = wmsCarryH.carrystd_id;
var resCarrybind = await _wmsCarryBindService.CarryBind(_carryBindInput); var resCarrybind = await _wmsCarryBindService.CarryBind(_carryBindInput, _db);
if (resCarrybind.code != JNPF.Common.Enums.HttpStatusCode.OK) if (resCarrybind.code != JNPF.Common.Enums.HttpStatusCode.OK)
{ {
throw new AppFriendlyException($"绑定料箱到料架失败 载具 {input.carry_code}", 500); throw new AppFriendlyException($"绑定料箱到料架失败 载具 {input.carry_code}", 500);

View File

@@ -25,9 +25,6 @@ using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr namespace Tnb.WarehouseMgr
{ {
/// <summary>
/// 载具解绑
/// </summary>
[OverideVisualDev(ModuleConsts.MODULE_WMSPRDRETURN_ID)] [OverideVisualDev(ModuleConsts.MODULE_WMSPRDRETURN_ID)]
[ServiceModule(BizTypeId)] [ServiceModule(BizTypeId)]
public class WmsPrdReturnService : BaseWareHouseService, IWmsPrdReturnService public class WmsPrdReturnService : BaseWareHouseService, IWmsPrdReturnService
@@ -169,19 +166,24 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($"【PrdReturn】存在装有与生产退料单明细不匹配物料的料箱请检查{msg.Trim(',')}", 500); throw new AppFriendlyException($"【PrdReturn】存在装有与生产退料单明细不匹配物料的料箱请检查{msg.Trim(',')}", 500);
} }
WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID).First(); WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
if (wmsPretaskH != null) if (wmsPretaskH != null)
{ {
Logger.LogWarning($"【CallRackToProductionLine】此料架{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}"); Logger.LogWarning($"【PrdReturn】此料架{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}");
throw new AppFriendlyException($"此料架{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}", 500); throw new AppFriendlyException($"此料架{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}", 500);
} }
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
// 标记为退料 // 标记为退料
await _db.Updateable<WmsCarryH>().SetColumns(r => r.need_return == 1).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync(); int row2= await _db.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == ((int)(EnumCarryStatus.退)).ToString()).Where(r => r.carry_code == wmsCarryH.carry_code).ExecuteCommandAsync();
if (row2 == 0)
{
throw new AppFriendlyException($"【PrdReturn】 料架 {wmsCarryH.carry_code} 退料状态回写失败", 500);
}
Logger.LogInformation($"【PrdReturn】料架 {wmsCarryH.carry_code} 退料状态回写成功!");
Logger.LogWarning($"【RackEmptyInstock】绑定料箱到料架"); Logger.LogInformation($"【PrdReturn】绑定料箱到料架");
List<WmsCarryH> membercarrys = _db.Queryable<WmsCarryH>().Where(r => input.details.Select(r => r.carry_code).Contains(r.carry_code)).ToList(); 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) foreach (WmsCarryH membercarry in membercarrys)
@@ -193,7 +195,7 @@ namespace Tnb.WarehouseMgr
_carryBindInput.membercarry_id = membercarry.id; _carryBindInput.membercarry_id = membercarry.id;
_carryBindInput.membercarry_code = membercarry.carry_code; _carryBindInput.membercarry_code = membercarry.carry_code;
_carryBindInput.carrystd_id = wmsCarryH.carrystd_id; _carryBindInput.carrystd_id = wmsCarryH.carrystd_id;
var resCarrybind = await _wmsCarryBindService.CarryBind(_carryBindInput); var resCarrybind = await _wmsCarryBindService.CarryBind(_carryBindInput, _db);
if (resCarrybind.code != JNPF.Common.Enums.HttpStatusCode.OK) if (resCarrybind.code != JNPF.Common.Enums.HttpStatusCode.OK)
{ {
throw new AppFriendlyException($"绑定料箱到料架失败 载具 {input.carry_code}", 500); throw new AppFriendlyException($"绑定料箱到料架失败 载具 {input.carry_code}", 500);
@@ -292,18 +294,23 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($"【PrdReturn】存在装有与生产退料单明细不匹配物料的料架/载运小车,请检查!{msg.Trim(',')}", 500); throw new AppFriendlyException($"【PrdReturn】存在装有与生产退料单明细不匹配物料的料架/载运小车,请检查!{msg.Trim(',')}", 500);
} }
WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID).First(); WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
if (wmsPretaskH != null) if (wmsPretaskH != null)
{ {
Logger.LogWarning($"【CallRackToProductionLine】此料架/载运小车{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}"); Logger.LogWarning($"【PrdReturn】此料架/载运小车{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}");
throw new AppFriendlyException($"此料架/载运小车{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}", 500); throw new AppFriendlyException($"此料架/载运小车{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}", 500);
} }
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
// 标记为退料 // 标记为退料
await _db.Updateable<WmsCarryH>().SetColumns(r => r.need_return == 1).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync(); int row2 =await _db.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == ((int)(EnumCarryStatus.退)).ToString()).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync();
if (row2 == 0)
{
throw new AppFriendlyException($"【PrdReturn】 料架 {wmsCarryH.carry_code} 退料状态回写失败", 500);
}
Logger.LogInformation($"【PrdReturn】料架 {wmsCarryH.carry_code} 退料状态回写成功!");
Logger.LogWarning($"【PrdReturn】开始生成预任务"); Logger.LogInformation($"【PrdReturn】开始生成预任务");
CommonCreatePretaskInput commonCreatePretaskInput = new(); CommonCreatePretaskInput commonCreatePretaskInput = new();
commonCreatePretaskInput.startlocation_id = startlocation.id; commonCreatePretaskInput.startlocation_id = startlocation.id;
commonCreatePretaskInput.endlocation_id = endlocation.id; commonCreatePretaskInput.endlocation_id = endlocation.id;

View File

@@ -67,7 +67,6 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
_fileManager = fileManager; _fileManager = fileManager;
} }
public SemaphoreSlim s_getBillNumber = new(1);
#region Get #region Get
@@ -278,8 +277,6 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
{ {
try try
{ {
s_getBillNumber.WaitAsync();
string cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYBILLRULE, _userManager.TenantId, _userManager.UserId + enCode); string cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYBILLRULE, _userManager.TenantId, _userManager.UserId + enCode);
string strNumber = string.Empty; string strNumber = string.Empty;
if (isCache) if (isCache)
@@ -308,10 +305,6 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
Logging.Log.Error("【GetBillNumber】" + ex.StackTrace); Logging.Log.Error("【GetBillNumber】" + ex.StackTrace);
throw; throw;
} }
finally
{
s_getBillNumber.Release();
}
} }
#endregion #endregion
@@ -325,8 +318,10 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
/// <returns></returns> /// <returns></returns>
private async Task<string> GetNumber(string enCode) private async Task<string> GetNumber(string enCode)
{ {
ISqlSugarClient db = _repository.CopyNew();
StringBuilder strNumber = new StringBuilder(); StringBuilder strNumber = new StringBuilder();
var entity = await _repository.GetFirstAsync(m => m.EnCode == enCode && m.DeleteMark == null); var entity = db.Queryable<BillRuleEntity>().Where(m => m.EnCode == enCode && m.DeleteMark == null).ToList()[0];
//var entity = await _repository.GetFirstAsync(m => m.EnCode == enCode && m.DeleteMark == null);
if (entity != null) if (entity != null)
{ {
// 处理隔天流水号归0 // 处理隔天流水号归0
@@ -359,7 +354,7 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
entity.OutputNumber = strNumber.ToString(); entity.OutputNumber = strNumber.ToString();
var str = strNumber.ToString(); var str = strNumber.ToString();
// 更新流水号 // 更新流水号
await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync(); await db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
} }
else else
{ {