Python基础资料自动分配脚本原创
金蝶云社区-Jeffrey_Bao
Jeffrey_Bao
4人赞赏了该文章 93次浏览 未经作者许可,禁止转载编辑于2024年10月22日 22:02:11
###基础资料自动分配

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.DataEntity')
clr.AddReference('Kingdee.BOS.Contracts')
clr.AddReference('Kingdee.BOS.ServiceHelper')
clr.AddReference("Kingdee.K3.MFG.App")

from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Contracts import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.DataEntity 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 *
from Kingdee.BOS.Log import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Core.Metadata.Operation import AllocateParameter
from Kingdee.BOS.Core.Enums import BOSEnums
from Kingdee.K3.MFG.App import AppServiceContext
from Kingdee.BOS.Contracts import IAllocateService


def AfterExecuteOperationTransaction(e):
   
 ##查询组织sql语句,where条件是需要自动分配的组织ID
    strSQL=" SELECT T1.FORGID,T2.FNAME AS ORGNAME FROM T_ORG_ORGANIZATIONS T1  INNER JOIN T_ORG_ORGANIZATIONS_L T2 ON T1.FORGID=T2.FORGID AND T2.FLOCALEID=2052 WHERE T1.FORGID IN (100219,100220) ";
    orgIds =DBUtils.ExecuteDynamicObject(this.Context, strSQL);
   
    if(orgIds.Count <=0):
   
        return;
    mtrlIdLst=List[object]();
    for mtrlObj in e.SelectedRows:
        mtrlId=mtrlObj.DataEntity["Id"];
       
        usrOrdId=mtrlObj.DataEntity["UseOrgId_Id"];
       
        creatOrgId=mtrlObj.DataEntity["CreateOrgId_Id"];
       
        creatOrgIdName=mtrlObj.DataEntity["CreateOrgId"]["Name"].ToString();
       
        if(usrOrdId==creatOrgId):
           
            mtrlIdLst.Add(mtrlId);
            mtrlMeta=MetaDataServiceHelper.Load(this.Context,"BD_MATERIAL");
            for orgId in orgIds:
                allocateParameter=AllocateParameter(mtrlMeta.BusinessInfo,mtrlMeta.InheritPath,creatOrgId,BOSEnums.Enu_AllocateType.Allocate, "Allocate");
               
                allocateParameter.PkId=mtrlIdLst;
                allocateParameter.DestOrgId=orgId["FORGID"];
                allocateParameter.DestOrgName=orgId["ORGNAME"];
                allocateParameter.AutoSubmitAndAudit=True;
                allocateParameter.AllocateUserId=this.Context.UserId;
                allocateService =BusinessDataServiceHelper.Allocate(this.Context,allocateParameter);


图标赞 4
4人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
1人打赏
还没有人打赏,快来当第一个打赏的人吧!