执行代码清理,修复warning
This commit is contained in:
@@ -29,46 +29,62 @@ 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<WmsPointH> points = new List<WmsPointH>();
|
||||
WmsPointH pt = new WmsPointH();
|
||||
List<string> aCodes = new List<string>();
|
||||
List<string> lCodes = new List<string>();
|
||||
List<WmsPointH> points = new();
|
||||
WmsPointH pt = new();
|
||||
List<string> aCodes = new();
|
||||
List<string> lCodes = 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;
|
||||
}
|
||||
d.ContainsKey("location_code");
|
||||
var pCode = d["point_code"]?.ToString() ?? string.Empty;
|
||||
var pName = d["point_name"]?.ToString() ?? string.Empty;
|
||||
var aCode = d["area_code"]?.ToString() ?? string.Empty;
|
||||
var lCode = d["location_code"]?.ToString() ?? string.Empty;
|
||||
var floor = d["floor"]?.ToString() ?? string.Empty;
|
||||
if (pCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位编号不可为空", 500);
|
||||
if (pName == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位名称不可为空", 500);
|
||||
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
||||
_ = d.ContainsKey("location_code");
|
||||
string pCode = d["point_code"]?.ToString() ?? string.Empty;
|
||||
string pName = d["point_name"]?.ToString() ?? string.Empty;
|
||||
string aCode = d["area_code"]?.ToString() ?? string.Empty;
|
||||
string lCode = d["location_code"]?.ToString() ?? string.Empty;
|
||||
string floor = d["floor"]?.ToString() ?? string.Empty;
|
||||
if (pCode == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位编号不可为空", 500);
|
||||
}
|
||||
|
||||
if (pName == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位名称不可为空", 500);
|
||||
}
|
||||
|
||||
if (floor == string.Empty)
|
||||
{
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
||||
}
|
||||
|
||||
aCodes.Add(aCode);
|
||||
lCodes.Add(lCode);
|
||||
d["create_time"] = DateTime.Now;
|
||||
d.Remove("modify_time");
|
||||
_ = d.Remove("modify_time");
|
||||
pt = d.Adapt<WmsPointH>();
|
||||
points.Add(pt);
|
||||
}
|
||||
var aDic = await _db.Queryable<WmsAreaH>().Where(it => aCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
||||
var lDic = await _db.Queryable<BasLocation>().Where(it => lCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||
var orgId = _userManager.User.OrganizeId;
|
||||
var userId = _userManager.UserId;
|
||||
foreach (var p in points)
|
||||
Dictionary<string, object> aDic = await _db.Queryable<WmsAreaH>().Where(it => aCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
||||
Dictionary<string, object> lDic = await _db.Queryable<BasLocation>().Where(it => lCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||
string orgId = _userManager.User.OrganizeId;
|
||||
string userId = _userManager.UserId;
|
||||
foreach (WmsPointH p in points)
|
||||
{
|
||||
if (!aDic.ContainsKey(p.area_code)) throw new AppFriendlyException($"第{points.IndexOf(p) + 1}个数据的管理区编号有误", 500);
|
||||
if (!aDic.ContainsKey(p.area_code))
|
||||
{
|
||||
throw new AppFriendlyException($"第{points.IndexOf(p) + 1}个数据的管理区编号有误", 500);
|
||||
}
|
||||
|
||||
p.id = SnowflakeIdHelper.NextId();
|
||||
p.org_id = orgId;
|
||||
p.is_lock = 0;
|
||||
|
||||
Reference in New Issue
Block a user