采购入库代码部分重写,回传bip调整,采购订单接收调整、小件移库到三层货架
This commit is contained in:
@@ -144,4 +144,13 @@ public partial class WmsPurchaseOrderD : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? production_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格
|
||||
/// </summary>
|
||||
public string? material_specification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 型号
|
||||
/// </summary>
|
||||
public string? material_standard { get; set; }
|
||||
}
|
||||
|
||||
@@ -437,7 +437,8 @@ namespace Tnb.WarehouseMgr
|
||||
if (material != null)
|
||||
{
|
||||
wmsPurchaseOrderD.matcode_id = material.id;
|
||||
wmsPurchaseOrderD.matspecification = material.material_specification;
|
||||
wmsPurchaseOrderD.material_specification = material.material_specification;
|
||||
wmsPurchaseOrderD.material_standard = material.material_standard;
|
||||
}
|
||||
wmsPurchaseOrderD.auxprop_gys = detail.auxprop_gys;
|
||||
wmsPurchaseOrderDs.Add(wmsPurchaseOrderD);
|
||||
|
||||
@@ -318,7 +318,6 @@ namespace Tnb.WarehouseMgr
|
||||
.AndIF(input.AvoidBusyPassage, it => !busyPassages.Contains(it.passage))
|
||||
.AndIF(!string.IsNullOrEmpty(input.passage), it => it.passage == input.passage)
|
||||
.ToExpression();
|
||||
|
||||
items = await db.Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -504,7 +503,7 @@ namespace Tnb.WarehouseMgr
|
||||
.LeftJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||
.Where(whereExpr)
|
||||
//.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
|
||||
.OrderBy("b.codeqty desc")
|
||||
.OrderBy("b.codeqty")
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
WmsCarryH = a,
|
||||
|
||||
@@ -235,14 +235,16 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (_wmsCarryCodes.Count > 0)
|
||||
{
|
||||
switch (carryLoc.wh_id)
|
||||
// 没其他情况 先默认原材料
|
||||
wmsMaterialSignH.warehouse_instock_id = WmsWareHouseConst.WAREHOUSE_YCL_ID;
|
||||
switch (wmsMaterialSignH.warehouse_instock_id)
|
||||
{
|
||||
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
|
||||
{
|
||||
try
|
||||
{
|
||||
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
wmsMaterialSignH.warehouse_instock_id = WmsWareHouseConst.WAREHOUSE_YCL_ID;
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
if (endLocations.Count == 0)
|
||||
|
||||
@@ -1808,6 +1808,38 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Ado.BeginTranAsync();
|
||||
await _db.Updateable<OtherOutstockD>().SetColumns(r => r.rk_qty == otherOutstockD_first.rk_qty + input.qty).Where(r => r.id == otherOutstockD_first.id).ExecuteCommandAsync();
|
||||
|
||||
|
||||
//InStockStrategyQuery inStockStrategyInput = null;
|
||||
//List<BasLocation> endlocations = new List<BasLocation>();
|
||||
|
||||
//BasMaterial mat = await _db.Queryable<WmsCarryCode>()
|
||||
// .InnerJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
// .Where((a, b) => a.carry_id == wmsCarryH.id).Select((a, b) => b).FirstAsync();
|
||||
|
||||
//List<string> categorys = new List<string>();
|
||||
//if (!string.IsNullOrEmpty(mat.category_id))
|
||||
//{
|
||||
// categorys = JsonConvert.DeserializeObject<List<string>>(mat.category_id);
|
||||
//}
|
||||
//// 小件物料入外协存储区
|
||||
//BasRegionMat basRegionMat = await _db.Queryable<BasRegionMat>()
|
||||
// .InnerJoin<DictionaryDataEntity>((a, b) => a.material_type == b.Id)
|
||||
// .Where((a, b) => categorys.Contains(b.EnCode)).FirstAsync();
|
||||
//if (basRegionMat != null)
|
||||
//{
|
||||
// inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = basRegionMat.region_id };
|
||||
// endlocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
// Logger.LogInformation($"【ScanInStockByRedis】托盘物料{mat.code} 物料类型id为{basRegionMat.material_type} 配置的入库区域为{basRegionMat.region_code} 托盘{wmsCarryH.carry_code}在检查外协存储区库存时找到可入库位数量为{endlocations.Count}");
|
||||
//}
|
||||
|
||||
//if (endlocations?.Count == 0)
|
||||
//{
|
||||
// inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID };
|
||||
// endlocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
// Logger.LogInformation($"【ScanInStockByRedis】托盘{wmsCarryH.carry_code}在检查采购存储区库存时找到可入库位数量为{endlocations.Count}");
|
||||
//}
|
||||
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new()
|
||||
{
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
|
||||
@@ -2568,8 +2600,8 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
Logger.LogWarning("【DistributeSCWToYCL】" + ex.Message);
|
||||
Logger.LogWarning("【DistributeSCWToYCL】" + ex.StackTrace);
|
||||
Logger.LogWarning("【DistributeSCWToZCC】" + ex.Message);
|
||||
Logger.LogWarning("【DistributeSCWToZCC】" + ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -144,6 +144,8 @@ namespace Tnb.WarehouseMgr
|
||||
case WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID:
|
||||
{
|
||||
wmsOutinStockDetail.source_detail_id = input.disTask.source_id;
|
||||
wmsOutinStockDetail.source_id = input.disTask.require_id;
|
||||
wmsOutinStockDetail.source_code = input.disTask.require_code;
|
||||
wmsOutinStockDetail.source_type = WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -121,71 +121,85 @@ namespace Tnb.WarehouseMgr
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
var instockDs = new List<WmsInstockD>();
|
||||
WmsInstockD? instockD = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = item.codeqty,
|
||||
qty = 0,
|
||||
code_batch = item.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID,
|
||||
print_qty = item.codeqty,
|
||||
scan_qty = item.codeqty,
|
||||
print_id = "",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
instockDs.Add(instockD);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.data.ContainsKey("details"))
|
||||
{
|
||||
instockDs = input.data["details"].Adapt<List<WmsInstockD>>();
|
||||
var instockCodes = new List<WmsInstockCode>();
|
||||
|
||||
List<WmsCarryCode> wmsCarryCodes = await _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == carry.id).ToListAsync();
|
||||
|
||||
wmsCarryCodes.GroupBy(g => new { g.material_id, g.code_batch }).Select(
|
||||
r =>
|
||||
{
|
||||
var list = r.ToList();
|
||||
decimal qty = list.Sum(x=>x.codeqty);
|
||||
|
||||
WmsInstockD? instockD = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = qty,
|
||||
qty = 0,
|
||||
code_batch = r.Key.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID,
|
||||
print_qty = qty,
|
||||
scan_qty = qty,
|
||||
print_id = "",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
instockDs.Add(instockD);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.data.ContainsKey("details"))
|
||||
{
|
||||
instockDs = input.data["details"].Adapt<List<WmsInstockD>>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var row in list)
|
||||
{
|
||||
WmsInstockCode? instockCode = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockCode = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
bill_d_id = instockD?.id ?? string.Empty,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
barcode = row.barcode,
|
||||
code_batch = row.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
codeqty = row.codeqty,
|
||||
is_lock = 0,
|
||||
is_end = 0,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
instockCodes.Add(instockCode);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WmsInstockCode? instockCode = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockCode = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
bill_d_id = instockD?.id ?? string.Empty,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
barcode = carryCode,
|
||||
code_batch = item.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
codeqty = item.codeqty,
|
||||
is_lock = 0,
|
||||
is_end = 0,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
_ = await _db.Insertable(instock).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(instockDs).ExecuteCommandAsync();
|
||||
if (instockCode != null)
|
||||
{
|
||||
_ = await _db.Insertable(instockCode).ExecuteCommandAsync();
|
||||
}
|
||||
_ = await _db.Insertable(instockCodes).ExecuteCommandAsync();
|
||||
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1 };
|
||||
@@ -260,21 +274,26 @@ namespace Tnb.WarehouseMgr
|
||||
return preTask;
|
||||
}).ToList();
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (WmsPretaskH? pt in preTasks)
|
||||
|
||||
foreach (var wmsCarryCode in wmsCarryCodes)
|
||||
{
|
||||
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.material_specification = instockCode.material_specification;
|
||||
ptc.container_no = instockCode.container_no;
|
||||
ptc.unit_id = instockCode.unit_id;
|
||||
ptc.code_batch = instockCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
foreach (WmsPretaskH? pt in preTasks)
|
||||
{
|
||||
WmsPretaskCode ptc = pt.Adapt<WmsPretaskCode>();
|
||||
ptc.id = SnowflakeIdHelper.NextId();
|
||||
ptc.bill_id = pt.id;
|
||||
ptc.material_id = wmsCarryCode.material_id;
|
||||
ptc.material_code = wmsCarryCode.material_code;
|
||||
ptc.barcode = wmsCarryCode.barcode;
|
||||
ptc.codeqty = wmsCarryCode.codeqty;
|
||||
ptc.material_specification = item.material_specification;
|
||||
ptc.container_no = item.container_no;
|
||||
ptc.unit_id = item.unit_id;
|
||||
ptc.code_batch = wmsCarryCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
}
|
||||
}
|
||||
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
if (isOk)
|
||||
{
|
||||
@@ -288,49 +307,49 @@ namespace Tnb.WarehouseMgr
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//生成操作记录
|
||||
WmsHandleH handleH = new()
|
||||
{
|
||||
org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!,
|
||||
startlocation_id = loc.id,
|
||||
endlocation_id = endLocations![0].id,
|
||||
bill_code = instock.bill_code,
|
||||
biz_type = instock.biz_type,
|
||||
carry_id = carry.id,
|
||||
carry_code = carry.carry_code,
|
||||
require_id = instock.id,
|
||||
require_code = instock.bill_code,
|
||||
create_id = _userManager.User == null ? "" : _userManager.UserId!,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
preTaskUpInput.PreTaskRecord = handleH;
|
||||
////生成操作记录
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!,
|
||||
// startlocation_id = loc.id,
|
||||
// endlocation_id = endLocations![0].id,
|
||||
// bill_code = instock.bill_code,
|
||||
// biz_type = instock.biz_type,
|
||||
// carry_id = carry.id,
|
||||
// carry_code = carry.carry_code,
|
||||
// require_id = instock.id,
|
||||
// require_code = instock.bill_code,
|
||||
// create_id = _userManager.User == null ? "" : _userManager.UserId!,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
|
||||
//生成操作记录条码表
|
||||
WmsHandleCode handleCode = instockCode.Adapt<WmsHandleCode>();
|
||||
handleCode.id = SnowflakeIdHelper.NextId();
|
||||
handleCode.org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!;
|
||||
handleCode.bill_id = handleH.id;
|
||||
handleCode.create_id = _userManager.User == null ? "" : _userManager.UserId!;
|
||||
handleCode.create_time = DateTime.Now;
|
||||
preTaskUpInput.PreTaskHandleCodes.Add(handleCode);
|
||||
////生成操作记录条码表
|
||||
//WmsHandleCode handleCode = instockCode.Adapt<WmsHandleCode>();
|
||||
//handleCode.id = SnowflakeIdHelper.NextId();
|
||||
//handleCode.org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!;
|
||||
//handleCode.bill_id = handleH.id;
|
||||
//handleCode.create_id = _userManager.User == null ? "" : _userManager.UserId!;
|
||||
//handleCode.create_time = DateTime.Now;
|
||||
//preTaskUpInput.PreTaskHandleCodes.Add(handleCode);
|
||||
|
||||
//生成载具条码表
|
||||
WmsCarryCode wmsCarryCode = instockCode.Adapt<WmsCarryCode>();
|
||||
{
|
||||
wmsCarryCode.id = SnowflakeIdHelper.NextId();
|
||||
wmsCarryCode.carry_id = carry.id;
|
||||
wmsCarryCode.is_out = 0;
|
||||
wmsCarryCode.location_id = loc.id;
|
||||
wmsCarryCode.location_code = loc.location_code;
|
||||
wmsCarryCode.warehouse_id = instock.warehouse_id;
|
||||
}
|
||||
_ = await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
|
||||
////生成载具条码表
|
||||
//WmsCarryCode wmsCarryCode = instockCode.Adapt<WmsCarryCode>();
|
||||
//{
|
||||
// wmsCarryCode.id = SnowflakeIdHelper.NextId();
|
||||
// wmsCarryCode.carry_id = carry.id;
|
||||
// wmsCarryCode.is_out = 0;
|
||||
// wmsCarryCode.location_id = loc.id;
|
||||
// wmsCarryCode.location_code = loc.location_code;
|
||||
// wmsCarryCode.warehouse_id = instock.warehouse_id;
|
||||
//}
|
||||
//_ = await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
|
||||
|
||||
//回更状态
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { carry_code = instock!.carry_code!, is_lock = 1, carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 });
|
||||
_ = await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instock.id == it.bill_id).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
@@ -399,11 +418,13 @@ namespace Tnb.WarehouseMgr
|
||||
string biz_type = WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID;
|
||||
string required_type = (await _dbScanInStockByRedis.Queryable<WmsTempCode>().FirstAsync(it => it.barcode == input.data["物料条码"])).required_type;
|
||||
string source_id = (await _dbScanInStockByRedis.Queryable<WmsTempCode>().FirstAsync(it => it.barcode == input.data["物料条码"])).require_id;
|
||||
string source_main_id = "";
|
||||
switch (required_type)
|
||||
{
|
||||
case WmsWareHouseConst.BILLTYPE_PURCHASE_ID:
|
||||
{
|
||||
bill_type = WmsWareHouseConst.BILLTYPE_MATERIALINSTOCK_ID;
|
||||
source_main_id = (await _dbScanInStockByRedis.Queryable<WmsPurchaseD>().FirstAsync(it => it.id == source_id)).bill_id;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.BILLTYPE_OUTSOURCE_ID:
|
||||
@@ -439,77 +460,90 @@ namespace Tnb.WarehouseMgr
|
||||
print_status = WmsWareHouseConst.PRINT_STATUS_PRINTCOMPLETE,
|
||||
is_check = 1,
|
||||
purchase_code = billCode?.ToString() ?? string.Empty,
|
||||
create_id = _userManager.UserId==null?"": _userManager.UserId,
|
||||
create_id = _userManager.UserId == null ? "" : _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
source_id = source_main_id
|
||||
};
|
||||
var instockDs = new List<WmsInstockD>();
|
||||
WmsInstockD? instockD = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = item.codeqty,
|
||||
qty = 0,
|
||||
code_batch = item.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
warehouse_id = whId?.ToString() ?? "1",
|
||||
print_qty = item.codeqty,
|
||||
scan_qty = item.codeqty,
|
||||
print_id = "",
|
||||
create_id = _userManager.UserId == null ? "" : _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
instockDs.Add(instockD);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.data.ContainsKey("details"))
|
||||
{
|
||||
instockDs = input.data["details"].Adapt<List<WmsInstockD>>();
|
||||
var instockCodes = new List<WmsInstockCode>();
|
||||
List<WmsCarryCode> wmsCarryCodes = await _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == carry.id).ToListAsync();
|
||||
|
||||
foreach (var r in wmsCarryCodes.GroupBy(g => new { g.material_id, g.code_batch }))
|
||||
{
|
||||
var list = r.ToList();
|
||||
decimal qty = list.Sum(x => x.codeqty);
|
||||
|
||||
WmsInstockD? instockD = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = qty,
|
||||
qty = 0,
|
||||
code_batch = r.Key.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID,
|
||||
print_qty = qty,
|
||||
scan_qty = qty,
|
||||
print_id = "",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
instockDs.Add(instockD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WmsInstockCode? instockCode = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockCode = new()
|
||||
else
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
bill_d_id = instockD?.id ?? string.Empty,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
barcode = carryCode,//carry code bar_code
|
||||
code_batch = item.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
codeqty = item.codeqty,
|
||||
is_lock = 0,
|
||||
is_end = 0,
|
||||
create_id = _userManager.UserId == null ? "" : _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
if (input.data.ContainsKey("details"))
|
||||
{
|
||||
instockDs = input.data["details"].Adapt<List<WmsInstockD>>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var row in list)
|
||||
{
|
||||
WmsInstockCode? instockCode = null;
|
||||
if (mat != null)
|
||||
{
|
||||
instockCode = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
bill_d_id = instockD?.id ?? string.Empty,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
barcode = row.barcode,
|
||||
code_batch = row.code_batch,
|
||||
material_specification = item.material_specification,
|
||||
container_no = item.container_no,
|
||||
codeqty = row.codeqty,
|
||||
is_lock = 0,
|
||||
is_end = 0,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
instockCodes.Add(instockCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ = await _dbScanInStockByRedis.Insertable(instock).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockH {JsonConvert.SerializeObject(instock)}");
|
||||
_ = await _dbScanInStockByRedis.Insertable(instockDs).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockD {JsonConvert.SerializeObject(instockDs)}");
|
||||
if (instockCode != null)
|
||||
if (instockCodes != null)
|
||||
{
|
||||
_ = await _dbScanInStockByRedis.Insertable(instockCode).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockCode {JsonConvert.SerializeObject(instockCode)}");
|
||||
_ = await _dbScanInStockByRedis.Insertable(instockCodes).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockCode {JsonConvert.SerializeObject(instockCodes)}");
|
||||
}
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID };
|
||||
@@ -593,20 +627,23 @@ namespace Tnb.WarehouseMgr
|
||||
return preTask;
|
||||
}).ToList();
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (WmsPretaskH? pt in preTasks)
|
||||
foreach (var wmsCarryCode in wmsCarryCodes)
|
||||
{
|
||||
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.material_specification = instockCode.material_specification;
|
||||
ptc.container_no = instockCode.container_no;
|
||||
ptc.unit_id = instockCode.unit_id;
|
||||
ptc.code_batch = instockCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
foreach (WmsPretaskH? pt in preTasks)
|
||||
{
|
||||
WmsPretaskCode ptc = pt.Adapt<WmsPretaskCode>();
|
||||
ptc.id = SnowflakeIdHelper.NextId();
|
||||
ptc.bill_id = pt.id;
|
||||
ptc.material_id = wmsCarryCode.material_id;
|
||||
ptc.material_code = wmsCarryCode.material_code;
|
||||
ptc.barcode = wmsCarryCode.barcode;
|
||||
ptc.codeqty = wmsCarryCode.codeqty;
|
||||
ptc.material_specification = item.material_specification;
|
||||
ptc.container_no = item.container_no;
|
||||
ptc.unit_id = mat.unit_id;
|
||||
ptc.code_batch = wmsCarryCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
}
|
||||
}
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes, _dbScanInStockByRedis);
|
||||
if (isOk)
|
||||
@@ -621,37 +658,37 @@ namespace Tnb.WarehouseMgr
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//生成操作记录
|
||||
WmsHandleH handleH = new()
|
||||
{
|
||||
org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!,
|
||||
startlocation_id = loc.id,
|
||||
endlocation_id = endLocations![0].id,
|
||||
bill_code = instock.bill_code,
|
||||
biz_type = instock.biz_type,
|
||||
carry_id = carry.id,
|
||||
carry_code = carry.carry_code,
|
||||
require_id = instock.id,
|
||||
require_code = instock.bill_code,
|
||||
create_id = _userManager.User == null ? "" : _userManager.UserId!,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
preTaskUpInput.PreTaskRecord = handleH;
|
||||
////生成操作记录
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!,
|
||||
// startlocation_id = loc.id,
|
||||
// endlocation_id = endLocations![0].id,
|
||||
// bill_code = instock.bill_code,
|
||||
// biz_type = instock.biz_type,
|
||||
// carry_id = carry.id,
|
||||
// carry_code = carry.carry_code,
|
||||
// require_id = instock.id,
|
||||
// require_code = instock.bill_code,
|
||||
// create_id = _userManager.User == null ? "" : _userManager.UserId!,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
|
||||
//生成操作记录条码表
|
||||
WmsHandleCode handleCode = instockCode.Adapt<WmsHandleCode>();
|
||||
handleCode.id = SnowflakeIdHelper.NextId();
|
||||
handleCode.org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!;
|
||||
handleCode.bill_id = handleH.id;
|
||||
handleCode.create_id = _userManager.User == null ? "" : _userManager.UserId!;
|
||||
handleCode.create_time = DateTime.Now;
|
||||
preTaskUpInput.PreTaskHandleCodes.Add(handleCode);
|
||||
////生成操作记录条码表
|
||||
//WmsHandleCode handleCode = instockCode.Adapt<WmsHandleCode>();
|
||||
//handleCode.id = SnowflakeIdHelper.NextId();
|
||||
//handleCode.org_id = _userManager.User == null ? "" : _userManager.User.OrganizeId!;
|
||||
//handleCode.bill_id = handleH.id;
|
||||
//handleCode.create_id = _userManager.User == null ? "" : _userManager.UserId!;
|
||||
//handleCode.create_time = DateTime.Now;
|
||||
//preTaskUpInput.PreTaskHandleCodes.Add(handleCode);
|
||||
|
||||
//回更状态
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { carry_code = instock!.carry_code!, is_lock = 1, carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 }, _dbScanInStockByRedis);
|
||||
_ = await _dbScanInStockByRedis.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instock.id == it.bill_id).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IThirdApiRecordService _thirdApiRecordService;
|
||||
public static SemaphoreSlim s_SaveCheckResult = new(1);
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
public WmsPurchaseDService(
|
||||
@@ -66,13 +67,24 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
await s_SaveCheckResult.WaitAsync();
|
||||
string id = dic["id"];
|
||||
string qcRes = dic["qc_res"];
|
||||
WmsPurchaseD wmsPurchaseD = await _db.Queryable<WmsPurchaseD>().SingleAsync(x => x.id == id);
|
||||
string purchaseHId = wmsPurchaseD?.bill_id ?? "";
|
||||
WmsPurchaseH wmsPurchaseH = await _db.Queryable<WmsPurchaseH>().SingleAsync(x => x.id == purchaseHId);
|
||||
|
||||
|
||||
#region 插入质检记录
|
||||
if (!string.IsNullOrEmpty(wmsPurchaseD.qc_res) && wmsPurchaseD.qc_res != "await")
|
||||
{
|
||||
throw Oops.Bah("当前收货明细行已操作过质检");
|
||||
}
|
||||
// 待检
|
||||
if (string.IsNullOrEmpty(qcRes) || qcRes == "await")
|
||||
{
|
||||
return "保存成功";
|
||||
}
|
||||
|
||||
|
||||
string? create_id = _userManager.User.Id;
|
||||
|
||||
@@ -101,28 +113,24 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//自制的采购入库 不在质检保存里调用erp接口
|
||||
if (string.IsNullOrEmpty(wmsPurchaseH.erp_bill_code))
|
||||
{
|
||||
return "保存成功";
|
||||
}
|
||||
|
||||
List<WmsOutinStockDetail> wmsOutinStockDetails = await _db.Queryable<WmsOutinStockDetail>()
|
||||
.Where(x => x.source_detail_id == wmsPurchaseD.id && x.source_type == WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID)
|
||||
.ToListAsync();
|
||||
|
||||
// 托盘对应入库单
|
||||
List<WmsInstockH> instock_mains = await _db.Queryable<WmsInstockH>().Where(x => x.source_id == wmsPurchaseD.bill_id).ToListAsync();
|
||||
|
||||
List<WmsInstockD> allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => instock_mains.Select(r => r.id).Contains(it.bill_id) && it.material_id == wmsPurchaseD.material_id && it.code_batch == wmsPurchaseD.code_batch).ToListAsync();
|
||||
|
||||
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
||||
List<string> carryIds = wmsOutinStockDetails.Select(x => x.carry_id).ToList();
|
||||
List<string> carryIds = instock_mains.Select(x => x.carry_id).ToList();
|
||||
string wmsPurchaseOrderHId = wmsPurchaseH?.erp_bill_code ?? "";
|
||||
WmsPurchaseOrderH wmsPurchaseOrderH = await _db.Queryable<WmsPurchaseOrderH>().SingleAsync(x => x.id == wmsPurchaseOrderHId);
|
||||
WmsPurchaseOrderD wmsPurchaseOrderDs = await _db.Queryable<WmsPurchaseOrderD>().FirstAsync(x => x.fk_wms_purchase_order_id == wmsPurchaseOrderHId);
|
||||
|
||||
foreach (var wmsOutinStockDetail in wmsOutinStockDetails)
|
||||
{
|
||||
WmsDistaskH wmsDistaskH = await _db.Queryable<WmsDistaskH>().FirstAsync(x=>x.bill_code==wmsOutinStockDetail.distask_code);
|
||||
WmsInstockH instock = await _db.Queryable<WmsInstockH>().SingleAsync(x=>x.id==wmsDistaskH.require_id);
|
||||
List<WmsInstockD> allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == instock.id).ToListAsync();
|
||||
|
||||
List<String> materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList();
|
||||
List<String> unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().ToList();
|
||||
List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()
|
||||
@@ -139,7 +147,7 @@ namespace Tnb.WarehouseMgr
|
||||
// tableIds.Add(_userManager.UserId);
|
||||
// tableIds.Add(wmsPurchaseH.create_id);
|
||||
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
||||
tableIds.Add(instock.warehouse_id);// 1001A11000000002OOGU
|
||||
tableIds.Add(instock_mains[0].warehouse_id);// 1001A11000000002OOGU
|
||||
tableIds.AddRange(materialIds);
|
||||
tableIds.Add(supplierId);
|
||||
tableIds.Add(tranTypeId);
|
||||
@@ -180,7 +188,7 @@ namespace Tnb.WarehouseMgr
|
||||
erpRequestData.Add("pk_org", erpOrg.pk_org);
|
||||
erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
||||
erpRequestData.Add("pk_group", erpOrg.pk_group);
|
||||
erpRequestData.Add("vbillcode", instock.bill_code);
|
||||
erpRequestData.Add("vbillcode", wmsPurchaseH.bill_code);
|
||||
erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? "");
|
||||
erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? "");
|
||||
|
||||
@@ -205,7 +213,7 @@ namespace Tnb.WarehouseMgr
|
||||
["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "",
|
||||
["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "",
|
||||
["dbizdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
["dbizdate"] = wmsPurchaseH.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
["nnum"] = item.qty,
|
||||
["nshouldnum"] = item.pr_qty,
|
||||
// ["pk_creqwareid"] = erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "",
|
||||
@@ -284,6 +292,10 @@ namespace Tnb.WarehouseMgr
|
||||
Log.Error(e.Message,e);
|
||||
throw Oops.Bah(e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SaveCheckResult.Release();
|
||||
}
|
||||
|
||||
return "保存成功";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user