package com.diagbot.facade;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.entity.QcModelHospital;
import com.diagbot.enums.IsDeleteEnum;
import com.diagbot.service.impl.QcModelHospitalServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description:
 * @author: zhoutg
 * @time: 2020/4/12 11:39
 */
@Component
public class QcModelHospitalFacade extends QcModelHospitalServiceImpl {

    /**
     * 获取医院对应的模块信息
     */
    @Cacheable(value = "cache", key = "'qcHosModel'")
    public Map<String, QcModelHospital> getHospitalModel() {
        Map<String, QcModelHospital> hospitalModelMap = new LinkedHashMap<>();
        List<QcModelHospital> basHospitalInfoList = this.list(new QueryWrapper<QcModelHospital>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .isNotNull("stand_model_id")
                .isNotNull("stand_model_name")
        );
        hospitalModelMap = basHospitalInfoList.stream()
                .collect(Collectors.toMap(r -> r.getHospitalId() + "##" + r.getHospitalModelName(), r -> r));
        return hospitalModelMap;
    }

}
