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,125 @@
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.BD.NewCode.Core.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Util;
using System.ComponentModel;
using Kingdee.BOS;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.Metadata.EntityElement;
namespace GZ.LJY000.Biori.PUR_ReceiveBill
{
[Description("收料通知单下推采购入库单#"), HotUpdate]
public class BillConvertEventPlugInEx : AbstractConvertPlugIn
{
public override void AfterConvert(AfterConvertEventArgs e)
{
base.AfterConvert(e);
HandleScanEntry(e);
}
private void HandleScanEntry(AfterConvertEventArgs e)
{
var paraDIC = this.Option.GetVariables();
if (!paraDIC.ContainsKey("ScanEntry"))
return;
var FInStockEntryItem = paraDIC["ScanEntry"] as DynamicObjectCollection;
if (FInStockEntryItem == null)
return;
var FInStockEntry = e.TargetBusinessInfo.GetEntity("FInStockEntry");
//得到单据数据包扩展集合
var billDynObjExs = e.Result.FindByEntityKey("FBillHead");
var tView = CreateView(e.TargetBusinessInfo.GetForm().Id);//创建目标单据视图
foreach (var billDynObjEx in billDynObjExs)
{
var billDynObj = billDynObjEx.DataEntity; //#单个单据数据包
tView.Model.DataObject = billDynObj; //#给模型设置数据包
var entryDynObjs = FInStockEntry.DynamicProperty.GetValue(billDynObj) as DynamicObjectCollection; //#得到字段所在实体的数据包
var rowIndex = 0;//#分录行索引
foreach (var rowObj in entryDynObjs)
{
//#查找对应分录标识
var fRealQtyField = e.TargetBusinessInfo.GetField("FPriceUnitQty"); //#数量
var Link = rowObj["FInStockEntry_Link"] as DynamicObjectCollection;// #找出LK关系表找出对应的源单内码数据
var entity = FInStockEntryItem.FirstOrDefault(w => w["ENTRYID"].Long2Int() == Link[0]["SId"].Long2Int());
if (entity != null)
{
tView.Model.SetValue(fRealQtyField, rowObj, entity["Qty"]);// #这字段值并且会触发值更新事件
tView.InvokeFieldUpdateService(fRealQtyField.Key, rowIndex);// #调用实体服务规则
}
rowIndex++;
}
}
}
/// <summary>
/// 创建单据视图
/// </summary>
/// <param name="ctx"></param>
/// <param name="metaData"></param>
/// <returns></returns>
private IDynamicFormView CreateView(string formId)
{
FormMetadata metadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, formId);
var OpenParameter = CreateOpenParameter(this.Context, metadata);
var Provider = metadata.BusinessInfo.GetForm().GetFormServiceProvider(true);
string importViewClass = "Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web";
Type type = Type.GetType(importViewClass);
IDynamicFormView view = (IDynamicFormView)Activator.CreateInstance(type);
((IDynamicFormViewService)view).Initialize(OpenParameter, Provider);
return view;
}
/// <summary>
/// 创建输入参数
/// </summary>
/// <param name="ctx"></param>
/// <param name="metaData"></param>
/// <returns></returns>
private BillOpenParameter CreateOpenParameter(Context ctx, FormMetadata metaData)
{
Form form = metaData.BusinessInfo.GetForm();
BillOpenParameter openPara = new BillOpenParameter(form.Id, metaData.GetLayoutInfo().Id);
openPara = new BillOpenParameter(form.Id, string.Empty);
openPara.Context = ctx;
openPara.ServiceName = form.FormServiceName;
openPara.PageId = Guid.NewGuid().ToString();
// 单据
openPara.FormMetaData = metaData;
openPara.LayoutId = metaData.GetLayoutInfo().Id;
// 操作相关参数
openPara.Status = OperationStatus.ADDNEW;
openPara.PkValue = null;
openPara.CreateFrom = CreateFrom.Default;
openPara.ParentId = 0;
openPara.GroupId = "";
openPara.DefaultBillTypeId = null;
openPara.DefaultBusinessFlowId = null;
// 修改主业务组织无须用户确认
openPara.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);
// 插件
List<AbstractDynamicFormPlugIn> plugins = form.CreateFormPlugIns();
openPara.SetCustomParameter(FormConst.PlugIns, plugins);
return openPara;
}
}
}

View File

