路泰机电科技体检——数据平台后端
zhaowenxuan
2025-02-21 aa93e512a60379c6373d10023f49dae4403b51c4
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
package com.example.factory;
 
import com.example.config.ConfigValue;
import com.example.service.HisService;
import com.example.service.LisService;
import com.example.service.PacsService;
import org.apache.ibatis.annotations.Case;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zhaowenxuan
 * @Date: 2024/12/18 09:32
 */
@Component
public class ServiceFactory {
    private final ApplicationContext applicationContext;
 
    @Autowired
    public ServiceFactory(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }
 
    public HisService getService(String hospName) {
        String beanName = getServiceBeanName(hospName);
        return (HisService) applicationContext.getBean(beanName);
    }
 
    public PacsService getPacsService(String hospName) {
        String beanName = getServiceBeanName(hospName);
        return (PacsService) applicationContext.getBean(beanName+"Pacs");
    }
 
    public LisService getLisService(String hospName) {
        String beanName = getServiceBeanName(hospName);
        return (LisService) applicationContext.getBean(beanName+"Lis");
    }
 
 
    private String getServiceBeanName(String hospName) {
        switch (hospName) {
            case "shanxiqinxamjyy":
                return "ShanXiQinXiAnMeiJi"; // 对应的业务 Bean 名称
            case "shanxiqinpbkwyy":
                return "ShanXiQinPbkwyy";
            case "shanxiqinjdczgzyy":
                return "ShanXiQinJdczgzyy";
            default:
                throw new RuntimeException("找不到对应的医院服务配置:" + hospName);
        }
    }
}