cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package cn.ksource.web.service.impl;
 
import java.util.List;
import java.util.Map;
 
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import cn.ksource.core.config.CacheKeyUtil;
import cn.ksource.core.dao.BaseDao;
import cn.ksource.core.dao.SqlParameter;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.web.service.DataDictionaryService;
 
@Service("dataDictionaryService")
public class DataDictionaryServiceImpl implements DataDictionaryService {
 
    private static Logger logger = Logger.getLogger(DataDictionaryServiceImpl.class);
    
    @Autowired
    private BaseDao baseDao;
 
    @Override
    public Map getAreaById(String areaid) {
        if (StringUtils.isBlank(areaid)) {
            return null;
        }
        Object object = null;
        if (object == null) {
            String sql = "select * from config_data_dictionary_area where id=:areaid";
            object = baseDao.queryForMap(sql,new SqlParameter("areaid",areaid));
            if (object != null) {
                return (Map)object;
            } else {
                return null;
            }
        }
        return (Map)object;
    }
 
    @Override
    public List<Map> getAreaListByParentID(String parentid) {
        String myPid = null;
        if (StringUtils.isBlank(parentid)) {
            myPid = "0";
        } else {
            myPid = parentid;
        }
        Object object = null;
        if (object == null) {
            String sql = "select ID,ADDRESS_NAME from config_data_dictionary_area where ADDRESS_STATUS=1  ";
            if (StringUtils.isBlank(myPid) || myPid.equalsIgnoreCase("0")) {
                sql += " and  UP_ID is null";
            } else {
                sql += " and  UP_ID=:parentid";
            }
            sql += " order by ADDRESS_SN ";
            List<Map> list  = baseDao.queryForList(sql,new SqlParameter("parentid",myPid));
            if (list != null && !list.isEmpty()) {
                return list;
            } else {
                return null;
            }
        }
        return (List<Map>)object;
    }
 
    @Override
    public List<Map> getDataDictionaryByCategoryKey(String categoryKey) {
        if (StringUtils.isBlank(categoryKey)) {
            return null;
        }
        Object object = null;
        if (object == null) {
            String sql = "SELECT * FROM CONFIG_DATA_DICTIONARY " +
                    "WHERE CATEGORYID=(SELECT ID FROM CONFIG_DATA_DICTIONARY_CATEGORY WHERE CATEGORYKEY=:CATEGORYKEY) AND USESTATE=1 ORDER BY ORDERNUM ";
            List<Map> list  = baseDao.queryForList(sql,new SqlParameter("CATEGORYKEY",categoryKey));
            if (list != null && !list.isEmpty()) {
                return list;
            } else {
                return null;
            }
        }
        return (List<Map>)object;
    }
 
    @Override
    public Map getDataDictionaryByKey(String dicKey) {
        if (StringUtils.isBlank(dicKey)) {
            return null;
        }
        if (StringUtils.isBlank(dicKey)) {
            return null;
        }
        Object object = null;
        if (object == null) {
            String sql = "select * from CONFIG_DATA_DICTIONARY where DATAKEY=:DATAKEY";
            object = baseDao.queryForMap(sql,new SqlParameter("DATAKEY",dicKey));
            if (object != null) {
                return (Map)object;
            } else {
                return null;
            }
        }
        return (Map)object;
    }
 
    @Override
    public String getInterfaceUrlByKey(String interfaceKey) {
        if (StringUtils.isBlank(interfaceKey)) {
            return null;
        }
        Object object = null;
        String result = null;
        if (object == null) {
            String sql = 
            "select CONFIG_DATA_SUBSYSTEM.SYSTEMKEY, CONFIG_DATA_INTERFACE.INTERFACEURL \n" +
            "from CONFIG_DATA_INTERFACE,CONFIG_DATA_SUBSYSTEM \n" +
            "WHERE CONFIG_DATA_INTERFACE.SYSTEMID = CONFIG_DATA_SUBSYSTEM.ID\n" +
            "AND CONFIG_DATA_INTERFACE.INTERFACEKEY = :INTERFACEKEY";
            Map map = baseDao.queryForMap(sql,new SqlParameter("INTERFACEKEY",interfaceKey));
            object = map.get("INTERFACEURL");
            if (object != null) {
                result =  getSubSystemUrl(ConvertUtil.obj2Str(map.get("SYSTEMKEY"))) +  object.toString();
                return result;
            } else {
                return null;
            }
        }
        return object.toString();
    }
 
