Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -24,6 +24,7 @@ using JNPF.VisualDev;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NPOI.HSSF.UserModel;
|
using NPOI.HSSF.UserModel;
|
||||||
using NPOI.SS.UserModel;
|
using NPOI.SS.UserModel;
|
||||||
@@ -96,9 +97,18 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (locDest == null) throw new ArgumentNullException(nameof(locDest));
|
if (locDest == null) throw new ArgumentNullException(nameof(locDest));
|
||||||
if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty())
|
if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var jsonArr = JArray.Parse(locDest.carrystd_id);
|
JArray? jsonArr = null;
|
||||||
var locCarryStdArr = jsonArr.Select(x => x.ToObject<string>()).ToArray();
|
try
|
||||||
isMatch = locCarryStdArr.Contains(carry.carrystd_id);
|
{
|
||||||
|
jsonArr = JArray.Parse(locDest.carrystd_id);
|
||||||
|
var locCarryStdArr = jsonArr.Select(x => x.ToObject<string>()).ToArray();
|
||||||
|
isMatch = locCarryStdArr.Contains(carry.carrystd_id);
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (ex is JsonException jex)
|
||||||
|
{
|
||||||
|
isMatch = carry.carrystd_id.Equals(locDest.carrystd_id, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return Task.FromResult(isMatch);
|
return Task.FromResult(isMatch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using JNPF.Logging;
|
|||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
|
using Spire.Pdf.Lists;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr
|
namespace Tnb.WarehouseMgr
|
||||||
{
|
{
|
||||||
@@ -39,55 +40,80 @@ namespace Tnb.WarehouseMgr
|
|||||||
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
||||||
{
|
{
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
var errorlist = new List<Dictionary<string, object>>();
|
||||||
|
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Dictionary<string, object>> dics = input.list;
|
List<Dictionary<string, object>> dics = input.list;
|
||||||
List<BasLocation> locs = new List<BasLocation>();
|
List<BasLocation> locs = new List<BasLocation>();
|
||||||
BasLocation loc = new BasLocation();
|
BasLocation loc = new BasLocation();
|
||||||
List<string> cStdCodes = new List<string>();
|
List<string> cStdCodes = new List<string>();
|
||||||
|
List<string> whCodes = new List<string>();
|
||||||
|
List<string> rgCodes = new List<string>();
|
||||||
|
|
||||||
//遍历字典,找出需要查询数据库拿的相关字段
|
//遍历字典,找出需要查询数据库拿的相关字段
|
||||||
foreach (var d in dics)
|
foreach (var d in dics)
|
||||||
{
|
{
|
||||||
var LCode = d["location_code"].ToString() ?? string.Empty;
|
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;
|
var isType = d["is_type"]?.ToString() ?? string.Empty;
|
||||||
if (isType == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位类型不可为空", 500);
|
if (isType == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位类型不可为空", 500);
|
||||||
var floor = d["floor"].ToString() ?? string.Empty;
|
var floor = d["floor"]? .ToString() ?? string.Empty;
|
||||||
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
||||||
var layers = d["layers"].ToString() ?? string.Empty;
|
var layers = d["layers"]?.ToString() ?? string.Empty;
|
||||||
var locLine = d["loc_line"].ToString() ?? string.Empty;
|
var locLine = d["loc_line"]?.ToString() ?? string.Empty;
|
||||||
var locColumn = d["loc_column"].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);
|
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;
|
var isSign = d["is_sign"]?.ToString() ?? string.Empty;
|
||||||
if(isSign==string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据自动签收不可为空", 500);
|
if (isSign == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据自动签收不可为空", 500);
|
||||||
var cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
|
var cStdCode = d["carrystd_id"]?.ToString() ?? string.Empty;
|
||||||
|
var whCode = d["wh_id"]?.ToString() ?? string.Empty;
|
||||||
|
var rgCode = d["region_id"]?.ToString() ?? string.Empty;
|
||||||
cStdCodes.Add(cStdCode);
|
cStdCodes.Add(cStdCode);
|
||||||
|
whCodes.Add(whCode);
|
||||||
|
rgCodes.Add(rgCode);
|
||||||
d["create_time"] = DateTime.Now;
|
d["create_time"] = DateTime.Now;
|
||||||
d.Remove("modify_time");
|
d.Remove("modify_time");
|
||||||
loc = d.Adapt<BasLocation>();
|
loc = d.Adapt<BasLocation>();
|
||||||
locs.Add(loc);
|
locs.Add(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.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 whDic = await _db.Queryable<BasWarehouse>().Where(it => whCodes.Contains(it.whcode)).ToDictionaryAsync(x => x.whcode, x => x.id);
|
||||||
|
var rgDic = await _db.Queryable<BasRegion>().Where(it => rgCodes.Contains(it.region_code)).ToDictionaryAsync(x => x.region_code, x => x.id);
|
||||||
|
|
||||||
locs.ForEach(x =>
|
locs.ForEach(x =>
|
||||||
{
|
{
|
||||||
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
if (!carryStdDic.ContainsKey(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
||||||
|
if (!whDic.ContainsKey(x.wh_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的仓库有误", 500);
|
||||||
|
if (!rgDic.ContainsKey(x.region_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的区域名称有误", 500);
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
x.org_id = _userManager.User.OrganizeId;
|
||||||
|
x.location_name = x.location_code;
|
||||||
x.is_lock = 0;
|
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()!;
|
||||||
|
x.wh_id = whDic[x.wh_id]?.ToString()!;
|
||||||
|
x.region_id = rgDic[x.region_id]?.ToString();
|
||||||
x.create_id = _userManager.UserId;
|
x.create_id = _userManager.UserId;
|
||||||
x.modify_id = null;
|
x.modify_id = null;
|
||||||
x.modify_time = null;
|
x.modify_time = null;
|
||||||
x.is_mix = 1;
|
x.is_mix = 1;
|
||||||
|
x.is_use = "0";
|
||||||
});
|
});
|
||||||
|
|
||||||
row = await _db.Insertable(locs).ExecuteCommandAsync();
|
row = await _db.Insertable(locs).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw Oops.Bah(ex.Message);
|
throw Oops.Bah(ex.Message);
|
||||||
}
|
}
|
||||||
return row > 0;
|
result = new VisualDevImportDataOutput()
|
||||||
|
{
|
||||||
|
snum = row,
|
||||||
|
fnum = 0,
|
||||||
|
failResult = errorlist,
|
||||||
|
resultType = errorlist.Count < 1 ? 0 : 1
|
||||||
|
};
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -581,6 +581,11 @@ namespace Tnb.WarehouseMgr
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> GenPreTask(List<WmsPretaskH> preTasks, List<WmsPretaskCode> preTaskCodes)
|
public async Task<bool> GenPreTask(List<WmsPretaskH> preTasks, List<WmsPretaskCode> preTaskCodes)
|
||||||
{
|
{
|
||||||
|
//如果预任务出现起终库位相同,则删除对应预任务
|
||||||
|
if (preTasks.FindAll(it => it.startlocation_id == it.endlocation_id)?.Count > 0)
|
||||||
|
{
|
||||||
|
preTasks.RemoveAll(it => it.startlocation_id == it.endlocation_id);
|
||||||
|
}
|
||||||
var grpList = preTasks.OrderBy(o => o.bill_code).GroupBy(g => g.carry_id).ToList();
|
var grpList = preTasks.OrderBy(o => o.bill_code).GroupBy(g => g.carry_id).ToList();
|
||||||
if (grpList?.Count > 0)
|
if (grpList?.Count > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using JNPF.FriendlyException;
|
|||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.ProductionMgr.Interfaces;
|
using Tnb.ProductionMgr.Interfaces;
|
||||||
@@ -55,8 +56,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
_prdInstockService = prdInstockService;
|
_prdInstockService = prdInstockService;
|
||||||
OverideFuncs.CreateAsync = ScanInStock;
|
OverideFuncs.CreateAsync = ScanInStock;
|
||||||
}
|
}
|
||||||
|
public async Task<dynamic> ScanInStock(VisualDevModelDataCrInput input)
|
||||||
private async Task<dynamic> ScanInStock(VisualDevModelDataCrInput input)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -84,9 +84,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
bill_date = DateTime.Today,
|
bill_date = DateTime.Today,
|
||||||
warehouse_id = "26103372441637",
|
warehouse_id = "26103372441637",
|
||||||
status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||||
generate_type = "1",
|
generate_type = "0",
|
||||||
sync_status = "0",
|
sync_status = WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC,
|
||||||
print_status = "0",
|
print_status = WmsWareHouseConst.PRINT_STATUS_PRINTCOMPLETE,
|
||||||
is_check = 1,
|
is_check = 1,
|
||||||
create_id = _userManager.UserId,
|
create_id = _userManager.UserId,
|
||||||
create_time = DateTime.Now,
|
create_time = DateTime.Now,
|
||||||
@@ -101,6 +101,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
unit_id = mat.unit_id,
|
unit_id = mat.unit_id,
|
||||||
pr_qty = item.codeqty,
|
pr_qty = item.codeqty,
|
||||||
qty = 0,
|
qty = 0,
|
||||||
|
code_batch = item.code_batch,
|
||||||
warehouse_id = "26103372441637",
|
warehouse_id = "26103372441637",
|
||||||
print_qty = item.codeqty,
|
print_qty = item.codeqty,
|
||||||
scan_qty = item.codeqty,
|
scan_qty = item.codeqty,
|
||||||
@@ -134,6 +135,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
WmsPointH sPoint = new();
|
WmsPointH sPoint = new();
|
||||||
WmsPointH ePoint = new();
|
WmsPointH ePoint = new();
|
||||||
|
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
var eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
var eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
@@ -141,6 +143,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||||
}
|
}
|
||||||
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == loc.id);
|
||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
@@ -168,7 +171,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
preTask.endpoint_code = ePoint?.point_code!;
|
preTask.endpoint_code = ePoint?.point_code!;
|
||||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID;
|
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID;
|
||||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
||||||
preTask.carry_id = carry.id;
|
preTask.carry_id = carry.id;
|
||||||
preTask.carry_code = carry.carry_code;
|
preTask.carry_code = carry.carry_code;
|
||||||
@@ -180,7 +183,21 @@ namespace Tnb.WarehouseMgr
|
|||||||
preTask.create_time = DateTime.Now;
|
preTask.create_time = DateTime.Now;
|
||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
List<WmsPretaskCode> pretaskCodes = new();
|
||||||
|
foreach (var pt in preTasks)
|
||||||
|
{
|
||||||
|
WmsPretaskCode ptc = pt.Adapt<WmsPretaskCode>();
|
||||||
|
ptc.id = SnowflakeIdHelper.NextId();
|
||||||
|
ptc.bill_id = pt.id;
|
||||||
|
ptc.material_id = instockCode.material_id;
|
||||||
|
ptc.material_code = instockCode.material_code;
|
||||||
|
ptc.barcode = instockCode.barcode;
|
||||||
|
ptc.codeqty = instockCode.codeqty;
|
||||||
|
ptc.unit_id = instockCode.unit_id;
|
||||||
|
ptc.code_batch = instockCode.code_batch;
|
||||||
|
pretaskCodes.Add(ptc);
|
||||||
|
}
|
||||||
|
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||||
if (isOk)
|
if (isOk)
|
||||||
{
|
{
|
||||||
var preTaskUpInput = new GenPreTaskUpInput();
|
var preTaskUpInput = new GenPreTaskUpInput();
|
||||||
|
|||||||
@@ -34,32 +34,39 @@ namespace Tnb.WarehouseMgr
|
|||||||
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
||||||
{
|
{
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
var errorlist = new List<Dictionary<string, object>>();
|
||||||
|
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Dictionary<string, object>> dics = input.list;
|
List<Dictionary<string, object>> dics = input.list;
|
||||||
List<WmsPointH> points = new List<WmsPointH>();
|
List<WmsPointH> points = new List<WmsPointH>();
|
||||||
WmsPointH pt = new WmsPointH();
|
WmsPointH pt = new WmsPointH();
|
||||||
List<string> aCodes = new List<string>();
|
List<string> aCodes = new List<string>();
|
||||||
|
List<string> lCodes = new List<string>();
|
||||||
//遍历字典,找出需要查询数据库拿的相关字段
|
//遍历字典,找出需要查询数据库拿的相关字段
|
||||||
foreach (var d in dics)
|
foreach (var d in dics)
|
||||||
{
|
{
|
||||||
var pCode = d["point_code"].ToString() ?? string.Empty;
|
d.ContainsKey("location_code");
|
||||||
var pName = d["point_name"].ToString() ?? string.Empty;
|
var pCode = d["point_code"]?.ToString() ?? string.Empty;
|
||||||
var aCode = d["area_code"].ToString() ?? string.Empty;
|
var pName = d["point_name"]?.ToString() ?? string.Empty;
|
||||||
var floor = d["floor"].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 (pCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位编号不可为空", 500);
|
||||||
if (pName == 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);
|
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
|
||||||
aCodes.Add(aCode);
|
aCodes.Add(aCode);
|
||||||
|
lCodes.Add(lCode);
|
||||||
d["create_time"] = DateTime.Now;
|
d["create_time"] = DateTime.Now;
|
||||||
d.Remove("modify_time");
|
d.Remove("modify_time");
|
||||||
pt = d.Adapt<WmsPointH>();
|
pt = d.Adapt<WmsPointH>();
|
||||||
points.Add(pt);
|
points.Add(pt);
|
||||||
}
|
}
|
||||||
var areas = await _db.Queryable<WmsAreaH>().Where(it => aCodes.Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
var aDic = await _db.Queryable<WmsAreaH>().Where(it => aCodes.Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
||||||
|
var lDic = await _db.Queryable<BasLocation>().Where(it => lCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||||
points.ForEach(x =>
|
points.ForEach(x =>
|
||||||
{
|
{
|
||||||
if (!areas.Keys.Contains(x.area_code)) throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号有误", 500);
|
if (!aDic.ContainsKey(x.area_code)) throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号有误", 500);
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
x.org_id = _userManager.User.OrganizeId;
|
||||||
x.is_lock = 0;
|
x.is_lock = 0;
|
||||||
@@ -67,7 +74,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
x.point_x = 0;
|
x.point_x = 0;
|
||||||
x.point_y = 0;
|
x.point_y = 0;
|
||||||
x.point_z = 0;
|
x.point_z = 0;
|
||||||
x.area_id = areas[x.area_code].ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号编号有误", 500);
|
x.location_id = x.location_code != null ? lDic[x.location_code]?.ToString() : null;
|
||||||
|
x.area_id = aDic[x.area_code]?.ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号编号有误", 500);
|
||||||
x.create_id = _userManager.UserId;
|
x.create_id = _userManager.UserId;
|
||||||
x.modify_id = null;
|
x.modify_id = null;
|
||||||
x.modify_time = null;
|
x.modify_time = null;
|
||||||
@@ -78,7 +86,14 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
throw Oops.Bah(ex.Message);
|
throw Oops.Bah(ex.Message);
|
||||||
}
|
}
|
||||||
return row > 0;
|
result = new VisualDevImportDataOutput()
|
||||||
|
{
|
||||||
|
snum = row,
|
||||||
|
fnum = 0,
|
||||||
|
failResult = errorlist,
|
||||||
|
resultType = errorlist.Count < 1 ? 0 : 1
|
||||||
|
};
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
|
||||||
{
|
{
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
var errorlist = new List<Dictionary<string, object>>();
|
||||||
|
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Dictionary<string, object>> dics = input.list;
|
List<Dictionary<string, object>> dics = input.list;
|
||||||
@@ -79,9 +81,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
//遍历字典,找出需要查询数据库拿的相关字段
|
//遍历字典,找出需要查询数据库拿的相关字段
|
||||||
foreach (var d in dics)
|
foreach (var d in dics)
|
||||||
{
|
{
|
||||||
var sCode = d["startpoint_code"].ToString() ?? string.Empty;
|
var sCode = d["startpoint_code"]?.ToString() ?? string.Empty;
|
||||||
var eCode = d["endpoint_code"].ToString() ?? string.Empty;
|
var eCode = d["endpoint_code"]?.ToString() ?? string.Empty;
|
||||||
var dis = d["distance"].ToString() ?? string.Empty;
|
var dis = d["distance"]?.ToString() ?? string.Empty;
|
||||||
if(sCode == eCode) throw new AppFriendlyException("起始点位不能等于终止点位", 500);
|
if(sCode == eCode) throw new AppFriendlyException("起始点位不能等于终止点位", 500);
|
||||||
if (dis.IsEmpty())
|
if (dis.IsEmpty())
|
||||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
|
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
|
||||||
@@ -97,12 +99,12 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
roads.ForEach(x =>
|
roads.ForEach(x =>
|
||||||
{
|
{
|
||||||
if (!points.Keys.Contains(x.startpoint_code) ) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500);
|
if (!points.ContainsKey(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.ContainsKey(x.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500);
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
x.org_id = _userManager.User.OrganizeId;
|
||||||
x.startpoint_id = points[x.startpoint_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.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.road_code = $"{x.startpoint_code}-{x.endpoint_code}";
|
||||||
x.status = 1;
|
x.status = 1;
|
||||||
x.create_id = _userManager.UserId;
|
x.create_id = _userManager.UserId;
|
||||||
@@ -111,12 +113,20 @@ namespace Tnb.WarehouseMgr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
row = await _db.Insertable(roads).ExecuteCommandAsync();
|
row = await _db.Insertable(roads).ExecuteCommandAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw Oops.Bah(ex.Message);
|
throw Oops.Bah(ex.Message);
|
||||||
}
|
}
|
||||||
return row > 0;
|
result = new VisualDevImportDataOutput()
|
||||||
|
{
|
||||||
|
snum = row,
|
||||||
|
fnum = 0,
|
||||||
|
failResult = errorlist,
|
||||||
|
resultType = errorlist.Count < 1 ? 0 : 1
|
||||||
|
};
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Channels;
|
using System.Threading.Channels;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Aop.Api.Domain;
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Dtos.VisualDev;
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
@@ -75,15 +76,15 @@ namespace Tnb.WarehouseMgr
|
|||||||
// 计算路径,插入预任务申请
|
// 计算路径,插入预任务申请
|
||||||
WmsPointH? sPoint = null;
|
WmsPointH? sPoint = null;
|
||||||
WmsPointH? ePoint = null;
|
WmsPointH? ePoint = null;
|
||||||
if (input.data.ContainsKey(nameof(WmsTransfer.startlocation_id)))
|
|
||||||
{
|
|
||||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsTransfer.startlocation_id)].ToString());
|
|
||||||
}
|
|
||||||
if (input.data.ContainsKey(nameof(WmsTransfer.endlocation_id)))
|
if (input.data.ContainsKey(nameof(WmsTransfer.endlocation_id)))
|
||||||
{
|
{
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsTransfer.endlocation_id)].ToString());
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsTransfer.endlocation_id)].ToString());
|
||||||
}
|
}
|
||||||
|
if (input.data.ContainsKey(nameof(WmsTransfer.startlocation_id)))
|
||||||
|
{
|
||||||
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsTransfer.startlocation_id)].ToString());
|
||||||
|
}
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
@@ -91,6 +92,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (points?.Count > 0)
|
if (points?.Count > 0)
|
||||||
{
|
{
|
||||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||||
|
|
||||||
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||||
{
|
{
|
||||||
var sPoint = it.FirstOrDefault();
|
var sPoint = it.FirstOrDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user