销售出库与拣货接口以及部分问题修复
This commit is contained in:
@@ -15,6 +15,7 @@ using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -151,35 +152,56 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.carry_id))
|
||||
if (string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
throw new AppFriendlyException("载具id不可为空", 500);
|
||||
throw new AppFriendlyException("载具编号不可为空", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.material_id))
|
||||
{
|
||||
throw new AppFriendlyException("物料不可为空", 500);
|
||||
throw new AppFriendlyException("物料id不可为空", 500);
|
||||
}
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.source_id))
|
||||
{
|
||||
throw new AppFriendlyException("成品调拨明细id不可为空", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.startlocation_id))
|
||||
{
|
||||
throw new AppFriendlyException("起点不可为空", 500);
|
||||
}
|
||||
|
||||
WmsTransferInstockD wmsTransferInstockD = await _db.Queryable<WmsTransferInstockD>().Where(r => r.id == input.source_id).FirstAsync();
|
||||
if (wmsTransferInstockD.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID)
|
||||
{
|
||||
throw new AppFriendlyException("此成品调拨任务已完成,不允许重复提交", 500);
|
||||
}
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
//入库取终点 //出库起点
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1 };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
if (endLocations.Count == 0)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的入库库位", 500);
|
||||
}
|
||||
WmsPointH sPoint = null!;
|
||||
WmsPointH ePoint = null!;
|
||||
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.startlocation_id);
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
|
||||
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
||||
if (carry.carry_status == "1")
|
||||
{
|
||||
throw new AppFriendlyException("载具已占用!", 500);
|
||||
}
|
||||
if (carry.is_lock == 1)
|
||||
{
|
||||
throw new AppFriendlyException("载具已锁定!", 500);
|
||||
}
|
||||
BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||
if (!isMatch)
|
||||
@@ -220,7 +242,7 @@ namespace Tnb.WarehouseMgr
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.carry_id);
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == input.carry_code);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
@@ -244,14 +266,14 @@ namespace Tnb.WarehouseMgr
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = _billRullService!.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSTRANSFERINSTOCK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_TRANSFER_TYPE_ID
|
||||
};
|
||||
preTask.carry_id = input.carry_id;
|
||||
preTask.carry_id = wmsCarryH.id;
|
||||
preTask.carry_code = wmsCarryH.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = "";
|
||||
preTask.require_id = input.source_id;
|
||||
preTask.require_code = "";
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
@@ -272,7 +294,7 @@ namespace Tnb.WarehouseMgr
|
||||
is_lock = 1,
|
||||
location_id = input.startlocation_id,
|
||||
location_code = location.location_code
|
||||
}).Where(it => it.id == input.carry_id).ExecuteCommandAsync();
|
||||
}).Where(it => it.id == wmsCarryH.id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
//所有库位加锁
|
||||
@@ -281,7 +303,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == input.material_id);
|
||||
WmsCarryCode wmsCarryCode = new WmsCarryCode();
|
||||
wmsCarryCode.carry_id = input.carry_id;
|
||||
wmsCarryCode.carry_id = wmsCarryH.id;
|
||||
wmsCarryCode.barcode = wmsCarryH.carry_code;
|
||||
wmsCarryCode.codeqty = input.qty;
|
||||
wmsCarryCode.material_id = input.material_id;
|
||||
@@ -289,16 +311,34 @@ namespace Tnb.WarehouseMgr
|
||||
wmsCarryCode.material_name = basMaterial.name;
|
||||
wmsCarryCode.location_id = endLocations[0].id;
|
||||
wmsCarryCode.location_code = endLocations[0].location_code;
|
||||
wmsCarryCode.code_batch = wmsTransferInstockD.pi_code;
|
||||
_ = await _db.Insertable<WmsCarryCode>(wmsCarryCode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 更新成品调拨入库单子表已下发数量
|
||||
await _db.Updateable<WmsTransferInstockD>().SetColumns(r => r.xf_qty == r.xf_qty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
|
||||
// 已下发数量达到需求数量回写已完成
|
||||
wmsTransferInstockD = await _db.Queryable<WmsTransferInstockD>().Where(r => r.id == input.source_id).FirstAsync();
|
||||
if (wmsTransferInstockD.xf_qty == wmsTransferInstockD.pr_qty)
|
||||
{
|
||||
await _db.Updateable<WmsTransferInstockD>().SetColumns(r => r.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
// 入库明细都完成 回写主表完成状态
|
||||
List<WmsTransferInstockD> wmsTransferInstockDs =_db.Queryable<WmsTransferInstockD>().InnerJoin<WmsTransferInstockD>((a, b) => a.bill_id == b.bill_id).Where((a, b) => a.id == input.source_id)
|
||||
.Where((a, b) => b.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList();
|
||||
if (wmsTransferInstockDs.Count == 0)
|
||||
{
|
||||
await _db.Updateable<WmsTransferInstockH>().SetColumns(r =>r.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).Where(r => r.id == wmsTransferInstockD.bill_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
@@ -325,8 +365,7 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException("起点id不可为空", 500);
|
||||
}
|
||||
|
||||
if (input.location_id != WmsWareHouseConst.FinishproductOutstockStation1 && input.location_id != WmsWareHouseConst.FinishproductOutstockStation2
|
||||
&& input.location_id != WmsWareHouseConst.FinishproductOutstockStation3)
|
||||
if (!_wareHouseService.GetFloor1OutstockLocation().Contains(input.location_id))
|
||||
{
|
||||
throw new AppFriendlyException("非一楼出库库位不允许通过此功能解锁", 500);
|
||||
}
|
||||
@@ -356,40 +395,6 @@ namespace Tnb.WarehouseMgr
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3楼到1楼出库 盘点签收 解锁一楼库位
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> FinishproductOutstockSort(FinishproductOutstockSortInput input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.carry_id))
|
||||
{
|
||||
throw new AppFriendlyException("载具id不可为空", 500);
|
||||
}
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
}
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
await _db.Updateable<WmsCarryCode>().SetColumns(r => new WmsCarryCode
|
||||
{
|
||||
codeqty = input.qty,
|
||||
}).Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user