    @Override
    public String getInterfaceUrlByMessageKey(String messageKey) {
        if (StringUtils.isBlank(messageKey)) {
            return null;
        }
        Object object = null;
        if (object == null) {
            String sql = "select INTERFACEKEY from CONFIG_DATA_MESSAGE where MESSAGE_KEY=:MESSAGE_KEY";
            object = baseDao.queryForString(sql,new SqlParameter("MESSAGE_KEY",messageKey));
            if (object != null) {
                return getInterfaceUrlByKey(object.toString());
            } else {
                return null;     
            }
        } else {
            return getInterfaceUrlByKey(object.toString());
        }
        
    }
 
    @Override
    public String getSubSystemUrl(String systemKey) {
        if (StringUtils.isBlank(systemKey)) {
            return null;
        }
        Object object = null;
        if (object == null) {
            String sql = "select URL from CONFIG_DATA_SUBSYSTEM where SYSTEMKEY=:SYSTEMKEY";
            object = baseDao.queryForString(sql,new SqlParameter("SYSTEMKEY",systemKey));
            if (object != null) {
                return object.toString();
            } else {
                return null;
            }
        }
        return object.toString();
    }
 
    @Override
    public void updateAreaById(String areaid) {
        if (StringUtils.isBlank(areaid)) {
            return;
        }
        String sql = "select UP_ID from config_data_dictionary_area where ID=:ID";
        String parentid = baseDao.queryForString(sql,new SqlParameter("ID",areaid));
        updateAreaListByParentID(parentid);
    }
 
    @Override
    public void updateAreaListByParentID(String parentid) {
        if (StringUtils.isBlank(parentid)) {
            parentid="0";
        }
        logger.info("update area list cache :" + parentid );
    }
    
    
    
 
    @Override
    public void updateDataDictionaryByCategoryKey(String categoryKey) {
        if (StringUtils.isBlank(categoryKey)) {
            return;
        }
    }
 
    @Override
    public void updateDataDictionaryByKey(String dicKey) {
        if (StringUtils.isBlank(dicKey)) {
            return;
        }
        String sql = "select CATEGORYKEY from CONFIG_DATA_DICTIONARY_CATEGORY where " +
                "id=(select CATEGORYID from CONFIG_DATA_DICTIONARY where DATAKEY=:DATAKEY)";
        String key = baseDao.queryForString(sql,new SqlParameter("DATAKEY",dicKey));
        updateDataDictionaryByCategoryKey(key);
    }
 
    @Override
    public void updateInterfaceUrlByKey(String interfaceKey) {
        if (StringUtils.isBlank(interfaceKey)) {
            return;
        }
    }
 
    @Override
    public void updateInterfaceUrlByMessageKey(String messageKey) {  
        if (StringUtils.isBlank(messageKey)) {
            return;
        }
    }
 
    @Override
    public void updateSubSystemUrl(String systemKey) {
        if (StringUtils.isBlank(systemKey)) {
            return;
        }
        String sql =
            "select  CONFIG_DATA_INTERFACE.INTERFACEKEY \n" +
            "from CONFIG_DATA_INTERFACE,CONFIG_DATA_SUBSYSTEM \n" +
            "WHERE CONFIG_DATA_INTERFACE.SYSTEMID = CONFIG_DATA_SUBSYSTEM.ID\n" +
            "AND CONFIG_DATA_SUBSYSTEM.SYSTEMKEY = :systemKey";
        List<Map> list = baseDao.queryForList(sql,new SqlParameter("systemKey",systemKey));
        for (Map map : list) {
            updateInterfaceUrlByKey(map.get("INTERFACEKEY").toString());
        }
    }
 
}