角色对应岗位去重
This commit is contained in:
parent
1fd2a85e0a
commit
2f98c1ff72
@ -4,7 +4,10 @@ import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.special
|
||||
import java.io.File;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.output.pr.util.PrReportComment;
|
||||
import com.actionsoft.apps.coe.pal.output.pr.util.ReportRepositoryCompare;
|
||||
@ -574,6 +577,10 @@ public class Report1Gener {
|
||||
}
|
||||
index++;
|
||||
}
|
||||
//角色信息去重
|
||||
roleMappingPostTable = jsonDeduplication(roleMappingPostTable);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 流程步骤的指标表格
|
||||
@ -1094,4 +1101,30 @@ public class Report1Gener {
|
||||
dataMap.put("FOOTERFONTSIZE",bo.getString("FOOTERFONTSIZE"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 去重
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
public JSONArray jsonDeduplication(JSONArray jsonArray){
|
||||
// 使用LinkedHashMap来保持插入顺序并去重
|
||||
Map<String, JSONObject> uniqueRolesMap = new LinkedHashMap<>();
|
||||
for (Object obj : jsonArray) {
|
||||
JSONObject jsonObject = (JSONObject) obj;
|
||||
String role = jsonObject.getString("roleMapping_role");
|
||||
// 如果Map中还没有这个角色,则添加进去
|
||||
if (!uniqueRolesMap.containsKey(role)) {
|
||||
uniqueRolesMap.put(role, jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果你想要一个JSONArray作为最终结果,你可以这样做:
|
||||
JSONArray uniqueJsonArray = new JSONArray();
|
||||
for (JSONObject jsonObject : uniqueRolesMap.values()) {
|
||||
uniqueJsonArray.add(jsonObject);
|
||||
}
|
||||
return uniqueJsonArray;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user