#FNOFFRECAMOUNT
#引入clr运行库
import clr
#import numpy as np
#添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.Business.DynamicForm')
clr.AddReference('Kingdee.BOS.ServiceHelper')
clr.AddReference('Kingdee.BOS.Contracts')
from System import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core import List
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.App.Data import DBUtils
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs import *
from Kingdee.BOS import Orm
from Kingdee.BOS import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Orm import *
from Kingdee.BOS.Core.DynamicForm.Operation import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.App import *
#from Kingdee.BOS.App.ServiceHelper import *
from Kingdee.BOS.Contracts import *
from Kingdee.BOS.Util.OperateOptionUtils import *
from System.Collections.Generic import *
from System.Collections.Generic import List, Dictionary
def OnPreparePropertys(e):
e.FieldKeys.Add("FDOSTATUS");
def EndOperationTransaction(e):
for extended in e.DataEntitys:
#entity = extended.DataEntity;
fid=extended["Id"];
rules = ConvertServiceHelper.GetConvertRules(this.Context, "BIJ_CXLLD", "STK_TransferDirect");
rule=rules[0];
for r1 in rules:
if r1.Key=="BIJ_CXZYDTOCXLLD":
rule=r1;
#i=rules.Count;
#rule =rules[0];
#rules.FirstOrDefault(t=>t.IsDefault);
#rule="BIJ_CXZYDTOCXLLD";
selectedrows=[];
primarykey=str(fid);
row=ListSelectedRow(primarykey,"",0,"BIJ_CXLLD");
selectedrows.append(row);
selectedrows=tuple(selectedrows);
pushargs=PushArgs(rule,selectedrows);
pushargs.TargetBillTypeId="ce8f49055c5c4782b65463a3f863bb4a";
pushargs.TargetOrgId=0;
PushResult=ConvertServiceHelper.Push(this.Context,pushargs,OperateOption.Create());
SuccessFlag=PushResult.IsSuccess;
if str(SuccessFlag)=="False":
Errmsg="";
if PushResult.OperateResult.Count>0:
Errmsg=PushResult.OperateResult[0].Message;
if PushResult.ValidationErrors.Count>0:
Errmsg=Errmsg+","+PushResult.ValidationErrors[0].Message;
Errmsg=Errmsg+","+str(PushResult.InteractionContext);
raise NameError("下推直接调拨单失败:"+Errmsg);
objs=[];
for p in PushResult.TargetDataEntities:
obj=p.DataEntity;
obj["FBIJAUTOPUSHFLAG"]=True;
objs.append(obj);
objs=tuple(objs);
targetBillMeta=MetaDataServiceHelper.Load(this.Context, "STK_TransferDirect");
saveOption=OperateOption.Create();
saveOption.SetVariableValue("IgnoreWarning",True);
SaveResult=BusinessDataServiceHelper.Save(this.Context, targetBillMeta.BusinessInfo, objs, saveOption, "Save");
SuccessFlag=SaveResult.IsSuccess;
if str(SuccessFlag)=="False":
Errmsg="";
if SaveResult.OperateResult.Count>0:
Errmsg=SaveResult.OperateResult[0].Message;
if SaveResult.ValidationErrors.Count>0:
Errmsg=Errmsg+","+SaveResult.ValidationErrors[0].Message;
Errmsg=Errmsg+","+str(SaveResult.InteractionContext);
raise NameError("保存直接调拨单失败:"+Errmsg);
#meta=MetaDataServiceHelper.Load(this.Context, "STK_TransferDirect");
pkobjs=[];
pkobj=SaveResult.OperateResult[0].PKValue;
pkobjs.append(pkobj);
pkobjs=tuple(pkobjs);
chkEntitys=[];
SubmitResult=BusinessDataServiceHelper.Submit(this.Context, targetBillMeta.BusinessInfo,pkobjs, "Submit");
SuccessFlag=SubmitResult.IsSuccess;
if str(SuccessFlag)=="False":
Errmsg="";
if SubmitResult.OperateResult.Count>0:
Errmsg=SubmitResult.OperateResult[0].Message;
if SubmitResult.ValidationErrors.Count>0:
Errmsg=Errmsg+","+SubmitResult.ValidationErrors[0].Message;
Errmsg=Errmsg+","+str(SubmitResult.InteractionContext);
raise NameError("提交直接调拨单失败:"+Errmsg);
auditOption=OperateOption.Create();
auditOption.SetVariableValue("IgnoreWarning",True);
auditOption.SetVariableValue("_IgnoreInteraction_",True);
pkobjs=list(pkobjs);
ss1=KeyValuePair[object, object]();
pkEntityIds=List[type(ss1)]();
for p1 in pkobjs:
pkEntityId=KeyValuePair[object, object](p1,"");
pkEntityIds.Add(pkEntityId);
paras=List[object]();
paras.Add("1");
paras.Add("");
AuditResult=BusinessDataServiceHelper.SetBillStatus(this.Context, targetBillMeta.BusinessInfo, pkEntityIds,paras,"Audit",auditOption);
SuccessFlag=AuditResult.IsSuccess;
if str(SuccessFlag)=="False":
Errmsg="";
if AuditResult.OperateResult.Count>0:
Errmsg=AuditResult.OperateResult[0].Message;
if AuditResult.ValidationErrors.Count>0:
Errmsg=Errmsg+","+AuditResult.ValidationErrors[0].Message;
Errmsg=Errmsg+","+str(AuditResult.InteractionContext);
raise NameError("审核直接调拨单失败:"+Errmsg);
推荐阅读