修改报错消息,增加注释

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

@@ -21,6 +21,9 @@ using NPOI.SS.Formula.Functions;
namespace Tnb.WarehouseMgr
{
/// <summary>
/// 库位定义业务类
/// </summary>
[OverideVisualDev(ModuleConsts.MODULE_LOCATIONDEFINITION_ID)]
public class LocationDefinitionService : BaseWareHouseService
{
@@ -41,27 +44,29 @@ namespace Tnb.WarehouseMgr
List<Dictionary<string, object>> dics = input.list;
List<BasLocation> locs = new List<BasLocation>();
BasLocation loc = new BasLocation();
List<string> cCodes = new List<string>();
List<string> cStdCodes = new List<string>();
//遍历字典,找出需要查询数据库拿的相关字段
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);
cCodes.Add(cCode);
var LCode = d["location_code"].ToString() ?? string.Empty;
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据起始点位编号不可为空", 500);
var cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
cStdCodes.Add(cStdCode);
d["create_time"] = DateTime.Now;
d.Remove("modify_time");
loc = d.Adapt<BasLocation>();
locs.Add(loc);
}
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);
if (carryStdDic?.Count > 0)
{
locs.ForEach(x =>
{
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}的载具规格有误", 500);
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.id = SnowflakeIdHelper.NextId();
x.org_id = _userManager.User.OrganizeId;
x.is_lock = 0;
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}的载具规格有误", 500);
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.create_id = _userManager.UserId;
x.modify_id = null;
x.modify_time = null;