procedure TCCBGSQDForm.FlowBroker1CreateFlowOutFlowTasks(Sender: TObject; Command: TFlowOutCommand);
var
lFlowTask:TFlowTask;
AAssignMode:TTaskAssignMode;
lRange:String;
AExecutorAmount:TTaskExecutorAmount;
i:integer;
lDeptList:TStrings;
lPositionList:TStrings;
lPersonList:TStrings;
APersonList:Tstrings;
//lOrgURL:TOrgURL;
//lQuery: TQuery;
begin
lRange := '';
lFlowTask := Command.FlowTasks.FindFlowTask('BMJLSP');
if lFlowTask <> nil then
begin
lDeptList:=TStringList.Create;
lPositionList:=TStringList.Create;
lPersonList:=TStringList.Create;
try
GetDeptPositionListByPersonList(lPersonList,lDeptList,lPositionList);
for i := 0 to lPersonList.Count -1 do
begin
if lRange ='' then
lRange:='OrgKey('''+lDeptList.Strings+''','''+lPositionList.Strings+''','''+lPersonList.Strings+''')'
else
lRange:=lRange + ' or '+'OrgKey('''+lDeptList.Strings+''','''+lPositionList.Strings+''','''+lPersonList.Strings+''')'
end;
//lRange:='OrgKey(JSFZC,KFCS,4956)';
if lRange='' then
lFlowTask.ExecutorMustBeFuncOwner:=True
else
lFlowTask.ExecutorMustBeFuncOwner:=False;
lFlowTask.ExecutorAmount:= AExecutorAmount; //TTaskExecutorAmount.teaMulti;
lFlowTask.ExecutorKinds := [TTaskExecutorKind.ekPersonMember]; //执行者类型 人员成员
lFlowTask.AssignMode := AAssignMode;// TTaskAssignMode.amSingleness;
case AAssignMode of
TTaskAssignMode.amSingleness:
begin
lFlowTask.ExecuteMode := TTaskExecuteMode.emExclusive;
end;
TTaskAssignMode.amTogether:
begin
lFlowTask.ExecuteMode := TTaskExecuteMode.emSimultaneous ; //任务执行方式 同时执行
end;
end;
lFlowTask.AllowExecutorRange:=lRange;
lFlowTask.ExecutorRange:=lRange;
{ lFlowTask.Executors.Clear; //删除缺省执行者
lOrgURL:=TOrgURL.Create('JSFZC','KFCS','4956' );
lFlowTask.Executors.Add(lOrgURL); }
finally
lDeptList.Free;
lPositionList.Free;
lPersonList.Free;
end;
end;
end;
Static procedure TCCBGSQDForm.GetDeptPositionListByPersonList(var APersonMember,ADeptList,APositionList:TStrings);
var
lPersonMembers: TList;
lPersonMember: TOrgUnit;
i,j: integer;
lQuery: TQuery;
begin
lPersonMembers := TList.Create;
APersonMember.Clear;
ADeptList.Clear;
APositionList.Clear;
lQuery := TQuery.Create(nil);
lQuery.ConnectionString :='DATABASEURL=Biz:\SYSTEM\SYSTEM.DATABASE';
//lQuery.CommandText := 'SELECT FDEPT,FPOSITION,FPERSON as FreportNo From TORGSYSTEM where '+
lQuery.CommandText := 'SELECT FPERSON as FreportNo From TORGSYSTEM where '+
'FDEPT = '''+TSystemCore.Operator.Positions[0].PositionMember.Parent.ID+''' and '+
'FPERSON <> '''' and '+
'FPOSITION = ''CZ1'' ';
lQuery.Open;
try
for j:=0 to lQuery.RecordCount-1 do
begin
lPersonMembers.Clear;
OrgSys.OrgSystem.GetPersonMembers(lQuery.Fields.AsString, lPersonMembers); //
for i := 0 to lPersonMembers.count-1 do
begin
lPersonMember := TOrgUnit(lPersonMembers.Items);
//lPersonMember := TOrgUnit(lQuery.Fields.AsString);
APersonMember.Add(lPersonMember.ID);
APositionList.Add(lPersonMember.Parent.ID);
ADeptList.Add(lPersonMember.Parent.Parent.ID);
end;
end;
finally
lPersonMembers.Free;
end;
lQuery.Free;
end; |