package cn.ksource.web.service.impl;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import org.apache.commons.lang.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import cn.ksource.core.dao.BaseDao;
|
import cn.ksource.core.dao.SqlParameter;
|
import cn.ksource.core.util.EqualUtil;
|
import cn.ksource.core.web.TreeNode;
|
import cn.ksource.web.service.AreaService;
|
|
@Service
|
public class AreaServiceImpl implements AreaService {
|
|
@Autowired
|
private BaseDao baseDao;
|
|
@Override
|
public TreeNode getAreaTreeNode(String pid) {
|
|
List<Map> list = getAreaList(pid);
|
TreeNode root = new TreeNode("1","区域树");
|
for (Map map : list) {
|
TreeNode node = new TreeNode(map.get("ID").toString(),map.get("ADDRESS_NAME").toString());
|
if (!EqualUtil.isStringEqual(map.get("LEVEL"),"3")) {
|
node.setIsOpen(false);
|
}
|
node.setAttributes(map);
|
|
/*if (values != null && value.length() > 0) {
|
for (String val : values) {
|
if (EqualUtil.isStringEqual(map.get("ID"), val)) {
|
node.getProperties().put("checked", true);
|
}
|
}
|
}*/
|
|
root.addChild(node);
|
}
|
return root;
|
}
|
|
public List<Map> getAreaList(String pid) {
|
String sql =
|
"SELECT * FROM config_data_dictionary_area \n" +
|
"WHERE ADDRESS_STATUS = 1 \n" ;
|
|
/*
|
String value = request.getParameter("values");
|
value = StringUtils.isBlank(value) ? "" : value;
|
String[] values = value.split(",");*/
|
|
String up_id = pid;
|
if (StringUtils.isNotBlank(up_id) && !StringUtils.equalsIgnoreCase(up_id, "1")) {
|
sql += " and UP_ID =:up_id \n";
|
} else {
|
sql += " and UP_ID is null \n";
|
}
|
sql += "ORDER BY LEVEL asc,address_sn asc";
|
List<Map> list = baseDao.queryForList(sql,new SqlParameter("up_id",up_id));
|
return list;
|
}
|
|
@Override
|
public Map getSalesAreaInfo(String countyId) {
|
String sql = "select * from crm_sales_area where COUNTY_ID=:county_id";
|
return baseDao.queryForMap(sql, new SqlParameter("county_id", countyId));
|
}
|
|
}
|