воскресенье, 12 апреля 2026 г.

m3DateNumQueryExecutor

{$IfDef FPC}{$CodePage cp1251}{$EndIf FPC}

unit m3DateNumQueryExecutor;

// --------------------------------------------------------------------------
// Родители: "Queries" <> MUID: (66FB115B029F) :: "m3" <> MUID: (66FB10950007) :: "Shared Delphi For Archi" <> MUID: (4ABA2360025A)
// --------------------------------------------------------------------------
// Модуль: "w:\common\components\rtl\Garant\m3\m3DateNumQueryExecutor.pas" GeneratorVersion: 1.0.0.883901
// Стереотип: "<>"
// Элемент модели: "Tm3DateNumQueryExecutor" MUID: (672C8F6000BE)
// --------------------------------------------------------------------------

//#UC START# *672C8F6000BEBeforeDefines*
//#UC END# *672C8F6000BEBeforeDefines*
{$Include daDefine.inc}

interface

uses
 l3IntfUses
 , daDateNumQueryParams
 , l3Ranges
 , m3AttrIndexInterfaces
 , daQueryInterfaces
 , m3QueryInterfaces
 , daEnumerableInterfaces
 , l3Interfaces
 , m4SearchResult
 , daQueryParams
 , l3LongintList
 , daTypes
 , evdDATypes
 , daAbstractQueryExecutor
;

type
 {$If not Defined(_ParamsType_Defined_) }
  {Tm3DateNumQueryExecutor.}_ParamsType_ = TdaDateNumQueryParams;
  {$Define _ParamsType_Defined_ }
  {$Define _ParamsType_IsClass_ }
  {$Define _ParamsType_IsAcceptableForScripts_ }
 {$IfEnd} // not Defined(_ParamsType_Defined_)
 {$Include Mm3QueryExecutor_imp.pas}
 Tm3DateNumQueryExecutor = class(_Mm3QueryExecutor_)
  protected
   function FindByParams(const aParams: TdaDateNumQueryParams;
    const aSearcher: Im3AttrIndexSearcher): Il3RangeEnumerable; override;
  public
   {$If NOT Defined(l3NoSRT)}
   function SetRefTo(var thePlace: Tm3DateNumQueryExecutor): Boolean; overload; {$If Defined(l3HasInl)}inline;{$IfEnd}
   {$IfEnd} // NOT Defined(l3NoSRT)
 end;//Tm3DateNumQueryExecutor

implementation

uses
 l3ImplUses
 , l3Date
 , m3QueryResultSetFromLongintList
 , daQueryExecutorFactory
 , m3AttrIndexSearcher
 , SysUtils
 , l3Enumerators
 , l3InterfacedIntegerList
 , k2Tags
 //#UC START# *672C8F6000BEimpl_uses*
 //, l3Date
 //, k2Tags
 //#UC END# *672C8F6000BEimpl_uses*
;

{$Include Mm3QueryExecutor_imp.pas}

{$If NOT Defined(l3NoSRT)}
function Tm3DateNumQueryExecutor.SetRefTo(var thePlace: Tm3DateNumQueryExecutor): Boolean;
begin
 if (thePlace = Self) then
  Result := false
 else
 begin
  Result := true;
  thePlace.Free;
  thePlace := Self.Use;
 end;//thePlace = Self
end;//Tm3DateNumQueryExecutor.SetRefTo
{$IfEnd} // NOT Defined(l3NoSRT)

function Tm3DateNumQueryExecutor.FindByParams(const aParams: TdaDateNumQueryParams;
 const aSearcher: Im3AttrIndexSearcher): Il3RangeEnumerable;
//#UC START# *670660CF0357_672C8F6000BE_var*
var
 l_DateResult : Il3RangeEnumerable;
 l_MaskResult : Il3RangeEnumerable;
 l_NumberTypeResult : Il3RangeEnumerable;
 l_dnAddNumResult : Il3RangeEnumerable;
 l_HasDate : Boolean;
 l_HasNumber : Boolean;
 l_HasNumberType : Boolean;
 l_FromDate: TStDate;
 l_ToDate: TStDate;
