This commit is contained in:
alex
2023-07-11 16:14:56 +08:00
parent 0b99644eea
commit 3a27e4cc15
3 changed files with 164 additions and 167 deletions

View File

@@ -171,7 +171,7 @@ namespace Tnb.WarehouseMgr
[HttpPost] [HttpPost]
public async Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input) public async Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input)
{ {
if(input.IsNull())throw new ArgumentNullException("input"); if (input.IsNull()) throw new ArgumentNullException("input");
try try
{ {
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code); var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
@@ -186,16 +186,16 @@ namespace Tnb.WarehouseMgr
var cols = new List<string>(); var cols = new List<string>();
var dic = new Dictionary<string, object>(); var dic = new Dictionary<string, object>();
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId(); dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyInstock.org_id)] = input.org_id; dic[nameof(WmsEmptyInstock.org_id)] = input.org_id ?? _userManager.User.OrganizeId;
dic[nameof(WmsEmptyInstock.location_id)] = location.id; dic[nameof(WmsEmptyInstock.location_id)] = location.id;
dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE); dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE);
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID; dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id; dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
dic[nameof(WmsEmptyInstock.carry_code)] = input.carry_code; dic[nameof(WmsEmptyInstock.carry_code)] = input.carry_code!;
dic[nameof(WmsEmptyInstock.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID; dic[nameof(WmsEmptyInstock.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
dic[nameof(WmsEmptyInstock.create_id)] = input.create_id; dic[nameof(WmsEmptyInstock.create_id)] = input.create_id ?? _userManager.UserId;
dic[nameof(WmsEmptyInstock.create_time)] = DateTime.Now; dic[nameof(WmsEmptyInstock.create_time)] = DateTime.Now;
dic[nameof(WmsEmptyInstock.warehouse_id)] = input.warehouse_id; dic[nameof(WmsEmptyInstock.warehouse_id)] = input.warehouse_id!;
VisualDevModelDataCrInput visualDevModelDataCrInput = new() VisualDevModelDataCrInput visualDevModelDataCrInput = new()
{ {

View File

@@ -293,11 +293,11 @@ namespace Tnb.WarehouseMgr
{ {
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
//出库申请主表 //出库申请主表
WmsOutstockH outstock = input.outstock!; WmsOutstockH? outstock = input.outstock;
//出库申请明细表 //出库申请明细表
List<WmsOutstockD> outstockDs = input.outstockDs!; List<WmsOutstockD>? outstockDs = input.outstockDs;
//如果数据不全, //如果数据不全,
if (outstock.IsNull() || outstock.location_id.IsNullOrWhiteSpace() || outstockDs?.Count < 1) if ((outstock?.location_id.IsNullOrWhiteSpace() ?? true) || outstockDs?.Count < 1)
{ {
//报错, 提示数据不全。 //报错, 提示数据不全。
throw new AppFriendlyException("数据不全!", 500); throw new AppFriendlyException("数据不全!", 500);
@@ -498,9 +498,7 @@ namespace Tnb.WarehouseMgr
public override async Task ModifyAsync(WareHouseUpInput input) public override async Task ModifyAsync(WareHouseUpInput input)
{ {
if (input == null) throw new ArgumentNullException("input"); if (input == null) throw new ArgumentNullException(nameof(input));
try try
{ {

View File

@@ -113,13 +113,12 @@ namespace Tnb.WarehouseMgr
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x => .Select(x =>
{ {
WmsCarryMat? carryMat = x.FirstOrDefault()!; WmsCarryMat? carryMat = x.FirstOrDefault();
carryMat.need_qty = x.Sum(d => d.need_qty); carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat; return carryMat;
}) })
.ToList(); .ToList();
await _db.Insertable(carryMats).ExecuteCommandAsync(); await _db.Insertable(carryMats).ExecuteCommandAsync();
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList(); carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString(), collocation_scheme_id = singleSorting.collocation_scheme_id, collocation_scheme_code = singleSorting.collocation_scheme_code }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString(), collocation_scheme_id = singleSorting.collocation_scheme_id, collocation_scheme_code = singleSorting.collocation_scheme_code }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();
@@ -280,7 +279,7 @@ namespace Tnb.WarehouseMgr
} }
} }
await _db.Updateable(curSortingDetails).ExecuteCommandAsync(); await _db.Updateable(curSortingDetails).ExecuteCommandAsync();
if(curSortingDetails.All(it=>it.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) if (curSortingDetails.All(it => it.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
{ {
await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();