自定义反写规则
仅用于学习,请谨慎使用。
标准产品的反写规则,适用于绝大部分场景,对于个别特殊需求,可能要通过二开插件来实现。所以简单做了一个简易功能,满足少数要求(用python实现,无需插件)。
1.新增一个基础资料,用于保存反写规则。
a.将需要执行的SQL语句,放到单据体的执行内容中(@fid 为单据内码)
b.点击菜单“生成存储过程”,自动将单据体内容拼接成存储过程(可修改),
使用自定义公式 FCONTENT ="ALTER PROCEDURE [dbo].["+ftitle+"]"+"@bill NVARCHAR(50), @fid NVARCHAR(50),@type NVARCHAR(50) as"+" ".join(map(lambda x : (" if(@bill='"+x.FBILLID.FID+"' and @type='"+x.ftype+"') begin "+x.fbody+" end" if(x.FISDELETE==false) else ""), F_whkf_Entity))
c.点击菜单“执行存储过程”,第一次执行需要将ALTER 改为Create
菜单点击事件用python简单生成
import clr 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.ServiceHelper') from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import * from System import * from System.Data import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import List from Kingdee.BOS.ServiceHelper import * def BarItemClick(e): if(e.BarItemKey.ToUpperInvariant()=="FEXCUTESQL"): billid = this.View.BusinessInfo.GetForm().Id.ToUpperInvariant(); PKV = Convert.ToString(this.View.Model.GetPKValue()); sqlGetEmpId =this.View.Model.GetValue("FCONTENT"); DBServiceHelper.Execute(this.Context,sqlGetEmpId); this.View.ShowMessage("执行成功!");
2.在对应单据的对应操作列表的服务插件,中注册以下python语句
import clr 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.ServiceHelper') clr.AddReference('Kingdee.BOS.ServiceHelper') from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import * from System import * from System.Data import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import List from Kingdee.BOS.ServiceHelper import * def EndOperationTransaction(e): for billObj in e.DataEntitys: fid=str(billObj["Id"]); billid=str(this.BusinessInfo.GetForm().Id); operationName=this.FormOperation.Operation.ToString().ToLowerInvariant(); sql = "/*dialect*/select FTITLE=ISNULL('/*dialect*/EXEC ' +FTITLE+ ' @bill,@fid,@type','/*dialect*/'+FBODY) from T_WHKF_FXRULE A INNER JOIN T_WHKF_FXRULEENTRY B ON A.FID=B.FID WHERE A.FDOCUMENTSTATUS='C' AND B.FBILLID='"+str(billid)+"' AND FTYPE='"+str(operationName)+"' AND FISDELETE<>1"; ds = DBServiceHelper.ExecuteDataSet(this.Context,sql); AllRows=ds.Tables[0].Rows; tab = ds.Tables[0]; if(AllRows.Count<=0): continue; for r in AllRows: tmpsql=str(r["FTITLE"]); tmpsql=tmpsql.replace("@bill","'"+billid+"'"); tmpsql=tmpsql.replace("@fid","'"+fid+"'"); tmpsql=tmpsql.replace("@type","'"+operationName+"'"); testsql=tmpsql.replace("'","#"); DBServiceHelper.Execute(this.Context,tmpsql);
即可实现。
自定义反写规则
仅用于学习,请谨慎使用。 标准产品的反写规则,适用于绝大部分场景,对于个别特殊需求,可能要通过二开插件来实现。所以简单做了...
点击下载文档
本文2024-09-16 17:17:07发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14718.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章