导入功能修改
This commit is contained in:
@@ -20,6 +20,10 @@ using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Spire.Pdf.Lists;
|
||||
using Aop.Api.Domain;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -55,6 +59,10 @@ namespace Tnb.WarehouseMgr
|
||||
//遍历字典,找出需要查询数据库拿的相关字段
|
||||
foreach (var d in dics)
|
||||
{
|
||||
if (d.Select(x => x.Value.ToString()).ToList().Find(v => v != "" && v != string.Empty && v != null) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var LCode = d["location_code"]?.ToString() ?? string.Empty;
|
||||
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位编号不可为空", 500);
|
||||
var isType = d["is_type"]?.ToString() ?? string.Empty;
|
||||
@@ -79,36 +87,38 @@ namespace Tnb.WarehouseMgr
|
||||
locs.Add(loc);
|
||||
}
|
||||
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
var whDic = await _db.Queryable<BasWarehouse>().Where(it => whCodes.Contains(it.whcode)).ToDictionaryAsync(x => x.whcode, x => x.id);
|
||||
var rgDic = await _db.Queryable<BasRegion>().Where(it => rgCodes.Contains(it.region_code)).ToDictionaryAsync(x => x.region_code, x => x.id);
|
||||
|
||||
locs.ForEach(x =>
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
var whDic = await _db.Queryable<BasWarehouse>().Where(it => whCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.whcode)).ToDictionaryAsync(x => x.whcode, x => x.id);
|
||||
var rgDic = await _db.Queryable<BasRegion>().Where(it => rgCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.region_code)).ToDictionaryAsync(x => x.region_code, x => x.id);
|
||||
var orgId = _userManager.User.OrganizeId;
|
||||
var userId = _userManager.UserId;
|
||||
foreach (var l in locs)
|
||||
{
|
||||
if (!carryStdDic.ContainsKey(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
||||
if (!whDic.ContainsKey(x.wh_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的仓库有误", 500);
|
||||
if (!rgDic.ContainsKey(x.region_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的区域名称有误", 500);
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.location_name = x.location_code;
|
||||
x.is_lock = 0;
|
||||
x.carrystd_id = carryStdDic[x.carrystd_id]?.ToString()!;
|
||||
x.wh_id = whDic[x.wh_id]?.ToString()!;
|
||||
x.region_id = rgDic[x.region_id]?.ToString();
|
||||
x.create_id = _userManager.UserId;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
x.is_mix = 1;
|
||||
x.is_use = "0";
|
||||
});
|
||||
if (!carryStdDic.ContainsKey(l.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(l) + 1}个数据的载具规格有误", 500);
|
||||
if (!whDic.ContainsKey(l.wh_id)) throw new AppFriendlyException($"第{locs.IndexOf(l) + 1}个数据的仓库有误", 500);
|
||||
if (!rgDic.ContainsKey(l.region_id)) throw new AppFriendlyException($"第{locs.IndexOf(l) + 1}个数据的区域名称有误", 500);
|
||||
l.id = SnowflakeIdHelper.NextId();
|
||||
l.org_id = orgId;
|
||||
l.location_name = l.location_code;
|
||||
l.is_lock = 0;
|
||||
l.carrystd_id = carryStdDic[l.carrystd_id]?.ToString()!;
|
||||
l.wh_id = whDic[l.wh_id]?.ToString()!;
|
||||
l.region_id = rgDic[l.region_id]?.ToString();
|
||||
l.create_id = userId;
|
||||
l.modify_id = null;
|
||||
l.modify_time = null;
|
||||
l.is_mix = 1;
|
||||
l.is_use = "0";
|
||||
}
|
||||
|
||||
if (locs.Count > 1000)
|
||||
{
|
||||
await _db.Fastest<BasLocation>().BulkCopyAsync(locs);
|
||||
row = await _db.Fastest<BasLocation>().BulkCopyAsync(locs);
|
||||
}
|
||||
else if (locs.Count > 400)
|
||||
{
|
||||
_db.Utilities.PageEach(locs, 100, async pageList => {
|
||||
await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||
row = await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -130,5 +140,6 @@ namespace Tnb.WarehouseMgr
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user