修改报错消息,增加注释

This commit is contained in:
FanLian
2023-08-10 10:21:13 +08:00
parent 831a469617
commit f21291380e
4 changed files with 42 additions and 31 deletions

View File

@@ -62,32 +62,33 @@ namespace Tnb.WarehouseMgr
List<Dictionary<string, object>> dics = input.list;
List<WmsCarryH> carrys = new List<WmsCarryH>();
List<string> locCodes = new();
List<string> cCodes = new();
List<string> cStdCodes = new();
WmsCarryH carryH = new WmsCarryH();
//遍历字典,找出需要查询数据库拿的相关字段
foreach (var d in dics)
{
var cCode = d["carrystd_id"].ToString() ?? string.Empty;
if (cCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}载具规格不可为空", 500);
var cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
//if (cStdCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据载具规格不可为空", 500);
locCodes.Add(d["location_code"]?.ToString() ?? string.Empty);
cCodes.Add(cCode);
cStdCodes.Add(cStdCode);
d["create_time"] = DateTime.Now;
d.Remove("modify_time");
carryH = d.Adapt<WmsCarryH>();
carrys.Add(carryH);
}
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
var 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 (!locs.Keys.Contains(x.location_code)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}的库位编号有误", 500);
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
if (!locs.Keys.Contains(x.location_code)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500);
x.id = SnowflakeIdHelper.NextId();
x.org_id = _userManager.User.OrganizeId;
x.status = 1;
x.is_lock = 0;
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}的载具规格有误", 500);
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.carry_status = ((int)EnumCarryStatus.).ToString();
x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}的库位编号有误", 500);
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;