import scala.io.StdIn
import java.time.format.DateTimeFormatter
import java.time.LocalDate._
import java.io.PrintWriter
import java.time.LocalDate
object TestBasic {
def main(args: Array[String]): Unit = {
//输入作业名(不含后缀)
val jobName = args(0)
//指定日期格式
val pattern = DateTimeFormatter.ofPattern("yyyyMMdd")
//获取开始日期
var startDt = LocalDate.parse(StdIn.readLine("开始日期(YYYYMMDD):"), pattern)
//获取结束日期
val endDt = LocalDate.parse(StdIn.readLine("结束日期(YYYYMMDD):"), pattern)
//打开文件(写入)
val writer = new PrintWriter(jobName+".bat")
while (startDt.isBefore(endDt)) {
//写入内容
writer.write("dsql -c logon.env -f " + jobName + ".dsql TX_DATE=" + startDt.format(pattern) + ">" + jobName + "_" + startDt.format(pattern) + ".sql\n")
startDt = startDt.plusDays(1)
writer.write("\n")
}
//关闭文件
writer.close()
//结束
println("work is done!")
}
}