Static procedure TFlowUtils.ModifyExecutorRangeByPersonList(Command:TFlowOutCommand;ANextProcUnit:string;APersonList:Tstrings;AAssignMode:TTaskAssignMode;AExecutorAmount:TTaskExecutorAmount);
var
lFlowTask:TFlowTask;
lRange:String;
i:integer;
lDeptList:TStrings;
lPositionList:TStrings;
lPersonList:TStrings;
begin
lRange := '';
lFlowTask := Command.FlowTasks.FindFlowTask(ANextProcUnit);
if lFlowTask <> nil then
begin
lDeptList:=TStringList.Create;
lPositionList:=TStringList.Create;
lPersonList:=TStringList.Create;
try
GetDeptPositionListByPersonList(APersonList,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;
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;
finally
lDeptList.Free;
lPositionList.Free;
lPersonList.Free;
end;
end;
end;
Static procedure TFlowUtils.GetDeptPositionListByPersonList(APersonList:Tstrings;var APersonMember,ADeptList,APositionList:TStrings);
var
lPersonMembers: TList;
lPersonMember: TOrgUnit;
i,j: integer;
begin
lPersonMembers := TList.Create;
APersonMember.Clear;
ADeptList.Clear;
APositionList.Clear;
try
for j:=0 to APersonList.Count-1 do
begin
lPersonMembers.Clear;
OrgSys.OrgSystem.GetPersonMembers(APersonList.Strings[j], lPersonMembers); //
for i := 0 to lPersonMembers.count-1 do
begin
lPersonMember := TOrgUnit(lPersonMembers.Items);
APersonMember.Add(lPersonMember.ID);
APositionList.Add(lPersonMember.Parent.ID);
ADeptList.Add(lPersonMember.Parent.Parent.ID);
end;
end;
finally
lPersonMembers.Free;
end;
end; |