//#UC END# *670660CF0357_672C8F6000BE_var*
begin
//#UC START# *670660CF0357_672C8F6000BE_impl*
 Result := nil;
 l_DateResult := nil;
 l_MaskResult := nil;
 l_NumberTypeResult := nil;
 l_HasDate := false;
 l_HasNumber := false;
 l_HasNumberType := false;

 l_FromDate := aParams.FromDate;
 l_ToDate := aParams.ToDate;
 if (l_FromDate <> 0) or (l_ToDate <> 0) then
 begin
  l_HasDate := true;
  //lSabDate := MakeSab(GlobalDataProvider.DictServer(CurrentFamily).Dict[da_dlDateNums].HackGroupTbl as TParamGroupTbl);
  if (l_ToDate <> 0) then
  begin
   if aParams.FromDate = 0 then // не ищем записи с пустой датой
   begin
    aParams.FromDate := 1;
    l_FromDate := 1;
   end;//aParams.FromDate = 0
   l_DateResult := aSearcher.SearchByDates(l_FromDate, l_ToDate);
   //lSabDate.Select(dnDateFld, l_FromDate, l_ToDate);
  end//l_ToDate <> 0
  else
   l_DateResult := aSearcher.SearchByDates(l_FromDate, High(TStDate));
  //if (fFromDate <> 0) then // это следует из предыдущих if
   //lSabDate.Select(dnDateFld, l_FromDate, GREAT_EQUAL)
   ;
 end;//(l_FromDate <> 0) or (l_ToDate <> 0)

 if (aParams.NumberMask <> '') then
 begin
  l_HasNumber := true;
  l_MaskResult := aSearcher.SearchByNumber(aParams.NumberMask);
  Result := l_MaskResult;
  // - пока так
 end;//aParams.NumberMask <> ''

 if (aParams.DNType <> dnDoc) then
 begin
  l_HasNumberType := true;
  l_NumberTypeResult := aSearcher.SearchByNumberType(aParams.DNType);
  if (aParams.DNType = dnPublish) then
  begin
   l_dnAddNumResult := aSearcher.SearchByNumberType(dnAddNum);
   // - при поиске по dnPublish, dnAddNum тоже годится
   l_NumberTypeResult := Il3RangeEnumerable_JoinWithOther(l_NumberTypeResult, l_dnAddNumResult);
  end//aParams.DNType = dnPublish
  else
  begin
   // - пока оставим эту ветку
  end;//aParams.DNType = dnPublish
 end;//aParams.DNType <> dnDoc

 if l_HasDate
    AND l_HasNumber
    AND l_HasNumberType then
 begin
  Result := Il3RangeEnumerable_Intersect(l_DateResult, l_MaskResult);
  Result := Il3RangeEnumerable_Intersect(Result, l_NumberTypeResult);
 end//l_HasDate
 else
 if l_HasDate
    AND l_HasNumber then
  Result := Il3RangeEnumerable_Intersect(l_DateResult, l_MaskResult)
 else
 if l_HasDate
    AND l_HasNumberType then
  Result := Il3RangeEnumerable_Intersect(l_DateResult, l_NumberTypeResult)
 else
 if l_HasNumber
    AND l_HasNumberType then
  Result := Il3RangeEnumerable_Intersect(l_MaskResult, l_NumberTypeResult)
 else
 if l_HasNumber then
  Result := l_MaskResult
 else
 if l_HasNumberType then
  Result := l_NumberTypeResult
 else
 if l_HasDate then
  Result := l_DateResult
 else
  Assert(false);

 if (Result <> nil) then
  Result := Il3RangeEnumerable_Diff(Result, aSearcher.AllRelated);
  // - тут вычитаем справки
//#UC END# *670660CF0357_672C8F6000BE_impl*
end;//Tm3DateNumQueryExecutor.FindByParams


//#UC START# *672C8F6000BEforDiagramm*
(*
*)
//#UC END# *672C8F6000BEforDiagramm*

end.

Комментариев нет:

Отправить комментарий