diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
index d0021eaf..a308d713 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
@@ -258,10 +258,18 @@
///
public const string BIZTYPE_WMSEMPTYINSTOCK_ID = "26121986416677";
///
+ /// 预任务生成业务类型-签收回库 todo
+ ///
+ public const string BIZTYPE_WmsMaterialSign_ID = "BIZTYPE_WmsMaterialSign_ID";
+ ///
/// 预任务生成业务类型-载具移入
///
public const string BIZTYPE_CARRYMOVEINSTOCK_ID = "26121988909861";
///
+ /// 预任务生成业务类型-成品调拨出库 todo
+ ///
+ public const string BIZTYPE_WmsTransferOutstock_ID = "BIZTYPE_WmsTransferOutstock_ID";
+ ///
/// 预任务生成业务类型-库内转移
///
public const string BIZTYPE_WMSTRANSFER_ID = "26125644258853";
@@ -310,6 +318,10 @@
///
public const string BIZTYPE_WMSMATERIALTRANSFER_ID = "34354738929685";
///
+ /// 预任务生成业务类型-调拨出库单(原材料)
+ ///
+ public const string BIZTYPE_WmsRawmatTransferoutstock_ID = "BIZTYPE_WmsRawmatTransferoutstock_ID";
+ ///
/// 预任务生成业务类型-生产退料单 todo
///
public const string BIZTYPE_PRDRETURN_ID = "BIZTYPE_PRDRETURN_ID";
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/TransferOrderInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/TransferOrderInput.cs
index 8fa89402..2414ff3b 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/TransferOrderInput.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/TransferOrderInput.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Transactions;
namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
{
@@ -43,6 +44,12 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
///
public string? erp_pk { get; set; }
+ ///
+ /// 交易类型
+ ///
+ public string? transaction_type { get; set; }
+
+
public List details { get; set; }
}
public class TransferOrderInputDetail
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CarryMaterialInventoryInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CarryMaterialInventoryInput.cs
new file mode 100644
index 00000000..9326e0ce
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CarryMaterialInventoryInput.cs
@@ -0,0 +1,21 @@
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 库房业务更新输入参数
+ ///
+ public class CarryMaterialInventoryInput
+ {
+ ///
+ /// 仓库编码
+ ///
+ public string? warehouse_code { get; set; }
+ ///
+ /// 物料id
+ ///
+ public string? material_id { get; set; }
+ ///
+ /// 批次
+ ///
+ public string? code_batch { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RawmatTransferoutstockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RawmatTransferoutstockInput.cs
new file mode 100644
index 00000000..d256999c
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RawmatTransferoutstockInput.cs
@@ -0,0 +1,29 @@
+using Tnb.WarehouseMgr.Entities.Consts;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 库房业务更新输入参数
+ ///
+ public class RawmatTransferoutstockInput
+ {
+ ///
+ /// 组织ID
+ ///
+ public string org_id { get; set; } = WmsWareHouseConst.AdministratorOrgId;
+ ///
+ /// 创建用户
+ ///
+ public string create_id { get; set; }
+
+ ///
+ /// 来源单据id
+ ///
+ public string? source_id { get; set; }
+
+ ///
+ /// 载具
+ ///
+ public List carrys { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs
new file mode 100644
index 00000000..95ca57bf
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs
@@ -0,0 +1,24 @@
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 库房业务更新输入参数
+ ///
+ public class WmsTransferOutstockInput
+ {
+ ///
+ /// 组织ID
+ ///
+ public string org_id { get; set; }
+ ///
+ /// 创建用户
+ ///
+ public string create_id { get; set; }
+ ///
+ /// 物料数量
+ ///
+ public decimal qty { get; set; }
+ /// 来源单据id
+ ///
+ public string? source_id { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs
index e0203850..13dfdcfd 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs
@@ -123,4 +123,14 @@ public partial class WmsPurchaseD : BaseEntity
/// 已绑定数量
///
public decimal? bind_qty { get; set; }
+
+ ///
+ /// 单价
+ ///
+ public decimal? price { get; set; }
+
+ ///
+ /// 是否赠品
+ ///
+ public int? gift { get; set; }
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs
index f9304917..0b8ccf38 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs
@@ -159,4 +159,9 @@ public partial class WmsPurchaseH : BaseEntity, IPurchaseAndSaleAuitEnti
/// erp到货单主表pk
///
public string erp_arriveorder_pk { get;set; }
+
+ ///
+ /// 来源
+ ///
+ public string create_origin { get; set; }
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTransferOrderH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTransferOrderH.cs
index bdfc9d82..42db65e5 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTransferOrderH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTransferOrderH.cs
@@ -79,4 +79,9 @@ public partial class WmsTransferOrderH : BaseEntity
///
public string? biller { get; set; }
+ ///
+ /// 交易类型
+ ///
+ public string? transaction_type { get; set; }
+
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
index 41ac9d7a..17c07277 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
@@ -108,6 +108,13 @@ namespace Tnb.WarehouseMgr.Interfaces
///
string[] GetFloor1GLSGWOutstockLocation();
+ ///
+ /// 是否为原材料调拨出库库位
+ ///
+ ///
+ ///
+ string[] GetFloor1YCLDBOutstockLocation();
+
///
/// 是否为外协三工位库位
///
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
index 52af1347..c9816d06 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
@@ -1001,8 +1001,19 @@ namespace Tnb.WarehouseMgr
wmsTransferOrderH.create_id = WmsWareHouseConst.ErpUserId;
wmsTransferOrderH.create_time = DateTime.Now;
wmsTransferOrderH.org_id = WmsWareHouseConst.AdministratorOrgId;
- await db.Insertable(wmsTransferOrderH).ExecuteCommandAsync();
+ var _erpExtendField = await db.Queryable().InnerJoin((a, b) => a.table_id == b.Id)
+ .Where((a, b) => a.transaction_type_id == input.transaction_type).Select((a, b) => b).FirstAsync();
+ if (_erpExtendField != null)
+ {
+ wmsTransferOrderH.transaction_type = _erpExtendField.EnCode;
+ }
+ else
+ {
+ _LoggerErp2Mes.LogWarning($@"【TransferOrder】表头交易类型{input.transaction_type}在wms系统中未找到!");
+ throw new AppFriendlyException($@"表头交易类型{input.transaction_type}在wms系统中未找到!", 500);
+ }
+ await db.Insertable(wmsTransferOrderH).ExecuteCommandAsync();
List wmsTransferOrderDs = new List();
foreach (var detail in input.details)
@@ -1047,7 +1058,7 @@ namespace Tnb.WarehouseMgr
if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID)
{
WmsRawmatTransferoutstockH wmsRawmatTransferoutstockH = new WmsRawmatTransferoutstockH();
- string code = await _billRuleService.GetBillNumber("WmsRawmatTransferoutstockH");
+ string code = await _billRuleService.GetBillNumber("RawmatTransferoutstock");
wmsRawmatTransferoutstockH.bill_code = code;
wmsRawmatTransferoutstockH.create_id = WmsWareHouseConst.ErpUserId;
wmsRawmatTransferoutstockH.create_time = DateTime.Now;
@@ -1056,6 +1067,9 @@ namespace Tnb.WarehouseMgr
wmsRawmatTransferoutstockH.warehouse_code = warehouse_outstock.whcode;
wmsRawmatTransferoutstockH.erp_pk = input.erp_pk;
wmsRawmatTransferoutstockH.transfer_order_id = wmsTransferOrderH.bill_code;
+ wmsRawmatTransferoutstockH.issuance_status = "0";
+ wmsRawmatTransferoutstockH.transaction_type = _erpExtendField.EnCode;
+ wmsRawmatTransferoutstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
List wmsRawmatTransferoutstockDs = new List ();
foreach (var detail in input.details)
{
@@ -1073,13 +1087,13 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
}
-
wmsRawmatTransferoutstockD.qty = detail.qty;
wmsRawmatTransferoutstockD.code_batch = detail.code_batch;
wmsRawmatTransferoutstockD.erp_line_pk = detail.erp_line_pk;
wmsRawmatTransferoutstockD.create_id = WmsWareHouseConst.ErpUserId;
wmsRawmatTransferoutstockD.create_time = DateTime.Now;
wmsRawmatTransferoutstockD.lineno = detail.lineno;
+ wmsRawmatTransferoutstockD.actual_qty = 0;
var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync();
if (material != null)
@@ -1098,15 +1112,53 @@ namespace Tnb.WarehouseMgr
else if(warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_CP_ID)
{
WmsTransferOutstockH wmsTransferOutstockH = new WmsTransferOutstockH();
- string code = await _billRuleService.GetBillNumber("WmsTransferOutstockH");
+ string code = await _billRuleService.GetBillNumber("WmsTransferOutstock");
wmsTransferOutstockH.bill_code = code;
wmsTransferOutstockH.create_id = WmsWareHouseConst.ErpUserId;
wmsTransferOutstockH.create_time = DateTime.Now;
wmsTransferOutstockH.warehouse_code = warehouse_outstock.whcode;
wmsTransferOutstockH.erp_pk = input.erp_pk;
wmsTransferOutstockH.transfer_order_id = wmsTransferOrderH.bill_code;
+ wmsTransferOutstockH.issuance_status = "0";
+ wmsTransferOutstockH.transaction_type = _erpExtendField.EnCode;
+ wmsTransferOutstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
List wmsTransferOutstockDs = new List();
+ foreach (var detail in input.details)
+ {
+ WmsTransferOutstockD wmsTransferOutstockD = new WmsTransferOutstockD();
+ wmsTransferOutstockD.bill_id = wmsTransferOutstockH.id;
+ var erpExtendField = await db.Queryable().InnerJoin((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
+ if (erpExtendField != null)
+ {
+ wmsTransferOutstockD.unit_id = erpExtendField.Id;
+ wmsTransferOutstockD.unit_code = erpExtendField.EnCode;
+ }
+ else
+ {
+ _LoggerErp2Mes.LogWarning($@"【TransferOrder】表体明细中单位{detail.unit_code}在wms系统中未找到!");
+ throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
+ }
+
+ wmsTransferOutstockD.pr_qty = detail.qty;
+ wmsTransferOutstockD.xf_qty = 0;
+ wmsTransferOutstockD.qty = 0;
+ wmsTransferOutstockD.pi_code = detail.code_batch;
+ wmsTransferOutstockD.erp_line_pk = detail.erp_line_pk;
+ wmsTransferOutstockD.create_id = WmsWareHouseConst.ErpUserId;
+ wmsTransferOutstockD.create_time = DateTime.Now;
+ wmsTransferOutstockD.lineno = detail.lineno;
+
+ var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync();
+ if (material != null)
+ {
+ wmsTransferOutstockD.material_id = material.id;
+ wmsTransferOutstockD.material_code = material.code;
+ wmsTransferOutstockD.material_desc = material.material_specification;
+ }
+
+ wmsTransferOutstockDs.Add(wmsTransferOutstockD);
+ }
await db.Insertable(wmsTransferOutstockH).ExecuteCommandAsync();
await db.Insertable(wmsTransferOutstockDs).ExecuteCommandAsync();
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index c7309dfe..2b48123e 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -395,6 +395,18 @@ namespace Tnb.WarehouseMgr
, WmsWareHouseConst.Floor1GLSGWOutstockStation3, WmsWareHouseConst.Floor1GLSGWOutstockStation4, WmsWareHouseConst.Floor1GLSGWOutstockStation5 };
}
+ ///
+ /// 是否为原材料调拨出库库位
+ ///
+ ///
+ ///
+ public string[] GetFloor1YCLDBOutstockLocation()
+ {
+ return new string[5] { WmsWareHouseConst.Floor1GLSGWOutstockStation1 , WmsWareHouseConst.Floor1GLSGWOutstockStation2
+ , WmsWareHouseConst.Floor1GLSGWOutstockStation3, WmsWareHouseConst.Floor1GLSGWOutstockStation4, WmsWareHouseConst.Floor1GLSGWOutstockStation5 };
+ }
+
+
///
/// 是否为外协三工位库位
///
@@ -432,7 +444,6 @@ namespace Tnb.WarehouseMgr
SqlSugarClient cyDb = _db.CopyNew();
-
List> items = cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
.LeftJoin((a, b, c) => a.location_id == c.id)
.Where(whereExpr)
@@ -3655,8 +3666,8 @@ namespace Tnb.WarehouseMgr
{
Logger.LogInformation($"【CommonCreatePretask】 {ex.Message}");
Logger.LogInformation($"【CommonCreatePretask】 {ex.StackTrace}");
- if (!db.Ado.Transaction.IsNull())
- await db.Ado.CommitTranAsync();
+ //if (!db.Ado.Transaction.IsNull())
+ // await db.Ado.CommitTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
finally
@@ -3669,6 +3680,105 @@ namespace Tnb.WarehouseMgr
}
}
}
+
+ ///
+ /// 可下发载具查询
+ ///
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify, AllowAnonymous]
+ public async Task CarryMaterialInventory(CarryMaterialInventoryInput input)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(input.warehouse_code))
+ {
+ throw new AppFriendlyException("出库仓库不可为空", 500);
+ }
+
+ if (string.IsNullOrEmpty(input.material_id))
+ {
+ throw new AppFriendlyException("物料id不可为空", 500);
+ }
+ if (string.IsNullOrEmpty(input.code_batch))
+ {
+ throw new AppFriendlyException("批号不可为空", 500);
+ }
+
+ BasWarehouse basWarehouse = await _db.Queryable().Where(r => r.whcode == input.warehouse_code).FirstAsync();
+
+ switch (basWarehouse.id)
+ {
+ case WmsWareHouseConst.WAREHOUSE_YCL_ID:
+ {
+ OutStockStrategyQuery outStockStrategyInput = new()
+ {
+ warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
+ material_id = input.material_id,
+ code_batch = input.code_batch,
+ Size = 100,
+ Region_id = WmsWareHouseConst.REGION_Purchase_ID,
+ PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK,
+ AvoidBusyPassage = true
+ };
+
+ List items = await OutStockStrategy(outStockStrategyInput);
+
+ var wmsCarryCodes = await _db.Queryable()
+ .InnerJoin((a, b) => a.carry_id == b.id)
+ .InnerJoin((a, b, c) => a.material_id == c.id)
+ .Where((a, b, c) => items.Select(r => r.id).Contains(a.carry_id))
+ .Select((a, b, c) => new
+ {
+ carry_id = a.carry_id,
+ carry_code = b.carry_code,
+ material_id = c.id,
+ material_code = c.code,
+ material_name = c.name,
+ material_specification = c.material_specification,
+ barcode = a.barcode,
+ code_batch = a.code_batch,
+ qty = a.codeqty
+ })
+ .ToListAsync();
+
+ var wmsCarryCodesSum = wmsCarryCodes.GroupBy(r => new { r.carry_id, r.material_id, r.code_batch }).Select(g =>
+ {
+ var list = g.ToList();
+
+ var newg = new
+ {
+ carry_id = list[0].carry_id,
+ carry_code = list[0].carry_code,
+ material_id = list[0].material_id,
+ material_code = list[0].material_code,
+ material_name = list[0].material_name,
+ material_specification = list[0].material_specification,
+ barcode = list[0].barcode,
+ code_batch = list[0].code_batch,
+ qty = g.Sum(r => r.qty)
+ };
+
+ return newg;
+ });
+
+ return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功", wmsCarryCodesSum);
+ }
+ default:
+ {
+ throw new AppFriendlyException("此仓库业务未完善", 500);
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ await _db.Ado.RollbackTranAsync();
+ return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
+ }
+ }
+
#endregion
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
index 2d74bd06..fac9fbc6 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
@@ -250,6 +250,8 @@ namespace Tnb.WarehouseMgr
List wmsCarrybindCodes = new List();
+ List wmsTempCodes = await _db.Queryable().Where(r => input.details.Select(c => c.barcode).Contains(r.barcode)).ToListAsync();
+
foreach (var detail in input.details)
{
var WmsCarryCode = detail.Adapt();
@@ -261,6 +263,12 @@ namespace Tnb.WarehouseMgr
WmsCarryCode.create_time = DateTime.Now;
WmsCarryCodes.Add(WmsCarryCode);
+ WmsTempCode wmsTempCode = wmsTempCodes.Where(r => r.barcode == detail.barcode).First();
+ if (wmsTempCode == null)
+ {
+ throw new Exception($"条码{wmsTempCode.barcode}在系统中不存在");
+ }
+ wmsTempCode.codeqty = detail.codeqty;
var wmsCarrybindCode = detail.Adapt();
wmsCarrybindCode.carrybind_id = wmsCarrybindH.id;
wmsCarrybindCodes.Add(wmsCarrybindCode);
@@ -271,6 +279,7 @@ namespace Tnb.WarehouseMgr
rows = await _db.Insertable(WmsCarryCodes).ExecuteCommandAsync();
await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync();
await _db.Insertable(wmsCarrybindCodes).ExecuteCommandAsync();
+ await _db.Updateable(wmsTempCodes).ExecuteCommandAsync();
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs
index 6aad3e9a..ba9297ba 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs
@@ -77,8 +77,6 @@ namespace Tnb.WarehouseMgr
throw new ArgumentNullException(nameof(input));
}
- await _db.Ado.BeginTranAsync();
-
WmsCarryH wmsCarryH = await _db.Queryable().Where(r => r.carry_code == input.carry_code).FirstAsync();
if (wmsCarryH == null)
{
@@ -93,7 +91,7 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}未绑定物料", 500);
}
- if (string.IsNullOrEmpty(wmsCarryH.location_id))
+ if (string.IsNullOrEmpty(wmsCarryH.location_id))
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}当前库位为空,无法签收", 500);
}
@@ -106,6 +104,7 @@ namespace Tnb.WarehouseMgr
wmsMaterialSignH.carry_id = wmsCarryH.id;
wmsMaterialSignH.carry_code = wmsCarryH.carry_code;
List wmsMaterialSignDs = new List();
+ await _db.Ado.BeginTranAsync();
foreach (var item in input.details)
{
if (item.sign_qty < 0)
@@ -147,11 +146,9 @@ namespace Tnb.WarehouseMgr
{
CarryCodeUnbindCodeInput carryCodeUnbindCodeInput = new CarryCodeUnbindCodeInput();
await _wmsCarryUnbindService.CarryCodeUnbindCode(carryCodeUnbindCodeInput, _db);
- wmsCarryCodes.Remove(wmsCarryCode);
-
- await _db.Updateable().SetColumns(r => r.codeqty == wmsCarryCode.codeqty - item.sign_qty)
- .Where(r => r.barcode == wmsCarryCode.barcode).ExecuteCommandAsync();
}
+ await _db.Updateable().SetColumns(r => r.codeqty == wmsCarryCode.codeqty)
+ .Where(r => r.barcode == wmsCarryCode.barcode).ExecuteCommandAsync();
}
BasLocation carryLoc = await _db.Queryable().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
@@ -179,21 +176,19 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("没有可以回库的库位", 500);
}
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
- commonCreatePretaskInput.startlocation_id = carryLoc.location_code;
+ commonCreatePretaskInput.startlocation_id = carryLoc.id;
commonCreatePretaskInput.endlocation_id = endLocations[0].id;
commonCreatePretaskInput.carry_id = wmsCarryH.id;
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
- commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
- commonCreatePretaskInput.isExcuteMission = false;
- commonCreatePretaskInput.moduleConsts = ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID;
+ commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WmsMaterialSign_ID;
Logger.LogInformation($"【MaterialSign】 开始生成原材料仓回库任务 起点{carryLoc.location_code} 终点{endLocations[0].location_code} 托盘 {wmsCarryH.carry_code}");
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);
- if (res.code == HttpStatusCode.OK)
+ if (res.code != HttpStatusCode.OK)
{
-
+ throw new AppFriendlyException(res.msg, 500);
}
}
catch (Exception ex)
@@ -210,8 +205,8 @@ namespace Tnb.WarehouseMgr
}
}
- await _db.Updateable(wmsMaterialSignH).ExecuteCommandAsync();
- await _db.Updateable(wmsMaterialSignDs).ExecuteCommandAsync();
+ await _db.Insertable(wmsMaterialSignH).ExecuteCommandAsync();
+ await _db.Insertable(wmsMaterialSignDs).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferoutstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferoutstockService.cs
index 713856be..a65b5c12 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferoutstockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferoutstockService.cs
@@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
+using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -69,58 +70,7 @@ namespace Tnb.WarehouseMgr
}
- ///
- /// 获取物料库存
- ///
- ///
- ///
- ///
- [HttpPost, NonUnify, AllowAnonymous]
- public async Task MaterialInventory(MaterialTransferGetMaterialInventoryInput input)
- {
- try
- {
- if (input.palletCount <= 0)
- {
- throw new AppFriendlyException("托盘数必须大于0", 500);
- }
- if (string.IsNullOrEmpty(input.material_id))
- {
- throw new AppFriendlyException("物料id不可为空", 500);
- }
- if (string.IsNullOrEmpty(input.code_batch))
- {
- throw new AppFriendlyException("批号不可为空", 500);
- }
-
- OutStockStrategyQuery outStockStrategyInput = new()
- {
- warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
- material_id = input.material_id,
- code_batch = input.code_batch,
- Size = input.palletCount,
- Region_id = WmsWareHouseConst.REGION_Purchase_ID,
- PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK,
- AvoidBusyPassage = true
- };
-
- List items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
-
- decimal qty = _db.Queryable().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == input.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty);
-
- JObject keyValuePairs = new JObject();
- keyValuePairs["realPalletCount"] = items.Count;
- keyValuePairs["realInvQty"] = qty;
-
- return await ToApiResult(HttpStatusCode.OK, "成功", keyValuePairs);
- }
- catch (Exception ex)
- {
- await _db.Ado.RollbackTranAsync();
- return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
- }
- }
-
+
///
/// 按托下发(到集中供料或外协)
///
@@ -128,7 +78,7 @@ namespace Tnb.WarehouseMgr
///
///
[HttpPost, NonUnify, AllowAnonymous]
- public async Task Distribute(MaterialTransferDistributeInput input)
+ public async Task Distribute(RawmatTransferoutstockInput input)
{
try
{
@@ -137,73 +87,39 @@ namespace Tnb.WarehouseMgr
{
throw new AppFriendlyException("来源单据id不可为空", 500);
}
- if (input.palletCount <= 0)
+ if (input.carrys.Count == 0)
{
- throw new AppFriendlyException("托盘数必须大于0", 500);
- }
- if (input.qty <= 0)
- {
- throw new AppFriendlyException("数量必须大于0", 500);
- }
- if (string.IsNullOrEmpty(input.code_batch))
- {
- throw new AppFriendlyException("批号不可为空", 500);
+ throw new AppFriendlyException("至少选择一个载具", 500);
}
- WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable().FirstAsync(it => it.id == input.source_id);
- WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable().FirstAsync(it => it.id == wmsMaterialTransferD.bill_id);
+ WmsRawmatTransferoutstockD wmsRawmatTransferoutstockD = await _db.Queryable().FirstAsync(it => it.id == input.source_id);
+ WmsRawmatTransferoutstockH wmsRawmatTransferoutstockH = await _db.Queryable().FirstAsync(it => it.id == wmsRawmatTransferoutstockD.bill_id);
- if (wmsMaterialTransferD.yxfqty >= wmsMaterialTransferD.qty)
+ List items = await _db.Queryable().Where(r => input.carrys.Contains(r.carry_code)).ToListAsync();
+
+
+
+
+
+ List wmsCarryCodes = await _db.Queryable().Where(r => items.Select(c => c.id).Contains(r.carry_id)
+ && r.material_id == wmsRawmatTransferoutstockD.matcode_id && r.code_batch == wmsRawmatTransferoutstockD.code_batch).ToListAsync();
+
+ decimal qty = wmsCarryCodes.Sum(c => c.codeqty);
+ if (wmsRawmatTransferoutstockD.actual_qty + qty > wmsRawmatTransferoutstockD.qty)
{
- throw new AppFriendlyException("已下发数量已达到转库数量", 500);
+ throw new AppFriendlyException($"本次出库数量{qty}已超过可出库数量{wmsRawmatTransferoutstockD.qty - wmsRawmatTransferoutstockD.actual_qty}", 500);
}
await _db.Ado.BeginTranAsync();
- OutStockStrategyQuery outStockStrategyInput = new()
- {
- warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
- material_id = wmsMaterialTransferD.material_id,
- code_batch = input.code_batch,
- Size = input.palletCount,
- Region_id = WmsWareHouseConst.REGION_Purchase_ID,
- PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK,
- AvoidBusyPassage = true
- };
- List items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
-
- if (items.Count == 0)
- {
- throw new AppFriendlyException($@"没有可以出库的载具", 500);
- }
-
- decimal qty = _db.Queryable().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == wmsMaterialTransferD.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty);
-
- // 暂定PDA上查询到的物料批次和库存数量与提交时获取的不一致时,需要前台重新获取库存接口
- if (input.palletCount != items.Count || input.qty != qty)
- {
- throw new AppFriendlyException($@"当前实际托盘数量为{input.palletCount} 实际库存数量为{qty},与前台数据不一致,请重新获取库存", HttpStatusCode.InternalServerError);
- }
-
List endLocations = new List();
- // 集中供料区三工位
- if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_JZGL_ID)
- {
- // 根据三工位任务数平均分配任务 暂定
- endLocations = _db.Queryable().Where(r => _wareHouseService.GetFloor1GLSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
- .OrderBy("is_lock, task_nums, location_code").ToList();
- }
- // 中储仓三工位
- else if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID)
- {
- // 根据三工位任务数平均分配任务 暂定
- endLocations = _db.Queryable().Where(r => _wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
- .OrderBy("is_lock, task_nums, location_code").ToList();
- }
+
+ endLocations = _db.Queryable().Where(r => _wareHouseService.GetFloor1YCLDBOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
+ .OrderBy("is_lock, task_nums, location_code").ToList();
- if (endLocations.Count() < input.palletCount)
+ if (endLocations.Count() < items.Count)
{
- throw new AppFriendlyException($@"可用的终点库位数量为{endLocations.Count()}个 下发数量为{input.palletCount}个 请检查终点库位的锁定和占用状态", 500);
+ throw new AppFriendlyException($@"可用的终点库位数量为{endLocations.Count()}个 下发数量为{items.Count}个 请检查终点库位的锁定和占用状态", 500);
}
foreach (var wmsCarryH in items)
@@ -211,19 +127,9 @@ namespace Tnb.WarehouseMgr
BasLocation startLocation = await _db.Queryable().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
BasLocation endLocation = null;
- // 集中供料区三工位
- if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_JZGL_ID)
- {
- // 根据三工位任务数平均分配任务 暂定
- endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1GLSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
- }
- // 中储仓三工位
- else if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID)
- {
- // 根据三工位任务数平均分配任务 暂定
- endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
- }
-
+
+ endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1YCLDBOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
+
if (endLocation == null)
{
throw new AppFriendlyException($@"没有可用的终点库位!请检查终点库位的锁定和占用状态", 500);
@@ -233,7 +139,7 @@ namespace Tnb.WarehouseMgr
commonCreatePretaskInput.startlocation_id = startLocation.id;
commonCreatePretaskInput.endlocation_id = endLocation.id;
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
- commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID;
+ commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WmsRawmatTransferoutstock_ID;
commonCreatePretaskInput.source_id = input.source_id;
commonCreatePretaskInput.carry_id = wmsCarryH.id;
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
@@ -249,7 +155,7 @@ namespace Tnb.WarehouseMgr
}
// 更新子表已下发数量
- await _db.Updateable().SetColumns(r => r.yxfqty == r.yxfqty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
+ await _db.Updateable().SetColumns(r => r.actual_qty == r.actual_qty + qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs
index 5afbfd3d..33e8b40c 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs
@@ -4,12 +4,26 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
+using JNPF.Common.Enums;
+using JNPF.Common.Extension;
+using JNPF.Common.Security;
+using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
using SqlSugar;
+using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
+using Tnb.WarehouseMgr.Entities.Entity;
+using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -52,10 +66,290 @@ namespace Tnb.WarehouseMgr
throw new ArgumentNullException(nameof(input));
}
- //if (!isOk)
- //{
- // throw Oops.Oh(ErrorCode.COM1001);
- //}
+
}
+
+ ///
+ /// 下发
+ ///
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify, AllowAnonymous]
+ public async Task Distribute(WmsTransferOutstockInput input)
+ {
+ Logger.LogInformation($"【Distribute】 成品调拨出库下发");
+ try
+ {
+ if (input.qty <= 0)
+ {
+ throw new AppFriendlyException("数量必须大于0", 500);
+ }
+ if (string.IsNullOrEmpty(input.source_id))
+ {
+ throw new AppFriendlyException("来源单据id不可为空", 500);
+ }
+
+ WmsTransferOutstockD wmsOutstockD = await _db.Queryable().FirstAsync(it => it.id == input.source_id);
+ await s_taskExecuteSemaphore.WaitAsync();
+ await _db.Ado.BeginTranAsync();
+ //入库取终点 //出库起点
+ OutStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.pi_code };
+ List> items = await _wareHouseService.OutStockStrategy_saleRelease(inStockStrategyInput);
+
+ decimal canOutstockQty = items.Sum(r => r.Item3.codeqty).ParseToDecimal();
+ if (canOutstockQty < input.qty)
+ {
+ throw new AppFriendlyException($@"当前可出库数量只有 {canOutstockQty.ToString("G")}", 500);
+ }
+
+ List> items_sorttask = items.Where(r => r.Item1 == "分拣任务").ToList();
+ List> items_pretask = items.Where(r => r.Item1 == "预任务").ToList();
+
+ Logger.LogInformation($"【Distribute】 预计生成{items_pretask.Count}条预任务");
+
+
+ List endLocations = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").ToListAsync();
+
+ if (endLocations.Count < items_pretask.Count)
+ {
+ throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
+ }
+
+
+ // 预任务逻辑
+ foreach (Tuple item in items_pretask)
+ {
+ WmsCarryH carry = item.Item2;
+ WmsCarryCode carryCode = item.Item3;
+ BasLocation startLocation = item.Item4;
+ // 根据一楼工位任务数平均分配任务 确定一楼工位
+ BasLocation endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
+
+ if (endLocation == null)
+ {
+ throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
+ }
+ WmsPointH sPoint = null!;
+ WmsPointH ePoint = null!;
+
+ sPoint = await _db.Queryable().FirstAsync(it => it.location_id == startLocation.id);
+
+ bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, endLocation);
+ if (!isMatch)
+ {
+ throw new AppFriendlyException("库位与载具规格不匹配", 500);
+ }
+
+ ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocation.id);
+
+ if (ePoint != null)
+ {
+ }
+ else
+ {
+ throw new AppFriendlyException($"库位{endLocation.location_code}未在点位表中维护对应点位", 500);
+ }
+
+
+ string endLocationId = endLocation.id;
+
+ // 在线开发
+ //VisualDevEntity? templateEntity = await _visualDevService?.GetInfoById(ModuleConsts.MODULE_WMSDELIVERYPDA_ID, true)!;
+ //await _runService.Create(templateEntity, input);
+
+ // 计算路径,插入预任务申请
+
+ if (sPoint != null && ePoint != null)
+ {
+ List points = new List();
+ if (sPoint.area_code != ePoint.area_code)
+ {
+ points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
+ if (points.Count <= 2)
+ {
+ throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
+ }
+ }
+ else
+ {
+ points.Add(sPoint);
+ points.Add(ePoint);
+ }
+
+ //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
+ if (points?.Count > 0)
+ {
+ List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
+ {
+ WmsPointH? sPoint = it.FirstOrDefault();
+ WmsPointH? ePoint = it.LastOrDefault();
+
+ WmsPretaskH preTask = new()
+ {
+ org_id = _userManager!.User.OrganizeId,
+ startlocation_id = sPoint?.location_id!,
+ startlocation_code = sPoint?.location_code!,
+ endlocation_id = ePoint?.location_id!,
+ endlocation_code = ePoint?.location_code!,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ startpoint_id = sPoint?.id!,
+ startpoint_code = sPoint?.point_code!,
+ endpoint_id = ePoint?.id!,
+ 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_WmsTransferOutstock_ID,
+ task_type = WmsWareHouseConst.WMS_PRETASK_TRANSFER_TYPE_ID
+ };
+ preTask.carry_id = carry.id;
+ preTask.carry_code = carry.carry_code;
+ preTask.area_id = sPoint?.area_id!;
+ preTask.area_code = it.Key;
+ preTask.require_id = input.source_id;
+ preTask.require_code = "";
+ preTask.create_id = _userManager.UserId;
+ preTask.create_time = DateTime.Now;
+ return preTask;
+ }).ToList();
+ bool isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
+ if (isOk)
+ {
+ if (endLocationId != null)
+ {
+ //查询库位表
+ BasLocation location = await _db.Queryable().SingleAsync(it => it.id == startLocation.id);
+ {
+ //载具加锁,增加库位信息
+ _ = await _db.Updateable().SetColumns(it => new WmsCarryH
+ {
+ carry_status = ((int)EnumCarryStatus.占用).ToString(),
+ is_lock = 1,
+ location_id = startLocation.id,
+ location_code = location.location_code
+ }).Where(it => it.id == carry.id).ExecuteCommandAsync();
+ }
+
+ //所有库位加锁
+ string?[] ids = new[] { startLocation.id, preTasks[0].endlocation_id, endLocationId };
+ _ = await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync();
+
+ }
+ }
+ }
+
+ }
+ }
+
+ Logger.LogInformation($"【Distribute】 预计生成{items_sorttask.Count}条分拣任务");
+ // 分拣任务逻辑
+ foreach (Tuple item in items_sorttask)
+ {
+ WmsCarryH carry = item.Item2;
+ WmsCarryCode carryCode = item.Item3;
+ BasLocation startLocation = item.Item4;
+
+ // 锁定分拣载具
+ await _db.Updateable().SetColumns(r => r.is_lock == 1).Where(r => r.id == carry.id).ExecuteCommandAsync();
+
+ Dictionary dic = new()
+ {
+ [nameof(WmsSortingtask.id)] = SnowflakeIdHelper.NextId(),
+ [nameof(WmsSortingtask.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_SORTINGTASK_ENCODE),
+ [nameof(WmsSortingtask.org_id)] = input.org_id ?? _userManager.User.OrganizeId,
+ [nameof(WmsSortingtask.qty)] = carryCode.codeqty,
+ [nameof(WmsSortingtask.carry_id)] = carry.id,
+ [nameof(WmsSortingtask.carry_code)] = carry.carry_code,
+ [nameof(WmsSortingtask.status)] = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID,
+ [nameof(WmsSortingtask.location_id)] = startLocation.id,
+ [nameof(WmsSortingtask.location_code)] = startLocation.location_code,
+ [nameof(WmsSortingtask.create_id)] = input.create_id ?? _userManager.UserId,
+ [nameof(WmsSortingtask.create_time)] = DateTime.Now,
+ [nameof(WmsSortingtask.source_id)] = input.source_id
+ };
+
+ VisualDevModelDataCrInput visualDevModelDataCrInput = new()
+ {
+ data = dic
+ };
+
+ //在线开发
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSSORTINGTASK_ID, false);
+ await _runService.Create(templateEntity, visualDevModelDataCrInput);
+ }
+
+ // 更新销售出库单子表已下发数量
+ await _db.Updateable().SetColumns(r => r.xf_qty == r.xf_qty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
+
+ await _db.Ado.CommitTranAsync();
+ Logger.LogInformation($"【Distribute】 成品调拨出库下发完成");
+ }
+ catch (Exception ex)
+ {
+ await _db.Ado.RollbackTranAsync();
+ Logger.LogError($"【Distribute】 销售出库 {ex.Message}");
+ Logger.LogError($"【Distribute】 销售出库 {ex.StackTrace}");
+ return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
+ }
+ finally
+ {
+ _ = s_taskExecuteSemaphore.Release();
+ await InvokeGenPretaskExcute();
+ }
+
+ return await ToApiResult(HttpStatusCode.OK, "成功");
+ }
+
+ ///
+ /// 分拣
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify, AllowAnonymous]
+ public async Task Sort(FinishproductOutstockSortInput input)
+ {
+ if (string.IsNullOrEmpty(input.source_id))
+ {
+ throw new AppFriendlyException("分拣任务id不能为空", 500);
+ }
+
+ await _db.Ado.BeginTranAsync();
+ try
+ {
+ WmsSortingtask wmsSortingtask = await _db.Queryable().Where(r => r.id == input.source_id).FirstAsync();
+ if (wmsSortingtask.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID)
+ {
+ throw new AppFriendlyException("此分拣任务已完成,不允许重复提交", 500);
+ }
+ // 解锁分拣载具
+ await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.id == wmsSortingtask.carry_id).ExecuteCommandAsync();
+ // 扣减载具物料库存
+ await _db.Updateable().SetColumns(r => r.codeqty == r.codeqty - wmsSortingtask.qty).Where(r => r.carry_id == wmsSortingtask.carry_id).ExecuteCommandAsync();
+
+ await _db.Updateable().SetColumns(r => new WmsSortingtask
+ {
+ status = WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID,
+ complete_time = DateTime.Now
+ }).Where(r => r.id == wmsSortingtask.id).ExecuteCommandAsync();
+
+ await _db.Updateable().SetColumns(r => r.xf_qty == r.xf_qty + wmsSortingtask.qty).Where(r => r.id == wmsSortingtask.source_id).ExecuteCommandAsync();
+ //await _db.Updateable().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();
+ return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
+ }
+
+ return await ToApiResult(HttpStatusCode.OK, "成功");
+ }
+
+
}
}