齐套分拣,齐套出库,业务代码调整

This commit is contained in:
2023-06-29 18:08:12 +08:00
parent 3a1c2ad1f0
commit 31fdfd66c9
5 changed files with 130 additions and 93 deletions

View File

@@ -10,6 +10,8 @@ namespace Tnb.WarehouseMgr.Entities.Consts
{ {
public class WmsWareHouseConst public class WmsWareHouseConst
{ {
public const string WAREHOUSE_ZC_ID = "2";
/// <summary> /// <summary>
/// 出入库单据状态TypeID /// 出入库单据状态TypeID
/// </summary> /// </summary>
@@ -93,7 +95,7 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// <summary> /// <summary>
/// 单据状态-已呼叫 /// 单据状态-已呼叫
/// </summary> /// </summary>
public const string BILLSTATUS_CALLED_ID = "25065138925589"; public const string BILLSTATUS_CALLED_ID = "26169430480933";
/// <summary> /// <summary>
/// 单据状态-待配送 /// 单据状态-待配送
/// </summary> /// </summary>

View File

@@ -24,10 +24,6 @@ public partial class WmsKittingoutD : BaseEntity<string>
/// </summary> /// </summary>
public string bill_id { get; set; } = string.Empty; public string bill_id { get; set; } = string.Empty;
/// <summary>
/// 行号
/// </summary>
public int bill_line { get; set; }
/// <summary> /// <summary>
/// 物品ID /// 物品ID
@@ -67,7 +63,7 @@ public partial class WmsKittingoutD : BaseEntity<string>
/// <summary> /// <summary>
/// 实际数量(件数) /// 实际数量(件数)
/// </summary> /// </summary>
public decimal real_qty { get; set; } public decimal qty { get; set; }
/// <summary> /// <summary>
/// 实际箱数 /// 实际箱数

View File

@@ -24,11 +24,6 @@ public partial class WmsSetsortingD : BaseEntity<string>
/// </summary> /// </summary>
public string bill_id { get; set; } = string.Empty; public string bill_id { get; set; } = string.Empty;
/// <summary>
/// 行号
/// </summary>
public int bill_line { get; set; }
/// <summary> /// <summary>
/// 物品ID /// 物品ID
/// </summary> /// </summary>

View File

@@ -55,6 +55,10 @@ namespace Tnb.WarehouseMgr
.ToListAsync(); .ToListAsync();
var items = await _db.Queryable<WmsSetsortingH>().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).ToListAsync(); var items = await _db.Queryable<WmsSetsortingH>().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).ToListAsync();
var onFlag = items?.Count > 0; var onFlag = items?.Count > 0;
try
{
await _db.Ado.BeginTranAsync();
if (setSortings?.Count > 0 && !onFlag) if (setSortings?.Count > 0 && !onFlag)
{ {
var singleSorting = setSortings[^setSortings.Count]; var singleSorting = setSortings[^setSortings.Count];
@@ -66,8 +70,8 @@ namespace Tnb.WarehouseMgr
List<string> carryIds = new(); List<string> carryIds = new();
foreach (var os in setSortingDList) foreach (var os in setSortingDList)
{ {
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id) var 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((a, b) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.) .Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus. && c.wh_id == os.warehouse_id)
.WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch) .WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch)
.Select<WmsCarryCode>() .Select<WmsCarryCode>()
.ToListAsync(); .ToListAsync();
@@ -79,7 +83,22 @@ namespace Tnb.WarehouseMgr
{ {
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500); throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
} }
var partCarryMats = carryCodesPart.Adapt<List<WmsCarryMat>>(); List<WmsCarryCode> curCarryCodes = new();
for (int i = 0; i < carryCodesPart.Count; i++)
{
if (os.pr_qty > carryCodesPart[i].codeqty)
{
os.pr_qty -= carryCodesPart[i].codeqty;
curCarryCodes.Add(carryCodesPart[i]);
}
else if (os.pr_qty <= carryCodesPart[i].codeqty)
{
carryCodesPart[i].codeqty = os.pr_qty;
curCarryCodes.Add(carryCodesPart[i]);
break;
}
}
var partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
for (int i = 0; i < partCarryMats.Count; i++) for (int i = 0; i < partCarryMats.Count; i++)
{ {
partCarryMats[i].need_qty = carryCodesPart[i].codeqty; partCarryMats[i].need_qty = carryCodesPart[i].codeqty;
@@ -103,7 +122,7 @@ namespace Tnb.WarehouseMgr
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty); var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList(); carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString(), collocation_scheme_id = singleSorting.collocation_scheme_id, collocation_scheme_code = singleSorting.collocation_scheme_code }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();
//天益项目不需要 //天益项目不需要
//await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync(); //await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
} }
@@ -137,15 +156,24 @@ namespace Tnb.WarehouseMgr
}); });
pretaskCodes.AddRange(curPreTaskCodes); pretaskCodes.AddRange(curPreTaskCodes);
} }
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).ExecuteCommandAsync();
GenPreTaskUpInput genPreTaskAfterUpInput = new(); GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_use = (int)EnumCarryStatus. }); await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_use = (int)EnumCarryStatus., is_lock = 1 });
} }
} }
} }
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
throw;
}
} }
private async Task _genPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks) private async Task _genPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks)
@@ -179,7 +207,7 @@ namespace Tnb.WarehouseMgr
preTask.end_floor = ePoint?.floor.ToString(); preTask.end_floor = ePoint?.floor.ToString();
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_WMSOUTSTOCK_ID; preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSSETSORTING_ID;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
preTask.carry_id = carry.id; preTask.carry_id = carry.id;
preTask.carry_code = carry.carry_code; preTask.carry_code = carry.carry_code;
@@ -211,8 +239,21 @@ namespace Tnb.WarehouseMgr
{ {
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.).ToString(), location_id = null, location_code = null }).ExecuteCommandAsync(); var carryId = input.carryIds[^input.carryIds.Count];
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = (int)EnumCarryStatus. }).ExecuteCommandAsync(); var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
if (carry != null)
{
if (carry.location_id.IsNotEmptyOrNull())
{
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = (int)EnumCarryStatus. }).Where(it => it.id == carry.location_id).ExecuteCommandAsync();
}
carry.out_status = ((int)EnumOutStatus.).ToString();
carry.carry_status = ((int)EnumCarryStatus.).ToString();
carry.location_id = null;
carry.location_code = null;
await _db.Updateable(carry).UpdateColumns(it => new { it.out_status,it.carry_status, it.location_id, it.location_code }).ExecuteCommandAsync();
await _db.Deleteable<WmsCarryMat>().Where(it => it.carry_id == carryId).ExecuteCommandAsync();
}
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }

