<span style="padding-left:5px;">分公司:</span>
<input id="orgCodeName" class="easyui-combotree" style="width: 165px; height: 24px;" panelHeight="300px"
data-options="
url: '${pageContext.request.contextPath }/org/findCountyData',
method: 'get',
valueField: 'id',
textField: 'orgName',
onSelect: function(node){loadDep(node);}
" value="${platformUserInfo.orgId}"/>
/**
* 获取当前用户本级及下级组织机构(全国和省份两层)
* @param request
* @return
* @author yys
*/
@RequestMapping("/getTreeJsonData")
@ResponseBody
public String getOrgTreeJsonData(HttpServletRequest request){
PlatformUserInfo curUser = getUser(request);
String orgCode = curUser.getOrgCode();
Org org = orgService.findByOrgCode(orgCode);
List<Org> orgList = orgService.findDescendantOrgsData(orgCode, true);
orgList = sortData(Integer.parseInt(org.getLevel()), orgList);
return JSONObject.toJSONString(orgList);
}
//层级排序
private List<Org> sortData(int topLevel, List<Org> data){
long startTime = System.currentTimeMillis();
final int TOP_LEVEL = topLevel;
int start = 30;
List<Org> retList = new ArrayList<Org>();
List<Org> childs;
while(start>=TOP_LEVEL){
for(Org one:data){
if(start==Integer.parseInt(one.getLevel())){
for(Org two:data){
if(start<4){
System.out.println(Integer.parseInt(two.getLevel())+" : "+(start+1));
}
if(Integer.parseInt(two.getLevel())==(start+1)
&& two.getParentCode().equals(one.getOrgCode())){
childs = one.getChildren();
if(childs==null){
childs = new ArrayList<Org>();
}
childs.add(two);
one.setChildren(childs);
}
}
if(start==TOP_LEVEL){
retList.add(one);
}
}
}
start-- ;
}
long endTime = System.currentTimeMillis();
System.out.println(" ======》》组装数据共耗时:"+(endTime-startTime)+"ms");
return retList;
}