123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #include "importDataUtil.h"
- #include <QDebug>
- #include <QSettings>
- #include "dbService/ClassSet.h"
- #include "dbService/ProjectService.h"
- #include "dbService/CNodeDataService.h"
- #include "dbService/UserService.h"
- #include "SchemePlanManager.h"
- #include "dbService/SchemeProcessService.h"
- #include "CNode.h"
- ImportDataUtil::ImportDataUtil() { }
- bool ImportDataUtil::importSystemData()
- {
- bool ret = false;
- try {
- // TODO 解析exportData数据
- QSettings exportData("exportData.ini", QSettings::IniFormat);
- exportData.setIniCodec("UTF-8");
- QString projectInfo = exportData.value("EXPORTDATA/projectInfo", "").toString();
- QString nodeDate = exportData.value("EXPORTDATA/nodeDate", "").toString();
- QString userInfo = exportData.value("EXPORTDATA/userInfo", "").toString();
- QString schemeProcess = exportData.value("EXPORTDATA/schemeProcess", "").toString();
- //清除表相关数据
- ProjectService().DeleteAll();
- CNodeDataService().DeleteAllNodeData();
- UserService().DeleteAllUser();
- SchemeProcessService().DeleteAll();
- //插入工程
- QStringList proList = projectInfo.split(",");
- ProjectInfo proj;
- proj.id = proList[0].toInt();
- proj.projectName = proList[1];
- proj.remark = proList[2];
- proj.taskName = proList[3];
- proj.estimateTime = proList[4];
- proj.estimateObjective = proList[5];
- proj.estimateDept = proList[6];
- proj.estimatePerson = proList[7];
- proj.estimateType = proList[8];
- proj.positionalTitles = proList[9];
- proj.createTime = proList[10];
- bool ret = ProjectService().SaveProjectInfo(proj);
- //保存节点信息系
- QStringList nodeList = nodeDate.split(";");
- for (int i = 0; i < nodeList.size(); i++) {
- CNodeData nodeData;
- QStringList nodeDataList = nodeList[i].split(",");
- if (nodeDataList.size() > 1) {
- nodeData.id = nodeDataList[0].toInt();
- nodeData.projectId = nodeDataList[1].toInt();
- nodeData.indexType = nodeDataList[2].toInt();
- nodeData.number = nodeDataList[3].toInt();
- nodeData.pNumber = nodeDataList[4].toInt();
- nodeData.name = nodeDataList[5];
- nodeData.remark = nodeDataList[6];
- nodeData.dimension = nodeDataList[7];
- nodeData.type = nodeDataList[8].toInt();
- nodeData.isEffective = nodeDataList[9].toInt();
- CNodeDataService().SaveCNodeData(nodeData);
- }
- }
- //保存用户信息
- QStringList userList = userInfo.split(";");
- for (int i = 0; i < userList.size(); i++) {
- QFUser user;
- QStringList userInfoList = userList[i].split(",");
- if (userInfoList.size() > 1) {
- user.id = userInfoList[0].toInt();
- user.userName = userInfoList[1];
- user.userNo = userInfoList[2];
- user.password = userInfoList[3];
- user.role = static_cast<QFUser::Role>(userInfoList[4].toInt());
- user.post = userInfoList[5];
- user.major = userInfoList[6];
- user.workPosition = userInfoList[7];
- user.educationDegree = userInfoList[8];
- user.phone = userInfoList[9];
- user.remark = userInfoList[10];
- user.projectId = userInfoList[11];
- user.writeTime = userInfoList[12];
- user.projectId = userInfoList[13];
- int retuser = UserService().AddUserInfo(user);
- // qDebug() << "-------------retUser=" << retuser;
- }
- }
- //保存流程信息
- QStringList schemeProcessList = schemeProcess.split(";");
- for (int i = 0; i < schemeProcessList.size(); i++) {
- QStringList schemeList = schemeProcessList[i].split(",");
- if (schemeList.size() > 1) {
- SchemePlanManager::SchemeProcessInfo info;
- info.id = schemeList[0].toInt();
- info.projectId = schemeList[1].toInt();
- info.indexType = schemeList[2].toInt();
- info.step = schemeList[3].toInt();
- info.type = static_cast<SchemePlanManager::SchemeProcessType>(schemeList[4].toInt());
- info.dSource = static_cast<SchemePlanManager::SchemeDataSource>(schemeList[5].toInt());
- info.algorithm = static_cast<SchemePlanManager::Algorithm>(schemeList[6].toInt());
- info.efficiencyGrades = schemeList[7].toInt();
- QVariant tempValue = schemeList[8];
- info.isChecked = tempValue.toBool();
- int retscheme = SchemeProcessService().SaveSchemeProcess(info);
- // qDebug() << "-------------retscheme=" << retscheme;
- }
- }
- ret = true;
- } catch (const std::exception &e) {
- // 捕获到std::exception类型的异常
- qDebug() << "Caught exception: " << e.what();
- }
- return ret;
- }
|