This commit is contained in:
alex
2023-07-13 14:13:22 +08:00
12 changed files with 204 additions and 143 deletions

View File

@@ -8,14 +8,14 @@
/// <summary>
/// 组织ID
/// </summary>
public string? org_id { get; set; }
public string org_id { get; set; }
/// <summary>
/// 载具Id
/// </summary>
public string? carry_code { get; set;}
public string carry_code { get; set;}
/// <summary>
/// 创建热Id
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
}
}

View File

@@ -14,22 +14,22 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 组织ID
/// </summary>
public string? org_id { get; set; }
public string org_id { get; set; }
/// <summary>
/// 库位编号
/// </summary>
public string? location_code { get; set; }
public string location_code { get; set; }
/// <summary>
/// 载具编号
/// </summary>
public string? carry_code { get; set; }
public string carry_code { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
/// <summary>
/// 入库仓库
/// </summary>
public string? warehouse_id { get; set; }
public string warehouse_id { get; set; }
}
}

View File

@@ -25,20 +25,20 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
/// <summary>
/// 入库仓库
/// </summary>
public string? warehouse_id { get; set; }
public string warehouse_id { get; set; }
/// <summary>
/// 载具规格编号
/// </summary>
public string? carrystd_id { get; set; }
public string carrystd_id { get; set; }
/// <summary>
/// 数量
/// </summary>
public int? qty { get; set; }
public int qty { get; set; }
}
}

View File

@@ -14,7 +14,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 所属组织ID
/// </summary>
public string? org_id { get; set; }
public string org_id { get; set; }
/// <summary>
/// 出库单创建日期
@@ -34,37 +34,37 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 库位ID
/// </summary>
public string? location_id { get; set; }
public string location_id { get; set; }
/// <summary>
/// 库位编号
/// </summary>
public string? location_code { get; set; }
public string location_code { get; set; }
/// <summary>
/// 载具ID
/// </summary>
public string? carry_id { get; set; }
public string carry_id { get; set; }
/// <summary>
/// 载具编号
/// </summary>
public string? carry_code { get; set; }
public string carry_code { get; set; }
/// <summary>
/// 产品ID
/// </summary>
public string? material_id { get; set; }
public string material_id { get; set; }
/// <summary>
/// 产品编号
/// </summary>
public string? material_code { get; set; }
public string material_code { get; set; }
/// <summary>
/// 齐套搭配方案ID
/// </summary>
public string? collocation_scheme_id { get; set; }
public string collocation_scheme_id { get; set; }
/// <summary>
/// 齐套搭配方案编号
@@ -74,7 +74,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 来源单据ID
/// </summary>
public string? source_id { get; set; }
public string source_id { get; set; }
/// <summary>
@@ -85,12 +85,12 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 创建用户ID
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
/// <summary>
/// MES齐套出库明细表输入
/// </summary>
public List<MESKittingOutStkDInput>? wmsKittingoutDs { get; set; }
public List<MESKittingOutStkDInput> wmsKittingoutDs { get; set; }
}
/// <summary>
@@ -108,33 +108,33 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 单位编号
/// </summary>
public string? unit_code { get; set; }
public string unit_code { get; set; }
/// <summary>
/// 产品ID
/// </summary>
public string? material_id { get; set; }
public string material_id { get; set; }
/// <summary>
/// 产品编号
/// </summary>
public string? material_code { get; set; }
public string material_code { get; set; }
/// <summary>
/// 批次
/// </summary>
public string? code_batch { get; set; }
public string code_batch { get; set; }
/// <summary>
/// 数量(件数)
/// </summary>
public decimal? pr_qty { get; set; }
public decimal pr_qty { get; set; }
/// <summary>
/// 箱数
/// </summary>
public int? box { get; set; }
public int box { get; set; }
}
}

View File

@@ -36,7 +36,7 @@ namespace Tnb.WarehouseMgr
public async Task<dynamic> MESCarryQuery(MESCarryQueryInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
var results = new List<CarryQueryOutput>();
var data = new List<CarryQueryOutput>();
try
{
var carrys = await _db.Queryable<WmsCarryH>()
@@ -44,7 +44,7 @@ namespace Tnb.WarehouseMgr
.Where((a, b) => a.carry_code.Contains(input.carry_code) || b.bill_name.Contains(input.collocation_scheme_name))
.ToListAsync();
results = carrys.Adapt<List<CarryQueryOutput>>();
data = carrys.Adapt<List<CarryQueryOutput>>();
}
catch (Exception ex)
@@ -52,7 +52,7 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return ToApiResult(results);
return ToApiResult(data);
}
/// <summary>
/// 载具查询返回接口
@@ -64,13 +64,13 @@ namespace Tnb.WarehouseMgr
public async Task<dynamic> MESCarryQueryResult(MESCarryQueryResultInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
var result = new CarryQueryOutput();
var data = new CarryQueryOutput();
try
{
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carry.id).ToListAsync();
result = carry.Adapt<CarryQueryOutput>();
result.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
data = carry.Adapt<CarryQueryOutput>();
data.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
}
catch (Exception ex)
@@ -78,7 +78,7 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, result);
return ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, data);
}
}
}