@@ -0,0 +1,104 @@
import clr
clr.AddReference("System")
clr.AddReference("System.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.ServiceHelper")
clr.AddReference("Newtonsoft.Json")
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn import *
from Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args import *
from Kingdee.BOS.Core.Metadata.FormElement import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Orm.Metadata.DataEntity import *
from Kingdee.BOS.ServiceHelper import *
from System import *
from System.Collections.Generic import *
from System.ComponentModel import *
from System.Linq import *
from Newtonsoft.Json import *
from Newtonsoft.Json.Linq import *
#单据转换之后事件
def AfterConvert(e):
paraDIC=this.Option.GetVariables();
if paraDIC.ContainsKey("ScanEntry") == False:
return;
FInStockEntryItem = paraDIC["ScanEntry"]
if FInStockEntryItem is None:
return;
FInStockEntry = e.TargetBusinessInfo.GetEntity("FInStockEntry");
#得到单据数据包扩展集合
billDynObjExs = e.Result.FindByEntityKey("FBillHead");
tView = CreateView(e.TargetBusinessInfo.GetForm().Id);#创建目标单据视图
for billDynObjEx in billDynObjExs:#循环数据包扩展集合
billDynObj = billDynObjEx.DataEntity; #单个单据数据包
tView.Model.DataObject = billDynObj; #给模型设置数据包
entryDynObjs = FInStockEntry.DynamicProperty.GetValue(billDynObj); #得到字段所在实体的数据包
rowIndex = 0;#分录行索引
for rowObj in entryDynObjs: #循环分录
dynObj = entryDynObjs[rowIndex]; #原原分录行数据包
#查找对应分录标识
fRealQtyField = e.TargetBusinessInfo.GetField("FRealQty"); #数量
# entity = FirstOrDefault(Where(FInStockEntryItem,lambda w: w["FENTRYID"].ToString()==Link[0]["SId"].ToString()))
entity = FInStockEntryItem[0]
if entity != None :
tView.Model.SetValue(fRealQtyField, dynObj, entity["Qty"]); #这字段值并且会触发值更新事件
tView.InvokeFieldUpdateService(fRealQtyField.Key, rowIndex); #调用实体服务规则
# tView.Model.SetItemValueByNumber("FStockId",entity["FStockID"].ToString(), rowIndex);
# tView.InvokeFieldUpdateService(FStockID.Key, rowIndex); #调用实体服务规则
# tView.Model.SetValue(FNote, dynObj, entity["FNote"]); #这字段值并且会触发值更新事件
rowIndex=rowIndex+1;
return
#创建单据视图
def CreateView(formId):
metadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, formId);
OpenParameter = CreateOpenParameter(this.Context, metadata);
Provider = metadata.BusinessInfo.GetForm().GetFormServiceProvider(True);
importViewClass = "Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web";
importViewClassType = Type.GetType(importViewClass);
view = Activator.CreateInstance(importViewClassType);
view.Initialize(OpenParameter, Provider);
return view;
#创建输入参数
def CreateOpenParameter(ctx, metaData):
form = metaData.BusinessInfo.GetForm();
openPara = BillOpenParameter(form.Id, metaData.GetLayoutInfo().Id);
openPara = BillOpenParameter(form.Id, "");
openPara.Context = ctx;
openPara.ServiceName = form.FormServiceName;
openPara.PageId = Guid.NewGuid().ToString();
#单据
openPara.FormMetaData = metaData;
openPara.LayoutId = metaData.GetLayoutInfo().Id;
#操作相关参数
openPara.Status = OperationStatus.ADDNEW;
openPara.PkValue = None;
openPara.CreateFrom = CreateFrom.Default;
openPara.ParentId = 0;
openPara.GroupId = "";
openPara.DefaultBillTypeId = None;
openPara.DefaultBusinessFlowId = None;
#修改主业务组织无须用户确认
openPara.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", False);
#插件
plugins = form.CreateFormPlugIns();
openPara.SetCustomParameter(FormConst.PlugIns, plugins);
return openPara;
def FirstOrDefault(col, fun = lambda x: True):
return Enumerable.FirstOrDefault[object](col, Func[object, bool](fun))
def Where(col, fun):
return Enumerable.Where[object](col, Func[object, bool](fun))

View File

