This commit is contained in:
2024-10-11 11:05:36 +08:00
2 changed files with 42 additions and 27 deletions

View File

@@ -43,6 +43,7 @@ namespace Tnb.ProductionMgr
{ {
private const string BizTypeId = "FloorCallMaterial"; private const string BizTypeId = "FloorCallMaterial";
private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository; private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository;
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IOrganizeService _organizeService; private readonly IOrganizeService _organizeService;
private readonly IBillRullService _billRullService; private readonly IBillRullService _billRullService;
@@ -63,6 +64,7 @@ namespace Tnb.ProductionMgr
) )
{ {
_repository = repository; _repository = repository;
_db = _repository.AsSugarClient();
_userManager = userManager; _userManager = userManager;
_organizeService = organizeService; _organizeService = organizeService;
_billRullService = billRullService; _billRullService = billRullService;
@@ -598,8 +600,8 @@ namespace Tnb.ProductionMgr
throw Oops.Bah("来源id为空"); throw Oops.Bah("来源id为空");
} }
var db = _repository.CopyNew(); // var db = _repository.AsSugarClient();
PrdMoTask moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.requireId); PrdMoTask moTask = await _db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.requireId);
if (moTask == null) if (moTask == null)
{ {
throw Oops.Bah($"未找到来源id为{input.requireId}的生产任务单"); throw Oops.Bah($"未找到来源id为{input.requireId}的生产任务单");
@@ -611,6 +613,8 @@ namespace Tnb.ProductionMgr
List<PrdFeedingH> insertFHList = new List<PrdFeedingH>(); List<PrdFeedingH> insertFHList = new List<PrdFeedingH>();
List<PrdFeedingD> insertFDList = new List<PrdFeedingD>(); List<PrdFeedingD> insertFDList = new List<PrdFeedingD>();
List<string> clearCarryIds = new List<string>(); List<string> clearCarryIds = new List<string>();
List<string> deleteCarryCodeIds = new List<string>();
List<string> deleteCarryDIds = new List<string>();
string orgId = WmsWareHouseConst.AdministratorOrgId; string orgId = WmsWareHouseConst.AdministratorOrgId;
// string userId = moTask.worker_id; // string userId = moTask.worker_id;
string userId = WmsWareHouseConst.AdministratorUserId; string userId = WmsWareHouseConst.AdministratorUserId;
@@ -621,7 +625,7 @@ namespace Tnb.ProductionMgr
foreach(string carryId in input.carryIds) foreach(string carryId in input.carryIds)
{ {
clearCarryIds.Add(carryId); clearCarryIds.Add(carryId);
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.id == carryId); WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(x => x.id == carryId);
string code = await _billRullService.GetBillNumber(CodeTemplateConst.MATERIAL_RECEIPT_CODE); string code = await _billRullService.GetBillNumber(CodeTemplateConst.MATERIAL_RECEIPT_CODE);
PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH() PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
{ {
@@ -667,19 +671,19 @@ namespace Tnb.ProductionMgr
if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID ||
carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID) carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID)
{ {
carryCodes = await db.Queryable<WmsCarryCode>().Where(x=>x.carry_id==carry.id).ToListAsync(); carryCodes = await _db.Queryable<WmsCarryCode>().Where(x=>x.carry_id==carry.id).ToListAsync();
} }
else else
{ {
//CarryQueryOutput carryQueryOutput = await _wmsCarryQueryService.MESCarryQueryResult(new MESCarryQueryResultInput(){carry_code = carry.carry_code}); //CarryQueryOutput carryQueryOutput = await _wmsCarryQueryService.MESCarryQueryResult(new MESCarryQueryResultInput(){carry_code = carry.carry_code});
memberCarryIds = await db.Queryable<WmsCarryD>().Where(x=>x.carry_id==carry.id).Select(x=>x.membercarry_id).ToListAsync(); memberCarryIds = await _db.Queryable<WmsCarryD>().Where(x=>x.carry_id==carry.id).Select(x=>x.membercarry_id).ToListAsync();
if (memberCarryIds == null || memberCarryIds.IsEmpty()) if (memberCarryIds == null || memberCarryIds.IsEmpty())
{ {
throw Oops.Bah($"未找到载具编号{carry.carry_code}的子载具"); throw Oops.Bah($"未找到载具编号{carry.carry_code}的子载具");
} }
memberCarrys = await db.Queryable<WmsCarryH>().Where(x=>memberCarryIds.Contains(x.id)).ToListAsync(); memberCarrys = await _db.Queryable<WmsCarryH>().Where(x=>memberCarryIds.Contains(x.id)).ToListAsync();
carryCodes = await db.Queryable<WmsCarryCode>().Where(x=>memberCarryIds.Contains(x.carry_id)).ToListAsync(); carryCodes = await _db.Queryable<WmsCarryCode>().Where(x=>memberCarryIds.Contains(x.carry_id)).ToListAsync();
clearCarryIds.AddRange(memberCarryIds); clearCarryIds.AddRange(memberCarryIds);
} }
@@ -748,9 +752,9 @@ namespace Tnb.ProductionMgr
// { // {
// throw Oops.Bah(result.msg); // throw Oops.Bah(result.msg);
// } // }
deleteCarryCodeIds.Add(detail.member_carry_id);
int row = await db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == detail.member_carry_id).ExecuteCommandAsync(); // int row = await db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == detail.member_carry_id).ExecuteCommandAsync();
Log.Information($"载具{detail.member_carry_id}已解绑,解绑条数{row}"); // Log.Information($"载具{detail.member_carry_id}已解绑,解绑条数{row}");
} }
} }
@@ -768,8 +772,9 @@ namespace Tnb.ProductionMgr
// throw Oops.Bah(result.msg); // throw Oops.Bah(result.msg);
// } // }
int row = await db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == carry.id).ExecuteCommandAsync(); deleteCarryCodeIds.Add(carry.id);
Log.Information($"载具{carry.id}已解绑,解绑条数{row}"); // int row = await db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == carry.id).ExecuteCommandAsync();
// Log.Information($"载具{carry.id}已解绑,解绑条数{row}");
} }
} }
else else
@@ -796,22 +801,24 @@ namespace Tnb.ProductionMgr
// throw Oops.Bah(result2.msg); // throw Oops.Bah(result2.msg);
// } // }
int row = await db.Deleteable<WmsCarryD>().Where(r => r.carry_id == prdMaterialReceiptH.carry_id).ExecuteCommandAsync(); deleteCarryDIds.Add(prdMaterialReceiptH.carry_id);
Log.Information($"载具{prdMaterialReceiptH.carry_id}已解绑,解绑条数{row}"); // int row = await db.Deleteable<WmsCarryD>().Where(r => r.carry_id == prdMaterialReceiptH.carry_id).ExecuteCommandAsync();
// Log.Information($"载具{prdMaterialReceiptH.carry_id}已解绑,解绑条数{row}");
} }
} }
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
work_station = ""
}).Where(r => input.carryIds.Contains(r.id)).ExecuteCommandAsync();
Log.Information($"清空载具信息:{JsonConvert.SerializeObject(clearCarryIds)}"); Log.Information($"清空载具信息:{JsonConvert.SerializeObject(clearCarryIds)}");
string carryStatus = ((int)EnumCarryStatus.).ToString(); string carryStatus = ((int)EnumCarryStatus.).ToString();
string isCheck = ((int)EnumCheckConclusion.).ToString(); string isCheck = ((int)EnumCheckConclusion.).ToString();
foreach(string carryId in clearCarryIds) foreach(string carryId in clearCarryIds)
{ {
string sql = $"update wms_carry_h set carry_status='0',is_check='8' where id='{carryId}';"; await _db.Updateable<WmsCarryH>()
Log.Information($"自动签收更新载具sql:{sql}");
await db.Ado.ExecuteCommandAsync(sql);
Log.Information($"用SQL更新载具{carryId}状态为空闲{carryStatus},检验为{isCheck}成功");
await db.Updateable<WmsCarryH>()
.SetColumns(x => x.carry_status == carryStatus) .SetColumns(x => x.carry_status == carryStatus)
.SetColumns(x => x.is_check == isCheck) .SetColumns(x => x.is_check == isCheck)
.Where(x => x.id==carryId) .Where(x => x.id==carryId)
@@ -823,11 +830,18 @@ namespace Tnb.ProductionMgr
{ {
throw Oops.Bah(ErrorCode.COM1000); throw Oops.Bah(ErrorCode.COM1000);
} }
int dRow1 = await _db.Deleteable<WmsCarryD>().Where(r => deleteCarryDIds.Contains(r.carry_id)).ExecuteCommandAsync();
Log.Information($"子载具{JsonConvert.SerializeObject(deleteCarryDIds)}已解绑,解绑条数{dRow1}");
int dRow2 = await _db.Deleteable<WmsCarryCode>().Where(r => deleteCarryCodeIds.Contains(r.carry_id)).ExecuteCommandAsync();
Log.Information($"载具条码{JsonConvert.SerializeObject(deleteCarryDIds)}已解绑,解绑条数{dRow2}");
int row1 = await db.Insertable(insertHList).ExecuteCommandAsync(); int row1 = await _db.Insertable(insertHList).ExecuteCommandAsync();
int row2 = await db.Insertable(insertDList).ExecuteCommandAsync(); int row2 = await _db.Insertable(insertDList).ExecuteCommandAsync();
int row3 = await db.Insertable(insertFHList).ExecuteCommandAsync(); int row3 = await _db.Insertable(insertFHList).ExecuteCommandAsync();
int row4 = await db.Insertable(insertFDList).ExecuteCommandAsync(); int row4 = await _db.Insertable(insertFDList).ExecuteCommandAsync();
if (row1 <= 0 || row2 <= 0 || row3<=0 || row4<=0) if (row1 <= 0 || row2 <= 0 || row3<=0 || row4<=0)

View File

@@ -3172,10 +3172,11 @@ namespace Tnb.WarehouseMgr
// 二楼物料呼叫任务结束后清空工位信息 // 二楼物料呼叫任务结束后清空工位信息
else if (dt.biz_type == "FloorCallMaterial") else if (dt.biz_type == "FloorCallMaterial")
{ {
await db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH //放到ModifyAsync
{ // await db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
work_station = "" // {
}).Where(r => r.id == dt.carry_id).ExecuteCommandAsync(); // work_station = ""
// }).Where(r => r.id == dt.carry_id).ExecuteCommandAsync();
//await QTRK2BIP(dt, db); //await QTRK2BIP(dt, db);
// require_code是任务单 // require_code是任务单