一共修改了3个地方,注释:“//20090210”是修改的
function TCIRCSCOMMONFILTER.RebuildRightsFilterText: string;
const
SSOrgURLIn = 'T1.FSORGURL IN(%s) OR (T1.FSPERSON = ''%s'')';
SSOrgURLIn_Pos = 'T1.FSORGURL IN(%s) OR ((T1.FSDEPT = ''%s'') AND ' +
'(T1.FSPOSITION = ''%s'') AND (T1.FSPERSON = ''%s''))';
//SSOrgURLLike = 'T1.FSORGURL LIKE ''%s%%''';
SSOrgURLLike = 'T1.FSORGURL LIKE ''%s'''; // 20090210
SSPositionWhere = 'T1.FSPOSITION = ''%s''';
SROrgEmpty = 'T1.FRPERSONNAMES IS NULL OR T1.FRPERSONNAMES = ''''';
SROrgURLIn = 'TTASKMESSAGE.FRORGURL IN(%s) OR (TTASKMESSAGE.FRPERSON = ''%s'') ';
SROrgURLIn_Pos = 'TTASKMESSAGE.FRORGURL IN(%s) OR ((TTASKMESSAGE.FRDEPT = ''%s'') AND ' +
'(TTASKMESSAGE.FRPOSITION = ''%s'') AND (TTASKMESSAGE.FRPERSON = ''%s''))';
//SROrgURLLike = 'TTASKMESSAGE.FRORGURL LIKE ''%s%%''';
SROrgURLLike = 'TTASKMESSAGE.FRORGURL LIKE ''%s'''; // 20090210
SRPositionWhere = 'TTASKMESSAGE.FRPOSITION = ''%s''';
SMain = 'FGUID IN(SELECT TTASKMESSAGE.FTASKGUID FROM TTASKMESSAGE WHERE (%s) UNION SELECT T1.FGUID FROM TTASK T1 WHERE (%s))';
// 新闻公告和会议纪要在部门模式下,默认不可见
cExceptTaskType1 = 'NOT (T1.FTYPE IN (''CHIEFMEETINGREC'', ''CHIEFMEETINGRECDEAL'', ''NEWSPLACARD''))';
cExceptTaskType2 = 'NOT (TTask.FTYPE IN (''CHIEFMEETINGREC'', ''CHIEFMEETINGRECDEAL'', ''NEWSPLACARD''))';
var
I: Integer;
lBizURL: TBizURL;
lKind: TOrgUnitKind;
lOperatorID: string;
lDept, lPos, lPer: string;
lSend, lProces: TStringList;
S, lDateTimeFilter: string;
lProcesStr, lSendStr, lSql: string;
lDeptEmpty: Boolean;
begin
lBizURL := TBizURL.Create;
lSend := TStringList.Create;
lProces := TStringList.Create;
try
lDeptEmpty := not FPersonChecked and not FDeptChecked and
(FCheckedSubordinationNodes.Count = 0);
if FCheckedSubordinationNodes.Count > 0 then
for I := 0 to FCheckedSubordinationNodes.Count - 1 do
begin
lSend.Add(SysUtils.Format(SSOrgURLLike, [DoGetQueryURLStr(TBizURL(FCheckedSubordinationNodes.Objects[I]).URL)]));
lProces.Add(SysUtils.Format(SROrgURLLike, [DoGetQueryURLStr(TBizURL(FCheckedSubordinationNodes.Objects[I]).URL)]));
end
else
begin
if lDeptEmpty then
begin
for I := 0 to SubordinationURLs.Count - 1 do
begin
lBizURL.URL := SubordinationURLs[I];
lKind := BizSys.BizSystem.GetObjectKind(lBizURL);
if lKind = TOrgUnitKind.boPosition then
begin
lSend.Add(SysUtils.Format(SSPositionWhere, [lBizURL.ID]));
lProces.Add(SysUtils.Format(SRPositionWhere, [lBizURL.ID]));
end
else
begin
lSend.Add(SysUtils.Format(SSOrgURLLike, [DoGetQueryURLStr(lBizURL.URL)]));
lProces.Add(SysUtils.Format(SROrgURLLike, [DoGetQueryURLStr(lBizURL.URL)]));
end
end;
end;
end;
if FPersonChecked or lDeptEmpty then
begin
if TOrgUtils.GetIsPersonMember(Context) then
begin
TContextUtils.GetContextOperator(Context, lDept, lPos, lPer);
lSend.Add(SysUtils.Format(SSOrgURLIn_Pos, [DoGetQueryURLStr(PersonMemberURLs),
lDept, lPos, lPer]));
lProces.Add(SysUtils.Format(SROrgURLIn_Pos, [DoGetQueryURLStr(PersonMemberURLs),
lDept, lPos, lPer]));
end
else
begin
lOperatorID := TContextUtils.GetOperator(Context).ID;
lSend.Add(SysUtils.Format(SSOrgURLIn, [DoGetQueryURLStr(PersonMemberURLs), lOperatorID]));
lProces.Add(SysUtils.Format(SROrgURLIn, [DoGetQueryURLStr(PersonMemberURLs), lOperatorID]));
end;
end;
if FDeptChecked or lDeptEmpty then
begin
for I := 0 to SuperiorDeptURLs.Count - 1 do
begin
lBizURL.URL := SuperiorDeptURLs[I];
lKind := BizSys.BizSystem.GetObjectKind(lBizURL);
if lKind = TOrgUnitKind.boPosition then
begin
lSQL := SysUtils.Format(SSPositionWhere, [lBizURL.ID]);
if SubordinationURLs.Count = 0 then
begin
// 发到部门的也包含 lSQL := AddAndCondition(lSQL,'NOT('+SROrgEmpty+')');
lSQL := AddAndCondition(lSQL, cExceptTaskType1);
end;
if not FPersonChecked and not lDeptEmpty then
begin
TContextUtils.GetContextOperator(Context, lDept, lPos, lPer);
lSQL := AddAndCondition(lSQL, SysUtils.Format('NOT (%s)', [SysUtils.Format(SSOrgURLIn_Pos,
[DoGetQueryURLStr(PersonMemberURLs), lDept, lPos, lPer])]));
end;
lSend.Add(lSQL);
lSQL := SysUtils.Format(SRPositionWhere, [lBizURL.ID]);
if SubordinationURLs.Count = 0 then //modify by maoguangyu 2007-5-12
begin
// 发到部门的也包含 lSQL := AddAndCondition(lSQL, 'NOT(TTASKMESSAGE.FRPERSON IS NULL OR TTASKMESSAGE.FRPERSON = '''')');
lSQL := AddAndCondition(lSQL, cExceptTaskType2);
end;
if not FPersonChecked and not lDeptEmpty then
begin
TContextUtils.GetContextOperator(Context, lDept, lPos, lPer);
lSQL := AddAndCondition(lSQL, SysUtils.Format('NOT (%s)', [SysUtils.Format(SROrgURLIn_Pos,
[DoGetQueryURLStr(PersonMemberAndParentURLs), lDept, lPos, lPer])]));
end;
lProces.Add(lSQL);
end
else
begin
lSQL := SysUtils.Format(SSOrgURLLike, [DoGetQueryURLStr(lBizURL.URL)]);
if SubordinationURLs.Count = 0 then
begin
// 发到部门的也包含 lSQL := AddAndCondition(lSQL,'NOT ('+ SROrgEmpty+')');
lSQL := AddAndCondition(lSQL, cExceptTaskType1);
end;
if not FPersonChecked and not lDeptEmpty then
begin
lOperatorID := TContextUtils.GetOperator(Context).ID;
lSQL := AddAndCondition(lSQL, SysUtils.Format('NOT (%s)', [SysUtils.Format(SSOrgURLIn,
[DoGetQueryURLStr(PersonMemberURLs), lOperatorID])]));
end;
lSend.Add(lSQL);
lSQL := SysUtils.Format(SROrgURLLike, [DoGetQueryURLStr(lBizURL.URL)]);
if SubordinationURLs.Count = 0 then //modify by maoguangyu 2007-5-12 过滤有问题
begin
// 发到部门的也包含 lSQL := AddAndCondition(lSQL, 'NOT(TTASKMESSAGE.FRPERSON IS NULL OR TTASKMESSAGE.FRPERSON = '''')');
lSQL := AddAndCondition(lSQL, cExceptTaskType2);
end;
if not FPersonChecked and not lDeptEmpty then
begin
{lSQL := AddAndCondition(lSQL, SysUtils.Format('NOT (%s)', [SysUtils.Format(SROrgURLIn,
[DoGetQueryURLStr(PersonMemberAndParentURLs), lOperatorID])]));}
lSQL := AddAndCondition(lSQL, SysUtils.Format('NOT (TTASKMESSAGE.FRORGURL IN (%s))', [DoGetQueryURLStr(PersonMemberURLs)])); // 20090210
end;
lProces.Add(lSQL);
end
end;
end;
lProcesStr := JSSysUtils.FormatAndUniteStr(' OR ', '%s', lProces);
lSendStr := JSSysUtils.FormatAndUniteStr(' OR ', '%s', lSend);
Result := SysUtils.Format(SMain, [lProcesStr, lSendStr]);
//为了使实现参与时间的过滤,故意做在这里的
lDateTimeFilter := GetDateTimeFilter;
if lDateTimeFilter <> '' then
Result := SysUtils.Format('%s AND (%s)', [lDateTimeFilter, Result])
else
Result := SysUtils.Format('(%s)', [Result]);
if ccbState.Text <> SAllState then
begin
if clbState.Checked[0] then
Result := SysUtils.Format('%s AND (TTASK.FSTATE IN(%s))', [Result, DoGetTaskStatesQueryStr(TTask.CanProcessTaskStates)])
else if clbState.Checked[1] then
Result := SysUtils.Format('%s AND (TTASK.FSTATE IN(%s))', [Result, DoGetTaskStatesQueryStr(TTask.FinishedTaskStates)]);
end;
S := GetBizGroupFilterText;
if S <> '' then
Result := Result + ' and (' + S + ')';
finally
lProces.Free;
lSend.Free;
lBizURL.Free;
end;
end; |