| | |
| | | import com.ltkj.web.wxUtils.HttpClientUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Slf4j |
| | | @Component |
| | | public class HisApiGetMethodService { |
| | | |
| | | |
| | | // 数据库配置文件路径 |
| | | private static final String CONFIG_PATH = "D:\\ltkjprojectconf\\config.properties"; |
| | | // private static final String CONFIG_PATH = url; |
| | | // private static final String CONFIG_PATH = "/Users/chacca/开发相关/代码/ltkj_peis/ltkj-admin/src/main/resources/config.properties"; |
| | | // 数据库名 |
| | | private static String DB_NAME = ""; |
| | |
| | | @Autowired |
| | | private HisApiConfigService hisApiConfigService; |
| | | |
| | | private static String url; |
| | | |
| | | |
| | | @Value ("${config.properties}") |
| | | public void set(String urls){ |
| | | url=urls; |
| | | FileInputStream inputStream = null; |
| | | try { |
| | | inputStream = new FileInputStream(url); |
| | | Properties props = new Properties(); |
| | | props.load(inputStream); |
| | | DB_NAME = props.getProperty("name"); |
| | | DATA_URL = "jdbc:mysql://" + props.getProperty("ip") + ":" + props.getProperty("prot") + "/" + DB_NAME + "" + |
| | | "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8"; |
| | | DATA_USER = props.getProperty("username"); |
| | | DATA_PASS = props.getProperty("password"); |
| | | String apiUrl = props.getProperty("his_api_url"); |
| | | String apiPort = props.getProperty("his_api_port"); |
| | | HIS_URL = apiUrl+":"+apiPort+"/api/His/HisRequest"; |
| | | } catch (IOException e) { |
| | | System.out.println("初始化数据库异常 ->"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | static { |
| | | try { |
| | | Class.forName("com.mysql.cj.jdbc.Driver"); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | InputStreamReader reader = new InputStreamReader(new FileInputStream(CONFIG_PATH), StandardCharsets.UTF_8); |
| | | Properties props = new Properties(); |
| | | props.load(reader); |
| | | String api_url = props.getProperty("his_api_url"); |
| | | String port = props.getProperty("his_api_port"); |
| | | DB_NAME = props.getProperty("name"); |
| | | DATA_URL = "jdbc:mysql://" + props.getProperty("ip") + ":" + props.getProperty("prot") + "/" + DB_NAME + |
| | | "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8"; |
| | | DATA_USER = props.getProperty("username"); |
| | | DATA_PASS = props.getProperty("password"); |
| | | HIS_URL=api_url+":"+port; |
| | | } catch (IOException throwables) { |
| | | throwables.printStackTrace(); |
| | | } |
| | | // try { |
| | | // InputStreamReader reader = new InputStreamReader(new FileInputStream(url), StandardCharsets.UTF_8); |
| | | // Properties props = new Properties(); |
| | | // props.load(reader); |
| | | // String api_url = props.getProperty("his_api_url"); |
| | | // String port = props.getProperty("his_api_port"); |
| | | // DB_NAME = props.getProperty("name"); |
| | | // DATA_URL = "jdbc:mysql://" + props.getProperty("ip") + ":" + props.getProperty("prot") + "/" + DB_NAME + |
| | | // "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8"; |
| | | // DATA_USER = props.getProperty("username"); |
| | | // DATA_PASS = props.getProperty("password"); |
| | | // HIS_URL=api_url+":"+port; |
| | | // } catch (IOException throwables) { |
| | | // throwables.printStackTrace(); |
| | | // } |
| | | } |
| | | |
| | | |