You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
Java
38 lines
1.0 KiB
Java
package com.supervision.utils;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.supervision.police.dto.AtomicData;
|
|
import com.supervision.police.dto.JudgeLogic;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Slf4j
|
|
public class JudgeLogicUtil {
|
|
|
|
public static List<JudgeLogic> parse(String logic) {
|
|
return JSONUtil.toList(logic, JudgeLogic.class);
|
|
}
|
|
|
|
/**
|
|
* 从逻辑中获取原子指标id
|
|
*
|
|
* @param judgeLogic 判断逻辑json字符串
|
|
* @return 原子指标id(不重复)
|
|
*/
|
|
public static List<String> pickAtomicIndexIds(String judgeLogic) {
|
|
List<String> ids = new ArrayList<>();
|
|
List<JudgeLogic> logic = parse(judgeLogic);
|
|
for (JudgeLogic judge : logic) {
|
|
List<AtomicData> atomicData = judge.getAtomicData();
|
|
for (AtomicData atomic : atomicData) {
|
|
if (!ids.contains(atomic.getAtomicIndex())) {
|
|
ids.add(atomic.getAtomicIndex());
|
|
}
|
|
}
|
|
}
|
|
return ids;
|
|
}
|
|
}
|