DictionaryEntriesService.java
2.07 KB
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
package com.erry.iclear.dateInterface.service;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.DictionaryEntries;
import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
/**
* @author Administrator
*/
@Service
@Slf4j
public class DictionaryEntriesService {
@Autowired
private DictionaryEntriesRepository dictionaryEntriesRepository;
public List<DictionaryEntries> getAllDictionaryEntries(){
List<DictionaryEntries> result = new ArrayList<DictionaryEntries>();
try {
result=dictionaryEntriesRepository.findAllDictionaryEntries();
}catch (Exception e){
log.error(e.getMessage(),e);
}
return result;
}
/**
* 初始化字典表
*/
public void initDictionaryEntries() {
try {
Constant.dictionaryEntriesCache.clear();
List<DictionaryEntries> dictionaryEntriesList = this.getAllDictionaryEntries();
for (DictionaryEntries dictionaryEntries : dictionaryEntriesList) {
//成交方式
if(Objects.equals(dictionaryEntries.getDictCode(),"ClinchType")){
Constant.dictionaryEntriesCache.put(Constant.CLINCH_TYPE+dictionaryEntries.getExt6(),dictionaryEntries);
}
//国家
else if(Objects.equals(dictionaryEntries.getDictCode(),"Country")){
Constant.dictionaryEntriesCache.put(Constant.COUNTRY+dictionaryEntries.getExt3(),dictionaryEntries);
}
else{
Constant.dictionaryEntriesCache.put(dictionaryEntries.getCode(),dictionaryEntries);
}
}
} catch (Exception e) {
log.error("initDictionaryEntries() error" + e.getMessage());
}
}
}