package com.brilliance.isc.doc.configload; import com.brilliance.mda.runtime.mda.config.IniConfig; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import java.util.Properties; /** * 配置加载 * */ @Configuration public class CustomPropertiesFonfig { private final Logger logger = LoggerFactory.getLogger(CustomPropertiesFonfig.class); @Bean public Properties xmlDocProperties() { YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); yamlPropertiesFactoryBean.setResources(new ClassPathResource("cfg/xmldoc.yml")); return yamlPropertiesFactoryBean.getObject(); } @Bean public Properties xmlDocPropertiesForFmt() { YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); yamlPropertiesFactoryBean.setResources(new ClassPathResource("cfg/xmldocfmt.yml")); return yamlPropertiesFactoryBean.getObject(); } //e结算报文配置 @Bean public IniConfig erxIni() { try { Resource resource = new ClassPathResource("cfg/ersovr.ini"); return IniConfig.loadIniFile("ersovr.ini", resource.getInputStream(), "utf-8"); } catch (Exception e) { logger.error("加载e结算报文静态配置[ersovr.ini]异常", e); //弄个空的配置,避免影响其他程序 return new IniConfig(); } } //e结算部分TAG对应值得映射配置 @Bean public IniConfig erxValIni() { try { Resource resource = new ClassPathResource("cfg/ersovr-val.ini"); return IniConfig.loadIniFile("ersovr-val.ini", resource.getInputStream(), "utf-8"); } catch (Exception e) { logger.error("加载e结算报文值静态配置[ersovr-val.ini]异常", e); //弄个空的配置,避免影响其他程序 return new IniConfig(); } } //四类来报TAG的映射配置 @Bean public IniConfig rcvIni() { try { Resource resource = new ClassPathResource("cfg/rcvdoc.ini"); return IniConfig.loadIniFile("rcvdoc.ini", resource.getInputStream(), "utf-8"); } catch (Exception e) { logger.error("加载来报通用静态配置[rcvdoc.ini]异常", e); //弄个空的配置,避免影响其他程序 return new IniConfig(); } } //ELCS报文TAG的映射配置 @Bean public IniConfig elcIni() { try { Resource resource = new ClassPathResource("cfg/elcdoc.ini"); return IniConfig.loadIniFile("elcdoc.ini", resource.getInputStream(), "utf-8"); } catch (Exception e) { logger.error("加载电证报文静态配置[elcdoc.ini]异常", e); //弄个空的配置,避免影响其他程序 return new IniConfig(); } } //加载老国结电证报文优先级最高静态配置 @Bean public IniConfig elcTagAdvIni() { try { Resource resource = new ClassPathResource("cfg/elcovr.ini"); return IniConfig.loadIniFile("elcovr.ini", resource.getInputStream(), "utf-8"); } catch (Exception e) { logger.error("加载老国结电证报文优先级最高静态配置[elcovr.ini]异常", e); //弄个空的配置,避免影响其他程序 return new IniConfig(); } } //四类来报TAG的映射配置 @Bean public IniConfig elcComIni() { try { Resource resource = new ClassPathResource("cfg/elcsup.ini"); return IniConfig.loadIniFile("elcsup.ini", resource.getInputStream(), "utf-8"); } catch (Exception e) { logger.error("加载老国结电证报文通用静态配置[elcsup.ini]异常", e); //弄个空的配置,避免影响其他程序 return new IniConfig(); } } }