This commit is contained in:
2025-12-12 11:00:17 +08:00
parent a22bf3ac79
commit 7d5acb6457
6 changed files with 120 additions and 15 deletions

View File

@@ -37,6 +37,9 @@
<Reference Include="Kingdee.BOS.App"> <Reference Include="Kingdee.BOS.App">
<HintPath>..\Library\Kingdee.BOS.App.dll</HintPath> <HintPath>..\Library\Kingdee.BOS.App.dll</HintPath>
</Reference> </Reference>
<Reference Include="Kingdee.BOS.Contracts">
<HintPath>..\Library\Kingdee.BOS.Contracts.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.Core"> <Reference Include="Kingdee.BOS.Core">
<HintPath>..\Library\Kingdee.BOS.Core.dll</HintPath> <HintPath>..\Library\Kingdee.BOS.Core.dll</HintPath>
</Reference> </Reference>
@@ -61,9 +64,11 @@
<Reference Include="Kingdee.K3.BD.BarCode.ServiceHelper"> <Reference Include="Kingdee.K3.BD.BarCode.ServiceHelper">
<HintPath>..\Library\Kingdee.K3.BD.BarCode.ServiceHelper.dll</HintPath> <HintPath>..\Library\Kingdee.K3.BD.BarCode.ServiceHelper.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Kingdee.K3.BD.Contracts">
<SpecificVersion>False</SpecificVersion> <HintPath>..\Library\Kingdee.K3.BD.Contracts.dll</HintPath>
<HintPath>..\Library\Newtonsoft.Json.dll</HintPath> </Reference>
<Reference Include="Kingdee.K3.Core">
<HintPath>..\Library\Kingdee.K3.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -77,10 +82,9 @@
<ItemGroup> <ItemGroup>
<Compile Include="PlugIn\PUR_PurchaseOrder\ConvertPlugIn\ToStkInStock.cs" /> <Compile Include="PlugIn\PUR_PurchaseOrder\ConvertPlugIn\ToStkInStock.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\UnitService.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>copy $(TargetPath) "D:\Program Files (x86)\Kingdee\K3Cloud\WebSite\Bin\$(TargetFileName)"</PostBuildEvent> <PostBuildEvent>copy $(TargetPath) "D:\Program Files (x86)\Kingdee\K3Cloud\WebSite\Bin\$(TargetFileName)"</PostBuildEvent>

View File

@@ -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.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util; using Kingdee.BOS.Util;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -15,12 +21,7 @@ namespace Gatedge.NewOrientLandMark.BOS.PlugIn.PUR_PurchaseOrder.ConvertPlugIn
{ {
private bool IsConvertByScanCode = false; private bool IsConvertByScanCode = false;
private readonly Dictionary<string, object> CustomParams = new Dictionary<string, object>(); private readonly Dictionary<string, object> CustomParams = new Dictionary<string, object>();
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) public override void OnInitVariable(InitVariableEventArgs e)
@@ -57,14 +58,63 @@ namespace Gatedge.NewOrientLandMark.BOS.PlugIn.PUR_PurchaseOrder.ConvertPlugIn
{ {
return; return;
} }
UnitService unitService = new UnitService(this.Context);
var billList = e.Result.FindByEntityKey("FBillHead"); var billList = e.Result.FindByEntityKey("FBillHead");
foreach (var bill in billList) foreach (var bill in billList)
{ {
var billObj = bill.DataEntity; 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<IViewService>();
//根据内码获取物料基础资料对象
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;
//}
}
} }
} }
} }
} }

View File

@@ -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;
}
/// <summary>
/// 单位转换
/// </summary>
/// <param name="masterId"></param>
/// <param name="sourceUnitId"></param>
/// <param name="destUnitId"></param>
/// <param name="qty"></param>
/// <returns></returns>
public decimal GetQtyByUtilConverRate(
long masterId,
long sourceUnitId,
long destUnitId,
decimal qty
)
{
IUnitConvertService utilService = ServiceHelper.GetService<IUnitConvertService>();
UnitConvert unitConvertRate = utilService.GetUnitConvertRate(
ctx,
new GetUnitConvertRateArgs
{
MasterId = masterId,
SourceUnitId = sourceUnitId,
DestUnitId = destUnitId,
}
);
return unitConvertRate.ConvertQty(qty);
}
}
}

Binary file not shown.

Binary file not shown.

BIN
Library/Kingdee.K3.Core.dll Normal file

Binary file not shown.