修改导入功能
This commit is contained in:
@@ -49,7 +49,17 @@ namespace Tnb.WarehouseMgr
|
||||
foreach (var d in dics)
|
||||
{
|
||||
var LCode = d["location_code"].ToString() ?? string.Empty;
|
||||
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据起始点位编号不可为空", 500);
|
||||
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;
|
||||
cStdCodes.Add(cStdCode);
|
||||
d["create_time"] = DateTime.Now;
|
||||
@@ -58,21 +68,19 @@ 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);
|
||||
if (carryStdDic?.Count > 0)
|
||||
locs.ForEach(x =>
|
||||
{
|
||||
locs.ForEach(x =>
|
||||
{
|
||||
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.create_id = _userManager.UserId;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
x.is_mix = 1;
|
||||
});
|
||||
}
|
||||
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.create_id = _userManager.UserId;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
x.is_mix = 1;
|
||||
});
|
||||
|
||||
row = await _db.Insertable(locs).ExecuteCommandAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
List<Dictionary<string, object>> dics = input.list;
|
||||
List<WmsCarryH> carrys = new List<WmsCarryH>();
|
||||
Dictionary<string, object>? locs = null;
|
||||
List<string> locCodes = new();
|
||||
List<string> cStdCodes = new();
|
||||
WmsCarryH carryH = new WmsCarryH();
|
||||
@@ -68,8 +69,7 @@ namespace Tnb.WarehouseMgr
|
||||
foreach (var d in dics)
|
||||
{
|
||||
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);
|
||||
locCodes.Add(d["location_code"].ToString() ?? string.Empty);
|
||||
cStdCodes.Add(cStdCode);
|
||||
d["create_time"] = DateTime.Now;
|
||||
d.Remove("modify_time");
|
||||
@@ -77,18 +77,19 @@ namespace Tnb.WarehouseMgr
|
||||
carrys.Add(carryH);
|
||||
}
|
||||
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);
|
||||
if (locCodes?.Count > 0)
|
||||
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);
|
||||
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.carry_status = ((int)EnumCarryStatus.空闲).ToString();
|
||||
x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500);
|
||||
if (locs != null && x.location_code != null && x.location_code != string.Empty)
|
||||
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;
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace Tnb.WarehouseMgr
|
||||
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 (aCode == 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);
|
||||
d["create_time"] = DateTime.Now;
|
||||
|
||||
@@ -83,10 +83,6 @@ namespace Tnb.WarehouseMgr
|
||||
var eCode = d["endpoint_code"].ToString() ?? string.Empty;
|
||||
var dis = d["distance"].ToString() ?? string.Empty;
|
||||
if(sCode == eCode) throw new AppFriendlyException("起始点位不能等于终止点位", 500);
|
||||
//if (sCode.IsEmpty())
|
||||
// throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据数据起始点位编号不可为空", 500);
|
||||
//if (eCode.IsEmpty())
|
||||
// throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据终止点位编号不可为空", 500);
|
||||
if (dis.IsEmpty())
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
|
||||
pointCodes.Add(sCode);
|
||||
|
||||
Reference in New Issue
Block a user