105 lines
4.5 KiB
Python
105 lines
4.5 KiB
Python
|
|
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")
|
||
|
|
clr.AddReference("Kingdee.K3.BD.BarCode.Business.PlugIn")
|
||
|
|
|
||
|
|
from Kingdee.BOS import *
|
||
|
|
from Kingdee.BOS.Contracts import *
|
||
|
|
from Kingdee.BOS.Core import *
|
||
|
|
from Kingdee.BOS.Core.SqlBuilder 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.Security.Cryptography import *
|
||
|
|
from System.ComponentModel import *
|
||
|
|
from System.Collections.Generic import *
|
||
|
|
from System.Text import*
|
||
|
|
from Kingdee.BOS.ServiceHelper import *
|
||
|
|
from Kingdee.K3.BD.BarCode.Business.PlugIn import *
|
||
|
|
|
||
|
|
_isFormisFromBillEx = 0
|
||
|
|
_sFormIdEx = ""
|
||
|
|
def OnInitialize(e):
|
||
|
|
_isFromBillObj = e.Paramter.GetCustomParameter("isFromBill");
|
||
|
|
global _isFormisFromBillEx
|
||
|
|
_isFormisFromBillEx = 0 if _isFromBillObj == None else int(_isFromBillObj)
|
||
|
|
|
||
|
|
_sFormIdExObj =e.Paramter.GetCustomParameter("SourceFormId")
|
||
|
|
global _sFormIdEx;
|
||
|
|
_sFormIdEx = "" if _sFormIdExObj == None else str(_sFormIdExObj)
|
||
|
|
|
||
|
|
def OnLoad(e):
|
||
|
|
# raise Exception(str(_isFormisFromBillEx))
|
||
|
|
# this.View.UpdateView("FEntityToBill");
|
||
|
|
if _isFormisFromBillEx == 1:
|
||
|
|
this.View.EntryBarItemClick("FEntityToBill", "tbGetNewData")
|
||
|
|
# if _sFormIdEx == 'PRD_MO':
|
||
|
|
# raise Exception(JsonUtil.Serialize(this.View.Model.DataObject))
|
||
|
|
|
||
|
|
|
||
|
|
def EntryBarItemClick(e):
|
||
|
|
fieldKey = str(e.BarItemKey).upper();
|
||
|
|
if fieldKey == "TBCREBARCODESUM" or fieldKey == "TBCREBARCODEROW":
|
||
|
|
entity = this.View.BusinessInfo.GetEntity("FEntityToBar");
|
||
|
|
entityDataObject = this.View.Model.GetEntityDataObject(entity);
|
||
|
|
|
||
|
|
if entityDataObject != None and entityDataObject.Count > 0:
|
||
|
|
#读取单据的元数据
|
||
|
|
sourceFormId = "UHIK_BD_BarCodeMainFile";
|
||
|
|
meta = MetaDataServiceHelper.Load(this.Context, sourceFormId);
|
||
|
|
#获取单据数据包的对象类型
|
||
|
|
ObjList = List[DynamicObject]();
|
||
|
|
for item in entityDataObject:
|
||
|
|
|
||
|
|
objType = meta.BusinessInfo.GetDynamicObjectType();
|
||
|
|
queryParameter = QueryBuilderParemeter();
|
||
|
|
queryParameter.FormId = sourceFormId;
|
||
|
|
|
||
|
|
barCode = item["BarCode"]
|
||
|
|
queryParameter.FilterClauseWihtKey = " FBarCode = '{0}' ".format(barCode);
|
||
|
|
|
||
|
|
newObj = DynamicObject(objType)
|
||
|
|
loadObjs = BusinessDataServiceHelper.Load(this.Context, objType, queryParameter)
|
||
|
|
if loadObjs != None and loadObjs.Count > 0:
|
||
|
|
newObj = loadObjs[0]
|
||
|
|
|
||
|
|
newObj["MaterialId_Id"] = item["MaterialIdToBar_Id"]
|
||
|
|
newObj["MaterialId"] = item["MaterialIdToBar"]
|
||
|
|
# 条码规则
|
||
|
|
newObj["BarCodeRule_Id"] = item["BarCodeRule_Id"]
|
||
|
|
newObj["BarCodeRule"] = item["BarCodeRule"]
|
||
|
|
# 条形码
|
||
|
|
newObj["BarCode"] = item["BarCode"]
|
||
|
|
|
||
|
|
newObj["UnitId_Id"] = item["UnitIDToBar_Id"]
|
||
|
|
newObj["UnitId"] = item["UnitIDToBar"]
|
||
|
|
newObj["Lot_Id"] = item["LotToBar_Id"]
|
||
|
|
newObj["Lot"] = item["LotToBar"]
|
||
|
|
|
||
|
|
ObjList.Add(newObj);
|
||
|
|
# raise Exception(JsonUtil.Serialize(ObjList))
|
||
|
|
if ObjList.Count > 0:
|
||
|
|
saveRslt = BusinessDataServiceHelper.Save(this.Context, meta.BusinessInfo,ObjList.ToArray(), None, "Save");
|
||
|
|
if bool(saveRslt.IsSuccess) == True:
|
||
|
|
resRows = saveRslt.Rows
|
||
|
|
# raise Exception(JsonUtil.Serialize(resRows))
|
||
|
|
for idx,resRow in enumerate(resRows):
|
||
|
|
# raise Exception(JsonUtil.Serialize(resRow))
|
||
|
|
# raise Exception(str(resRow.DataEntity["Id"]))
|
||
|
|
this.View.Model.SetValue("FBarCodeMD5ToBar", str(resRow.DataEntity["Id"]) , idx)
|
||
|
|
this.View.UpdateView("FEntityToBar");
|
||
|
|
# raise Exception(JsonUtil.Serialize(saveRslt))
|