use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionService method getProvince.
public String getProvince(String provinceCode) {
StringBuilder sBuilder = new StringBuilder();
// 获得省份信息
SysRegion region = getRegionByCode(provinceCode);
if (region != null)
sBuilder.append(region.getNameCn());
return sBuilder.toString();
}
use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionService method getAllName.
/**
* 根据省份、地市、区县代码获取名称信息
* @param provinceCode
* @param cityCode
* @param countyCode
* @return
*/
public String getAllName(String provinceCode, String cityCode, String countyCode) {
StringBuilder sBuilder = new StringBuilder();
// 暂时不需要国家信息,不处理countryCode
// 获得省份信息
SysRegion region = getRegionByCode(provinceCode);
if (region != null)
sBuilder.append(region.getNameCn() + "-");
// 获得地市信息
region = getRegionByCode(cityCode);
if (region != null)
sBuilder.append(region.getNameCn() + "-");
// 获得区县信息
region = getRegionByCode(countyCode);
if (region != null)
sBuilder.append(region.getNameCn() + "-");
return sBuilder.toString();
}
use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionService method getRegionsByCode.
/**
* 根据行政区代码,获取行政区子级信息
* @param code
* @param type
* @return
* @throws ServiceNullException
*/
public List<Region4t> getRegionsByCode(String code, Integer type) throws ServiceNullException {
List<Region4t> region4tList = new ArrayList<Region4t>();
SysRegion sysRegion = getRegionByCode(code);
// 指定代码不存在
if (sysRegion == null) {
throw new ServiceNullException("未知的行政区代码【" + code + "】");
}
// 查询指定代码的下层节点
SysRegionExample sysRegionExample = new SysRegionExample();
SysRegionExample.Criteria srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdEqualTo(sysRegion.getId());
srCriteria.andTypeEqualTo(sysRegion.getType() + 1);
sysRegionExample.setOrderByClause("code asc");
Map<Long, SysRegion> childSR = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectByExample", sysRegionExample, "id");
// 判断下级节点是否有子节点
sysRegionExample.clear();
sysRegionExample.setOrderByClause(null);
srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdIn(new ArrayList<Long>(childSR.keySet()));
Map<Long, Object> childNumMap = new HashMap<Long, Object>();
if (!childSR.isEmpty())
childNumMap = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectChildNumByExample", sysRegionExample, "parentId");
Iterator iter = childSR.entrySet().iterator();
while (iter.hasNext()) {
SysRegion sr = (SysRegion) ((Map.Entry) iter.next()).getValue();
region4tList.add(new Region4t(sr.getNameCn(), sr.getCode(), sr.getType(), childNumMap.containsKey(sr.getId()) ? 1 : 0));
}
return region4tList;
}
Aggregations