通过bat文件快捷创建json文件

创建一个扩展名为bat的dos文件。内容如下,根据自己的需要把:newJson……goto :eof内容进行调整

其中%1,%2表示顺序参数值。

 

@echo on
SETLOCAL ENABLEDELAYEDEXPANSION
echo !
echo *******************************************

call :newJson 文名1,来源表1,目标表1,条件1
call :newJson 文名2,来源表2,目标表2,条件2
call :newJson 文名3,来源表3,目标表3,条件3

echo 顺利完成,
echo ===========================================
echo ===========================================
echo on
exit

:newJson

echo    {    >%1.txt
echo      "job": {    >>%1.txt
echo        "content": [    >>%1.txt
echo          {    >>%1.txt
echo            "reader": {    >>%1.txt
echo              "name": "oraclereader",    >>%1.txt
echo              "parameter": {    >>%1.txt
echo                "column": [    >>%1.txt
echo                  "*"    >>%1.txt
echo                ],    >>%1.txt
echo                "connection": [    >>%1.txt
echo                  {    >>%1.txt
echo                    "jdbcUrl": [    >>%1.txt
echo                      "jdbc:oracle:thin:@X.X.X.X:1521:oragbk"    >>%1.txt
echo                    ],    >>%1.txt
echo                    "table": [    >>%1.txt
echo                      "%2"    >>%1.txt
echo                    ]    >>%1.txt
echo                  }    >>%1.txt
echo                ],    >>%1.txt
echo                "password": "datax_readerSN",    >>%1.txt
echo                "username": "datax_reader",    >>%1.txt
echo                "where": "%4"    >>%1.txt
echo              }    >>%1.txt
echo            },    >>%1.txt
echo            "writer": {    >>%1.txt
echo              "name": "oraclewriter",    >>%1.txt
echo              "parameter": {    >>%1.txt
echo                "column": [    >>%1.txt
echo                  "*"    >>%1.txt
echo                ],    >>%1.txt
echo                "connection": [    >>%1.txt
echo                  {    >>%1.txt
echo                    "jdbcUrl": "jdbc:oracle:thin:@X.X.X.X:1521:oragbk",    >>%1.txt
echo                    "table": [    >>%1.txt
echo                      "%3"    >>%1.txt
echo                    ]    >>%1.txt
echo                  }    >>%1.txt
echo                ],    >>%1.txt
echo                "password": "DB042SN",    >>%1.txt
echo                "username": "DB0428",    >>%1.txt
echo                "preSql": [    >>%1.txt
echo                  "truncate table %3"    >>%1.txt
echo                ]    >>%1.txt
echo              }    >>%1.txt
echo            }    >>%1.txt
echo          }    >>%1.txt
echo        ],    >>%1.txt
echo        "setting": {    >>%1.txt
echo          "speed": {    >>%1.txt
echo            "channel": 6    >>%1.txt
echo          }    >>%1.txt
echo        }    >>%1.txt
echo      }    >>%1.txt
echo    }    >>%1.txt

 

goto :eof

posted @ 2021-06-23 16:36  山䂥进城  阅读(909)  评论(0)    收藏  举报