Python插件,读数据包,查询,写数据
def match_material(entry): useorg=this.View.Model.GetValue("F_OrgId_fg2") if useorg is None:return if this.View.Model.GetValue("F_StyleNo",0) is None:return useorgid=useorg.Id tableN="T_TEMP_"+str(this.Context.UserId) data_package = this.Model.DataObject[entry] dt = DataTable() dt.Columns.Add("Seq") dt.Columns.Add("F_StyleNo") dt.Columns.Add("F_ColorDesc") dt.Columns.Add("F_SizeDesc") dt.BeginLoadData() for item in data_package: dt.LoadDataRow(Array[object]([item["Seq"],item["F_StyleNo"], item["F_ColorDesc"],item["F_SizeDesc"]]), True) dt.EndLoadData() #创建临时表 sql_create=""" /*dialect*/ IF not EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}') begin CREATE TABLE {0} (Seq INT, F_StyleNo VARCHAR(150), F_ColorDesc VARCHAR(150),FMaterialId INT,F_SizeDesc VARCHAR(150)) end delete from {0} """.format(tableN) DBUtils.Execute(this.Context, sql_create) # 插入数据 dt.TableName = tableN DBUtils.BulkInserts(this.Context, dt) # 关联取数 query = """ /*dialect*/ SELECT b.FMATERIALID,c.size_id FROM {0} a left JOIN t_bd_material b ON b.F_KH = a.F_StyleNo AND b.F_YWYS = a.F_ColorDesc and b.FUSEORGID={1} left join u_view_kmx c on c.pm_id=b.F_ASSISTANT_PEIMA and a.F_SizeDesc=c.f_kmx where b.FMATERIALID>0 order by a.seq """.format(tableN,str(useorgid)) reader=DBUtils.ExecuteReader(this.Context, query) # 删除临时表 #DBUtils.DropSessionTemplateTable(this.Context, tableN) # 处理查询结果 # 填充 FMaterialId 列 i=0 for item in reader: FMaterialId=item["FMaterialId"] SizeId=item["size_id"] this.View.Model.SetValue("FMaterialId",FMaterialId,i) this.View.UpdateView("FMaterialId") this.View.Model.SetValue("$$FAuxPropId__FF100001",SizeId,i) this.View.UpdateView("$$FAuxPropId__FF100001") i=i+1
Python插件,读数据包,查询,写数据
本文2024-09-16 17:43:04发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-17504.html