@Override
public List<Bidsection<Workarea<Pname<Name>>>> getComponentInfo() {
// 1级节点树
List<Bidsection<Workarea<Pname<Name>>>> resultData = new ArrayList<>();
long start = System.currentTimeMillis();
// 查询1级节点
List<Bidsection> bidsectionList = progressDao.queryBidsection();
for (int i = 0; i < bidsectionList.size(); i++) {
// 1级节点实体
Bidsection<Workarea<Pname<Name>>> bidsection = new Bidsection<>();
// 2级节点树
List<Workarea<Pname<Name>>> workareaData = new ArrayList<>();
// 查询2级节点
List<Workarea> workareaList = progressDao.queryWorkarea(bidsectionList.get(i).getTitle());
for (int j = 0; j < workareaList.size(); j++) {
// 2级节点实体
Workarea<Pname<Name>> workarea = new Workarea<>();
// 3级节点树
List<Pname<Name>> pnameData = new ArrayList<>();
// 查询3级节点
List<Pname> pnameList = progressDao.queryPname(workareaList.get(j).getTitle());
for (int k = 0; k < pnameList.size(); k++) {
// 3级节点实体
Pname<Name> pname = new Pname<>();
// 4级节点树
List<Name> nameData = new ArrayList<>();
// 查询4级节点
List<Name> nameList = progressDao.queryName(pnameList.get(k).getTitle());
for (int l = 0; l < nameList.size(); l++) {
// 4级节点实体
Name name = new Name();
name.setTitle(nameList.get(l).getTitle());
name.setModelId(nameList.get(l).getModelId());
nameData.add(name);
}
// 添加3级标题
pname.setTitle(pnameList.get(k).getTitle());
// 添加3级内容
pname.setChildren(nameList);
// 生成3级树
pnameData.add(pname);
}
// 添加2级标题
workarea.setTitle(workareaList.get(j).getTitle());
// 添加2级内容
workarea.setChildren(pnameData);
// 生成2级树
workareaData.add(workarea);
}
// 添加1级标题
bidsection.setTitle(bidsectionList.get(i).getTitle());
// 添加1级内容
bidsection.setChildren(workareaData);
// 生成1级树
resultData.add(bidsection);
}
long end = System.currentTimeMillis();
System.out.print("-------耗时-------" + (end - start) / 1000 + "秒-------");
return resultData;
}
循环查询数据处理数据,查询下来40多秒,哪位大神帮忙看下怎么优化实现比较快啊!!急急急!!!