View File

@@ -83,6 +83,7 @@ namespace Tnb.WarehouseMgr
if (!isCalled) if (!isCalled)
{ {
var setSortingH = ko.Adapt<WmsSetsortingH>(); var setSortingH = ko.Adapt<WmsSetsortingH>();
setSortingH.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
setSortingH.id = SnowflakeIdHelper.NextId(); setSortingH.id = SnowflakeIdHelper.NextId();
setSortingH.kittingout_id = ko.id; setSortingH.kittingout_id = ko.id;
setSortingH.seq = ko.seq; setSortingH.seq = ko.seq;
@@ -91,11 +92,13 @@ namespace Tnb.WarehouseMgr
setSortingH.create_time = DateTime.Now; setSortingH.create_time = DateTime.Now;
await _db.Insertable(setSortingH).ExecuteCommandAsync(); await _db.Insertable(setSortingH).ExecuteCommandAsync();
var kittingOutDetails = await _db.Queryable<WmsKittingoutD>().Where(it => it.bill_id == setSortingH.id).ToListAsync(); var kittingOutDetails = await _db.Queryable<WmsKittingoutD>().Where(it => it.bill_id == ko.id).ToListAsync();
var setSortDetails = kittingOutDetails.Adapt<List<WmsSetsortingD>>(); var setSortDetails = kittingOutDetails.Adapt<List<WmsSetsortingD>>();
setSortDetails.ForEach(x => setSortDetails.ForEach(x =>
{ {
x.id = SnowflakeIdHelper.NextId(); x.id = SnowflakeIdHelper.NextId();
x.bill_id = setSortingH.id;
x.warehouse_id = setSortingH.warehouse_id;
x.org_id = _userManager.User.OrganizeId; x.org_id = _userManager.User.OrganizeId;
x.create_id = _userManager.UserId; x.create_id = _userManager.UserId;
x.create_time = DateTime.Now; x.create_time = DateTime.Now;