mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-09-10 05:59:09 +00:00
version 1.6.7
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
### 1、功能描述
|
||||
|
||||
一句话,dbswitch工具提供源端数据库向目的端数据的迁移同步功能,支持数据的全量和增量方式同步。包括:
|
||||
一句话,dbswitch工具提供源端数据库向目的端数据库的**批量**迁移同步功能,支持数据的全量和增量方式同步。包括:
|
||||
|
||||
- **结构迁移**
|
||||
|
||||
@@ -214,7 +214,7 @@ dbswitch:
|
||||
|
||||
```
|
||||
jdbc连接地址:jdbc:mysql://172.17.2.10:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&tinyInt1isBit=false
|
||||
jdbc驱动名称: com.mysql.cj.jdbc.Driver
|
||||
jdbc驱动名称: com.mysql.jdbc.Driver
|
||||
```
|
||||
|
||||
与:
|
||||
@@ -444,7 +444,7 @@ bin/startup.sh
|
||||
|
||||
**缺点:**
|
||||
|
||||
> 当数据库内的表数量较大时,WEB方式卡顿严重;
|
||||
> 当数据库内的表或字段数量较大时,WEB方式卡顿严重;
|
||||
|
||||
> 多个任务并发执行不易于分析任务错误原因;
|
||||
|
||||
|
@@ -54,7 +54,9 @@
|
||||
</el-table>
|
||||
<div class="page"
|
||||
align="right">
|
||||
<el-pagination :current-page="currentPage"
|
||||
<el-pagination @size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="currentPage"
|
||||
:page-sizes="[5, 10, 20, 40]"
|
||||
:page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@@ -344,7 +346,6 @@ export default {
|
||||
} else {
|
||||
alert("加载任务列表失败:" + res.data.message);
|
||||
}
|
||||
this.totalCount = this.tableData.length;
|
||||
},
|
||||
function () {
|
||||
console.log("failed");
|
||||
@@ -500,6 +501,17 @@ export default {
|
||||
alert("请检查输入");
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSizeChange: function (pageSize) {
|
||||
this.loading = true;
|
||||
this.pageSize = pageSize;
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
handleCurrentChange: function (currentPage) {
|
||||
this.loading = true;
|
||||
this.currentPage = currentPage;
|
||||
this.loadData();
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
@@ -61,7 +61,9 @@
|
||||
</el-table>
|
||||
<div class="page"
|
||||
align="right">
|
||||
<el-pagination :current-page="currentPage"
|
||||
<el-pagination @size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="currentPage"
|
||||
:page-sizes="[5, 10, 20, 40]"
|
||||
:page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@@ -96,11 +98,8 @@ export default {
|
||||
this.totalCount = res.data.pagination.total;
|
||||
this.tableData = res.data.data;
|
||||
} else {
|
||||
if (res.data.message) {
|
||||
alert("加载任务列表失败:" + res.data.errmsg);
|
||||
alert("加载任务列表失败:" + res.data.message);
|
||||
}
|
||||
}
|
||||
this.totalCount = this.tableData.length;
|
||||
},
|
||||
function () {
|
||||
console.log("failed");
|
||||
@@ -205,6 +204,17 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSizeChange: function (pageSize) {
|
||||
this.loading = true;
|
||||
this.pageSize = pageSize;
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
handleCurrentChange: function (currentPage) {
|
||||
this.loading = true;
|
||||
this.currentPage = currentPage;
|
||||
this.loadData();
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.loadData();
|
||||
|
@@ -704,7 +704,11 @@ export default {
|
||||
}
|
||||
|
||||
if (this.updateform.includeOrExclude == "INCLUDE") {
|
||||
if (this.updateform.sourceTables && this.updateform.sourceTables.length > 0) {
|
||||
this.preiveSeeTableNameList = this.updateform.sourceTables;
|
||||
} else {
|
||||
this.preiveSeeTableNameList = this.sourceSchemaTables;
|
||||
}
|
||||
} else {
|
||||
if (this.updateform.sourceTables.length == 0) {
|
||||
alert("请选择排除表的【表名配置】!");
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-admin</artifactId>
|
||||
|
@@ -1 +1 @@
|
||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>异构数据迁移工具</title><link href=/static/css/app.e8bbc180c5f37cdd2ace1ddbfb97b9f8.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.b6ccbbd6dc0126e76b11.js></script><script type=text/javascript src=/static/js/vendor.d6c2f50c2f02bf33c8cf.js></script><script type=text/javascript src=/static/js/app.16126c7c1f0b72278ba8.js></script></body></html>
|
||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>异构数据迁移工具</title><link href=/static/css/app.5ecc6abf3a20668fd115c18e59dc362b.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.cbc4b16180a8bf2afd41.js></script><script type=text/javascript src=/static/js/vendor.d6c2f50c2f02bf33c8cf.js></script><script type=text/javascript src=/static/js/app.418d956a43293c6e0efb.js></script></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
webpackJsonp([10],{"0eSS":function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l={data:function(){return{loading:!0,lists:[],currentPage:1,pageSize:10,totalCount:0}},methods:{loadData:function(){var e=this;this.$http.get("/dbswitch/admin/api/v1/syslog/list/2/"+this.currentPage+"/"+this.pageSize).then(function(t){e.loading=!1,0===t.data.code?(e.currentPage=t.data.pagination.page,e.pageSize=t.data.pagination.size,e.totalCount=t.data.pagination.total,e.lists=t.data.data):alert("加载数据失败:"+t.data.message)},function(t){e.$message({showClose:!0,message:"数据加载错误",type:"error"})})},boolFormat:function(e,t){return!0===e.failed?"是":"否"},handleSizeChange:function(e){this.loading=!0,this.pageSize=e,this.loadData()},handleCurrentChange:function(e){this.loading=!0,this.currentPage=e,this.loadData()},handleDetail:function(e,t){this.$message({showClose:!0,message:"查看日志详情"+e+" "+t,type:"info"})}},created:function(){this.loadData()}},o={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticStyle:{"margin-top":"15px"}},[a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticStyle:{width:"100%"},attrs:{"element-loading-text":"拼命加载中","element-loading-spinner":"el-icon-loading","element-loading-background":"rgba(0, 0, 0, 0.8)",data:e.lists,stripe:"",size:"small",border:""}},[a("el-table-column",{attrs:{type:"expand"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-form",{staticClass:"demo-table-expand",attrs:{"label-position":"left",inline:""}},[a("el-form-item",{attrs:{label:"日志编号:"}},[a("span",[e._v(e._s(t.row.id))])]),e._v(" "),a("el-form-item",{attrs:{label:"日志时间:"}},[a("span",[e._v(e._s(t.row.createTime))])]),e._v(" "),a("el-form-item",{attrs:{label:"操作用户:"}},[a("span",[e._v(e._s(t.row.username))])]),e._v(" "),a("el-form-item",{attrs:{label:"请求IP地址:"}},[a("span",[e._v(e._s(t.row.ipAddress))])]),e._v(" "),a("el-form-item",{attrs:{label:"操作模块:"}},[a("span",[e._v(e._s(t.row.moduleName))])]),e._v(" "),a("el-form-item",{attrs:{label:"操作描述:"}},[a("span",[e._v(e._s(t.row.content))])]),e._v(" "),a("el-form-item",{attrs:{label:"处理耗时(ms):"}},[a("span",[e._v(e._s(t.row.elapseSeconds))])]),e._v(" "),a("el-form-item",{attrs:{label:"请求路径:"}},[a("span",[e._v(e._s(t.row.urlPath))])]),e._v(" "),a("el-form-item",{attrs:{label:"异常状态:"}},[a("span",[e._v(e._s(t.row.failed))])]),e._v(" "),a("el-form-item",{attrs:{label:""}},[a("span")]),e._v(" "),a("el-form-item",{attrs:{label:"异常日志:"}},[a("el-input",{staticStyle:{"font-size":"12px",width:"700px"},attrs:{type:"textarea",autosize:{minRows:2,maxRows:5}},model:{value:t.row.exception,callback:function(a){e.$set(t.row,"exception",a)},expression:"props.row.exception"}})],1)],1)]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"createTime",label:"日志时间","min-width":"15%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"username",label:"操作用户","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"ipAddress",label:"请求IP","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"moduleName",label:"操作类型","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"elapseSeconds",label:"耗时(ms)","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"urlPath",label:"请求路径","min-width":"20%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"failed",label:"异常",formatter:e.boolFormat,"min-width":"10%","show-overflow-tooltip":!0}})],1),e._v(" "),a("div",{staticClass:"page",attrs:{align:"right"}},[a("el-pagination",{attrs:{"current-page":e.currentPage,"page-sizes":[5,10,20,40],"page-size":e.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.totalCount},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}})],1)],1)},staticRenderFns:[]};var n=a("VU/8")(l,o,!1,function(e){a("sACR")},"data-v-5a0d71c9",null);t.default=n.exports},sACR:function(e,t){}});
|
||||
//# sourceMappingURL=10.ec3b8253b1c336df3447.js.map
|
||||
webpackJsonp([11],{"0eSS":function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l={data:function(){return{loading:!0,lists:[],currentPage:1,pageSize:10,totalCount:0}},methods:{loadData:function(){var e=this;this.$http.get("/dbswitch/admin/api/v1/syslog/list/2/"+this.currentPage+"/"+this.pageSize).then(function(t){e.loading=!1,0===t.data.code?(e.currentPage=t.data.pagination.page,e.pageSize=t.data.pagination.size,e.totalCount=t.data.pagination.total,e.lists=t.data.data):alert("加载数据失败:"+t.data.message)},function(t){e.$message({showClose:!0,message:"数据加载错误",type:"error"})})},boolFormat:function(e,t){return!0===e.failed?"是":"否"},handleSizeChange:function(e){this.loading=!0,this.pageSize=e,this.loadData()},handleCurrentChange:function(e){this.loading=!0,this.currentPage=e,this.loadData()},handleDetail:function(e,t){this.$message({showClose:!0,message:"查看日志详情"+e+" "+t,type:"info"})}},created:function(){this.loadData()}},o={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticStyle:{"margin-top":"15px"}},[a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticStyle:{width:"100%"},attrs:{"element-loading-text":"拼命加载中","element-loading-spinner":"el-icon-loading","element-loading-background":"rgba(0, 0, 0, 0.8)",data:e.lists,stripe:"",size:"small",border:""}},[a("el-table-column",{attrs:{type:"expand"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-form",{staticClass:"demo-table-expand",attrs:{"label-position":"left",inline:""}},[a("el-form-item",{attrs:{label:"日志编号:"}},[a("span",[e._v(e._s(t.row.id))])]),e._v(" "),a("el-form-item",{attrs:{label:"日志时间:"}},[a("span",[e._v(e._s(t.row.createTime))])]),e._v(" "),a("el-form-item",{attrs:{label:"操作用户:"}},[a("span",[e._v(e._s(t.row.username))])]),e._v(" "),a("el-form-item",{attrs:{label:"请求IP地址:"}},[a("span",[e._v(e._s(t.row.ipAddress))])]),e._v(" "),a("el-form-item",{attrs:{label:"操作模块:"}},[a("span",[e._v(e._s(t.row.moduleName))])]),e._v(" "),a("el-form-item",{attrs:{label:"操作描述:"}},[a("span",[e._v(e._s(t.row.content))])]),e._v(" "),a("el-form-item",{attrs:{label:"处理耗时(ms):"}},[a("span",[e._v(e._s(t.row.elapseSeconds))])]),e._v(" "),a("el-form-item",{attrs:{label:"请求路径:"}},[a("span",[e._v(e._s(t.row.urlPath))])]),e._v(" "),a("el-form-item",{attrs:{label:"异常状态:"}},[a("span",[e._v(e._s(t.row.failed))])]),e._v(" "),a("el-form-item",{attrs:{label:""}},[a("span")]),e._v(" "),a("el-form-item",{attrs:{label:"异常日志:"}},[a("el-input",{staticStyle:{"font-size":"12px",width:"700px"},attrs:{type:"textarea",autosize:{minRows:2,maxRows:5}},model:{value:t.row.exception,callback:function(a){e.$set(t.row,"exception",a)},expression:"props.row.exception"}})],1)],1)]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"createTime",label:"日志时间","min-width":"15%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"username",label:"操作用户","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"ipAddress",label:"请求IP","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"moduleName",label:"操作类型","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"elapseSeconds",label:"耗时(ms)","min-width":"10%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"urlPath",label:"请求路径","min-width":"20%","show-overflow-tooltip":!0}}),e._v(" "),a("el-table-column",{attrs:{prop:"failed",label:"异常",formatter:e.boolFormat,"min-width":"10%","show-overflow-tooltip":!0}})],1),e._v(" "),a("div",{staticClass:"page",attrs:{align:"right"}},[a("el-pagination",{attrs:{"current-page":e.currentPage,"page-sizes":[5,10,20,40],"page-size":e.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.totalCount},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}})],1)],1)},staticRenderFns:[]};var n=a("VU/8")(l,o,!1,function(e){a("sACR")},"data-v-5a0d71c9",null);t.default=n.exports},sACR:function(e,t){}});
|
||||
//# sourceMappingURL=11.f892b415a253bac53fa8.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
webpackJsonp([12],{"mKp/":function(t,a,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var s={data:function(){return{loading:!0,currentPage:1,pageSize:10,totalCount:0,allTaskAssignments:[],taskId:"请选择一个任务安排",jobTableData:[],jobScheduleTime:"",isActive:-1,array:[]}},methods:{loadAllTaskAssignments:function(){var t=this;this.$http({method:"GET",url:"/dbswitch/admin/api/v1/assignment/list/1/10000"}).then(function(a){0===a.data.code?t.allTaskAssignments=a.data.data:a.data.message&&alert("初始化任务安排信息失败:"+a.data.message)})},handleClose:function(){},handleSizeChange:function(t){this.loading=!0,this.pageSize=t,this.loadJobsData()},handleCurrentChange:function(t){this.loading=!0,this.currentPage=t,this.loadJobsData()},loadJobsData:function(){var t=this;this.$http.get("/dbswitch/admin/api/v1/ops/jobs/list/"+this.currentPage+"/"+this.pageSize+"?id="+this.taskId).then(function(a){0===a.data.code?(t.currentPage=a.data.pagination.page,t.pageSize=a.data.pagination.size,t.totalCount=a.data.pagination.total,t.jobTableData=a.data.data):a.data.message&&alert("查询JOB执行历史纪录失败,"+a.data.message)})},handleChooseClick:function(t,a){this.isActive=a,this.taskId=t,this.loadJobsData()},handleCancelJob:function(t){var a=this;this.$http.get("/dbswitch/admin/api/v1/ops/job/cancel?id="+t).then(function(t){0===t.data.code?(a.$message("停止JOB成功"),a.loadJobsData()):t.data.message&&alert("JOB停止失败,"+t.data.message)})}},created:function(){this.loadAllTaskAssignments()}},l={render:function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",[e("el-card",[e("div",{staticClass:"container"},[e("el-card",{staticClass:"box-card"},[e("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("任务安排列表")])]),t._v(" "),e("div",{staticClass:"navsBox"},[e("ul",t._l(t.allTaskAssignments,function(a,s){return e("li",{key:s,class:{active:s==t.isActive},on:{click:function(e){return t.handleChooseClick(a.id,s)}}},[t._v("["+t._s(a.id)+"]"+t._s(a.name))])}),0)])]),t._v(" "),e("div",{staticClass:"contentBox"},[e("el-table",{attrs:{"header-cell-style":{background:"#eef1f6",color:"#606266"},data:t.jobTableData,size:"small",border:""}},[e("template",{slot:"empty"},[e("span",[t._v("单击左侧任务列表记录来查看作业调度记录")])]),t._v(" "),e("el-table-column",{attrs:{type:"expand"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-form",{staticClass:"demo-table-expand",attrs:{"label-position":"left",inline:""}},[e("el-form-item",{attrs:{label:"JOB编号:"}},[e("span",[t._v(t._s(a.row.jobId))])]),t._v(" "),e("el-form-item",{attrs:{label:"调度方式:"}},[e("span",[t._v(t._s(a.row.scheduleMode))])]),t._v(" "),e("el-form-item",{attrs:{label:"开始时间:"}},[e("span",[t._v(t._s(a.row.startTime))])]),t._v(" "),e("el-form-item",{attrs:{label:"结束时间:"}},[e("span",[t._v(t._s(a.row.finishTime))])]),t._v(" "),e("el-form-item",{attrs:{label:"执行状态:"}},[e("span",[t._v(t._s(a.row.jobStatus))])]),t._v(" "),e("el-form-item",{attrs:{label:"操作:"}},["1"==a.row.status?e("el-button",{attrs:{size:"small",type:"danger"},on:{click:function(e){return t.handleCancelJob(a.row.jobId)}}},[t._v("\n 停止\n ")]):t._e()],1),t._v(" "),e("el-form-item",{attrs:{label:"异常日志:"}},[e("el-input",{staticStyle:{"font-size":"12px",width:"700px"},attrs:{type:"textarea",autosize:{minRows:2,maxRows:5}},model:{value:a.row.errorLog,callback:function(e){t.$set(a.row,"errorLog",e)},expression:"props.row.errorLog"}})],1)],1)]}}])}),t._v(" "),e("el-table-column",{attrs:{property:"jobId",label:"ID",width:"60"}}),t._v(" "),e("el-table-column",{attrs:{property:"assignmentId",label:"任务ID",width:"80"}}),t._v(" "),e("el-table-column",{attrs:{property:"scheduleMode",label:"调度方式",width:"80"}}),t._v(" "),e("el-table-column",{attrs:{property:"startTime",label:"开始时间",width:"160"}}),t._v(" "),e("el-table-column",{attrs:{property:"finishTime",label:"结束时间",width:"160"}}),t._v(" "),e("el-table-column",{attrs:{property:"duration",label:"持续时长(s)",width:"100"}}),t._v(" "),e("el-table-column",{attrs:{property:"jobStatus",label:"执行状态",width:"100"}})],2),t._v(" "),e("div",{staticClass:"page",attrs:{align:"right"}},[e("el-pagination",{attrs:{"current-page":t.currentPage,"page-sizes":[5,10,20,40],"page-size":t.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:t.totalCount},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1)],1)],1)])],1)},staticRenderFns:[]};var n=e("VU/8")(s,l,!1,function(t){e("sSvd")},"data-v-315acdde",null);a.default=n.exports},sSvd:function(t,a){}});
|
||||
//# sourceMappingURL=12.ff8bfea7a9029d5ba336.js.map
|
||||
webpackJsonp([13],{"mKp/":function(t,a,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var s={data:function(){return{loading:!0,currentPage:1,pageSize:10,totalCount:0,allTaskAssignments:[],taskId:"请选择一个任务安排",jobTableData:[],jobScheduleTime:"",isActive:-1,array:[]}},methods:{loadAllTaskAssignments:function(){var t=this;this.$http({method:"GET",url:"/dbswitch/admin/api/v1/assignment/list/1/10000"}).then(function(a){0===a.data.code?t.allTaskAssignments=a.data.data:a.data.message&&alert("初始化任务安排信息失败:"+a.data.message)})},handleClose:function(){},handleSizeChange:function(t){this.loading=!0,this.pageSize=t,this.loadJobsData()},handleCurrentChange:function(t){this.loading=!0,this.currentPage=t,this.loadJobsData()},loadJobsData:function(){var t=this;this.$http.get("/dbswitch/admin/api/v1/ops/jobs/list/"+this.currentPage+"/"+this.pageSize+"?id="+this.taskId).then(function(a){0===a.data.code?(t.currentPage=a.data.pagination.page,t.pageSize=a.data.pagination.size,t.totalCount=a.data.pagination.total,t.jobTableData=a.data.data):a.data.message&&alert("查询JOB执行历史纪录失败,"+a.data.message)})},handleChooseClick:function(t,a){this.isActive=a,this.taskId=t,this.loadJobsData()},handleCancelJob:function(t){var a=this;this.$http.get("/dbswitch/admin/api/v1/ops/job/cancel?id="+t).then(function(t){0===t.data.code?(a.$message("停止JOB成功"),a.loadJobsData()):t.data.message&&alert("JOB停止失败,"+t.data.message)})}},created:function(){this.loadAllTaskAssignments()}},l={render:function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",[e("el-card",[e("div",{staticClass:"container"},[e("el-card",{staticClass:"box-card"},[e("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("任务安排列表")])]),t._v(" "),e("div",{staticClass:"navsBox"},[e("ul",t._l(t.allTaskAssignments,function(a,s){return e("li",{key:s,class:{active:s==t.isActive},on:{click:function(e){return t.handleChooseClick(a.id,s)}}},[t._v("["+t._s(a.id)+"]"+t._s(a.name))])}),0)])]),t._v(" "),e("div",{staticClass:"contentBox"},[e("el-table",{attrs:{"header-cell-style":{background:"#eef1f6",color:"#606266"},data:t.jobTableData,size:"small",border:""}},[e("template",{slot:"empty"},[e("span",[t._v("单击左侧任务列表记录来查看作业调度记录")])]),t._v(" "),e("el-table-column",{attrs:{type:"expand"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-form",{staticClass:"demo-table-expand",attrs:{"label-position":"left",inline:""}},[e("el-form-item",{attrs:{label:"JOB编号:"}},[e("span",[t._v(t._s(a.row.jobId))])]),t._v(" "),e("el-form-item",{attrs:{label:"调度方式:"}},[e("span",[t._v(t._s(a.row.scheduleMode))])]),t._v(" "),e("el-form-item",{attrs:{label:"开始时间:"}},[e("span",[t._v(t._s(a.row.startTime))])]),t._v(" "),e("el-form-item",{attrs:{label:"结束时间:"}},[e("span",[t._v(t._s(a.row.finishTime))])]),t._v(" "),e("el-form-item",{attrs:{label:"执行状态:"}},[e("span",[t._v(t._s(a.row.jobStatus))])]),t._v(" "),e("el-form-item",{attrs:{label:"操作:"}},["1"==a.row.status?e("el-button",{attrs:{size:"small",type:"danger"},on:{click:function(e){return t.handleCancelJob(a.row.jobId)}}},[t._v("\n 停止\n ")]):t._e()],1),t._v(" "),e("el-form-item",{attrs:{label:"异常日志:"}},[e("el-input",{staticStyle:{"font-size":"12px",width:"700px"},attrs:{type:"textarea",autosize:{minRows:2,maxRows:5}},model:{value:a.row.errorLog,callback:function(e){t.$set(a.row,"errorLog",e)},expression:"props.row.errorLog"}})],1)],1)]}}])}),t._v(" "),e("el-table-column",{attrs:{property:"jobId",label:"ID",width:"60"}}),t._v(" "),e("el-table-column",{attrs:{property:"assignmentId",label:"任务ID",width:"80"}}),t._v(" "),e("el-table-column",{attrs:{property:"scheduleMode",label:"调度方式",width:"80"}}),t._v(" "),e("el-table-column",{attrs:{property:"startTime",label:"开始时间",width:"160"}}),t._v(" "),e("el-table-column",{attrs:{property:"finishTime",label:"结束时间",width:"160"}}),t._v(" "),e("el-table-column",{attrs:{property:"duration",label:"持续时长(s)",width:"100"}}),t._v(" "),e("el-table-column",{attrs:{property:"jobStatus",label:"执行状态",width:"100"}})],2),t._v(" "),e("div",{staticClass:"page",attrs:{align:"right"}},[e("el-pagination",{attrs:{"current-page":t.currentPage,"page-sizes":[5,10,20,40],"page-size":t.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:t.totalCount},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1)],1)],1)])],1)},staticRenderFns:[]};var n=e("VU/8")(s,l,!1,function(t){e("sSvd")},"data-v-315acdde",null);a.default=n.exports},sSvd:function(t,a){}});
|
||||
//# sourceMappingURL=13.a95a8fc1f81d32bcfc9c.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
webpackJsonp([14],{HH4r:function(t,e){},oQRv:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={data:function(){return{loading:!0,lists:[],currentPage:1,pageSize:10,totalCount:0}},methods:{loadData:function(){var t=this;this.$http.get("/dbswitch/admin/api/v1/syslog/list/1/"+this.currentPage+"/"+this.pageSize).then(function(e){t.loading=!1,0===e.data.code?(t.currentPage=e.data.pagination.page,t.pageSize=e.data.pagination.size,t.totalCount=e.data.pagination.total,t.lists=e.data.data):alert("加载数据失败:"+e.data.message)},function(e){t.$message({showClose:!0,message:"数据加载错误",type:"error"})})},handleSizeChange:function(t){this.loading=!0,this.pageSize=t,this.loadData()},handleCurrentChange:function(t){this.loading=!0,this.currentPage=t,this.loadData()}},created:function(){this.loadData()}},i={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticStyle:{"margin-top":"15px"}},[a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticStyle:{width:"100%"},attrs:{"element-loading-text":"拼命加载中","element-loading-spinner":"el-icon-loading","element-loading-background":"rgba(0, 0, 0, 0.8)",data:t.lists,stripe:"",size:"small",border:""}},[a("el-table-column",{attrs:{prop:"createTime",label:"日志时间","min-width":"15%","show-overflow-tooltip":!0}}),t._v(" "),a("el-table-column",{attrs:{prop:"ipAddress",label:"请求IP","min-width":"10%","show-overflow-tooltip":!0}}),t._v(" "),a("el-table-column",{attrs:{prop:"content",label:"操作内容","min-width":"20%","show-overflow-tooltip":!0}}),t._v(" "),a("el-table-column",{attrs:{prop:"userAgent",label:"请求代理","min-width":"50%","show-overflow-tooltip":!0}})],1),t._v(" "),a("div",{staticClass:"page",attrs:{align:"right"}},[a("el-pagination",{attrs:{"current-page":t.currentPage,"page-sizes":[5,10,20,40],"page-size":t.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:t.totalCount},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1)],1)},staticRenderFns:[]};var o=a("VU/8")(n,i,!1,function(t){a("HH4r")},"data-v-1bc640ee",null);e.default=o.exports}});
|
||||
//# sourceMappingURL=14.220c10d64f09655e8973.js.map
|
||||
webpackJsonp([15],{HH4r:function(t,e){},oQRv:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={data:function(){return{loading:!0,lists:[],currentPage:1,pageSize:10,totalCount:0}},methods:{loadData:function(){var t=this;this.$http.get("/dbswitch/admin/api/v1/syslog/list/1/"+this.currentPage+"/"+this.pageSize).then(function(e){t.loading=!1,0===e.data.code?(t.currentPage=e.data.pagination.page,t.pageSize=e.data.pagination.size,t.totalCount=e.data.pagination.total,t.lists=e.data.data):alert("加载数据失败:"+e.data.message)},function(e){t.$message({showClose:!0,message:"数据加载错误",type:"error"})})},handleSizeChange:function(t){this.loading=!0,this.pageSize=t,this.loadData()},handleCurrentChange:function(t){this.loading=!0,this.currentPage=t,this.loadData()}},created:function(){this.loadData()}},i={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticStyle:{"margin-top":"15px"}},[a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticStyle:{width:"100%"},attrs:{"element-loading-text":"拼命加载中","element-loading-spinner":"el-icon-loading","element-loading-background":"rgba(0, 0, 0, 0.8)",data:t.lists,stripe:"",size:"small",border:""}},[a("el-table-column",{attrs:{prop:"createTime",label:"日志时间","min-width":"15%","show-overflow-tooltip":!0}}),t._v(" "),a("el-table-column",{attrs:{prop:"ipAddress",label:"请求IP","min-width":"10%","show-overflow-tooltip":!0}}),t._v(" "),a("el-table-column",{attrs:{prop:"content",label:"操作内容","min-width":"20%","show-overflow-tooltip":!0}}),t._v(" "),a("el-table-column",{attrs:{prop:"userAgent",label:"请求代理","min-width":"50%","show-overflow-tooltip":!0}})],1),t._v(" "),a("div",{staticClass:"page",attrs:{align:"right"}},[a("el-pagination",{attrs:{"current-page":t.currentPage,"page-sizes":[5,10,20,40],"page-size":t.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:t.totalCount},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1)],1)},staticRenderFns:[]};var o=a("VU/8")(n,i,!1,function(t){a("HH4r")},"data-v-1bc640ee",null);e.default=o.exports}});
|
||||
//# sourceMappingURL=15.dec790aca8fa0a8e930a.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
webpackJsonp([17],{NHnr:function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=t("//Fk"),r=t.n(o),a=t("7+uW"),u={render:function(){var n=this.$createElement,e=this._self._c||n;return e("div",{staticClass:"body-wrapper"},[e("router-view")],1)},staticRenderFns:[]};var c=t("VU/8")({name:"App"},u,!1,function(n){t("Pibb")},"data-v-a97617c2",null).exports,i=t("/ocq");a.default.use(i.a);var l=new i.a({routes:[{path:"/",name:"首页",component:function(){return t.e(4).then(t.bind(null,"4er+"))},redirect:"/dashboard",children:[{path:"/dashboard",name:"概览",icon:"el-icon-menu",component:function(){return Promise.all([t.e(0),t.e(8)]).then(t.bind(null,"ARoL"))}},{path:"/connection",name:"连接管理",icon:"el-icon-s-order",component:function(){return Promise.all([t.e(0),t.e(9)]).then(t.bind(null,"qdtB"))}},{path:"/metadata",name:"数据目录",icon:"el-icon-coin",component:function(){return t.e(1).then(t.bind(null,"PJ2q"))}},{path:"/task",name:"任务管理",icon:"el-icon-s-tools",component:function(){return t.e(6).then(t.bind(null,"4KEO"))},children:[{path:"/task/assignment",name:"任务安排",icon:"el-icon-eleme",component:function(){return Promise.all([t.e(0),t.e(13)]).then(t.bind(null,"D0I9"))}},{path:"/task/schedule",name:"调度记录",icon:"el-icon-pie-chart",component:function(){return t.e(12).then(t.bind(null,"mKp/"))}}]},{path:"/log",name:"审计日志",icon:"el-icon-platform-eleme",component:function(){return t.e(7).then(t.bind(null,"QWih"))},children:[{path:"/log/access",name:"登录日志",icon:"el-icon-eleme",component:function(){return t.e(14).then(t.bind(null,"oQRv"))}},{path:"/log/action",name:"操作日志",icon:"el-icon-s-check",component:function(){return t.e(10).then(t.bind(null,"0eSS"))}}]},{path:"/about",name:"关于系统",icon:"el-icon-s-custom",component:function(){return t.e(2).then(t.bind(null,"m25N"))}},{path:"/user/personal",name:"个人中心",hidden:!0,component:function(){return t.e(3).then(t.bind(null,"uTKz"))}},{path:"/task/create",name:"创建任务",hidden:!0,component:function(){return Promise.all([t.e(0),t.e(11)]).then(t.bind(null,"/rCC"))}},{path:"/task/update",name:"修改任务",hidden:!0,component:function(){return Promise.all([t.e(0),t.e(15)]).then(t.bind(null,"txod"))}}]},{path:"/login",name:"登录",component:function(){return t.e(5).then(t.bind(null,"T+/8"))}}]}),p=t("mtWM"),s=t.n(p).a.create();s.interceptors.request.use(function(n){return n.url=""+n.url,n});var d=s,m=t("zL8q"),h=t.n(m),f=(t("muQq"),t("tvR6"),t("7Vno")),b=t.n(f),v=t("XLwt"),g=t.n(v);a.default.use(d),a.default.use(h.a),a.default.use(b.a),a.default.prototype.$http=d,a.default.config.productionTip=!1,a.default.prototype.$echarts=g.a,d.interceptors.request.use(function(n){var e=sessionStorage.getItem("token");return e&&(n.headers.Authorization="Bearer "+e),n},function(n){return r.a.reject(n)}),d.interceptors.response.use(function(n){return!n.data||401!==n.data.code&&403!==n.data.code&&404!==n.data.code||l.push({path:"/login"}),n},function(n){return console.log(n),r.a.reject(n.response)}),new a.default({el:"#app",router:l,components:{App:c},template:"<App/>"})},Pibb:function(n,e){},muQq:function(n,e){},tvR6:function(n,e){}},["NHnr"]);
|
||||
//# sourceMappingURL=app.16126c7c1f0b72278ba8.js.map
|
||||
webpackJsonp([17],{NHnr:function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=t("//Fk"),r=t.n(o),a=t("7+uW"),u={render:function(){var n=this.$createElement,e=this._self._c||n;return e("div",{staticClass:"body-wrapper"},[e("router-view")],1)},staticRenderFns:[]};var c=t("VU/8")({name:"App"},u,!1,function(n){t("Pibb")},"data-v-a97617c2",null).exports,i=t("/ocq");a.default.use(i.a);var l=new i.a({routes:[{path:"/",name:"首页",component:function(){return t.e(4).then(t.bind(null,"4er+"))},redirect:"/dashboard",children:[{path:"/dashboard",name:"概览",icon:"el-icon-menu",component:function(){return Promise.all([t.e(0),t.e(8)]).then(t.bind(null,"ARoL"))}},{path:"/connection",name:"连接管理",icon:"el-icon-s-order",component:function(){return Promise.all([t.e(0),t.e(10)]).then(t.bind(null,"qdtB"))}},{path:"/metadata",name:"数据目录",icon:"el-icon-coin",component:function(){return t.e(1).then(t.bind(null,"PJ2q"))}},{path:"/task",name:"任务管理",icon:"el-icon-s-tools",component:function(){return t.e(6).then(t.bind(null,"4KEO"))},children:[{path:"/task/assignment",name:"任务安排",icon:"el-icon-eleme",component:function(){return Promise.all([t.e(0),t.e(14)]).then(t.bind(null,"D0I9"))}},{path:"/task/schedule",name:"调度记录",icon:"el-icon-pie-chart",component:function(){return t.e(13).then(t.bind(null,"mKp/"))}}]},{path:"/log",name:"审计日志",icon:"el-icon-platform-eleme",component:function(){return t.e(7).then(t.bind(null,"QWih"))},children:[{path:"/log/access",name:"登录日志",icon:"el-icon-eleme",component:function(){return t.e(15).then(t.bind(null,"oQRv"))}},{path:"/log/action",name:"操作日志",icon:"el-icon-s-check",component:function(){return t.e(11).then(t.bind(null,"0eSS"))}}]},{path:"/about",name:"关于系统",icon:"el-icon-s-custom",component:function(){return t.e(2).then(t.bind(null,"m25N"))}},{path:"/user/personal",name:"个人中心",hidden:!0,component:function(){return t.e(3).then(t.bind(null,"uTKz"))}},{path:"/task/create",name:"创建任务",hidden:!0,component:function(){return Promise.all([t.e(0),t.e(12)]).then(t.bind(null,"/rCC"))}},{path:"/task/update",name:"修改任务",hidden:!0,component:function(){return Promise.all([t.e(0),t.e(9)]).then(t.bind(null,"txod"))}}]},{path:"/login",name:"登录",component:function(){return t.e(5).then(t.bind(null,"T+/8"))}}]}),p=t("mtWM"),s=t.n(p).a.create();s.interceptors.request.use(function(n){return n.url=""+n.url,n});var d=s,m=t("zL8q"),h=t.n(m),f=(t("muQq"),t("tvR6"),t("7Vno")),b=t.n(f),v=t("XLwt"),g=t.n(v);a.default.use(d),a.default.use(h.a),a.default.use(b.a),a.default.prototype.$http=d,a.default.config.productionTip=!1,a.default.prototype.$echarts=g.a,d.interceptors.request.use(function(n){var e=sessionStorage.getItem("token");return e&&(n.headers.Authorization="Bearer "+e),n},function(n){return r.a.reject(n)}),d.interceptors.response.use(function(n){return!n.data||401!==n.data.code&&403!==n.data.code&&404!==n.data.code||l.push({path:"/login"}),n},function(n){return console.log(n),r.a.reject(n.response)}),new a.default({el:"#app",router:l,components:{App:c},template:"<App/>"})},Pibb:function(n,e){},muQq:function(n,e){},tvR6:function(n,e){}},["NHnr"]);
|
||||
//# sourceMappingURL=app.418d956a43293c6e0efb.js.map
|
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,o){for(var f,d,i,u=0,s=[];u<r.length;u++)d=r[u],t[d]&&s.push(t[d][0]),t[d]=0;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(e[f]=c[f]);for(n&&n(r,c,o);s.length;)s.shift()();if(o)for(u=0;u<o.length;u++)i=a(a.s=o[u]);return i};var r={},t={18:0};function a(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,a){n=t[e]=[r,a]});n[2]=r;var c=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.charset="utf-8",o.async=!0,o.timeout=12e4,a.nc&&o.setAttribute("nonce",a.nc),o.src=a.p+"static/js/"+e+"."+{0:"ca67e87d8c000a42e592",1:"e3d4daa7d15a531ade81",2:"45757fdd22b0c905f12a",3:"d4c1dc7b68edb49b61d2",4:"c4abd62fbe15189d37a5",5:"837a4a67f1fcf6ee6c6a",6:"7f56c2238fb7e4ee2ecd",7:"d5dc80a855f66a3208ff",8:"07c5486141568381ea3e",9:"1a8259c3445b063a73e3",10:"ec3b8253b1c336df3447",11:"698a50794af7c9a68ca6",12:"ff8bfea7a9029d5ba336",13:"e722a189dec1accc4256",14:"220c10d64f09655e8973",15:"64c4b0b3cf5cd6a8b285"}[e]+".js";var f=setTimeout(d,12e4);function d(){o.onerror=o.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return o.onerror=o.onload=d,c.appendChild(o),r},a.m=e,a.c=r,a.d=function(e,n,r){a.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},a.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(n,"a",n),n},a.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},a.p="/",a.oe=function(e){throw console.error(e),e}}([]);
|
||||
//# sourceMappingURL=manifest.b6ccbbd6dc0126e76b11.js.map
|
||||
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,o){for(var f,d,i,u=0,s=[];u<r.length;u++)d=r[u],t[d]&&s.push(t[d][0]),t[d]=0;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(e[f]=c[f]);for(n&&n(r,c,o);s.length;)s.shift()();if(o)for(u=0;u<o.length;u++)i=a(a.s=o[u]);return i};var r={},t={18:0};function a(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,a){n=t[e]=[r,a]});n[2]=r;var c=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.charset="utf-8",o.async=!0,o.timeout=12e4,a.nc&&o.setAttribute("nonce",a.nc),o.src=a.p+"static/js/"+e+"."+{0:"ca67e87d8c000a42e592",1:"e3d4daa7d15a531ade81",2:"45757fdd22b0c905f12a",3:"d4c1dc7b68edb49b61d2",4:"c4abd62fbe15189d37a5",5:"837a4a67f1fcf6ee6c6a",6:"7f56c2238fb7e4ee2ecd",7:"d5dc80a855f66a3208ff",8:"07c5486141568381ea3e",9:"729e286f79df81fea7d3",10:"f5b649582844e192d384",11:"f892b415a253bac53fa8",12:"de5a454fa0c65c9c60a4",13:"a95a8fc1f81d32bcfc9c",14:"cadc6af4835efe7c42e4",15:"dec790aca8fa0a8e930a"}[e]+".js";var f=setTimeout(d,12e4);function d(){o.onerror=o.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return o.onerror=o.onload=d,c.appendChild(o),r},a.m=e,a.c=r,a.d=function(e,n,r){a.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},a.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(n,"a",n),n},a.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},a.p="/",a.oe=function(e){throw console.error(e),e}}([]);
|
||||
//# sourceMappingURL=manifest.cbc4b16180a8bf2afd41.js.map
|
File diff suppressed because one or more lines are too long
@@ -5,9 +5,19 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -96,8 +96,12 @@ public final class DatabaseAwareUtils {
|
||||
ps.setString(1, schemaName);
|
||||
ps.setString(2, tableName);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (SQLException se) {
|
||||
throw new RuntimeException(se);
|
||||
}
|
||||
|
@@ -0,0 +1,196 @@
|
||||
package com.gitee.dbswitch.common.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.SQLException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public final class TypeConvertUtils {
|
||||
|
||||
public static String castToString(final Object in) {
|
||||
if (in instanceof java.lang.Character) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.lang.String) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.lang.Character) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.sql.Clob) {
|
||||
return clob2Str((java.sql.Clob) in);
|
||||
} else if (in instanceof java.lang.Number) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.sql.RowId) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.lang.Boolean) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.util.Date) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.time.LocalDate) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.time.LocalTime) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.time.LocalDateTime) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.time.OffsetDateTime) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.sql.SQLXML) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.sql.Array) {
|
||||
return in.toString();
|
||||
} else if (in instanceof java.util.UUID) {
|
||||
return in.toString();
|
||||
} else if ("org.postgresql.util.PGobject".equals(in.getClass().getName())) {
|
||||
return in.toString();
|
||||
} else if ("org.postgresql.jdbc.PgSQLXML".equals(in.getClass().getName())) {
|
||||
try {
|
||||
Class<?> clz = in.getClass();
|
||||
Method getString = clz.getMethod("getString");
|
||||
return getString.invoke(in).toString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
} else if (in.getClass().getName().equals("oracle.sql.INTERVALDS")) {
|
||||
return in.toString();
|
||||
} else if (in.getClass().getName().equals("oracle.sql.INTERVALYM")) {
|
||||
return in.toString();
|
||||
} else if (in.getClass().getName().equals("oracle.sql.TIMESTAMPLTZ")) {
|
||||
return in.toString();
|
||||
} else if (in.getClass().getName().equals("oracle.sql.TIMESTAMPTZ")) {
|
||||
return in.toString();
|
||||
} else if (in.getClass().getName().equals("oracle.sql.BFILE")) {
|
||||
Class<?> clz = in.getClass();
|
||||
try {
|
||||
Method methodFileExists = clz.getMethod("fileExists");
|
||||
boolean exists = (boolean) methodFileExists.invoke(in);
|
||||
if (!exists) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Method methodOpenFile = clz.getMethod("openFile");
|
||||
methodOpenFile.invoke(in);
|
||||
|
||||
try {
|
||||
Method methodCharacterStreamValue = clz.getMethod("getBinaryStream");
|
||||
java.io.InputStream is = (java.io.InputStream) methodCharacterStreamValue.invoke(in);
|
||||
|
||||
String line;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(is));
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
} finally {
|
||||
Method methodCloseFile = clz.getMethod("closeFile");
|
||||
methodCloseFile.invoke(in);
|
||||
}
|
||||
} catch (java.lang.reflect.InvocationTargetException ex) {
|
||||
log.warn("Error for handle oracle.sql.BFILE: ", ex);
|
||||
return "";
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else if (in.getClass().getName().equals("microsoft.sql.DateTimeOffset")) {
|
||||
return in.toString();
|
||||
} else if (in instanceof byte[]) {
|
||||
return new String((byte[]) in);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] castToByteArray(final Object in) {
|
||||
if (in instanceof byte[]) {
|
||||
return (byte[]) in;
|
||||
} else if (in instanceof java.util.Date) {
|
||||
return in.toString().getBytes();
|
||||
} else if (in instanceof java.sql.Blob) {
|
||||
return blob2Bytes((java.sql.Blob) in);
|
||||
} else if (in instanceof java.lang.String || in instanceof java.lang.Character) {
|
||||
return in.toString().getBytes();
|
||||
} else if (in instanceof java.sql.Clob) {
|
||||
return clob2Str((java.sql.Clob) in).getBytes();
|
||||
} else {
|
||||
return toByteArray(in);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object castByDetermine(final Object in) {
|
||||
if (null == in) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (in instanceof java.sql.Clob) {
|
||||
return clob2Str((java.sql.Clob) in);
|
||||
} else if (in instanceof java.sql.Array
|
||||
|| in instanceof java.sql.SQLXML) {
|
||||
try {
|
||||
return castToString(in);
|
||||
} catch (Exception e) {
|
||||
log.warn("Unsupported type for convert {} to java.lang.String", in.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
} else if (in instanceof java.sql.Blob) {
|
||||
try {
|
||||
return blob2Bytes((java.sql.Blob) in);
|
||||
} catch (Exception e) {
|
||||
log.warn("Unsupported type for convert {} to byte[] ", in.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
} else if (in instanceof java.sql.Struct) {
|
||||
log.warn("Unsupported type for convert {} to java.lang.String", in.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
private static byte[] blob2Bytes(java.sql.Blob blob) {
|
||||
try (java.io.InputStream inputStream = blob.getBinaryStream()) {
|
||||
try (java.io.BufferedInputStream is = new java.io.BufferedInputStream(inputStream)) {
|
||||
byte[] bytes = new byte[(int) blob.length()];
|
||||
int len = bytes.length;
|
||||
int offset = 0;
|
||||
int read = 0;
|
||||
while (offset < len && (read = is.read(bytes, offset, len - offset)) >= 0) {
|
||||
offset += read;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String clob2Str(java.sql.Clob clob) {
|
||||
try (java.io.Reader is = clob.getCharacterStream()) {
|
||||
java.io.BufferedReader reader = new java.io.BufferedReader(is);
|
||||
String line = reader.readLine();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (line != null) {
|
||||
sb.append(line);
|
||||
line = reader.readLine();
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (SQLException | java.io.IOException e) {
|
||||
log.warn("Field Value convert from java.sql.Clob to java.lang.String failed:", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] toByteArray(Object obj) {
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bos)) {
|
||||
oos.writeObject(obj);
|
||||
oos.flush();
|
||||
return bos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
log.error("Field value convert from {} to byte[] failed:", obj.getClass().getName(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
BIN
dbswitch-core/lib/ojdbc8-19.3.0.0.jar
Normal file
BIN
dbswitch-core/lib/ojdbc8-19.3.0.0.jar
Normal file
Binary file not shown.
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-core</artifactId>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-data</artifactId>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-dbchange</artifactId>
|
||||
|
@@ -9,13 +9,14 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbchange;
|
||||
|
||||
import com.gitee.dbswitch.common.util.JdbcTypesUtils;
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.core.service.IMetaDataByDatasourceService;
|
||||
import com.gitee.dbswitch.core.service.impl.MetaDataByDataSourceServiceImpl;
|
||||
import com.gitee.dbswitch.dbcommon.constant.Constants;
|
||||
import com.gitee.dbswitch.dbcommon.database.DatabaseOperatorFactory;
|
||||
import com.gitee.dbswitch.dbcommon.database.IDatabaseOperator;
|
||||
import com.gitee.dbswitch.dbcommon.domain.StatementResultSet;
|
||||
import com.gitee.dbswitch.common.util.JdbcTypesUtils;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
@@ -27,7 +28,6 @@ import java.util.stream.Collectors;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
* 数据变化量计算核心类
|
||||
@@ -437,8 +437,8 @@ public final class ChangeCalculatorService implements IDatabaseChangeCaculator {
|
||||
* </p>
|
||||
*/
|
||||
if (JdbcTypesUtils.isString(type)) {
|
||||
String s1 = String.valueOf(o1);
|
||||
String s2 = String.valueOf(o2);
|
||||
String s1 = TypeConvertUtils.castToString(o1);
|
||||
String s2 = TypeConvertUtils.castToString(o2);
|
||||
return s1.compareTo(s2);
|
||||
} else if (JdbcTypesUtils.isNumeric(type) && o1 instanceof java.lang.Number
|
||||
&& o2 instanceof java.lang.Number) {
|
||||
@@ -470,7 +470,10 @@ public final class ChangeCalculatorService implements IDatabaseChangeCaculator {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return compareTo(SerializationUtils.serialize(o1), SerializationUtils.serialize(o2));
|
||||
return compareTo(
|
||||
TypeConvertUtils.castToByteArray(o1),
|
||||
TypeConvertUtils.castToByteArray(o2)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.warn("CDC compare field value failed, return 0 instead,{}", e.getMessage());
|
||||
return 0;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-dbcommon</artifactId>
|
||||
@@ -24,11 +24,6 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-dbsynch</artifactId>
|
||||
|
@@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbsynch.db2;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbsynch.AbstractDatabaseSynchronize;
|
||||
import com.gitee.dbswitch.dbsynch.IDatabaseSynchronize;
|
||||
import java.util.Collections;
|
||||
@@ -72,4 +73,33 @@ public class DB2DatabaseSyncImpl extends AbstractDatabaseSynchronize implements
|
||||
schemaName, tableName, StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeInsert(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeInsert(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeUpdate(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeUpdate(records);
|
||||
}
|
||||
}
|
||||
|
@@ -9,18 +9,97 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbsynch.dm;
|
||||
|
||||
import com.gitee.dbswitch.dbsynch.oracle.OracleDatabaseSyncImpl;
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbsynch.AbstractDatabaseSynchronize;
|
||||
import com.gitee.dbswitch.dbsynch.IDatabaseSynchronize;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* DM数据库DML同步实现类
|
||||
*
|
||||
* @author tang
|
||||
*/
|
||||
public class DmDatabaseSyncImpl extends OracleDatabaseSyncImpl {
|
||||
public class DmDatabaseSyncImpl extends AbstractDatabaseSynchronize implements
|
||||
IDatabaseSynchronize {
|
||||
|
||||
public DmDatabaseSyncImpl(DataSource ds) {
|
||||
super(ds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnMetaDataSql(String schemaName, String tableName) {
|
||||
return String.format("SELECT * FROM \"%s\".\"%s\" WHERE 1=2", schemaName, tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInsertPrepareStatementSql(String schemaName, String tableName,
|
||||
List<String> fieldNames) {
|
||||
List<String> placeHolders = Collections.nCopies(fieldNames.size(), "?");
|
||||
return String.format("INSERT INTO \"%s\".\"%s\" ( \"%s\" ) VALUES ( %s )",
|
||||
schemaName, tableName,
|
||||
StringUtils.join(fieldNames, "\",\""),
|
||||
StringUtils.join(placeHolders, ","));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpdatePrepareStatementSql(String schemaName, String tableName,
|
||||
List<String> fieldNames, List<String> pks) {
|
||||
List<String> uf = fieldNames.stream()
|
||||
.filter(field -> !pks.contains(field))
|
||||
.map(field -> String.format("\"%s\"=?", field))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> uw = pks.stream()
|
||||
.map(pk -> String.format("\"%s\"=?", pk))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return String.format("UPDATE \"%s\".\"%s\" SET %s WHERE %s",
|
||||
schemaName, tableName, StringUtils.join(uf, " , "),
|
||||
StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeletePrepareStatementSql(String schemaName, String tableName,
|
||||
List<String> pks) {
|
||||
List<String> uw = pks.stream()
|
||||
.map(pk -> String.format("\"%s\"=?", pk))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return String.format("DELETE FROM \"%s\".\"%s\" WHERE %s ",
|
||||
schemaName, tableName, StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeInsert(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeInsert(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeUpdate(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeUpdate(records);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbsynch.mssql;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbsynch.AbstractDatabaseSynchronize;
|
||||
import com.gitee.dbswitch.dbsynch.IDatabaseSynchronize;
|
||||
import java.util.Collections;
|
||||
@@ -72,4 +73,33 @@ public class SqlServerDatabaseSyncImpl extends AbstractDatabaseSynchronize imple
|
||||
schemaName, tableName, StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeInsert(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeInsert(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeUpdate(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeUpdate(records);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbsynch.mysql;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbsynch.AbstractDatabaseSynchronize;
|
||||
import com.gitee.dbswitch.dbsynch.IDatabaseSynchronize;
|
||||
import java.util.Collections;
|
||||
@@ -72,4 +73,33 @@ public class MySqlDatabaseSyncImpl extends AbstractDatabaseSynchronize implement
|
||||
schemaName, tableName, StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeInsert(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeInsert(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeUpdate(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeUpdate(records);
|
||||
}
|
||||
}
|
||||
|
@@ -9,13 +9,22 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbsynch.oracle;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbsynch.AbstractDatabaseSynchronize;
|
||||
import com.gitee.dbswitch.dbsynch.IDatabaseSynchronize;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.jdbc.core.SqlTypeValue;
|
||||
|
||||
/**
|
||||
* Oracle数据库DML同步实现类
|
||||
@@ -72,4 +81,124 @@ public class OracleDatabaseSyncImpl extends AbstractDatabaseSynchronize implemen
|
||||
schemaName, tableName, StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeInsert(List<Object[]> records) {
|
||||
List<InputStream> iss = new ArrayList<>();
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
switch (this.insertArgsType[i]) {
|
||||
case Types.CLOB:
|
||||
case Types.NCLOB:
|
||||
row[i] = Objects.isNull(row[i])
|
||||
? null
|
||||
: TypeConvertUtils.castToString(row[i]);
|
||||
break;
|
||||
case Types.BLOB:
|
||||
final byte[] bytes = Objects.isNull(row[i])
|
||||
? null
|
||||
: TypeConvertUtils.castToByteArray(row[i]);
|
||||
row[i] = new SqlTypeValue() {
|
||||
@Override
|
||||
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType,
|
||||
String typeName) throws SQLException {
|
||||
if (null != bytes) {
|
||||
InputStream is = new ByteArrayInputStream(bytes);
|
||||
ps.setBlob(paramIndex, is);
|
||||
iss.add(is);
|
||||
} else {
|
||||
ps.setNull(paramIndex, sqlType);
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case Types.ROWID:
|
||||
case Types.ARRAY:
|
||||
case Types.REF:
|
||||
case Types.SQLXML:
|
||||
row[i] = null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
return super.executeInsert(records);
|
||||
} finally {
|
||||
iss.forEach(is -> {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeUpdate(List<Object[]> records) {
|
||||
List<InputStream> iss = new ArrayList<>();
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
switch (this.updateArgsType[i]) {
|
||||
case Types.CLOB:
|
||||
case Types.NCLOB:
|
||||
row[i] = Objects.isNull(row[i])
|
||||
? null
|
||||
: TypeConvertUtils.castToString(row[i]);
|
||||
break;
|
||||
case Types.BLOB:
|
||||
final byte[] bytes = Objects.isNull(row[i])
|
||||
? null
|
||||
: TypeConvertUtils.castToByteArray(row[i]);
|
||||
row[i] = new SqlTypeValue() {
|
||||
@Override
|
||||
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType,
|
||||
String typeName) throws SQLException {
|
||||
if (null != bytes) {
|
||||
InputStream is = new ByteArrayInputStream(bytes);
|
||||
ps.setBlob(paramIndex, is);
|
||||
iss.add(is);
|
||||
} else {
|
||||
ps.setNull(paramIndex, sqlType);
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case Types.ROWID:
|
||||
case Types.ARRAY:
|
||||
case Types.REF:
|
||||
case Types.SQLXML:
|
||||
row[i] = null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
return super.executeUpdate(records);
|
||||
} finally {
|
||||
iss.forEach(is -> {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeDelete(List<Object[]> records) {
|
||||
return super.executeDelete(records);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbsynch.pgsql;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbsynch.AbstractDatabaseSynchronize;
|
||||
import com.gitee.dbswitch.dbsynch.IDatabaseSynchronize;
|
||||
import java.util.Collections;
|
||||
@@ -71,4 +72,33 @@ public class PostgresqlDatabaseSyncImpl extends AbstractDatabaseSynchronize impl
|
||||
StringUtils.join(uw, " AND "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeInsert(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeInsert(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeUpdate(List<Object[]> records) {
|
||||
records.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = TypeConvertUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.executeUpdate(records);
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-dbwriter</artifactId>
|
||||
|
@@ -11,6 +11,8 @@ package com.gitee.dbswitch.dbwriter.db2;
|
||||
|
||||
import com.gitee.dbswitch.dbwriter.AbstractDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.IDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.util.ObjectCastUtils;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -31,4 +33,18 @@ public class DB2WriterImpl extends AbstractDatabaseWriter implements IDatabaseWr
|
||||
return "DB2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long write(List<String> fieldNames, List<Object[]> recordValues) {
|
||||
recordValues.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = ObjectCastUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.write(fieldNames, recordValues);
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,10 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbwriter.dm;
|
||||
|
||||
import com.gitee.dbswitch.dbwriter.AbstractDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.IDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.oracle.OracleWriterImpl;
|
||||
import com.gitee.dbswitch.dbwriter.util.ObjectCastUtils;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
@@ -18,7 +20,7 @@ import javax.sql.DataSource;
|
||||
*
|
||||
* @author tang
|
||||
*/
|
||||
public class DmWriterImpl extends OracleWriterImpl implements IDatabaseWriter {
|
||||
public class DmWriterImpl extends AbstractDatabaseWriter implements IDatabaseWriter {
|
||||
|
||||
public DmWriterImpl(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
@@ -29,4 +31,18 @@ public class DmWriterImpl extends OracleWriterImpl implements IDatabaseWriter {
|
||||
return "DM";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long write(List<String> fieldNames, List<Object[]> recordValues) {
|
||||
recordValues.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = ObjectCastUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.write(fieldNames, recordValues);
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ package com.gitee.dbswitch.dbwriter.gpdb;
|
||||
|
||||
import com.gitee.dbswitch.dbwriter.AbstractDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.IDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.util.ObjectCastUtils;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -31,4 +33,18 @@ public class GreenplumInsertWriterImpl extends AbstractDatabaseWriter implements
|
||||
return "Greenplum";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long write(List<String> fieldNames, List<Object[]> recordValues) {
|
||||
recordValues.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = ObjectCastUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return super.write(fieldNames, recordValues);
|
||||
}
|
||||
}
|
||||
|
@@ -9,14 +9,23 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbwriter.mysql;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbwriter.AbstractDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.IDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.util.ObjectCastUtils;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.jdbc.core.SqlTypeValue;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
@@ -55,6 +64,20 @@ public class MySqlWriterImpl extends AbstractDatabaseWriter implements IDatabase
|
||||
|
||||
@Override
|
||||
public long write(List<String> fieldNames, List<Object[]> recordValues) {
|
||||
if (recordValues.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
recordValues.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
row[i] = ObjectCastUtils.castByDetermine(row[i]);
|
||||
} catch (Exception e) {
|
||||
row[i] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<String> placeHolders = Collections.nCopies(fieldNames.size(), "?");
|
||||
String sqlInsert = String.format("INSERT INTO `%s`.`%s` ( `%s` ) VALUES ( %s )",
|
||||
schemaName, tableName,
|
||||
|
@@ -9,13 +9,20 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.dbwriter.oracle;
|
||||
|
||||
import com.gitee.dbswitch.common.util.TypeConvertUtils;
|
||||
import com.gitee.dbswitch.dbwriter.AbstractDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.IDatabaseWriter;
|
||||
import com.gitee.dbswitch.dbwriter.util.ObjectCastUtils;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.jdbc.core.SqlTypeValue;
|
||||
|
||||
/**
|
||||
* Oracle数据库写入实现类
|
||||
@@ -40,28 +47,48 @@ public class OracleWriterImpl extends AbstractDatabaseWriter implements IDatabas
|
||||
* 将java.sql.Array 类型转换为java.lang.String
|
||||
* <p>
|
||||
* Oracle 没有数组类型,这里以文本类型进行存在
|
||||
* <p>
|
||||
* Oracle的CLOB和BLOB类型写入请见:
|
||||
* <p>
|
||||
* oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical
|
||||
*/
|
||||
List<InputStream> iss = new ArrayList<>();
|
||||
recordValues.parallelStream().forEach((Object[] row) -> {
|
||||
for (int i = 0; i < row.length; ++i) {
|
||||
try {
|
||||
int dataType = this.columnType.get(fieldNames.get(i));
|
||||
switch (dataType) {
|
||||
// oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical
|
||||
case Types.CLOB:
|
||||
case Types.NCLOB:
|
||||
row[i] = Objects.isNull(row[i])
|
||||
? null
|
||||
: TypeConvertUtils.castToString(row[i]);
|
||||
break;
|
||||
case Types.BLOB:
|
||||
// 需要oracle.sql.BLOB类型
|
||||
log.warn("Unsupported type for convert {} to oracle.sql.BLOB",
|
||||
row[i].getClass().getName());
|
||||
row[i] = null;
|
||||
final byte[] bytes = Objects.isNull(row[i])
|
||||
? null
|
||||
: TypeConvertUtils.castToByteArray(row[i]);
|
||||
row[i] = new SqlTypeValue() {
|
||||
@Override
|
||||
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType,
|
||||
String typeName) throws SQLException {
|
||||
if (null != bytes) {
|
||||
InputStream is = new ByteArrayInputStream(bytes);
|
||||
ps.setBlob(paramIndex, is);
|
||||
iss.add(is);
|
||||
} else {
|
||||
ps.setNull(paramIndex, sqlType);
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case Types.ROWID:
|
||||
case Types.ARRAY:
|
||||
case Types.NCLOB:
|
||||
case Types.REF:
|
||||
case Types.SQLXML:
|
||||
row[i] = null;
|
||||
break;
|
||||
default:
|
||||
row[i] = ObjectCastUtils.castByDetermine(row[i]);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -70,6 +97,15 @@ public class OracleWriterImpl extends AbstractDatabaseWriter implements IDatabas
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
return super.write(fieldNames, recordValues);
|
||||
} finally {
|
||||
iss.forEach(is -> {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -868,18 +868,18 @@ public final class ObjectCastUtils {
|
||||
}
|
||||
|
||||
if (in instanceof java.sql.Clob) {
|
||||
return ObjectCastUtils.clob2Str((java.sql.Clob) in);
|
||||
return clob2Str((java.sql.Clob) in);
|
||||
} else if (in instanceof java.sql.Array
|
||||
|| in instanceof java.sql.SQLXML) {
|
||||
try {
|
||||
return ObjectCastUtils.objectToString(in);
|
||||
return objectToString(in);
|
||||
} catch (Exception e) {
|
||||
log.warn("Unsupported type for convert {} to java.lang.String", in.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
} else if (in instanceof java.sql.Blob) {
|
||||
try {
|
||||
return ObjectCastUtils.blob2Bytes((java.sql.Blob) in);
|
||||
return blob2Bytes((java.sql.Blob) in);
|
||||
} catch (Exception e) {
|
||||
log.warn("Unsupported type for convert {} to byte[] ", in.getClass().getName());
|
||||
return null;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-pgwriter</artifactId>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dbswitch-sql</artifactId>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>package-tool</artifactId>
|
||||
|
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gitee.dbswitch</groupId>
|
||||
<artifactId>dbswitch-parent</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<version>1.6.7</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>dbswitch</name>
|
||||
<description>database switch project</description>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
@echo off
|
||||
|
||||
set APP_VERSION=1.6.6
|
||||
set APP_VERSION=1.6.7
|
||||
|
||||
echo "Clean Project ..."
|
||||
call mvn clean -f pom.xml
|
||||
|
Reference in New Issue
Block a user