cy
2022-06-27 150ced737ad5d16d476df143c7e4238fc6b8b998
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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));
    }
    
}