diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - + + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index 84ff02a..68608e9 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -114,5 +114,6 @@ image/msgbox/icon_box_success.png image/msgbox/icon_box_warning.png image/msgbox/icon_box_fail.png + image/login/logo.png diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index 84ff02a..68608e9 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -114,5 +114,6 @@ image/msgbox/icon_box_success.png image/msgbox/icon_box_warning.png image/msgbox/icon_box_fail.png + image/login/logo.png diff --git a/res/qss/mainForm.css b/res/qss/mainForm.css index f1eaa41..666e8de 100644 --- a/res/qss/mainForm.css +++ b/res/qss/mainForm.css @@ -65,6 +65,13 @@ QWidget#wdgtTemp QLabel{ font-size: 20px; color: #333333; - font-family: "Microsoft YaHei"; + font-family: "Microsoft YaHei"; } + +/** 状态栏 **/ +QWidget#wdgtFoot QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index 84ff02a..68608e9 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -114,5 +114,6 @@ image/msgbox/icon_box_success.png image/msgbox/icon_box_warning.png image/msgbox/icon_box_fail.png + image/login/logo.png diff --git a/res/qss/mainForm.css b/res/qss/mainForm.css index f1eaa41..666e8de 100644 --- a/res/qss/mainForm.css +++ b/res/qss/mainForm.css @@ -65,6 +65,13 @@ QWidget#wdgtTemp QLabel{ font-size: 20px; color: #333333; - font-family: "Microsoft YaHei"; + font-family: "Microsoft YaHei"; } + +/** 状态栏 **/ +QWidget#wdgtFoot QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} diff --git a/utils/ProMemory.cpp b/utils/ProMemory.cpp index c2b6d26..0b82146 100644 --- a/utils/ProMemory.cpp +++ b/utils/ProMemory.cpp @@ -36,3 +36,12 @@ { this->groupCodeDict = bizGroupCode; } + +QMap ProMemory::getMeasureStatusDict() +{ + return this->measureStatusDict; +} +void ProMemory::setMeasureStatusDict(QMap measureStatus) +{ + this->measureStatusDict = measureStatus; +} diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index 84ff02a..68608e9 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -114,5 +114,6 @@ image/msgbox/icon_box_success.png image/msgbox/icon_box_warning.png image/msgbox/icon_box_fail.png + image/login/logo.png diff --git a/res/qss/mainForm.css b/res/qss/mainForm.css index f1eaa41..666e8de 100644 --- a/res/qss/mainForm.css +++ b/res/qss/mainForm.css @@ -65,6 +65,13 @@ QWidget#wdgtTemp QLabel{ font-size: 20px; color: #333333; - font-family: "Microsoft YaHei"; + font-family: "Microsoft YaHei"; } + +/** 状态栏 **/ +QWidget#wdgtFoot QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} diff --git a/utils/ProMemory.cpp b/utils/ProMemory.cpp index c2b6d26..0b82146 100644 --- a/utils/ProMemory.cpp +++ b/utils/ProMemory.cpp @@ -36,3 +36,12 @@ { this->groupCodeDict = bizGroupCode; } + +QMap ProMemory::getMeasureStatusDict() +{ + return this->measureStatusDict; +} +void ProMemory::setMeasureStatusDict(QMap measureStatus) +{ + this->measureStatusDict = measureStatus; +} diff --git a/utils/ProMemory.h b/utils/ProMemory.h index 62aef18..ee6911f 100644 --- a/utils/ProMemory.h +++ b/utils/ProMemory.h @@ -27,6 +27,9 @@ QMap getGroupCodeDict(); void setGroupCodeDict(QMap bizGroupCode); + QMap getMeasureStatusDict(); + void setMeasureStatusDict(QMap measureStatus); + private: ProMemory(); @@ -34,6 +37,7 @@ QMap labCodeDict; QMap groupCodeDict; + QMap measureStatusDict; }; #endif // PROMEMORY_H diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index 84ff02a..68608e9 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -114,5 +114,6 @@ image/msgbox/icon_box_success.png image/msgbox/icon_box_warning.png image/msgbox/icon_box_fail.png + image/login/logo.png diff --git a/res/qss/mainForm.css b/res/qss/mainForm.css index f1eaa41..666e8de 100644 --- a/res/qss/mainForm.css +++ b/res/qss/mainForm.css @@ -65,6 +65,13 @@ QWidget#wdgtTemp QLabel{ font-size: 20px; color: #333333; - font-family: "Microsoft YaHei"; + font-family: "Microsoft YaHei"; } + +/** 状态栏 **/ +QWidget#wdgtFoot QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} diff --git a/utils/ProMemory.cpp b/utils/ProMemory.cpp index c2b6d26..0b82146 100644 --- a/utils/ProMemory.cpp +++ b/utils/ProMemory.cpp @@ -36,3 +36,12 @@ { this->groupCodeDict = bizGroupCode; } + +QMap ProMemory::getMeasureStatusDict() +{ + return this->measureStatusDict; +} +void ProMemory::setMeasureStatusDict(QMap measureStatus) +{ + this->measureStatusDict = measureStatus; +} diff --git a/utils/ProMemory.h b/utils/ProMemory.h index 62aef18..ee6911f 100644 --- a/utils/ProMemory.h +++ b/utils/ProMemory.h @@ -27,6 +27,9 @@ QMap getGroupCodeDict(); void setGroupCodeDict(QMap bizGroupCode); + QMap getMeasureStatusDict(); + void setMeasureStatusDict(QMap measureStatus); + private: ProMemory(); @@ -34,6 +37,7 @@ QMap labCodeDict; QMap groupCodeDict; + QMap measureStatusDict; }; #endif // PROMEMORY_H diff --git a/utils/utils.pri b/utils/utils.pri index d326cac..38f51d6 100644 --- a/utils/utils.pri +++ b/utils/utils.pri @@ -5,9 +5,6 @@ HEADERS += $$PWD/QssFileUtils.h SOURCES += $$PWD/QssFileUtils.cpp -HEADERS += $$PWD/PageUtil.h -SOURCES += $$PWD/PageUtil.cpp - HEADERS += $$PWD/LogUtil.h SOURCES += $$PWD/LogUtil.cpp diff --git a/AutoCalibrationXC.pro b/AutoCalibrationXC.pro index 1d2155a..6bcb335 100644 --- a/AutoCalibrationXC.pro +++ b/AutoCalibrationXC.pro @@ -19,6 +19,8 @@ include(frame/frame.pri) include(utils/utils.pri) include(infomation/infomation.pri) +include(calibration/calibration.pri) +include(check/check.pri) include(QPagedTable/QPagedTable.pri) SOURCES += main.cpp diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 5b7c7f5..427416b 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -101,6 +101,15 @@ { columns = columnList; } +void QPagedTable::setColumns(QList> colMapList) +{ + QList columnList; + for (QMap colMap : colMapList) { + QPagedTableColumn col(colMap); + columnList.append(col); + } + setColumns(columnList); +} void QPagedTable::setDatas(QList > pagedDataList) { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index d423c13..f1afca6 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -41,6 +41,7 @@ void initTableHeader(); void adjustTableWidth(); void setColumns(QList columnList); + void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); diff --git a/QPagedTable/QPagedTableColumn.h b/QPagedTable/QPagedTableColumn.h index f55075d..4bb25d2 100644 --- a/QPagedTable/QPagedTableColumn.h +++ b/QPagedTable/QPagedTableColumn.h @@ -8,6 +8,18 @@ { public: QPagedTableColumn() {}; + QPagedTableColumn(QMap colMap) { + idx = colMap.value("idx").toInt(); + name = colMap.value("name").toString(); + text = colMap.value("text").toString(); + value = colMap.value("value").toString(); + + setWidthType(colMap.value("widthType").toString()); + setAlignType(colMap.value("align").toString()); + setResizeMode(colMap.value("resizeMode").toString()); + + width = colMap.value("width").toDouble(); + } enum ColumnWidthType { PIXEL, @@ -26,6 +38,10 @@ void setWidthType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + widthType = ColumnWidthType::PIXEL; + } + if (type == "PIXEL") { widthType = ColumnWidthType::PIXEL; } else if (type == "PERCENT") { @@ -35,6 +51,10 @@ void setAlignType(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + align = Qt::AlignmentFlag::AlignCenter; + } + if (type == "LEFT") { align = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter; } else if (type == "CENTER") { @@ -46,6 +66,10 @@ void setResizeMode(QString type) { type = type.toUpper(); + if (type.isEmpty()) { + resizeMode = QHeaderView::ResizeMode::Fixed; + } + if (type == "STRETCH") { resizeMode = QHeaderView::ResizeMode::Stretch; } else if (type == "FIXED") { diff --git a/calibration/calibration.pri b/calibration/calibration.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/calibration/calibration.pri diff --git a/check/check.pri b/check/check.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/check/check.pri diff --git a/dao/BaseDao.h b/dao/BaseDao.h index 159fe77..b0fe22b 100644 --- a/dao/BaseDao.h +++ b/dao/BaseDao.h @@ -8,6 +8,13 @@ #include "dao/util/IdWorker.h" #include "utils/utilsInclude.h" +struct Page { + int pageSize = 15; + int currentPage = 0; + int totalPage = 0; + int totalCount = 0; +}; + class BaseDao { public: diff --git a/dao/CommonData.h b/dao/CommonData.h index 9dcae97..6a86741 100644 --- a/dao/CommonData.h +++ b/dao/CommonData.h @@ -5,6 +5,45 @@ #include +// 待检任务 +class TaskDTO { +public: + QString id; + QString sampleName; + QString sampleModel; + QString checkCycle; + QString helpInstruction; + QString manufactureNo; + QString manufacturer; + QString customerName; + QString deptFullName; + QString requireOverTime; + QString isUrgent; + QString isUrgentName; + QString measureStatus; + QString measureStatusName; + QString orderId; + QString orderNo; + QString sampleId; + QString sampleNo; + QString customerId; + QString deliverer; + QString requireCertifications; + QString customerAddress; + QString measurePersonId; + QString labelBind; + QString certificateValid; + QString measureDeptId; + QString measureDeptName; + QString belongStandardEquipment; + QString belongStandardEquipmentName; + QString approvalStatus; + QString checkDate; + QString inputCheckOrganization; + QString inputAddress; +}; + + // 检定程序管理 class CheckProgramDto { public: diff --git a/dao/SystemDao.cpp b/dao/SystemDao.cpp index 61b0b71..95f0785 100644 --- a/dao/SystemDao.cpp +++ b/dao/SystemDao.cpp @@ -43,6 +43,33 @@ } } +QString SystemDao::getStaffDeptIdByUserId(QString userId) +{ + QString result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询语句 + QString sql = "SELECT brsi.dept_id AS deptId " + "FROM biz_resource_staff_info brsi " + "JOIN sys_user ON sys_user.ACCOUNT = brsi.account " + "WHERE sys_user.id = :userId"; + + query.prepare(sql); + query.bindValue(":userId", userId); + + if (query.exec() && query.next()) { + result = query.value("deptId").toString(); + } else { + LogUtil::PrintLog("ERROR", QString("查询计量人员所在部门失败[userId=%1][%2]").arg(userId).arg(query.lastError().text())); + } + +// qDebug() << sql << userId << result; + + return result; +} + QMap SystemDao::getSysUserByAccount(QString account) { QMap result; @@ -131,3 +158,9 @@ QMap dict = getSysDictByCode("eqptApprovalStatus"); return dict; } +QMap SystemDao::getTaskMeasureStatusDict() +{ + QMap measureStatusDict = getSysDictByCode("measureStatus"); + ProMemory::getInstance().setMeasureStatusDict(measureStatusDict); + return measureStatusDict; +} diff --git a/dao/SystemDao.h b/dao/SystemDao.h index e20a8bf..fe8efa5 100644 --- a/dao/SystemDao.h +++ b/dao/SystemDao.h @@ -27,6 +27,7 @@ SystemDao(); void getUserRoleIdAndName(QString userId, QMap &user); + QString getStaffDeptIdByUserId(QString userId); QMap getSysUserByAccount(QString account); @@ -34,6 +35,7 @@ QMap getLabCodeDict(); QMap getGroupCodeDict(); QMap getEqptApprovalStatusDict(); + QMap getTaskMeasureStatusDict(); }; #endif // SYSTEMDAO_H diff --git a/dao/SystemLocalDao.cpp b/dao/SystemLocalDao.cpp new file mode 100644 index 0000000..d4d8ab9 --- /dev/null +++ b/dao/SystemLocalDao.cpp @@ -0,0 +1,44 @@ +#include "SystemLocalDao.h" + +SystemLocalDao::SystemLocalDao() +{ + +} + +QList> SystemLocalDao::getInfomationTableColumns(QString tableName) +{ + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QList> resultList; + + // 查询用户 + QString sql = "SELECT id, table_name, column_idx, column_name, column_text, column_value, " + "column_width_type, column_width, column_align, column_resize_mode FROM " + "zd_table_column WHERE table_name = :tableName ORDER BY column_idx ASC"; + + query.prepare(sql); + query.bindValue(":tableName", tableName); + +// qDebug() << sql << tableName; + + if (query.exec()) { + while (query.next()) { + QMap item; + item.insert("idx", query.value("column_idx")); + item.insert("name", query.value("column_name")); + item.insert("text", query.value("column_text")); + item.insert("value", query.value("column_value")); + item.insert("widthType", query.value("column_width_type")); + item.insert("width", query.value("column_width")); + item.insert("align", query.value("column_align")); + item.insert("resizeMode", query.value("column_resize_mode")); + + resultList.append(item); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询表格列属性失败[tableName=%1][%2]").arg(tableName).arg(query.lastError().text())); + } + + return resultList; +} diff --git a/dao/SystemLocalDao.h b/dao/SystemLocalDao.h new file mode 100644 index 0000000..9a20cfa --- /dev/null +++ b/dao/SystemLocalDao.h @@ -0,0 +1,14 @@ +#ifndef SYSTEMLOCALDAO_H +#define SYSTEMLOCALDAO_H + +#include "BaseDao.h" + +class SystemLocalDao : public BaseDao +{ +public: + SystemLocalDao(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSTEMLOCALDAO_H diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp new file mode 100644 index 0000000..f980394 --- /dev/null +++ b/dao/TaskDao.cpp @@ -0,0 +1,394 @@ +#include "TaskDao.h" + +TaskDao::TaskDao() +{ + +} + +QList TaskDao::getTaskListPage(TaskRequest request, Page &page) +{ + QList resultList; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 查询总数并赋值 + quint32 totalCount = getTaskTotalCount(request); + page.totalCount = totalCount; + + // 构造查询语句 + QString sql = "SELECT blei.id AS id, blei.sample_id, eei.equipment_name, eei.model, " + "eei.manufacture_no, eei.manufacturer, bo.id as orderId, bo.order_no, bo.undertake_time, " + "bo.customer_name, sd.SIMPLE_NAME, bo.require_over_time, bo.is_urgent, blei.measure_status " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + // 设置分页数据 + sql = QString("%1 ORDER BY bo.undertake_time DESC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + + query.prepare(sql); + bindValueTaskListPage(query, request); + + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + qDebug() << sql; + + // 分页查询 + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + TaskDTO task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("equipment_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.customerName = query.value("customer_name").toString(); + task.measureDeptName = query.value("SIMPLE_NAME").toString(); + task.requireOverTime = query.value("require_over_time").toDate().toString("yyyy-MM-dd"); + task.isUrgent = query.value("is_urgent").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.orderId = query.value("orderId").toString(); + task.orderNo = query.value("order_no").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单失败[%1]").arg(query.lastError().text())); + } + + // 返回结果 + return resultList; +} + +quint32 TaskDao::getTaskTotalCount(TaskRequest request) +{ + quint32 totalCount = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT COUNT( blei.id ) AS recCount " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id"; + + sql = QString("%1 %2").arg(sql).arg(generateTaskListPageWhereClause(request)); + + query.prepare(sql); + bindValueTaskListPage(query, request); + +// qDebug() << sql; + + if (query.exec() && query.next()) { + totalCount = query.value("recCount").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询任务单数量失败[%1]").arg(query.lastError().text())); + } + + return totalCount; +} +/* +quint32 TaskDao::getMyTaskCount(QString userId, QString devName, QString devModel, QString devSerial, QString customer) +{ + quint32 count = 0; + + QString sql = "SELECT COUNT(blei.id) AS RECCT FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + + bool isSuccess = query.exec(); + if (isSuccess && query.next()) { + count = query.value("RECCT").toInt(); + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return count; +} +*/ +/* +QList TaskDao::getMyTaskListPage(QString userId, QString devName, QString devModel, QString devSerial, QString customer, qint8 limit, qint16 offset) +{ + QList result; + + QString sql = "SELECT blei.id AS id, blei.measure_person_id, blei.require_certifications, blei.measure_status, " + "eei.id AS sample_id, eei.equipment_no AS sampleNo, eei.equipment_name AS sampleName, eei.model AS sampleModel, " + "eei.check_cycle, eei.manufacture_no AS manufactureNo, eei.manufacturer, eei.help_instruction AS helpInstruction, " + "eei.certificate_valid AS certificateValid, eei.RFID AS labelBind, " + "bo.order_no AS orderNo, bo.id AS orderId, bo.customer_id, bo.customer_name, bo.deliverer, bo.is_urgent, bo.require_over_time, bo.customer_address, " + "sd.ID AS measureDeptId, sd.SIMPLE_NAME AS measureDeptName " + "FROM biz_business_lab_executive_info blei " + "JOIN eqpt_equipment_info eei ON eei.id = blei.sample_id " + "JOIN biz_business_order_info bo ON bo.id = blei.order_id " + "LEFT JOIN sys_dept sd ON blei.measure_dept_id = sd.ID " + "WHERE blei.measure_person_id = " + "(SELECT brsi.id from biz_resource_staff_info brsi JOIN sys_user ON sys_user.ACCOUNT = brsi.account WHERE sys_user.id = :userId) " + "AND blei.measure_status = 3"; + + if (devName.isEmpty() == false && devName != "%%") { + sql += " AND eei.equipment_name like :name"; + } + if (devModel.isEmpty() == false && devModel != "%%") { + sql += " AND eei.model like :model"; + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + sql += " AND eei.manufacture_no like :serial"; + } + if (customer.isEmpty() == false) { + sql += " AND bo.customer_id = :customer"; + } + + sql += " limit :limit offset :offset;"; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + query.prepare(sql); + + query.bindValue(":userId", userId); + if (devName.isEmpty() == false && devName != "%%") { + query.bindValue(":name", devName); + } + if (devModel.isEmpty() == false && devModel != "%%") { + query.bindValue(":model", devModel); + } + if (devSerial.isEmpty() == false && devSerial != "%%") { + query.bindValue(":serial", devSerial); + } + if (customer.isEmpty() == false) { + query.bindValue(":customer", customer); + } + query.bindValue(":limit", limit); + query.bindValue(":offset", offset); + + if (query.exec()) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleNo = query.value("sampleNo").toString(); + task.sampleName = query.value("sampleName").toString(); + task.sampleModel = query.value("sampleModel").toString(); + task.checkCycle = query.value("check_cycle").toString(); + task.manufactureNo = query.value("manufactureNo").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.helpInstruction = query.value("helpInstruction").toString(); + task.orderNo = query.value("orderNo").toString(); + task.orderId = query.value("orderId").toString(); + task.customerId = query.value("customer_id").toString(); + task.customerName = query.value("customer_name").toString(); + task.deliverer = query.value("deliverer").toString(); + task.isUrgent = query.value("is_urgent").toString(); + task.requireOverTime = query.value("require_over_time").toDateTime(); + task.requireCertifications = query.value("require_certifications").toString(); + task.measureStatus = query.value("measure_status").toString(); + task.customerAddress = query.value("customer_address").toString(); + task.measurePersonId = query.value("measure_person_id").toString(); + task.labelBind = query.value("labelBind").toString(); + task.certificateValid = query.value("certificateValid").toString(); + task.measureDeptId = query.value("measureDeptId").toString(); + task.deptFullName = query.value("measureDeptName").toString(); +// loginMeasureDeptName = query.value("measureDeptName").toString(); + result.append(task); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + + return result; +} +*/ +/* +quint32 TaskDao::getMyTaskEquipmentCount(EqptEquipmentRequest request) +{ + quint32 result = 0; + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + // 构造查询语句 + QString sql = "SELECT COUNT( eei.id ) AS RECCT FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id "; + sql = QString("%1 %2;").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); +// qDebug() << sql; + + // 绑定查询条件 + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + + if (query.exec() && query.next()) { + result = query.value("RECCT").toInt(); + } else { + LogUtil::PrintLog("ERROR", QString("查询待检设备数量失败[%1]").arg(query.lastError().text())); + } + return result; +} +*/ +/* +QList TaskDao::getMyTaskEquipmentListPage(EqptEquipmentRequest request, Page &page) +{ + QList resultList; + + // 查询总数 + page.totalCount = getMyTaskEquipmentCount(request); + + QSqlDatabase dbLocal = CDbConnectionPool::instance().openConnection("local"); + QSqlQuery query(dbLocal); + + QString sql = "SELECT eei.id AS sample_id, eei.equipment_name AS sample_name, eei.manufacturer, eei.manufacture_no, " + "eei.check_date, eei.check_organization, eei.quality_condition, eemi.model, " + "bbdmii.id AS itemid, bbdmii.item_category_name, bbdmii.belong_standard_equipment, bbdmii.approval_status " + "FROM eqpt_equipment_info eei " + "LEFT JOIN eqpt_equipment_model_info eemi ON eei.model_id = eemi.id " + "LEFT JOIN biz_business_device_measure_item_info bbdmii ON eei.model_id = bbdmii.device_model_id " + "LEFT JOIN biz_business_device_measure_item_category bbdmic ON bbdmic.id = bbdmii.item_category_id"; + + sql = QString("%1 %2").arg(sql).arg(generateEqptEqptInfoListPageWhereClause(request)); + + // 添加分页查询 + sql = QString("%1 ORDER BY eei.id ASC").arg(sql); + sql = QString("%1 %2").arg(sql).arg("LIMIT :offset, :limit;"); + +// qDebug() << sql << page.currentPage * page.tableRowCount << page.tableRowCount; + + query.prepare(sql); + bindValueEqptEqptInfoListPage(query, request); + query.bindValue(":offset", page.currentPage * page.pageSize); + query.bindValue(":limit", page.pageSize); + + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + MyTaskDto task; + task.id = query.value("sample_id").toString(); + task.sampleId = query.value("sample_id").toString(); + task.sampleName = query.value("sample_name").toString(); + task.sampleModel = query.value("model").toString(); + task.manufactureNo = query.value("manufacture_no").toString(); + task.manufacturer = query.value("manufacturer").toString(); + task.checkDate = query.value("check_date").toString(); + task.inputCheckOrganization = query.value("check_organization").toString(); + task.inputAddress = query.value("quality_condition").toString(); + task.belongStandardEquipment = query.value("belong_standard_equipment").toString(); +// task.belongStandardEquipmentName = ConstCailDeviceGroup.value(query.value("belong_standard_equipment").toString()); + task.approvalStatus = query.value("approval_status").toString(); + + resultList.append(task); + } + } else { + LogUtil::PrintLog("ERROR", QString("查询标准设备失败[%1]").arg(query.lastError().text())); + } + + return resultList; +} +*/ + +QString TaskDao::generateTaskListPageWhereClause(TaskRequest request) +{ + QString where = "WHERE blei.measure_status != 1"; // 1=待分配 不出现在自动检定的任务清单中 + if (!request.userId.isEmpty()) { + where = QString("%1 AND blei.measure_person_id = :userId").arg(where); + } + if (!request.deptId.isEmpty()) { + where = QString("%1 AND blei.measure_dept_id = :deptId").arg(where); + } + if (!request.sampleName.isEmpty()) { + where = QString("%1 AND eei.equipment_name like :eqptName").arg(where); + } + if (!request.sampleModel.isEmpty()) { + where = QString("%1 AND eei.model like :model").arg(where); + } + if (!request.customerName.isEmpty()) { + where = QString("%1 AND bo.customer_name like :customer").arg(where); + } + if (!request.requireStart.isEmpty()) { + where = QString("%1 AND bo.require_over_time > :start").arg(where); + } + if (!request.requireEnd.isEmpty()) { + where = QString("%1 AND bo.require_over_time < :end").arg(where); + } + if (!request.isUrgent.isEmpty()) { + where = QString("%1 AND bo.is_urgent = :urgent").arg(where); + } + if (!request.measureStatusList.isEmpty()) { + where = QString("%1 AND blei.measure_status IN (:statusList)").arg(where); + } + + return where; +} + +void TaskDao::bindValueTaskListPage(QSqlQuery query, TaskRequest request) +{ + if (!request.userId.isEmpty()) { + query.bindValue(":userId", request.userId); + } + if (!request.deptId.isEmpty()) { + query.bindValue(":deptId", request.deptId); + } + if (!request.sampleName.isEmpty()) { + query.bindValue(":eqptName", "%" + request.sampleName + "%"); + } + if (!request.sampleModel.isEmpty()) { + query.bindValue(":model", "%" + request.sampleModel + "%"); + } + if (!request.customerName.isEmpty()) { + query.bindValue(":customer", "%" + request.customerName + "%"); + } + if (!request.requireStart.isEmpty()) { + query.bindValue(":start", request.requireStart); + } + if (!request.requireEnd.isEmpty()) { + query.bindValue(":end", request.requireEnd); + } + if (!request.isUrgent.isEmpty()) { + query.bindValue(":urgent", request.isUrgent); + } + if (!request.measureStatusList.isEmpty()) { + query.bindValue(":statusList", request.measureStatusList.join(",")); + } +} diff --git a/dao/TaskDao.h b/dao/TaskDao.h new file mode 100644 index 0000000..26d31a9 --- /dev/null +++ b/dao/TaskDao.h @@ -0,0 +1,38 @@ +#ifndef TASKDAO_H +#define TASKDAO_H + +#include "BaseDao.h" + +/** + * @brief The TaskRequest struct + * 部门任务 我的任务查询条件 + */ +struct TaskRequest { + QString userId; // 用户Id + QString deptId; // 部门Id + QString sampleName; // 样品/设备名称 + QString sampleModel; // 样品/设备型号 + QString customerName; // 委托方名称 + QString requireStart; // 要求检完时间-开始时间 + QString requireEnd; // 要求检完时间-结束时间 + QString isUrgent; // 是否加急 + QStringList measureStatusList; // 多选测试状态 +}; + + +class TaskDao : public BaseDao +{ +public: + TaskDao(); + + QList getTaskListPage(TaskRequest request, Page& page); + + +private: + QString generateTaskListPageWhereClause(TaskRequest request); + void bindValueTaskListPage(QSqlQuery query, TaskRequest request); + + quint32 getTaskTotalCount(TaskRequest request); +}; + +#endif // TASKDAO_H diff --git a/dao/dao.pri b/dao/dao.pri index 375914f..8989888 100644 --- a/dao/dao.pri +++ b/dao/dao.pri @@ -8,7 +8,11 @@ SOURCES += $$PWD/util/CdbConnectionPool.cpp HEADERS += $$PWD/service/SysUserService.h +HEADERS += $$PWD/service/SysLocalService.h +HEADERS += $$PWD/service/TaskService.h SOURCES += $$PWD/service/SysUserService.cpp +SOURCES += $$PWD/service/SysLocalService.cpp +SOURCES += $$PWD/service/TaskService.cpp #HEADERS += $$PWD/EqptEquipmentDao.h @@ -17,11 +21,14 @@ HEADERS += $$PWD/SystemDao.h SOURCES += $$PWD/SystemDao.cpp +HEADERS += $$PWD/SystemLocalDao.h +SOURCES += $$PWD/SystemLocalDao.cpp + #HEADERS += $$PWD/EquipmentDao.h #SOURCES += $$PWD/EquipmentDao.cpp -#HEADERS += $$PWD/TaskDao.h -#SOURCES += $$PWD/TaskDao.cpp +HEADERS += $$PWD/TaskDao.h +SOURCES += $$PWD/TaskDao.cpp #HEADERS += $$PWD/OrderDao.h #SOURCES += $$PWD/OrderDao.cpp @@ -34,3 +41,4 @@ #HEADERS += $$PWD/ResSystemFileDao.h #SOURCES += $$PWD/ResSystemFileDao.cpp + diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp new file mode 100644 index 0000000..1a46765 --- /dev/null +++ b/dao/service/SysLocalService.cpp @@ -0,0 +1,12 @@ +#include "SysLocalService.h" + +SysLocalService::SysLocalService() +{ + +} + +QList> SysLocalService::getInfomationTableColumns(QString tableName) +{ + SystemLocalDao dao; + return dao.getInfomationTableColumns(tableName); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h new file mode 100644 index 0000000..91ef5f0 --- /dev/null +++ b/dao/service/SysLocalService.h @@ -0,0 +1,14 @@ +#ifndef SYSLOCALSERVICE_H +#define SYSLOCALSERVICE_H + +#include "dao/SystemLocalDao.h" + +class SysLocalService +{ +public: + SysLocalService(); + + QList> getInfomationTableColumns(QString tableName); +}; + +#endif // SYSLOCALSERVICE_H diff --git a/dao/service/TaskService.cpp b/dao/service/TaskService.cpp new file mode 100644 index 0000000..5af1053 --- /dev/null +++ b/dao/service/TaskService.cpp @@ -0,0 +1,37 @@ +#include "TaskService.h" + +#include "utils/ProMemory.h" + +TaskService::TaskService() +{ + +} + +QList TaskService::getDeptTaskListPage(TaskRequest request, Page &page) +{ + TaskDao taskDao; + SystemDao systemDao; + + // 根据计量人员userId查询所在部门deptId + QString deptId = systemDao.getStaffDeptIdByUserId(request.userId); + request.deptId = deptId; + request.userId = ""; // 查询部门任务时不需要userId + + QList deptTaskList = taskDao.getTaskListPage(request, page); + + // 获取字典值 + systemDao.getTaskMeasureStatusDict(); + + // 为其他字典值填充名称 + for (TaskDTO &task : deptTaskList) { + wrapperTaskDTO(task); + } + + return deptTaskList; +} + +void TaskService::wrapperTaskDTO(TaskDTO &task) +{ + task.isUrgentName = task.isUrgent == "1" ? "是" : "否"; + task.measureStatusName = ProMemory::getInstance().getMeasureStatusDict().value(QString("measureStatus-%1").arg(task.measureStatus)); +} diff --git a/dao/service/TaskService.h b/dao/service/TaskService.h new file mode 100644 index 0000000..07290f8 --- /dev/null +++ b/dao/service/TaskService.h @@ -0,0 +1,18 @@ +#ifndef TASKSERVICE_H +#define TASKSERVICE_H + +#include "dao/TaskDao.h" +#include "dao/SystemDao.h" + +class TaskService +{ +public: + TaskService(); + + QList getDeptTaskListPage(TaskRequest request, Page& page); + +private: + void wrapperTaskDTO(TaskDTO & task); +}; + +#endif // TASKSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index 53f8bcb..2ded44b 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -14,10 +14,10 @@ // 每秒更新 界面上没有地方能摆 暂时先不启动定时器 connect(TimeCounterUtil::getInstance().clockTimer, &QTimer::timeout, this, &MainWindowForm::onUpdateTimestampHandler); -// TimeCounterUtil::getInstance().clockTimer->start(1000); + TimeCounterUtil::getInstance().clockTimer->start(1000); /** 临时调试代码 **/ -// emit ui->btnInfo->clicked(); + emit ui->btnInfomation->clicked(); } MainWindowForm::~MainWindowForm() @@ -54,16 +54,17 @@ setWindowTitle(SettingConfig::getInstance().CLIENT_TITLE); // 设置最小尺寸(宽度, 高度) lxc - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenSize = screen->availableGeometry(); // 可用区域(排除任务栏) - // 设置最小尺寸为屏幕宽度的 80%,高度 600 - int minWidth = screenSize.width() * 0.8; - this->setMinimumSize(minWidth, 600); + // 设置最小尺寸为屏幕宽度的 80%,高度 600 + int minWidth = screenSize.width() * 0.8; + this->setMinimumSize(minWidth, 600); } void MainWindowForm::initMenuWidgets() { + wdgtInfoMain = new InfoMainForm(this); // wdgtInfo = new TF_InfoManag(this); // wdgtCheckMethod = new CheckMethodManage(this); // wdgtCheck = new CheckWindow(this); @@ -85,6 +86,7 @@ // connect(wdgtCheck, &CheckWindow::BarsetEnabled, this, &MainWindowForm::onMenuButtonsEabled); // 添加到stackWidget中 + ui->wdgtContent->insertWidget(2, wdgtInfoMain); // ui->wdgtContent->insertWidget(0, wdgtCalibrationForm); // ui->wdgtContent->insertWidget(1, wdgtStdDevForm); // ui->wdgtContent->insertWidget(1, wdgtStandDev); @@ -135,25 +137,13 @@ if(btn) { btn->setChecked(true); ui->wdgtContent->setCurrentIndex(btn->property("index").toInt()); - - /** 待所有的导航菜单替换完之后不再需要 **/ - // 获取当前在 QStackedWidget 中的部件 - QWidget * currentWidget = ui->wdgtContent->currentWidget(); - - // 尝试将当前部件转换为 InfoBase 类型 -// Baseobject * baseInfo = qobject_cast(currentWidget); -// // 检查转换是否成功 -// if (baseInfo != nullptr) { -// // 如果转换成功,调用子类Load 方法 -// baseInfo->Load(); -// } } } void MainWindowForm::onUpdateTimestampHandler() { QDateTime now = QDateTime::currentDateTime(); - // ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); + ui->labelTime->setText(now.toString("yyyy-MM-dd HH:mm:ss")); } void MainWindowForm::on_btnMenuMax_clicked() diff --git a/frame/MainWindowForm.h b/frame/MainWindowForm.h index bc111de..4d206b1 100644 --- a/frame/MainWindowForm.h +++ b/frame/MainWindowForm.h @@ -11,6 +11,9 @@ #include "frame/MaskWidget.h" #include "frame/CustomMessageBox.h" #include "frame/FramelessWindow.h" + +#include "infomation/InfoMainForm.h" + //#include "infomation/standDev/StandardDeviceForm.h" //#include "infomation/testDev/TestDeviceForm.h" //#include "infomation/fileRes/FileResourcesForm.h" @@ -53,6 +56,8 @@ private: Ui::MainWindowForm *ui; + InfoMainForm * wdgtInfoMain; + // TF_InfoManag * wdgtInfo; // CheckMethodManage * wdgtCheckMethod; // CheckWindow * wdgtCheck; diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index 8fa49fc..bd42122 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -96,7 +96,7 @@ - :/image/main/icon_main.png + :/image/login/logo.png true @@ -154,110 +154,6 @@ 0 - - - - 100 - 84 - - - - 计量数据 - - - - :/image/main/info.png:/image/main/info.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 标准设备 - - - - :/image/main/standDevice.png:/image/main/standDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 被检设备 - - - - :/image/main/checkDevice.png:/image/main/checkDevice.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 检定程序 - - - - :/image/main/checkProgram.png:/image/main/checkProgram.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - @@ -266,10 +162,10 @@ - 自动校准 + 自动检定 - + :/image/main/calibration.png:/image/main/calibration.png @@ -284,7 +180,7 @@ - + 100 @@ -292,10 +188,10 @@ - 原始记录 + 自动核查 - + :/image/main/rawDataRecord.png:/image/main/rawDataRecord.png @@ -310,7 +206,7 @@ - + 100 @@ -318,36 +214,10 @@ - 证书报告 + 信息管理 - - :/image/main/certApproval.png:/image/main/certApproval.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 100 - 84 - - - - 计量文件 - - - + :/image/main/fileRes.png:/image/main/fileRes.png @@ -361,37 +231,17 @@ - - - - - 100 - 84 - - - - 系统管理 - - - - :/image/main/staff.png:/image/main/staff.png - - - - 36 - 36 - - - - Qt::ToolButtonTextUnderIcon - - -
+ + + 320 + 16777215 + + 0 @@ -457,7 +307,7 @@ - + :/image/main/icon_setting_p.png:/image/main/icon_setting_p.png @@ -483,7 +333,7 @@ - + :/image/main/icon_min_p.png:/image/main/icon_min_p.png @@ -509,7 +359,7 @@ - + :/image/main/icon_close_p.png:/image/main/icon_close_p.png @@ -543,6 +393,12 @@ + + + 0 + 0 + + 欢迎! @@ -570,13 +426,91 @@ + + + + + 0 + 30 + + + + + 20 + + + 0 + + + 0 + + + 40 + + + 0 + + + + + Qt::Horizontal + + + + 1289 + 20 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + wdgtContent wdgtTop + wdgtFoot - + diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp new file mode 100644 index 0000000..c001199 --- /dev/null +++ b/infomation/InfoMainForm.cpp @@ -0,0 +1,59 @@ +#include "InfoMainForm.h" +#include "ui_InfoMainForm.h" + +InfoMainForm::InfoMainForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::InfoMainForm) +{ + ui->setupUi(this); + + initForm(); + initSubMenuForms(); + initMenuButtons(); + + ui->menuDeptTask->click(); +} + +InfoMainForm::~InfoMainForm() +{ + delete ui; +} + +void InfoMainForm::initForm() +{ + + + +} +void InfoMainForm::initSubMenuForms() +{ + fmMyTask = new MyTaskForm(this); + fmDeptTask = new DeptTaskForm(this); + fmNewTask = new NewTaskForm(this); + + ui->wdgtInfoTable->insertWidget(0, fmDeptTask); + ui->wdgtInfoTable->insertWidget(1, fmMyTask); + ui->wdgtInfoTable->insertWidget(2, fmNewTask); +} +void InfoMainForm::initMenuButtons() +{ + // 查找所有 QPushButton 类型的子控件 + QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 + QList buttList = ui->wdgtMenu->findChildren(); + for (int i = 0; i < buttList.size(); i++) { + QToolButton * menuButt = buttList.at(i); + menuButt->setProperty("index", i); + menuButt->setCheckable(true); + funcButtGroup->addButton(menuButt); + connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); + } +} + +void InfoMainForm::onMenuButtonsAction() +{ + QToolButton *btn = qobject_cast(sender()); + if(btn) { + btn->setChecked(true); + ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); + } +} diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h new file mode 100644 index 0000000..d6060ea --- /dev/null +++ b/infomation/InfoMainForm.h @@ -0,0 +1,38 @@ +#ifndef INFOMAINFORM_H +#define INFOMAINFORM_H + +#include +#include + +#include "task/MyTaskForm.h" +#include "task/DeptTaskForm.h" +#include "task/NewTaskForm.h" + +namespace Ui { +class InfoMainForm; +} + +class InfoMainForm : public QWidget +{ + Q_OBJECT + +public: + explicit InfoMainForm(QWidget *parent = nullptr); + ~InfoMainForm(); + +private: + Ui::InfoMainForm *ui; + + MyTaskForm * fmMyTask; + DeptTaskForm * fmDeptTask; + NewTaskForm * fmNewTask; + + void initForm(); + void initSubMenuForms(); + void initMenuButtons(); + +private slots: + void onMenuButtonsAction(); +}; + +#endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui new file mode 100644 index 0000000..958a6b2 --- /dev/null +++ b/infomation/InfoMainForm.ui @@ -0,0 +1,282 @@ + + + InfoMainForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 300 + 624 + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 280 + 48 + + + + 实验室任务 + + + + + + + + 280 + 48 + + + + 我的任务 + + + + + + + + 280 + 48 + + + + 新建任务单 + + + + + + + + 280 + 48 + + + + 标准设备管理 + + + + + + + + 280 + 48 + + + + 被检设备管理 + + + + + + + + 280 + 48 + + + + 检定数据管理 + + + + + + + + 280 + 48 + + + + 核查数据管理 + + + + + + + + 280 + 48 + + + + 检定程序管理 + + + + + + + + 280 + 48 + + + + 核查程序管理 + + + + + + + + 280 + 48 + + + + 体系文件 + + + + + + + + 280 + 48 + + + + 现行测试校准检定方法 + + + + + + + + 280 + 48 + + + + 签名管理 + + + + + + + + 280 + 48 + + + + 数据同步 + + + + + + + Qt::Vertical + + + + 20 + 19 + + + + + + + + + + + + + + + + diff --git a/infomation/config/conf.pri b/infomation/config/conf.pri new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/infomation/config/conf.pri diff --git a/infomation/infomation.pri b/infomation/infomation.pri index 7cc86f7..c891050 100644 --- a/infomation/infomation.pri +++ b/infomation/infomation.pri @@ -1,4 +1,10 @@ include(task/task.pri) include(equipment/eqpt.pri) include(data/data.pri) +include(config/conf.pri) include(file/file.pri) + +HEADERS += $$PWD/InfoMainForm.h +SOURCES += $$PWD/InfoMainForm.cpp + +FORMS += $$PWD/InfoMainForm.ui diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp new file mode 100644 index 0000000..ea21a9f --- /dev/null +++ b/infomation/task/DeptTaskForm.cpp @@ -0,0 +1,89 @@ +#include "DeptTaskForm.h" +#include "ui_DeptTaskForm.h" + +DeptTaskForm::DeptTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::DeptTaskForm) +{ + ui->setupUi(this); + + initFormTable(); + + // 绑定信号与槽 + connect(ui->tableDeptTask, &QPagedTable::reloadTablePagedData, this, &DeptTaskForm::getDeptTaskList); +} + +DeptTaskForm::~DeptTaskForm() +{ + delete ui; +} + +void DeptTaskForm::showEvent(QShowEvent *event) +{ + ui->tableDeptTask->adjustTableWidth(); + getDeptTaskList(0); +} + +void DeptTaskForm::initFormTable() +{ + // 初始化查询条件 + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + SysLocalService localServ; + QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); + ui->tableDeptTask->setColumns(deptTaskColumns); + + ui->tableDeptTask->initTableWidget(); + ui->tableDeptTask->initTableHeader(); +} + +void DeptTaskForm::getDeptTaskList(int currPage) +{ + TaskService taskServ; + + TaskRequest request; + request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); + request.sampleName = ui->inputDevName->text(); + request.sampleModel = ui->inputDevModel->text(); + request.customerName = ui->selectCustomer->currentData().toString(); + request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); + request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); +// request.measureStatusList << ui->selectStatus->currentData().toString(); + request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + + page.currentPage = currPage; + + QList deptTaskList = taskServ.getDeptTaskListPage(request, page); + QList> pageData; + for (TaskDTO task : deptTaskList) { + QMap item; + + item.insert("id", task.id); + item.insert("name", task.sampleName); + item.insert("model", task.sampleModel); + item.insert("serialNo", task.manufactureNo); + item.insert("maker", task.manufacturer); + item.insert("custom", task.customerName); + item.insert("requireTime", task.requireOverTime); + item.insert("isUrgent", task.isUrgentName); + item.insert("orderNo", task.orderNo); + item.insert("measureStatus", task.measureStatusName); + + pageData.append(item); + + } + + ui->tableDeptTask->setTotalCount(page.totalCount); + ui->tableDeptTask->setDatas(pageData); +} + +void DeptTaskForm::on_btnQuery_clicked() +{ + getDeptTaskList(0); +} + +void DeptTaskForm::on_btnResetQuery_clicked() +{ + +} diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h new file mode 100644 index 0000000..1055c36 --- /dev/null +++ b/infomation/task/DeptTaskForm.h @@ -0,0 +1,38 @@ +#ifndef DEPTTASKFORM_H +#define DEPTTASKFORM_H + +#include + +#include "dao/service/SysLocalService.h" +#include "dao/service/TaskService.h" +#include "utils/ProMemory.h" +#include "utils/utilsInclude.h" + +namespace Ui { +class DeptTaskForm; +} + +class DeptTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit DeptTaskForm(QWidget *parent = nullptr); + ~DeptTaskForm(); + +protected: + void showEvent(QShowEvent *event) override; + +private: + Ui::DeptTaskForm *ui; + Page page; + + void initFormTable(); + +private slots: + void getDeptTaskList(int currPage); + void on_btnQuery_clicked(); + void on_btnResetQuery_clicked(); +}; + +#endif // DEPTTASKFORM_H diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui new file mode 100644 index 0000000..2287fae --- /dev/null +++ b/infomation/task/DeptTaskForm.ui @@ -0,0 +1,256 @@ + + + DeptTaskForm + + + + 0 + 0 + 1442 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 15 + + + 15 + + + + + + 15 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + + + 受检设备名称 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + 规格型号 + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择委托方 + + + + + + + + + 0 + 0 + + + + + 150 + 36 + + + + + 请选择检测状态 + + + + + + + + + 0 + 36 + + + + 要求检完时间 + + + + + + + + 150 + 36 + + + + + + + + + 150 + 36 + + + + + + + + + 0 + 36 + + + + 加急 + + + + + + + Qt::Horizontal + + + + 130 + 20 + + + + + + + + + 120 + 36 + + + + 查询 + + + + + + + + 120 + 36 + + + + 重置 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + QPagedTable + QWidget +
QPagedTable/QPagedTable.h
+
+
+ + +
diff --git a/infomation/task/MyTaskForm.cpp b/infomation/task/MyTaskForm.cpp new file mode 100644 index 0000000..c442d82 --- /dev/null +++ b/infomation/task/MyTaskForm.cpp @@ -0,0 +1,14 @@ +#include "MyTaskForm.h" +#include "ui_MyTaskForm.h" + +MyTaskForm::MyTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::MyTaskForm) +{ + ui->setupUi(this); +} + +MyTaskForm::~MyTaskForm() +{ + delete ui; +} diff --git a/infomation/task/MyTaskForm.h b/infomation/task/MyTaskForm.h new file mode 100644 index 0000000..5976f65 --- /dev/null +++ b/infomation/task/MyTaskForm.h @@ -0,0 +1,22 @@ +#ifndef MYTASKFORM_H +#define MYTASKFORM_H + +#include + +namespace Ui { +class MyTaskForm; +} + +class MyTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit MyTaskForm(QWidget *parent = nullptr); + ~MyTaskForm(); + +private: + Ui::MyTaskForm *ui; +}; + +#endif // MYTASKFORM_H diff --git a/infomation/task/MyTaskForm.ui b/infomation/task/MyTaskForm.ui new file mode 100644 index 0000000..3cddb2c --- /dev/null +++ b/infomation/task/MyTaskForm.ui @@ -0,0 +1,19 @@ + + + MyTaskForm + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + diff --git a/infomation/task/NewTaskForm.cpp b/infomation/task/NewTaskForm.cpp new file mode 100644 index 0000000..85cd3eb --- /dev/null +++ b/infomation/task/NewTaskForm.cpp @@ -0,0 +1,14 @@ +#include "NewTaskForm.h" +#include "ui_NewTaskForm.h" + +NewTaskForm::NewTaskForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewTaskForm) +{ + ui->setupUi(this); +} + +NewTaskForm::~NewTaskForm() +{ + delete ui; +} diff --git a/infomation/task/NewTaskForm.h b/infomation/task/NewTaskForm.h new file mode 100644 index 0000000..7eed3ef --- /dev/null +++ b/infomation/task/NewTaskForm.h @@ -0,0 +1,22 @@ +#ifndef NEWTASKFORM_H +#define NEWTASKFORM_H + +#include + +namespace Ui { +class NewTaskForm; +} + +class NewTaskForm : public QWidget +{ + Q_OBJECT + +public: + explicit NewTaskForm(QWidget *parent = nullptr); + ~NewTaskForm(); + +private: + Ui::NewTaskForm *ui; +}; + +#endif // NEWTASKFORM_H diff --git a/infomation/task/NewTaskForm.ui b/infomation/task/NewTaskForm.ui new file mode 100644 index 0000000..1244d0e --- /dev/null +++ b/infomation/task/NewTaskForm.ui @@ -0,0 +1,21 @@ + + + + + NewTaskForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/infomation/task/task.pri b/infomation/task/task.pri index e69de29..9278026 100644 --- a/infomation/task/task.pri +++ b/infomation/task/task.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/MyTaskForm.h +HEADERS += $$PWD/DeptTaskForm.h +HEADERS += $$PWD/NewTaskForm.h + +SOURCES += $$PWD/MyTaskForm.cpp +SOURCES += $$PWD/DeptTaskForm.cpp +SOURCES += $$PWD/NewTaskForm.cpp + +FORMS += $$PWD/MyTaskForm.ui +FORMS += $$PWD/DeptTaskForm.ui +FORMS += $$PWD/NewTaskForm.ui diff --git a/res/image/login/logo.png b/res/image/login/logo.png new file mode 100644 index 0000000..0d201f6 --- /dev/null +++ b/res/image/login/logo.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index 84ff02a..68608e9 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -114,5 +114,6 @@ image/msgbox/icon_box_success.png image/msgbox/icon_box_warning.png image/msgbox/icon_box_fail.png + image/login/logo.png diff --git a/res/qss/mainForm.css b/res/qss/mainForm.css index f1eaa41..666e8de 100644 --- a/res/qss/mainForm.css +++ b/res/qss/mainForm.css @@ -65,6 +65,13 @@ QWidget#wdgtTemp QLabel{ font-size: 20px; color: #333333; - font-family: "Microsoft YaHei"; + font-family: "Microsoft YaHei"; } + +/** 状态栏 **/ +QWidget#wdgtFoot QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} diff --git a/utils/ProMemory.cpp b/utils/ProMemory.cpp index c2b6d26..0b82146 100644 --- a/utils/ProMemory.cpp +++ b/utils/ProMemory.cpp @@ -36,3 +36,12 @@ { this->groupCodeDict = bizGroupCode; } + +QMap ProMemory::getMeasureStatusDict() +{ + return this->measureStatusDict; +} +void ProMemory::setMeasureStatusDict(QMap measureStatus) +{ + this->measureStatusDict = measureStatus; +} diff --git a/utils/ProMemory.h b/utils/ProMemory.h index 62aef18..ee6911f 100644 --- a/utils/ProMemory.h +++ b/utils/ProMemory.h @@ -27,6 +27,9 @@ QMap getGroupCodeDict(); void setGroupCodeDict(QMap bizGroupCode); + QMap getMeasureStatusDict(); + void setMeasureStatusDict(QMap measureStatus); + private: ProMemory(); @@ -34,6 +37,7 @@ QMap labCodeDict; QMap groupCodeDict; + QMap measureStatusDict; }; #endif // PROMEMORY_H diff --git a/utils/utils.pri b/utils/utils.pri index d326cac..38f51d6 100644 --- a/utils/utils.pri +++ b/utils/utils.pri @@ -5,9 +5,6 @@ HEADERS += $$PWD/QssFileUtils.h SOURCES += $$PWD/QssFileUtils.cpp -HEADERS += $$PWD/PageUtil.h -SOURCES += $$PWD/PageUtil.cpp - HEADERS += $$PWD/LogUtil.h SOURCES += $$PWD/LogUtil.cpp diff --git a/utils/utilsInclude.h b/utils/utilsInclude.h index cbc1694..d83d60b 100644 --- a/utils/utilsInclude.h +++ b/utils/utilsInclude.h @@ -4,7 +4,6 @@ #include #include "AppInit.h" -#include "PageUtil.h" #include "LogUtil.h" #include "DownloadFileUtil.h" #include "QssFileUtils.h"