@@ -0,0 +1,84 @@
import clr
clr.AddReference("System")
clr.AddReference("System.Xml")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("Kingdee.BOS.Contracts")
clr.AddReference("Kingdee.BOS.ServiceHelper")
from Kingdee.BOS import *
from Kingdee.BOS.Contracts import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Core.Metadata.EntityElement import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.Core.Util import *
from System import *
from System.Xml import *
from System.ComponentModel import *
from System.Collections.Generic import *
from System.Text import*
from Kingdee.BOS.ServiceHelper import *
# 收料通知单
def BarItemClick(e):
# 条码扫描
if e.BarItemKey.Equals("tbBarCodeScanEx"):
billObj = this.View.Model.DataObject;
# billId = billObj["BillNo"]
billNo = billObj["BillNo"]
FFormId = billObj["FFormId"]
# allRowCollection = ListSelectedRowCollection()
# allRowCollection.Add(ListSelectedRow(billId,None,0,FFormId))
# raise Exception(JsonUtil.Serialize(allRowCollection))
# 条码扫描
billShowParameter = BillShowParameter();
billShowParameter.FormId = "UHIK_BD_BarCodeScan";
billShowParameter.ParentPageId =this.View.PageId;
# billShowParameter.OpenStyle.ShowType = ShowType.Modal;
billShowParameter.CustomParams.Add("isFromBill", "1");
billShowParameter.CustomParams.Add("SourceFormId", FFormId);
billShowParameter.CustomParams.Add("SourceId", billNo);
# billShowParameter.CustomParams.Add("RuleId", str(1003602));
# billShowParameter.CustomParams.Add("SelectedRows", JsonUtil.Serialize(allRowCollection))
#单据内码
# billShowParameter.PKey = str(this.View.Model.DataObject["Id"])
billShowParameter.Status = OperationStatus.ADDNEW
# billShowParameter.Status = OperationStatus.VIEW;
this.View.ShowForm(billShowParameter);
return;
# 条码打印
if e.BarItemKey.Equals("tbBarCodePrintEx"):
# dynamicFormShowParameter = DynamicFormShowParameter();
# dynamicFormShowParameter.FormId = "sfsf_SCJHZQLKUAIZHANTIE";#动态表单标识
# this.View.ShowForm(dynamicFormShowParameter,lambda x: SetModel(x));
billObj = this.View.Model.DataObject;
billId = billObj["Id"]
FFormId = billObj["FFormId"]
allRowCollection = ListSelectedRowCollection()
allRowCollection.Add(ListSelectedRow(str(billId),None,0,FFormId))
# raise Exception(JsonUtil.Serialize(allRowCollection))
billShowParameter = BillShowParameter();
billShowParameter.FormId = "UHIK_BAR_BarCodePrint";
billShowParameter.ParentPageId =this.View.PageId;
# billShowParameter.OpenStyle.ShowType = ShowType.Modal;
billShowParameter.CustomParams.Add("isFromBill", "1");
billShowParameter.CustomParams.Add("SourceFormId", FFormId);
billShowParameter.CustomParams.Add("SourceId", str(billId));
billShowParameter.CustomParams.Add("RuleId", str(1004002));
billShowParameter.CustomParams.Add("SelectedRows", JsonUtil.Serialize(allRowCollection))
#单据内码
# billShowParameter.PKey = str(this.View.Model.DataObject["Id"])
billShowParameter.Status = OperationStatus.ADDNEW
this.View.ShowForm(billShowParameter);
return;

View File

@@ -0,0 +1,59 @@
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.App.Core')
clr.AddReference('Kingdee.BOS.Contracts')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.ServiceHelper')
#dairycloud基础库中的常用实体对象分命名空间导入不会递归导入
from Kingdee.BOS.Core import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs import *
from System import *
from System.Data import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.App import *
from Kingdee.BOS.Orm import *
from Kingdee.BOS.Contracts import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.App.Core import *
def OnPreparePropertys(e):
# e.FieldKeys.Add("FPMoBillTypeId_Id")
e.FieldKeys.Add("FShowEntryID")
def EndOperationTransaction(e):
# * 保存8提交9审核1反审核26删除3
if this.FormOperation.OperationId == 8:
WriteBackFShowEntryID(e.DataEntitys);
def WriteBackFShowEntryID(dataEntitys):
entryIds = List[str]()
for item in dataEntitys:
# raise Exception(JsonUtil.Serialize(item))
for entity in item.PUR_ReceiveEntry:
FShowEntryID = entity["FShowEntryID"]
if FShowEntryID == 0:
entryIds.Add(str(entity["Id"]))
if entryIds.Count > 0:
sqlL = """/*dialect*/
UPDATE T_PUR_RECEIVEENTRY SET FShowEntryID = FENTRYID WHERE FENTRYID IN ({0})
""".format(",".join(entryIds))
DBUtils.Execute(this.Context, sqlL);