View File

@@ -92,10 +92,10 @@ namespace Tnb.WarehouseMgr
public async Task<dynamic> MESCollocationSchemeQuery(MESCollocationSchemeQueryInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
var results = new List<CollocationSchemeOutput>();
var data = new List<CollocationSchemeOutput>();
try
{
results = await _db.Queryable<WmsCollocationSchemeH>()
data = await _db.Queryable<WmsCollocationSchemeH>()
.Where(a => a.material_id == input.material_id)
.Select(a => new CollocationSchemeOutput
{
@@ -108,7 +108,7 @@ namespace Tnb.WarehouseMgr
{
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return await ToApiResult(results);
return await ToApiResult(data);
}
}
}

View File

@@ -87,10 +87,10 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
else
{
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 sPoint = it.FirstOrDefault();
@@ -153,6 +153,10 @@ namespace Tnb.WarehouseMgr
}
}
else
{
throw new AppFriendlyException("起始库位不可用或无可用的目标库位",500);
}
await _db.Ado.CommitTranAsync();
}

View File

@@ -89,25 +89,23 @@ namespace Tnb.WarehouseMgr
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
{
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 == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0);
}
int i = 0;
//根据每个载具的起始库位做路径运算
for (i = 0; i < setQty.qty; i++)
for (int i = 0; i < setQty.qty; i++)
{
if (carrys?.Count > 0)
{
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
}
var isOk = false;
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
else
{
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 sPoint = it.FirstOrDefault();
@@ -142,7 +140,6 @@ namespace Tnb.WarehouseMgr
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
}
isOk = await _wareHouseService.GenPreTask(preTasks, null!);
}
if (isOk)
{
@@ -174,6 +171,10 @@ namespace Tnb.WarehouseMgr
it => new BasLocation { is_lock = 1 });
}
}
else
{
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
}
}
@@ -226,24 +227,24 @@ namespace Tnb.WarehouseMgr
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
var dic = new Dictionary<string, object>();
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
var dic = new Dictionary<string, object>();
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
{
data = dic,
};
await PDAWmsEmptyOut(visualDevModelDataCrInput);
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
{
data = dic,
};
await PDAWmsEmptyOut(visualDevModelDataCrInput);
}
catch (Exception ex)
{

View File

@@ -132,71 +132,85 @@ namespace Tnb.WarehouseMgr
public async Task KittingOutByIsToBeShipped()
{
var kittingOuts = await _db.Queryable<WmsKittingoutH>()
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
.OrderBy(a => a.seq)
.ToListAsync();
if (kittingOuts?.Count > 0)
try
{
var grpList = kittingOuts.GroupBy(g => g.location_id).ToList();
foreach (var koGrp in grpList)
var kittingOuts = await _db.Queryable<WmsKittingoutH>()
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
.OrderBy(a => a.seq)
.ToListAsync();
if (kittingOuts?.Count > 0)
{
var locs = await _db.Queryable<BasLocation>().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.).ToString() && it.is_lock == 0).ToListAsync();
if (locs?.Count > 0)
var grpList = kittingOuts.GroupBy(g => g.location_id).ToList();
foreach (var koGrp in grpList)
{
var arr = koGrp.ToArray();
var ko = arr[^arr.Length];
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
var locs = await _db.Queryable<BasLocation>().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.).ToString() && it.is_lock == 0).ToListAsync();
if (locs?.Count > 0)
{
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == ko.location_id);
if (sPoint != null && ePoint != null)
var arr = koGrp.ToArray();
var ko = arr[^arr.Length];
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
{
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points?.Count > 0)
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == ko.location_id);
if (sPoint != null && ePoint != null)
{
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
if (points?.Count > 0)
{
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = ko.biz_type;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
preTask.carry_id = ko!.carry_id!;
preTask.carry_code = ko!.carry_code!;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.require_id = ko.id;
preTask.require_code = ko.bill_code;
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
await _warehouseService.GenPreTask(preTasks, null!);
var subCarrys = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == ko.carry_id).ToListAsync();
var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List<string> { carry.location_id!, ko.location_id! } };
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_lock = 1 });
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = ko.biz_type;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
preTask.carry_id = ko!.carry_id!;
preTask.carry_code = ko!.carry_code!;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.require_id = ko.id;
preTask.require_code = ko.bill_code;
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
await _warehouseService.GenPreTask(preTasks, null!);
var subCarrys = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == ko.carry_id).ToListAsync();
var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List<string> { carry.location_id!, ko.location_id! } };
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_lock = 1 });
}
}
}
else
{
throw new AppFriendlyException("无可用的载具", 500);
}
}
else
{
throw new AppFriendlyException("无可用的库位", 500);
}
}
}
}
catch (Exception)
{
throw;
}
}
public override async Task ModifyAsync(WareHouseUpInput input)