diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 089c411a..e58eb8e1 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -406,12 +406,7 @@ namespace Tnb.ProductionMgr List insertHList = new List(); List insertDList = new List(); string orgId = WmsWareHouseConst.AdministratorOrgId; - string userId = WmsWareHouseConst.AdministratorUserId; - if (_userManager != null && _userManager.GetUserInfo() != null && _userManager.GetUserInfo().Result!=null) - { - orgId = _userManager.GetUserInfo().Result.organizeId; - userId = _userManager.UserId; - } + string userId = moTask.worker_id; foreach(string carryId in input.carryIds) { WmsCarryH carry = await db.Queryable().SingleAsync(x => x.id == carryId); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs index f92985fd..8d264fb1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs @@ -74,55 +74,47 @@ namespace Tnb.WarehouseMgr } CarryQueryOutput data = new(); - try + WmsCarryH carry = await _db.Queryable().FirstAsync(a => a.carry_code == input.carry_code && a.status == 1); + if (carry.IsNull()) { - WmsCarryH carry = await _db.Queryable().FirstAsync(a => a.carry_code == input.carry_code && a.status == 1); - if (carry.IsNull()) + throw new AppFriendlyException($"编号{input.carry_code},对应载具不存在或被禁用", 500); + } + + Dictionary mCarryIdDic = await _db.Queryable().Where(it => it.carry_id == carry.id).ToDictionaryAsync(x => x.membercarry_id, x => x.membercarry_code); + Expression> whereExp = carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && mCarryIdDic.Keys?.Count > 0 + ? a => mCarryIdDic.Keys.Contains(a.carry_id) + : a => a.carry_id == carry.id; + + List carryCodes = await _db.Queryable().InnerJoin((a, b) => a.carry_id == b.id).LeftJoin((a, b, c) => a.carry_id == c.carry_id) + .Where(whereExp) + .Select((a, b, c) => new WmsCarryCode + { + check_conclusion = SqlFunc.IsNull(b.check_conclusion, 1), + instock_time = b.create_time, + }, true) + .ToListAsync(); + + if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && mCarryIdDic?.Count > 0) + { + if (carryCodes.Count < mCarryIdDic.Keys?.Count) { - throw new AppFriendlyException($"编号{input.carry_code},对应载具不存在或被禁用", 500); + throw new AppFriendlyException("载具条码数据异常,有料箱为空", 500); } - Dictionary mCarryIdDic = await _db.Queryable().Where(it => it.carry_id == carry.id).ToDictionaryAsync(x => x.membercarry_id, x => x.membercarry_code); - Expression> whereExp = carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && mCarryIdDic.Keys?.Count > 0 - ? a => mCarryIdDic.Keys.Contains(a.carry_id) - : a => a.carry_id == carry.id; - - List carryCodes = await _db.Queryable().InnerJoin((a, b) => a.carry_id == b.id).LeftJoin((a, b, c) => a.carry_id == c.carry_id) - .Where(whereExp) - .Select((a, b, c) => new WmsCarryCode - { - check_conclusion = SqlFunc.IsNull(b.check_conclusion, 1), - instock_time = b.create_time, - }, true) - .ToListAsync(); - - if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && mCarryIdDic?.Count > 0) + int i = 0; + foreach ((string mCarryId, object v) in mCarryIdDic) { - if (carryCodes.Count < mCarryIdDic.Keys?.Count) + carryCodes[i].member_carrycode = v?.ToString() ?? string.Empty; + var carryCode = carryCodes.Find(x => x.carry_id == mCarryId); + if (carryCode != null) { - throw new AppFriendlyException("载具条码数据异常,有料箱为空", 500); - } - - int i = 0; - foreach ((string mCarryId, object v) in mCarryIdDic) - { - carryCodes[i].member_carrycode = v?.ToString() ?? string.Empty; - var carryCode = carryCodes.Find(x => x.carry_id == mCarryId); - if (carryCode != null) - { - carryCodes[i].material_name = s_materialMap.ContainsKey(carryCode.material_id) ? s_materialMap[carryCode.material_id]?.ToString() ?? "" : ""; - } - i++; + carryCodes[i].material_name = s_materialMap.ContainsKey(carryCode.material_id) ? s_materialMap[carryCode.material_id]?.ToString() ?? "" : ""; } + i++; } - data = carry.Adapt(); - data.wmsCarryCodes = carryCodes.Adapt>(); - } - catch (Exception) - { - await _db.Ado.RollbackTranAsync(); - throw; } + data = carry.Adapt(); + data.wmsCarryCodes = carryCodes.Adapt>(); return data; } }