Commit cdffa583 by zhengxj

finish 优化代码逻辑 on 20191211 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@25524 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent c5fea700
......@@ -60,28 +60,29 @@ public class AreaServiceImpl implements IAreaService {
@Override
public SysArea getAllChargeItems(Integer id) {
SysArea prandPa = new SysArea();
try{
SysAreaExample example = new SysAreaExample();
example.createCriteria().andIdEqualTo(id);
List<SysArea> child = sysAreaMapper.selectByExample(example);
example.clear();
example.createCriteria().andIdEqualTo(child.get(0).getParentId());
List<SysArea> parent = sysAreaMapper.selectByExample(example);
if (!parent.isEmpty()) {
example.clear();
example.createCriteria().andIdEqualTo(parent.get(0).getParentId());
prandPa = sysAreaMapper.selectByExample(example).get(0);
if (prandPa != null) {
parent.get(0).setChildren(child);
prandPa.setChildren(parent);
}
}
} catch (Exception e) {
logger.error("获取日志异常" + e);
}
return prandPa;
}
SysAreaExample example = new SysAreaExample();
example.createCriteria().andIdEqualTo(id);
List<SysArea> child = sysAreaMapper.selectByExample(example);
if (child.isEmpty()) {
return new SysArea();
}
example.clear();
example.createCriteria().andIdEqualTo(child.get(0).getParentId());
List<SysArea> parent = sysAreaMapper.selectByExample(example);
if (parent.isEmpty()) {
return child.get(0);
}
parent.get(0).setChildren(child);
example.clear();
example.createCriteria().andIdEqualTo(parent.get(0).getParentId());
List<SysArea> grandPa = sysAreaMapper.selectByExample(example);
if (grandPa.isEmpty()) {
return parent.get(0);
}
grandPa.get(0).setChildren(parent);
return grandPa.get(0);
}
/*
* (non-Javadoc)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!