applicant_result

This commit is contained in:
Алексей Заблоцкий 2023-10-30 20:54:41 +03:00
parent ac9caf456f
commit 274ab8994e
7 changed files with 193 additions and 78 deletions

View File

@ -326,12 +326,12 @@ end;
function TCommand.getInt(keyName: string; defaultValue: integer): integer;
begin
result := StrToIntDef(fResult.Keys.Values[keyName],defaultValue);
result := StrToIntDef(fData.Keys.Values[keyName],defaultValue);
end;
function TCommand.getString(KeyName: string): string;
begin
result := fResult.Keys.Values[KeyName];
result := fData.Keys.Values[KeyName];
end;
constructor TCommand.Create(aConnect: TBaseConnection; ASubClass: string);

View File

@ -25,6 +25,7 @@ type
flogger: TLogger;
class function DeleteLastChar(const St: String; const CharCount: integer=1): String;
public
class function FloatAsSQL(Value: Double): String;
class function PeriodAsSQL(BegDate, EndDate: TDateTime): string;
class function DateAsSQL(Date: TDateTime): String;
@ -40,6 +41,7 @@ type
class procedure UpdateWithArguments(var code: string; const Arguments: TStrings);
property logger: TLogger read flogger write flogger;
property connection: TnnzConnection read fCon;
function CheckConnection: boolean;
function QueryValue(ASQL: string; Default: string=''): string;
function QueryIntValue(ASQL: string): integer;
function GetData(ASQL: string): TDataSet;
@ -243,6 +245,20 @@ begin
end;
end;
function TNIDBDM.CheckConnection: boolean;
begin
if not connection.Connected then
OpenConnection;
try
connection.ExecuteSQL('SELECT 1');
result := true;
except
connection.Close(true);
OpenConnection;
result := false;
end;
end;
@ -288,6 +304,7 @@ end;
function TNIDBDM.QueryValue(ASQL: string; Default: string): string;
begin
log(mtDebug,self,'QueryValue'#13#10+ASQL);
CheckConnection;
with TnnzQuery.Create(self) do
try
Connection := fcon;
@ -302,6 +319,7 @@ end;
function TNIDBDM.QueryIntValue(ASQL: string): integer;
begin
log(mtDebug,self,'QueryIntValue'#13#10+ASQL);
CheckConnection;
with TnnzQuery.Create(self) do
try
Connection := fcon;
@ -317,6 +335,7 @@ end;
function TNIDBDM.GetData(ASQL: string): TDataSet;
begin
log(mtDebug,self,'getData '#13#10+ASQL);
CheckConnection;
result := TnnzQuery.Create(self);
with result as TnnzQuery do
begin
@ -356,6 +375,7 @@ end;
procedure TNIDBDM.ExecuteSQL(ASQL: string);
begin
log(mtDebug,self,'ExecuteSQL '+ASQL);
CheckConnection;
connection.ExecuteSQL(ASQL);
end;

View File

@ -3,8 +3,8 @@ object ConnectionsDM: TConnectionsDM
OnDestroy = DataModuleDestroy
OldCreateOrder = False
Height = 150
HorizontalOffset = 677
VerticalOffset = 301
HorizontalOffset = 1016
VerticalOffset = 342
Width = 533
object Process1: TProcess
Active = False

View File

@ -213,6 +213,22 @@ begin
result := true;
exit;
end;
if ACommand='help' then
begin
result := true;
rValues := TStringList.Create;
rvalues.Add('"help"');
rvalues.Add('"version"');
rValues.add('"reports"');
rValues.add('{action:"arguments",params:["name"]}');
rValues.add('{action:"login",params:["user","password"]}');
rValues.add('{action:"logout",params:["connect"]}');
rValues.add('{action:"test",params:["connect"]}');
rValues.add('{action:"option_values",params:["connect","report","name"]}');
rValues.add('{action:"report",params:["connect","name"]}');
rValues.add('{action:"status",params:["connect","operation"]}');
rValues.add('{action:"result",params:["connect","operation"]}');
end;
if ACommand='version' then
begin
result := true;

Binary file not shown.

View File

@ -1,7 +1,7 @@
object CGIServerGUI: TCGIServerGUI
Left = 333
Left = 500
Height = 566
Top = 224
Top = 219
Width = 870
Caption = 'Сервер отчетов LMS'
ClientHeight = 566

View File

@ -24,6 +24,7 @@ type
ColCount: integer;
function MakeCols(): string;
function UpdateEnrollStatus(): integer;
procedure MakeProblemsTable();
public
class function CommandSubClass: string; override;
procedure Prepare; override;
@ -60,7 +61,14 @@ begin
SQL := format(
'DROP TABLE IF EXISTS tmpExams; '+
'CREATE TEMPORARY TABLE tmpExams AS '+
'SELECT trim(t.ExamName) as ExamName, COALESCE(NULLIF(FIND_IN_SET(trim(t.ExamName),''Русский язык,Математика,Иностранный язык''),0),min(t.sorting)+6 ) as sorting FROM ( '+
'SELECT trim(t.ExamName) as ExamName, '+
'CASE t.ExamName '+
' WHEN ''Русский язык'' THEN 1 '+
' WHEN ''Математика'' THEN 2 '+
' WHEN ''Иностранный язык'' THEN 3 '+
' ELSE min(t.sorting)+6 '+
'END as sorting '+
'FROM ( '+
' SELECT '''' as ExamName, 0 as sorting '+
' %2:s '+
' ) t '+
@ -114,43 +122,44 @@ var
begin
DateFilter := '';
if cbStream > 0 then
DateFilter := ' AND cast(a1.Date as DATE) BETWEEN %10:s AND %11:s ';
DateFilter := ' AND cast(a1.Date as DATE) BETWEEN %10:s AND %11:s '#13#10;
for i := 1 to 10 do
sParts[i] := '';
for i := 1 to 8 do
begin
sParts[1] := sParts[1] + format(
'+IF(COALESCE(ep.psycho_mode%0:d,0)>=0,gradevalue((COALESCE(ep.psycho_mode%0:d,0)+1)*a1.EnterTest%0:dGrade,0),0)',[i]);
'+case when COALESCE(ep.psycho_mode%0:d,0)>=0 then (COALESCE(ep.psycho_mode%0:d,0)+1)*asnumeric(a1.EnterTest%0:dGrade) else 0 end '#13#10,[i]);
sParts[6] := sParts[6] + format(' and case coalesce(ep.psycho_mode%0:d,0) '+
'when -3 then true '+
'when -2 then coalesce(a1.EnterTest%0:dGrade,'''')=''да'' '+
'when -1 then coalesce(a1.EnterTest%0:dGrade,'''')=''нет'' '+
'else ROUND(10000*coalesce(a1.EnterTest%0:dGrade,0))>=ROUND(10000*coalesce(ep.psycho_pass%0:d,ep.psycho_min%0:d,-10)) '+
'end ',
'else ROUND(10000*coalesce(asnumeric(a1.EnterTest%0:dGrade),0))>=ROUND(10000*coalesce(ep.psycho_pass%0:d,ep.psycho_min%0:d,-10)) '+
'end '#13#10,
[i]);
sParts[8] := sParts[8] + format(
', IF( ep.psycho_mode%0:d=-1 AND coalesce(a1.EnterTest%0:dGrade,'''')<>''нет'',ep.psycho_name%0:d,null) ',[i]);
', case when ep.psycho_mode%0:d=-1 AND coalesce(a1.EnterTest%0:dGrade,'''')<>''нет'' then ep.psycho_name%0:d else null end '#13#10,[i]);
sParts[8] := sParts[8] + format(
', IF( ep.psycho_mode%0:d=-2 AND coalesce(a1.EnterTest%0:dGrade,'''')<>''да'',concat(''не пройден тест: ('',ep.psycho_name%0:d,'')''),null) ',[i]);
', case when ep.psycho_mode%0:d=-2 AND coalesce(a1.EnterTest%0:dGrade,'''')<>''да'' then concat(''не пройден тест: ('',ep.psycho_name%0:d,'')'') else null end '#13#10,[i]);
sParts[8] := sParts[8] + format(
', IF( ep.psycho_mode%0:d in (0,1,2,3,4,5,6,7) '+
' AND ROUND(10000*coalesce(a1.EnterTest%0:dGrade,0))<ROUND(10000*coalesce(ep.psycho_pass%0:d,ep.psycho_min%0:d,-10)),concat(''не пройден тест: ('',ep.psycho_name%0:d,'')''),null) ',[i]);
', case when ep.psycho_mode%0:d in (0,1,2,3,4,5,6,7) '+
' AND ROUND(10000*coalesce(asnumeric(a1.EnterTest%0:dGrade),0))<ROUND(10000*coalesce(ep.psycho_pass%0:d,ep.psycho_min%0:d,-10)) '+
' then concat(''не пройден тест: ('',ep.psycho_name%0:d,'')'') else null end '#13#10,[i]);
if i <= 6 then
begin
sParts[2] := sParts[2] + format(
' COALESCE(NULLIF(g.Exam%0:dColName,''''),g.EnterExam%0:dName,a1.EnterExam%0:dName) as Col%0:d, ',[i]);
' COALESCE(NULLIF(g.Exam%0:dColName,''''),g.EnterExam%0:dName,a1.EnterExam%0:dName) as Col%0:d, '#13#10,[i]);
sParts[3] := sParts[3] + format(
' a1.EnterExam%0:dGrade as Grade%0:d, ',[i]);
' a1.EnterExam%0:dGrade as Grade%0:d, '#13#10,[i]);
sParts[4] := sParts[4] + format(
' and (coalesce(gradevalue(a1.EnterExam%0:dGrade,1)>= coalesce(g.Pass%0:dGrade,0),false) or NULLIF(a1.EnterExam%0:dName,'''') IS NULL) ',[i]);
' and (coalesce(gradevalue(a1.EnterExam%0:dGrade,1)>= coalesce(g.Pass%0:dGrade,0),false) or NULLIF(a1.EnterExam%0:dName,'''') IS NULL) '#13#10,[i]);
sParts[5] := sParts[5] + format(
' and coalesce(a1.EnterExam%0:dGrade NOT LIKE ''н%%'',true) ',[i]);
' and coalesce(a1.EnterExam%0:dGrade NOT LIKE ''н%%'',true) '#13#10,[i]);
sParts[7] := sParts[7] + format(
', IF (NULLIF(a1.EnterExam%0:dName,'''') IS NOT NULL '+
', case when NULLIF(a1.EnterExam%0:dName,'''') IS NOT NULL '+
' AND (coalesce(gradevalue(a1.EnterExam%0:dGrade,1)< coalesce(g.Pass%0:dGrade,0),false) '+
' OR coalesce(a1.EnterExam%0:dGrade LIKE ''незачет%%'',false)),a1.EnterExam%0:dName,null) ',[i]);
' OR coalesce(a1.EnterExam%0:dGrade LIKE ''незачет%%'',false)) then a1.EnterExam%0:dName else null end '#13#10,[i]);
end;
end;
@ -160,42 +169,41 @@ begin
'or coalesce(gradevalue(a1.EnterExam3Grade,1)>=coalesce(g.Pass3Grade,0),false) '+
'or coalesce(gradevalue(a1.EnterExam4Grade,1)>=coalesce(g.Pass4Grade,0),false) '+
'or coalesce(gradevalue(a1.EnterExam5Grade,1)>=coalesce(g.Pass5Grade,0),false) '+
'or coalesce(gradevalue(a1.EnterExam6Grade,1)>=coalesce(g.Pass6Grade,0),false)) ';
'or coalesce(gradevalue(a1.EnterExam6Grade,1)>=coalesce(g.Pass6Grade,0),false)) '#13#10;
SQL := format(
'DROP TABLE IF EXISTS tmp_rpt_applicant_us; '+
'CREATE TEMPORARY TABLE tmp_rpt_applicant_us AS '+
'DROP TABLE IF EXISTS tmp_rpt_applicant_us; '#13#10+
'CREATE TEMPORARY TABLE tmp_rpt_applicant_us AS '#13#10+
'SELECT '+
' a.xp_key, '+
' a.s_year_id, '+
' a.trajectory, '+
' subj.Subject, '+
' CONCAT_WS('' '',UPPER(a.Child_LastName),a.Child_FirstName,a.Child_MidName) AS FIO, '+
' CONCAT_WS('' '',UPPER(a.Child_LastName),a.Child_FirstName,a.Child_MidName) AS FIO, '#13#10+
' a.Child_Birth, '+
' a.Child_Class, '+
' CASE WHEN a.testready<>0 and coalesce(a.scr_fail,0) = 0 THEN ''годен'' ELSE ''не годен'' END AS isready, '+
' COALESCE(a.coeff,1) as coeff, '+
' a.sex, '+
' COALESCE(a.coeff,1) as coeff, a.sex, '+
' COALESCE(NULLIF(a2.Privilege,''''),''нет'') as Privilege , '+
' a2.Priv_Count, a2.priv_super, a2.Priv_M > 0 and priv_with_exam and a2.TestPassed and a.testready as priv_m, '+
' a2.Priv_Count, a2.priv_super, a2.Priv_M > 0 and priv_with_exam and a2.TestPassed and a.testready<>0 as priv_m, '#13#10+
' a.scr_fail, '+
' a2.Grade_RUS, '+
' a2.Grade_MATH, '+
' a2.Grade_INO, '+
' a2.Grade_PHYS, '+
' CASE WHEN COALESCE(ep.psychomode,0)=0 THEN '+
' ROUND(a2.psycho_grade,2) '+
' ROUND(a2.psycho_grade,2)::character varying '+
' ELSE CASE WHEN a.Psychologist<>0 THEN ''Зачет'' ELSE ''Незачет'' END '+
' END as Psycho, '+
' END as Psycho, '#13#10+
' a.applicant_status_id NOT IN (5,8) '+
' AND COALESCE(a.scr_fail,0)=0 '+
' AND ( a2.ExamPassed AND a2.TestPassed '+
' AND (COALESCE(ep.psychomode,0)=0 AND ROUND(10000*a2.Psycho_grade)>=ROUND(10000*coalesce(ep.psycho_pass,0)) OR a.Psychologist<>0 AND ep.psychomode<>0) '+
' OR a2.Priv_super<>0 OR (a2.priv_m > 0 and priv_with_exam AND a2.TestPassed and a.testready)) '+
'as ExamOK, '+
' OR a2.Priv_super<>0 OR (a2.priv_m > 0 and priv_with_exam AND a2.TestPassed and a.testready<>0)) '+
'as ExamOK, '#13#10+
' calc_applicant_ball(a.xp_key) AS Ball, '+
' calc_applicant_ball_priv_m(a.xp_key) as Ball_m, '+
' calc_applicant_ball_priv_m(a.xp_key) as Ball_m, '#13#10+
' CASE '+
' WHEN a.absent <> 0 THEN CASE a.Sex WHEN ''женский'' THEN ''не явилась'' ELSE ''не явился'' END '+
' WHEN a.scr_fail <> 0 THEN a.screening '+
@ -204,7 +212,7 @@ begin
' WHEN a2.priv_super>0 THEN '''' '+
' WHEN a2.priv_m > 0 THEN TRIM(CONCAT(IF(COALESCE(ep.psychomode,0)=0 AND ROUND(10000*a2.Psycho_grade)<ROUND(10000*coalesce(ep.psycho_pass,0)) ' +
' OR coalesce(a.Psychologist,0)=0 AND ep.psychomode<>0,''Не рекомендуется к обучению по результатам психологического отбора'', ''''), ' +
' CASE WHEN LOCATE(''физическая культура'', a2.FailedExams) > 0 THEN '' Не сданы: физическая культура'' ELSE '''' END)) '+
' CASE WHEN position(''физическая культура'' in a2.FailedExams) > 0 THEN '' Не сданы: физическая культура'' ELSE '''' END)) '+
' WHEN nd.errors<>'''' THEN nd.errors '+
' WHEN NOT a2.TestPassed or NOT a2.ExamPassed '+
' or COALESCE(ep.psychomode,0)=0 AND ROUND(10000*a2.Psycho_grade)<ROUND(10000*coalesce(ep.psycho_pass,0)) OR coalesce(a.Psychologist,0)=0 AND ep.psychomode<>0 '+
@ -213,45 +221,50 @@ begin
' IF(NOT a2.TestPassed AND a2.Priv_super=0, a2.FailedTests,NULL), '+
' IF(NOT a2.ExamPassed AND a2.Priv_super=0, CONCAT(''Не сданы: \n'',a2.FailedExams),NULL)'+
' ) '+
' END AS Prim, '+
' END AS Prim, '#13#10+
' a2.FailedExams, a2.FailedTests, a2.ExamPassed,a2.TestPassed, '+
' CASE WHEN a.absent<>0 THEN 1 ELSE 0 END as absent, '+
' a2.col1,a2.col2,a2.col3,a2.col4,a2.col5,a2.col6, '+
' a2.grade1,a2.grade2,a2.grade3,a2.grade4,a2.grade5,a2.grade6 '+
' a2.grade1,a2.grade2,a2.grade3,a2.grade4,a2.grade5,a2.grade6 '#13#10+
'FROM ( '+
' SELECT a1.xp_key, '+
' GROUP_CONCAT(distinct CASE '+
' WHEN np.code = ''Л'' THEN ''Указ Президента РФ от 09.05.2022 г. №268 п.3/ч.1.'' '+
' WHEN np.code = ''Л1'' THEN ''Указ Президента РФ от 09.05.2022 г. №268 п.3/ч.2.'' '+
' WHEN np.code = ''М'' THEN ''Федеральный закон от 29 декабря 2022 года «641-ФЗ, статья 86, часть 6.1'' '+
' WHEN np.code IS NOT NULL THEN priv.PrivilegeCode '+
' ELSE priv.PrivilegeName END order by priv.PrivilegeCode SEPARATOR '', '') AS Privilege, '+
' COUNT(priv.PrivilegeCode) AS Priv_Count, '+
' SUM(if(np.code in ( ''Л''),1, 0) ) AS Priv_super, '+
' SUM(if(np.code in (''М''),1,0)) as Priv_M, '+
' get_applicant_grade(a1.xp_key,''%%русский%%'','''') AS Grade_RUS, '+
' get_applicant_grade(a1.xp_key,''%%математика%%'','''') AS Grade_MATH, '+
' get_applicant_grade(a1.xp_key,''%%язык%%'',''%%русский%%'') AS Grade_INO, '+
' get_applicant_grade(a1.xp_key,''%%физ%%'',''физика'') AS Grade_PHYS, '+
' get_applicant_grade(a1.xp_key,''%%физ%%'',''физика'') AS Grade_PHYS, '#13#10+
' %3:s '+
' %4:s '+
' (0.0 %2:s )/COALESCE(ep.psycho_denom,5) as Psycho_grade, '+
' (TRUE %5:s %6:s) as ExamPassed, '+
' (TRUE %7:s ) as TestPassed, '+
' %12:s as priv_with_exam, '+
' priv.Privilege, priv.Priv_Count, priv.Priv_super, priv.Priv_M, '+
' CONCAT_WS('', '' %8:s ) as FailedExams, '+
' CONCAT_WS('', '' %9:s ) as FailedTests '+
' CONCAT_WS('', '' %9:s ) as FailedTests '#13#10+
' FROM xp_applicant a1 '+
' LEFT JOIN xp_applicant_file_privilege priv ON priv.mid=a1.xp_key AND priv.PrivilegeCode <> ''-'' '+
' LEFT JOIN c_privilege np ON np.code=priv.PrivilegeCode '+
' LEFT JOIN ( '#13#10+
' SELECT priv.mid, '+
' string_agg(distinct CASE '+
' WHEN np.code = ''Л'' THEN ''Указ Президента РФ от 09.05.2022 г. №268 п.3/ч.1.'' '+
' WHEN np.code = ''Л1'' THEN ''Указ Президента РФ от 09.05.2022 г. №268 п.3/ч.2.'' '+
' WHEN np.code = ''М'' THEN ''Федеральный закон от 29 декабря 2022 года «641-ФЗ, статья 86, часть 6.1'' '+
' WHEN np.code IS NOT NULL THEN priv.PrivilegeCode '+
' ELSE priv.PrivilegeName END , '', '' ) AS Privilege, '#13#10+
' COUNT(priv.PrivilegeCode) AS Priv_Count, '+
' SUM(if(np.code in ( ''Л''),1, 0) ) AS Priv_super, '+
' SUM(if(np.code in (''М''),1,0)) as Priv_M '#13#10+
' FROM xp_applicant_file_privilege priv '+
' JOIN c_privilege np ON np.code=priv.PrivilegeCode '+
' WHERE priv.PrivilegeCode <> ''-'' '+
' GROUP BY priv.mid '#13#10+
') priv ON priv.mid=a1.xp_key '+
' JOIN applicant_group g ON g.id=a1.applicant_group '+
' LEFT JOIN enroll_params ep ON ep.school_year=a1.s_year_id '+
' LEFT JOIN enroll_params ep ON ep.school_year=a1.s_year_id '#13#10+
' WHERE a1.s_year_id=%0:d AND a1.Child_Class>0 AND a1.testready <> 0 AND applicant_status_id <> 4 '+
' AND (%1:d=COALESCE(a1.stream,0)) '+
DateFilter +
' GROUP BY a1.xp_key '+
') a2 '+
') a2 '#13#10+
' JOIN xp_applicant a ON a.xp_key = a2.xp_key '+
' LEFT JOIN enroll_params ep ON ep.school_year=a.s_year_id '+
' LEFT JOIN tmp_rpt_problems nd ON nd.xp_key=a.xp_key '+
@ -276,8 +289,8 @@ begin
colSorter := MakeCols();
SQL := format(
'DROP TABLE IF EXISTS tmp_rpt_applicant; '+
'CREATE TEMPORARY TABLE tmp_rpt_applicant AS '+
'DROP TABLE IF EXISTS tmp_rpt_applicant; '#13#10+
'CREATE TEMPORARY TABLE tmp_rpt_applicant AS '#13#10+
' SELECT a1.*, e.places, e.places_male, e.places_female, '+
ColSorter+
'CASE '+
@ -290,23 +303,20 @@ begin
' ELSE 3 ' +
' END ' +
' ELSE 4 ' +
'END as GroupID ' +
'END as GroupID '#13#10 +
' FROM ( '+
' SELECT t.*, '+
' CASE '+
' WHEN @kurs=t.Child_Class AND @gender=t.gender AND @track=t.track THEN @row := @row+1 '+
' ELSE @row := 1 '+
' END as row, '+
' @kurs := t.Child_Class, @gender := t.gender, @track := t.track '+
' SELECT t.*, '#13#10+
' ROW_NUMBER() OVER (PARTITION BY t.Child_Class, t.gender, t.track '+
' ORDER BY t.child_class,t.gender,t.track, COALESCE(t.scr_fail,0), t.absent,t.has_errors, '+
' t.priv_super desc, t.priv_m desc,t.priv_ball desc, ExamOK desc, t.ball, t.has_priv, t.fio ) as row '#13#10+
' FROM '+
' (SELECT @row:=-1 as row, @kurs:=-1 as i_kurs, @gender:=-1 as i_gender, @track:=-1 as i_track ) init, '+
' (SELECT '+
' CASE '+
' WHEN et.places>0 THEN et.places '+
' WHEN e.places_female>0 AND a.Sex=''женский'' THEN e.places_female '+
' WHEN e.places_male>0 AND a.Sex=''мужской'' THEN e.places_male '+
' ELSE e.places '+
' END as place_limit, '+
' END as place_limit, '#13#10+
' CASE '+
' WHEN a.sex=''женский'' AND e.places_female>0 THEN 2 '+
' WHEN a.Sex=''мужской'' AND e.places_male>0 THEN 1 '+
@ -316,16 +326,19 @@ begin
' WHEN et.trajectory>0 THEN a.trajectory '+
' ELSE 0 '+
' END as track, '+
' a.*,nd.errors as undefined '+
' a.*,nd.errors as undefined, '+
' IF(nd.errors<>'''',1,0) as has_errors,'+
' case when a.priv_m then a.Ball_m else 0 end as priv_ball,'+
' case a.Priv_Count when 0 then 1 else 0 end as has_priv '#13#10+
' from tmp_rpt_applicant_us a '+
' join xp_enroll e ON e.school_year=%0:d and e.kurs=a.child_class AND e.trajectory=0 AND e.places>0 '+
' and (e.places_female>0 and a.Sex=''женский'' OR e.places_male>0 and a.Sex=''мужской'' OR e.places_female IS NULL AND e.places_male IS NULL) '+
' LEFT JOIN xp_enroll et ON et.school_year=%0:d AND et.kurs=a.Child_Class AND et.trajectory=a.trajectory '+
' LEFT JOIN tmp_rpt_problems nd ON nd.xp_key=a.xp_key '+
' LEFT JOIN tmp_rpt_problems nd ON nd.xp_key=a.xp_key '#13#10+
' WHERE 1=1 '+
' AND (et.trajectory>0 OR NOT EXISTS (SELECT 1 FROM xp_enroll WHERE school_year=a.s_year_id AND kurs=a.Child_Class AND trajectory>0)) '+
' AND (et.trajectory>0 OR NOT EXISTS (SELECT 1 FROM xp_enroll WHERE school_year=a.s_year_id AND kurs=a.Child_Class AND trajectory>0)) '#13#10+
' ORDER BY a.Child_Class,COALESCE(a.scr_fail,0), absent,IF(nd.errors<>'''',1,0),gender,'+
' track,priv_super desc,a.priv_m desc, case when a.priv_m > 0 then a.Ball_m else 0 end desc,ExamOK DESC, ball desc ,case a.Priv_Count when 0 then 1 else 0 end, a.fio '+
' track,priv_super desc,a.priv_m desc, case when a.priv_m then a.Ball_m else 0 end desc,ExamOK DESC, ball desc ,case a.Priv_Count when 0 then 1 else 0 end, a.fio '+
' ) t '+
{
' SELECT IF(Child_Class<>@class OR use_sex AND sex <> @sex,@i:=1,@i:=@i+1) as Row, '+
@ -353,22 +366,87 @@ begin
SQL :=
'UPDATE xp_applicant a '+
' JOIN tmp_rpt_applicant r ON r.xp_key = a.xp_key '+
'SET a.passed = null, a.ball = null; ';
connect.processor.ExecuteSQL(SQL);
SQL :=
'UPDATE xp_applicant a '+
' JOIN tmp_rpt_applicant r ON r.xp_key = a.xp_key '+
'SET a.passed = r.GroupID IN (0,1,2), a.ball = r.ball; ';
connect.processor.ExecuteSQL(SQL);
'SET passed = r.GroupID IN (0,1,2), ball = r.ball '+
'FROM tmp_rpt_applicant r '+
'WHERE r.xp_key = a.xp_key; ';
// connect.processor.ExecuteSQL(SQL);
result := colcount;
end;
procedure TRepApplicantResult.MakeProblemsTable;
var
SQL: string;
DateFilter: string;
clsError: string;
Exams,Psycho: array[1..4] of string;
i: integer;
FS:TStrings;
begin
if cbStream > 0 then
DateFilter := Format(' AND cast(date as DATE) BETWEEN %0:s AND %1:s '#13#10,
[TNIDBDM.StringAsSQL(Arguments.Keys.Values['fromdate']), TNIDBDM.StringAsSQL(Arguments.Keys.Values['todate'])]);
Psycho[1] := 'false';
for i := 1 to 8 do
psycho[1] := psycho[1]+ format(' OR IF(coalesce(ep.psycho_mode%0:d,0)>=-2, NULLIF(a.EnterTest%0:dGrade,'''') IS NULL, FALSE)'#13#10,[i]);
Exams[1] := 'NULL';
for i := 1 to 6 do
Exams[1] := Exams[1] + format(', case when COALESCE(g.EnterExam%0:dName,'''') <> '''' AND COALESCE(a.EnterExam%0:dGrade,'''') = '''' then g.EnterExam%0:dName else null end '#13#10,[i]);
Psycho[2] := 'false';
for i := 1 to 8 do
Psycho[2] := psycho[2] + format(
' OR coalesce(ep.psycho_mode%0:d,0)=-1 AND a.EnterTest%0:dGrade=''да'' '+
' OR coalesce(ep.psycho_mode%0:d,0)=-2 AND a.EnterTest%0:dGrade=''нет'''+
' OR coalesce(ep.psycho_mode%0:d,0) IN (0,1,2,3,4,5,6,7) AND ROUND(10000*COALESCE(asnumeric(a.EnterTest%0:dGrade),100)) < ROUND(10000*coalesce(ep.psycho_pass%0:d,ep.psycho_min%0:d,-10)) '#13#10,
[i]);
SQL := format(
'DROP TABLE IF EXISTS tmp_rpt_problems; '#13#10+
'CREATE TEMPORARY TABLE tmp_rpt_problems AS '#13#10+
'SELECT xp_key,child_class,xp_format_fio(child_lastname,child_firstname,child_midname,1) as fio, '#13#10+
'CONCAT_WS('', '', '+
' e.errGroup,errPsycho,errExams,errPortfolio,errTabAvg,errOlympic,errTechno '+
') as errors '#13#10+
'FROM ( '+
'SELECT a.xp_key,a.child_class, a.child_lastname,a.child_firstname,a.child_midname, '+
' IF(g.id IS NULL,''не назначена экзаменационная группа'',null) as errGroup, '+
' IF(coalesce(ep.Psychomode,0)=0 AND (%2:s),''не рассчитано итоговое заключение по псих. тестам'',null) as errPsycho, '+
' IF(NOT (%4:s),CONCAT(''не заполнены результаты испытаний('',NULLIF(CONCAT_WS('', '', %3:s),''''),'')''),null) as errExams, '+
' IF(coalesce(ep.portfolio_mode,0)<>0 AND a.portfoliograde IS NULL,''нет балла за портфолио'',null) as errPortfolio, '+
' IF(coalesce(ep.tabel_mode,1)<>0 AND a.tabel_avg IS NULL,''нет ср. балла по табелю'',null) as errTabAvg, '+
' IF(coalesce(ep.olympic_mode,1)<>0 AND a.olympic_grade IS NULL,''нет балла за олимпиады'',null) as errOlympic, '+
' IF(coalesce(ep.techno_mode,0)<>0 AND a.techno IS NULL,''нет оценки тех./физ. подготовки'',null) as errTechno '+
'FROM '#13#10+
'(SELECT a.xp_key FROM xp_applicant a '+
'WHERE a.testready<>0 AND coalesce(a.absent,0)=0 and coalesce(a.scr_fail,0)=0 '+
' AND a.applicant_status_id NOT IN (4,5,8) '+
' AND a.s_year_id=%0:d AND a.Child_Class>0 '+
DateFilter +
' AND (%1:d=COALESCE(a.stream,0)) '+
' and a.xp_key NOT IN (SELECT priv.mid FROM xp_applicant_file_privilege priv JOIN c_privilege np ON np.code=priv.PrivilegeCode WHERE np.code in (''Л'', ''М'')) '+
') u '#13#10+
' JOIN xp_applicant a ON a.xp_key=u.xp_key '+
' LEFT JOIN applicant_group g ON g.id=a.applicant_group '+
' LEFT JOIN enroll_params ep ON ep.school_year=a.s_year_id '+
'WHERE 1=1 '+
') e '#13#10+
'WHERE '+
' e.errGroup IS NOT NULL '+
' OR e.errPsycho IS NOT NULL '+
' OR e.errExams IS NOT NULL '+
' OR e.errPortfolio IS NOT NULL '+
' OR e.errTabAvg IS NOT NULL '+
' OR e.errOlympic IS NOT NULL '+
' OR e.errTechno IS NOT NULL '+
'ORDER BY child_class,2; ',
[idYear,cbStream, Psycho[1],Exams[1], Psycho[2]]);
connect.Processor.ExecuteSQL(SQL);
end;
class function TRepApplicantResult.CommandSubClass: string;
begin
Result:='applicant_results';
Result:='applicant_result';
end;
procedure TRepApplicantResult.Prepare;
@ -376,8 +454,9 @@ var
SQL: string;
begin
inherited Prepare;
idYear := getInt('year');
idYear := getInt('schoolyear');
cbStream := getInt('stream');
MakeProblemsTable;
UpdateEnrollStatus();
SQL := format(
'DROP TABLE IF EXISTS tmp_members; '+