12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "importDataUtil.h"
- #include <QDebug>
- #include <QSettings>
- #include "dbService/ClassSet.h"
- #include "dbService/ProjectService.h"
- #include "dbService/CNodeDataService.h"
- #include "dbService/UserService.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();
- //清除表相关数据
- ProjectService().DeleteAll();
- CNodeDataService().DeleteAllNodeData();
- UserService().DeleteAllUser();
- //插入工程
- 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];
- 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];
- int retuser = UserService().AddUserInfo(user);
- qDebug() << "-------------retUser=" << retuser;
- }
- }
- ret = true;
- } catch (const std::exception &e) {
- // 捕获到std::exception类型的异常
- qDebug() << "Caught exception: " << e.what();
- }
- return ret;
- }
|