python列表插件(能与数据库交互不是那么迫切,暂时记录代码,仅供参考)原创
金蝶云社区-ALAOK
ALAOK
10人赞赏了该文章 1,021次浏览 未经作者许可,禁止转载编辑于2020年07月06日 12:11:20

import clr
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.ServiceHelper")
from Kingdee.BOS.Core.List.PlugIn import *
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Core.Permission import *
from Kingdee.BOS.ServiceHelper import *
def AfterBarItemClick(e):
    #this.View.ShowMessage("执行")
    #DataTable dt;
    if e.BarItemKey=="AI_BTNTEST":        
        #把当前组织‘是否为结算点’更新为0
        updatesql="update T_ENG_ROUTEOPERDETAIL set F_AI_YESNOJSD=0  where FPROORGID={0}".format(str(this.Context.CurrentOrganizationInfo.ID))
        flag = DBUtils.Execute(this.Context, updatesql)
        if flag>0:
            selsql="select FDETAILID,FPROCESSID,FENTRYID,FWORKCENTERID from T_ENG_ROUTEOPERDETAIL where FPROORGID={0} order by FENTRYID,FOPERNUMBER".format(str(this.Context.CurrentOrganizationInfo.ID))
            dt = DBServiceHelper.ExecuteDynamicObject(this.Context, selsql)
            updatestr="";
            for i in range(len(dt)) :
                if i+1==len(dt):
                    continue
                else:
                    if dt[i][2]==dt[i + 1][2]:    #判断当前行与下一行是否为同一个单据
                        if dt[i][3]==dt[i + 1][3]:        #判断当前行与下一行是否为同一个工作中心
                            continue
                        else:
                            if getThisOrgDDID()!="":        #判断当前组织是否有电镀
                                if str(dt[i][1]) != getThisOrgDDID():
                                    if updatestr=="":
                                        updatestr = str(dt[i][0])
                                    else:
                                        updatestr = updatestr + "," +str(dt[i][0])
                                else:
                                    if i != 0 && str(dt[i - 1][3]) == str(dt[i + 1][3]):
                                                           laststr =find_last(updatestr,",")
                                                            updatestr = updatestr[0, laststr]
                                                            continue
                                                        else :
                                                            continue
                            else:
                                if updatestr == "":                                            
                                                        updatestr = str(dt[i][0])
                                                else:                                            
                                                        updatestr = updatestr + "," + str(dt[i][0])
                else:
                    if this.Context.CurrentOrganizationInfo.ID == 101293 && dt[i][1] == 356519:
                                    #1.将当前行上一行的主键从更新字符串中剔除                                    
                                    #2.将当前行主键加入字符串
                                    updatestr = updatestr.replace(str(dt[i - 1][0]),"")
                                else :
                                    continue
    updatejsd="update T_ENG_ROUTEOPERDETAIL set F_AI_YESNOJSD=1 where FDETAILID in ({0})".format(str(updatestr))
    count=DBUtils.Execute(this.Context, updatejsd)
    if count > 0:
        this.View.ShowMessage("修改成功")
    else:
        this.View.ShowMessage("修改失败")
def getThisOrgDDID():
    strs = ""
      sql="select t0.FID from T_ENG_PROCESS t0 inner join T_ENG_PROCESS_L t1 on(t0.FID=t1.FID and t1.FNAME='电镀' and t0.FUSEORGID={0} and t0.FDOCUMENTSTATUS='C' and t0.FFORBIDSTATUS='A' and t1.FLOCALEID=2052)".format(str(this.Context.CurrentOrganizationInfo.ID))
      dt=DBServiceHelper.ExecuteDynamicObject(this.Context, sql)
    if len(dt) > 0:
        strs=str(dt[0][0])
    return strs             
                 

赞 10