|
@@ -114,7 +114,7 @@ public class GeneralCalculateScoreComponent {
|
|
scoreGot = typeScoreMap.get(key);
|
|
scoreGot = typeScoreMap.get(key);
|
|
}
|
|
}
|
|
//获取权重
|
|
//获取权重
|
|
- double singleNodeWeight = getNodeWeight(basicNode, node.getCategory(), node.getName());
|
|
|
|
|
|
+ double singleNodeWeight = getNodeWeight(basicNode, node);
|
|
typeScoreMap.put(key, scoreGot + singleNodeWeight);
|
|
typeScoreMap.put(key, scoreGot + singleNodeWeight);
|
|
break;//一旦找到命中node则跳出,无需继续遍历
|
|
break;//一旦找到命中node则跳出,无需继续遍历
|
|
}
|
|
}
|
|
@@ -134,22 +134,28 @@ public class GeneralCalculateScoreComponent {
|
|
* 获取node节点的权重
|
|
* 获取node节点的权重
|
|
*
|
|
*
|
|
* @param basicNode 元node
|
|
* @param basicNode 元node
|
|
- * @param nodeName node名称
|
|
|
|
|
|
+ * @param singleNode 要计算权重的node节点
|
|
* @return node节点的权重
|
|
* @return node节点的权重
|
|
*/
|
|
*/
|
|
- private double getNodeWeight(CaseGraphDTO basicNode, String category, String nodeName) {
|
|
|
|
- int nodeNum = 0;
|
|
|
|
|
|
+ private double getNodeWeight(CaseGraphDTO basicNode, Node singleNode) {
|
|
|
|
+ int weightNum = 0;
|
|
|
|
+ int thisNodeWeight = singleNode.getWeight()==null?1:singleNode.getWeight();
|
|
for (Node node : basicNode.getNodes()) {
|
|
for (Node node : basicNode.getNodes()) {
|
|
- if (node.getCategory().equals(category)) {
|
|
|
|
- nodeNum++;
|
|
|
|
|
|
+ if (node.getCategory().equals(singleNode.getCategory())) {
|
|
|
|
+ if(node.getWeight()!=null){
|
|
|
|
+ weightNum+=node.getWeight();
|
|
|
|
+ }else{
|
|
|
|
+ weightNum++;//同类型的node节点默认权重为1
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- BigDecimal bg = new BigDecimal(100.00 / nodeNum).setScale(10, RoundingMode.HALF_UP);
|
|
|
|
|
|
+ BigDecimal bg = new BigDecimal((100.00*thisNodeWeight)/weightNum).setScale(10, RoundingMode
|
|
|
|
+ .HALF_UP);
|
|
|
|
|
|
- double singleNodeWeight = bg.doubleValue(); //同类型的node节点默认权重相等
|
|
|
|
|
|
+ double singleNodeWeight = bg.doubleValue();
|
|
|
|
|
|
for (Node node : basicNode.getNodes()) {
|
|
for (Node node : basicNode.getNodes()) {
|
|
- if (node.getName().equals(nodeName)) {
|
|
|
|
|
|
+ if (node.getName().equals(singleNode.getName())) {
|
|
String description = node.getDescription();
|
|
String description = node.getDescription();
|
|
if ((!(description == null)) && (description.contains("\"weight\":"))) {//描述中含有权重字段,暂时这样存放单个node的权重
|
|
if ((!(description == null)) && (description.contains("\"weight\":"))) {//描述中含有权重字段,暂时这样存放单个node的权重
|
|
NodeExtends nodeExtension = JSONUtil.json2Obj(description, NodeExtends.class);
|
|
NodeExtends nodeExtension = JSONUtil.json2Obj(description, NodeExtends.class);
|