| | |
| | | |
| | | 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; |
| | |
| | | */ |
| | | @Component |
| | | public class ServiceFactory { |
| | | private final ConfigValue configValue; |
| | | private final ApplicationContext applicationContext; |
| | | private final String userId; |
| | | |
| | | @Autowired |
| | | public ServiceFactory(ApplicationContext applicationContext, ConfigValue configValue) { |
| | | public ServiceFactory(ApplicationContext applicationContext) { |
| | | this.applicationContext = applicationContext; |
| | | this.configValue = configValue; |
| | | try { |
| | | this.userId = configValue.getConfigValue("hosp_service"); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("配置文件中没有配置hosp_service医院编码"); |
| | | } |
| | | } |
| | | |
| | | public HisService getService() { |
| | | String beanName = getServiceBeanName(userId); |
| | | public HisService getService(String hospName) { |
| | | String beanName = getServiceBeanName(hospName); |
| | | return (HisService) applicationContext.getBean(beanName); |
| | | } |
| | | |
| | | private String getServiceBeanName(String userId) { |
| | | switch (userId) { |
| | | // 配置文件中值 |
| | | case "ShanXi_Qin_XiAn_MeiJi": |
| | | // 业务Bean的name |
| | | return "ShanXiQinXiAnMeiJi"; |
| | | 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"; |
| | | case "shanxiqinsqyy": |
| | | return "ShanXiQinXiAnShanQi"; |
| | | case "shanxiqinwbzxyy": |
| | | return "ShanXiQinWeiNanWbzxyy"; |
| | | case "shanxiqinbjxjyy": |
| | | return "ShanXiQinBaoJiBjxjyy"; |
| | | case "shanxiqinbjfhyy": |
| | | return "ShanXiQinBaoJiBjfhyy"; |
| | | case "shanxiqinbjsqyy": |
| | | return "ShanXiQinBaoJiBjsqyy"; |
| | | case "shanxiqinssyjyy": |
| | | return "ShanXiQinBaoJiSsyjyy"; |
| | | default: |
| | | throw new RuntimeException("找不到对应的医院编码服务层配置:" + userId); |
| | | throw new RuntimeException("找不到对应的医院服务配置:" + hospName); |
| | | } |
| | | } |
| | | } |