执行代码清理,修复warning
This commit is contained in:
@@ -36,7 +36,6 @@ namespace Tnb.WarehouseMgr
|
||||
/// <summary>
|
||||
/// 载具导入
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
||||
{
|
||||
@@ -44,28 +43,35 @@ namespace Tnb.WarehouseMgr
|
||||
try
|
||||
{
|
||||
List<Dictionary<string, object>> dics = input.list;
|
||||
List<WmsCarryH> carrys = new List<WmsCarryH>();
|
||||
List<WmsCarryH> carrys = new();
|
||||
Dictionary<string, object>? locs = null;
|
||||
List<string> locCodes = new();
|
||||
List<string> cStdCodes = new();
|
||||
WmsCarryH carryH = new WmsCarryH();
|
||||
WmsCarryH carryH = new();
|
||||
//遍历字典,找出需要查询数据库拿的相关字段
|
||||
foreach (var d in dics)
|
||||
foreach (Dictionary<string, object> d in dics)
|
||||
{
|
||||
var cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
|
||||
string cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
|
||||
locCodes.Add(d["location_code"].ToString() ?? string.Empty);
|
||||
cStdCodes.Add(cStdCode);
|
||||
d["create_time"] = DateTime.Now;
|
||||
d.Remove("modify_time");
|
||||
_ = d.Remove("modify_time");
|
||||
carryH = d.Adapt<WmsCarryH>();
|
||||
carrys.Add(carryH);
|
||||
}
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
Dictionary<string, object> carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
if (locCodes?.Count > 0)
|
||||
{
|
||||
locs = await _db.Queryable<BasLocation>().Where(it => locCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||
}
|
||||
|
||||
carrys.ForEach(x =>
|
||||
{
|
||||
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
||||
if (!carryStdDic.Keys.Contains(x.carrystd_id))
|
||||
{
|
||||
throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
||||
}
|
||||
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.status = 1;
|
||||
@@ -73,7 +79,10 @@ namespace Tnb.WarehouseMgr
|
||||
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
||||
x.carry_status = ((int)EnumCarryStatus.空闲).ToString();
|
||||
if (locs != null && x.location_code != null && x.location_code != string.Empty)
|
||||
{
|
||||
x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500);
|
||||
}
|
||||
|
||||
x.out_status = ((int)EnumOutStatus.正常).ToString();
|
||||
x.is_check = 1;
|
||||
x.create_id = _userManager.UserId;
|
||||
@@ -82,13 +91,13 @@ namespace Tnb.WarehouseMgr
|
||||
});
|
||||
if (carrys.Count > 1000)
|
||||
{
|
||||
await _db.Fastest<WmsCarryH>().BulkCopyAsync(carrys);
|
||||
_ = await _db.Fastest<WmsCarryH>().BulkCopyAsync(carrys);
|
||||
}
|
||||
else if (carrys.Count > 400)
|
||||
{
|
||||
_db.Utilities.PageEach(carrys, 100, async pageList =>
|
||||
{
|
||||
await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user