|
@@ -64,13 +64,17 @@ bool ExportReportManager::exportReport()
|
|
|
if (m_evalType == ProjectManager::OptimalEval) {
|
|
|
insertSchemeDesignInfo();
|
|
|
insertSchemeIndex();
|
|
|
- insertSchemeData();
|
|
|
insertSchemeAlgInfo();
|
|
|
+ insertSchemeData();
|
|
|
insertSchemeWeightData();
|
|
|
}
|
|
|
|
|
|
if (m_evalType == ProjectManager::EfficiencyEval) {
|
|
|
insertEffiIndex();
|
|
|
+ insertEffiAlgInfo();
|
|
|
+ insertEffiConfigData();
|
|
|
+ insertEffiSchemeData();
|
|
|
+ insertEffiWeightData();
|
|
|
}
|
|
|
|
|
|
m_word->setVisible(true);
|
|
@@ -249,7 +253,7 @@ void ExportReportManager::insertSchemeData()
|
|
|
QMap<int, QMap<QString, double>> schemeData;
|
|
|
QMap<int, QString> schemeNames;
|
|
|
QList<SchemaEval *> schemeList;
|
|
|
- ret = SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, 0);
|
|
|
+ ret = SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, m_schemeType);
|
|
|
if (ret == false || schemeList.size() <= 0) {
|
|
|
delete mind;
|
|
|
return;
|
|
@@ -542,6 +546,209 @@ void ExportReportManager::insertEffiIndex()
|
|
|
delete mind;
|
|
|
}
|
|
|
|
|
|
+void ExportReportManager::insertEffiAlgInfo()
|
|
|
+{
|
|
|
+ // bmWeightAlg bmEvalAlg
|
|
|
+ QList<SchemePlanManager::SchemeProcessInfo> processList;
|
|
|
+ bool processRet = SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, 8);
|
|
|
+ if (processRet == false) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < processList.size(); ++i) {
|
|
|
+ if (processList[i].type == SchemePlanManager::CalculateWeight) {
|
|
|
+ SchemePlanManager::Algorithm alg = processList[i].algorithm;
|
|
|
+ QString algStr = SchemePlanManager::stringFromAlgorithm(alg);
|
|
|
+ insertText("bmWeightAlg", algStr);
|
|
|
+ }
|
|
|
+ if (processList[i].type == SchemePlanManager::RunEvaluate) {
|
|
|
+ SchemePlanManager::Algorithm alg = processList[i].algorithm;
|
|
|
+ if (alg == SchemePlanManager::MEA) {
|
|
|
+ m_schemeType = 1;
|
|
|
+ } else {
|
|
|
+ m_schemeType = 2;
|
|
|
+ }
|
|
|
+ QString algStr = SchemePlanManager::stringFromAlgorithm(alg);
|
|
|
+ insertText("bmEvalAlg", algStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ExportReportManager::insertEffiConfigData()
|
|
|
+{
|
|
|
+ // bmProjName31, bmProjName32, bmConfigTable
|
|
|
+ insertText("bmProjName31", m_proj->projectName);
|
|
|
+ insertText("bmProjName32", m_proj->projectName);
|
|
|
+}
|
|
|
+
|
|
|
+void ExportReportManager::insertEffiSchemeData()
|
|
|
+{
|
|
|
+ QList<CNodeData> nodeList;
|
|
|
+ bool ret = CNodeDataService().QueryAllValid(nodeList, m_proj->id, 8);
|
|
|
+ if (ret == false) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CMind *mind = new CMind();
|
|
|
+ mind->setNodeList(nodeList);
|
|
|
+
|
|
|
+ QMap<int, QMap<QString, double>> schemeData;
|
|
|
+ QMap<int, QString> schemeNames;
|
|
|
+ QList<SchemaEval *> schemeList;
|
|
|
+ ret = SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, m_schemeType);
|
|
|
+ if (ret == false || schemeList.size() <= 0) {
|
|
|
+ delete mind;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (SchemaEval *scheme : schemeList) {
|
|
|
+ if (schemeData.keys().contains(scheme->id) == false) {
|
|
|
+ schemeData[scheme->id] = QMap<QString, double>();
|
|
|
+ }
|
|
|
+ QStringList keyValueStringList = scheme->valueStr.split(";");
|
|
|
+ for (QString keyValueStr : keyValueStringList) {
|
|
|
+ QStringList keyValue = keyValueStr.split(":");
|
|
|
+ if (keyValue.size() == 2) {
|
|
|
+ schemeData[scheme->id][keyValue.first()] = keyValue.last().toDouble();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ schemeNames[scheme->id] = scheme->name;
|
|
|
+ }
|
|
|
+
|
|
|
+ QList<CNodeData> leaveNodes = mind->leaves();
|
|
|
+ int rowCount = leaveNodes.size() + 1;
|
|
|
+ int columnCount = schemeNames.keys().size() + 1;
|
|
|
+ delete mind;
|
|
|
+
|
|
|
+ // bmSchemeDataTable
|
|
|
+ QAxObject *table = insertTable("bmEffiDataTable", rowCount, columnCount);
|
|
|
+ if (table == nullptr) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QList<int> schemeIds = schemeNames.keys();
|
|
|
+ for (int i = 0; i < schemeIds.size() + 1; ++i) {
|
|
|
+ if (i == 0) {
|
|
|
+ setCellString(table, 1, i + 1, "指标");
|
|
|
+ } else {
|
|
|
+ setCellString(table, 1, i + 1, schemeNames[schemeIds[i - 1]]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < leaveNodes.size(); ++i) {
|
|
|
+ CNodeData node = leaveNodes[i];
|
|
|
+ setCellString(table, i + 2, 1, node.name);
|
|
|
+
|
|
|
+ for (int j = 0; j < schemeIds.size(); ++j) {
|
|
|
+ QString value = QString("%1").arg(schemeData[schemeIds[j]][node.name]);
|
|
|
+ setCellString(table, i + 2, j + 2, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ExportReportManager::insertEffiWeightData()
|
|
|
+{
|
|
|
+ // 指标权重表:bmWeightTable,指标权重图:bmWeightPic
|
|
|
+
|
|
|
+ QList<CNodeData> nodeList;
|
|
|
+ bool ret = CNodeDataService().QueryAllValid(nodeList, m_proj->id, 8);
|
|
|
+ if (ret == false) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CMind *mind = new CMind();
|
|
|
+ mind->setNodeList(nodeList);
|
|
|
+
|
|
|
+ QList<CNodeData> leaveNodes = mind->leaves();
|
|
|
+ int rowCount = leaveNodes.size() + 1;
|
|
|
+ int columnCount = mind->levels();
|
|
|
+
|
|
|
+ // bmIndexTable
|
|
|
+ QAxObject *table = insertTable("bmWeightTable", rowCount, columnCount);
|
|
|
+ if (table == nullptr) {
|
|
|
+ delete mind;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 2; i <= mind->levels(); ++i) {
|
|
|
+ if (i < mind->levels()) {
|
|
|
+ setCellString(table, 1, i - 1, QString("%1级指标\n(能力项)").arg(i - 1));
|
|
|
+ } else {
|
|
|
+ setCellString(table, 1, i - 1, QString("指标"));
|
|
|
+ setCellString(table, 1, i, QString("权重值"));
|
|
|
+ }
|
|
|
+
|
|
|
+ QList<CNodeData> nodes = mind->nodesInLevel(i);
|
|
|
+ int rowPos = 2;
|
|
|
+ for (int j = 0; j < nodes.size(); ++j) {
|
|
|
+ CNodeData node = nodes[j];
|
|
|
+ int leaves = mind->leavesCountOfNode(node);
|
|
|
+ int textPos = (rowPos + leaves / 2);
|
|
|
+ setCellString(table, textPos, i - 1, node.name);
|
|
|
+
|
|
|
+ if (leaves > 1) {
|
|
|
+ mergeCells(table, rowPos, i - 1, leaves, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ rowPos += leaves;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ delete mind;
|
|
|
+
|
|
|
+ MindWeightInfo info;
|
|
|
+ ret = MindWeightService().queryWeightData(&info, m_proj->id, 8);
|
|
|
+ if (ret == false) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (info.id < 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QMap<QString, double> weightData;
|
|
|
+ QStringList weightList = info.weight.split(";");
|
|
|
+ for (QString keyValueStr : weightList) {
|
|
|
+ QStringList keyValue = keyValueStr.split(":");
|
|
|
+ if (keyValue.size() == 2) {
|
|
|
+ weightData[keyValue.first()] = keyValue.last().toDouble();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QVector<PlotView::Data> values;
|
|
|
+ for (int i = 0; i < leaveNodes.size(); ++i) {
|
|
|
+ CNodeData node = leaveNodes[i];
|
|
|
+ QString value = QString("%1").arg(weightData[node.name]);
|
|
|
+ setCellString(table, i + 2, columnCount, value);
|
|
|
+
|
|
|
+ PlotView::Data data { node.name, weightData[node.name] };
|
|
|
+ values.append(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ PlotView *plot = new PlotView(PlotView::HistogramHorizontal, values, "");
|
|
|
+ plot->setFixedSize(QSize(600, 600));
|
|
|
+ plot->plot();
|
|
|
+ QPixmap pixmap = plot->grab();
|
|
|
+ plot->deleteLater();
|
|
|
+ if (pixmap.isNull()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QString imgName = QString("%1_%2_weight").arg(m_proj->id).arg(4);
|
|
|
+ QString path = saveImage(imgName, pixmap);
|
|
|
+
|
|
|
+ QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmWeightPic");
|
|
|
+ if (bmWeightPic != nullptr) {
|
|
|
+ bmWeightPic->dynamicCall("Select(void)");
|
|
|
+ QAxObject *range = bmWeightPic->querySubObject("Range");
|
|
|
+ QAxObject *inlineShapes = range->querySubObject("InlineShapes");
|
|
|
+ QAxObject *shape = inlineShapes->querySubObject("AddPicture(const QString&)", path);
|
|
|
+ if (shape != nullptr) {
|
|
|
+ shape->setProperty("Width", 400);
|
|
|
+ shape->setProperty("Height", 400);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
bool ExportReportManager::insertText(const QString &bookmark, const QString &text)
|
|
|
{
|
|
|
bool ret = false;
|