This commit is contained in:
PastSaid
2024-12-05 15:39:19 +08:00
parent 5472714e30
commit 9725ab5376
128 changed files with 46381 additions and 69 deletions

View File

@@ -0,0 +1,165 @@
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.Core.Mobile.Utils;
using Kingdee.K3.SCM.Business;
using Kingdee.K3.SCM.Core.SAL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace GZ.LJY000.Biori.STK_TransferDirect
{
[HotUpdate, Description("直接调拨单表单插件")]
public class BillEventPlugInEx : AbstractDynamicFormPlugIn
{
public override void BeforeUpdateValue(BeforeUpdateValueEventArgs e)
{
base.BeforeUpdateValue(e);
}
public override void EntryBarItemClick(BarItemClickEventArgs e)
{
base.EntryBarItemClick(e);
if (e.BarItemKey.Equals("tbScanPack"))
{
var billShowParameter = new DynamicFormShowParameter();
if (this.Context.DBId.Equals("6735f10547df64"))
billShowParameter.FormId = "k474702e8884e43a3b11c235d9d430f5d";
else
billShowParameter.FormId = "UHIK_ScanGetPack";
billShowParameter.ParentPageId = this.View.PageId;
var billObj = this.View.Model.DataObject;
var billId = billObj["Id"].ToString();
var entity = billObj["TransferDirectEntry"] as DynamicObjectCollection;
this.View.ShowForm(billShowParameter, (result) =>
{
if (result != null)
{
if (entity != null && entity.Any())
{
var rows = result.ReturnData as DynamicObjectCollection;
foreach (var item in entity)
{
//var row = rows.FirstOrDefault(w => w["FRowId"].ToString() == item["RowId"].ToString());
var row = rows.FirstOrDefault(w => w["FMaterialID_Id"].Long2Int() == item["MaterialID_Id"].Long2Int());
if (row != null)
{
item["FPackBillNo"] = row["FBILLNO"].ToString();
item["FPackBillSeq"] = row["FBILLSEQ"].Long2Int();
item["FPackBillEntryId"] = row["FBILLENTRYID"].Long2Int();
}
}
}
else
{
var rows = result.ReturnData as DynamicObjectCollection;
var parentRowIdxs = new List<int>();
foreach (var row in rows)
{
var parentRowId = row["FParentRowId"].ToString();
var rowId = row["FRowId"].ToString();
this.View.Model.CreateNewEntryRow("FBillEntry");
int entryCurrentRowIndex = Model.GetEntryCurrentRowIndex("FBillEntry");
if (parentRowId.IsNullOrEmptyOrWhiteSpace())
parentRowIdxs.Add(entryCurrentRowIndex);
this.View.Model.SetValue("FRowType", (parentRowId.IsNullOrEmptyOrWhiteSpace() ? "Parent" : "Son"), entryCurrentRowIndex);
this.View.Model.SetItemValueByID("FMaterialId", row["FMaterialId_Id"], entryCurrentRowIndex);
this.View.InvokeFieldUpdateService("FMaterialId", entryCurrentRowIndex);
this.View.Model.SetValue("FParentRowId", parentRowId, entryCurrentRowIndex);
this.View.Model.SetValue("FRowId", rowId, entryCurrentRowIndex);
this.View.Model.SetValue("FQty", row["FQty"], entryCurrentRowIndex);
this.View.Model.SetValue("FPackBillNo", row["FBILLNO"], entryCurrentRowIndex);
this.View.Model.SetValue("FPackBillSeq", row["FBILLSEQ"], entryCurrentRowIndex);
this.View.Model.SetValue("FPackBillEntryId", row["FBILLENTRYID"], entryCurrentRowIndex);
}
if (parentRowIdxs.Any())
{
foreach (var idx in parentRowIdxs)
{
this.View.InvokeFieldUpdateService("FQty", idx);
}
}
//GetBOMExpandResult();
}
}
this.View.UpdateView("FEntity");
return;
});
}
}
/// <summary>
/// 调用生产接口获取套件展开数据包,FDemandOrgId 需求组织FSUPPLYORGID 供应组织
/// </summary>
/// <param name="sCurrRowId"></param>
/// <returns></returns>
private DynamicObjectCollection GetBOMExpandResult(string sCurrRowId = "")
{
//提前保证所有套件父项行行标识FRowId必须有值(有可能下推的单据没有值)
CheckRowIDValueForParentEntry();
DynamicObjectCollection dycExpandResult = null;
ProductBomExpandArgs pbeArgs = new ProductBomExpandArgs("FDemandOrgId", "FSUPPLYORGID", "FRowType", "FRowId", "FParentRowId", "FParentMatId",
"FMaterialId", "FBomId", "FBaseUnitId", "FStockBaseQty", "FMaterialId", "FUnitId", "FQty"
);
ProductBomExpand pbe = new ProductBomExpand(this.Context, this.View.BusinessInfo.GetForm().Id, this.View.BusinessInfo, this.View.Model.DataObject);
if (!sCurrRowId.IsNullOrEmptyOrWhiteSpace())
{
dycExpandResult = pbe.GetProductBomExpandResult(pbeArgs, sCurrRowId);
}
else
{
//首次展开或者重复执行全部展开操作
dycExpandResult = pbe.GetProductBomExpandResult(pbeArgs);
}
return dycExpandResult;
}
//提前保证所有套件父项行行标识FRowId必须有值(有可能下推的单据没有值)
private void CheckRowIDValueForParentEntry()
{
Entity entryEntity = this.View.BusinessInfo.GetEntity("FBillEntry");
this.View.Model.ClearNoDataRow();
DynamicObjectCollection dycEntryList = this.View.Model.GetEntityDataObject(entryEntity);
if (dycEntryList == null || dycEntryList.Count < 1)
{
return;
}
string sRowType = "";
string sRowId = "";
foreach (DynamicObject dyItem in dycEntryList)
{
sRowType = Convert.ToString(dyItem["RowType"]);
sRowId = Convert.ToString(dyItem["RowId"]);
if (sRowType.EqualsIgnoreCase("Parent") && sRowId.IsNullOrEmptyOrWhiteSpace())
{
dyItem["RowId"] = SequentialGuid.NewGuid().ToString();
}
}
}
}
}