消除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

@@ -156,36 +156,36 @@ namespace Tnb.WarehouseMgr
List<WmsPretaskH> preTasks = new(); List<WmsPretaskH> preTasks = new();
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id); var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
if (points?.Count > 0) if (points?.Count > 0)
{ {
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{ {
var sPoint = it.FirstOrDefault(); var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault(); var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new(); WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId; preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!; preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!; preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!; preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!; preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString(); preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString(); preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGOUTSTK_ID; preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGOUTSTK_ID;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
preTask.carry_id = carry.id!; preTask.carry_id = carry.id!;
preTask.carry_code = carry.carry_code!; preTask.carry_code = carry.carry_code!;
preTask.area_id = sPoint?.area_id!; preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key; preTask.area_code = it.Key;
preTask.require_id = KittingOutObj.requireId; preTask.require_id = KittingOutObj.requireId;
preTask.require_code = KittingOutObj.requireCode; preTask.require_code = KittingOutObj.requireCode;
preTask.create_id = _userManager.UserId; preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now; preTask.create_time = DateTime.Now;
return preTask; return preTask;
}).ToList(); }).ToList();
} }
return preTasks; return preTasks;
} }

View File

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