Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -21,6 +21,9 @@ using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 库位定义业务类
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_LOCATIONDEFINITION_ID)]
|
||||
public class LocationDefinitionService : BaseWareHouseService
|
||||
{
|
||||
@@ -41,29 +44,30 @@ 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.create_time = DateTime.Now;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
x.is_mix = 1;
|
||||
|
||||
@@ -62,36 +62,36 @@ 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;
|
||||
x.create_time = DateTime.Now;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
@@ -15,12 +16,15 @@ using Tnb.WarehouseMgr.Entities;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 点位管理业务类
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSPOINT_ID)]
|
||||
public class WmsPointService: BaseWareHouseService
|
||||
public class WmsPointService : BaseWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
public WmsPointService(ISqlSugarRepository<WmsPointH> repository, IUserManager userManager)
|
||||
public WmsPointService(ISqlSugarRepository<WmsPointH> repository, IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
@@ -35,34 +39,40 @@ namespace Tnb.WarehouseMgr
|
||||
List<Dictionary<string, object>> dics = input.list;
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
WmsPointH pt = new WmsPointH();
|
||||
List<string> cCodes = new List<string>();
|
||||
List<string> aCodes = 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 pCode = d["point_code"].ToString() ?? string.Empty;
|
||||
var pName = d["point_name"].ToString() ?? string.Empty;
|
||||
var aCode = d["area_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 (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;
|
||||
d.Remove("modify_time");
|
||||
pt = d.Adapt<WmsPointH>();
|
||||
points.Add(pt);
|
||||
}
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
if (carryStdDic?.Count > 0)
|
||||
var areas = await _db.Queryable<WmsAreaH>().Where(it => aCodes.Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
||||
points.ForEach(x =>
|
||||
{
|
||||
points.ForEach(x =>
|
||||
{
|
||||
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.is_lock = 0;
|
||||
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
|
||||
});
|
||||
}
|
||||
if (!areas.Keys.Contains(x.area_code)) throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号有误", 500);
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.is_lock = 0;
|
||||
x.status = 1;
|
||||
x.point_x = 0;
|
||||
x.point_y = 0;
|
||||
x.point_z = 0;
|
||||
x.area_id = areas[x.area_code].ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号编号有误", 500);
|
||||
x.create_id = _userManager.UserId;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
});
|
||||
row = await _db.Insertable(points).ExecuteCommandAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -76,18 +76,19 @@ namespace Tnb.WarehouseMgr
|
||||
List<string> pointCodes = new List<string>();
|
||||
List<string> locCodes = new();
|
||||
WmsRoad road = new WmsRoad();
|
||||
//遍历字典,找出需要查询数据库拿的相关字段
|
||||
foreach (var d in dics)
|
||||
{
|
||||
var sCode = d["startpoint_code"].ToString() ?? string.Empty;
|
||||
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 (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);
|
||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
|
||||
pointCodes.Add(sCode);
|
||||
pointCodes.Add(eCode);
|
||||
d["create_time"] = DateTime.Now;
|
||||
@@ -100,12 +101,12 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
roads.ForEach(x =>
|
||||
{
|
||||
if (!points.Keys.Contains(x.startpoint_code) ) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的起始点位编号有误", 500);
|
||||
if (!points.Keys.Contains(x.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的终止点位编号有误", 500);
|
||||
if (!points.Keys.Contains(x.startpoint_code) ) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500);
|
||||
if (!points.Keys.Contains(x.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500);
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.startpoint_id = points[x.startpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的起始点位编号有误", 500);
|
||||
x.endpoint_id = points[x.endpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的终止点位编号有误", 500);
|
||||
x.startpoint_id = points[x.startpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500);
|
||||
x.endpoint_id = points[x.endpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500);
|
||||
x.road_code = $"{x.startpoint_code}-{x.endpoint_code}";
|
||||
x.status = 1;
|
||||
x.create_id = _userManager.UserId;
|
||||
|
||||
@@ -798,7 +798,7 @@ namespace JNPF.VisualDev
|
||||
{
|
||||
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.CreateAsync != null)
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.ImportDataAsync != null)
|
||||
{
|
||||
await overideSvc.OverideFuncs.ImportDataAsync(list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user