就是在填报报表里面添加java代码,代码的作用是调用bat,然后在服务器上把kettle的对应文件放上去,在本地搞好bat文件,配置服务器上的kettle环境,然后运行就可以了
java代码如下:
package com.fr.data;
import java.io.IOException;
import com.fr.script.Calculator;
import com.fr.data.DefinedSubmitJob;
public class CustomSubmitJob6 extends DefinedSubmitJob {
public void doJob(Calculator calculator) throws Exception {
//执行批处理文件
String strcmd="cmd /c start C:/ALLbat/Cxfenjie.bat";
Runtime rt = Runtime.getRuntime();
Process ps = null;
try {
ps = rt.exec(strcmd);
Thread.sleep(10000);
} catch (IOException e1) {
e1.printStackTrace();
}
try {
ps.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int i = ps.exitValue();
if (i == 0) {
System.out.println("执行完成.") ;
} else {
System.out.println("执行失败.") ;
}
ps.destroy();
ps = null;
killProcess();
}
public void killProcess(){
Runtime rt = Runtime.getRuntime();
Process p = null;
try {
rt.exec("cmd.exe /C start wmic process where name='cmd.exe' call terminate");
} catch (IOException e) {
e.printStackTrace();
}
}
}