diff --git a/Gatedge.NewOrientLandMark.BOS/Gatedge.NewOrientLandMark.BOS.csproj b/Gatedge.NewOrientLandMark.BOS/Gatedge.NewOrientLandMark.BOS.csproj
index c1f7aa9..4aa202c 100644
--- a/Gatedge.NewOrientLandMark.BOS/Gatedge.NewOrientLandMark.BOS.csproj
+++ b/Gatedge.NewOrientLandMark.BOS/Gatedge.NewOrientLandMark.BOS.csproj
@@ -37,6 +37,9 @@
..\Library\Kingdee.BOS.App.dll
+
+ ..\Library\Kingdee.BOS.Contracts.dll
+
..\Library\Kingdee.BOS.Core.dll
@@ -61,9 +64,11 @@
..\Library\Kingdee.K3.BD.BarCode.ServiceHelper.dll
-
- False
- ..\Library\Newtonsoft.Json.dll
+
+ ..\Library\Kingdee.K3.BD.Contracts.dll
+
+
+ ..\Library\Kingdee.K3.Core.dll
@@ -77,10 +82,9 @@
+
-
-
-
+
copy $(TargetPath) "D:\Program Files (x86)\Kingdee\K3Cloud\WebSite\Bin\$(TargetFileName)"
diff --git a/Gatedge.NewOrientLandMark.BOS/PlugIn/PUR_PurchaseOrder/ConvertPlugIn/ToStkInStock.cs b/Gatedge.NewOrientLandMark.BOS/PlugIn/PUR_PurchaseOrder/ConvertPlugIn/ToStkInStock.cs
index f02b096..a01ea69 100644
--- a/Gatedge.NewOrientLandMark.BOS/PlugIn/PUR_PurchaseOrder/ConvertPlugIn/ToStkInStock.cs
+++ b/Gatedge.NewOrientLandMark.BOS/PlugIn/PUR_PurchaseOrder/ConvertPlugIn/ToStkInStock.cs
@@ -1,5 +1,11 @@
-using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
+using Gatedge.NewOrientLandMark.BOS.Services;
+using Kingdee.BOS.App;
+using Kingdee.BOS.Contracts;
+using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
+using Kingdee.BOS.Core.Metadata.FieldElement;
+using Kingdee.BOS.Orm.DataEntity;
+using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
@@ -15,12 +21,7 @@ namespace Gatedge.NewOrientLandMark.BOS.PlugIn.PUR_PurchaseOrder.ConvertPlugIn
{
private bool IsConvertByScanCode = false;
private readonly Dictionary CustomParams = new Dictionary();
- private bool InStockQty = false;
- private bool InStockId = false;
- private bool FStockDate = false;
- private bool FExpirationDate = false;
- private bool FLot_Id = false;
- private bool FLot_Text = false;
+
public override void OnInitVariable(InitVariableEventArgs e)
@@ -57,14 +58,63 @@ namespace Gatedge.NewOrientLandMark.BOS.PlugIn.PUR_PurchaseOrder.ConvertPlugIn
{
return;
}
+ UnitService unitService = new UnitService(this.Context);
var billList = e.Result.FindByEntityKey("FBillHead");
foreach (var bill in billList)
{
var billObj = bill.DataEntity;
+ var entryList = billObj["InStockEntry"] as DynamicObjectCollection;
+ BaseDataField StockField =
+ e.TargetBusinessInfo.GetField("FStockId") as BaseDataField;
+ BaseDataField StockStatusField =
+ e.TargetBusinessInfo.GetField("FStockStatusId") as BaseDataField;
+ IViewService service = ServiceHelper.GetService();
+ //根据内码获取物料基础资料对象
+ var org = bill.DataEntity["StockOrgId"] as DynamicObject; // 调出组织
+ var orgId = org["Id"].ToString();
+ foreach (var item in entryList)
+ {
+ DynamicObject Stock = service.LoadSingle(
+ this.Context,
+ CustomParams["InStockId"],
+ StockField.RefFormDynamicObjectType
+ );
+ DynamicObject StockStatus = service.LoadSingle(
+ this.Context,
+ "10000",
+ StockStatusField.RefFormDynamicObjectType
+ ); // 指定库存状态为可用
+ item["StockId_Id"] = Stock["Id"];
+ item["StockId"] = Stock;
+ item["StockStatusId_Id"] = StockStatus["Id"];
+ item["StockStatusId"] = StockStatus;
+ var material = item["MaterialId"] as DynamicObject; // 物料
+ var materialId = Convert.ToInt64(material["msterID"]); // 物料模板Id
+ var unitId = Convert.ToInt64(item["UnitId_Id"]); // 主单位
+ var priceUnitId = Convert.ToInt64(item["PriceUnitID_Id"]); // 计价单位
+ var remainInStockUnitId = Convert.ToInt64(item["RemainInStockUnitId_Id"]); // 采购单位
+ //var snUnitId = Convert.ToInt64(item["SNUnitID_Id"]); // 序列号单位
+ var qty = Convert.ToDecimal(CustomParams["InStockQty"]);
+ item["RealQty"] = qty; // 填写实收数
+ if (priceUnitId != 0) // 计价数量
+ {
+ var BaseRealQty = unitService.GetQtyByUtilConverRate(materialId, unitId, priceUnitId, qty);
+ item["PriceUnitQty"] = BaseRealQty;
+ item["PriceUnitQty"] = BaseRealQty;
+ }
+ if (remainInStockUnitId != 0) // 采购数量
+ {
+ var SecRealQty = unitService.GetQtyByUtilConverRate(materialId, unitId, remainInStockUnitId, qty);
+ item["RemainInStockQty"] = SecRealQty;
+ }
+ //if (snUnitId != 0)
+ //{
+ // var snQty = unitService.GetQtyByUtilConverRate(materialId, unitId, snUnitId, qty);
+ // item["SNQty"] = snQty;
+ //}
+ }
}
}
-
-
}
}
diff --git a/Gatedge.NewOrientLandMark.BOS/Services/UnitService.cs b/Gatedge.NewOrientLandMark.BOS/Services/UnitService.cs
new file mode 100644
index 0000000..8c268db
--- /dev/null
+++ b/Gatedge.NewOrientLandMark.BOS/Services/UnitService.cs
@@ -0,0 +1,51 @@
+using Kingdee.BOS;
+using Kingdee.BOS.App;
+using Kingdee.K3.BD.Contracts;
+using Kingdee.K3.Core.BD;
+using Kingdee.K3.Core.BD.ServiceArgs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gatedge.NewOrientLandMark.BOS.Services
+{
+ public class UnitService
+ {
+ private Context ctx;
+ public UnitService(Context context)
+ {
+ this.ctx = context;
+ }
+ ///
+ /// 单位转换
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public decimal GetQtyByUtilConverRate(
+ long masterId,
+ long sourceUnitId,
+ long destUnitId,
+ decimal qty
+ )
+ {
+ IUnitConvertService utilService = ServiceHelper.GetService();
+ UnitConvert unitConvertRate = utilService.GetUnitConvertRate(
+ ctx,
+ new GetUnitConvertRateArgs
+ {
+ MasterId = masterId,
+ SourceUnitId = sourceUnitId,
+ DestUnitId = destUnitId,
+ }
+ );
+ return unitConvertRate.ConvertQty(qty);
+ }
+
+
+ }
+}
diff --git a/Library/Kingdee.BOS.Contracts.dll b/Library/Kingdee.BOS.Contracts.dll
new file mode 100644
index 0000000..fdf8e81
Binary files /dev/null and b/Library/Kingdee.BOS.Contracts.dll differ
diff --git a/Library/Kingdee.K3.BD.Contracts.dll b/Library/Kingdee.K3.BD.Contracts.dll
new file mode 100644
index 0000000..9dda905
Binary files /dev/null and b/Library/Kingdee.K3.BD.Contracts.dll differ
diff --git a/Library/Kingdee.K3.Core.dll b/Library/Kingdee.K3.Core.dll
new file mode 100644
index 0000000..7b9c16d
Binary files /dev/null and b/Library/Kingdee.K3.Core.dll differ