scada服务数据源

highway
zhaoxiaolin 1 year ago
parent 77742e3c2f
commit 9b58911bfa

@ -1,74 +0,0 @@
package com.op.scada.config;
import com.sap.conn.jco.ext.DestinationDataProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Properties;
@Configuration
public class DestinationManager {
@Value("${sap.ashost}")
private String ashost;
@Value("${sap.sysnr}")
private String sysnr;
@Value("${sap.client}")
private String client;
@Value("${sap.user}")
private String user;
@Value("${sap.passwd}")
private String passwd;
@Value("${sap.lang}")
private String lang;
@Value("${sap.pool_capacity}")
private String pool_capacity;
@Value("${sap.peak_limit}")
private String peak_limit;
@Value("${sap.saprouter}")
private String saprouter;
private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
@Bean
public void CreateABAP(){
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, ashost);
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, sysnr);
connectProperties.setProperty(DestinationDataProvider.JCO_USER, user);
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, passwd);
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, client);
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, lang);
connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,peak_limit);
connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY,pool_capacity);
connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER,saprouter);
createDataFile(ABAP_AS_POOLED,"jcoDestination",connectProperties);
}
private static void createDataFile(String name, String suffix, Properties properties) {
// TODO Auto-generated method stub
File cfg = new File(name + "." + suffix);
if (cfg.exists()) {
cfg.deleteOnExit();
}
try {
FileOutputStream fos = new FileOutputStream(cfg,false);
properties.store(fos, "for test only!");
} catch (Exception e) {
// TODO: handle exception
// System.out.println("Create Data file fault,error msg:" + e.toString());
throw new RuntimeException("无法创建目标文件" + cfg.getName());
}
}
}
Loading…
Cancel
Save