/**
* 根据树的根节点
递归获取所有叶子节点
*
* @param pid
* @return
*/
public static void getleafGenericvalue(Delegator delegator, String pid) {
List<GenericValue> partys;
GenericValue party;
try {
partys = delegator.findByAnd("PartyGroup", UtilMisc.toMap("parentId", pid));
party = delegator.findByPrimaryKey("PartyGroup", UtilMisc.toMap("partyId", pid));
if (partys.size()<=0) {
map2.put(pid, party);
}
if (partys.size()>0) {
map.put(pid, party);
}
if (map.size() != 0) {
getGv(delegator);
}
} catch (GenericEntityException e) {
ServiceUtil.returnError(e.getMessage());
}
}
public static void getGv(Delegator delegator) {
List<GenericValue> partys;
GenericValue party;
List l = new ArrayList();
try {
for (Map.Entry<String, GenericValue> entry : map.entrySet()) {
partys = delegator.findByAnd("PartyGroup", UtilMisc.toMap("parentId", entry.getKey()));//找子级中没有结算权限的商户,直到叶子
party = delegator.findByPrimaryKey("PartyGroup", UtilMisc.toMap("partyId", entry.getKey()));
if (partys.size()<=0 && !"Y".equals(party.getString("isSettlement"))) {
map2.put(entry.getKey(), party);
}
if (partys.size()>0) {
map.put(entry.getKey(), party);
for(GenericValue pt : partys){
if(!"Y".equals(pt.getString("isSettlement"))){
map.put(pt.getString("partyId").toString(), delegator.findByPrimaryKey("PartyGroup", UtilMisc.toMap("partyId", pt.getString("partyId").toString())));
}
}
}
l.add(entry.getKey());
}
if (l.size() != 0) {
for (int p = 0; p < l.size(); p++) {
map.remove(l.get(p));
}
}
if (map.size() != 0) {
getGv(delegator);
}
} catch (GenericEntityException e) {
ServiceUtil.returnError(e.getMessage());
}
}