#include "ClassSet.h" #include "DBServiceSet.h" #include "UserService.h" #include #include #include QList ClassSet::datas; ClassSet::ClassSet() { datas.clear(); NodeMatrixInfo *testData = new NodeMatrixInfo(); testData->expertName = "luoyc"; testData->expertId = "1"; testData->engineerId = 1; testData->node = "1.1"; testData->abscissa = "A"; testData->ordinate = "A"; datas.append(testData); NodeMatrixInfo *testData1 = new NodeMatrixInfo(); testData1->expertName = "luoyc"; testData1->expertId = "1"; testData1->engineerId = 1; testData1->node = "1.1"; testData1->abscissa = "A"; testData1->ordinate = "B"; datas.append(testData1); NodeMatrixInfo *testData2 = new NodeMatrixInfo(); testData2->expertName = "luoyc"; testData2->expertId = "1"; testData2->engineerId = 1; testData2->node = "1.2"; testData2->abscissa = "B"; testData2->ordinate = "A"; datas.append(testData2); NodeMatrixInfo *testData3 = new NodeMatrixInfo(); testData3->expertName = "luoyc"; testData3->expertId = "1"; testData3->engineerId = 1; testData3->node = "1.2"; testData3->abscissa = "B"; testData3->ordinate = "B"; datas.append(testData3); NodeMatrixInfo *testData4 = new NodeMatrixInfo(); testData4->expertName = "luoyc"; testData4->expertId = "1"; testData4->engineerId = 1; testData4->node = "1.1.1"; testData4->abscissa = "A1"; testData4->ordinate = "A1"; datas.append(testData4); NodeMatrixInfo *testData5 = new NodeMatrixInfo(); testData5->expertName = "luoyc"; testData5->expertId = "1"; testData5->engineerId = 1; testData5->node = "1.1.1"; testData5->abscissa = "A1"; testData5->ordinate = "A2"; datas.append(testData5); NodeMatrixInfo *testData6 = new NodeMatrixInfo(); testData6->expertName = "luoyc"; testData6->expertId = "1"; testData6->engineerId = 1; testData6->node = "1.1.2"; testData6->abscissa = "A2"; testData6->ordinate = "A1"; datas.append(testData6); NodeMatrixInfo *testData7 = new NodeMatrixInfo(); testData7->expertName = "luoyc"; testData7->expertId = "1"; testData7->engineerId = 1; testData7->node = "1.1.2"; testData7->abscissa = "A2"; testData7->ordinate = "A2"; datas.append(testData7); NodeMatrixInfo *testData8 = new NodeMatrixInfo(); testData8->expertName = "luoyc"; testData8->expertId = "1"; testData8->engineerId = 1; testData8->node = "1.2.1"; testData8->abscissa = "B1"; testData8->ordinate = "B1"; datas.append(testData8); NodeMatrixInfo *testData9 = new NodeMatrixInfo(); testData9->expertName = "luoyc"; testData9->expertId = "1"; testData9->engineerId = 1; testData9->node = "1.2.1"; testData9->abscissa = "B1"; testData9->ordinate = "B2"; datas.append(testData9); NodeMatrixInfo *testData10 = new NodeMatrixInfo(); testData10->expertName = "luoyc"; testData10->expertId = "1"; testData10->engineerId = 1; testData10->node = "1.2.2"; testData10->abscissa = "B2"; testData10->ordinate = "B1"; datas.append(testData10); NodeMatrixInfo *testData11 = new NodeMatrixInfo(); testData11->expertName = "luoyc"; testData11->expertId = "1"; testData11->engineerId = 1; testData11->node = "1.2.2"; testData11->abscissa = "B2"; testData11->ordinate = "B2"; datas.append(testData11); } static QFUser *m_currentUser = nullptr; QString QFUser::nameOfRole(QFUser::Role role) { switch (role) { case QFUser::SuperAdmin: { return "超级管理员"; } case QFUser::GerneralAdmin: { return "普通管理员"; } case QFUser::Expert: { return "专家"; } default: return "未知"; } } QFUser::QFUser() { } QFUser::QFUser(const QString userId, const QString password) : userNo(userId), m_rawPassword(password) { } const QString QFUser::rawPassword() const { return m_rawPassword; } QFUser *QFUser::currentUser() { return m_currentUser; } QString QFUser::roleName() const { return nameOfRole(role); } int QFUser::logout() { if (m_currentUser == nullptr) { return QF_CODE_NOT_LOGIN; } delete m_currentUser; m_currentUser = nullptr; return QF_CODE_SUCCEEDED; } int QFUser::resetAdmin(QString account, QString password, QString repeatPassword) { qDebug() << account << password << repeatPassword << (password == repeatPassword); if (account.isEmpty()) { return QF_CODE_EMPTY_ACCOUNT; } else if (password.isEmpty()) { return QF_CODE_EMPTY_PASSWORD; } else if (password != repeatPassword) { return QF_CODE_PASSWORD_NOT_SAME; } else if (password == m_rawPassword) { return QF_CODE_PASSWORD_UNCHANGED; } QString md5str; QByteArray md5bytes = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5); md5str.prepend(md5bytes.toHex()); bool ret = UserService().UpdateUserById(account, md5str, id); if (ret) { return QF_CODE_SUCCEEDED; } else { return QF_CODE_DATA_ERROR; } } int QFUser::login() { if (m_currentUser != nullptr) { return QF_CODE_ALREADY_LOGIN; } if (userNo.isEmpty()) { return QF_CODE_EMPTY_ACCOUNT; } if (m_rawPassword.isEmpty()) { return QF_CODE_EMPTY_PASSWORD; } if (!UserService().QueryUserByNo(this, userNo)) { return QF_CODE_USER_NOT_EXISTS; } QCryptographicHash ch(QCryptographicHash::Md5); qDebug() << "m_rawPassword=" << m_rawPassword; QString md5str; QByteArray md5bytes = QCryptographicHash::hash(m_rawPassword.toLatin1(), QCryptographicHash::Md5); md5str.prepend(md5bytes.toHex()); qDebug() << "m_rawPassword=" << md5str; m_currentUser = new QFUser(userNo, m_rawPassword); if (!UserService().QueryUserByNoAndPassword(m_currentUser, userNo, md5str)) { delete m_currentUser; m_currentUser = nullptr; return QF_CODE_WRONG_PASSWORD; } return QF_CODE_SUCCEEDED; } QString EngineerInfo::nameOfEvalType(EngineerInfo::EvalType t) { switch (t) { case Importance: return "能力与技术重要度评估"; case TechSchema: return "技术方案评估"; case Requirements: return "需求分析评估"; case SchemeOptimization: return "方案优选评估"; case OverallEfficiency: return "综合效能评估"; } } QString EngineerInfo::nameOFIndexType(EngineerInfo::IndexType t) { switch (t) { case Capability: return "能力重要度评估指标体系"; case TechMessaures: return "技术措施重要度评估对象"; case SchemaEval: return "方案评估指标体系"; } } QList EngineerInfo::indexListOfEvalFlags(EvalTypes flags) { QList list; if ((flags & EngineerInfo::Importance) == EngineerInfo::Importance) { list.append(Capability); list.append(TechMessaures); } if ((flags & EngineerInfo::TechSchema) == EngineerInfo::TechSchema) { list.append(SchemaEval); } return list; } EngineerInfo::EvalTypes EngineerInfo::evalFlags() const { EvalTypes flags; if (remark.contains("能力与技术重要度评估")) { flags |= Importance; } if (remark.contains("技术方案评估")) { flags |= TechSchema; } return flags; } QList EngineerInfo::indexList() const { return indexListOfEvalFlags(evalFlags()); }