执行代码清理,修复warning
This commit is contained in:
@@ -29,58 +29,90 @@ namespace Tnb.WarehouseMgr
|
||||
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
||||
{
|
||||
int row = 0;
|
||||
var errorlist = new List<Dictionary<string, object>>();
|
||||
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
||||
List<Dictionary<string, object>> errorlist = new();
|
||||
VisualDevImportDataOutput result = new();
|
||||
try
|
||||
{
|
||||
List<Dictionary<string, object>> dics = input.list;
|
||||
List<BasLocation> locs = new List<BasLocation>();
|
||||
BasLocation loc = new BasLocation();
|
||||
List<string> cStdCodes = new List<string>();
|
||||
List<string> whCodes = new List<string>();
|
||||
List<string> rgCodes = new List<string>();
|
||||
List<BasLocation> locs = new();
|
||||
BasLocation loc = new();
|
||||
List<string> cStdCodes = new();
|
||||
List<string> whCodes = new();
|
||||
List<string> rgCodes = new();
|
||||
|
||||
//遍历字典,找出需要查询数据库拿的相关字段
|
||||
foreach (var d in dics)
|
||||
foreach (Dictionary<string, object> 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;
|
||||
if (isType == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位类型不可为空", 500);
|
||||
var floor = d["floor"]?.ToString() ?? string.Empty;
|
||||
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
||||
var layers = d["layers"]?.ToString() ?? string.Empty;
|
||||
var locLine = d["loc_line"]?.ToString() ?? string.Empty;
|
||||
var locColumn = d["loc_column"]?.ToString() ?? string.Empty;
|
||||
if (locLine == string.Empty || locColumn == string.Empty || layers == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据行列层不可为空", 500);
|
||||
var isSign = d["is_sign"]?.ToString() ?? string.Empty;
|
||||
if (isSign == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据自动签收不可为空", 500);
|
||||
var cStdCode = d["carrystd_id"]?.ToString() ?? string.Empty;
|
||||
var whCode = d["wh_id"]?.ToString() ?? string.Empty;
|
||||
var rgCode = d["region_id"]?.ToString() ?? string.Empty;
|
||||
string LCode = d["location_code"]?.ToString() ?? string.Empty;
|
||||
if (LCode == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位编号不可为空", 500);
|
||||
}
|
||||
|
||||
string isType = d["is_type"]?.ToString() ?? string.Empty;
|
||||
if (isType == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位类型不可为空", 500);
|
||||
}
|
||||
|
||||
string floor = d["floor"]?.ToString() ?? string.Empty;
|
||||
if (floor == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
||||
}
|
||||
|
||||
string layers = d["layers"]?.ToString() ?? string.Empty;
|
||||
string locLine = d["loc_line"]?.ToString() ?? string.Empty;
|
||||
string locColumn = d["loc_column"]?.ToString() ?? string.Empty;
|
||||
if (locLine == string.Empty || locColumn == string.Empty || layers == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据行列层不可为空", 500);
|
||||
}
|
||||
|
||||
string isSign = d["is_sign"]?.ToString() ?? string.Empty;
|
||||
if (isSign == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据自动签收不可为空", 500);
|
||||
}
|
||||
|
||||
string cStdCode = d["carrystd_id"]?.ToString() ?? string.Empty;
|
||||
string whCode = d["wh_id"]?.ToString() ?? string.Empty;
|
||||
string rgCode = d["region_id"]?.ToString() ?? string.Empty;
|
||||
cStdCodes.Add(cStdCode);
|
||||
whCodes.Add(whCode);
|
||||
rgCodes.Add(rgCode);
|
||||
d["create_time"] = DateTime.Now;
|
||||
d.Remove("modify_time");
|
||||
_ = d.Remove("modify_time");
|
||||
loc = d.Adapt<BasLocation>();
|
||||
locs.Add(loc);
|
||||
}
|
||||
|
||||
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)
|
||||
Dictionary<string, object> 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);
|
||||
Dictionary<string, object> 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);
|
||||
Dictionary<string, object> 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);
|
||||
string orgId = _userManager.User.OrganizeId;
|
||||
string userId = _userManager.UserId;
|
||||
foreach (BasLocation l in locs)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user