#include "ProjectManager.h" #include #include #include #include #include QString ProjectManager::nameOfIndexType(ProjectManager::IndexType t) { switch (t) { case AbilityIndex: return "能力重要度评估"; case TechIndex: return "技术措施重要度评估"; case OptimalIndex: return "方案优选评估"; case EfficiencyIndex: return "综合效能评估"; } } QString ProjectManager::nameOfEvalType(ProjectManager::EvalType t) { switch (t) { case None: return "无"; case DemandEval: return "需求分析评估"; case OptimalEval: return "方案优选评估"; case EfficiencyEval: return "综合效能评估"; } } QList ProjectManager::indexListOfEvalTypes(EvalTypes types) { QList list; QMetaEnum metaEnum = QMetaEnum::fromType(); for (int i = 0; i < metaEnum.keyCount(); i++) { IndexType t = IndexType(metaEnum.value(i)); if ((types & t) == t) { list.append(t); } } return list; } ProjectManager::EvalTypes ProjectManager::evalTypes(ProjectInfo proj) { int t = proj.estimateType.toInt(); EvalTypes types = EvalTypes(t); return types; } QList ProjectManager::evalTypeList(EvalTypes types) { QList list; QMetaEnum metaEnum = QMetaEnum::fromType(); for (int i = 0; i < metaEnum.keyCount(); i++) { EvalType t = EvalType(metaEnum.value(i)); if (t != None && (types & t) == t) { list.append(t); } } return list; } QList ProjectManager::evalTypeList(ProjectInfo proj) { EvalTypes types = evalTypes(proj); QList list = evalTypeList(types); return list; } QList ProjectManager::indexList(ProjectInfo proj) { return indexListOfEvalTypes(evalTypes(proj)); } int ProjectManager::queryProjects(QList *projList) { bool ret = ProjectService().QueryAll(projList); return ret ? QF_CODE_SUCCEEDED : QF_CODE_DATA_ERROR; } int ProjectManager::queryProjects(QList *list, int &total, int page, int pageSize, QString name) { qDebug() << __FUNCTION__ << __LINE__ << "page:" << page << "pagesize:" << pageSize << "name:" << name << endl; bool ret = ProjectService().SelectAllByPage(list, total, page, pageSize, name); return ret ? QF_CODE_SUCCEEDED : QF_CODE_DATA_ERROR; } int ProjectManager::verifyProjectInfo(ProjectInfo proj) { if (proj.taskName.isEmpty() || proj.estimateObjective.isEmpty() || proj.estimateDept.isEmpty() || proj.estimatePerson.isEmpty() || proj.positionalTitles.isEmpty() || proj.remark.isEmpty()) { return QF_CODE_NEED_PROJ_SUMMARY; } if (proj.projectName.isEmpty()) { return QF_CODE_NEED_PROJ_NAME; } if (proj.estimateType.isEmpty()) { return QF_CODE_NEED_PROJ_TYPE; } return QF_CODE_SUCCEEDED; } int ProjectManager::insertProject(ProjectInfo &proj) { int code = verifyProjectInfo(proj); if (code == QF_CODE_SUCCEEDED) { int id = ProjectService().AddProjectInfo(proj); qDebug() << __FUNCTION__ << __LINE__ << "id:" << id; if (id == -1) { code = QF_CODE_PROJ_CREATE_FALIED; } } return code; } int ProjectManager::updateProject(ProjectInfo &proj) { if (proj.estimateType.isEmpty()) { return QF_CODE_PROJ_NOT_EDITABLE; } int code = verifyProjectInfo(proj); if (code == QF_CODE_SUCCEEDED) { bool ret = ProjectService().UpdateProjectInfo(proj); qDebug() << __FUNCTION__ << __LINE__ << "ret:" << ret; if (ret == false) { code = QF_CODE_PROJ_UPDATE_FALIED; } } return code; } int ProjectManager::deleteProject(int id) { bool ret = ProjectService().DeleteById(id); qDebug() << __FUNCTION__ << __LINE__ << "id:" << id << "ret:" << ret; return ret ? QF_CODE_SUCCEEDED : QF_CODE_PROJ_DELETE_FALIED; }