|
@@ -14,6 +14,7 @@
|
|
|
#include <dbService/SchemeProcessService.h>
|
|
|
#include <dbService/UserConfigService.h>
|
|
|
#include <dbService/MindWeightService.h>
|
|
|
+#include <dbService/MindScoreService.h>
|
|
|
|
|
|
#include <QMap>
|
|
|
#include <QDebug>
|
|
@@ -50,11 +51,7 @@ bool DataEvaluator::evaluate()
|
|
|
}
|
|
|
} else if (m_process.type == SchemePlanManager::ImportEvalData) {
|
|
|
if (m_process.indexType == ProjectManager::TechIndex) {
|
|
|
- if (m_process.dSource == SchemePlanManager::FromExpert) {
|
|
|
- return evaluateTechFromExpert();
|
|
|
- } else if (m_process.dSource == SchemePlanManager::FromMeasurement) {
|
|
|
- return evaluateTechFromMeasure();
|
|
|
- }
|
|
|
+ return evaluateTech();
|
|
|
} else if (m_process.indexType == ProjectManager::OptimalIndex) {
|
|
|
return evaluateScheme();
|
|
|
} else if (m_process.indexType == ProjectManager::EfficiencyIndex) {
|
|
@@ -140,7 +137,7 @@ bool DataEvaluator::evaluateWeightFromExpert()
|
|
|
for (int j = 0; j < subNodes.size(); j++) {
|
|
|
double sum = 0;
|
|
|
for (QString expertId : nodeData.keys()) {
|
|
|
- sum += mWeights[expertId][subNodes[j].name];
|
|
|
+ sum += mWeights[expertId][subNodes[j].name] * config[expertId];
|
|
|
}
|
|
|
indexWeights[subNodes[j].name] = sum / nodeData.keys().size();
|
|
|
}
|
|
@@ -159,7 +156,7 @@ bool DataEvaluator::evaluateWeightFromExpert()
|
|
|
} else {
|
|
|
v = nodeValue[0].toDouble() / nodeValue[1].toDouble();
|
|
|
}
|
|
|
- sum += v;
|
|
|
+ sum += v * config[expertId];
|
|
|
}
|
|
|
avgNodeValue[key] = sum / nodeData.keys().size();
|
|
|
}
|
|
@@ -203,7 +200,6 @@ bool DataEvaluator::evaluateWeightFromExpert()
|
|
|
bool ret = MindWeightService().saveUniqueWeightData(m_process.projectId, m_process.indexType, m_process.dSource,
|
|
|
algorithm, valueStr);
|
|
|
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << ret << valueStr << endl;
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -316,19 +312,77 @@ bool DataEvaluator::evaluateWeightFromMeasure()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << allWeights << endl;
|
|
|
+ QStringList valueList;
|
|
|
+ for (QString key : allWeights.keys()) {
|
|
|
+ valueList.append(QString("%1:%2").arg(key).arg(allWeights[key]));
|
|
|
+ }
|
|
|
+ QString valueStr = valueList.join(";");
|
|
|
|
|
|
- return true;
|
|
|
-}
|
|
|
+ bool ret = MindWeightService().saveUniqueWeightData(m_process.projectId, m_process.indexType, m_process.dSource,
|
|
|
+ algorithm, valueStr);
|
|
|
|
|
|
-bool DataEvaluator::evaluateTechFromExpert()
|
|
|
-{
|
|
|
- return false;
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
-bool DataEvaluator::evaluateTechFromMeasure()
|
|
|
+bool DataEvaluator::evaluateTech()
|
|
|
{
|
|
|
- return false;
|
|
|
+ QMap<QString, double> weightData;
|
|
|
+ bool weightRet = getWeight(weightData);
|
|
|
+
|
|
|
+ QMap<QString, QMap<QString, NodeMatrixInfo *>> nodeData;
|
|
|
+ bool dataRet = getNodeData(nodeData);
|
|
|
+
|
|
|
+ /// 获取指标体系
|
|
|
+ QList<CNodeData> nodeList;
|
|
|
+ bool mindRet = CNodeDataService().QueryAll(nodeList, m_process.projectId, m_process.indexType);
|
|
|
+ CMind *mind = new CMind(this);
|
|
|
+ mind->setNodeList(nodeList);
|
|
|
+
|
|
|
+ /// 获取权重配置
|
|
|
+ QMap<QString, double> config;
|
|
|
+ bool cfgRet = false;
|
|
|
+ if (m_process.dSource == SchemePlanManager::FromExpert) {
|
|
|
+ cfgRet = getUserConfig(config);
|
|
|
+ } else {
|
|
|
+ for (QString uuid : nodeData.keys()) {
|
|
|
+ config[uuid] = 1.0 / nodeData.keys().size();
|
|
|
+ }
|
|
|
+ cfgRet = nodeData.size() > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (weightRet == false || dataRet == false || mindRet == false || nodeList.size() <= 0 || cfgRet == false) {
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ QMap<QString, double> scoreData;
|
|
|
+ for (int i = 1; i < mind->levels(); i++) {
|
|
|
+ for (CNodeData node : mind->nodesInLevel(i)) {
|
|
|
+ QList<CNodeData> subNodes = mind->subNodes(node);
|
|
|
+ for (int j = 0; j < subNodes.size(); j++) {
|
|
|
+ double score = 0;
|
|
|
+ for (QString uuid : nodeData.keys()) {
|
|
|
+ for (QString weightKey : weightData.keys()) {
|
|
|
+ QString key = subNodes[j].name + "-" + weightKey;
|
|
|
+ if (nodeData[uuid].keys().contains(key)) {
|
|
|
+ score += nodeData[uuid][key]->nodeValue.toDouble() * weightData[weightKey] * config[uuid];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scoreData[subNodes[j].name] = score;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QStringList valueList;
|
|
|
+ for (QString key : scoreData.keys()) {
|
|
|
+ valueList.append(QString("%1:%2").arg(key).arg(scoreData[key]));
|
|
|
+ }
|
|
|
+ QString valueStr = valueList.join(";");
|
|
|
+ bool ret = MindScoreService().saveUniqueScoreData(m_process.projectId, valueStr);
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << valueStr << endl;
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool DataEvaluator::evaluateScheme()
|
|
@@ -356,6 +410,12 @@ bool DataEvaluator::getNodeData(QMap<QString, QMap<QString, NodeMatrixInfo *>> &
|
|
|
if (ret == false) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ if (dataList.size() <= 0) {
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << "未录入评估数据" << endl;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
for (NodeMatrixInfo *info : dataList) {
|
|
|
QString key = info->strUuid; // 实测数据的 key
|
|
|
if (m_process.dSource == SchemePlanManager::FromExpert) {
|
|
@@ -406,7 +466,34 @@ bool DataEvaluator::getUserConfig(QMap<QString, double> &cfg) const
|
|
|
}
|
|
|
|
|
|
for (UserConfig *config : userCfgList) {
|
|
|
- cfg[QString("%1").arg(config->userId)] = config->weight;
|
|
|
+ cfg[QString("%1").arg(config->userId)] = config->weight / 100;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool DataEvaluator::getWeight(QMap<QString, double> &weight) const
|
|
|
+{
|
|
|
+ MindWeightInfo info;
|
|
|
+ int indexType = m_process.indexType;
|
|
|
+ if (indexType == ProjectManager::TechIndex) {
|
|
|
+ indexType = ProjectManager::AbilityIndex;
|
|
|
+ }
|
|
|
+ bool ret = MindWeightService().queryWeightData(&info, m_process.projectId, indexType);
|
|
|
+ if (ret == false) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (info.id < 0) {
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << "未找到指标权重数据" << endl;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ QStringList weightList = info.weight.split(";");
|
|
|
+ for (QString keyValueStr : weightList) {
|
|
|
+ QStringList keyValue = keyValueStr.split(":");
|
|
|
+ if (keyValue.size() == 2) {
|
|
|
+ weight[keyValue.first()] = keyValue.last().toDouble();
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|