jiazx0107@163.com
2023-12-07 ae084b7ab31c38588928afb770cec1320c8c27f0
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
package com.fzzy.api.service;
 
 
import com.bstek.dorado.annotation.Expose;
import com.fzzy.api.entity.GbCheckItem;
import com.fzzy.api.view.repository.GbCheckItemRep;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * 公共接口服务-检验项目表
 */
@Component
public class GbCheckItemService {
 
 
    /**
     * 用于存放字典与对接系统的编码映射
     */
    public static Map<String, String> contextMap = new HashMap<>();
 
 
    @Autowired
    private GbCheckItemRep gbCheckItemRep;
 
 
    /**
     * gbCheckItemService#flushCache
     * 刷新缓存
     */
    @Expose
    public void flushCache() {
 
        List<GbCheckItem> list = gbCheckItemRep.findAll();
        if (null == list || list.isEmpty()){
            return;
        }
 
        list.stream()
                .filter(c -> StringUtils.isNotEmpty(c.getBizCode()) && !c.getBizCode().equals("0"))
                .collect(Collectors.toList());
        for (GbCheckItem item : list) {
            add2Cache(item);
        }
 
    }
 
    private void add2Cache(GbCheckItem item) {
 
        //添加映射
        if(StringUtils.isNotEmpty(item.getCode())){
            contextMap.put(item.getBizCode(), item.getCode());
        }
    }
}