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());
|
}
|
}
|
}
|