Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -24,6 +24,7 @@ using JNPF.VisualDev;
|
|||||||
using JNPF.VisualDev.Entitys;
|
using JNPF.VisualDev.Entitys;
|
||||||
using JNPF.VisualDev.Interfaces;
|
using JNPF.VisualDev.Interfaces;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
@@ -72,6 +73,8 @@ namespace Tnb.EquipMgr
|
|||||||
toolMoldMaintainRule.mode = input.data["mode"].ToString();
|
toolMoldMaintainRule.mode = input.data["mode"].ToString();
|
||||||
toolMoldMaintainRule.cycle = cycle;
|
toolMoldMaintainRule.cycle = cycle;
|
||||||
toolMoldMaintainRule.startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss");
|
toolMoldMaintainRule.startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
toolMoldMaintainRule.create_id = _userManager.UserId;
|
||||||
|
toolMoldMaintainRule.create_time=DateTime.Now;
|
||||||
await _db.Insertable(toolMoldMaintainRule).ExecuteCommandAsync();
|
await _db.Insertable(toolMoldMaintainRule).ExecuteCommandAsync();
|
||||||
if (toolMoldMaintainRule.mode == "27118635748885")
|
if (toolMoldMaintainRule.mode == "27118635748885")
|
||||||
{
|
{
|
||||||
@@ -83,7 +86,8 @@ namespace Tnb.EquipMgr
|
|||||||
comtentModel.parameter = new List<InterfaceParameter>();
|
comtentModel.parameter = new List<InterfaceParameter>();
|
||||||
comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = id, defaultValue = "" });
|
comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = id, defaultValue = "" });
|
||||||
comtentModel.localHostTaskId = "MoldMaintainTask/CreateTask";
|
comtentModel.localHostTaskId = "MoldMaintainTask/CreateTask";
|
||||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
DateTimeOffset dateTimeOffset = new DateTimeOffset(startTime);
|
||||||
|
comtentModel.startTime = dateTimeOffset.ToUnixTimeMilliseconds();
|
||||||
comtentModel.TenantId = _userManager?.TenantId!;
|
comtentModel.TenantId = _userManager?.TenantId!;
|
||||||
comtentModel.TenantDbName = _userManager?.TenantDbName!;
|
comtentModel.TenantDbName = _userManager?.TenantDbName!;
|
||||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig!;
|
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig!;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
_cacheManager = cacheManager;
|
_cacheManager = cacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据载具Id带出库位、仓库信息
|
/// 根据载具Id带出库位、仓库信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -519,7 +519,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
loc.is_use = ((int)EnumCarryStatus.占用).ToString();
|
loc.is_use = ((int)EnumCarryStatus.占用).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
locIts.Add(loc);
|
locIts.Add(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using JNPF.VisualDev.Interfaces;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NPOI.SS.Formula.Functions;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using SqlSugar.DbConvert;
|
using SqlSugar.DbConvert;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
@@ -76,14 +77,63 @@ namespace Tnb.WarehouseMgr
|
|||||||
OverideFuncs.CreateAsync = OutStockApplyFor;
|
OverideFuncs.CreateAsync = OutStockApplyFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task<dynamic> OutStockApplyFor(VisualDevModelDataCrInput input)
|
private async Task<dynamic> OutStockApplyFor(VisualDevModelDataCrInput input)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
//判断目标库位是否自动签收
|
//判断目标库位是否自动签收
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
BasLocation? loc = null;
|
||||||
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)) && input.data[nameof(WmsPointH.location_id)].IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
|
}
|
||||||
|
else if (input.data.ContainsKey(nameof(WmsOutstockH.station_id)) && input.data[nameof(WmsOutstockH.station_id)].IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
//多个投料库位
|
||||||
|
/*
|
||||||
|
* 天益
|
||||||
|
* 2、不管库位是否为空, 获取到所有库位 A B
|
||||||
|
* 2.1 根据这些库位去查任务执行 目的库位是这些库位的未完成任务数。 A 10 B 9
|
||||||
|
* 2.2 哪个最少给哪个
|
||||||
|
*/
|
||||||
|
var org = await _db.Queryable<OrganizeEntity>().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString());
|
||||||
|
if (!org?.FeedingLocationId.IsNullOrWhiteSpace() ?? false)
|
||||||
|
{
|
||||||
|
var fLocIds = JArray.Parse(org.FeedingLocationId).Values<string>().ToList();
|
||||||
|
var minTaskNumLocs = await _db.Queryable<WmsPretaskH>().Where(it => it.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && fLocIds.Contains(it.endlocation_id))
|
||||||
|
.GroupBy(it => it.endlocation_id)
|
||||||
|
.Select(it => new
|
||||||
|
{
|
||||||
|
it.endlocation_id,
|
||||||
|
count = SqlFunc.AggregateCount(it.endlocation_id)
|
||||||
|
})
|
||||||
|
.MergeTable()
|
||||||
|
.OrderBy(it => it.count)
|
||||||
|
.ToListAsync();
|
||||||
|
if (minTaskNumLocs?.Count > 0)
|
||||||
|
{
|
||||||
|
var freeLocIds = fLocIds.Except(minTaskNumLocs.Select(x => x.endlocation_id)).ToList();
|
||||||
|
if (freeLocIds?.Count > 0)
|
||||||
|
{
|
||||||
|
var rIdx = new Random().Next(0, freeLocIds.Count);
|
||||||
|
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == freeLocIds[rIdx]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var firstLocId = minTaskNumLocs.FirstOrDefault().endlocation_id;
|
||||||
|
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == firstLocId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (minTaskNumLocs?.Count < 1)
|
||||||
|
{
|
||||||
|
var rIdx = new Random().Next(0, fLocIds.Count);
|
||||||
|
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == fLocIds[rIdx]);
|
||||||
|
}
|
||||||
|
input.data[nameof(WmsOutstockH.location_id)] = loc.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var carryIds = new List<string>();
|
var carryIds = new List<string>();
|
||||||
//tablefield120 出库物料明细
|
//tablefield120 出库物料明细
|
||||||
@@ -98,20 +148,20 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
var OutStockStrategyInput = new OutStockStrategyQuery
|
var OutStockStrategyInput = new OutStockStrategyQuery
|
||||||
{
|
{
|
||||||
carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(),
|
carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)]?.ToString() ?? string.Empty,
|
||||||
warehouse_id = input.data[nameof(WmsOutstockH.warehouse_id)].ToString(),
|
warehouse_id = input.data[nameof(WmsOutstockH.warehouse_id)]?.ToString() ?? string.Empty,
|
||||||
material_id = os.material_id,
|
material_id = os.material_id,
|
||||||
code_batch = os.code_batch,
|
code_batch = os.code_batch,
|
||||||
};
|
};
|
||||||
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||||
Expression<Func<WmsCarryH, WmsCarryCode, bool>> whereExp = input.data.ContainsKey(nameof(WmsOutstockH.carry_id))
|
Expression<Func<WmsCarryH, WmsCarryCode, bool>> whereExp = input.data.ContainsKey(nameof(WmsOutstockH.carry_id)) && input.data[nameof(WmsOutstockH.carry_id)].IsNotEmptyOrNull()
|
||||||
? (a, b) => a.id == input.data[nameof(WmsOutstockH.carry_id)].ToString()
|
? (a, b) => a.id == input.data[nameof(WmsOutstockH.carry_id)].ToString()
|
||||||
: (a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id);
|
: (a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id);
|
||||||
|
|
||||||
List<WmsCarryCode>? carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
List<WmsCarryCode>? carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||||
.Where(whereExp)
|
.Where(whereExp)
|
||||||
.Select<WmsCarryCode>()
|
.Select<WmsCarryCode>()
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (carryCodesPart?.Count > 0)
|
if (carryCodesPart?.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -177,8 +227,20 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString(), source_id = input.data[nameof(WmsOutstockH.source_id)].ToString(), source_code = input.data[nameof(WmsOutstockH.source_code)].ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
var carryH = new WmsCarryH
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString(), source_id = input.data[nameof(WmsOutstockH.source_id)].ToString(), source_code = input.data[nameof(WmsOutstockH.source_code)].ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
{
|
||||||
|
out_status = ((int)EnumOutStatus.全部出).ToString(),
|
||||||
|
source_id = input.data.ContainsKey(nameof(WmsOutstockH.source_id)) ? input.data[nameof(WmsOutstockH.source_id)]?.ToString() ?? string.Empty : string.Empty,
|
||||||
|
source_code = input.data.ContainsKey(nameof(WmsOutstockH.source_code)) ? input.data[nameof(WmsOutstockH.source_code)]?.ToString() ?? string.Empty : string.Empty,
|
||||||
|
};
|
||||||
|
await _db.Updateable(carryH)
|
||||||
|
.UpdateColumns(it => new { it.out_status, it.source_id, it.source_code })
|
||||||
|
.Where(it => allOutIds.Contains(it.id))
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
carryH.out_status = ((int)EnumOutStatus.分拣出).ToString();
|
||||||
|
await _db.Updateable(carryH)
|
||||||
|
.UpdateColumns(it => new { it.out_status, it.source_id, it.source_code })
|
||||||
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -205,37 +267,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)) && input.data[nameof(WmsPointH.location_id)].IsNotEmptyOrNull())
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)) && input.data[nameof(WmsPointH.location_id)].IsNotEmptyOrNull())
|
||||||
{
|
{
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == loc.id);
|
||||||
}
|
|
||||||
else if (input.data.ContainsKey(nameof(WmsOutstockH.station_id)))
|
|
||||||
{
|
|
||||||
//多个投料库位
|
|
||||||
/*
|
|
||||||
* 潍柴
|
|
||||||
* 1、那个库位状态是空的出那个
|
|
||||||
* 1.1、没有空位直接抛异常
|
|
||||||
*
|
|
||||||
* 天益
|
|
||||||
* 2、不管库位是否为空, 获取到所有库位 A B
|
|
||||||
* 2.1 根据这些库位去查任务执行 目的库位是这些库位的未完成任务数。 A 10 B 9
|
|
||||||
* 2.2 哪个最少给哪个
|
|
||||||
*/
|
|
||||||
var org = await _db.Queryable<OrganizeEntity>().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString());
|
|
||||||
if (!org?.FeedingLocationId.IsNullOrWhiteSpace() ?? false)
|
|
||||||
{
|
|
||||||
var fLocIds = JArray.Parse(org.FeedingLocationId).Values<string>();
|
|
||||||
var minTaskNumLoc = await _db.Queryable<WmsPretaskH>().Where(it => it.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && fLocIds.Contains(it.endlocation_id))
|
|
||||||
.GroupBy(it => it.endlocation_id)
|
|
||||||
.Select(it => new
|
|
||||||
{
|
|
||||||
it.endlocation_id,
|
|
||||||
count = SqlFunc.AggregateCount(it.endlocation_id)
|
|
||||||
})
|
|
||||||
.MergeTable()
|
|
||||||
.OrderBy(it => it.count)
|
|
||||||
.FirstAsync();
|
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == minTaskNumLoc.endlocation_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
@@ -323,8 +355,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
JNPF.Logging.Log.Error(ex.ToString());
|
||||||
await _db.Ado.RollbackTranAsync();
|
await _db.Ado.RollbackTranAsync();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -221,70 +238,5 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
|
||||||
{
|
|
||||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
|
||||||
//更具distaskCode的barcode 更新 instockcode 的 is_end 为 1
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _db.Ado.BeginTranAsync();
|
|
||||||
|
|
||||||
if (input.distaskCodes?.Count > 0)
|
|
||||||
{
|
|
||||||
var barCodes = input.distaskCodes.Select(x => x.barcode);
|
|
||||||
await _db.Updateable<WmsInstockCode>().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync();
|
|
||||||
var instockCodes = await _db.Queryable<WmsInstockCode>().Where(it => barCodes.Contains(it.barcode)).Select(it => new
|
|
||||||
{
|
|
||||||
id = it.bill_d_id,
|
|
||||||
barcode_qty = it.codeqty,
|
|
||||||
}).ToListAsync();
|
|
||||||
var dic = instockCodes.GroupBy(g => g.id).ToDictionary(x => x.Key, x => x.Select(d => d.barcode_qty).ToList());
|
|
||||||
var ids = instockCodes.Select(it => it.id).ToList();
|
|
||||||
var instockDetails = await _db.Queryable<WmsInstockD>().Where(it => ids.Contains(it.id)).ToListAsync();
|
|
||||||
|
|
||||||
foreach (var item in instockDetails)
|
|
||||||
{
|
|
||||||
if (dic.ContainsKey(item.id))
|
|
||||||
{
|
|
||||||
item.qty += dic[item.id].Sum(x => x);
|
|
||||||
if (item.qty >= item.pr_qty)
|
|
||||||
{
|
|
||||||
item.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
|
||||||
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
|
||||||
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
|
||||||
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
|
||||||
{
|
|
||||||
//如果是自动单据,需要回更上层系统
|
|
||||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
|
|
||||||
var callBackRes = await _prdInstockService.SyncInstock(pars);
|
|
||||||
instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
|
|
||||||
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
|
||||||
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
|
||||||
{
|
|
||||||
instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//任务没有结束,更新状态为工作中
|
|
||||||
instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
|
||||||
}
|
|
||||||
await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
await _db.Ado.RollbackTranAsync();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,11 +92,12 @@ 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();
|
||||||
var ePoint = it.LastOrDefault();
|
var ePoint = it.LastOrDefault();
|
||||||
|
|
||||||
WmsPretaskH preTask = new();
|
WmsPretaskH preTask = new();
|
||||||
preTask.org_id = _userManager.User.OrganizeId;
|
preTask.org_id = _userManager.User.OrganizeId;
|
||||||
preTask.startlocation_id = sPoint?.location_id!;
|
preTask.startlocation_id = sPoint?.location_id!;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using Tnb.QcMgr.Entities.Entity;
|
|||||||
|
|
||||||
namespace Tnb.TaskScheduler.Listener
|
namespace Tnb.TaskScheduler.Listener
|
||||||
{
|
{
|
||||||
internal class MoldMaintainTask : ISpareTimeWorker
|
public class MoldMaintainTask : ISpareTimeWorker
|
||||||
{
|
{
|
||||||
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
|
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
|
||||||
[SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
[SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
||||||
@@ -41,6 +41,8 @@ namespace Tnb.TaskScheduler.Listener
|
|||||||
toolMoldMaintainPlan.plan_code = "JHDM" + now.ToString("yyyyMMdd") + rNum.Next(1000, 9999).ToString();
|
toolMoldMaintainPlan.plan_code = "JHDM" + now.ToString("yyyyMMdd") + rNum.Next(1000, 9999).ToString();
|
||||||
toolMoldMaintainPlan.mode = ToolMoldMaintainRule.mode;
|
toolMoldMaintainPlan.mode = ToolMoldMaintainRule.mode;
|
||||||
toolMoldMaintainPlan.status = "UnMaintain";
|
toolMoldMaintainPlan.status = "UnMaintain";
|
||||||
|
toolMoldMaintainPlan.create_id = ToolMoldMaintainRule.create_id;
|
||||||
|
toolMoldMaintainPlan.create_time = now;
|
||||||
toolMoldMaintainPlan.plan_start_date = now;
|
toolMoldMaintainPlan.plan_start_date = now;
|
||||||
toolMoldMaintainPlan.plan_end_date = now.AddDays((double)ToolMoldMaintainRule.cycle!);
|
toolMoldMaintainPlan.plan_end_date = now.AddDays((double)ToolMoldMaintainRule.cycle!);
|
||||||
List<ToolMoldMaintainPlanRelation> toolMoldMaintainPlanRelations = new List<ToolMoldMaintainPlanRelation>();
|
List<ToolMoldMaintainPlanRelation> toolMoldMaintainPlanRelations = new List<ToolMoldMaintainPlanRelation>();
|
||||||
|
|||||||
Reference in New Issue
Block a user