新增,判断目标库位是否可以放置当前载具
This commit is contained in:
@@ -75,6 +75,10 @@ public partial class BasLocation : BaseEntity<string>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
/// <summary>
|
||||
/// 载具规格分类Id
|
||||
/// </summary>
|
||||
public string carrystd_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
|
||||
@@ -15,7 +15,9 @@ using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
@@ -47,8 +49,32 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断最终目标库位是否可以放置当前载具
|
||||
/// </summary>
|
||||
/// <param name="carry">当前载具</param>
|
||||
/// <param name="locDest">目标库位</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
[NonAction]
|
||||
protected Task<bool> IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest)
|
||||
{
|
||||
bool isMatch = false;
|
||||
string errMessage = string.Empty;
|
||||
if (carry == null) throw new ArgumentNullException(nameof(carry));
|
||||
if (locDest == null) throw new ArgumentNullException(nameof(locDest));
|
||||
if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty())
|
||||
{
|
||||
var jsonArr = JArray.Parse(locDest.carrystd_id);
|
||||
var locCarryStdArr = jsonArr.Select(x => x.ToObject<string>()).ToArray();
|
||||
if (locCarryStdArr.Contains(carry.carrystd_id))
|
||||
{
|
||||
isMatch = true;
|
||||
}
|
||||
}
|
||||
return Task.FromResult(isMatch);
|
||||
}
|
||||
|
||||
|
||||
[NonAction]
|
||||
protected async Task DoUpdate(WareHouseUpInput input)
|
||||
{
|
||||
|
||||
@@ -52,6 +52,9 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost]
|
||||
public async Task PackSortingByAdd(WmsCarryMat? carryMat)
|
||||
{
|
||||
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
|
||||
var endLocation = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == secondLocationId);
|
||||
|
||||
var setSortings = await _db.Queryable<WmsSetsortingH>()
|
||||
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq)
|
||||
.ToListAsync();
|
||||
@@ -61,9 +64,14 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var singleSorting = setSortings[^setSortings.Count];
|
||||
var curCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == singleSorting.carry_id);
|
||||
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation);
|
||||
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
|
||||
if (setSortings?.Count > 0 && !onFlag)
|
||||
{
|
||||
var singleSorting = setSortings[^setSortings.Count];
|
||||
|
||||
var setSortingDList = await _db.Queryable<WmsSetsortingD>().Where(it => it.bill_id == singleSorting.id).ToListAsync();
|
||||
if (setSortingDList?.Count > 0)
|
||||
{
|
||||
@@ -141,18 +149,18 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
List<WmsPretaskH> preTasks = new();
|
||||
List<string> locIds = new();
|
||||
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
|
||||
|
||||
var mid = 6;
|
||||
if (carrys.Length > mid)
|
||||
{
|
||||
var leftCarrys = carrys[..mid];
|
||||
var rightCarrys = carrys[mid..];
|
||||
await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
|
||||
await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
|
||||
}
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
@@ -187,9 +195,8 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
private async Task InnerGenPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks)
|
||||
private async Task InnerGenPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks, BasLocation endLocation)
|
||||
{
|
||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == eLocationId);
|
||||
foreach (var carry in carrys)
|
||||
{
|
||||
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
@@ -232,7 +239,7 @@ namespace Tnb.WarehouseMgr
|
||||
};
|
||||
return preTask;
|
||||
}).ToList();
|
||||
if (loc.is_sign == 0)
|
||||
if (endLocation.is_sign == 0)
|
||||
{
|
||||
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user