123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #include "ProjectManager.h"
- #include <dbService/DBServiceSet.h>
- #include <dbService/UserConfigService.h>
- #include <dbService/ProjectService.h>
- #include <QMetaEnum>
- #include <QDebug>
- 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::IndexType> ProjectManager::indexListOfEvalTypes(EvalTypes types)
- {
- QList<IndexType> list;
- QMetaEnum metaEnum = QMetaEnum::fromType<IndexType>();
- 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::EvalType> ProjectManager::evalTypeList(EvalTypes types)
- {
- QList<ProjectManager::EvalType> list;
- QMetaEnum metaEnum = QMetaEnum::fromType<EvalType>();
- 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::EvalType> ProjectManager::evalTypeList(ProjectInfo proj)
- {
- EvalTypes types = evalTypes(proj);
- QList<ProjectManager::EvalType> list = evalTypeList(types);
- return list;
- }
- QList<ProjectManager::IndexType> ProjectManager::indexList(ProjectInfo proj)
- {
- return indexListOfEvalTypes(evalTypes(proj));
- }
- int ProjectManager::queryProjects(QList<ProjectInfo *> *projList)
- {
- bool ret = ProjectService().QueryAll(projList);
- return ret ? QF_CODE_SUCCEEDED : QF_CODE_DATA_ERROR;
- }
- int ProjectManager::queryProjects(QList<ProjectInfo *> *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;
- }
|