123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- #include "ClassSet.h"
- #include "DBServiceSet.h"
- #include "UserService.h"
- #include <QCryptographicHash>
- #include <QSettings>
- #include <QDebug>
- QList<NodeMatrixInfo *> 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::IndexType> EngineerInfo::indexListOfEvalFlags(EvalTypes flags)
- {
- QList<IndexType> 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::IndexType> EngineerInfo::indexList() const
- {
- return indexListOfEvalFlags(evalFlags());
- }
|