消除warning

This commit is contained in:
alex
2023-07-14 15:59:14 +08:00
parent 4bada98d09
commit 6c351f0906
2 changed files with 48 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,6 +11,7 @@ using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Interfaces.System;
using Mapster;
using Microsoft.AspNetCore.Http;
@@ -53,7 +55,7 @@ namespace Tnb.WarehouseMgr
/// <returns></returns>
[HttpPost]
public async Task KittingOutByAdd()
{
{
try
{
await _db.Ado.BeginTranAsync();
@@ -129,7 +131,7 @@ namespace Tnb.WarehouseMgr
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task KittingOutByIsToBeShipped()
public async Task KittingOutByIsToBeShipped(IDbTransaction? tran = null)
{
try
@@ -308,13 +310,20 @@ namespace Tnb.WarehouseMgr
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
using (var conn = _db.Ado.Connection)
{
using (var tran = conn.BeginTransaction())
{
_db.Ado.Transaction = tran;
}
}
await _db.Ado.BeginTranAsync();
List<WmsKittingoutD> kittingOutDs = new();
var kittingOuts = input.Adapt<List<WmsKittingoutH>>();
for (int i = 0; i < kittingOuts.Count; i++)
{
var x= kittingOuts[i];
var x = kittingOuts[i];
x.id = SnowflakeIdHelper.NextId();
x.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_KITTINGOUTSTK_ENCODE).GetAwaiter().GetResult();
x.bill_date = DateTime.Now;
@@ -322,7 +331,7 @@ namespace Tnb.WarehouseMgr
x.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;
x.biz_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGOUTSTK_ID;
var d = input[i]?.wmsKittingoutDs?.Adapt<List<WmsKittingoutD>>();
d?.ForEach(it =>
d?.ForEach(it =>
{
it.id = SnowflakeIdHelper.NextId();
it.bill_id = x.id;
@@ -330,21 +339,26 @@ namespace Tnb.WarehouseMgr
it.real_box = 0;
it.warehouse_id = x.warehouse_id;
});
kittingOutDs.AddRange(d!);
if (d != null)
{
kittingOutDs.AddRange(d);
}
}
await _db.Insertable(kittingOuts).ExecuteCommandAsync();
await _db.Insertable(kittingOutDs).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
await KittingOutByAdd();
isSuccessFul = true;
}
catch (Exception ex)
{
Log.Error("MES齐套出库接口出错", ex);
isSuccessFul = false;
await _db.Ado.RollbackTranAsync();
}
return isSuccessFul;
}