mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Report upgrade WH
This commit is contained in:
@@ -5,7 +5,8 @@ common_info_for_project(DataBaseInterface)
|
|||||||
add_library(DataBaseInterface SHARED
|
add_library(DataBaseInterface SHARED
|
||||||
DataBaseLMS_global.h
|
DataBaseLMS_global.h
|
||||||
databaselms.cpp
|
databaselms.cpp
|
||||||
databaselms_tasks.cpp
|
databaselms_tasks_amm.cpp
|
||||||
|
databaselms_tasks_fim.cpp
|
||||||
databaselms_groups.cpp
|
databaselms_groups.cpp
|
||||||
databaselms_users.cpp
|
databaselms_users.cpp
|
||||||
databaselms_instructors.cpp
|
databaselms_instructors.cpp
|
||||||
|
|||||||
314
LibDataBaseInterface/databaselms_tasks_amm.cpp
Normal file
314
LibDataBaseInterface/databaselms_tasks_amm.cpp
Normal file
@@ -0,0 +1,314 @@
|
|||||||
|
#include "databaselms.h"
|
||||||
|
|
||||||
|
#include <QtSql>
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
#include <QSqlDriver>
|
||||||
|
|
||||||
|
int DataBaseLMS::insertTaskAMM(TaskAmmFim task, int id_trainee)
|
||||||
|
{
|
||||||
|
QString queryStr;
|
||||||
|
bool resBool = false;
|
||||||
|
|
||||||
|
resBool = db->transaction();
|
||||||
|
|
||||||
|
task.ammProcedure.title = task.ammProcedure.title.replace("'", "''"); //Задваиваем одинарные кавычки
|
||||||
|
|
||||||
|
queryStr = QString("INSERT INTO public.tasks_amm (title, dm_code, fk_trainee_id) "
|
||||||
|
"VALUES ('%1', '%2', %3) "
|
||||||
|
"RETURNING tasks_amm.task_id").arg(
|
||||||
|
task.ammProcedure.title,
|
||||||
|
task.ammProcedure.dmCode,
|
||||||
|
QString::number(id_trainee));
|
||||||
|
|
||||||
|
int task_id = queryExecInt(queryStr);
|
||||||
|
if(!task_id)
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(SubProc subProc : task.listSubProc)
|
||||||
|
{
|
||||||
|
subProc.setTitle(subProc.getTitle().replace("'", "''")); //Задваиваем одинарные кавычки
|
||||||
|
|
||||||
|
queryStr = QString("INSERT INTO public.subprocs (dm_code, title, canplay, fk_task_amm_id) "
|
||||||
|
"VALUES ('%1', '%2', '%3', %4) "
|
||||||
|
"RETURNING subprocs.subproc_id").arg(
|
||||||
|
subProc.getDmCode(),
|
||||||
|
subProc.getTitle(),
|
||||||
|
subProc.getModeListStr(),
|
||||||
|
QString::number(task_id));
|
||||||
|
|
||||||
|
int subproc_id = queryExecInt(queryStr);
|
||||||
|
if(!subproc_id)
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resBool = db->commit();
|
||||||
|
return task_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DataBaseLMS::updateTaskAMM(TaskAmmFim task)
|
||||||
|
{
|
||||||
|
task.ammProcedure.title = task.ammProcedure.title.replace("'", "''"); //Задваиваем одинарные кавычки
|
||||||
|
|
||||||
|
QString queryStr = QString("UPDATE public.tasks_amm SET title = '%1', dm_code = '%2', status = '%3' "
|
||||||
|
"WHERE task_id = %4 "
|
||||||
|
"RETURNING tasks_amm.task_id").arg(
|
||||||
|
task.ammProcedure.title,
|
||||||
|
task.ammProcedure.dmCode,
|
||||||
|
task.status,
|
||||||
|
QString::number(task.getID()) );
|
||||||
|
|
||||||
|
return queryExecInt(queryStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DataBaseLMS::updateStatusTaskAMM(int task_id, QString status)
|
||||||
|
{
|
||||||
|
QString queryStr;
|
||||||
|
bool resBool = false;
|
||||||
|
int id_trainee = 0;
|
||||||
|
|
||||||
|
resBool = db->transaction();
|
||||||
|
|
||||||
|
queryStr = QString("SELECT users.user_id "
|
||||||
|
"FROM public.users JOIN public.tasks_amm ON users.user_id = tasks_amm.fk_trainee_id "
|
||||||
|
"WHERE tasks_amm.task_id = %1 "
|
||||||
|
"ORDER BY users.user_id ASC").arg(
|
||||||
|
QString::number(task_id));
|
||||||
|
|
||||||
|
QSqlQuery query = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &query))
|
||||||
|
{
|
||||||
|
if (query.first())
|
||||||
|
{//Обучаемый
|
||||||
|
id_trainee = query.value(0).toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!id_trainee)
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
queryStr = QString("UPDATE public.tasks_amm SET status = '%1' "
|
||||||
|
"WHERE task_id = %2 "
|
||||||
|
"RETURNING tasks_amm.task_id").arg(
|
||||||
|
status,
|
||||||
|
QString::number(task_id) );
|
||||||
|
|
||||||
|
|
||||||
|
if(!queryExecInt(queryStr))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
resBool = db->commit();
|
||||||
|
return id_trainee;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DataBaseLMS::deleteTaskAMM(int id_task)
|
||||||
|
{
|
||||||
|
QString queryStr;
|
||||||
|
bool resBool = false;
|
||||||
|
int id_trainee = 0;
|
||||||
|
|
||||||
|
resBool = db->transaction();
|
||||||
|
|
||||||
|
queryStr = QString("SELECT users.user_id "
|
||||||
|
"FROM public.users JOIN public.tasks_amm ON users.user_id = tasks_amm.fk_trainee_id "
|
||||||
|
"WHERE tasks_amm.task_id = %1 "
|
||||||
|
"ORDER BY users.user_id ASC").arg(
|
||||||
|
QString::number(id_task));
|
||||||
|
|
||||||
|
QSqlQuery queryUserSEL = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &queryUserSEL))
|
||||||
|
{
|
||||||
|
if (queryUserSEL.first())
|
||||||
|
{//Обучаемый
|
||||||
|
id_trainee = queryUserSEL.value(0).toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!id_trainee)
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
queryStr = QString("DELETE FROM public.subprocs "
|
||||||
|
"WHERE fk_task_amm_id = %1 ").arg(
|
||||||
|
QString::number(id_task));
|
||||||
|
|
||||||
|
QSqlQuery querySubProcDEL = QSqlQuery(*db);
|
||||||
|
if(!queryExec(queryStr, &querySubProcDEL))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------
|
||||||
|
queryStr = QString("DELETE FROM public.tasks_amm "
|
||||||
|
"WHERE task_id = %1 "
|
||||||
|
"RETURNING tasks_amm.task_id").arg(
|
||||||
|
QString::number(id_task));
|
||||||
|
|
||||||
|
if(!queryExecInt(queryStr))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
resBool = db->commit();
|
||||||
|
return id_trainee;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<TaskAmmFim> DataBaseLMS::selectTasksAMMofTrainee(int id_trainee)
|
||||||
|
{
|
||||||
|
QList<TaskAmmFim> listTasks;
|
||||||
|
QString queryStr;
|
||||||
|
bool resBool = false;
|
||||||
|
|
||||||
|
resBool = db->transaction();
|
||||||
|
|
||||||
|
queryStr = QString("SELECT tasks_amm.task_id, tasks_amm.title, tasks_amm.dm_code, tasks_amm.status, "
|
||||||
|
"users.user_id "
|
||||||
|
"FROM public.tasks_amm JOIN public.users ON users.user_id = tasks_amm.fk_trainee_id "
|
||||||
|
"WHERE tasks_amm.fk_trainee_id = %1 "
|
||||||
|
"ORDER BY tasks_amm.task_id ASC").arg(
|
||||||
|
id_trainee);
|
||||||
|
|
||||||
|
QSqlQuery query = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &query))
|
||||||
|
{
|
||||||
|
while (query.next())
|
||||||
|
{//Задача
|
||||||
|
TaskAmmFim task;
|
||||||
|
|
||||||
|
task.setID(query.value(0).toInt());
|
||||||
|
task.ammProcedure.title = query.value(1).toString();
|
||||||
|
task.ammProcedure.dmCode = query.value(2).toString();
|
||||||
|
task.status = query.value(3).toString();
|
||||||
|
|
||||||
|
//Выгребаем все subproc для этой задачи
|
||||||
|
queryStr = QString("SELECT subprocs.subproc_id, subprocs.dm_code, subprocs.title, subprocs.canplay, "
|
||||||
|
"tasks_amm.task_id "
|
||||||
|
"FROM public.subprocs JOIN public.tasks_amm ON tasks_amm.task_id = subprocs.fk_task_amm_id "
|
||||||
|
"WHERE subprocs.fk_task_amm_id = %1 "
|
||||||
|
"ORDER BY subprocs.subproc_id ASC").arg(
|
||||||
|
task.getID());
|
||||||
|
|
||||||
|
QSqlQuery querySubProc = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &querySubProc))
|
||||||
|
{
|
||||||
|
while (querySubProc.next())
|
||||||
|
{//Подпроцедура
|
||||||
|
SubProc subProc;
|
||||||
|
int subproc_id = 0;
|
||||||
|
|
||||||
|
subproc_id = querySubProc.value(0).toString().toInt();
|
||||||
|
subProc.setDmCode(querySubProc.value(1).toString());
|
||||||
|
subProc.setTitle(querySubProc.value(2).toString());
|
||||||
|
subProc.setModeListStr(querySubProc.value(3).toString());
|
||||||
|
|
||||||
|
task.listSubProc.append(subProc);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return QList<TaskAmmFim>();
|
||||||
|
}
|
||||||
|
|
||||||
|
listTasks.append(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return QList<TaskAmmFim>();
|
||||||
|
}
|
||||||
|
|
||||||
|
resBool = db->commit();
|
||||||
|
return listTasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskAmmFim DataBaseLMS::selectTaskAMMbyID(int id_task)
|
||||||
|
{
|
||||||
|
TaskAmmFim task;
|
||||||
|
|
||||||
|
QString queryStr;
|
||||||
|
bool resBool = false;
|
||||||
|
|
||||||
|
resBool = db->transaction();
|
||||||
|
|
||||||
|
queryStr = QString("SELECT tasks_amm.task_id, tasks_amm.title, tasks_amm.dm_code, tasks_amm.status "
|
||||||
|
"FROM public.tasks_amm "
|
||||||
|
"WHERE tasks_amm.task_id = %1 "
|
||||||
|
"ORDER BY tasks_amm.task_id ASC").arg(
|
||||||
|
id_task);
|
||||||
|
|
||||||
|
QSqlQuery query = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &query))
|
||||||
|
{
|
||||||
|
if (query.first())
|
||||||
|
{//Задача
|
||||||
|
task.setID(query.value(0).toInt());
|
||||||
|
task.ammProcedure.title = query.value(1).toString();
|
||||||
|
task.ammProcedure.dmCode = query.value(2).toString();
|
||||||
|
task.status = query.value(3).toString();
|
||||||
|
|
||||||
|
//Выгребаем все subproc для этой задачи
|
||||||
|
queryStr = QString("SELECT subprocs.subproc_id, subprocs.dm_code, subprocs.title, subprocs.canplay, "
|
||||||
|
"tasks_amm.task_id "
|
||||||
|
"FROM public.subprocs JOIN public.tasks_amm ON tasks_amm.task_id = subprocs.fk_task_amm_id "
|
||||||
|
"WHERE subprocs.fk_task_amm_id = %1 "
|
||||||
|
"ORDER BY subprocs.subproc_id ASC").arg(
|
||||||
|
task.getID());
|
||||||
|
|
||||||
|
QSqlQuery querySubProc = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &querySubProc))
|
||||||
|
{
|
||||||
|
while (querySubProc.next())
|
||||||
|
{//Подпроцедура
|
||||||
|
SubProc subProc;
|
||||||
|
int subproc_id = 0;
|
||||||
|
|
||||||
|
subproc_id = querySubProc.value(0).toString().toInt();
|
||||||
|
subProc.setDmCode(querySubProc.value(1).toString());
|
||||||
|
subProc.setTitle(querySubProc.value(2).toString());
|
||||||
|
subProc.setModeListStr(querySubProc.value(3).toString());
|
||||||
|
|
||||||
|
task.listSubProc.append(subProc);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return TaskAmmFim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return TaskAmmFim();
|
||||||
|
}
|
||||||
|
|
||||||
|
resBool = db->commit();
|
||||||
|
return task;
|
||||||
|
}
|
||||||
@@ -4,316 +4,6 @@
|
|||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QSqlDriver>
|
#include <QSqlDriver>
|
||||||
|
|
||||||
int DataBaseLMS::insertTaskAMM(TaskAmmFim task, int id_trainee)
|
|
||||||
{
|
|
||||||
QString queryStr;
|
|
||||||
bool resBool = false;
|
|
||||||
|
|
||||||
resBool = db->transaction();
|
|
||||||
|
|
||||||
task.ammProcedure.title = task.ammProcedure.title.replace("'", "''"); //Задваиваем одинарные кавычки
|
|
||||||
|
|
||||||
queryStr = QString("INSERT INTO public.tasks_amm (title, dm_code, fk_trainee_id) "
|
|
||||||
"VALUES ('%1', '%2', %3) "
|
|
||||||
"RETURNING tasks_amm.task_id").arg(
|
|
||||||
task.ammProcedure.title,
|
|
||||||
task.ammProcedure.dmCode,
|
|
||||||
QString::number(id_trainee));
|
|
||||||
|
|
||||||
int task_id = queryExecInt(queryStr);
|
|
||||||
if(!task_id)
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(SubProc subProc : task.listSubProc)
|
|
||||||
{
|
|
||||||
subProc.setTitle(subProc.getTitle().replace("'", "''")); //Задваиваем одинарные кавычки
|
|
||||||
|
|
||||||
queryStr = QString("INSERT INTO public.subprocs (dm_code, title, canplay, fk_task_amm_id) "
|
|
||||||
"VALUES ('%1', '%2', '%3', %4) "
|
|
||||||
"RETURNING subprocs.subproc_id").arg(
|
|
||||||
subProc.getDmCode(),
|
|
||||||
subProc.getTitle(),
|
|
||||||
subProc.getModeListStr(),
|
|
||||||
QString::number(task_id));
|
|
||||||
|
|
||||||
int subproc_id = queryExecInt(queryStr);
|
|
||||||
if(!subproc_id)
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
resBool = db->commit();
|
|
||||||
return task_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DataBaseLMS::updateTaskAMM(TaskAmmFim task)
|
|
||||||
{
|
|
||||||
task.ammProcedure.title = task.ammProcedure.title.replace("'", "''"); //Задваиваем одинарные кавычки
|
|
||||||
|
|
||||||
QString queryStr = QString("UPDATE public.tasks_amm SET title = '%1', dm_code = '%2', status = '%3' "
|
|
||||||
"WHERE task_id = %4 "
|
|
||||||
"RETURNING tasks_amm.task_id").arg(
|
|
||||||
task.ammProcedure.title,
|
|
||||||
task.ammProcedure.dmCode,
|
|
||||||
task.status,
|
|
||||||
QString::number(task.getID()) );
|
|
||||||
|
|
||||||
return queryExecInt(queryStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int DataBaseLMS::updateStatusTaskAMM(int task_id, QString status)
|
|
||||||
{
|
|
||||||
QString queryStr;
|
|
||||||
bool resBool = false;
|
|
||||||
int id_trainee = 0;
|
|
||||||
|
|
||||||
resBool = db->transaction();
|
|
||||||
|
|
||||||
queryStr = QString("SELECT users.user_id "
|
|
||||||
"FROM public.users JOIN public.tasks_amm ON users.user_id = tasks_amm.fk_trainee_id "
|
|
||||||
"WHERE tasks_amm.task_id = %1 "
|
|
||||||
"ORDER BY users.user_id ASC").arg(
|
|
||||||
QString::number(task_id));
|
|
||||||
|
|
||||||
QSqlQuery query = QSqlQuery(*db);
|
|
||||||
|
|
||||||
if(queryExec(queryStr, &query))
|
|
||||||
{
|
|
||||||
if (query.first())
|
|
||||||
{//Обучаемый
|
|
||||||
id_trainee = query.value(0).toInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!id_trainee)
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
queryStr = QString("UPDATE public.tasks_amm SET status = '%1' "
|
|
||||||
"WHERE task_id = %2 "
|
|
||||||
"RETURNING tasks_amm.task_id").arg(
|
|
||||||
status,
|
|
||||||
QString::number(task_id) );
|
|
||||||
|
|
||||||
|
|
||||||
if(!queryExecInt(queryStr))
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
resBool = db->commit();
|
|
||||||
return id_trainee;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DataBaseLMS::deleteTaskAMM(int id_task)
|
|
||||||
{
|
|
||||||
QString queryStr;
|
|
||||||
bool resBool = false;
|
|
||||||
int id_trainee = 0;
|
|
||||||
|
|
||||||
resBool = db->transaction();
|
|
||||||
|
|
||||||
queryStr = QString("SELECT users.user_id "
|
|
||||||
"FROM public.users JOIN public.tasks_amm ON users.user_id = tasks_amm.fk_trainee_id "
|
|
||||||
"WHERE tasks_amm.task_id = %1 "
|
|
||||||
"ORDER BY users.user_id ASC").arg(
|
|
||||||
QString::number(id_task));
|
|
||||||
|
|
||||||
QSqlQuery queryUserSEL = QSqlQuery(*db);
|
|
||||||
|
|
||||||
if(queryExec(queryStr, &queryUserSEL))
|
|
||||||
{
|
|
||||||
if (queryUserSEL.first())
|
|
||||||
{//Обучаемый
|
|
||||||
id_trainee = queryUserSEL.value(0).toInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!id_trainee)
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
queryStr = QString("DELETE FROM public.subprocs "
|
|
||||||
"WHERE fk_task_amm_id = %1 ").arg(
|
|
||||||
QString::number(id_task));
|
|
||||||
|
|
||||||
QSqlQuery querySubProcDEL = QSqlQuery(*db);
|
|
||||||
if(!queryExec(queryStr, &querySubProcDEL))
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------
|
|
||||||
queryStr = QString("DELETE FROM public.tasks_amm "
|
|
||||||
"WHERE task_id = %1 "
|
|
||||||
"RETURNING tasks_amm.task_id").arg(
|
|
||||||
QString::number(id_task));
|
|
||||||
|
|
||||||
if(!queryExecInt(queryStr))
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
resBool = db->commit();
|
|
||||||
return id_trainee;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<TaskAmmFim> DataBaseLMS::selectTasksAMMofTrainee(int id_trainee)
|
|
||||||
{
|
|
||||||
QList<TaskAmmFim> listTasks;
|
|
||||||
QString queryStr;
|
|
||||||
bool resBool = false;
|
|
||||||
|
|
||||||
resBool = db->transaction();
|
|
||||||
|
|
||||||
queryStr = QString("SELECT tasks_amm.task_id, tasks_amm.title, tasks_amm.dm_code, tasks_amm.status, "
|
|
||||||
"users.user_id "
|
|
||||||
"FROM public.tasks_amm JOIN public.users ON users.user_id = tasks_amm.fk_trainee_id "
|
|
||||||
"WHERE tasks_amm.fk_trainee_id = %1 "
|
|
||||||
"ORDER BY tasks_amm.task_id ASC").arg(
|
|
||||||
id_trainee);
|
|
||||||
|
|
||||||
QSqlQuery query = QSqlQuery(*db);
|
|
||||||
|
|
||||||
if(queryExec(queryStr, &query))
|
|
||||||
{
|
|
||||||
while (query.next())
|
|
||||||
{//Задача
|
|
||||||
TaskAmmFim task;
|
|
||||||
|
|
||||||
task.setID(query.value(0).toInt());
|
|
||||||
task.ammProcedure.title = query.value(1).toString();
|
|
||||||
task.ammProcedure.dmCode = query.value(2).toString();
|
|
||||||
task.status = query.value(3).toString();
|
|
||||||
|
|
||||||
//Выгребаем все subproc для этой задачи
|
|
||||||
queryStr = QString("SELECT subprocs.subproc_id, subprocs.dm_code, subprocs.title, subprocs.canplay, "
|
|
||||||
"tasks_amm.task_id "
|
|
||||||
"FROM public.subprocs JOIN public.tasks_amm ON tasks_amm.task_id = subprocs.fk_task_amm_id "
|
|
||||||
"WHERE subprocs.fk_task_amm_id = %1 "
|
|
||||||
"ORDER BY subprocs.subproc_id ASC").arg(
|
|
||||||
task.getID());
|
|
||||||
|
|
||||||
QSqlQuery querySubProc = QSqlQuery(*db);
|
|
||||||
|
|
||||||
if(queryExec(queryStr, &querySubProc))
|
|
||||||
{
|
|
||||||
while (querySubProc.next())
|
|
||||||
{//Подпроцедура
|
|
||||||
SubProc subProc;
|
|
||||||
int subproc_id = 0;
|
|
||||||
|
|
||||||
subproc_id = querySubProc.value(0).toString().toInt();
|
|
||||||
subProc.setDmCode(querySubProc.value(1).toString());
|
|
||||||
subProc.setTitle(querySubProc.value(2).toString());
|
|
||||||
subProc.setModeListStr(querySubProc.value(3).toString());
|
|
||||||
|
|
||||||
task.listSubProc.append(subProc);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return QList<TaskAmmFim>();
|
|
||||||
}
|
|
||||||
|
|
||||||
listTasks.append(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return QList<TaskAmmFim>();
|
|
||||||
}
|
|
||||||
|
|
||||||
resBool = db->commit();
|
|
||||||
return listTasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskAmmFim DataBaseLMS::selectTaskAMMbyID(int id_task)
|
|
||||||
{
|
|
||||||
TaskAmmFim task;
|
|
||||||
|
|
||||||
QString queryStr;
|
|
||||||
bool resBool = false;
|
|
||||||
|
|
||||||
resBool = db->transaction();
|
|
||||||
|
|
||||||
queryStr = QString("SELECT tasks_amm.task_id, tasks_amm.title, tasks_amm.dm_code, tasks_amm.status "
|
|
||||||
"FROM public.tasks_amm "
|
|
||||||
"WHERE tasks_amm.task_id = %1 "
|
|
||||||
"ORDER BY tasks_amm.task_id ASC").arg(
|
|
||||||
id_task);
|
|
||||||
|
|
||||||
QSqlQuery query = QSqlQuery(*db);
|
|
||||||
|
|
||||||
if(queryExec(queryStr, &query))
|
|
||||||
{
|
|
||||||
if (query.first())
|
|
||||||
{//Задача
|
|
||||||
task.setID(query.value(0).toInt());
|
|
||||||
task.ammProcedure.title = query.value(1).toString();
|
|
||||||
task.ammProcedure.dmCode = query.value(2).toString();
|
|
||||||
task.status = query.value(3).toString();
|
|
||||||
|
|
||||||
//Выгребаем все subproc для этой задачи
|
|
||||||
queryStr = QString("SELECT subprocs.subproc_id, subprocs.dm_code, subprocs.title, subprocs.canplay, "
|
|
||||||
"tasks_amm.task_id "
|
|
||||||
"FROM public.subprocs JOIN public.tasks_amm ON tasks_amm.task_id = subprocs.fk_task_amm_id "
|
|
||||||
"WHERE subprocs.fk_task_amm_id = %1 "
|
|
||||||
"ORDER BY subprocs.subproc_id ASC").arg(
|
|
||||||
task.getID());
|
|
||||||
|
|
||||||
QSqlQuery querySubProc = QSqlQuery(*db);
|
|
||||||
|
|
||||||
if(queryExec(queryStr, &querySubProc))
|
|
||||||
{
|
|
||||||
while (querySubProc.next())
|
|
||||||
{//Подпроцедура
|
|
||||||
SubProc subProc;
|
|
||||||
int subproc_id = 0;
|
|
||||||
|
|
||||||
subproc_id = querySubProc.value(0).toString().toInt();
|
|
||||||
subProc.setDmCode(querySubProc.value(1).toString());
|
|
||||||
subProc.setTitle(querySubProc.value(2).toString());
|
|
||||||
subProc.setModeListStr(querySubProc.value(3).toString());
|
|
||||||
|
|
||||||
task.listSubProc.append(subProc);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return TaskAmmFim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resBool = db->rollback();
|
|
||||||
return TaskAmmFim();
|
|
||||||
}
|
|
||||||
|
|
||||||
resBool = db->commit();
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int DataBaseLMS::insertTaskFIM(TaskAmmFim task, int id_trainee)
|
int DataBaseLMS::insertTaskFIM(TaskAmmFim task, int id_trainee)
|
||||||
{
|
{
|
||||||
QString queryStr;
|
QString queryStr;
|
||||||
@@ -340,12 +30,14 @@ int DataBaseLMS::insertTaskFIM(TaskAmmFim task, int id_trainee)
|
|||||||
{
|
{
|
||||||
malfanction.description = malfanction.description.replace("'", "''"); //Задваиваем одинарные кавычки
|
malfanction.description = malfanction.description.replace("'", "''"); //Задваиваем одинарные кавычки
|
||||||
|
|
||||||
queryStr = QString("INSERT INTO public.malfunctions (num, dm_code, description, fk_task_fim_id) "
|
queryStr = QString("INSERT INTO public.malfunctions (num, dm_code, description, go_name, obj_name, fk_task_fim_id) "
|
||||||
"VALUES ('%1', '%2', '%3', %4) "
|
"VALUES ('%1', '%2', '%3', '%4', '%5', %6) "
|
||||||
"RETURNING malfunctions.malfunction_id").arg(
|
"RETURNING malfunctions.malfunction_id").arg(
|
||||||
malfanction.num,
|
malfanction.num,
|
||||||
malfanction.dmCode,
|
malfanction.dmCode,
|
||||||
malfanction.description,
|
malfanction.description,
|
||||||
|
malfanction.goName,
|
||||||
|
malfanction.objName,
|
||||||
QString::number(task_id));
|
QString::number(task_id));
|
||||||
|
|
||||||
int malfunction_id = queryExecInt(queryStr);
|
int malfunction_id = queryExecInt(queryStr);
|
||||||
@@ -471,6 +163,17 @@ int DataBaseLMS::updateStatusTaskFIM(int task_id, QString status)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queryStr = QString("DELETE FROM public.report_wh_items "
|
||||||
|
"WHERE fk_report_id = %1 ").arg(
|
||||||
|
QString::number(report_id));
|
||||||
|
|
||||||
|
QSqlQuery queryWhItemsDEL = QSqlQuery(*db);
|
||||||
|
if(!queryExec(queryStr, &queryWhItemsDEL))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
queryStr = QString("DELETE FROM public.reports "
|
queryStr = QString("DELETE FROM public.reports "
|
||||||
"WHERE report_id = %1 ").arg(
|
"WHERE report_id = %1 ").arg(
|
||||||
QString::number(report_id));
|
QString::number(report_id));
|
||||||
@@ -601,6 +304,17 @@ int DataBaseLMS::deleteTaskFIM(int id_task)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queryStr = QString("DELETE FROM public.report_wh_items "
|
||||||
|
"WHERE fk_report_id = %1 ").arg(
|
||||||
|
QString::number(report_id));
|
||||||
|
|
||||||
|
QSqlQuery queryWhItemsDEL = QSqlQuery(*db);
|
||||||
|
if(!queryExec(queryStr, &queryWhItemsDEL))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
queryStr = QString("DELETE FROM public.reports "
|
queryStr = QString("DELETE FROM public.reports "
|
||||||
"WHERE report_id = %1 ").arg(
|
"WHERE report_id = %1 ").arg(
|
||||||
QString::number(report_id));
|
QString::number(report_id));
|
||||||
@@ -657,7 +371,7 @@ QList<TaskAmmFim> DataBaseLMS::selectTasksFIMofTrainee(int id_trainee)
|
|||||||
task.status = query.value(2).toString();
|
task.status = query.value(2).toString();
|
||||||
|
|
||||||
//Выгребаем все malfunction для этой задачи
|
//Выгребаем все malfunction для этой задачи
|
||||||
queryStr = QString("SELECT malfunctions.malfunction_id, malfunctions.num, malfunctions.dm_code, malfunctions.description, "
|
queryStr = QString("SELECT malfunctions.malfunction_id, malfunctions.num, malfunctions.dm_code, malfunctions.description, malfunctions.go_name, malfunctions.obj_name, "
|
||||||
"tasks_fim.task_id "
|
"tasks_fim.task_id "
|
||||||
"FROM public.malfunctions JOIN public.tasks_fim ON tasks_fim.task_id = malfunctions.fk_task_fim_id "
|
"FROM public.malfunctions JOIN public.tasks_fim ON tasks_fim.task_id = malfunctions.fk_task_fim_id "
|
||||||
"WHERE malfunctions.fk_task_fim_id = %1 "
|
"WHERE malfunctions.fk_task_fim_id = %1 "
|
||||||
@@ -677,6 +391,8 @@ QList<TaskAmmFim> DataBaseLMS::selectTasksFIMofTrainee(int id_trainee)
|
|||||||
malfanction.num = queryMalf.value(1).toString();
|
malfanction.num = queryMalf.value(1).toString();
|
||||||
malfanction.dmCode = queryMalf.value(2).toString();
|
malfanction.dmCode = queryMalf.value(2).toString();
|
||||||
malfanction.description = queryMalf.value(3).toString();
|
malfanction.description = queryMalf.value(3).toString();
|
||||||
|
malfanction.goName = queryMalf.value(4).toString();
|
||||||
|
malfanction.objName = queryMalf.value(5).toString();
|
||||||
|
|
||||||
//Выгребаем сигналы для этой неисправности
|
//Выгребаем сигналы для этой неисправности
|
||||||
queryStr = QString("SELECT malf_signs.sign_id, malf_signs.type, malf_signs.description "
|
queryStr = QString("SELECT malf_signs.sign_id, malf_signs.type, malf_signs.description "
|
||||||
@@ -771,6 +487,35 @@ QList<TaskAmmFim> DataBaseLMS::selectTasksFIMofTrainee(int id_trainee)
|
|||||||
resBool = db->rollback();
|
resBool = db->rollback();
|
||||||
return QList<TaskAmmFim>();
|
return QList<TaskAmmFim>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Выгребаем все wh_item отчета
|
||||||
|
|
||||||
|
queryStr = QString("SELECT report_wh_items.wh_item_id, report_wh_items.status, report_wh_items.go_name, report_wh_items.obj_name, report_wh_items.fk_report_id, report_wh_items.number "
|
||||||
|
"FROM public.report_wh_items "
|
||||||
|
"WHERE fk_report_id = %1 "
|
||||||
|
"ORDER BY report_wh_items.number ASC").arg(
|
||||||
|
QString::number(report_id));
|
||||||
|
|
||||||
|
QSqlQuery queryWhItems = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &queryWhItems))
|
||||||
|
{
|
||||||
|
while (queryWhItems.next())
|
||||||
|
{//report_wh_item
|
||||||
|
FIMReportWarehouseItem reportWhItem;
|
||||||
|
reportWhItem.id = queryWhItems.value(0).toInt();
|
||||||
|
reportWhItem.status = queryWhItems.value(1).toInt();
|
||||||
|
reportWhItem.goName = queryWhItems.value(2).toString();
|
||||||
|
reportWhItem.objName = queryWhItems.value(3).toString();
|
||||||
|
|
||||||
|
task.report.warehouseItemList.append(reportWhItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return QList<TaskAmmFim>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listTasks.append(task);
|
listTasks.append(task);
|
||||||
@@ -813,7 +558,7 @@ TaskAmmFim DataBaseLMS::selectTaskFIMbyID(int id_task)
|
|||||||
task.status = query.value(2).toString();
|
task.status = query.value(2).toString();
|
||||||
|
|
||||||
//Выгребаем все malfunction для этой задачи
|
//Выгребаем все malfunction для этой задачи
|
||||||
queryStr = QString("SELECT malfunctions.malfunction_id, malfunctions.num, malfunctions.dm_code, malfunctions.description, "
|
queryStr = QString("SELECT malfunctions.malfunction_id, malfunctions.num, malfunctions.dm_code, malfunctions.description, malfunctions.go_name, malfunctions.obj_name, "
|
||||||
"tasks_fim.task_id "
|
"tasks_fim.task_id "
|
||||||
"FROM public.malfunctions JOIN public.tasks_fim ON tasks_fim.task_id = malfunctions.fk_task_fim_id "
|
"FROM public.malfunctions JOIN public.tasks_fim ON tasks_fim.task_id = malfunctions.fk_task_fim_id "
|
||||||
"WHERE malfunctions.fk_task_fim_id = %1 "
|
"WHERE malfunctions.fk_task_fim_id = %1 "
|
||||||
@@ -833,6 +578,8 @@ TaskAmmFim DataBaseLMS::selectTaskFIMbyID(int id_task)
|
|||||||
malfanction.num = queryMalf.value(1).toString();
|
malfanction.num = queryMalf.value(1).toString();
|
||||||
malfanction.dmCode = queryMalf.value(2).toString();
|
malfanction.dmCode = queryMalf.value(2).toString();
|
||||||
malfanction.description = queryMalf.value(3).toString();
|
malfanction.description = queryMalf.value(3).toString();
|
||||||
|
malfanction.goName = queryMalf.value(4).toString();
|
||||||
|
malfanction.objName = queryMalf.value(5).toString();
|
||||||
|
|
||||||
//Выгребаем сигналы для этой неисправности
|
//Выгребаем сигналы для этой неисправности
|
||||||
queryStr = QString("SELECT malf_signs.sign_id, malf_signs.type, malf_signs.description "
|
queryStr = QString("SELECT malf_signs.sign_id, malf_signs.type, malf_signs.description "
|
||||||
@@ -927,6 +674,35 @@ TaskAmmFim DataBaseLMS::selectTaskFIMbyID(int id_task)
|
|||||||
resBool = db->rollback();
|
resBool = db->rollback();
|
||||||
return TaskAmmFim();
|
return TaskAmmFim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Выгребаем все wh_item отчета
|
||||||
|
|
||||||
|
queryStr = QString("SELECT report_wh_items.wh_item_id, report_wh_items.status, report_wh_items.go_name, report_wh_items.obj_name, report_wh_items.fk_report_id, report_wh_items.number "
|
||||||
|
"FROM public.report_wh_items "
|
||||||
|
"WHERE fk_report_id = %1 "
|
||||||
|
"ORDER BY report_wh_items.number ASC").arg(
|
||||||
|
QString::number(report_id));
|
||||||
|
|
||||||
|
QSqlQuery queryWhItems = QSqlQuery(*db);
|
||||||
|
|
||||||
|
if(queryExec(queryStr, &queryWhItems))
|
||||||
|
{
|
||||||
|
while (queryWhItems.next())
|
||||||
|
{//report_wh_item
|
||||||
|
FIMReportWarehouseItem reportWhItem;
|
||||||
|
reportWhItem.id = queryWhItems.value(0).toInt();
|
||||||
|
reportWhItem.status = queryWhItems.value(1).toInt();
|
||||||
|
reportWhItem.goName = queryWhItems.value(2).toString();
|
||||||
|
reportWhItem.objName = queryWhItems.value(3).toString();
|
||||||
|
|
||||||
|
task.report.warehouseItemList.append(reportWhItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return TaskAmmFim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -972,10 +748,11 @@ int DataBaseLMS::updateReportFIMforTask(TaskAmmFim task)
|
|||||||
|
|
||||||
if(!report_id)
|
if(!report_id)
|
||||||
{
|
{
|
||||||
queryStr = QString("INSERT INTO public.reports (fk_task_fim_id) "
|
queryStr = QString("INSERT INTO public.reports (fk_task_fim_id, mmel) "
|
||||||
"VALUES (%1) "
|
"VALUES (%1, %2) "
|
||||||
"RETURNING reports.report_id").arg(
|
"RETURNING reports.report_id").arg(
|
||||||
task.getID());
|
task.getID(),
|
||||||
|
task.report.mmel);
|
||||||
|
|
||||||
report_id = queryExecInt(queryStr);
|
report_id = queryExecInt(queryStr);
|
||||||
if(!report_id)
|
if(!report_id)
|
||||||
@@ -996,6 +773,17 @@ int DataBaseLMS::updateReportFIMforTask(TaskAmmFim task)
|
|||||||
resBool = db->rollback();
|
resBool = db->rollback();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queryStr = QString("DELETE FROM public.report_wh_items "
|
||||||
|
"WHERE fk_report_id = %1 ").arg(
|
||||||
|
QString::number(report_id));
|
||||||
|
|
||||||
|
QSqlQuery queryWhItemsDEL = QSqlQuery(*db);
|
||||||
|
if(!queryExec(queryStr, &queryWhItemsDEL))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int number = 0;
|
int number = 0;
|
||||||
@@ -1019,6 +807,26 @@ int DataBaseLMS::updateReportFIMforTask(TaskAmmFim task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
number = 0;
|
||||||
|
for(FIMReportWarehouseItem reportWhItem : task.report.warehouseItemList)
|
||||||
|
{
|
||||||
|
queryStr = QString("INSERT INTO public.report_wh_items (status, go_name, obj_name, code, fk_report_id, number) "
|
||||||
|
"VALUES ('%1', '%2', '%3', '%4', %5, %6) "
|
||||||
|
"RETURNING report_wh_items.wh_item_id").arg(
|
||||||
|
QString::number(reportWhItem.status),
|
||||||
|
reportWhItem.goName,
|
||||||
|
reportWhItem.objName,
|
||||||
|
reportWhItem.code,
|
||||||
|
QString::number(report_id),
|
||||||
|
QString::number(++number));
|
||||||
|
|
||||||
|
if(!queryExecInt(queryStr))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
queryStr = QString("UPDATE public.tasks_fim SET status = '%1' "
|
queryStr = QString("UPDATE public.tasks_fim SET status = '%1' "
|
||||||
"WHERE task_id = %2 ").arg(
|
"WHERE task_id = %2 ").arg(
|
||||||
"checkup",
|
"checkup",
|
||||||
@@ -384,8 +384,19 @@ int DataBaseLMS::deleteTrainee(int id_trainee)
|
|||||||
queryStr = QString("DELETE FROM public.report_items "
|
queryStr = QString("DELETE FROM public.report_items "
|
||||||
"WHERE report_items.fk_report_id = %1 ").arg(
|
"WHERE report_items.fk_report_id = %1 ").arg(
|
||||||
report_id);
|
report_id);
|
||||||
QSqlQuery queryReportDEL = QSqlQuery(*db);
|
QSqlQuery queryItemsDEL = QSqlQuery(*db);
|
||||||
if(!queryExec(queryStr, &queryReportDEL))
|
if(!queryExec(queryStr, &queryItemsDEL))
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Удаление wh_items для этого отчета*/
|
||||||
|
queryStr = QString("DELETE FROM public.report_wh_items "
|
||||||
|
"WHERE report_wh_items.fk_report_id = %1 ").arg(
|
||||||
|
report_id);
|
||||||
|
QSqlQuery queryWhItemsDEL = QSqlQuery(*db);
|
||||||
|
if(!queryExec(queryStr, &queryWhItemsDEL))
|
||||||
{
|
{
|
||||||
resBool = db->rollback();
|
resBool = db->rollback();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ void TaskAmmFim::addMalfunction(Malfunction malfunction)
|
|||||||
malfunctionList.append(malfunction);
|
malfunctionList.append(malfunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Malfunction::initialize(QString dmCode, QString num, QString description)
|
void Malfunction::initialize(QString dmCode, QString num, QString description, QString goName, QString objName)
|
||||||
{
|
{
|
||||||
this->dmCode = dmCode;
|
this->dmCode = dmCode;
|
||||||
this->num = num;
|
this->num = num;
|
||||||
this->description = description;
|
this->description = description;
|
||||||
|
this->goName = goName;
|
||||||
|
this->objName = objName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Malfunction::addMalfunctionSign(MalfunctionSign sign)
|
void Malfunction::addMalfunctionSign(MalfunctionSign sign)
|
||||||
|
|||||||
@@ -84,13 +84,15 @@ public:
|
|||||||
Malfunction(){};
|
Malfunction(){};
|
||||||
~Malfunction(){};
|
~Malfunction(){};
|
||||||
public:
|
public:
|
||||||
void initialize(QString dmCode, QString num, QString description);
|
void initialize(QString dmCode, QString num, QString description, QString goName, QString objName);
|
||||||
void addMalfunctionSign(MalfunctionSign sign);
|
void addMalfunctionSign(MalfunctionSign sign);
|
||||||
public:
|
public:
|
||||||
QString dmCode; // dmCode процедуры
|
QString dmCode; // dmCode процедуры
|
||||||
QString num; // номер по-порядку в пункте "2. Возможные причины" процедуры
|
QString num; // номер по-порядку в пункте "2. Возможные причины" процедуры
|
||||||
QString description; // описание
|
QString description; // описание
|
||||||
QList<MalfunctionSign> malfunctionSigns;// список соответствующих неисправности признаков
|
QList<MalfunctionSign> malfunctionSigns;// список соответствующих неисправности признаков
|
||||||
|
QString goName; // имя GameObject (со скриптом DismantleData) - неисправный прибор
|
||||||
|
QString objName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DATABASELMS_EXPORT FIMReportItem
|
class DATABASELMS_EXPORT FIMReportItem
|
||||||
@@ -104,6 +106,23 @@ public:
|
|||||||
ProcedureID procedure; // ссылка на процедуру, при необходимости
|
ProcedureID procedure; // ссылка на процедуру, при необходимости
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DATABASELMS_EXPORT FIMReportWarehouseItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FIMReportWarehouseItem(){};
|
||||||
|
~FIMReportWarehouseItem(){};
|
||||||
|
public:
|
||||||
|
int id = 0; // для идентификации в БД
|
||||||
|
// статус GameObject-а в сцене
|
||||||
|
int status = 0; // 0 - демонтировано, 1 - неисправно, 2 - заменено на новое со склада
|
||||||
|
// имя GameObject-а в сцене
|
||||||
|
QString goName = "";
|
||||||
|
// человеческое название прибора
|
||||||
|
QString objName = "";
|
||||||
|
// его код из документации
|
||||||
|
QString code = "";
|
||||||
|
};
|
||||||
|
|
||||||
class DATABASELMS_EXPORT FIMReport
|
class DATABASELMS_EXPORT FIMReport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -111,7 +130,9 @@ public:
|
|||||||
~FIMReport(){};
|
~FIMReport(){};
|
||||||
public:
|
public:
|
||||||
int id = 0; // для идентификации в БД
|
int id = 0; // для идентификации в БД
|
||||||
QList<FIMReportItem> itemList;
|
QList<FIMReportItem> itemList; // список выполненных/просмотренных процедур
|
||||||
|
QList<FIMReportWarehouseItem> warehouseItemList;
|
||||||
|
bool mmel = false; // выпуск самолета по MMEL
|
||||||
};
|
};
|
||||||
|
|
||||||
class DATABASELMS_EXPORT TaskAmmFim
|
class DATABASELMS_EXPORT TaskAmmFim
|
||||||
|
|||||||
@@ -202,6 +202,8 @@ QByteArray DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB, int id
|
|||||||
xmlWriter.writeAttribute("dmCode", malfunction.dmCode);
|
xmlWriter.writeAttribute("dmCode", malfunction.dmCode);
|
||||||
xmlWriter.writeAttribute("num", malfunction.num);
|
xmlWriter.writeAttribute("num", malfunction.num);
|
||||||
xmlWriter.writeAttribute("description", malfunction.description);
|
xmlWriter.writeAttribute("description", malfunction.description);
|
||||||
|
xmlWriter.writeAttribute("goName", malfunction.goName);
|
||||||
|
xmlWriter.writeAttribute("objName", malfunction.objName);
|
||||||
|
|
||||||
for(MalfunctionSign sign : malfunction.malfunctionSigns)
|
for(MalfunctionSign sign : malfunction.malfunctionSigns)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -862,6 +862,8 @@ void RecognizeSystem::xmlParserQueryToDB(PacketType packetType, QByteArray array
|
|||||||
malfunction.num = malfOrReportNode.toElement().attribute("num");
|
malfunction.num = malfOrReportNode.toElement().attribute("num");
|
||||||
malfunction.dmCode = malfOrReportNode.toElement().attribute("dmCode");
|
malfunction.dmCode = malfOrReportNode.toElement().attribute("dmCode");
|
||||||
malfunction.description = malfOrReportNode.toElement().attribute("description");
|
malfunction.description = malfOrReportNode.toElement().attribute("description");
|
||||||
|
malfunction.goName = malfOrReportNode.toElement().attribute("goName");
|
||||||
|
malfunction.objName = malfOrReportNode.toElement().attribute("objName");
|
||||||
|
|
||||||
for(int s = 0; s < malfOrReportNode.childNodes().count(); s++)
|
for(int s = 0; s < malfOrReportNode.childNodes().count(); s++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -189,6 +189,10 @@ void CheckerTask::outReport(FIMReport report)
|
|||||||
ui->plainText->appendHtml("<br>");
|
ui->plainText->appendHtml("<br>");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Действия обучаемого
|
||||||
|
str = QString("<b>%1</b>").arg(tr("Trainee's actions:"));
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
|
||||||
for(FIMReportItem item : report.itemList)
|
for(FIMReportItem item : report.itemList)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -220,6 +224,69 @@ void CheckerTask::outReport(FIMReport report)
|
|||||||
|
|
||||||
ui->plainText->appendHtml("<br>");
|
ui->plainText->appendHtml("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->plainText->appendHtml("<br>");
|
||||||
|
|
||||||
|
//Устройства/приборы
|
||||||
|
bool flNeedMMEL = false;
|
||||||
|
str = QString("<b>%1</b>").arg(tr("Devices/instruments:"));
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
|
||||||
|
for(FIMReportWarehouseItem whItem : report.warehouseItemList)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
//WhItem ID
|
||||||
|
str = QString("<p>WhItem ID: %1</p>").arg(QString::number(whItem.id));
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// статус GameObject-а в сцене
|
||||||
|
str = QString("<p>%1</p>").arg(getStatusStr(whItem.status));
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
if(whItem.status == 0)
|
||||||
|
flNeedMMEL = true;
|
||||||
|
|
||||||
|
// имя GameObject-а в сцене
|
||||||
|
str = QString("<p>%1</p>").arg(whItem.goName);
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
|
||||||
|
// человеческое название прибора
|
||||||
|
str = QString("<p>%1</p>").arg(whItem.objName);
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
|
||||||
|
// его код из документации
|
||||||
|
str = QString("<p>%1</p>").arg(whItem.code);
|
||||||
|
ui->plainText->appendHtml(str);
|
||||||
|
|
||||||
|
ui->plainText->appendHtml("<br>");
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->plainText->appendHtml("<br>");
|
||||||
|
|
||||||
|
if(flNeedMMEL)
|
||||||
|
{
|
||||||
|
QString strMMEL = tr("Trainee believes that:") + "\n";
|
||||||
|
|
||||||
|
if(report.mmel)
|
||||||
|
str += tr("The aircraft may operate with its equipment removed in accordance with the \"Master Minimum Equipment List\"");
|
||||||
|
else
|
||||||
|
str += tr("The aircraft cannot be flown with equipment removed in accordance with the \"Master Minimum Equipment List\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CheckerTask::getStatusStr(int status)
|
||||||
|
{
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
//демонтировано
|
||||||
|
case 0: return tr("dismantled");
|
||||||
|
//неисправно
|
||||||
|
case 1: return tr("faulty");
|
||||||
|
//заменено на новое со склада
|
||||||
|
case 2: return tr("replaced with a new one from the warehouse");
|
||||||
|
//unknown
|
||||||
|
default: return "unknown";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//НЕВЕРНО
|
//НЕВЕРНО
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void outReport(FIMReport report);
|
void outReport(FIMReport report);
|
||||||
|
QString getStatusStr(int status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TaskAmmFim task;
|
TaskAmmFim task;
|
||||||
|
|||||||
@@ -310,9 +310,9 @@ void FIMtasksWidget::reSetHeadTreeWidget()
|
|||||||
QStringList listHeaders;
|
QStringList listHeaders;
|
||||||
|
|
||||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||||
listHeaders = QStringList{tr("Procedure FIM"), tr("Status"), tr("ID")};
|
listHeaders = QStringList{tr("Procedure FIM"), tr("Device"), tr("Status"), tr("ID")};
|
||||||
else
|
else
|
||||||
listHeaders = QStringList{tr("Procedure FIM"), tr("Status"), tr("ID")};
|
listHeaders = QStringList{tr("Procedure FIM"), tr("Device"), tr("Status"), tr("ID")};
|
||||||
|
|
||||||
treeWidget->setHeaderLabels(listHeaders);
|
treeWidget->setHeaderLabels(listHeaders);
|
||||||
}
|
}
|
||||||
@@ -323,6 +323,8 @@ void FIMtasksWidget::setWidthColumnsTree()
|
|||||||
|
|
||||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_Title, 100);
|
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_Title, 100);
|
||||||
listWidthColumn.append(100);
|
listWidthColumn.append(100);
|
||||||
|
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_Device, 150);
|
||||||
|
listWidthColumn.append(150);
|
||||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_status, 150);
|
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_status, 150);
|
||||||
listWidthColumn.append(130);
|
listWidthColumn.append(130);
|
||||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_ID, 50);
|
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_ID, 50);
|
||||||
|
|||||||
@@ -225,7 +225,9 @@ void TaskAMMFIMTreePreparation::loadFIMtasksFromXML(QByteArray array)
|
|||||||
|
|
||||||
malfunction.initialize(nodeMap.namedItem("dmCode").nodeValue(),
|
malfunction.initialize(nodeMap.namedItem("dmCode").nodeValue(),
|
||||||
nodeMap.namedItem("num").nodeValue(),
|
nodeMap.namedItem("num").nodeValue(),
|
||||||
nodeMap.namedItem("description").nodeValue());
|
nodeMap.namedItem("description").nodeValue(),
|
||||||
|
nodeMap.namedItem("goName").nodeValue(),
|
||||||
|
nodeMap.namedItem("objName").nodeValue());
|
||||||
|
|
||||||
QDomElement signElement = malfunctionElement.firstChildElement();
|
QDomElement signElement = malfunctionElement.firstChildElement();
|
||||||
if(!signElement.isNull())
|
if(!signElement.isNull())
|
||||||
@@ -614,6 +616,7 @@ void TaskAMMFIMTreePreparation::slot_prepareFIMListItems(QByteArray array)
|
|||||||
itemMalfunction->setFlags(itemMalfunction->flags() ^ Qt::ItemIsSelectable);
|
itemMalfunction->setFlags(itemMalfunction->flags() ^ Qt::ItemIsSelectable);
|
||||||
|
|
||||||
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
||||||
|
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Device, malfunction.objName);
|
||||||
if(type == TypeListTreeAMMFIM::listCommon)
|
if(type == TypeListTreeAMMFIM::listCommon)
|
||||||
{
|
{
|
||||||
itemMalfunction->setFlags(itemMalfunction->flags() | Qt::ItemIsUserCheckable);
|
itemMalfunction->setFlags(itemMalfunction->flags() | Qt::ItemIsUserCheckable);
|
||||||
@@ -706,6 +709,7 @@ void TaskAMMFIMTreePreparation::slot_prepareFIMListItemsForTrainee(QList<TaskAmm
|
|||||||
QTreeWidgetItem* itemMalfunction = new QTreeWidgetItem();
|
QTreeWidgetItem* itemMalfunction = new QTreeWidgetItem();
|
||||||
|
|
||||||
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
||||||
|
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Device, malfunction.objName);
|
||||||
if(type == TypeListTreeAMMFIM::listCommon)
|
if(type == TypeListTreeAMMFIM::listCommon)
|
||||||
{
|
{
|
||||||
itemMalfunction->setFlags(itemMalfunction->flags() | Qt::ItemIsUserCheckable);
|
itemMalfunction->setFlags(itemMalfunction->flags() | Qt::ItemIsUserCheckable);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ enum ColumnsTreeAMM{
|
|||||||
|
|
||||||
enum ColumnsTreeFIM{
|
enum ColumnsTreeFIM{
|
||||||
clmnFIM_Title = 0,
|
clmnFIM_Title = 0,
|
||||||
|
clmnFIM_Device,
|
||||||
clmnFIM_status,
|
clmnFIM_status,
|
||||||
clmnFIM_ID,
|
clmnFIM_ID,
|
||||||
clmnFIM_count
|
clmnFIM_count
|
||||||
|
|||||||
@@ -207,6 +207,8 @@ QByteArray DBAnswerParser::listTasksFIMofTrainee(bool result, QList<TaskAmmFim>
|
|||||||
malfunctionNode.toElement().setAttribute("dmCode", malfunction.dmCode);
|
malfunctionNode.toElement().setAttribute("dmCode", malfunction.dmCode);
|
||||||
malfunctionNode.toElement().setAttribute("num", malfunction.num);
|
malfunctionNode.toElement().setAttribute("num", malfunction.num);
|
||||||
malfunctionNode.toElement().setAttribute("description", malfunction.description);
|
malfunctionNode.toElement().setAttribute("description", malfunction.description);
|
||||||
|
malfunctionNode.toElement().setAttribute("goName", malfunction.goName);
|
||||||
|
malfunctionNode.toElement().setAttribute("objName", malfunction.objName);
|
||||||
|
|
||||||
for(MalfunctionSign sign : malfunction.malfunctionSigns)
|
for(MalfunctionSign sign : malfunction.malfunctionSigns)
|
||||||
{//Сигналы
|
{//Сигналы
|
||||||
|
|||||||
@@ -208,6 +208,21 @@ void ProcessParser::clientUnityTaskFIMreport(QXmlStreamReader &xmlReader, Client
|
|||||||
|
|
||||||
report.itemList.append(reportItem);
|
report.itemList.append(reportItem);
|
||||||
}
|
}
|
||||||
|
else if(reportItemNode.nodeName() == "warehouseItems")
|
||||||
|
{
|
||||||
|
FIMReportWarehouseItem warehouseItem;
|
||||||
|
warehouseItem.id = 0;
|
||||||
|
warehouseItem.status = reportItemNode.toElement().attribute("status").toInt();
|
||||||
|
warehouseItem.goName = reportItemNode.toElement().attribute("goName");
|
||||||
|
warehouseItem.objName = reportItemNode.toElement().attribute("name");
|
||||||
|
warehouseItem.code = reportItemNode.toElement().attribute("code");
|
||||||
|
|
||||||
|
report.warehouseItemList.append(warehouseItem);
|
||||||
|
}
|
||||||
|
else if(reportItemNode.nodeName() == "mmel")
|
||||||
|
{
|
||||||
|
report.mmel = (reportItemNode.toElement().nodeValue() == "true" ? true : false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task.report = report;
|
task.report = report;
|
||||||
@@ -279,6 +294,8 @@ TaskAmmFim ProcessParser::xmlParserQueryToDB_ASSIGN_TASK_FIM_TO_TRAINEE(QByteArr
|
|||||||
malfunction.num = malfunctionNode.toElement().attribute("num");
|
malfunction.num = malfunctionNode.toElement().attribute("num");
|
||||||
malfunction.dmCode = malfunctionNode.toElement().attribute("dmCode");
|
malfunction.dmCode = malfunctionNode.toElement().attribute("dmCode");
|
||||||
malfunction.description = malfunctionNode.toElement().attribute("description");
|
malfunction.description = malfunctionNode.toElement().attribute("description");
|
||||||
|
malfunction.goName = malfunctionNode.toElement().attribute("goName");
|
||||||
|
malfunction.objName = malfunctionNode.toElement().attribute("objName");
|
||||||
|
|
||||||
//Сигналы
|
//Сигналы
|
||||||
for(int j = 0; j < malfunctionNode.childNodes().count(); j++)
|
for(int j = 0; j < malfunctionNode.childNodes().count(); j++)
|
||||||
|
|||||||
Reference in New Issue
Block a user