CX 2 years ago
commit
f3edf8b7fa
100 changed files with 15944 additions and 0 deletions
  1. 623 0
      kettle-scheduler-oracle.sql
  2. 277 0
      kettle-scheduler.sql
  3. 353 0
      pom.xml
  4. 62 0
      src/main/java/com/zhaxd/common/exception/KettleMasterException.java
  5. 9 0
      src/main/java/com/zhaxd/common/exception/SeviceException.java
  6. 92 0
      src/main/java/com/zhaxd/common/kettle/Main.java
  7. 262 0
      src/main/java/com/zhaxd/common/kettle/environment/KettleInit.java
  8. 30 0
      src/main/java/com/zhaxd/common/kettle/environment/StartInit.java
  9. 233 0
      src/main/java/com/zhaxd/common/kettle/repository/RepositoryUtil.java
  10. 190 0
      src/main/java/com/zhaxd/common/toolkit/Constant.java
  11. 119 0
      src/main/java/com/zhaxd/common/toolkit/EmailUtil.java
  12. 56 0
      src/main/java/com/zhaxd/common/toolkit/MD5Utils.java
  13. 426 0
      src/main/java/com/zhaxd/common/toolkit/ObjectID.java
  14. 38 0
      src/main/java/com/zhaxd/core/conf/LoginInterceptor.java
  15. 95 0
      src/main/java/com/zhaxd/core/conf/UTF8StringHttpMessageConverter.java
  16. 36 0
      src/main/java/com/zhaxd/core/dto/BootTablePage.java
  17. 143 0
      src/main/java/com/zhaxd/core/dto/ResultDto.java
  18. 82 0
      src/main/java/com/zhaxd/core/dto/kettle/RepositoryTree.java
  19. 86 0
      src/main/java/com/zhaxd/core/dto/web/KRepositoryDto.java
  20. 7 0
      src/main/java/com/zhaxd/core/mapper/KCategoryDao.java
  21. 19 0
      src/main/java/com/zhaxd/core/mapper/KJobDao.java
  22. 17 0
      src/main/java/com/zhaxd/core/mapper/KJobMonitorDao.java
  23. 10 0
      src/main/java/com/zhaxd/core/mapper/KJobRecordDao.java
  24. 10 0
      src/main/java/com/zhaxd/core/mapper/KQuartzDao.java
  25. 10 0
      src/main/java/com/zhaxd/core/mapper/KRepositoryDao.java
  26. 10 0
      src/main/java/com/zhaxd/core/mapper/KRepositoryTypeDao.java
  27. 20 0
      src/main/java/com/zhaxd/core/mapper/KTransDao.java
  28. 17 0
      src/main/java/com/zhaxd/core/mapper/KTransMonitorDao.java
  29. 10 0
      src/main/java/com/zhaxd/core/mapper/KTransRecordDao.java
  30. 10 0
      src/main/java/com/zhaxd/core/mapper/KUserDao.java
  31. 105 0
      src/main/java/com/zhaxd/core/model/KCategory.java
  32. 212 0
      src/main/java/com/zhaxd/core/model/KJob.java
  33. 145 0
      src/main/java/com/zhaxd/core/model/KJobMonitor.java
  34. 83 0
      src/main/java/com/zhaxd/core/model/KJobRecord.java
  35. 85 0
      src/main/java/com/zhaxd/core/model/KQuartz.java
  36. 167 0
      src/main/java/com/zhaxd/core/model/KRepository.java
  37. 35 0
      src/main/java/com/zhaxd/core/model/KRepositoryType.java
  38. 212 0
      src/main/java/com/zhaxd/core/model/KTrans.java
  39. 156 0
      src/main/java/com/zhaxd/core/model/KTransMonitor.java
  40. 83 0
      src/main/java/com/zhaxd/core/model/KTransRecord.java
  41. 118 0
      src/main/java/com/zhaxd/core/model/KUser.java
  42. 74 0
      src/main/java/com/zhaxd/web/controller/CategoryController.java
  43. 66 0
      src/main/java/com/zhaxd/web/controller/DownLoadRecordController.java
  44. 57 0
      src/main/java/com/zhaxd/web/controller/IndexController.java
  45. 139 0
      src/main/java/com/zhaxd/web/controller/JobController.java
  46. 46 0
      src/main/java/com/zhaxd/web/controller/JobMonitorController.java
  47. 42 0
      src/main/java/com/zhaxd/web/controller/JobRecordController.java
  48. 106 0
      src/main/java/com/zhaxd/web/controller/MainController.java
  49. 203 0
      src/main/java/com/zhaxd/web/controller/PageController.java
  50. 61 0
      src/main/java/com/zhaxd/web/controller/QuartzController.java
  51. 158 0
      src/main/java/com/zhaxd/web/controller/RepositoryController.java
  52. 134 0
      src/main/java/com/zhaxd/web/controller/TransController.java
  53. 46 0
      src/main/java/com/zhaxd/web/controller/TransMonitorController.java
  54. 40 0
      src/main/java/com/zhaxd/web/controller/TransRecordController.java
  55. 72 0
      src/main/java/com/zhaxd/web/controller/UserController.java
  56. 261 0
      src/main/java/com/zhaxd/web/quartz/JobQuartz.java
  57. 71 0
      src/main/java/com/zhaxd/web/quartz/QuartzListener.java
  58. 231 0
      src/main/java/com/zhaxd/web/quartz/QuartzManager.java
  59. 271 0
      src/main/java/com/zhaxd/web/quartz/TransQuartz.java
  60. 40 0
      src/main/java/com/zhaxd/web/quartz/model/DBConnectionModel.java
  61. 79 0
      src/main/java/com/zhaxd/web/service/CategoryService.java
  62. 183 0
      src/main/java/com/zhaxd/web/service/DataBaseRepositoryService.java
  63. 156 0
      src/main/java/com/zhaxd/web/service/JobMonitorService.java
  64. 59 0
      src/main/java/com/zhaxd/web/service/JobRecordService.java
  65. 513 0
      src/main/java/com/zhaxd/web/service/JobService.java
  66. 110 0
      src/main/java/com/zhaxd/web/service/QuartzService.java
  67. 158 0
      src/main/java/com/zhaxd/web/service/TransMonitorService.java
  68. 60 0
      src/main/java/com/zhaxd/web/service/TransRecordService.java
  69. 510 0
      src/main/java/com/zhaxd/web/service/TransService.java
  70. 144 0
      src/main/java/com/zhaxd/web/service/UserService.java
  71. 76 0
      src/main/java/com/zhaxd/web/utils/CommonUtils.java
  72. 42 0
      src/main/java/com/zhaxd/web/utils/DataValidate.java
  73. 123 0
      src/main/java/com/zhaxd/web/utils/DateField.java
  74. 241 0
      src/main/java/com/zhaxd/web/utils/DateTime.java
  75. 91 0
      src/main/java/com/zhaxd/web/utils/JsonUtils.java
  76. 4133 0
      src/main/java/org/pentaho/di/core/database/Database.java
  77. 2 0
      src/main/resources/btsql-ext.properties
  78. 11 0
      src/main/resources/kettle-lifecycle-listeners.xmlbak
  79. 11 0
      src/main/resources/kettle-registry-extensions.xmlbak
  80. 473 0
      src/main/resources/kettle-variables.xml
  81. 24 0
      src/main/resources/log4j.properties
  82. 153 0
      src/main/resources/log4j.xml
  83. 1092 0
      src/main/resources/mondrian.properties
  84. 19 0
      src/main/resources/quartz.properties
  85. 1 0
      src/main/resources/resource/active.properties
  86. 15 0
      src/main/resources/resource/db-DEV.properties
  87. 15 0
      src/main/resources/resource/db-PROD.properties
  88. 29 0
      src/main/resources/resource/kettle-DEV.properties
  89. 14 0
      src/main/resources/resource/kettle_PROD.properties
  90. 69 0
      src/main/resources/spring/applicationContext-beetlsql.xml
  91. 13 0
      src/main/resources/spring/applicationContext-service.xml
  92. 55 0
      src/main/resources/spring/spring-mvc.xml
  93. 62 0
      src/main/resources/sql/mysql/kJob.md
  94. 56 0
      src/main/resources/sql/mysql/kJobMonitor.md
  95. 62 0
      src/main/resources/sql/mysql/kTrans.md
  96. 56 0
      src/main/resources/sql/mysql/kTransMonitor.md
  97. 38 0
      src/main/resources/sql/oracle/dimEtlConfig.md
  98. 61 0
      src/main/resources/sql/oracle/kJob.md
  99. 64 0
      src/main/resources/sql/oracle/kJobMonitor.md
  100. 0 0
      src/main/resources/sql/oracle/kTrans.md

+ 623 - 0
kettle-scheduler-oracle.sql

@@ -0,0 +1,623 @@
1
+-- Oracle作数据源初始化脚本(首次执行需要注释掉DROP语句)
2
+
3
+DROP TABLE "K_CATEGORY";
4
+DROP TABLE "K_JOB";
5
+DROP TABLE "K_JOB_MONITOR";
6
+DROP TABLE "K_JOB_RECORD";
7
+DROP TABLE "K_QUARTZ";
8
+DROP TABLE "K_REPOSITORY";
9
+DROP TABLE "K_REPOSITORY_TYPE";
10
+DROP TABLE "K_TRANS";
11
+DROP TABLE "K_TRANS_MONITOR";
12
+DROP TABLE "K_TRANS_RECORD";
13
+DROP TABLE "K_USER";
14
+DROP SEQUENCE CATEGORY_ID_SEQ;
15
+DROP SEQUENCE JOB_ID_SEQ;
16
+DROP SEQUENCE JOB_MONITOR_ID_SEQ;
17
+DROP SEQUENCE JOB_RECORD_ID_SEQ;
18
+DROP SEQUENCE QUARTZ_ID_SEQ;
19
+DROP SEQUENCE REPOSITORY_ID_SEQ;
20
+DROP SEQUENCE REPOSITORY_TYPE_ID_SEQ;
21
+DROP SEQUENCE TRANS_ID_SEQ;
22
+DROP SEQUENCE TRANS_MONITOR_ID_SEQ;
23
+DROP SEQUENCE TRANS_RECORD_ID_SEQ;
24
+DROP SEQUENCE USER_ID_SEQ;
25
+
26
+-- ----------------------------
27
+-- Table structure for K_CATEGORY
28
+-- ----------------------------
29
+CREATE TABLE "K_CATEGORY" (
30
+"CATEGORY_ID" NUMBER(11) NOT NULL ,
31
+"CATEGORY_NAME" NVARCHAR2(50) NULL ,
32
+"ADD_TIME" DATE NULL ,
33
+"ADD_USER" NUMBER(11) NULL ,
34
+"EDIT_TIME" DATE NULL ,
35
+"EDIT_USER" NUMBER(11) NULL ,
36
+"DEL_FLAG" NUMBER(11) NULL
37
+)
38
+LOGGING
39
+NOCOMPRESS
40
+NOCACHE
41
+
42
+;
43
+COMMENT ON COLUMN "K_CATEGORY"."CATEGORY_ID" IS '分类ID';
44
+COMMENT ON COLUMN "K_CATEGORY"."CATEGORY_NAME" IS '分类名称';
45
+COMMENT ON COLUMN "K_CATEGORY"."ADD_TIME" IS '添加时间';
46
+COMMENT ON COLUMN "K_CATEGORY"."ADD_USER" IS '添加者';
47
+COMMENT ON COLUMN "K_CATEGORY"."EDIT_TIME" IS '编辑时间';
48
+COMMENT ON COLUMN "K_CATEGORY"."EDIT_USER" IS '编辑者';
49
+COMMENT ON COLUMN "K_CATEGORY"."DEL_FLAG" IS '是否删除(1:存在;0:删除)';
50
+
51
+-- ----------------------------
52
+-- Records of K_CATEGORY
53
+-- ----------------------------
54
+
55
+-- ----------------------------
56
+-- Table structure for K_JOB
57
+-- ----------------------------
58
+CREATE TABLE "K_JOB" (
59
+"JOB_ID" NUMBER(11) NOT NULL ,
60
+"CATEGORY_ID" NUMBER(11) NULL ,
61
+"JOB_NAME" NVARCHAR2(50) NULL ,
62
+"JOB_DESCRIPTION" NVARCHAR2(500) NULL ,
63
+"JOB_TYPE" NUMBER(11) NULL ,
64
+"JOB_PATH" NVARCHAR2(200) NULL ,
65
+"JOB_REPOSITORY_ID" NUMBER(11) NULL ,
66
+"JOB_QUARTZ" NUMBER(11) NULL ,
67
+"JOB_RECORD" NUMBER(11) NULL ,
68
+"JOB_LOG_LEVEL" NVARCHAR2(10) NULL ,
69
+"JOB_STATUS" NUMBER(11) NULL ,
70
+"ADD_TIME" DATE NULL ,
71
+"ADD_USER" NUMBER(11) NULL ,
72
+"EDIT_TIME" DATE NULL ,
73
+"EDIT_USER" NUMBER(11) NULL ,
74
+"DEL_FLAG" NUMBER(11) NULL
75
+)
76
+LOGGING
77
+NOCOMPRESS
78
+NOCACHE
79
+
80
+;
81
+COMMENT ON COLUMN "K_JOB"."JOB_ID" IS '作业ID';
82
+COMMENT ON COLUMN "K_JOB"."JOB_NAME" IS '作业名称';
83
+COMMENT ON COLUMN "K_JOB"."JOB_DESCRIPTION" IS '任务描述';
84
+COMMENT ON COLUMN "K_JOB"."JOB_TYPE" IS '1:数据库资源库;2:上传的文件';
85
+COMMENT ON COLUMN "K_JOB"."JOB_PATH" IS '作业保存路径(可以是资源库中的路径也可以是服务器中保存作业文件的路径)';
86
+COMMENT ON COLUMN "K_JOB"."JOB_REPOSITORY_ID" IS '作业的资源库ID';
87
+COMMENT ON COLUMN "K_JOB"."JOB_QUARTZ" IS '定时策略(外键ID)';
88
+COMMENT ON COLUMN "K_JOB"."JOB_RECORD" IS '作业执行记录(外键ID)';
89
+COMMENT ON COLUMN "K_JOB"."JOB_LOG_LEVEL" IS '日志级别(basic,detail,error,debug,minimal,rowlevel)';
90
+COMMENT ON COLUMN "K_JOB"."JOB_STATUS" IS '状态(1:正在运行;2:已停止)';
91
+COMMENT ON COLUMN "K_JOB"."ADD_TIME" IS '添加时间';
92
+COMMENT ON COLUMN "K_JOB"."ADD_USER" IS '添加者';
93
+COMMENT ON COLUMN "K_JOB"."EDIT_TIME" IS '编辑时间';
94
+COMMENT ON COLUMN "K_JOB"."EDIT_USER" IS '编辑者';
95
+COMMENT ON COLUMN "K_JOB"."DEL_FLAG" IS '是否删除(1:存在;0:删除)';
96
+
97
+-- ----------------------------
98
+-- Records of K_JOB
99
+-- ----------------------------
100
+
101
+-- ----------------------------
102
+-- Table structure for K_JOB_MONITOR
103
+-- ----------------------------
104
+CREATE TABLE "K_JOB_MONITOR" (
105
+"MONITOR_ID" NUMBER(11) NOT NULL ,
106
+"MONITOR_JOB" NUMBER(11) NULL ,
107
+"MONITOR_SUCCESS" NUMBER(11) NULL ,
108
+"MONITOR_FAIL" NUMBER(11) NULL ,
109
+"ADD_USER" NUMBER(11) NULL ,
110
+"MONITOR_STATUS" NUMBER(11) NULL ,
111
+"RUN_STATUS" NCLOB NULL ,
112
+"LAST_EXECUTE_TIME" DATE NULL ,
113
+"NEXT_EXECUTE_TIME" DATE NULL
114
+)
115
+LOGGING
116
+NOCOMPRESS
117
+NOCACHE
118
+
119
+;
120
+COMMENT ON COLUMN "K_JOB_MONITOR"."MONITOR_ID" IS '监控作业ID';
121
+COMMENT ON COLUMN "K_JOB_MONITOR"."MONITOR_JOB" IS '监控的作业ID';
122
+COMMENT ON COLUMN "K_JOB_MONITOR"."MONITOR_SUCCESS" IS '成功次数';
123
+COMMENT ON COLUMN "K_JOB_MONITOR"."MONITOR_FAIL" IS '失败次数';
124
+COMMENT ON COLUMN "K_JOB_MONITOR"."ADD_USER" IS '添加人';
125
+COMMENT ON COLUMN "K_JOB_MONITOR"."MONITOR_STATUS" IS '监控状态(是否启动,1:启动;2:停止)';
126
+COMMENT ON COLUMN "K_JOB_MONITOR"."RUN_STATUS" IS '运行状态(起始时间-结束时间,起始时间-结束时间……)';
127
+
128
+-- ----------------------------
129
+-- Records of K_JOB_MONITOR
130
+-- ----------------------------
131
+
132
+-- ----------------------------
133
+-- Table structure for K_JOB_RECORD
134
+-- ----------------------------
135
+CREATE TABLE "K_JOB_RECORD" (
136
+"RECORD_ID" NUMBER(11) NOT NULL ,
137
+"RECORD_JOB" NUMBER(11) NULL ,
138
+"START_TIME" DATE NULL ,
139
+"STOP_TIME" DATE NULL ,
140
+"RECORD_STATUS" NUMBER(11) NULL ,
141
+"LOG_FILE_PATH" NVARCHAR2(100) NULL ,
142
+"ADD_USER" NUMBER(11) NULL
143
+)
144
+LOGGING
145
+NOCOMPRESS
146
+NOCACHE
147
+
148
+;
149
+COMMENT ON COLUMN "K_JOB_RECORD"."RECORD_ID" IS '作业记录ID';
150
+COMMENT ON COLUMN "K_JOB_RECORD"."RECORD_JOB" IS '作业ID';
151
+COMMENT ON COLUMN "K_JOB_RECORD"."START_TIME" IS '启动时间';
152
+COMMENT ON COLUMN "K_JOB_RECORD"."STOP_TIME" IS '停止时间';
153
+COMMENT ON COLUMN "K_JOB_RECORD"."RECORD_STATUS" IS '任务执行结果(1:成功;2:失败)';
154
+COMMENT ON COLUMN "K_JOB_RECORD"."LOG_FILE_PATH" IS '作业日志记录文件保存位置';
155
+COMMENT ON COLUMN "K_JOB_RECORD"."ADD_USER" IS '添加人';
156
+
157
+-- ----------------------------
158
+-- Records of K_JOB_RECORD
159
+-- ----------------------------
160
+
161
+-- ----------------------------
162
+-- Table structure for K_QUARTZ
163
+-- ----------------------------
164
+CREATE TABLE "K_QUARTZ" (
165
+"QUARTZ_ID" NUMBER(11) NOT NULL ,
166
+"QUARTZ_DESCRIPTION" NVARCHAR2(500) NULL ,
167
+"QUARTZ_CRON" NVARCHAR2(100) NULL ,
168
+"ADD_TIME" DATE NULL ,
169
+"ADD_USER" NUMBER(11) NULL ,
170
+"EDIT_TIME" DATE NULL ,
171
+"EDIT_USER" NUMBER(11) NULL ,
172
+"DEL_FLAG" NUMBER(11) NULL
173
+)
174
+LOGGING
175
+NOCOMPRESS
176
+NOCACHE
177
+
178
+;
179
+COMMENT ON COLUMN "K_QUARTZ"."QUARTZ_ID" IS '任务ID';
180
+COMMENT ON COLUMN "K_QUARTZ"."QUARTZ_DESCRIPTION" IS '任务描述';
181
+COMMENT ON COLUMN "K_QUARTZ"."QUARTZ_CRON" IS '定时策略';
182
+COMMENT ON COLUMN "K_QUARTZ"."ADD_TIME" IS '添加时间';
183
+COMMENT ON COLUMN "K_QUARTZ"."ADD_USER" IS '添加者';
184
+COMMENT ON COLUMN "K_QUARTZ"."EDIT_TIME" IS '编辑时间';
185
+COMMENT ON COLUMN "K_QUARTZ"."EDIT_USER" IS '编辑者';
186
+COMMENT ON COLUMN "K_QUARTZ"."DEL_FLAG" IS '是否删除(1:存在;0:删除)';
187
+
188
+-- ----------------------------
189
+-- Records of K_QUARTZ
190
+-- ----------------------------
191
+INSERT INTO "K_QUARTZ" VALUES ('1', '立即执行一次', null, TO_DATE('2017-05-27 14:44:13', 'YYYY-MM-DD HH24:MI:SS'), '1', TO_DATE('2017-05-27 14:44:13', 'YYYY-MM-DD HH24:MI:SS'), null, '1');
192
+INSERT INTO "K_QUARTZ" VALUES ('2', '每周一0点执行一次', '0 0 0 ? * 2', TO_DATE('2017-05-27 14:56:38', 'YYYY-MM-DD HH24:MI:SS'), '1', TO_DATE('2017-05-27 14:56:38', 'YYYY-MM-DD HH24:MI:SS'), null, '1');
193
+INSERT INTO "K_QUARTZ" VALUES ('3', '每月1日0点执行一次', '0 0 0 1 * ?', TO_DATE('2017-05-27 14:56:38', 'YYYY-MM-DD HH24:MI:SS'), '1', TO_DATE('2017-05-27 14:56:38', 'YYYY-MM-DD HH24:MI:SS'), null, '1');
194
+INSERT INTO "K_QUARTZ" VALUES ('4', '每日0点执行一次', '0 0 0 * * ?', TO_DATE('2017-05-27 14:44:13', 'YYYY-MM-DD HH24:MI:SS'), '1', TO_DATE('2017-05-27 14:44:15', 'YYYY-MM-DD HH24:MI:SS'), null, '1');
195
+INSERT INTO "K_QUARTZ" VALUES ('31', '每分钟执行一次', '0 * * * * ?', TO_DATE('2018-10-16 14:12:44', 'YYYY-MM-DD HH24:MI:SS'), '6', TO_DATE('2018-10-16 14:12:44', 'YYYY-MM-DD HH24:MI:SS'), '6', '1');
196
+
197
+-- ----------------------------
198
+-- Table structure for K_REPOSITORY
199
+-- ----------------------------
200
+CREATE TABLE "K_REPOSITORY" (
201
+"REPOSITORY_ID" NUMBER(11) NOT NULL ,
202
+"REPOSITORY_NAME" NVARCHAR2(50) NULL ,
203
+"REPOSITORY_USERNAME" NVARCHAR2(50) NULL ,
204
+"REPOSITORY_PASSWORD" NVARCHAR2(50) NULL ,
205
+"REPOSITORY_TYPE" NVARCHAR2(10) NULL ,
206
+"DATABASE_ACCESS" NVARCHAR2(10) NULL ,
207
+"DATABASE_HOST" NVARCHAR2(50) NULL ,
208
+"DATABASE_PORT" NVARCHAR2(10) NULL ,
209
+"DATABASE_NAME" NVARCHAR2(20) NULL ,
210
+"DATABASE_USERNAME" NVARCHAR2(50) NULL ,
211
+"DATABASE_PASSWORD" NVARCHAR2(50) NULL ,
212
+"ADD_TIME" DATE NULL ,
213
+"ADD_USER" NUMBER(11) NULL ,
214
+"EDIT_TIME" DATE NULL ,
215
+"EDIT_USER" NUMBER(11) NULL ,
216
+"DEL_FLAG" NUMBER(11) NULL
217
+)
218
+LOGGING
219
+NOCOMPRESS
220
+NOCACHE
221
+
222
+;
223
+COMMENT ON COLUMN "K_REPOSITORY"."REPOSITORY_ID" IS 'ID';
224
+COMMENT ON COLUMN "K_REPOSITORY"."REPOSITORY_NAME" IS '资源库名称';
225
+COMMENT ON COLUMN "K_REPOSITORY"."REPOSITORY_USERNAME" IS '登录用户名';
226
+COMMENT ON COLUMN "K_REPOSITORY"."REPOSITORY_PASSWORD" IS '登录密码';
227
+COMMENT ON COLUMN "K_REPOSITORY"."REPOSITORY_TYPE" IS '资源库数据库类型(MYSQL、ORACLE)';
228
+COMMENT ON COLUMN "K_REPOSITORY"."DATABASE_ACCESS" IS '资源库数据库访问模式("Native", "ODBC", "OCI", "Plugin", "JNDI")';
229
+COMMENT ON COLUMN "K_REPOSITORY"."DATABASE_HOST" IS '资源库数据库主机名或者IP地址';
230
+COMMENT ON COLUMN "K_REPOSITORY"."DATABASE_PORT" IS '资源库数据库端口号';
231
+COMMENT ON COLUMN "K_REPOSITORY"."DATABASE_NAME" IS '资源库数据库名称';
232
+COMMENT ON COLUMN "K_REPOSITORY"."DATABASE_USERNAME" IS '数据库登录账号';
233
+COMMENT ON COLUMN "K_REPOSITORY"."DATABASE_PASSWORD" IS '数据库登录密码';
234
+COMMENT ON COLUMN "K_REPOSITORY"."ADD_TIME" IS '添加时间';
235
+COMMENT ON COLUMN "K_REPOSITORY"."ADD_USER" IS '添加者';
236
+COMMENT ON COLUMN "K_REPOSITORY"."EDIT_TIME" IS '编辑时间';
237
+COMMENT ON COLUMN "K_REPOSITORY"."EDIT_USER" IS '编辑者';
238
+COMMENT ON COLUMN "K_REPOSITORY"."DEL_FLAG" IS '是否删除(1:存在;0:删除)';
239
+
240
+-- ----------------------------
241
+-- Records of K_REPOSITORY
242
+-- ----------------------------
243
+
244
+-- ----------------------------
245
+-- Table structure for K_REPOSITORY_TYPE
246
+-- ----------------------------
247
+CREATE TABLE "K_REPOSITORY_TYPE" (
248
+"REPOSITORY_TYPE_ID" NUMBER(11) NOT NULL ,
249
+"REPOSITORY_TYPE_CODE" NVARCHAR2(30) NULL ,
250
+"REPOSITORY_TYPE_DES" NVARCHAR2(100) NULL
251
+)
252
+LOGGING
253
+NOCOMPRESS
254
+NOCACHE
255
+
256
+;
257
+
258
+-- ----------------------------
259
+-- Records of K_REPOSITORY_TYPE
260
+-- ----------------------------
261
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('1', 'INGRES', 'Ingres');
262
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('2', 'INTERBASE', 'Borland Interbase');
263
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('3', 'INFOBRIGHT', 'Infobright');
264
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('4', 'ORACLE', 'Oracle');
265
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('5', 'EXTENDB', 'ExtenDB');
266
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('6', 'MSACCESS', 'MS Access');
267
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('7', 'SYBASE', 'Sybase');
268
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('8', 'PALO', 'Palo MOLAP Server');
269
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('9', 'INFORMIX', 'Informix');
270
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('10', 'LucidDB', 'LucidDB');
271
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('11', 'TERADATA', 'Teradata');
272
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('12', 'UNIVERSE', 'UniVerse database');
273
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('13', 'MONETDB', 'MonetDB');
274
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('14', 'CACHE', 'Intersystems Cache');
275
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('15', 'MSSQL', 'MS SQL Server');
276
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('16', 'KettleThin', 'Pentaho Data Services');
277
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('17', 'GREENPLUM', 'Greenplum');
278
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('18', 'GENERIC', 'Generic database');
279
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('19', 'IMPALA', 'Impala');
280
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('20', 'SQLITE', 'SQLite');
281
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('21', 'REMEDY-AR-SYSTEM', 'Remedy Action Request System');
282
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('22', 'MONDRIAN', 'Native Mondrian');
283
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('23', 'HIVE2', 'Hadoop Hive 2');
284
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('24', 'NETEZZA', 'Netezza');
285
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('25', 'VERTICA5', 'Vertica 5+');
286
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('26', 'POSTGRESQL', 'PostgreSQL');
287
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('27', 'EXASOL4', 'Exasol 4');
288
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('28', 'HYPERSONIC', 'Hypersonic');
289
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('29', 'AS/400', 'AS/400');
290
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('30', 'ORACLERDB', 'Oracle RDB');
291
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('31', 'DBASE', 'dBase III, IV or 5');
292
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('32', 'IMPALASIMBA', 'Cloudera Impala');
293
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('33', 'KINGBASEES', 'KingbaseES');
294
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('34', 'SAPR3', 'SAP ERP System');
295
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('35', 'SQLBASE', 'Gupta SQL Base');
296
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('36', 'DERBY', 'Apache Derby');
297
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('37', 'VERTICA', 'Vertica');
298
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('38', 'INFINIDB', 'Calpont InfiniDB');
299
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('39', 'HIVE', 'Hadoop Hive');
300
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('40', 'MYSQL', 'MySQL');
301
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('41', 'MSSQLNATIVE', 'MS SQL Server (Native)');
302
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('42', 'H2', 'H2');
303
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('43', 'SAPDB', 'MaxDB (SAP DB)');
304
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('44', 'SPARKSIMBA', 'SparkSQL');
305
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('45', 'VECTORWISE', 'Ingres VectorWise');
306
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('46', 'DB2', 'IBM DB2');
307
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('47', 'NEOVIEW', 'Neoview');
308
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('48', 'SYBASEIQ', 'SybaseIQ');
309
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('49', 'REDSHIFT', 'Redshift');
310
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('50', 'FIREBIRD', 'Firebird SQL');
311
+INSERT INTO "K_REPOSITORY_TYPE" VALUES ('51', 'OpenERPDatabaseMeta', 'OpenERP Server');
312
+
313
+-- ----------------------------
314
+-- Table structure for K_TRANS
315
+-- ----------------------------
316
+CREATE TABLE "K_TRANS" (
317
+"TRANS_ID" NUMBER(11) NOT NULL ,
318
+"CATEGORY_ID" NUMBER(11) NULL ,
319
+"TRANS_NAME" NVARCHAR2(50) NULL ,
320
+"TRANS_DESCRIPTION" NVARCHAR2(500) NULL ,
321
+"TRANS_TYPE" NUMBER(11) NULL ,
322
+"TRANS_PATH" NVARCHAR2(200) NULL ,
323
+"TRANS_REPOSITORY_ID" NUMBER(11) NULL ,
324
+"TRANS_QUARTZ" NUMBER(11) NULL ,
325
+"TRANS_RECORD" NUMBER(11) NULL ,
326
+"TRANS_LOG_LEVEL" NVARCHAR2(10) NULL ,
327
+"TRANS_STATUS" NUMBER(11) NULL ,
328
+"ADD_TIME" DATE NULL ,
329
+"ADD_USER" NUMBER(11) NULL ,
330
+"EDIT_TIME" DATE NULL ,
331
+"EDIT_USER" NUMBER(11) NULL ,
332
+"DEL_FLAG" NUMBER(11) NULL
333
+)
334
+LOGGING
335
+NOCOMPRESS
336
+NOCACHE
337
+
338
+;
339
+COMMENT ON COLUMN "K_TRANS"."TRANS_ID" IS '转换ID';
340
+COMMENT ON COLUMN "K_TRANS"."TRANS_NAME" IS '转换名称';
341
+COMMENT ON COLUMN "K_TRANS"."TRANS_DESCRIPTION" IS '转换描述';
342
+COMMENT ON COLUMN "K_TRANS"."TRANS_TYPE" IS '1:数据库资源库;2:上传的文件';
343
+COMMENT ON COLUMN "K_TRANS"."TRANS_PATH" IS '转换保存路径(可以是资源库中的路径也可以是服务器中保存作业文件的路径)';
344
+COMMENT ON COLUMN "K_TRANS"."TRANS_REPOSITORY_ID" IS '转换的资源库ID';
345
+COMMENT ON COLUMN "K_TRANS"."TRANS_QUARTZ" IS '定时策略(外键ID)';
346
+COMMENT ON COLUMN "K_TRANS"."TRANS_RECORD" IS '转换执行记录(外键ID)';
347
+COMMENT ON COLUMN "K_TRANS"."TRANS_LOG_LEVEL" IS '日志级别(basic,detail,error,debug,minimal,rowlevel)';
348
+COMMENT ON COLUMN "K_TRANS"."TRANS_STATUS" IS '状态(1:正在运行;2:已停止)';
349
+COMMENT ON COLUMN "K_TRANS"."ADD_TIME" IS '添加时间';
350
+COMMENT ON COLUMN "K_TRANS"."ADD_USER" IS '添加者';
351
+COMMENT ON COLUMN "K_TRANS"."EDIT_TIME" IS '编辑时间';
352
+COMMENT ON COLUMN "K_TRANS"."EDIT_USER" IS '编辑者';
353
+COMMENT ON COLUMN "K_TRANS"."DEL_FLAG" IS '是否删除(1:存在;0:删除)';
354
+
355
+-- ----------------------------
356
+-- Records of K_TRANS
357
+-- ----------------------------
358
+
359
+-- ----------------------------
360
+-- Table structure for K_TRANS_MONITOR
361
+-- ----------------------------
362
+CREATE TABLE "K_TRANS_MONITOR" (
363
+"MONITOR_ID" NUMBER(11) NOT NULL ,
364
+"MONITOR_TRANS" NUMBER(11) NULL ,
365
+"MONITOR_SUCCESS" NUMBER(11) NULL ,
366
+"MONITOR_FAIL" NUMBER(11) NULL ,
367
+"ADD_USER" NUMBER(11) NULL ,
368
+"MONITOR_STATUS" NUMBER(11) NULL ,
369
+"RUN_STATUS" NCLOB NULL ,
370
+"LAST_EXECUTE_TIME" DATE NULL ,
371
+"NEXT_EXECUTE_TIME" DATE NULL
372
+)
373
+LOGGING
374
+NOCOMPRESS
375
+NOCACHE
376
+
377
+;
378
+COMMENT ON COLUMN "K_TRANS_MONITOR"."MONITOR_ID" IS '监控转换ID';
379
+COMMENT ON COLUMN "K_TRANS_MONITOR"."MONITOR_TRANS" IS '监控的转换的ID';
380
+COMMENT ON COLUMN "K_TRANS_MONITOR"."MONITOR_SUCCESS" IS '成功次数';
381
+COMMENT ON COLUMN "K_TRANS_MONITOR"."MONITOR_FAIL" IS '失败次数';
382
+COMMENT ON COLUMN "K_TRANS_MONITOR"."ADD_USER" IS '添加人';
383
+COMMENT ON COLUMN "K_TRANS_MONITOR"."MONITOR_STATUS" IS '监控状态(是否启动,1:启动;2:停止)';
384
+COMMENT ON COLUMN "K_TRANS_MONITOR"."RUN_STATUS" IS '运行状态(起始时间-结束时间,起始时间-结束时间……)';
385
+
386
+-- ----------------------------
387
+-- Records of K_TRANS_MONITOR
388
+-- ----------------------------
389
+
390
+-- ----------------------------
391
+-- Table structure for K_TRANS_RECORD
392
+-- ----------------------------
393
+CREATE TABLE "K_TRANS_RECORD" (
394
+"RECORD_ID" NUMBER(11) NOT NULL ,
395
+"RECORD_TRANS" NUMBER(11) NULL ,
396
+"START_TIME" DATE NULL ,
397
+"STOP_TIME" DATE NULL ,
398
+"RECORD_STATUS" NUMBER(11) NULL ,
399
+"LOG_FILE_PATH" NVARCHAR2(100) NULL ,
400
+"ADD_USER" NUMBER(11) NULL
401
+)
402
+LOGGING
403
+NOCOMPRESS
404
+NOCACHE
405
+
406
+;
407
+COMMENT ON COLUMN "K_TRANS_RECORD"."RECORD_ID" IS '转换记录ID';
408
+COMMENT ON COLUMN "K_TRANS_RECORD"."RECORD_TRANS" IS '转换ID';
409
+COMMENT ON COLUMN "K_TRANS_RECORD"."START_TIME" IS '启动时间';
410
+COMMENT ON COLUMN "K_TRANS_RECORD"."STOP_TIME" IS '停止时间';
411
+COMMENT ON COLUMN "K_TRANS_RECORD"."RECORD_STATUS" IS '任务执行结果(1:成功;2:失败)';
412
+COMMENT ON COLUMN "K_TRANS_RECORD"."LOG_FILE_PATH" IS '转换日志记录文件保存位置';
413
+COMMENT ON COLUMN "K_TRANS_RECORD"."ADD_USER" IS '添加人';
414
+
415
+-- ----------------------------
416
+-- Records of K_TRANS_RECORD
417
+-- ----------------------------
418
+
419
+-- ----------------------------
420
+-- Table structure for K_USER
421
+-- ----------------------------
422
+CREATE TABLE "K_USER" (
423
+"U_ID" NUMBER(11) NOT NULL ,
424
+"U_NICKNAME" NVARCHAR2(50) NULL ,
425
+"U_EMAIL" NVARCHAR2(30) NULL ,
426
+"U_PHONE" NVARCHAR2(50) NULL ,
427
+"U_ACCOUNT" NVARCHAR2(50) NULL ,
428
+"U_PASSWORD" NVARCHAR2(50) NULL ,
429
+"ADD_TIME" DATE NULL ,
430
+"ADD_USER" NUMBER(11) NULL ,
431
+"EDIT_TIME" DATE NULL ,
432
+"EDIT_USER" NUMBER(11) NULL ,
433
+"DEL_FLAG" NUMBER(11) NULL
434
+)
435
+LOGGING
436
+NOCOMPRESS
437
+NOCACHE
438
+
439
+;
440
+COMMENT ON COLUMN "K_USER"."U_ID" IS '用户ID';
441
+COMMENT ON COLUMN "K_USER"."U_NICKNAME" IS '用户昵称';
442
+COMMENT ON COLUMN "K_USER"."U_EMAIL" IS '用户邮箱';
443
+COMMENT ON COLUMN "K_USER"."U_PHONE" IS '用于电话';
444
+COMMENT ON COLUMN "K_USER"."U_ACCOUNT" IS '用户账号';
445
+COMMENT ON COLUMN "K_USER"."U_PASSWORD" IS '用户密码';
446
+COMMENT ON COLUMN "K_USER"."ADD_TIME" IS '添加时间';
447
+COMMENT ON COLUMN "K_USER"."ADD_USER" IS '添加者';
448
+COMMENT ON COLUMN "K_USER"."EDIT_TIME" IS '编辑时间';
449
+COMMENT ON COLUMN "K_USER"."EDIT_USER" IS '编辑者';
450
+COMMENT ON COLUMN "K_USER"."DEL_FLAG" IS '是否删除(1:存在;0:删除)';
451
+
452
+-- ----------------------------
453
+-- Records of K_USER
454
+-- ----------------------------
455
+INSERT INTO "K_USER" VALUES ('1', 'admin', null, null, 'admin', 'b1276925a59fd8d9e1a53c10637f271d', null, null, null, null, '1');
456
+
457
+-- ----------------------------
458
+-- Indexes structure for table K_CATEGORY
459
+-- ----------------------------
460
+
461
+-- ----------------------------
462
+-- Checks structure for table K_CATEGORY
463
+-- ----------------------------
464
+ALTER TABLE "K_CATEGORY" ADD CHECK ("CATEGORY_ID" IS NOT NULL);
465
+
466
+-- ----------------------------
467
+-- Primary Key structure for table K_CATEGORY
468
+-- ----------------------------
469
+ALTER TABLE "K_CATEGORY" ADD PRIMARY KEY ("CATEGORY_ID");
470
+
471
+-- ----------------------------
472
+-- Indexes structure for table K_JOB
473
+-- ----------------------------
474
+
475
+-- ----------------------------
476
+-- Checks structure for table K_JOB
477
+-- ----------------------------
478
+ALTER TABLE "K_JOB" ADD CHECK ("JOB_ID" IS NOT NULL);
479
+
480
+-- ----------------------------
481
+-- Primary Key structure for table K_JOB
482
+-- ----------------------------
483
+ALTER TABLE "K_JOB" ADD PRIMARY KEY ("JOB_ID");
484
+
485
+-- ----------------------------
486
+-- Indexes structure for table K_JOB_MONITOR
487
+-- ----------------------------
488
+
489
+-- ----------------------------
490
+-- Checks structure for table K_JOB_MONITOR
491
+-- ----------------------------
492
+ALTER TABLE "K_JOB_MONITOR" ADD CHECK ("MONITOR_ID" IS NOT NULL);
493
+
494
+-- ----------------------------
495
+-- Primary Key structure for table K_JOB_MONITOR
496
+-- ----------------------------
497
+ALTER TABLE "K_JOB_MONITOR" ADD PRIMARY KEY ("MONITOR_ID");
498
+
499
+-- ----------------------------
500
+-- Indexes structure for table K_JOB_RECORD
501
+-- ----------------------------
502
+
503
+-- ----------------------------
504
+-- Checks structure for table K_JOB_RECORD
505
+-- ----------------------------
506
+ALTER TABLE "K_JOB_RECORD" ADD CHECK ("RECORD_ID" IS NOT NULL);
507
+
508
+-- ----------------------------
509
+-- Primary Key structure for table K_JOB_RECORD
510
+-- ----------------------------
511
+ALTER TABLE "K_JOB_RECORD" ADD PRIMARY KEY ("RECORD_ID");
512
+
513
+-- ----------------------------
514
+-- Indexes structure for table K_QUARTZ
515
+-- ----------------------------
516
+
517
+-- ----------------------------
518
+-- Checks structure for table K_QUARTZ
519
+-- ----------------------------
520
+ALTER TABLE "K_QUARTZ" ADD CHECK ("QUARTZ_ID" IS NOT NULL);
521
+
522
+-- ----------------------------
523
+-- Primary Key structure for table K_QUARTZ
524
+-- ----------------------------
525
+ALTER TABLE "K_QUARTZ" ADD PRIMARY KEY ("QUARTZ_ID");
526
+
527
+-- ----------------------------
528
+-- Indexes structure for table K_REPOSITORY
529
+-- ----------------------------
530
+
531
+-- ----------------------------
532
+-- Checks structure for table K_REPOSITORY
533
+-- ----------------------------
534
+ALTER TABLE "K_REPOSITORY" ADD CHECK ("REPOSITORY_ID" IS NOT NULL);
535
+
536
+-- ----------------------------
537
+-- Primary Key structure for table K_REPOSITORY
538
+-- ----------------------------
539
+ALTER TABLE "K_REPOSITORY" ADD PRIMARY KEY ("REPOSITORY_ID");
540
+
541
+-- ----------------------------
542
+-- Indexes structure for table K_REPOSITORY_TYPE
543
+-- ----------------------------
544
+
545
+-- ----------------------------
546
+-- Checks structure for table K_REPOSITORY_TYPE
547
+-- ----------------------------
548
+ALTER TABLE "K_REPOSITORY_TYPE" ADD CHECK ("REPOSITORY_TYPE_ID" IS NOT NULL);
549
+
550
+-- ----------------------------
551
+-- Primary Key structure for table K_REPOSITORY_TYPE
552
+-- ----------------------------
553
+ALTER TABLE "K_REPOSITORY_TYPE" ADD PRIMARY KEY ("REPOSITORY_TYPE_ID");
554
+
555
+-- ----------------------------
556
+-- Indexes structure for table K_TRANS
557
+-- ----------------------------
558
+
559
+-- ----------------------------
560
+-- Checks structure for table K_TRANS
561
+-- ----------------------------
562
+ALTER TABLE "K_TRANS" ADD CHECK ("TRANS_ID" IS NOT NULL);
563
+
564
+-- ----------------------------
565
+-- Primary Key structure for table K_TRANS
566
+-- ----------------------------
567
+ALTER TABLE "K_TRANS" ADD PRIMARY KEY ("TRANS_ID");
568
+
569
+-- ----------------------------
570
+-- Indexes structure for table K_TRANS_MONITOR
571
+-- ----------------------------
572
+
573
+-- ----------------------------
574
+-- Checks structure for table K_TRANS_MONITOR
575
+-- ----------------------------
576
+ALTER TABLE "K_TRANS_MONITOR" ADD CHECK ("MONITOR_ID" IS NOT NULL);
577
+
578
+-- ----------------------------
579
+-- Primary Key structure for table K_TRANS_MONITOR
580
+-- ----------------------------
581
+ALTER TABLE "K_TRANS_MONITOR" ADD PRIMARY KEY ("MONITOR_ID");
582
+
583
+-- ----------------------------
584
+-- Indexes structure for table K_TRANS_RECORD
585
+-- ----------------------------
586
+
587
+-- ----------------------------
588
+-- Checks structure for table K_TRANS_RECORD
589
+-- ----------------------------
590
+ALTER TABLE "K_TRANS_RECORD" ADD CHECK ("RECORD_ID" IS NOT NULL);
591
+
592
+-- ----------------------------
593
+-- Primary Key structure for table K_TRANS_RECORD
594
+-- ----------------------------
595
+ALTER TABLE "K_TRANS_RECORD" ADD PRIMARY KEY ("RECORD_ID");
596
+
597
+-- ----------------------------
598
+-- Indexes structure for table K_USER
599
+-- ----------------------------
600
+
601
+-- ----------------------------
602
+-- Checks structure for table K_USER
603
+-- ----------------------------
604
+ALTER TABLE "K_USER" ADD CHECK ("U_ID" IS NOT NULL);
605
+
606
+-- ----------------------------
607
+-- Primary Key structure for table K_USER
608
+-- ----------------------------
609
+ALTER TABLE "K_USER" ADD PRIMARY KEY ("U_ID");
610
+
611
+
612
+-- 增加自增序列
613
+CREATE SEQUENCE CATEGORY_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
614
+CREATE SEQUENCE JOB_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
615
+CREATE SEQUENCE JOB_MONITOR_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
616
+CREATE SEQUENCE JOB_RECORD_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
617
+CREATE SEQUENCE QUARTZ_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
618
+CREATE SEQUENCE REPOSITORY_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
619
+CREATE SEQUENCE REPOSITORY_TYPE_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
620
+CREATE SEQUENCE TRANS_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
621
+CREATE SEQUENCE TRANS_MONITOR_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
622
+CREATE SEQUENCE TRANS_RECORD_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;
623
+CREATE SEQUENCE USER_ID_SEQ start with 1 maxvalue 9999999999 increment by 1 NOCYCLE NOCACHE;

+ 277 - 0
kettle-scheduler.sql

@@ -0,0 +1,277 @@
1
+
2
+
3
+SET FOREIGN_KEY_CHECKS=0;
4
+
5
+-- ----------------------------
6
+-- Table structure for `k_category`
7
+-- ----------------------------
8
+DROP TABLE IF EXISTS `k_category`;
9
+CREATE TABLE `k_category` (
10
+  `category_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '分类ID',
11
+  `category_name` varchar(50) DEFAULT NULL COMMENT '分类名称',
12
+  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
13
+  `add_user` int(11) DEFAULT NULL COMMENT '添加者',
14
+  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
15
+  `edit_user` int(11) DEFAULT NULL COMMENT '编辑者',
16
+  `del_flag` int(11) DEFAULT NULL COMMENT '是否删除(1:存在;0:删除)',
17
+  PRIMARY KEY (`category_id`)
18
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
19
+
20
+
21
+-- ----------------------------
22
+-- Table structure for `k_job`
23
+-- ----------------------------
24
+DROP TABLE IF EXISTS `k_job`;
25
+CREATE TABLE `k_job` (
26
+  `job_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '作业ID',
27
+  `category_id` int(11) DEFAULT NULL,
28
+  `job_name` varchar(50) DEFAULT NULL COMMENT '作业名称',
29
+  `job_description` varchar(500) DEFAULT NULL COMMENT '任务描述',
30
+  `job_type` int(11) DEFAULT NULL COMMENT '1:数据库资源库;2:上传的文件',
31
+  `job_path` varchar(200) DEFAULT NULL COMMENT '作业保存路径(可以是资源库中的路径也可以是服务器中保存作业文件的路径)',
32
+  `job_repository_id` int(11) DEFAULT NULL COMMENT '作业的资源库ID',
33
+  `job_quartz` int(11) DEFAULT '1' COMMENT '定时策略(外键ID)',
34
+  `job_record` int(11) DEFAULT NULL COMMENT '作业执行记录(外键ID)',
35
+  `job_log_level` varchar(10) DEFAULT NULL COMMENT '日志级别(basic,detail,error,debug,minimal,rowlevel)',
36
+  `job_status` int(11) DEFAULT NULL COMMENT '状态(1:正在运行;2:已停止)',
37
+  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
38
+  `add_user` int(11) DEFAULT NULL COMMENT '添加者',
39
+  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
40
+  `edit_user` int(11) DEFAULT NULL COMMENT '编辑者',
41
+  `del_flag` int(11) DEFAULT NULL COMMENT '是否删除(1:存在;0:删除)',
42
+  PRIMARY KEY (`job_id`)
43
+) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
44
+
45
+
46
+-- ----------------------------
47
+-- Table structure for `k_job_monitor`
48
+-- ----------------------------
49
+DROP TABLE IF EXISTS `k_job_monitor`;
50
+CREATE TABLE `k_job_monitor` (
51
+  `monitor_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '监控作业ID',
52
+  `monitor_job` int(11) DEFAULT NULL COMMENT '监控的作业ID',
53
+  `monitor_success` int(11) DEFAULT NULL COMMENT '成功次数',
54
+  `monitor_fail` int(11) DEFAULT NULL COMMENT '失败次数',
55
+  `add_user` int(11) DEFAULT NULL COMMENT '添加人',
56
+  `monitor_status` int(11) DEFAULT NULL COMMENT '监控状态(是否启动,1:启动;2:停止)',
57
+  `run_status` text COMMENT '运行状态(起始时间-结束时间,起始时间-结束时间……)',
58
+  `last_execute_time` datetime DEFAULT NULL,
59
+  `next_execute_time` datetime DEFAULT NULL,
60
+  PRIMARY KEY (`monitor_id`)
61
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
62
+
63
+
64
+-- ----------------------------
65
+-- Table structure for `k_job_record`
66
+-- ----------------------------
67
+DROP TABLE IF EXISTS `k_job_record`;
68
+CREATE TABLE `k_job_record` (
69
+  `record_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '作业记录ID',
70
+  `record_job` int(11) DEFAULT NULL COMMENT '作业ID',
71
+  `start_time` datetime DEFAULT NULL COMMENT '启动时间',
72
+  `stop_time` datetime DEFAULT NULL COMMENT '停止时间',
73
+  `record_status` int(11) DEFAULT NULL COMMENT '任务执行结果(1:成功;2:失败)',
74
+  `log_file_path` varchar(100) DEFAULT NULL COMMENT '作业日志记录文件保存位置',
75
+  `add_user` int(11) DEFAULT NULL COMMENT '添加人',
76
+  PRIMARY KEY (`record_id`)
77
+) ENGINE=InnoDB AUTO_INCREMENT=390 DEFAULT CHARSET=utf8;
78
+
79
+
80
+-- ----------------------------
81
+-- Table structure for `k_quartz`
82
+-- ----------------------------
83
+DROP TABLE IF EXISTS `k_quartz`;
84
+CREATE TABLE `k_quartz` (
85
+  `quartz_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '任务ID',
86
+  `quartz_description` varchar(500) DEFAULT NULL COMMENT '任务描述',
87
+  `quartz_cron` varchar(100) DEFAULT NULL COMMENT '定时策略',
88
+  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
89
+  `add_user` int(11) DEFAULT NULL COMMENT '添加者',
90
+  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
91
+  `edit_user` int(11) DEFAULT NULL COMMENT '编辑者',
92
+  `del_flag` int(11) DEFAULT NULL COMMENT '是否删除(1:存在;0:删除)',
93
+  PRIMARY KEY (`quartz_id`)
94
+) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;
95
+
96
+-- ----------------------------
97
+-- Records of k_quartz
98
+-- ----------------------------
99
+INSERT INTO `k_quartz` VALUES ('1', '立即执行一次', null, '2017-05-27 14:44:13', '1', '2017-05-27 14:44:13', null, '1');
100
+INSERT INTO `k_quartz` VALUES ('2', '每周一0点执行一次', '0 0 0 ? * 2', '2017-05-27 14:56:38', '1', '2017-05-27 14:56:38', null, '1');
101
+INSERT INTO `k_quartz` VALUES ('3', '每月1日0点执行一次', '0 0 0 1 * ?', '2017-05-27 14:56:38', '1', '2017-05-27 14:56:38', null, '1');
102
+INSERT INTO `k_quartz` VALUES ('4', '每日0点执行一次', '0 0 0 * * ?', '2017-05-27 14:44:13', '1', '2017-05-27 14:44:15', null, '1');
103
+INSERT INTO `k_quartz` VALUES ('31', '每分钟执行一次', '0 * * * * ?', '2018-10-16 14:12:44', '6', '2018-10-16 14:12:44', '6', '1');
104
+
105
+-- ----------------------------
106
+-- Table structure for `k_repository`
107
+-- ----------------------------
108
+DROP TABLE IF EXISTS `k_repository`;
109
+CREATE TABLE `k_repository` (
110
+  `repository_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
111
+  `repository_name` varchar(50) DEFAULT NULL COMMENT '资源库名称',
112
+  `repository_username` varchar(50) DEFAULT NULL COMMENT '登录用户名',
113
+  `repository_password` varchar(50) DEFAULT NULL COMMENT '登录密码',
114
+  `repository_type` varchar(10) DEFAULT NULL COMMENT '资源库数据库类型(MYSQL、ORACLE)',
115
+  `database_access` varchar(10) DEFAULT NULL COMMENT '资源库数据库访问模式("Native", "ODBC", "OCI", "Plugin", "JNDI")',
116
+  `database_host` varchar(50) DEFAULT NULL COMMENT '资源库数据库主机名或者IP地址',
117
+  `database_port` varchar(10) DEFAULT NULL COMMENT '资源库数据库端口号',
118
+  `database_name` varchar(20) DEFAULT NULL COMMENT '资源库数据库名称',
119
+  `database_username` varchar(50) DEFAULT NULL COMMENT '数据库登录账号',
120
+  `database_password` varchar(50) DEFAULT NULL COMMENT '数据库登录密码',
121
+  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
122
+  `add_user` int(11) DEFAULT NULL COMMENT '添加者',
123
+  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
124
+  `edit_user` int(11) DEFAULT NULL COMMENT '编辑者',
125
+  `del_flag` int(11) DEFAULT NULL COMMENT '是否删除(1:存在;0:删除)',
126
+  PRIMARY KEY (`repository_id`)
127
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
128
+
129
+
130
+-- ----------------------------
131
+-- Table structure for `k_repository_type`
132
+-- ----------------------------
133
+DROP TABLE IF EXISTS `k_repository_type`;
134
+CREATE TABLE `k_repository_type` (
135
+  `repository_type_id` int(11) NOT NULL,
136
+  `repository_type_code` varchar(30) DEFAULT NULL,
137
+  `repository_type_des` varchar(100) DEFAULT NULL,
138
+  PRIMARY KEY (`repository_type_id`)
139
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
140
+
141
+-- ----------------------------
142
+-- Records of k_repository_type
143
+-- ----------------------------
144
+INSERT INTO `k_repository_type` VALUES ('1', 'INGRES', 'Ingres');
145
+INSERT INTO `k_repository_type` VALUES ('2', 'INTERBASE', 'Borland Interbase');
146
+INSERT INTO `k_repository_type` VALUES ('3', 'INFOBRIGHT', 'Infobright');
147
+INSERT INTO `k_repository_type` VALUES ('4', 'ORACLE', 'Oracle');
148
+INSERT INTO `k_repository_type` VALUES ('5', 'EXTENDB', 'ExtenDB');
149
+INSERT INTO `k_repository_type` VALUES ('6', 'MSACCESS', 'MS Access');
150
+INSERT INTO `k_repository_type` VALUES ('7', 'SYBASE', 'Sybase');
151
+INSERT INTO `k_repository_type` VALUES ('8', 'PALO', 'Palo MOLAP Server');
152
+INSERT INTO `k_repository_type` VALUES ('9', 'INFORMIX', 'Informix');
153
+INSERT INTO `k_repository_type` VALUES ('10', 'LucidDB', 'LucidDB');
154
+INSERT INTO `k_repository_type` VALUES ('11', 'TERADATA', 'Teradata');
155
+INSERT INTO `k_repository_type` VALUES ('12', 'UNIVERSE', 'UniVerse database');
156
+INSERT INTO `k_repository_type` VALUES ('13', 'MONETDB', 'MonetDB');
157
+INSERT INTO `k_repository_type` VALUES ('14', 'CACHE', 'Intersystems Cache');
158
+INSERT INTO `k_repository_type` VALUES ('15', 'MSSQL', 'MS SQL Server');
159
+INSERT INTO `k_repository_type` VALUES ('16', 'KettleThin', 'Pentaho Data Services');
160
+INSERT INTO `k_repository_type` VALUES ('17', 'GREENPLUM', 'Greenplum');
161
+INSERT INTO `k_repository_type` VALUES ('18', 'GENERIC', 'Generic database');
162
+INSERT INTO `k_repository_type` VALUES ('19', 'IMPALA', 'Impala');
163
+INSERT INTO `k_repository_type` VALUES ('20', 'SQLITE', 'SQLite');
164
+INSERT INTO `k_repository_type` VALUES ('21', 'REMEDY-AR-SYSTEM', 'Remedy Action Request System');
165
+INSERT INTO `k_repository_type` VALUES ('22', 'MONDRIAN', 'Native Mondrian');
166
+INSERT INTO `k_repository_type` VALUES ('23', 'HIVE2', 'Hadoop Hive 2');
167
+INSERT INTO `k_repository_type` VALUES ('24', 'NETEZZA', 'Netezza');
168
+INSERT INTO `k_repository_type` VALUES ('25', 'VERTICA5', 'Vertica 5+');
169
+INSERT INTO `k_repository_type` VALUES ('26', 'POSTGRESQL', 'PostgreSQL');
170
+INSERT INTO `k_repository_type` VALUES ('27', 'EXASOL4', 'Exasol 4');
171
+INSERT INTO `k_repository_type` VALUES ('28', 'HYPERSONIC', 'Hypersonic');
172
+INSERT INTO `k_repository_type` VALUES ('29', 'AS/400', 'AS/400');
173
+INSERT INTO `k_repository_type` VALUES ('30', 'ORACLERDB', 'Oracle RDB');
174
+INSERT INTO `k_repository_type` VALUES ('31', 'DBASE', 'dBase III, IV or 5');
175
+INSERT INTO `k_repository_type` VALUES ('32', 'IMPALASIMBA', 'Cloudera Impala');
176
+INSERT INTO `k_repository_type` VALUES ('33', 'KINGBASEES', 'KingbaseES');
177
+INSERT INTO `k_repository_type` VALUES ('34', 'SAPR3', 'SAP ERP System');
178
+INSERT INTO `k_repository_type` VALUES ('35', 'SQLBASE', 'Gupta SQL Base');
179
+INSERT INTO `k_repository_type` VALUES ('36', 'DERBY', 'Apache Derby');
180
+INSERT INTO `k_repository_type` VALUES ('37', 'VERTICA', 'Vertica');
181
+INSERT INTO `k_repository_type` VALUES ('38', 'INFINIDB', 'Calpont InfiniDB');
182
+INSERT INTO `k_repository_type` VALUES ('39', 'HIVE', 'Hadoop Hive');
183
+INSERT INTO `k_repository_type` VALUES ('40', 'MYSQL', 'MySQL');
184
+INSERT INTO `k_repository_type` VALUES ('41', 'MSSQLNATIVE', 'MS SQL Server (Native)');
185
+INSERT INTO `k_repository_type` VALUES ('42', 'H2', 'H2');
186
+INSERT INTO `k_repository_type` VALUES ('43', 'SAPDB', 'MaxDB (SAP DB)');
187
+INSERT INTO `k_repository_type` VALUES ('44', 'SPARKSIMBA', 'SparkSQL');
188
+INSERT INTO `k_repository_type` VALUES ('45', 'VECTORWISE', 'Ingres VectorWise');
189
+INSERT INTO `k_repository_type` VALUES ('46', 'DB2', 'IBM DB2');
190
+INSERT INTO `k_repository_type` VALUES ('47', 'NEOVIEW', 'Neoview');
191
+INSERT INTO `k_repository_type` VALUES ('48', 'SYBASEIQ', 'SybaseIQ');
192
+INSERT INTO `k_repository_type` VALUES ('49', 'REDSHIFT', 'Redshift');
193
+INSERT INTO `k_repository_type` VALUES ('50', 'FIREBIRD', 'Firebird SQL');
194
+INSERT INTO `k_repository_type` VALUES ('51', 'OpenERPDatabaseMeta', 'OpenERP Server');
195
+
196
+-- ----------------------------
197
+-- Table structure for `k_trans`
198
+-- ----------------------------
199
+DROP TABLE IF EXISTS `k_trans`;
200
+CREATE TABLE `k_trans` (
201
+  `trans_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '转换ID',
202
+  `category_id` int(11) DEFAULT NULL,
203
+  `trans_name` varchar(50) DEFAULT NULL COMMENT '转换名称',
204
+  `trans_description` varchar(500) DEFAULT NULL COMMENT '转换描述',
205
+  `trans_type` int(11) DEFAULT NULL COMMENT '1:数据库资源库;2:上传的文件',
206
+  `trans_path` varchar(200) DEFAULT NULL COMMENT '转换保存路径(可以是资源库中的路径也可以是服务器中保存作业文件的路径)',
207
+  `trans_repository_id` int(11) DEFAULT NULL COMMENT '转换的资源库ID',
208
+  `trans_quartz` int(11) DEFAULT '1' COMMENT '定时策略(外键ID)',
209
+  `trans_record` int(11) DEFAULT NULL COMMENT '转换执行记录(外键ID)',
210
+  `trans_log_level` varchar(10) DEFAULT NULL COMMENT '日志级别(basic,detail,error,debug,minimal,rowlevel)',
211
+  `trans_status` int(11) DEFAULT NULL COMMENT '状态(1:正在运行;2:已停止)',
212
+  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
213
+  `add_user` int(11) DEFAULT NULL COMMENT '添加者',
214
+  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
215
+  `edit_user` int(11) DEFAULT NULL COMMENT '编辑者',
216
+  `del_flag` int(11) DEFAULT NULL COMMENT '是否删除(1:存在;0:删除)',
217
+  PRIMARY KEY (`trans_id`)
218
+) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
219
+
220
+
221
+-- ----------------------------
222
+-- Table structure for `k_trans_monitor`
223
+-- ----------------------------
224
+DROP TABLE IF EXISTS `k_trans_monitor`;
225
+CREATE TABLE `k_trans_monitor` (
226
+  `monitor_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '监控转换ID',
227
+  `monitor_trans` int(11) DEFAULT NULL COMMENT '监控的转换的ID',
228
+  `monitor_success` int(11) DEFAULT NULL COMMENT '成功次数',
229
+  `monitor_fail` int(11) DEFAULT NULL COMMENT '失败次数',
230
+  `add_user` int(11) DEFAULT NULL COMMENT '添加人',
231
+  `monitor_status` int(11) DEFAULT NULL COMMENT '监控状态(是否启动,1:启动;2:停止)',
232
+  `run_status` text COMMENT '运行状态(起始时间-结束时间,起始时间-结束时间……)',
233
+  `last_execute_time` datetime DEFAULT NULL,
234
+  `next_execute_time` datetime DEFAULT NULL,
235
+  PRIMARY KEY (`monitor_id`)
236
+) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
237
+
238
+
239
+-- ----------------------------
240
+-- Table structure for `k_trans_record`
241
+-- ----------------------------
242
+DROP TABLE IF EXISTS `k_trans_record`;
243
+CREATE TABLE `k_trans_record` (
244
+  `record_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '转换记录ID',
245
+  `record_trans` int(11) DEFAULT NULL COMMENT '转换ID',
246
+  `start_time` datetime DEFAULT NULL COMMENT '启动时间',
247
+  `stop_time` datetime DEFAULT NULL COMMENT '停止时间',
248
+  `record_status` int(11) DEFAULT NULL COMMENT '任务执行结果(1:成功;2:失败)',
249
+  `log_file_path` varchar(100) DEFAULT NULL COMMENT '转换日志记录文件保存位置',
250
+  `add_user` int(11) DEFAULT NULL COMMENT '添加人',
251
+  PRIMARY KEY (`record_id`)
252
+) ENGINE=InnoDB AUTO_INCREMENT=546 DEFAULT CHARSET=utf8;
253
+
254
+
255
+-- ----------------------------
256
+-- Table structure for `k_user`
257
+-- ----------------------------
258
+DROP TABLE IF EXISTS `k_user`;
259
+CREATE TABLE `k_user` (
260
+  `u_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
261
+  `u_nickname` varchar(50) DEFAULT NULL COMMENT '用户昵称',
262
+  `u_email` varchar(30) DEFAULT NULL COMMENT '用户邮箱',
263
+  `u_phone` varchar(50) DEFAULT NULL COMMENT '用于电话',
264
+  `u_account` varchar(50) DEFAULT NULL COMMENT '用户账号',
265
+  `u_password` varchar(50) DEFAULT NULL COMMENT '用户密码',
266
+  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
267
+  `add_user` int(11) DEFAULT NULL COMMENT '添加者',
268
+  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
269
+  `edit_user` int(11) DEFAULT NULL COMMENT '编辑者',
270
+  `del_flag` int(11) DEFAULT NULL COMMENT '是否删除(1:存在;0:删除)',
271
+  PRIMARY KEY (`u_id`)
272
+) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
273
+
274
+-- ----------------------------
275
+-- Records of k_user
276
+-- ----------------------------
277
+INSERT INTO `k_user` VALUES ('1', 'admin', null, null, 'admin', 'b1276925a59fd8d9e1a53c10637f271d', null, null, null, null, '1');

+ 353 - 0
pom.xml

@@ -0,0 +1,353 @@
1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+    <modelVersion>4.0.0</modelVersion>
4
+    <groupId>com.zhaxd</groupId>
5
+    <artifactId>kettle-scheduler</artifactId>
6
+    <version>0.0.1-SNAPSHOT</version>
7
+    <packaging>war</packaging>
8
+    <repositories>
9
+        <repository>
10
+            <id>pentaho</id>
11
+            <url>http://nexus.pentaho.org/content/groups/omni/</url>
12
+        </repository>
13
+    </repositories>
14
+    <build>
15
+        <finalName>ROOT</finalName>
16
+        <plugins>
17
+            <plugin>
18
+                <groupId>org.apache.maven.plugins</groupId>
19
+                <artifactId>maven-compiler-plugin</artifactId>
20
+                <version>3.5.1</version>
21
+                <configuration>
22
+                    <source>1.8</source>
23
+                    <target>1.8</target>
24
+                    <encoding>UTF-8</encoding>
25
+                </configuration>
26
+            </plugin>
27
+        </plugins>
28
+    </build>
29
+    <properties>
30
+        <java-version>1.8</java-version>
31
+        <junit-version>4.12</junit-version>
32
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
34
+        <org.springframework-version>4.3.1.RELEASE</org.springframework-version>
35
+        <beetlsql-version>2.10.18</beetlsql-version>
36
+        <mysql-connector-java-version>5.1.38</mysql-connector-java-version>
37
+        <druid-version>1.0.29</druid-version>
38
+        <commons-configuration.version>1.10</commons-configuration.version>
39
+        <commons.fileupload-version>1.3.2</commons.fileupload-version>
40
+        <commons-beanutils-core-version>1.8.3</commons-beanutils-core-version>
41
+        <commons-codec-version>1.10</commons-codec-version>
42
+        <json-lib-version>2.4</json-lib-version>
43
+        <javax.mail-version>1.5.6</javax.mail-version>
44
+        <jackson.databind-version>2.10.1</jackson.databind-version>
45
+        <kettle-version>8.2.0.0-342</kettle-version>
46
+        <quartz-version>2.2.1</quartz-version>
47
+        <dependency.hadoop-shims-api.revision>80.2017.10.00-28</dependency.hadoop-shims-api.revision>
48
+        <pentaho-big-data-plugin.version>8.0.0.0-28</pentaho-big-data-plugin.version>
49
+        <pdi-osgi-bridge.version>8.0.0.0-28</pdi-osgi-bridge.version>
50
+        <kafka-clients.version>0.10.2.1</kafka-clients.version>
51
+        <blueprints-core.version>2.6.0</blueprints-core.version>
52
+        <log4j.version>1.2.16</log4j.version>
53
+        <slf4j.version>1.6.1</slf4j.version>
54
+    </properties>
55
+
56
+    <dependencies>
57
+        <dependency>
58
+            <groupId>com.oracle</groupId>
59
+            <artifactId>ojdbc6</artifactId>
60
+            <version>11.2.0.1.0</version>
61
+        </dependency>
62
+        <!-- with spring -->
63
+        <dependency>
64
+            <groupId>org.springframework</groupId>
65
+            <artifactId>spring-core</artifactId>
66
+            <version>${org.springframework-version}</version>
67
+        </dependency>
68
+        <dependency>
69
+            <groupId>org.springframework</groupId>
70
+            <artifactId>spring-webmvc</artifactId>
71
+            <version>${org.springframework-version}</version>
72
+        </dependency>
73
+        <dependency>
74
+            <groupId>org.springframework</groupId>
75
+            <artifactId>spring-jdbc</artifactId>
76
+            <version>${org.springframework-version}</version>
77
+        </dependency>
78
+        <dependency>
79
+            <groupId>org.springframework</groupId>
80
+            <artifactId>spring-aspects</artifactId>
81
+            <version>${org.springframework-version}</version>
82
+        </dependency>
83
+        <dependency>
84
+            <groupId>org.springframework</groupId>
85
+            <artifactId>spring-test</artifactId>
86
+            <version>${org.springframework-version}</version>
87
+        </dependency>
88
+        <dependency>
89
+            <groupId>org.springframework</groupId>
90
+            <artifactId>spring-context-support</artifactId>
91
+            <version>${org.springframework-version}</version>
92
+        </dependency>
93
+        <dependency>
94
+            <groupId>javax.annotation</groupId>
95
+            <artifactId>jsr250-api</artifactId>
96
+            <version>1.0</version>
97
+        </dependency>
98
+        <dependency>
99
+            <groupId>com.ibeetl</groupId>
100
+            <artifactId>beetlsql</artifactId>
101
+            <version>${beetlsql-version}</version>
102
+        </dependency>
103
+        <dependency>
104
+            <groupId>mysql</groupId>
105
+            <artifactId>mysql-connector-java</artifactId>
106
+            <version>${mysql-connector-java-version}</version>
107
+        </dependency>
108
+
109
+        <dependency>
110
+            <groupId>com.alibaba</groupId>
111
+            <artifactId>druid</artifactId>
112
+            <version>${druid-version}</version>
113
+        </dependency>
114
+        <dependency>
115
+            <groupId>com.fasterxml.jackson.core</groupId>
116
+            <artifactId>jackson-databind</artifactId>
117
+            <version>${jackson.databind-version}</version>
118
+        </dependency>
119
+        <dependency>
120
+            <groupId>com.fasterxml.jackson.core</groupId>
121
+            <artifactId>jackson-core</artifactId>
122
+            <version>${jackson.databind-version}</version>
123
+        </dependency>
124
+        <dependency>
125
+            <groupId>commons-configuration</groupId>
126
+            <artifactId>commons-configuration</artifactId>
127
+            <version>${commons-configuration.version}</version>
128
+        </dependency>
129
+        <dependency>
130
+            <groupId>commons-fileupload</groupId>
131
+            <artifactId>commons-fileupload</artifactId>
132
+            <version>${commons.fileupload-version}</version>
133
+        </dependency>
134
+        <dependency>
135
+            <groupId>commons-beanutils</groupId>
136
+            <artifactId>commons-beanutils-core</artifactId>
137
+            <version>${commons-beanutils-core-version}</version>
138
+        </dependency>
139
+        <dependency>
140
+            <groupId>commons-codec</groupId>
141
+            <artifactId>commons-codec</artifactId>
142
+            <version>${commons-codec-version}</version>
143
+        </dependency>
144
+        <dependency>
145
+            <groupId>net.sf.json-lib</groupId>
146
+            <artifactId>json-lib</artifactId>
147
+            <version>${json-lib-version}</version>
148
+            <classifier>jdk15</classifier>
149
+        </dependency>
150
+        <dependency>
151
+            <groupId>com.sun.mail</groupId>
152
+            <artifactId>javax.mail</artifactId>
153
+            <version>${javax.mail-version}</version>
154
+        </dependency>
155
+        <!-- with pentaho-kettle -->
156
+        <dependency>
157
+            <groupId>pentaho-kettle</groupId>
158
+            <artifactId>kettle-core</artifactId>
159
+            <version>${kettle-version}</version>
160
+        </dependency>
161
+        <dependency>
162
+            <groupId>pentaho-kettle</groupId>
163
+            <artifactId>kettle-engine</artifactId>
164
+            <version>${kettle-version}</version>
165
+        </dependency>
166
+        <dependency>
167
+            <groupId>pentaho-kettle</groupId>
168
+            <artifactId>kettle-dbdialog</artifactId>
169
+            <version>${kettle-version}</version>
170
+        </dependency>
171
+        <dependency>
172
+            <groupId>org.pentaho.di.plugins</groupId>
173
+            <artifactId>kettle-sap-plugin-core</artifactId>
174
+            <version>${kettle-version}</version>
175
+        </dependency>
176
+        <dependency>
177
+            <groupId>pentaho-kettle</groupId>
178
+            <artifactId>kettle-ui-swt</artifactId>
179
+            <version>${kettle-version}</version>
180
+        </dependency>
181
+        <dependency>
182
+            <groupId>org.pentaho</groupId>
183
+            <artifactId>pentaho-hadoop-shims-api</artifactId>
184
+            <version>${dependency.hadoop-shims-api.revision}</version>
185
+        </dependency>
186
+
187
+        <dependency>
188
+            <groupId>pentaho</groupId>
189
+            <artifactId>pentaho-big-data-api-jdbc</artifactId>
190
+            <version>${kettle-version}</version>
191
+        </dependency>
192
+        <dependency>
193
+            <groupId>pentaho</groupId>
194
+            <artifactId>pentaho-big-data-impl-cluster</artifactId>
195
+            <version>${kettle-version}</version>
196
+        </dependency>
197
+
198
+        <dependency>
199
+            <groupId>pentaho</groupId>
200
+            <artifactId>pentaho-big-data-kettle-plugins-hdfs</artifactId>
201
+            <version>${kettle-version}</version>
202
+        </dependency>
203
+        <dependency>
204
+            <groupId>pentaho</groupId>
205
+            <artifactId>pentaho-big-data-kettle-plugins-formats</artifactId>
206
+            <version>${kettle-version}</version>
207
+        </dependency>
208
+        <dependency>
209
+            <groupId>pentaho</groupId>
210
+            <artifactId>pentaho-big-data-impl-shim-format</artifactId>
211
+            <version>${kettle-version}</version>
212
+        </dependency>
213
+        <dependency>
214
+            <groupId>pentaho</groupId>
215
+            <artifactId>pentaho-big-data-api-cluster-service-locator</artifactId>
216
+            <version>${kettle-version}</version>
217
+        </dependency>
218
+        <dependency>
219
+            <groupId>pentaho</groupId>
220
+            <artifactId>pentaho-big-data-api-format</artifactId>
221
+            <version>${kettle-version}</version>
222
+        </dependency>
223
+        <dependency>
224
+            <groupId>pentaho</groupId>
225
+            <artifactId>pentaho-big-data-api-hbase</artifactId>
226
+            <version>${kettle-version}</version>
227
+        </dependency>
228
+        <dependency>
229
+            <groupId>pentaho</groupId>
230
+            <artifactId>pentaho-big-data-api-hdfs</artifactId>
231
+            <version>${kettle-version}</version>
232
+        </dependency>
233
+        <dependency>
234
+            <groupId>pentaho</groupId>
235
+            <artifactId>pentaho-big-data-api-jaas</artifactId>
236
+            <version>${kettle-version}</version>
237
+        </dependency>
238
+        <dependency>
239
+            <groupId>pentaho</groupId>
240
+            <artifactId>pentaho-big-data-api-mapreduce</artifactId>
241
+            <version>${kettle-version}</version>
242
+        </dependency>
243
+        <dependency>
244
+            <groupId>pentaho</groupId>
245
+            <artifactId>pentaho-big-data-kettle-plugins-formats-meta</artifactId>
246
+            <version>${kettle-version}</version>
247
+        </dependency>
248
+        <dependency>
249
+            <groupId>pentaho</groupId>
250
+            <artifactId>pdi-osgi-bridge-core</artifactId>
251
+            <version>${pdi-osgi-bridge.version}</version>
252
+        </dependency>
253
+        <!--<dependency>-->
254
+        <!--<groupId>pentaho</groupId>-->
255
+        <!--<artifactId>pentaho-big-data-plugin</artifactId>-->
256
+        <!--<version>${pentaho-big-data-plugin.version}</version>-->
257
+        <!--<type>zip</type>-->
258
+        <!--</dependency>-->
259
+        <dependency>
260
+            <groupId>pentaho</groupId>
261
+            <artifactId>pentaho-platform-extensions</artifactId>
262
+            <version>${kettle-version}</version>
263
+            <exclusions>
264
+                <exclusion>
265
+                    <artifactId>xbean</artifactId>
266
+                    <groupId>org.apache.xbean</groupId>
267
+                </exclusion>
268
+            </exclusions>
269
+        </dependency>
270
+        <dependency>
271
+            <groupId>pentaho</groupId>
272
+            <artifactId>pentaho-metaverse-api</artifactId>
273
+            <version>${kettle-version}</version>
274
+            <exclusions>
275
+                <exclusion>
276
+                    <groupId>*</groupId>
277
+                    <artifactId>*</artifactId>
278
+                </exclusion>
279
+            </exclusions>
280
+        </dependency>
281
+        <dependency>
282
+            <groupId>org.apache.kafka</groupId>
283
+            <artifactId>kafka-clients</artifactId>
284
+            <version>${kafka-clients.version}</version>
285
+            <exclusions>
286
+                <exclusion>
287
+                    <groupId>*</groupId>
288
+                    <artifactId>*</artifactId>
289
+                </exclusion>
290
+            </exclusions>
291
+        </dependency>
292
+        <dependency>
293
+            <groupId>pentaho</groupId>
294
+            <artifactId>pentaho-metastore-locator-api</artifactId>
295
+            <version>${kettle-version}</version>
296
+        </dependency>
297
+        <dependency>
298
+            <groupId>com.tinkerpop.blueprints</groupId>
299
+            <artifactId>blueprints-core</artifactId>
300
+            <version>${blueprints-core.version}</version>
301
+            <exclusions>
302
+                <exclusion>
303
+                    <groupId>*</groupId>
304
+                    <artifactId>*</artifactId>
305
+                </exclusion>
306
+            </exclusions>
307
+        </dependency>
308
+        <dependency>
309
+            <groupId>org.apache.hive</groupId>
310
+            <artifactId>hive-jdbc</artifactId>
311
+            <version>2.3.0</version>
312
+        </dependency>
313
+        <!--<dependency>-->
314
+        <!--<groupId>org.apache.hadoop</groupId>-->
315
+        <!--<artifactId>hadoop-common</artifactId>-->
316
+        <!--<version>2.7.3</version>-->
317
+        <!--</dependency>-->
318
+        <!-- with quartz -->
319
+        <dependency>
320
+            <groupId>org.quartz-scheduler</groupId>
321
+            <artifactId>quartz</artifactId>
322
+            <version>${quartz-version}</version>
323
+        </dependency>
324
+        <!-- kettle plugin excel export-->
325
+        <dependency>
326
+            <groupId>net.sourceforge.jexcelapi</groupId>
327
+            <artifactId>jxl</artifactId>
328
+            <version>2.6.12</version>
329
+        </dependency>
330
+        <dependency>
331
+            <groupId>junit</groupId>
332
+            <artifactId>junit</artifactId>
333
+            <version>4.11</version>
334
+        </dependency>
335
+        <dependency>
336
+            <groupId>log4j</groupId>
337
+            <artifactId>log4j</artifactId>
338
+            <version>${log4j.version}</version>
339
+        </dependency>
340
+
341
+        <dependency>
342
+            <groupId>org.slf4j</groupId>
343
+            <artifactId>slf4j-api</artifactId>
344
+            <version>${slf4j.version}</version>
345
+        </dependency>
346
+
347
+        <dependency>
348
+            <groupId>org.slf4j</groupId>
349
+            <artifactId>slf4j-log4j12</artifactId>
350
+            <version>${slf4j.version}</version>
351
+        </dependency>
352
+    </dependencies>
353
+</project>

+ 62 - 0
src/main/java/com/zhaxd/common/exception/KettleMasterException.java

@@ -0,0 +1,62 @@
1
+package com.zhaxd.common.exception;
2
+
3
+import java.io.PrintWriter;
4
+import java.io.StringWriter;
5
+
6
+public class KettleMasterException extends RuntimeException {
7
+
8
+	static final long serialVersionUID = 1662900257135756746L;
9
+
10
+	public KettleMasterException() {
11
+		super();
12
+	}
13
+
14
+	public KettleMasterException(String message) {
15
+		super(message);
16
+	}
17
+
18
+	public KettleMasterException(String message, Throwable cause) {
19
+		super(message, cause);
20
+	}
21
+
22
+	public KettleMasterException(Throwable cause) {
23
+		super(cause);
24
+	}
25
+
26
+	/**
27
+	 * 将CheckedException转换为UncheckedException.
28
+	 */
29
+	public static RuntimeException unchecked(Exception e) {
30
+		if (e instanceof RuntimeException) {
31
+			return (RuntimeException) e;
32
+		} else {
33
+			return new RuntimeException(e);
34
+		}
35
+	}
36
+
37
+	/**
38
+	 * 将ErrorStack转化为String.
39
+	 */
40
+	public static String getStackTraceAsString(Exception e) {
41
+		StringWriter stringWriter = new StringWriter();
42
+		e.printStackTrace(new PrintWriter(stringWriter));
43
+		return stringWriter.toString();
44
+	}
45
+
46
+	/**
47
+	 * 判断异常是否由某些底层的异常引起.
48
+	 */
49
+	public static boolean isCausedBy(Exception ex,
50
+			@SuppressWarnings("unchecked") Class<? extends Exception>... causeExceptionClasses) {
51
+		Throwable cause = ex.getCause();
52
+		while (cause != null) {
53
+			for (Class<? extends Exception> causeClass : causeExceptionClasses) {
54
+				if (causeClass.isInstance(cause)) {
55
+					return true;
56
+				}
57
+			}
58
+			cause = cause.getCause();
59
+		}
60
+		return false;
61
+	}
62
+}

+ 9 - 0
src/main/java/com/zhaxd/common/exception/SeviceException.java

@@ -0,0 +1,9 @@
1
+package com.zhaxd.common.exception;
2
+
3
+public class SeviceException extends Exception{
4
+
5
+	private static final long serialVersionUID = 1L;
6
+
7
+
8
+	
9
+}

+ 92 - 0
src/main/java/com/zhaxd/common/kettle/Main.java

@@ -0,0 +1,92 @@
1
+package com.zhaxd.common.kettle;
2
+
3
+import org.pentaho.di.core.KettleEnvironment;
4
+import org.pentaho.di.core.ProgressNullMonitorListener;
5
+import org.pentaho.di.core.database.DatabaseMeta;
6
+import org.pentaho.di.core.exception.KettleException;
7
+import org.pentaho.di.core.logging.KettleLogStore;
8
+import org.pentaho.di.core.logging.LogLevel;
9
+import org.pentaho.di.core.logging.LoggingBuffer;
10
+import org.pentaho.di.job.Job;
11
+import org.pentaho.di.job.JobMeta;
12
+import org.pentaho.di.repository.RepositoryDirectoryInterface;
13
+import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
14
+import org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta;
15
+import org.pentaho.di.trans.Trans;
16
+import org.pentaho.di.trans.TransMeta;
17
+
18
+public class Main {
19
+
20
+	public static void main(String[] args) throws Exception{
21
+		KettleEnvironment.init();		
22
+		//数据库连接元对象
23
+    	//DatabaseMeta databaseMeta = new DatabaseMeta(null, "MYSQL", "Native", "172.17.7.78", "kettle-repository", "3306", "root", "123456");
24
+    	DatabaseMeta databaseMeta = new DatabaseMeta(null, "MYSQL", "Native", "localhost", "kettle", "3306", "root", "123456");
25
+    	//资源库元对象
26
+        KettleDatabaseRepositoryMeta repositoryInfo = new KettleDatabaseRepositoryMeta();
27
+        repositoryInfo.setConnection(databaseMeta);
28
+        //资源库
29
+        KettleDatabaseRepository repository = new KettleDatabaseRepository();
30
+        repository.init(repositoryInfo);
31
+        repository.connect("admin", "admin");
32
+        //判断是否连接成功
33
+        if (repository.isConnected()) {
34
+        	System.out.println( "connected" );
35
+        }else{
36
+        	System.out.println("error");
37
+        }
38
+        RepositoryDirectoryInterface jobDirectory = repository.loadRepositoryDirectoryTree().findDirectory("/");
39
+        //runTranslate(repository, jobDirectory, "kettle-test-6.2");
40
+        runJob(repository, jobDirectory, "work1");
41
+	}
42
+	
43
+	public static void runTranslate(KettleDatabaseRepository repository, RepositoryDirectoryInterface directory, String transName) throws KettleException{
44
+		TransMeta transMeta = repository.loadTransformation(transName, directory, new ProgressNullMonitorListener(), true, "1.0");
45
+		transMeta.setCapturingStepPerformanceSnapShots(true);
46
+		Trans trans = new Trans(transMeta);  
47
+        trans.setLogLevel(LogLevel.DEBUG);
48
+        trans.setMonitored(true);
49
+		trans.setInitializing(true);
50
+		trans.setPreparing(true);
51
+		trans.setRunning(true);
52
+		trans.setSafeModeEnabled(true);
53
+		trans.execute(null);
54
+		trans.waitUntilFinished();     
55
+        if (trans.isFinished()){
56
+        	System.out.println("执行成功");
57
+        	/*Map<String, List<StepPerformanceSnapShot>> stepPerformanceSnapShots = trans.getStepPerformanceSnapShots();
58
+        	stepPerformanceSnapShots.forEach((str, StepPerformanceSnapShotList) -> {
59
+        		for (StepPerformanceSnapShot stepPerformanceSnapShot : StepPerformanceSnapShotList){
60
+        			System.out.println(JSONObject.fromObject(stepPerformanceSnapShot).toString());
61
+        		}        		
62
+        	});*/
63
+        	
64
+        	String logChannelId = trans.getLogChannelId();
65
+        	LoggingBuffer appender = KettleLogStore.getAppender();
66
+        	String logText = appender.getBuffer(logChannelId, true).toString();
67
+        	System.out.println(logText);
68
+        }else{
69
+        	System.out.println("执行失败");
70
+        }
71
+	}
72
+	
73
+	public static void runJob(KettleDatabaseRepository repository, RepositoryDirectoryInterface directory, String jobName) throws KettleException{	
74
+        JobMeta jobMeta = repository.loadJob(jobName, directory, new ProgressNullMonitorListener(), null);
75
+        Job job = new Job(repository, jobMeta);
76
+        job.setDaemon(true);
77
+        job.setLogLevel(LogLevel.DEBUG);
78
+        job.run();
79
+        job.waitUntilFinished();   
80
+        if (job.isFinished()){
81
+        	String logChannelId = job.getLogChannelId();
82
+        	LoggingBuffer appender = KettleLogStore.getAppender();
83
+        	String logText = appender.getBuffer(logChannelId, true).toString();
84
+        	System.out.println(logText);
85
+        }else{
86
+        	System.out.println("执行失败");
87
+        }
88
+	}
89
+
90
+	
91
+	
92
+}

+ 262 - 0
src/main/java/com/zhaxd/common/kettle/environment/KettleInit.java

@@ -0,0 +1,262 @@
1
+package com.zhaxd.common.kettle.environment;
2
+
3
+import java.io.File;
4
+import java.io.FileOutputStream;
5
+import java.io.IOException;
6
+import java.util.Map;
7
+
8
+import org.pentaho.di.core.JndiUtil;
9
+import org.pentaho.di.core.KettleVariablesList;
10
+import org.pentaho.di.core.auth.AuthenticationConsumerPluginType;
11
+import org.pentaho.di.core.auth.AuthenticationProviderPluginType;
12
+import org.pentaho.di.core.compress.CompressionPluginType;
13
+import org.pentaho.di.core.exception.KettleException;
14
+import org.pentaho.di.core.exception.KettlePluginException;
15
+import org.pentaho.di.core.lifecycle.KettleLifecycleSupport;
16
+import org.pentaho.di.core.logging.ConsoleLoggingEventListener;
17
+import org.pentaho.di.core.logging.KettleLogStore;
18
+import org.pentaho.di.core.logging.LogTablePluginType;
19
+import org.pentaho.di.core.plugins.*;
20
+import org.pentaho.di.core.variables.Variables;
21
+import org.pentaho.di.i18n.BaseMessages;
22
+import org.pentaho.di.trans.step.RowDistributionPluginType;
23
+
24
+import com.zhaxd.common.toolkit.Constant;
25
+
26
+
27
+/**
28
+ * <p>
29
+ * Kettle环境初始化.
30
+ * </p>
31
+ * 
32
+ * @author zhaxd
33
+ * @Date Mar 19, 2014
34
+ * @Time 11:45:33
35
+ * @email 839536@QQ.com
36
+ * @version 1.0
37
+ * @since JDK 1.6
38
+ */
39
+public class KettleInit {
40
+
41
+	private static Class<?> PKG = Constant.class;
42
+	private static Boolean initialized;
43
+
44
+	/**
45
+	 * 初始化Kettle环境。 此方法将尝试配置 简单的JNDI, 通过简单地调用init(true)。
46
+	 * 
47
+	 * @see #KettleEnvironment.init(boolean)
48
+	 * 
49
+	 * @throws KettleException
50
+	 *             在初始化过程中发生的任何错误都将抛出 KettleException。
51
+	 */
52
+	public static void init() throws KettleException {
53
+		init(true);
54
+	}
55
+
56
+	/**
57
+	 * 初始化Ketle环境。此方法执行以下 操作:
58
+	 * 
59
+	 * 创建一个Kettle "home" 的目录,如果它已经不存在 - 读取 在kettle.properties文件 - 初始化记录后端 - 设置
60
+	 * 控制台日志级别调试 - 如果指定的参数,配置 简单的JNDI - 寄存器的各种原生类型和插件 插件类型 - 读取变量列表 - 初始化生命周期
61
+	 * 启动监听程序等
62
+	 * 
63
+	 * @param simpleJndi
64
+	 *            , 真正简单的JNDI配置,否则返回false
65
+	 * @throws KettleException
66
+	 *             在初始化过程中发生的任何错误都将抛出 KettleException。
67
+	 */
68
+	public static void init(boolean simpleJndi) throws KettleException {
69
+		if (initialized == null) {
70
+			// 创建一个Kettle "home" 的目录
71
+			// createKettleHome();
72
+			// 初始化 kettle.properties 初始化其他属性等
73
+			environmentInit();
74
+			// 初始化日志
75
+			KettleLogStore.init();
76
+			// 设置控制台日志级用来调试
77
+			KettleLogStore.getAppender().addLoggingEventListener(new ConsoleLoggingEventListener());
78
+			// 配置简单的JNDI 仅供我们在单机模式运行
79
+			if (simpleJndi) {
80
+				JndiUtil.initJNDI();
81
+			}
82
+			// 注册原生类型和各个所需的插件
83
+			PluginRegistry.addPluginType(RowDistributionPluginType.getInstance());			
84
+	        PluginRegistry.addPluginType(LogTablePluginType.getInstance());	        
85
+	        PluginRegistry.addPluginType(CartePluginType.getInstance());
86
+	        PluginRegistry.addPluginType(CompressionPluginType.getInstance());
87
+	        PluginRegistry.addPluginType(AuthenticationProviderPluginType.getInstance());
88
+	        PluginRegistry.addPluginType(AuthenticationConsumerPluginType.getInstance());			
89
+			PluginRegistry.addPluginType(StepPluginType.getInstance());
90
+			PluginRegistry.addPluginType(PartitionerPluginType.getInstance());
91
+			PluginRegistry.addPluginType(JobEntryPluginType.getInstance());
92
+			PluginRegistry.addPluginType(RepositoryPluginType.getInstance());
93
+			PluginRegistry.addPluginType(DatabasePluginType.getInstance());
94
+			PluginRegistry.addPluginType(LifecyclePluginType.getInstance());
95
+			PluginRegistry.addPluginType(KettleLifecyclePluginType.getInstance());
96
+			PluginRegistry.addPluginType(ImportRulePluginType.getInstance());
97
+			PluginRegistry.init();
98
+//			StepPluginType.getInstance().getPluginFolders().add(new PluginFolder("E:\\zhaxiaodong\\plugins\\pentaho-big-data-plugin",false,true));
99
+			// 初始化读取的变量列表。
100
+			KettleVariablesList.init();
101
+			// 初始化生命周期监听器
102
+			initLifecycleListeners();
103
+			initialized = true;
104
+		}
105
+	}
106
+
107
+	/**
108
+	 * 提醒所有生命周期的插件水壶环境。 初始化。
109
+	 * 
110
+	 * @throws KettleException
111
+	 *             当一个生命周期侦听器抛出一个异常
112
+	 */
113
+	private static void initLifecycleListeners() throws KettleException {
114
+		final KettleLifecycleSupport s = new KettleLifecycleSupport();
115
+		s.onEnvironmentInit();
116
+		// 注册关闭hook监听的调用OnExit()方法
117
+		Runtime.getRuntime().addShutdownHook(new Thread() {
118
+			public void run() {
119
+				try {
120
+					s.onEnvironmentShutdown();
121
+				} catch (Exception e) {
122
+					System.err.println(BaseMessages
123
+							.getString(PKG,
124
+									"LifecycleSupport.ErrorInvokingKettleEnvironmentShutdownListeners"));
125
+					e.printStackTrace();
126
+				}
127
+			};
128
+		});
129
+
130
+	}
131
+
132
+	/**
133
+	 * 创建Kettle home,这是一个目录,其中包含一个默认的 kettle.properties 属性文件等
134
+	 */
135
+	public static void createKettleHome() {
136
+		// 尝试创建目录
137
+		String directory = Constant.getKettleDirectory();
138
+		File dir = new File(directory);
139
+		try {
140
+			dir.mkdirs();
141
+			// 创建属性文件 kettle.properties
142
+			createDefaultKettleProperties(directory);
143
+		} catch (Exception e) {
144
+		}
145
+	}
146
+
147
+	/**
148
+	 * 创建默认的 kettle properties 文件
149
+	 * 
150
+	 * @param 目录
151
+	 *            目录
152
+	 */
153
+	private static void createDefaultKettleProperties(String directory) {
154
+
155
+		String kpFile = directory + Constant.FILE_SEPARATOR + Constant.UKETTLE;
156
+		File file = new File(kpFile);
157
+		if (!file.exists()) {
158
+			FileOutputStream out = null;
159
+			try {
160
+				out = new FileOutputStream(file);
161
+				out.write(Constant.getKettlePropertiesFileHeader().getBytes());
162
+			} catch (IOException e) {
163
+				System.err
164
+						.println(BaseMessages
165
+								.getString(
166
+										PKG,
167
+										"Props.Log.Error.UnableToCreateDefaultKettleProperties.Message",
168
+										Constant.UKETTLE, kpFile));
169
+				System.err.println(e.getStackTrace());
170
+			} finally {
171
+				if (out != null) {
172
+					try {
173
+						out.close();
174
+					} catch (IOException e) {
175
+						System.err
176
+								.println(BaseMessages
177
+										.getString(
178
+												PKG,
179
+												"Props.Log.Error.UnableToCreateDefaultKettleProperties.Message",
180
+												Constant.UKETTLE, kpFile));
181
+						System.err.println(e.getStackTrace());
182
+					}
183
+				}
184
+			}
185
+		}
186
+	}
187
+
188
+	/**
189
+	 * Checks if the Kettle environment has been initialized.
190
+	 * 
191
+	 * @return true if initialized, false otherwise
192
+	 */
193
+	/**
194
+	 * 检查Kettle 环境初始化。
195
+	 * 
196
+	 * @return 返回 true or false
197
+	 */
198
+	public static boolean isInitialized() {
199
+		if (initialized == null)
200
+			return false;
201
+		else
202
+			return true;
203
+	}
204
+
205
+	/**
206
+	 * 加载插件注册表。
207
+	 * 
208
+	 * @throws KettlePluginException
209
+	 *             加载插件如果遇到任何错误返回KettlePluginException
210
+	 */
211
+	public void loadPluginRegistry() throws KettlePluginException {
212
+
213
+	}
214
+
215
+	/**
216
+	 * 初始化环境变量。
217
+	 * 
218
+	 * @throws KettleException
219
+	 *             初始化如果遇到任何错误返回KettleException
220
+	 */
221
+	public static void environmentInit() throws KettleException {
222
+		if (Thread.currentThread().getContextClassLoader() == null) {
223
+			Thread.currentThread().setContextClassLoader(
224
+					ClassLoader.getSystemClassLoader());
225
+		}
226
+		Map<?, ?> prop = Constant.readProperties();
227
+		Variables variables = new Variables();
228
+		for (Object key : prop.keySet()) {
229
+			String variable = (String) key;
230
+			String value = variables.environmentSubstitute((String) prop
231
+					.get(key));
232
+			variables.setVariable(variable, value);
233
+		}
234
+		for (String variable : variables.listVariables()) {
235
+			System.setProperty(variable, variables.getVariable(variable));
236
+		}
237
+
238
+		System.getProperties().put("KETTLE_HOME", Constant.KETTLE_HOME);
239
+		System.getProperties().put("KETTLE_PLUGIN_BASE_FOLDERS",
240
+				Constant.KETTLE_PLUGIN);
241
+		System.getProperties().put("KETTLE_JS_HOME", Constant.KETTLE_SCRIPT);
242
+		System.getProperties()
243
+				.put(Constant.INTERNAL_VARIABLE_CLUSTER_SIZE, "1");
244
+		System.getProperties().put(
245
+				Constant.INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER, "0");
246
+		System.getProperties().put(
247
+				Constant.INTERNAL_VARIABLE_SLAVE_SERVER_NAME,
248
+				"slave-trans-name");
249
+		System.getProperties().put(Constant.INTERNAL_VARIABLE_STEP_COPYNR, "0");
250
+		System.getProperties().put(Constant.INTERNAL_VARIABLE_STEP_NAME,
251
+				"step-name");
252
+		System.getProperties().put(
253
+				Constant.INTERNAL_VARIABLE_STEP_PARTITION_ID, "partition-id");
254
+		System.getProperties().put(
255
+				Constant.INTERNAL_VARIABLE_STEP_PARTITION_NR, "0");
256
+		System.getProperties().put(
257
+				Constant.INTERNAL_VARIABLE_STEP_UNIQUE_COUNT, "1");
258
+		System.getProperties().put(
259
+				Constant.INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER, "0");
260
+	}
261
+
262
+}

+ 30 - 0
src/main/java/com/zhaxd/common/kettle/environment/StartInit.java

@@ -0,0 +1,30 @@
1
+package com.zhaxd.common.kettle.environment;
2
+
3
+import org.springframework.beans.factory.InitializingBean;
4
+
5
+public class StartInit implements InitializingBean{
6
+
7
+	@Override
8
+	public void afterPropertiesSet() throws Exception {
9
+		//如果是linux,加载器需要重新设置,要不然log4j匹配不上
10
+		if(isLinux()) {
11
+			Thread thread = Thread.currentThread();
12
+			ClassLoader loader = thread.getContextClassLoader();
13
+			System.out.println("********** - "+thread.getContextClassLoader().toString());
14
+			loader = loader.getParent();
15
+			System.out.println("********** - "+loader.toString());
16
+			thread.setContextClassLoader(loader);
17
+		}
18
+
19
+
20
+		//初始化环境***
21
+//		com.zhaxd.common.kettle.environment.KettleInit.init();
22
+		com.zhaxd.common.kettle.environment.KettleInit.environmentInit();
23
+		org.pentaho.di.core.KettleEnvironment.init();
24
+	}
25
+
26
+	private boolean isLinux() {
27
+		String os = System.getProperty("os.name");
28
+		return os.toUpperCase().contains("LINUX");
29
+	}
30
+}

+ 233 - 0
src/main/java/com/zhaxd/common/kettle/repository/RepositoryUtil.java

@@ -0,0 +1,233 @@
1
+package com.zhaxd.common.kettle.repository;
2
+
3
+import java.util.ArrayList;
4
+import java.util.HashMap;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import org.pentaho.di.core.KettleEnvironment;
9
+import org.pentaho.di.core.database.DatabaseMeta;
10
+import org.pentaho.di.core.exception.KettleException;
11
+import org.pentaho.di.repository.RepositoryDirectory;
12
+import org.pentaho.di.repository.RepositoryDirectoryInterface;
13
+import org.pentaho.di.repository.RepositoryElementMetaInterface;
14
+import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
15
+import org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta;
16
+
17
+import com.zhaxd.common.toolkit.Constant;
18
+import com.zhaxd.core.dto.kettle.RepositoryTree;
19
+import com.zhaxd.core.model.KRepository;
20
+
21
+public class RepositoryUtil {
22
+
23
+	public static Map<Integer, KettleDatabaseRepository> KettleDatabaseRepositoryCatch 
24
+														= new HashMap<Integer, KettleDatabaseRepository>();
25
+	
26
+	
27
+	public static void main(String[] args) throws KettleException{
28
+	
29
+		KRepository kRepository = new KRepository();
30
+		kRepository.setRepositoryId(1);
31
+		kRepository.setRepositoryName("repository");
32
+		kRepository.setRepositoryUsername("admin");
33
+		kRepository.setRepositoryPassword("admin");
34
+		kRepository.setRepositoryType("MYSQL");
35
+		kRepository.setDatabaseAccess("Native");
36
+		kRepository.setDatabaseHost("localhost");
37
+		kRepository.setDatabasePort("3306");
38
+		kRepository.setDatabaseName("kettle");
39
+		kRepository.setDatabaseUsername("root");
40
+		kRepository.setDatabasePassword("123456");
41
+		
42
+		KettleEnvironment.init();
43
+		
44
+		KettleDatabaseRepository kettleDatabaseRepository = connectionRepository(kRepository);
45
+		
46
+		List<RepositoryTree> allRepositoryTreeList = new ArrayList<RepositoryTree>();
47
+		
48
+		List<RepositoryTree> repositoryTreeList = getAllDirectoryTreeList(kettleDatabaseRepository, "/", allRepositoryTreeList);
49
+
50
+		for (RepositoryTree repositoryTree : repositoryTreeList){
51
+			System.out.println(repositoryTree);
52
+		}
53
+	}
54
+	
55
+	
56
+	public static String[] getDataBaseAccess(){
57
+		String[] dataBaseAccess = DatabaseMeta.dbAccessTypeCode;
58
+		
59
+		return dataBaseAccess;
60
+	}
61
+	
62
+	/**
63
+	 * @Title connectionRepository
64
+	 * @Description 连接资源库对象
65
+	 * @param kRepository 资源库连接信息
66
+	 * @throws KettleException
67
+	 * @return void
68
+	 */
69
+	public static KettleDatabaseRepository connectionRepository(KRepository kRepository) throws KettleException{
70
+		if (null != kRepository){
71
+			//数据库连接元对象
72
+	    	//DatabaseMeta databaseMeta = new DatabaseMeta("repository", "MYSQL", 
73
+					//"Native", "localhost", "kettle-repository", "3306", "root", "1234");    	
74
+	    	DatabaseMeta databaseMeta = new DatabaseMeta(null, kRepository.getRepositoryType(), 
75
+	    			kRepository.getDatabaseAccess(), kRepository.getDatabaseHost(), kRepository.getDatabaseName(), 
76
+	    			kRepository.getDatabasePort(), kRepository.getDatabaseUsername(), kRepository.getDatabasePassword());    	
77
+	    	//资源库元对象
78
+	        KettleDatabaseRepositoryMeta repositoryInfo = new KettleDatabaseRepositoryMeta();
79
+	        repositoryInfo.setConnection(databaseMeta);
80
+	        //资源库
81
+	        KettleDatabaseRepository repository = new KettleDatabaseRepository();
82
+	        repository.init(repositoryInfo);
83
+	        repository.connect(kRepository.getRepositoryUsername(), kRepository.getRepositoryPassword());
84
+	        //添加缓存
85
+	        if (null != kRepository.getRepositoryId()){
86
+	        	KettleDatabaseRepositoryCatch.put(kRepository.getRepositoryId(), repository);	
87
+	        }	
88
+	        return repository;	
89
+		}
90
+		return null;
91
+	}	
92
+	
93
+	/**
94
+	 * @Title disConnectionRepository
95
+	 * @Description 断开资源库并删除缓存对象
96
+	 * @param repository
97
+	 * @param ID
98
+	 * @return void
99
+	 */
100
+	public static void disConnectionRepository(KettleDatabaseRepository repository, Integer ID){
101
+		repository.disconnect();
102
+		repository.clearSharedObjectCache();
103
+		KettleDatabaseRepositoryCatch.remove(ID);
104
+	}
105
+	
106
+	/**
107
+	 * @Title disConnectionAllRepository
108
+	 * @Description 断开全部资源库
109
+	 * @return void
110
+	 */
111
+	public static void disConnectionAllRepository(){
112
+		KettleDatabaseRepositoryCatch.forEach((ID, repository) -> {
113
+			repository.disconnect();
114
+			repository.clearSharedObjectCache();			
115
+		});
116
+		KettleDatabaseRepositoryCatch.clear();
117
+	}
118
+	
119
+	
120
+	/**
121
+	 * @Title getAllDirectoryTreeList
122
+	 * @Description 递归调用获取全部的树形菜单
123
+	 * @param kettleDatabaseRepository 资源库
124
+	 * @param path 当前路径
125
+	 * @param allRepositoryTreeList 所有的树形菜单
126
+	 * @return
127
+	 * @throws KettleException
128
+	 * @return List<RepositoryTree> 所有的树形菜单
129
+	 */
130
+	public static List<RepositoryTree> getAllDirectoryTreeList(KettleDatabaseRepository kettleDatabaseRepository, 
131
+			String path, List<RepositoryTree> allRepositoryTreeList) throws KettleException{
132
+		//获取Job和Transformation和Directory的信息
133
+		List<RepositoryTree> repositoryTreeList = getJobAndTrans(kettleDatabaseRepository, path);
134
+		if (repositoryTreeList.size() != 0){
135
+			for (RepositoryTree repositoryTree : repositoryTreeList){
136
+				//如果有子Directory或者Job和Transformation。那么递归遍历
137
+				if (!repositoryTree.isLasted()){
138
+					getAllDirectoryTreeList(kettleDatabaseRepository, repositoryTree.getPath(), allRepositoryTreeList);
139
+					allRepositoryTreeList.add(repositoryTree);
140
+				}else{
141
+					allRepositoryTreeList.add(repositoryTree);
142
+				}
143
+			}
144
+		}				
145
+		return allRepositoryTreeList;		
146
+	}
147
+	
148
+	/**
149
+	 * @Title getJobAndTrans
150
+	 * @Description 获取Job和Transformation和Directory的信息
151
+	 * @param repository
152
+	 * @param path
153
+	 * @return RepositoryTree的集合
154
+	 * @throws KettleException
155
+	 * @return List<RepositoryTree>
156
+	 */
157
+	public static List<RepositoryTree> getJobAndTrans(KettleDatabaseRepository repository, 
158
+			String path) throws KettleException {
159
+		//获取当前的路径信息
160
+		RepositoryDirectoryInterface rDirectory = repository.loadRepositoryDirectoryTree().findDirectory(path);
161
+		//获取Directory信息
162
+		List<RepositoryTree> repositoryTreeList = getDirectory(repository, rDirectory);
163
+		//获取Job和Transformation的信息
164
+		List<RepositoryElementMetaInterface> li = repository.getJobAndTransformationObjects(rDirectory.getObjectId(), false);
165
+		if (null != li) {
166
+			for (RepositoryElementMetaInterface repel : li) {
167
+				if (Constant.TYPE_JOB.equals(repel.getObjectType().toString())) {						
168
+					RepositoryTree repositoryTree = new RepositoryTree();
169
+					StringBuilder stringBuilder = new StringBuilder();
170
+					stringBuilder.append(Constant.TYPE_JOB).append(rDirectory.getObjectId().toString()).append("@").append(repel.getObjectId().toString());
171
+					repositoryTree.setId(stringBuilder.toString());
172
+					repositoryTree.setParent(rDirectory.getObjectId().toString());
173
+					repositoryTree.setText(repel.getName());
174
+					repositoryTree.setType(Constant.TYPE_JOB);
175
+					repositoryTree.setLasted(true);
176
+					repositoryTreeList.add(repositoryTree);
177
+				}else if (Constant.TYPE_TRANS.equals(repel.getObjectType().toString())){
178
+					RepositoryTree repositoryTree = new RepositoryTree();
179
+					StringBuilder stringBuilder = new StringBuilder();
180
+					stringBuilder.append(Constant.TYPE_TRANS).append(rDirectory.getObjectId().toString()).append("@").append(repel.getObjectId().toString());
181
+					repositoryTree.setId(stringBuilder.toString());
182
+					repositoryTree.setParent(rDirectory.getObjectId().toString());
183
+					repositoryTree.setText(repel.getName());
184
+					repositoryTree.setType(Constant.TYPE_TRANS);
185
+					repositoryTree.setLasted(true);
186
+					repositoryTreeList.add(repositoryTree);
187
+				}
188
+			}
189
+		}
190
+		return repositoryTreeList;
191
+	}
192
+	
193
+	/**
194
+	 * @Title getDirectory
195
+	 * @Description 获取Directory信息
196
+	 * @param repository
197
+	 * @param rDirectory
198
+	 * @return
199
+	 * @throws KettleException
200
+	 * @return List<RepositoryTree>
201
+	 */
202
+	private static List<RepositoryTree> getDirectory(KettleDatabaseRepository repository, 
203
+			RepositoryDirectoryInterface rDirectory) throws KettleException {
204
+		List<RepositoryTree> repositoryTreeList = new ArrayList<RepositoryTree>();
205
+		if (null != repository && null != rDirectory){			
206
+			RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree().findDirectory(rDirectory.getObjectId());
207
+			if (rDirectory.getNrSubdirectories() > 0){
208
+				for (int i = 0; i < rDirectory.getNrSubdirectories(); i++) {				
209
+					RepositoryDirectory subTree = tree.getSubdirectory(i);
210
+					RepositoryTree repositoryTree = new RepositoryTree();
211
+					repositoryTree.setId(subTree.getObjectId().toString());
212
+					repositoryTree.setParent(rDirectory.getObjectId().toString());
213
+					repositoryTree.setText(subTree.getName());
214
+					repositoryTree.setPath(subTree.getPath());
215
+					//判断是否还有子Directory或者Job和Transformation
216
+					List<RepositoryElementMetaInterface> RepositoryElementMetaInterfaceList = 
217
+							repository.getJobAndTransformationObjects(subTree.getObjectId(), false);					
218
+					if (subTree.getNrSubdirectories() > 0 || RepositoryElementMetaInterfaceList.size() > 0){
219
+						repositoryTree.setLasted(false);
220
+					}else{
221
+						repositoryTree.setLasted(true);
222
+					}
223
+					repositoryTreeList.add(repositoryTree);
224
+				}	
225
+			}					
226
+		}
227
+		return repositoryTreeList;	
228
+	}
229
+	
230
+	
231
+	
232
+	
233
+}

+ 190 - 0
src/main/java/com/zhaxd/common/toolkit/Constant.java

@@ -0,0 +1,190 @@
1
+package com.zhaxd.common.toolkit;
2
+
3
+import aQute.bnd.annotation.component.Component;
4
+import org.pentaho.di.core.Const;
5
+import org.pentaho.di.core.logging.LogLevel;
6
+
7
+import java.io.FileInputStream;
8
+import java.util.Properties;
9
+
10
+/**
11
+ *
12
+ * @ClassName Constant
13
+ * @Description 常量类
14
+ * @author zhaxd
15
+ * @date 2017528日 下午3:33:55
16
+ */
17
+@Component
18
+public class Constant extends Const {
19
+
20
+	/** Public */
21
+	public static final String VERSION = "7.0.0.0-25";
22
+	public static final String DEFAULT_ENCODING = "UTF-8";
23
+	public static final String DEFAULT_TIMEZONE = "GMT+8";
24
+	public static String UKETTLE;
25
+	public static final String SESSION_ID = "SESSION_ID";
26
+
27
+	public static final String STATUS_ENABLED = "ENABLED";
28
+	public static final String STATUS_DISABLED = "DISABLED";
29
+	public static final String STATUS_FINISHED = "FINISHED";
30
+	public static final String STATUS_CLOSED = "CLOSED";
31
+
32
+	public static final String STATUS_ERROR = "ERROR";
33
+	public static final String STATUS_AGAIN = "AGAIN";
34
+	public static final String STATUS_COMPLETE = "COMPLETE";
35
+
36
+	public static final String FORMAT_JSON = "json";
37
+	public static final String FORMAT_XML = "xml";
38
+	public static final String FORMAT_STREAM = "stream";
39
+	public static final int VALID_TIMESTAMP = 15;
40
+
41
+	/** Kettle */
42
+	public static final String TYPE_JOB = "job";
43
+	public static final String TYPE_TRANS = "transformation";
44
+	public static final String TYPE_JOB_SUFFIX = ".kjb";
45
+	public static final String TYPE_TRANS_SUFFIX = ".ktr";
46
+	public static final String TYPE_TESTING = "TESTING";
47
+	public static final String TYPE_RUNNING = "RUNNING";
48
+	public static final String TYPE_USER_KETTLE = "KETTLE";
49
+	public static final String TYPE_AGAIN = "AGAIN";
50
+
51
+	public static final String STARTS_WITH_USD = "$";
52
+	public static final String STARTS_WITH_PARAM = "-param:";
53
+	public static final String SPLIT_PARAM = "-param:";
54
+	public static final String SPLIT_EQUAL = "=";
55
+	public static final String SPLIT_USD = "$";
56
+	public static final String KETTLE_REPO = "repo";
57
+
58
+	/** quartz **/
59
+
60
+	public static final String JOB_PREFIX = "JOB";
61
+	public static final String JOB_GROUP_PREFIX = "JOB_GROUP";
62
+	public static final String TRIGGER_PREFIX = "TRIGGER";
63
+	public static final String TRIGGER_GROUP_PREFIX = "TRIGGER_GROUP";
64
+	public static final String QUARTZ_SEPARATE = "@";
65
+
66
+	/** quartz parameter **/
67
+	public static final String REPOSITORYOBJECT = "REPOSITORYOBJECT";
68
+	public static final String DBCONNECTIONOBJECT = "DBCONNECTIONOBJECT";
69
+	public static final String JOBID = "JOBID";
70
+	public static final String TRANSID= "TRANSID";
71
+	public static final String JOBTYPE="JOBTYPE";
72
+	public static final String JOBPATH = "JOBPATH";
73
+	public static final String TRANSPATH = "TRANSPATH";
74
+	public static final String JOBNAME = "JOBNAME";
75
+	public static final String TRANSNAME = "TRANSNAME";
76
+	public static final String USERID = "USERID";
77
+	public static final String LOGLEVEL = "LOGLEVEL";
78
+	public static final String LOGFILEPATH = "LOGFILEPATH";
79
+
80
+	public static final String RUNSTATUS_SEPARATE = "-";
81
+
82
+	public static String KETTLE_HOME;
83
+	public static String KETTLE_PLUGIN;
84
+	public static String KETTLE_SCRIPT;
85
+	public static LogLevel KETTLE_LOGLEVEL;
86
+
87
+	public static String DATASOURCE_TYPE;
88
+
89
+	public static Properties props;
90
+
91
+	static {
92
+		setActive();
93
+		props = readProperties();
94
+		KETTLE_HOME = props.getProperty("kettle.home");
95
+//		KETTLE_PLUGIN = KETTLE_HOME + FILE_SEPARATOR
96
+//				+ props.getProperty("kettle.plugin");
97
+		KETTLE_PLUGIN = props.getProperty("kettle.plugin");
98
+		KETTLE_SCRIPT = uKettle()
99
+				+ props.getProperty("kettle.script");
100
+		KETTLE_LOGLEVEL = logger(props
101
+				.getProperty("kettle.loglevel"));
102
+
103
+	}
104
+
105
+	public static void setActive(){
106
+		Properties pActive = new Properties();
107
+		try {
108
+			pActive.load(new FileInputStream(Constant.class.getResource("/")
109
+					.getPath().replace("%20", " ")
110
+					+ "resource/active.properties"));
111
+		} catch (Exception e) {
112
+			e.printStackTrace();
113
+		}
114
+		String active = pActive.getProperty("active.property");
115
+		UKETTLE = "resource/kettle-"+active+".properties";
116
+		Properties pdb = new Properties();
117
+		try {
118
+			pdb.load(new FileInputStream(Constant.class.getResource("/")
119
+					.getPath().replace("%20", " ")
120
+					+ "resource/db-"+active+".properties"));
121
+		} catch (Exception e) {
122
+			e.printStackTrace();
123
+		}
124
+		DATASOURCE_TYPE = pdb.getProperty("datasource.type");
125
+	}
126
+
127
+	public static String get(String key) {
128
+		return props.getProperty(key);
129
+	}
130
+
131
+	public static void set(Properties p) {
132
+		props = p;
133
+	}
134
+
135
+	public static Properties readProperties() {
136
+		Properties p = new Properties();
137
+		try {
138
+			p.load(new FileInputStream(Constant.class.getResource("/")
139
+					.getPath().replace("%20", " ")
140
+					+ UKETTLE));
141
+		} catch (Exception e) {
142
+			e.printStackTrace();
143
+		}
144
+		return p;
145
+	}
146
+
147
+	public static LogLevel logger(String level) {
148
+		LogLevel logLevel = null;
149
+		if ("basic".equals(level)) {
150
+			logLevel = LogLevel.BASIC;
151
+		} else if ("detail".equals(level)) {
152
+			logLevel = LogLevel.DETAILED;
153
+		} else if ("error".equals(level)) {
154
+			logLevel = LogLevel.ERROR;
155
+		} else if ("debug".equals(level)) {
156
+			logLevel = LogLevel.DEBUG;
157
+		} else if ("minimal".equals(level)) {
158
+			logLevel = LogLevel.MINIMAL;
159
+		} else if ("rowlevel".equals(level)) {
160
+			logLevel = LogLevel.ROWLEVEL;
161
+		} else if ("Nothing".endsWith(level)){
162
+			logLevel = LogLevel.NOTHING;
163
+		}else {
164
+			logLevel = KETTLE_LOGLEVEL;
165
+		}
166
+		return logLevel;
167
+	}
168
+
169
+	private static String uKettle() {
170
+		String classPath = Constant.class.getResource("/").getPath()
171
+				.replace("%20", " ");
172
+		String iQuartz = "";
173
+		String index = "WEB-INF";
174
+		if (classPath.indexOf("target") > 0) {
175
+			index = "target";
176
+		}
177
+		// windows path
178
+		if ("\\".equals(Constant.FILE_SEPARATOR)) {
179
+			iQuartz = classPath.substring(1, classPath.indexOf(index));
180
+			iQuartz = iQuartz.replace("/", "\\");
181
+		}
182
+		// linux path
183
+		if ("/".equals(Constant.FILE_SEPARATOR)) {
184
+			iQuartz = classPath.substring(0, classPath.indexOf(index));
185
+			iQuartz = iQuartz.replace("\\", "/");
186
+		}
187
+		return iQuartz;
188
+	}
189
+
190
+}

+ 119 - 0
src/main/java/com/zhaxd/common/toolkit/EmailUtil.java

@@ -0,0 +1,119 @@
1
+package com.zhaxd.common.toolkit;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Date;
5
+import java.util.List;
6
+import java.util.Properties;
7
+import java.util.regex.Matcher;
8
+import java.util.regex.Pattern;
9
+
10
+import javax.mail.Address;
11
+import javax.mail.Authenticator;
12
+import javax.mail.BodyPart;
13
+import javax.mail.Message;
14
+import javax.mail.PasswordAuthentication;
15
+import javax.mail.Session;
16
+import javax.mail.Transport;
17
+import javax.mail.internet.InternetAddress;
18
+import javax.mail.internet.MimeBodyPart;
19
+import javax.mail.internet.MimeMessage;
20
+import javax.mail.internet.MimeMultipart;
21
+
22
+import com.sun.mail.util.MailSSLSocketFactory;
23
+
24
+/**
25
+ * 发送邮件工具类
26
+ * @author Administrator
27
+ *
28
+ */
29
+public class EmailUtil {
30
+
31
+	public void SendMailVerification(String emailAdress,String identifyingcode) throws Exception {
32
+		//配置服务器信息
33
+		Properties properties = new Properties();
34
+		properties.put("mail.smtp.host", "smtp.163.com");
35
+		properties.put("mail.smtp.auth", "true");
36
+		//启用SSL加密
37
+		MailSSLSocketFactory sf = null;
38
+		sf = new MailSSLSocketFactory();
39
+		//设置信任所有的主机
40
+		sf.setTrustAllHosts(true);
41
+		properties.put("mail.smtp.ssl.enable", "true");
42
+		properties.put("mail.smtp.ssl.socketFactory", sf);
43
+		//根据邮件的会话属性构造一个发送邮件的Session,这里需要注意的是用户名那里不能加后缀,否则便不是用户名了
44
+		//还需要注意的是,这里的密码不是正常使用邮箱的登陆密码,而是客户端生成的另一个专门的授权码
45
+		MailAuthenticator authenticator = new MailAuthenticator("18842652126", "123456");
46
+		Session session = Session.getInstance(properties, authenticator);
47
+		//根据Session 构建邮件信息
48
+		Message message = new MimeMessage(session);
49
+		//创建邮件发送者地址
50
+		Address from = new InternetAddress("18842652126@163.com");
51
+		//设置邮件消息的发送者
52
+		message.setFrom(from);
53
+		//设置收件人列表
54
+		//同时验证收件人邮箱地址
55
+		List<String> toAddressList = new ArrayList<>();
56
+		toAddressList.add(emailAdress);
57
+		StringBuffer buffer = new StringBuffer();
58
+		if (!toAddressList.isEmpty()) {
59
+			String regEx = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
60
+			Pattern p = Pattern.compile(regEx);
61
+			for (int i = 0; i < toAddressList.size(); i++) {
62
+				Matcher match = p.matcher(toAddressList.get(i));
63
+				if (match.matches()) {
64
+					buffer.append(toAddressList.get(i));
65
+					if (i < toAddressList.size() - 1) {
66
+						buffer.append(",");
67
+					}
68
+				}
69
+			}
70
+		}
71
+		String toAddress = buffer.toString();
72
+		if (!toAddress.isEmpty()) {
73
+			//创建邮件的接收者地址
74
+			Address[] to = InternetAddress.parse(toAddress);
75
+			//设置邮件接收人地址
76
+			message.setRecipients(Message.RecipientType.TO, to);
77
+			//邮件主题
78
+			message.setSubject("==新密码==");
79
+			//邮件容器
80
+			MimeMultipart mimeMultiPart = new MimeMultipart();
81
+			//设置HTML
82
+			BodyPart bodyPart = new MimeBodyPart();
83
+			//邮件内容
84
+			String htmlText = "您的新密码为:" + identifyingcode + "。请尽快修改密码,并注意保护自己的密码";
85
+			bodyPart.setContent(htmlText, "text/html;charset=utf-8");
86
+			mimeMultiPart.addBodyPart(bodyPart);
87
+			message.setContent(mimeMultiPart);
88
+			message.setSentDate(new Date());
89
+			//保存邮件
90
+			message.saveChanges();
91
+			//发送邮件
92
+			Transport.send(message);
93
+		}
94
+	}
95
+	class MailAuthenticator extends Authenticator {
96
+		private String username;
97
+		private String password;
98
+		public MailAuthenticator(String username, String password) {
99
+			this.username = username;
100
+			this.password = password;
101
+		}
102
+		public String getPassword() {
103
+			return password;
104
+		}
105
+		@Override
106
+		protected PasswordAuthentication getPasswordAuthentication() {
107
+			return new PasswordAuthentication(username, password);
108
+		}
109
+		public String getUsername() {
110
+			return username;
111
+		}
112
+		public void setPassword(String password) {
113
+			this.password = password;
114
+		}
115
+		public void setUsername(String username) {
116
+			this.username = username;
117
+		}
118
+	}
119
+}

+ 56 - 0
src/main/java/com/zhaxd/common/toolkit/MD5Utils.java

@@ -0,0 +1,56 @@
1
+package com.zhaxd.common.toolkit;
2
+
3
+import org.apache.commons.codec.digest.DigestUtils;
4
+import org.apache.commons.lang.ArrayUtils;
5
+import org.apache.commons.lang.StringUtils;
6
+
7
+public class MD5Utils {
8
+
9
+	private static String salt = "kettlescheduler";
10
+	
11
+	/**
12
+	 * 加密字符串
13
+	 * @param password 要加密的明文
14
+	 * @param isAddSalt 是否加默认盐
15
+	 * @return 加密之后的结果
16
+	 */
17
+	public static String Encrypt(String password, boolean isAddSalt){
18
+		if (StringUtils.isNotEmpty(password)){
19
+			if (isAddSalt){
20
+				return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
21
+			} else {
22
+				return DigestUtils.md5Hex(DigestUtils.md5(password));
23
+			}
24
+		}
25
+		return null;		
26
+	}
27
+	
28
+	/**
29
+	 * 
30
+	 * @param bytes
31
+	 * @return
32
+	 */
33
+	public static String Encrypt(byte[] bytes){
34
+		if (ArrayUtils.isNotEmpty(bytes)){
35
+			return DigestUtils.md5Hex(DigestUtils.md5(bytes));
36
+		}
37
+		return null;
38
+	}
39
+	
40
+	/**
41
+	 * MD5加盐加密
42
+	 * @param password 要加密的明文
43
+	 * @param salt 盐
44
+	 * @return 加密之后的结果
45
+	 */
46
+	public static String Encrypt(String password, String salt){
47
+		if (StringUtils.isNotEmpty(password)){
48
+			return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
49
+		}
50
+		return null;			
51
+	}
52
+	
53
+	public static void main(String[] args){
54
+		System.out.println(MD5Utils.Encrypt("admin", true));		
55
+	}
56
+}

+ 426 - 0
src/main/java/com/zhaxd/common/toolkit/ObjectID.java

@@ -0,0 +1,426 @@
1
+package com.zhaxd.common.toolkit;
2
+
3
+/**
4
+ *      Copyright (C) 2008 10gen Inc.
5
+ *
6
+ *   Licensed under the Apache License, Version 2.0 (the "License");
7
+ *   you may not use this file except in compliance with the License.
8
+ *   You may obtain a copy of the License at
9
+ *
10
+ *      http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ *   Unless required by applicable law or agreed to in writing, software
13
+ *   distributed under the License is distributed on an "AS IS" BASIS,
14
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ *   See the License for the specific language governing permissions and
16
+ *   limitations under the License.
17
+ */
18
+
19
+import java.io.Serializable;
20
+import java.lang.management.ManagementFactory;
21
+import java.net.NetworkInterface;
22
+import java.nio.ByteBuffer;
23
+import java.util.Date;
24
+import java.util.Enumeration;
25
+import java.util.Random;
26
+import java.util.concurrent.atomic.AtomicInteger;
27
+
28
+/**
29
+ * A globally unique identifier for objects.
30
+ * <p>
31
+ * Consists of 12 bytes, divided as follows: <blockquote>
32
+ * 
33
+ * <pre>
34
+ * <table border="1">
35
+ * <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
36
+ *     <td>7</td><td>8</td><td>9</td><td>10</td><td>11</td></tr>
37
+ * <tr><td colspan="4">time</td><td colspan="3">machine</td>
38
+ *     <td colspan="2">pid</td><td colspan="3">inc</td></tr>
39
+ * </table>
40
+ * </pre>
41
+ * 
42
+ * </blockquote>
43
+ * 
44
+ * @ objectids
45
+ */
46
+public class ObjectID implements Comparable<ObjectID>, Serializable {
47
+
48
+	private static final long serialVersionUID = -4415279469780082174L;
49
+
50
+	/**
51
+	 * Gets a new String id.
52
+	 * 
53
+	 * @return the new id
54
+	 */
55
+	public static String id() {
56
+		return new ObjectID().toString();
57
+	}
58
+
59
+	/**
60
+	 * Gets a new object id.
61
+	 * 
62
+	 * @return the new id
63
+	 */
64
+	public static ObjectID get() {
65
+		return new ObjectID();
66
+	}
67
+
68
+	/**
69
+	 * Checks if a string could be an <code>ObjectId</code>.
70
+	 * 
71
+	 * @return whether the string could be an object id
72
+	 */
73
+	public static boolean isValid(String s) {
74
+		if (s == null)
75
+			return false;
76
+
77
+		final int len = s.length();
78
+		if (len != 24)
79
+			return false;
80
+
81
+		for (int i = 0; i < len; i++) {
82
+			char c = s.charAt(i);
83
+			if (c >= '0' && c <= '9')
84
+				continue;
85
+			if (c >= 'a' && c <= 'f')
86
+				continue;
87
+			if (c >= 'A' && c <= 'F')
88
+				continue;
89
+
90
+			return false;
91
+		}
92
+
93
+		return true;
94
+	}
95
+
96
+	/**
97
+	 * Turn an object into an <code>ObjectId</code>, if possible. Strings will
98
+	 * be converted into <code>ObjectId</code>s, if possible, and
99
+	 * <code>ObjectId</code>s will be cast and returned. Passing in
100
+	 * <code>null</code> returns <code>null</code>.
101
+	 * 
102
+	 * @param o
103
+	 *            the object to convert
104
+	 * @return an <code>ObjectId</code> if it can be massaged, null otherwise
105
+	 */
106
+	public static ObjectID massageToObjectId(Object o) {
107
+		if (o == null)
108
+			return null;
109
+
110
+		if (o instanceof ObjectID)
111
+			return (ObjectID) o;
112
+
113
+		if (o instanceof String) {
114
+			String s = o.toString();
115
+			if (isValid(s))
116
+				return new ObjectID(s);
117
+		}
118
+
119
+		return null;
120
+	}
121
+
122
+	public ObjectID(Date time) {
123
+		this(time, _genmachine, _nextInc.getAndIncrement());
124
+	}
125
+
126
+	public ObjectID(Date time, int inc) {
127
+		this(time, _genmachine, inc);
128
+	}
129
+
130
+	public ObjectID(Date time, int machine, int inc) {
131
+		_time = (int) (time.getTime() / 1000);
132
+		_machine = machine;
133
+		_inc = inc;
134
+		_new = false;
135
+	}
136
+
137
+	/**
138
+	 * Creates a new instance from a string.
139
+	 * 
140
+	 * @param s
141
+	 *            the string to convert
142
+	 * @throws IllegalArgumentException
143
+	 *             if the string is not a valid id
144
+	 */
145
+	public ObjectID(String s) {
146
+		this(s, false);
147
+	}
148
+
149
+	public ObjectID(String s, boolean babble) {
150
+
151
+		if (!isValid(s))
152
+			throw new IllegalArgumentException("invalid ObjectId [" + s + "]");
153
+
154
+		if (babble)
155
+			s = babbleToMongod(s);
156
+
157
+		byte b[] = new byte[12];
158
+		for (int i = 0; i < b.length; i++) {
159
+			b[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
160
+		}
161
+		ByteBuffer bb = ByteBuffer.wrap(b);
162
+		_time = bb.getInt();
163
+		_machine = bb.getInt();
164
+		_inc = bb.getInt();
165
+		_new = false;
166
+	}
167
+
168
+	public ObjectID(byte[] b) {
169
+		if (b.length != 12)
170
+			throw new IllegalArgumentException("need 12 bytes");
171
+		ByteBuffer bb = ByteBuffer.wrap(b);
172
+		_time = bb.getInt();
173
+		_machine = bb.getInt();
174
+		_inc = bb.getInt();
175
+		_new = false;
176
+	}
177
+
178
+	/**
179
+	 * Creates an ObjectId
180
+	 * 
181
+	 * @param time
182
+	 *            time in seconds
183
+	 * @param machine
184
+	 *            machine ID
185
+	 * @param inc
186
+	 *            incremental value
187
+	 */
188
+	public ObjectID(int time, int machine, int inc) {
189
+		_time = time;
190
+		_machine = machine;
191
+		_inc = inc;
192
+		_new = false;
193
+	}
194
+
195
+	/**
196
+	 * Create a new object id.
197
+	 */
198
+	public ObjectID() {
199
+		_time = (int) (System.currentTimeMillis() / 1000);
200
+		_machine = _genmachine;
201
+		_inc = _nextInc.getAndIncrement();
202
+		_new = true;
203
+	}
204
+
205
+	public int hashCode() {
206
+		int x = _time;
207
+		x += (_machine * 111);
208
+		x += (_inc * 17);
209
+		return x;
210
+	}
211
+
212
+	public boolean equals(Object o) {
213
+
214
+		if (this == o)
215
+			return true;
216
+
217
+		ObjectID other = massageToObjectId(o);
218
+		if (other == null)
219
+			return false;
220
+
221
+		return _time == other._time && _machine == other._machine
222
+				&& _inc == other._inc;
223
+	}
224
+
225
+	public String toStringBabble() {
226
+		return babbleToMongod(toStringMongod());
227
+	}
228
+
229
+	public String toStringMongod() {
230
+		byte b[] = toByteArray();
231
+
232
+		StringBuilder buf = new StringBuilder(24);
233
+
234
+		for (int i = 0; i < b.length; i++) {
235
+			int x = b[i] & 0xFF;
236
+			String s = Integer.toHexString(x);
237
+			if (s.length() == 1)
238
+				buf.append("0");
239
+			buf.append(s);
240
+		}
241
+
242
+		return buf.toString();
243
+	}
244
+
245
+	public byte[] toByteArray() {
246
+		byte b[] = new byte[12];
247
+		ByteBuffer bb = ByteBuffer.wrap(b);
248
+		// by default BB is big endian like we need
249
+		bb.putInt(_time);
250
+		bb.putInt(_machine);
251
+		bb.putInt(_inc);
252
+		return b;
253
+	}
254
+
255
+	static String _pos(String s, int p) {
256
+		return s.substring(p * 2, (p * 2) + 2);
257
+	}
258
+
259
+	public static String babbleToMongod(String b) {
260
+		if (!isValid(b))
261
+			throw new IllegalArgumentException("invalid object id: " + b);
262
+
263
+		StringBuilder buf = new StringBuilder(24);
264
+		for (int i = 7; i >= 0; i--)
265
+			buf.append(_pos(b, i));
266
+		for (int i = 11; i >= 8; i--)
267
+			buf.append(_pos(b, i));
268
+
269
+		return buf.toString();
270
+	}
271
+
272
+	public String toString() {
273
+		return toStringMongod();
274
+	}
275
+
276
+	int _compareUnsigned(int i, int j) {
277
+		long li = 0xFFFFFFFFL;
278
+		li = i & li;
279
+		long lj = 0xFFFFFFFFL;
280
+		lj = j & lj;
281
+		long diff = li - lj;
282
+		if (diff < Integer.MIN_VALUE)
283
+			return Integer.MIN_VALUE;
284
+		if (diff > Integer.MAX_VALUE)
285
+			return Integer.MAX_VALUE;
286
+		return (int) diff;
287
+	}
288
+
289
+	public int compareTo(ObjectID id) {
290
+		if (id == null)
291
+			return -1;
292
+
293
+		int x = _compareUnsigned(_time, id._time);
294
+		if (x != 0)
295
+			return x;
296
+
297
+		x = _compareUnsigned(_machine, id._machine);
298
+		if (x != 0)
299
+			return x;
300
+
301
+		return _compareUnsigned(_inc, id._inc);
302
+	}
303
+
304
+	public int getMachine() {
305
+		return _machine;
306
+	}
307
+
308
+	/**
309
+	 * Gets the time of this ID, in milliseconds
310
+	 */
311
+	public long getTime() {
312
+		return _time * 1000L;
313
+	}
314
+
315
+	/**
316
+	 * Gets the time of this ID, in seconds
317
+	 */
318
+	public int getTimeSecond() {
319
+		return _time;
320
+	}
321
+
322
+	public int getInc() {
323
+		return _inc;
324
+	}
325
+
326
+	public int _time() {
327
+		return _time;
328
+	}
329
+
330
+	public int _machine() {
331
+		return _machine;
332
+	}
333
+
334
+	public int _inc() {
335
+		return _inc;
336
+	}
337
+
338
+	public boolean isNew() {
339
+		return _new;
340
+	}
341
+
342
+	public void notNew() {
343
+		_new = false;
344
+	}
345
+
346
+	/**
347
+	 * Gets the generated machine ID, identifying the machine / process / class
348
+	 * loader
349
+	 */
350
+	public static int getGenMachineId() {
351
+		return _genmachine;
352
+	}
353
+
354
+	/**
355
+	 * Gets the current value of the auto increment
356
+	 */
357
+	public static int getCurrentInc() {
358
+		return _nextInc.get();
359
+	}
360
+
361
+	final int _time;
362
+	final int _machine;
363
+	final int _inc;
364
+
365
+	boolean _new;
366
+
367
+	public static int _flip(int x) {
368
+		int z = 0;
369
+		z |= ((x << 24) & 0xFF000000);
370
+		z |= ((x << 8) & 0x00FF0000);
371
+		z |= ((x >> 8) & 0x0000FF00);
372
+		z |= ((x >> 24) & 0x000000FF);
373
+		return z;
374
+	}
375
+
376
+	private static AtomicInteger _nextInc = new AtomicInteger(
377
+			(new Random()).nextInt());
378
+
379
+	private static final int _genmachine;
380
+	static {
381
+		try {
382
+			// build a 2-byte machine piece based on NICs info
383
+			int machinePiece;
384
+			{
385
+				try {
386
+					StringBuilder sb = new StringBuilder();
387
+					Enumeration<NetworkInterface> e = NetworkInterface
388
+							.getNetworkInterfaces();
389
+					while (e.hasMoreElements()) {
390
+						NetworkInterface ni = e.nextElement();
391
+						sb.append(ni.toString());
392
+					}
393
+					machinePiece = sb.toString().hashCode() << 16;
394
+				} catch (Exception e) {
395
+					// exception sometimes happens with IBM JVM, use random
396
+					machinePiece = (new Random().nextInt()) << 16;
397
+				}
398
+			}
399
+			// add a 2 byte process piece. It must represent not only the JVM
400
+			// but the class loader.
401
+			// Since static var belong to class loader there could be collisions
402
+			// otherwise
403
+			final int processPiece;
404
+			{
405
+				int processId = new Random().nextInt();
406
+				try {
407
+					processId = ManagementFactory.getRuntimeMXBean().getName()
408
+							.hashCode();
409
+				} catch (Exception e) {
410
+				}
411
+				ClassLoader loader = ObjectID.class.getClassLoader();
412
+				int loaderId = loader != null ? System.identityHashCode(loader)
413
+						: 0;
414
+
415
+				StringBuilder sb = new StringBuilder();
416
+				sb.append(Integer.toHexString(processId));
417
+				sb.append(Integer.toHexString(loaderId));
418
+				processPiece = sb.toString().hashCode() & 0xFFFF;
419
+			}
420
+			_genmachine = machinePiece | processPiece;
421
+		} catch (Exception e) {
422
+			throw new RuntimeException(e);
423
+		}
424
+	}
425
+
426
+}

+ 38 - 0
src/main/java/com/zhaxd/core/conf/LoginInterceptor.java

@@ -0,0 +1,38 @@
1
+package com.zhaxd.core.conf;
2
+
3
+import javax.servlet.http.HttpServletRequest;
4
+import javax.servlet.http.HttpServletResponse;
5
+
6
+import org.springframework.web.servlet.HandlerInterceptor;
7
+import org.springframework.web.servlet.ModelAndView;
8
+
9
+import com.zhaxd.common.toolkit.Constant;
10
+
11
+public class LoginInterceptor implements HandlerInterceptor{
12
+
13
+	@Override
14
+	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
15
+			throws Exception {
16
+		Object attribute = request.getSession().getAttribute(Constant.SESSION_ID);
17
+		String uri = request.getRequestURI();
18
+		//登陆请求不能被拦截
19
+		if(!uri.contains("view/loginUI.shtml") && !uri.contains("index/login.shtml")){
20
+			//判断session中是否有值?
21
+			if(attribute == null){
22
+				response.sendRedirect(request.getContextPath() + "/view/loginUI.shtml");
23
+				return false;
24
+			}
25
+		}
26
+		return true;
27
+	}
28
+
29
+	@Override
30
+	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
31
+			ModelAndView modelAndView) throws Exception {		
32
+	}
33
+
34
+	@Override
35
+	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
36
+			throws Exception {	
37
+	}
38
+}

+ 95 - 0
src/main/java/com/zhaxd/core/conf/UTF8StringHttpMessageConverter.java

@@ -0,0 +1,95 @@
1
+package com.zhaxd.core.conf;
2
+
3
+import java.io.IOException;
4
+import java.io.InputStreamReader;
5
+import java.io.OutputStreamWriter;
6
+import java.io.UnsupportedEncodingException;
7
+import java.nio.charset.Charset;
8
+import java.util.ArrayList;
9
+import java.util.List;
10
+
11
+import org.springframework.http.HttpInputMessage;
12
+import org.springframework.http.HttpOutputMessage;
13
+import org.springframework.http.MediaType;
14
+import org.springframework.http.converter.AbstractHttpMessageConverter;
15
+import org.springframework.util.FileCopyUtils;
16
+/**
17
+ * @ClassName UTF8StringHttpMessageConverter 
18
+ * @Description 格式化springmvc返回值对象,防止出现乱码 
19
+ * @author gongym
20
+ * @date 2017317日 上午8:08:09
21
+ */
22
+public class UTF8StringHttpMessageConverter extends AbstractHttpMessageConverter<String> {
23
+
24
+	public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
25
+
26
+	private final List<Charset> availableCharsets;
27
+
28
+	private boolean writeAcceptCharset = true;
29
+
30
+	public UTF8StringHttpMessageConverter() {
31
+		super(new MediaType("text", "plain", DEFAULT_CHARSET), MediaType.ALL);
32
+		this.availableCharsets = new ArrayList<Charset>(Charset.availableCharsets().values());
33
+	}
34
+
35
+	/**
36
+	 * Indicates whether the {@code Accept-Charset} should be written to any
37
+	 * outgoing request.
38
+	 * <p>
39
+	 * Default is {@code true}.
40
+	 */
41
+	public void setWriteAcceptCharset(boolean writeAcceptCharset) {
42
+		this.writeAcceptCharset = writeAcceptCharset;
43
+	}
44
+
45
+	@Override
46
+	public boolean supports(Class<?> clazz) {
47
+		return String.class.equals(clazz);
48
+	}
49
+
50
+	@Override
51
+	protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException {
52
+		Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType());
53
+		return FileCopyUtils.copyToString(new InputStreamReader(inputMessage.getBody(), charset));
54
+	}
55
+
56
+	@Override
57
+	protected Long getContentLength(String s, MediaType contentType) {
58
+		Charset charset = getContentTypeCharset(contentType);
59
+		try {
60
+			return (long) s.getBytes(charset.name()).length;
61
+		} catch (UnsupportedEncodingException ex) {
62
+			throw new InternalError(ex.getMessage());
63
+		}
64
+	}
65
+
66
+	@Override
67
+	protected void writeInternal(String s, HttpOutputMessage outputMessage) throws IOException {
68
+		if (writeAcceptCharset) {
69
+			outputMessage.getHeaders().setAcceptCharset(getAcceptedCharsets());
70
+		}
71
+		Charset charset = getContentTypeCharset(outputMessage.getHeaders().getContentType());
72
+		FileCopyUtils.copy(s, new OutputStreamWriter(outputMessage.getBody(), charset));
73
+	}
74
+
75
+	/**
76
+	 * Return the list of supported {@link Charset}.
77
+	 *
78
+	 * <p>
79
+	 * By default, returns {@link Charset#availableCharsets()}. Can be
80
+	 * overridden in subclasses.
81
+	 *
82
+	 * @return the list of accepted charsets
83
+	 */
84
+	protected List<Charset> getAcceptedCharsets() {
85
+		return this.availableCharsets;
86
+	}
87
+
88
+	private Charset getContentTypeCharset(MediaType contentType) {
89
+		if (contentType != null && contentType.getCharset() != null) {
90
+			return contentType.getCharset();
91
+		} else {
92
+			return DEFAULT_CHARSET;
93
+		}
94
+	}
95
+}

+ 36 - 0
src/main/java/com/zhaxd/core/dto/BootTablePage.java

@@ -0,0 +1,36 @@
1
+package com.zhaxd.core.dto;
2
+
3
+import java.util.List;
4
+
5
+/**
6
+ * BootstrapTable表格规定
7
+ * 返回数据格式
8
+ */
9
+public class BootTablePage {
10
+
11
+	//总数量
12
+	private long total;
13
+	//每一页的数据
14
+	private List<?> rows;
15
+	
16
+	public BootTablePage() {
17
+	}
18
+	public BootTablePage(long total, List<?> rows) {
19
+		super();
20
+		this.total = total;
21
+		this.rows = rows;
22
+	}
23
+
24
+	public long getTotal() {
25
+		return total;
26
+	}
27
+	public void setTotal(long total) {
28
+		this.total = total;
29
+	}
30
+	public List<?> getRows() {
31
+		return rows;
32
+	}
33
+	public void setRows(List<?> rows) {
34
+		this.rows = rows;
35
+	}
36
+}

+ 143 - 0
src/main/java/com/zhaxd/core/dto/ResultDto.java

@@ -0,0 +1,143 @@
1
+package com.zhaxd.core.dto;
2
+
3
+import java.text.SimpleDateFormat;
4
+
5
+import com.fasterxml.jackson.databind.ObjectMapper;
6
+
7
+public class ResultDto {
8
+
9
+	/**
10
+     * 定义返回值状态
11
+     */
12
+    private String status;
13
+    /**
14
+     * 返回值数据
15
+     */
16
+    private Object data;
17
+    /**
18
+     * 返回值失败携带提示信息
19
+     */
20
+    private String message;
21
+
22
+    /**
23
+     * jackson进行json序列化工具
24
+     */
25
+    private static ObjectMapper objectMapper = new ObjectMapper();
26
+    /**
27
+     * 序列化中的时间格式化
28
+     */
29
+    private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
30
+
31
+
32
+    public ResultDto() { }
33
+    
34
+    public ResultDto(String status) { 
35
+    	this.status = status;
36
+    }
37
+
38
+    private ResultDto(String status, Object data){
39
+        this.status = status;
40
+        this.data = data;
41
+    }
42
+    
43
+    private ResultDto(String status, String message) {
44
+        this.status = status;
45
+        this.message = message;
46
+    }
47
+
48
+    /**
49
+     * 返回成功,返回列表,需要自定义时间格式化
50
+     * @param status 返回值状态
51
+     * @param data 返回的列表数据
52
+     * @param pageable 返回的列表携带的分页数据(需要和前端框架中的分页参数进行协商好)
53
+     * @param DateFormat 返回的列表需要时间格式化的自定义格式
54
+     * @return JSON字符串
55
+     */
56
+    public static String resultListWithFormat(String status, Object data, String DateFormat) {
57
+        try {
58
+            objectMapper.setDateFormat(new SimpleDateFormat(DateFormat));
59
+            return objectMapper.writeValueAsString(new ResultDto(status, data));
60
+        } catch (Exception e) {
61
+            return null;
62
+        }
63
+    }
64
+
65
+    /**
66
+     * 返回成功,返回列表,默认时间格式化
67
+     * @param status 返回值状态
68
+     * @param data 返回值列表数据
69
+     * @param pageable 返回列表携带的分页数据
70
+     * @return JSON字符串
71
+     */
72
+    public static String resultList(String status, Object data) {
73
+        try {
74
+            objectMapper.setDateFormat(new SimpleDateFormat(DEFAULT_DATE_FORMAT));
75
+            return objectMapper.writeValueAsString(new ResultDto(status, data));
76
+        } catch (Exception e) {
77
+            return null;
78
+        }
79
+    }
80
+
81
+    /**
82
+     * 返回成功,返回单个实体
83
+     * @param data 单个实体的数据
84
+     * @return JSON字符串
85
+     */
86
+    public static String success(Object data) {
87
+        try {
88
+            objectMapper.setDateFormat(new SimpleDateFormat(DEFAULT_DATE_FORMAT));
89
+            return objectMapper.writeValueAsString(new ResultDto("success", data));
90
+        } catch (Exception e) {
91
+            return null;
92
+        }
93
+    }
94
+
95
+    /**
96
+     * 返回成功,没有参数
97
+     * @return JSON字符串
98
+     */
99
+    public static String success() {
100
+        try {
101
+            return objectMapper.writeValueAsString(new ResultDto("success"));
102
+        } catch (Exception e) {
103
+            return null;
104
+        }
105
+    }
106
+
107
+    /**
108
+     * 返回失败
109
+     * @param message 返回失败的提示信息
110
+     * @return JSON字符串
111
+     */
112
+    public static String fail(String message) {
113
+        try {
114
+            return objectMapper.writeValueAsString(new ResultDto("error", message));
115
+        } catch (Exception e) {
116
+            return null;
117
+        }
118
+    }
119
+
120
+    public String getStatus() {
121
+        return status;
122
+    }
123
+
124
+    public void setStatus(String status) {
125
+        this.status = status;
126
+    }
127
+
128
+    public Object getData() {
129
+        return data;
130
+    }
131
+
132
+    public void setData(Object data) {
133
+        this.data = data;
134
+    }
135
+
136
+    public String getMessage() {
137
+        return message;
138
+    }
139
+
140
+    public void setMessage(String message) {
141
+        this.message = message;
142
+    }
143
+}

+ 82 - 0
src/main/java/com/zhaxd/core/dto/kettle/RepositoryTree.java

@@ -0,0 +1,82 @@
1
+package com.zhaxd.core.dto.kettle;
2
+
3
+public class RepositoryTree {
4
+
5
+	private String id;
6
+	private String parent;
7
+	private String text;
8
+	private String icon;
9
+	private Object state;
10
+	private String type;
11
+	private boolean isLasted;
12
+	private String path;
13
+	
14
+	public String getType() {
15
+		return type;
16
+	}
17
+	public void setType(String type) {
18
+		this.type = type;
19
+	}
20
+	public String getPath() {
21
+		return path;
22
+	}
23
+	public void setPath(String path) {
24
+		this.path = path;
25
+	}
26
+	public boolean isLasted() {
27
+		return isLasted;
28
+	}
29
+	public void setLasted(boolean isLasted) {
30
+		this.isLasted = isLasted;
31
+	}
32
+	public String getId() {
33
+		return id;
34
+	}
35
+	public void setId(String id) {
36
+		this.id = id;
37
+	}
38
+	public String getParent() {
39
+		return parent;
40
+	}
41
+	public void setParent(String parent) {
42
+		this.parent = parent;
43
+	}
44
+	public String getText() {
45
+		return text;
46
+	}
47
+	public void setText(String text) {
48
+		this.text = text;
49
+	}
50
+	public String getIcon() {
51
+		return icon;
52
+	}
53
+	public void setIcon(String icon) {
54
+		this.icon = icon;
55
+	}
56
+	public Object getState() {
57
+		return state;
58
+	}
59
+	public void setState(Object state) {
60
+		this.state = state;
61
+	}
62
+	public RepositoryTree(String id, String parent, String text, String icon, Object state, String type,
63
+			boolean isLasted, String path) {
64
+		super();
65
+		this.id = id;
66
+		this.parent = parent;
67
+		this.text = text;
68
+		this.icon = icon;
69
+		this.state = state;
70
+		this.type = type;
71
+		this.isLasted = isLasted;
72
+		this.path = path;
73
+	}
74
+	public RepositoryTree() {
75
+	}
76
+	
77
+	@Override
78
+	public String toString() {
79
+		return "RepositoryTree [id=" + id + ", parent=" + parent + ", text=" + text + ", icon=" + icon + ", state="
80
+				+ state + ", type=" + type + ", isLasted=" + isLasted + ", path=" + path + "]";
81
+	}	
82
+}

+ 86 - 0
src/main/java/com/zhaxd/core/dto/web/KRepositoryDto.java

@@ -0,0 +1,86 @@
1
+package com.zhaxd.core.dto.web;
2
+
3
+public class KRepositoryDto {
4
+
5
+	//资源库数据库访问模式("Native", "ODBC", "OCI", "Plugin", "JNDI")
6
+	private String databaseAccess;
7
+	//资源库数据库主机名或者IP地址
8
+	private String databaseHost;
9
+	//资源库数据库名称
10
+	private String databaseName;
11
+	//数据库登录密码
12
+	private String databasePassword;
13
+	//资源库数据库端口号
14
+	private String databasePort;
15
+	//数据库登录账号
16
+	private String databaseUsername;
17
+	//资源库名称
18
+	private String repositoryName;
19
+	//登录密码
20
+	private String repositoryPassword;
21
+	//资源库数据库类型(MYSQL、ORACLE)
22
+	private String repositoryType;
23
+	//登录用户名
24
+	private String repositoryUsername;
25
+	
26
+	public String getDatabaseAccess() {
27
+		return databaseAccess;
28
+	}
29
+	public void setDatabaseAccess(String databaseAccess) {
30
+		this.databaseAccess = databaseAccess;
31
+	}
32
+	public String getDatabaseHost() {
33
+		return databaseHost;
34
+	}
35
+	public void setDatabaseHost(String databaseHost) {
36
+		this.databaseHost = databaseHost;
37
+	}
38
+	public String getDatabaseName() {
39
+		return databaseName;
40
+	}
41
+	public void setDatabaseName(String databaseName) {
42
+		this.databaseName = databaseName;
43
+	}
44
+	public String getDatabasePassword() {
45
+		return databasePassword;
46
+	}
47
+	public void setDatabasePassword(String databasePassword) {
48
+		this.databasePassword = databasePassword;
49
+	}
50
+	public String getDatabasePort() {
51
+		return databasePort;
52
+	}
53
+	public void setDatabasePort(String databasePort) {
54
+		this.databasePort = databasePort;
55
+	}
56
+	public String getDatabaseUsername() {
57
+		return databaseUsername;
58
+	}
59
+	public void setDatabaseUsername(String databaseUsername) {
60
+		this.databaseUsername = databaseUsername;
61
+	}
62
+	public String getRepositoryName() {
63
+		return repositoryName;
64
+	}
65
+	public void setRepositoryName(String repositoryName) {
66
+		this.repositoryName = repositoryName;
67
+	}
68
+	public String getRepositoryPassword() {
69
+		return repositoryPassword;
70
+	}
71
+	public void setRepositoryPassword(String repositoryPassword) {
72
+		this.repositoryPassword = repositoryPassword;
73
+	}
74
+	public String getRepositoryType() {
75
+		return repositoryType;
76
+	}
77
+	public void setRepositoryType(String repositoryType) {
78
+		this.repositoryType = repositoryType;
79
+	}
80
+	public String getRepositoryUsername() {
81
+		return repositoryUsername;
82
+	}
83
+	public void setRepositoryUsername(String repositoryUsername) {
84
+		this.repositoryUsername = repositoryUsername;
85
+	}
86
+}

+ 7 - 0
src/main/java/com/zhaxd/core/mapper/KCategoryDao.java

@@ -0,0 +1,7 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import com.zhaxd.core.model.KCategory;
4
+import org.beetl.sql.core.mapper.BaseMapper;
5
+
6
+public interface KCategoryDao extends BaseMapper<KCategory> {
7
+}

+ 19 - 0
src/main/java/com/zhaxd/core/mapper/KJobDao.java

@@ -0,0 +1,19 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import com.zhaxd.core.model.KJob;
4
+import org.beetl.sql.core.annotatoin.SqlStatement;
5
+import org.beetl.sql.core.mapper.BaseMapper;
6
+
7
+import java.util.List;
8
+
9
+
10
+public interface KJobDao extends BaseMapper<KJob> {
11
+    @SqlStatement(params = "kJob,start,size")
12
+    List<KJob> pageQuery(KJob kJob, Integer start, Integer size);
13
+
14
+    @SqlStatement(params = "kJob")
15
+    List<KJob> queryByCondition(KJob kJob);
16
+
17
+    @SqlStatement(params = "kJob")
18
+    Long allCount(KJob kJob);
19
+}

+ 17 - 0
src/main/java/com/zhaxd/core/mapper/KJobMonitorDao.java

@@ -0,0 +1,17 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.annotatoin.SqlStatement;
4
+import org.beetl.sql.core.mapper.BaseMapper;
5
+
6
+import com.zhaxd.core.model.*;
7
+
8
+import java.util.List;
9
+
10
+
11
+public interface KJobMonitorDao extends BaseMapper<KJobMonitor> {
12
+    @SqlStatement(params = "kJobMonitor,start,size,categoryId")
13
+    List<KJobMonitor> pageQuery(KJobMonitor kJobMonitor, Integer start, Integer size, Integer categoryId);
14
+
15
+    @SqlStatement(params = "kJobMonitor,categoryId")
16
+    Long allCount(KJobMonitor kJobMonitor, Integer categoryId);
17
+}

+ 10 - 0
src/main/java/com/zhaxd/core/mapper/KJobRecordDao.java

@@ -0,0 +1,10 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.mapper.BaseMapper;
4
+
5
+import com.zhaxd.core.model.*;
6
+
7
+
8
+public interface KJobRecordDao extends BaseMapper<KJobRecord> {
9
+	
10
+}

+ 10 - 0
src/main/java/com/zhaxd/core/mapper/KQuartzDao.java

@@ -0,0 +1,10 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.mapper.BaseMapper;
4
+
5
+import com.zhaxd.core.model.*;
6
+
7
+
8
+public interface KQuartzDao extends BaseMapper<KQuartz> {
9
+	
10
+}

+ 10 - 0
src/main/java/com/zhaxd/core/mapper/KRepositoryDao.java

@@ -0,0 +1,10 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.mapper.BaseMapper;
4
+
5
+import com.zhaxd.core.model.*;
6
+
7
+
8
+public interface KRepositoryDao extends BaseMapper<KRepository> {
9
+	
10
+}

+ 10 - 0
src/main/java/com/zhaxd/core/mapper/KRepositoryTypeDao.java

@@ -0,0 +1,10 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.mapper.BaseMapper;
4
+
5
+import com.zhaxd.core.model.*;
6
+
7
+
8
+public interface KRepositoryTypeDao extends BaseMapper<KRepositoryType> {
9
+	
10
+}

+ 20 - 0
src/main/java/com/zhaxd/core/mapper/KTransDao.java

@@ -0,0 +1,20 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.annotatoin.SqlStatement;
4
+import org.beetl.sql.core.mapper.BaseMapper;
5
+
6
+import com.zhaxd.core.model.*;
7
+
8
+import java.util.List;
9
+
10
+
11
+public interface KTransDao extends BaseMapper<KTrans> {
12
+    @SqlStatement(params = "kTrans,start,size")
13
+    List<KTrans> pageQuery(KTrans kTrans, Integer start, Integer size);
14
+
15
+    @SqlStatement(params = "kTrans")
16
+    List<KTrans> queryByCondition(KTrans kTrans);
17
+
18
+    @SqlStatement(params = "kTrans")
19
+    Long allCount(KTrans kTrans);
20
+}

+ 17 - 0
src/main/java/com/zhaxd/core/mapper/KTransMonitorDao.java

@@ -0,0 +1,17 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.annotatoin.SqlStatement;
4
+import org.beetl.sql.core.mapper.BaseMapper;
5
+
6
+import com.zhaxd.core.model.*;
7
+
8
+import java.util.List;
9
+
10
+
11
+public interface KTransMonitorDao extends BaseMapper<KTransMonitor> {
12
+    @SqlStatement(params = "kTransMonitor,start,size,categoryId")
13
+    List<KTransMonitor> pageQuery(KTransMonitor kTransMonitor, Integer start, Integer size, Integer categoryId);
14
+
15
+    @SqlStatement(params = "kTransMonitor,categoryId")
16
+    Long allCount(KTransMonitor kTransMonitor, Integer categoryId);
17
+}

+ 10 - 0
src/main/java/com/zhaxd/core/mapper/KTransRecordDao.java

@@ -0,0 +1,10 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.mapper.BaseMapper;
4
+
5
+import com.zhaxd.core.model.*;
6
+
7
+
8
+public interface KTransRecordDao extends BaseMapper<KTransRecord> {
9
+	
10
+}

+ 10 - 0
src/main/java/com/zhaxd/core/mapper/KUserDao.java

@@ -0,0 +1,10 @@
1
+package com.zhaxd.core.mapper;
2
+
3
+import org.beetl.sql.core.mapper.BaseMapper;
4
+
5
+import com.zhaxd.core.model.*;
6
+
7
+
8
+public interface KUserDao extends BaseMapper<KUser> {
9
+	
10
+}

+ 105 - 0
src/main/java/com/zhaxd/core/model/KCategory.java

@@ -0,0 +1,105 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KCategory {
8
+    //分类ID
9
+    @SeqID(name="CATEGORY_ID_SEQ")
10
+    private Integer categoryId ;
11
+    //分类名称
12
+    private String categoryName;
13
+    //添加者
14
+    private Integer addUser ;
15
+    //是否删除(1:存在;0:删除)
16
+    private Integer delFlag ;
17
+    //编辑者
18
+    private Integer editUser ;
19
+    //添加时间
20
+    private Date addTime ;
21
+    //编辑时间
22
+    private Date editTime ;
23
+
24
+    public KCategory() {
25
+    }
26
+
27
+    public Integer getCategoryId() {
28
+        return categoryId;
29
+    }
30
+
31
+    public void setCategoryId(Integer categoryId) {
32
+        this.categoryId = categoryId;
33
+    }
34
+
35
+    public String getCategoryName() {
36
+        return categoryName;
37
+    }
38
+
39
+    public void setCategoryName(String categoryName) {
40
+        this.categoryName = categoryName;
41
+    }
42
+
43
+    public Integer getAddUser() {
44
+        return addUser;
45
+    }
46
+
47
+    public void setAddUser(Integer addUser) {
48
+        this.addUser = addUser;
49
+    }
50
+
51
+    public Integer getDelFlag() {
52
+        return delFlag;
53
+    }
54
+
55
+    public void setDelFlag(Integer delFlag) {
56
+        this.delFlag = delFlag;
57
+    }
58
+
59
+    public Integer getEditUser() {
60
+        return editUser;
61
+    }
62
+
63
+    public void setEditUser(Integer editUser) {
64
+        this.editUser = editUser;
65
+    }
66
+
67
+    public Date getAddTime() {
68
+        return addTime;
69
+    }
70
+
71
+    public void setAddTime(Date addTime) {
72
+        this.addTime = addTime;
73
+    }
74
+
75
+    public Date getEditTime() {
76
+        return editTime;
77
+    }
78
+
79
+    public void setEditTime(Date editTime) {
80
+        this.editTime = editTime;
81
+    }
82
+
83
+    public KCategory(Integer categoryId, String categoryName, Integer addUser, Integer delFlag, Integer editUser, Date addTime, Date editTime) {
84
+        this.categoryId = categoryId;
85
+        this.categoryName = categoryName;
86
+        this.addUser = addUser;
87
+        this.delFlag = delFlag;
88
+        this.editUser = editUser;
89
+        this.addTime = addTime;
90
+        this.editTime = editTime;
91
+    }
92
+
93
+    @Override
94
+    public String toString() {
95
+        return "KCategory{" +
96
+                "categoryId=" + categoryId +
97
+                ", categoryName='" + categoryName + '\'' +
98
+                ", addUser=" + addUser +
99
+                ", delFlag=" + delFlag +
100
+                ", editUser=" + editUser +
101
+                ", addTime=" + addTime +
102
+                ", editTime=" + editTime +
103
+                '}';
104
+    }
105
+}

+ 212 - 0
src/main/java/com/zhaxd/core/model/KJob.java

@@ -0,0 +1,212 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KJob {
8
+    //作业ID
9
+    @SeqID(name="JOB_ID_SEQ")
10
+    private Integer jobId;
11
+    private Integer categoryId;
12
+    //添加者
13
+    private Integer addUser;
14
+    //是否删除(1:存在;0:删除)
15
+    private Integer delFlag;
16
+    //编辑者
17
+    private Integer editUser;
18
+    //作业执行日志(外键ID)
19
+    private Integer jobRecord;
20
+    //定时策略(外键ID)
21
+    private Integer jobQuartz;
22
+    //作业的资源库ID
23
+    private Integer jobRepositoryId;
24
+    //状态(1:正在运行;2:已停止)
25
+    private Integer jobStatus;
26
+    //1:数据库资源库;2:上传的文件
27
+    private Integer jobType;
28
+    //任务描述
29
+    private String jobDescription;
30
+    //作业名称
31
+    private String jobName;
32
+    //作业保存路径(可以是资源库中的路径也可以是服务器中保存作业文件的路径)
33
+    private String jobPath;
34
+    //日志级别(basic,detail,error,debug,minimal,rowlevel)
35
+    private String jobLogLevel;
36
+    //添加时间
37
+    private Date addTime;
38
+    //编辑时间
39
+    private Date editTime;
40
+
41
+    public KJob() {
42
+    }
43
+
44
+    public Integer getJobId() {
45
+        return jobId;
46
+    }
47
+
48
+    public void setJobId(Integer jobId) {
49
+        this.jobId = jobId;
50
+    }
51
+
52
+    public Integer getAddUser() {
53
+        return addUser;
54
+    }
55
+
56
+    public void setAddUser(Integer addUser) {
57
+        this.addUser = addUser;
58
+    }
59
+
60
+    public Integer getDelFlag() {
61
+        return delFlag;
62
+    }
63
+
64
+    public void setDelFlag(Integer delFlag) {
65
+        this.delFlag = delFlag;
66
+    }
67
+
68
+    public Integer getEditUser() {
69
+        return editUser;
70
+    }
71
+
72
+    public void setEditUser(Integer editUser) {
73
+        this.editUser = editUser;
74
+    }
75
+
76
+    public Integer getJobRecord() {
77
+        return jobRecord;
78
+    }
79
+
80
+    public void setJobRecord(Integer jobRecord) {
81
+        this.jobRecord = jobRecord;
82
+    }
83
+
84
+    public Integer getJobQuartz() {
85
+        return jobQuartz;
86
+    }
87
+
88
+    public void setJobQuartz(Integer jobQuartz) {
89
+        this.jobQuartz = jobQuartz;
90
+    }
91
+
92
+    public Integer getJobRepositoryId() {
93
+        return jobRepositoryId;
94
+    }
95
+
96
+    public void setJobRepositoryId(Integer jobRepositoryId) {
97
+        this.jobRepositoryId = jobRepositoryId;
98
+    }
99
+
100
+    public Integer getJobStatus() {
101
+        return jobStatus;
102
+    }
103
+
104
+    public void setJobStatus(Integer jobStatus) {
105
+        this.jobStatus = jobStatus;
106
+    }
107
+
108
+    public Integer getJobType() {
109
+        return jobType;
110
+    }
111
+
112
+    public void setJobType(Integer jobType) {
113
+        this.jobType = jobType;
114
+    }
115
+
116
+    public String getJobDescription() {
117
+        return jobDescription;
118
+    }
119
+
120
+    public void setJobDescription(String jobDescription) {
121
+        this.jobDescription = jobDescription;
122
+    }
123
+
124
+    public String getJobName() {
125
+        return jobName;
126
+    }
127
+
128
+    public void setJobName(String jobName) {
129
+        this.jobName = jobName;
130
+    }
131
+
132
+    public String getJobPath() {
133
+        return jobPath;
134
+    }
135
+
136
+    public void setJobPath(String jobPath) {
137
+        this.jobPath = jobPath;
138
+    }
139
+
140
+    public Date getAddTime() {
141
+        return addTime;
142
+    }
143
+
144
+    public void setAddTime(Date addTime) {
145
+        this.addTime = addTime;
146
+    }
147
+
148
+    public Date getEditTime() {
149
+        return editTime;
150
+    }
151
+
152
+    public void setEditTime(Date editTime) {
153
+        this.editTime = editTime;
154
+    }
155
+
156
+    public String getJobLogLevel() {
157
+        return jobLogLevel;
158
+    }
159
+
160
+    public void setJobLogLevel(String jobLogLevel) {
161
+        this.jobLogLevel = jobLogLevel;
162
+    }
163
+
164
+    public Integer getCategoryId() {
165
+        return categoryId;
166
+    }
167
+
168
+    public void setCategoryId(Integer categoryId) {
169
+        this.categoryId = categoryId;
170
+    }
171
+
172
+    public KJob(Integer jobId, Integer categoryId, Integer addUser, Integer delFlag, Integer editUser, Integer jobRecord, Integer jobQuartz, Integer jobRepositoryId, Integer jobStatus, Integer jobType, String jobDescription, String jobName, String jobPath, String jobLogLevel, Date addTime, Date editTime) {
173
+        this.jobId = jobId;
174
+        this.categoryId = categoryId;
175
+        this.addUser = addUser;
176
+        this.delFlag = delFlag;
177
+        this.editUser = editUser;
178
+        this.jobRecord = jobRecord;
179
+        this.jobQuartz = jobQuartz;
180
+        this.jobRepositoryId = jobRepositoryId;
181
+        this.jobStatus = jobStatus;
182
+        this.jobType = jobType;
183
+        this.jobDescription = jobDescription;
184
+        this.jobName = jobName;
185
+        this.jobPath = jobPath;
186
+        this.jobLogLevel = jobLogLevel;
187
+        this.addTime = addTime;
188
+        this.editTime = editTime;
189
+    }
190
+
191
+    @Override
192
+    public String toString() {
193
+        return "KJob{" +
194
+                "jobId=" + jobId +
195
+                ", categoryId=" + categoryId +
196
+                ", addUser=" + addUser +
197
+                ", delFlag=" + delFlag +
198
+                ", editUser=" + editUser +
199
+                ", jobRecord=" + jobRecord +
200
+                ", jobQuartz=" + jobQuartz +
201
+                ", jobRepositoryId=" + jobRepositoryId +
202
+                ", jobStatus=" + jobStatus +
203
+                ", jobType=" + jobType +
204
+                ", jobDescription='" + jobDescription + '\'' +
205
+                ", jobName='" + jobName + '\'' +
206
+                ", jobPath='" + jobPath + '\'' +
207
+                ", jobLogLevel='" + jobLogLevel + '\'' +
208
+                ", addTime=" + addTime +
209
+                ", editTime=" + editTime +
210
+                '}';
211
+    }
212
+}

+ 145 - 0
src/main/java/com/zhaxd/core/model/KJobMonitor.java

@@ -0,0 +1,145 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KJobMonitor implements Comparable<KJobMonitor>{
8
+	//监控作业ID
9
+	@SeqID(name="JOB_MONITOR_ID_SEQ")
10
+	private Integer monitorId ;
11
+	//添加人
12
+	private Integer addUser ;
13
+	//失败次数
14
+	private Integer monitorFail ;
15
+	//监控的作业ID
16
+	private Integer monitorJob ;
17
+	//监控状态(是否启动,1:启动;2:停止)
18
+	private Integer monitorStatus ;
19
+	//成功次数
20
+	private Integer monitorSuccess ;
21
+	//运行状态(起始时间-结束时间,起始时间-结束时间……)
22
+	private String runStatus ;
23
+	//上次执行时间
24
+	private Date lastExecuteTime;
25
+	//下次执行时间
26
+	private Date nextExecuteTime;
27
+
28
+	private String jobName;
29
+
30
+	private String categoryName;
31
+
32
+	public KJobMonitor() {
33
+	}
34
+
35
+	public Integer getMonitorId(){
36
+		return  monitorId;
37
+	}
38
+	public void setMonitorId(Integer monitorId){
39
+		this.monitorId = monitorId;
40
+	}
41
+	public Integer getAddUser(){
42
+		return  addUser;
43
+	}
44
+	public void setAddUser(Integer addUser){
45
+		this.addUser = addUser;
46
+	}
47
+	public Integer getMonitorFail(){
48
+		return  monitorFail;
49
+	}
50
+	public void setMonitorFail(Integer monitorFail){
51
+		this.monitorFail = monitorFail;
52
+	}
53
+	public Integer getMonitorJob(){
54
+		return  monitorJob;
55
+	}
56
+	public void setMonitorJob(Integer monitorJob){
57
+		this.monitorJob = monitorJob;
58
+	}
59
+	public Integer getMonitorStatus(){
60
+		return  monitorStatus;
61
+	}
62
+	public void setMonitorStatus(Integer monitorStatus){
63
+		this.monitorStatus = monitorStatus;
64
+	}
65
+	public Integer getMonitorSuccess(){
66
+		return  monitorSuccess;
67
+	}
68
+	public void setMonitorSuccess(Integer monitorSuccess){
69
+		this.monitorSuccess = monitorSuccess;
70
+	}
71
+	public String getRunStatus(){
72
+		return  runStatus;
73
+	}
74
+	public void setRunStatus(String runStatus){
75
+		this.runStatus = runStatus;
76
+	}
77
+
78
+	public Date getLastExecuteTime() {
79
+		return lastExecuteTime;
80
+	}
81
+
82
+	public void setLastExecuteTime(Date lastExecuteTime) {
83
+		this.lastExecuteTime = lastExecuteTime;
84
+	}
85
+
86
+	public Date getNextExecuteTime() {
87
+		return nextExecuteTime;
88
+	}
89
+
90
+	public void setNextExecuteTime(Date nextExecuteTime) {
91
+		this.nextExecuteTime = nextExecuteTime;
92
+	}
93
+
94
+	public String getJobName() {
95
+		return jobName;
96
+	}
97
+
98
+	public void setJobName(String jobName) {
99
+		this.jobName = jobName;
100
+	}
101
+
102
+	public String getCategoryName() {
103
+		return categoryName;
104
+	}
105
+
106
+	public void setCategoryName(String categoryName) {
107
+		this.categoryName = categoryName;
108
+	}
109
+
110
+	@Override
111
+    public int compareTo(KJobMonitor kJobMonitor) {
112
+        return this.getMonitorSuccess() - kJobMonitor.getMonitorSuccess();//按照成功次数排序;
113
+    }
114
+
115
+	public KJobMonitor(Integer monitorId, Integer addUser, Integer monitorFail, Integer monitorJob, Integer monitorStatus, Integer monitorSuccess, String runStatus, Date lastExecuteTime, Date nextExecuteTime, String jobName, String categoryName) {
116
+		this.monitorId = monitorId;
117
+		this.addUser = addUser;
118
+		this.monitorFail = monitorFail;
119
+		this.monitorJob = monitorJob;
120
+		this.monitorStatus = monitorStatus;
121
+		this.monitorSuccess = monitorSuccess;
122
+		this.runStatus = runStatus;
123
+		this.lastExecuteTime = lastExecuteTime;
124
+		this.nextExecuteTime = nextExecuteTime;
125
+		this.jobName = jobName;
126
+		this.categoryName = categoryName;
127
+	}
128
+
129
+	@Override
130
+	public String toString() {
131
+		return "KJobMonitor{" +
132
+				"monitorId=" + monitorId +
133
+				", addUser=" + addUser +
134
+				", monitorFail=" + monitorFail +
135
+				", monitorJob=" + monitorJob +
136
+				", monitorStatus=" + monitorStatus +
137
+				", monitorSuccess=" + monitorSuccess +
138
+				", runStatus='" + runStatus + '\'' +
139
+				", lastExecuteTime=" + lastExecuteTime +
140
+				", nextExecuteTime=" + nextExecuteTime +
141
+				", jobName='" + jobName + '\'' +
142
+				", categoryName='" + categoryName + '\'' +
143
+				'}';
144
+	}
145
+}

+ 83 - 0
src/main/java/com/zhaxd/core/model/KJobRecord.java

@@ -0,0 +1,83 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KJobRecord {
8
+	//作业记录ID
9
+	@SeqID(name="JOB_RECORD_ID_SEQ")
10
+	private Integer recordId ;
11
+	//作业ID
12
+	private Integer recordJob ;
13
+	//任务执行结果(1:成功;2:失败)
14
+	private Integer recordStatus ;
15
+	//添加人
16
+	private Integer addUser;
17
+	//作业日志记录文件保存位置
18
+	private String logFilePath ;
19
+	//启动时间
20
+	private Date startTime ;
21
+	//停止时间
22
+	private Date stopTime ;
23
+
24
+	public KJobRecord() {
25
+	}
26
+
27
+	public Integer getRecordId(){
28
+		return  recordId;
29
+	}
30
+	public void setRecordId(Integer recordId ){
31
+		this.recordId = recordId;
32
+	}
33
+
34
+	public Integer getRecordJob(){
35
+		return  recordJob;
36
+	}
37
+	public void setRecordJob(Integer recordJob ){
38
+		this.recordJob = recordJob;
39
+	}
40
+
41
+	public Integer getRecordStatus(){
42
+		return  recordStatus;
43
+	}
44
+	public void setRecordStatus(Integer recordStatus ){
45
+		this.recordStatus = recordStatus;
46
+	}
47
+
48
+	public String getLogFilePath(){
49
+		return  logFilePath;
50
+	}
51
+	public void setLogFilePath(String logFilePath ){
52
+		this.logFilePath = logFilePath;
53
+	}
54
+
55
+	public Date getStartTime(){
56
+		return  startTime;
57
+	}
58
+	public void setStartTime(Date startTime ){
59
+		this.startTime = startTime;
60
+	}
61
+
62
+	public Date getStopTime(){
63
+		return  stopTime;
64
+	}
65
+	public void setStopTime(Date stopTime ){
66
+		this.stopTime = stopTime;
67
+	}
68
+
69
+	@Override
70
+	public String toString() {
71
+		return "KJobRecord [recordId=" + recordId + ", recordJob=" + recordJob + ", recordStatus=" + recordStatus
72
+				+ ", addUser=" + addUser + ", logFilePath=" + logFilePath + ", startTime=" + startTime + ", stopTime="
73
+				+ stopTime + "]";
74
+	}
75
+
76
+	public Integer getAddUser() {
77
+		return addUser;
78
+	}
79
+
80
+	public void setAddUser(Integer addUser) {
81
+		this.addUser = addUser;
82
+	}
83
+}

+ 85 - 0
src/main/java/com/zhaxd/core/model/KQuartz.java

@@ -0,0 +1,85 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KQuartz {
8
+	//任务ID
9
+	@SeqID(name="QUARTZ_ID_SEQ")
10
+	private Integer quartzId ;
11
+	//添加者
12
+	private Integer addUser ;
13
+	//是否删除(1:存在;0:删除)
14
+	private Integer delFlag ;
15
+	//编辑者
16
+	private Integer editUser ;
17
+	//定时策略
18
+	private String quartzCron ;
19
+	//任务描述
20
+	private String quartzDescription ;
21
+	//添加时间
22
+	private Date addTime ;
23
+	//编辑时间
24
+	private Date editTime ;
25
+
26
+	public KQuartz() {
27
+	}
28
+
29
+	public Integer getQuartzId(){
30
+		return  quartzId;
31
+	}
32
+	public void setQuartzId(Integer quartzId ){
33
+		this.quartzId = quartzId;
34
+	}
35
+
36
+	public Integer getAddUser(){
37
+		return  addUser;
38
+	}
39
+	public void setAddUser(Integer addUser ){
40
+		this.addUser = addUser;
41
+	}
42
+
43
+	public Integer getDelFlag(){
44
+		return  delFlag;
45
+	}
46
+	public void setDelFlag(Integer delFlag ){
47
+		this.delFlag = delFlag;
48
+	}
49
+
50
+	public Integer getEditUser(){
51
+		return  editUser;
52
+	}
53
+	public void setEditUser(Integer editUser ){
54
+		this.editUser = editUser;
55
+	}
56
+
57
+	public String getQuartzCron(){
58
+		return  quartzCron;
59
+	}
60
+	public void setQuartzCron(String quartzCron ){
61
+		this.quartzCron = quartzCron;
62
+	}
63
+
64
+	public String getQuartzDescription(){
65
+		return  quartzDescription;
66
+	}
67
+	public void setQuartzDescription(String quartzDescription ){
68
+		this.quartzDescription = quartzDescription;
69
+	}
70
+
71
+	public Date getAddTime(){
72
+		return  addTime;
73
+	}
74
+	public void setAddTime(Date addTime ){
75
+		this.addTime = addTime;
76
+	}
77
+
78
+	public Date getEditTime(){
79
+		return  editTime;
80
+	}
81
+	public void setEditTime(Date editTime ){
82
+		this.editTime = editTime;
83
+	}
84
+
85
+}

+ 167 - 0
src/main/java/com/zhaxd/core/model/KRepository.java

@@ -0,0 +1,167 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KRepository {
8
+	//ID
9
+	@SeqID(name="REPOSITORY_ID_SEQ")
10
+	private Integer repositoryId ;
11
+	//添加者
12
+	private Integer addUser ;
13
+	//是否删除(1:存在;0:删除)
14
+	private Integer delFlag ;
15
+	//编辑者
16
+	private Integer editUser ;
17
+	//资源库数据库访问模式("Native", "ODBC", "OCI", "Plugin", "JNDI")
18
+	private String databaseAccess ;
19
+	//资源库数据库主机名或者IP地址
20
+	private String databaseHost ;
21
+	//资源库数据库名称
22
+	private String databaseName ;
23
+	//数据库登录密码
24
+	private String databasePassword ;
25
+	//资源库数据库端口号
26
+	private String databasePort ;
27
+	//数据库登录账号
28
+	private String databaseUsername ;
29
+	//资源库名称
30
+	private String repositoryName ;
31
+	//登录密码
32
+	private String repositoryPassword ;
33
+	//资源库数据库类型(MYSQL、ORACLE)
34
+	private String repositoryType ;
35
+	//登录用户名
36
+	private String repositoryUsername ;
37
+	//添加时间
38
+	private Date addTime ;
39
+	//编辑时间
40
+	private Date editTime ;
41
+
42
+	public KRepository() {
43
+	}
44
+
45
+	public Integer getRepositoryId(){
46
+		return  repositoryId;
47
+	}
48
+	public void setRepositoryId(Integer repositoryId ){
49
+		this.repositoryId = repositoryId;
50
+	}
51
+
52
+	public Integer getAddUser(){
53
+		return  addUser;
54
+	}
55
+	public void setAddUser(Integer addUser ){
56
+		this.addUser = addUser;
57
+	}
58
+
59
+	public Integer getDelFlag(){
60
+		return  delFlag;
61
+	}
62
+	public void setDelFlag(Integer delFlag ){
63
+		this.delFlag = delFlag;
64
+	}
65
+
66
+	public Integer getEditUser(){
67
+		return  editUser;
68
+	}
69
+	public void setEditUser(Integer editUser ){
70
+		this.editUser = editUser;
71
+	}
72
+
73
+	public String getDatabaseAccess(){
74
+		return  databaseAccess;
75
+	}
76
+	public void setDatabaseAccess(String databaseAccess ){
77
+		this.databaseAccess = databaseAccess;
78
+	}
79
+
80
+	public String getDatabaseHost(){
81
+		return  databaseHost;
82
+	}
83
+	public void setDatabaseHost(String databaseHost ){
84
+		this.databaseHost = databaseHost;
85
+	}
86
+
87
+	public String getDatabaseName(){
88
+		return  databaseName;
89
+	}
90
+	public void setDatabaseName(String databaseName ){
91
+		this.databaseName = databaseName;
92
+	}
93
+
94
+	public String getDatabasePassword(){
95
+		return  databasePassword;
96
+	}
97
+	public void setDatabasePassword(String databasePassword ){
98
+		this.databasePassword = databasePassword;
99
+	}
100
+
101
+	public String getDatabasePort(){
102
+		return  databasePort;
103
+	}
104
+	public void setDatabasePort(String databasePort ){
105
+		this.databasePort = databasePort;
106
+	}
107
+
108
+	public String getDatabaseUsername(){
109
+		return  databaseUsername;
110
+	}
111
+	public void setDatabaseUsername(String databaseUsername ){
112
+		this.databaseUsername = databaseUsername;
113
+	}
114
+
115
+	public String getRepositoryName(){
116
+		return  repositoryName;
117
+	}
118
+	public void setRepositoryName(String repositoryName ){
119
+		this.repositoryName = repositoryName;
120
+	}
121
+
122
+	public String getRepositoryPassword(){
123
+		return  repositoryPassword;
124
+	}
125
+	public void setRepositoryPassword(String repositoryPassword ){
126
+		this.repositoryPassword = repositoryPassword;
127
+	}
128
+
129
+	public String getRepositoryType(){
130
+		return  repositoryType;
131
+	}
132
+	public void setRepositoryType(String repositoryType ){
133
+		this.repositoryType = repositoryType;
134
+	}
135
+
136
+	public String getRepositoryUsername(){
137
+		return  repositoryUsername;
138
+	}
139
+	public void setRepositoryUsername(String repositoryUsername ){
140
+		this.repositoryUsername = repositoryUsername;
141
+	}
142
+
143
+	public Date getAddTime(){
144
+		return  addTime;
145
+	}
146
+	public void setAddTime(Date addTime ){
147
+		this.addTime = addTime;
148
+	}
149
+
150
+	public Date getEditTime(){
151
+		return  editTime;
152
+	}
153
+	public void setEditTime(Date editTime ){
154
+		this.editTime = editTime;
155
+	}
156
+
157
+	@Override
158
+	public String toString() {
159
+		return "KRepository [repositoryId=" + repositoryId + ", addUser=" + addUser + ", delFlag=" + delFlag
160
+				+ ", editUser=" + editUser + ", databaseAccess=" + databaseAccess + ", databaseHost=" + databaseHost
161
+				+ ", databaseName=" + databaseName + ", databasePassword=" + databasePassword + ", databasePort="
162
+				+ databasePort + ", databaseUsername=" + databaseUsername + ", repositoryName=" + repositoryName
163
+				+ ", repositoryPassword=" + repositoryPassword + ", repositoryType=" + repositoryType
164
+				+ ", repositoryUsername=" + repositoryUsername + ", addTime=" + addTime + ", editTime=" + editTime
165
+				+ "]";
166
+	}
167
+}

+ 35 - 0
src/main/java/com/zhaxd/core/model/KRepositoryType.java

@@ -0,0 +1,35 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+public class KRepositoryType {
6
+	@SeqID(name="REPOSITORY_TYPE_ID_SEQ")
7
+	private Integer repositoryTypeId ;
8
+	private String repositoryTypeCode ;
9
+	private String repositoryTypeDes ;
10
+
11
+	public KRepositoryType() {
12
+	}
13
+
14
+	public Integer getRepositoryTypeId(){
15
+		return  repositoryTypeId;
16
+	}
17
+	public void setRepositoryTypeId(Integer repositoryTypeId ){
18
+		this.repositoryTypeId = repositoryTypeId;
19
+	}
20
+
21
+	public String getRepositoryTypeCode(){
22
+		return  repositoryTypeCode;
23
+	}
24
+	public void setRepositoryTypeCode(String repositoryTypeCode ){
25
+		this.repositoryTypeCode = repositoryTypeCode;
26
+	}
27
+
28
+	public String getRepositoryTypeDes(){
29
+		return  repositoryTypeDes;
30
+	}
31
+	public void setRepositoryTypeDes(String repositoryTypeDes ){
32
+		this.repositoryTypeDes = repositoryTypeDes;
33
+	}
34
+
35
+}

+ 212 - 0
src/main/java/com/zhaxd/core/model/KTrans.java

@@ -0,0 +1,212 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KTrans {
8
+    //转换ID
9
+    @SeqID(name="TRANS_ID_SEQ")
10
+    private Integer transId;
11
+    private Integer categoryId;
12
+    //添加者
13
+    private Integer addUser;
14
+    //是否删除(1:存在;0:删除)
15
+    private Integer delFlag;
16
+    //编辑者
17
+    private Integer editUser;
18
+    //定时策略(外键ID)
19
+    private Integer transQuartz;
20
+    //转换执行记录(外键ID)
21
+    private Integer transRecord;
22
+    //转换的资源库ID
23
+    private Integer transRepositoryId;
24
+    //状态(1:正在运行;2:已停止)
25
+    private Integer transStatus;
26
+    //1:数据库资源库;2:上传的文件
27
+    private Integer transType;
28
+    //转换描述
29
+    private String transDescription;
30
+    //日志级别(basic,detail,error,debug,minimal,rowlevel)
31
+    private String transLogLevel;
32
+    //转换名称
33
+    private String transName;
34
+    //转换保存路径(可以是资源库中的路径也可以是服务器中保存作业文件的路径)
35
+    private String transPath;
36
+    //添加时间
37
+    private Date addTime;
38
+    //编辑时间
39
+    private Date editTime;
40
+
41
+    public KTrans() {
42
+    }
43
+
44
+    public Integer getTransId() {
45
+        return transId;
46
+    }
47
+
48
+    public void setTransId(Integer transId) {
49
+        this.transId = transId;
50
+    }
51
+
52
+    public Integer getAddUser() {
53
+        return addUser;
54
+    }
55
+
56
+    public void setAddUser(Integer addUser) {
57
+        this.addUser = addUser;
58
+    }
59
+
60
+    public Integer getDelFlag() {
61
+        return delFlag;
62
+    }
63
+
64
+    public void setDelFlag(Integer delFlag) {
65
+        this.delFlag = delFlag;
66
+    }
67
+
68
+    public Integer getEditUser() {
69
+        return editUser;
70
+    }
71
+
72
+    public void setEditUser(Integer editUser) {
73
+        this.editUser = editUser;
74
+    }
75
+
76
+    public Integer getTransQuartz() {
77
+        return transQuartz;
78
+    }
79
+
80
+    public void setTransQuartz(Integer transQuartz) {
81
+        this.transQuartz = transQuartz;
82
+    }
83
+
84
+    public Integer getTransRecord() {
85
+        return transRecord;
86
+    }
87
+
88
+    public void setTransRecord(Integer transRecord) {
89
+        this.transRecord = transRecord;
90
+    }
91
+
92
+    public Integer getTransRepositoryId() {
93
+        return transRepositoryId;
94
+    }
95
+
96
+    public void setTransRepositoryId(Integer transRepositoryId) {
97
+        this.transRepositoryId = transRepositoryId;
98
+    }
99
+
100
+    public Integer getTransStatus() {
101
+        return transStatus;
102
+    }
103
+
104
+    public void setTransStatus(Integer transStatus) {
105
+        this.transStatus = transStatus;
106
+    }
107
+
108
+    public Integer getTransType() {
109
+        return transType;
110
+    }
111
+
112
+    public void setTransType(Integer transType) {
113
+        this.transType = transType;
114
+    }
115
+
116
+    public String getTransDescription() {
117
+        return transDescription;
118
+    }
119
+
120
+    public void setTransDescription(String transDescription) {
121
+        this.transDescription = transDescription;
122
+    }
123
+
124
+    public String getTransLogLevel() {
125
+        return transLogLevel;
126
+    }
127
+
128
+    public void setTransLogLevel(String transLogLevel) {
129
+        this.transLogLevel = transLogLevel;
130
+    }
131
+
132
+    public String getTransName() {
133
+        return transName;
134
+    }
135
+
136
+    public void setTransName(String transName) {
137
+        this.transName = transName;
138
+    }
139
+
140
+    public String getTransPath() {
141
+        return transPath;
142
+    }
143
+
144
+    public void setTransPath(String transPath) {
145
+        this.transPath = transPath;
146
+    }
147
+
148
+    public Date getAddTime() {
149
+        return addTime;
150
+    }
151
+
152
+    public void setAddTime(Date addTime) {
153
+        this.addTime = addTime;
154
+    }
155
+
156
+    public Date getEditTime() {
157
+        return editTime;
158
+    }
159
+
160
+    public void setEditTime(Date editTime) {
161
+        this.editTime = editTime;
162
+    }
163
+
164
+    public Integer getCategoryId() {
165
+        return categoryId;
166
+    }
167
+
168
+    public void setCategoryId(Integer categoryId) {
169
+        this.categoryId = categoryId;
170
+    }
171
+
172
+    public KTrans(Integer transId, Integer categoryId, Integer addUser, Integer delFlag, Integer editUser, Integer transQuartz, Integer transRecord, Integer transRepositoryId, Integer transStatus, Integer transType, String transDescription, String transLogLevel, String transName, String transPath, Date addTime, Date editTime) {
173
+        this.transId = transId;
174
+        this.categoryId = categoryId;
175
+        this.addUser = addUser;
176
+        this.delFlag = delFlag;
177
+        this.editUser = editUser;
178
+        this.transQuartz = transQuartz;
179
+        this.transRecord = transRecord;
180
+        this.transRepositoryId = transRepositoryId;
181
+        this.transStatus = transStatus;
182
+        this.transType = transType;
183
+        this.transDescription = transDescription;
184
+        this.transLogLevel = transLogLevel;
185
+        this.transName = transName;
186
+        this.transPath = transPath;
187
+        this.addTime = addTime;
188
+        this.editTime = editTime;
189
+    }
190
+
191
+    @Override
192
+    public String toString() {
193
+        return "KTrans{" +
194
+                "transId=" + transId +
195
+                ", categoryId=" + categoryId +
196
+                ", addUser=" + addUser +
197
+                ", delFlag=" + delFlag +
198
+                ", editUser=" + editUser +
199
+                ", transQuartz=" + transQuartz +
200
+                ", transRecord=" + transRecord +
201
+                ", transRepositoryId=" + transRepositoryId +
202
+                ", transStatus=" + transStatus +
203
+                ", transType=" + transType +
204
+                ", transDescription='" + transDescription + '\'' +
205
+                ", transLogLevel='" + transLogLevel + '\'' +
206
+                ", transName='" + transName + '\'' +
207
+                ", transPath='" + transPath + '\'' +
208
+                ", addTime=" + addTime +
209
+                ", editTime=" + editTime +
210
+                '}';
211
+    }
212
+}

+ 156 - 0
src/main/java/com/zhaxd/core/model/KTransMonitor.java

@@ -0,0 +1,156 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KTransMonitor implements Comparable<KTransMonitor> {
8
+    //监控转换ID
9
+    @SeqID(name="TRANS_MONITOR_ID_SEQ")
10
+    private Integer monitorId;
11
+    //添加人
12
+    private Integer addUser;
13
+    //失败次数
14
+    private Integer monitorFail;
15
+    //监控状态(是否启动,1:启动;2:停止)
16
+    private Integer monitorStatus;
17
+    //成功次数
18
+    private Integer monitorSuccess;
19
+    //监控的转换的ID
20
+    private Integer monitorTrans;
21
+    //运行状态(起始时间-结束时间,起始时间-结束时间……)
22
+    private String runStatus;
23
+    //上次执行时间
24
+    private Date lastExecuteTime;
25
+    //下次执行时间
26
+    private Date nextExecuteTime;
27
+    private String categoryName;
28
+    private String transName;
29
+
30
+    public KTransMonitor() {
31
+    }
32
+
33
+    public Integer getMonitorId() {
34
+        return monitorId;
35
+    }
36
+
37
+    public void setMonitorId(Integer monitorId) {
38
+        this.monitorId = monitorId;
39
+    }
40
+
41
+    public Integer getAddUser() {
42
+        return addUser;
43
+    }
44
+
45
+    public void setAddUser(Integer addUser) {
46
+        this.addUser = addUser;
47
+    }
48
+
49
+    public Integer getMonitorFail() {
50
+        return monitorFail;
51
+    }
52
+
53
+    public void setMonitorFail(Integer monitorFail) {
54
+        this.monitorFail = monitorFail;
55
+    }
56
+
57
+    public Integer getMonitorStatus() {
58
+        return monitorStatus;
59
+    }
60
+
61
+    public void setMonitorStatus(Integer monitorStatus) {
62
+        this.monitorStatus = monitorStatus;
63
+    }
64
+
65
+    public Integer getMonitorSuccess() {
66
+        return monitorSuccess;
67
+    }
68
+
69
+    public void setMonitorSuccess(Integer monitorSuccess) {
70
+        this.monitorSuccess = monitorSuccess;
71
+    }
72
+
73
+    public Integer getMonitorTrans() {
74
+        return monitorTrans;
75
+    }
76
+
77
+    public void setMonitorTrans(Integer monitorTrans) {
78
+        this.monitorTrans = monitorTrans;
79
+    }
80
+
81
+    public String getRunStatus() {
82
+        return runStatus;
83
+    }
84
+
85
+    public void setRunStatus(String runStatus) {
86
+        this.runStatus = runStatus;
87
+    }
88
+
89
+    public Date getLastExecuteTime() {
90
+        return lastExecuteTime;
91
+    }
92
+
93
+    public void setLastExecuteTime(Date lastExecuteTime) {
94
+        this.lastExecuteTime = lastExecuteTime;
95
+    }
96
+
97
+    public Date getNextExecuteTime() {
98
+        return nextExecuteTime;
99
+    }
100
+
101
+    public void setNextExecuteTime(Date nextExecuteTime) {
102
+        this.nextExecuteTime = nextExecuteTime;
103
+    }
104
+
105
+    public String getCategoryName() {
106
+        return categoryName;
107
+    }
108
+
109
+    public void setCategoryName(String categoryName) {
110
+        this.categoryName = categoryName;
111
+    }
112
+
113
+    public String getTransName() {
114
+        return transName;
115
+    }
116
+
117
+    public void setTransName(String transName) {
118
+        this.transName = transName;
119
+    }
120
+
121
+    @Override
122
+    public int compareTo(KTransMonitor o) {
123
+        return this.getMonitorSuccess() - o.getMonitorSuccess();
124
+    }
125
+
126
+    public KTransMonitor(Integer monitorId, Integer addUser, Integer monitorFail, Integer monitorStatus, Integer monitorSuccess, Integer monitorTrans, String runStatus, Date lastExecuteTime, Date nextExecuteTime, String categoryName, String transName) {
127
+        this.monitorId = monitorId;
128
+        this.addUser = addUser;
129
+        this.monitorFail = monitorFail;
130
+        this.monitorStatus = monitorStatus;
131
+        this.monitorSuccess = monitorSuccess;
132
+        this.monitorTrans = monitorTrans;
133
+        this.runStatus = runStatus;
134
+        this.lastExecuteTime = lastExecuteTime;
135
+        this.nextExecuteTime = nextExecuteTime;
136
+        this.categoryName = categoryName;
137
+        this.transName = transName;
138
+    }
139
+
140
+    @Override
141
+    public String toString() {
142
+        return "KTransMonitor{" +
143
+                "monitorId=" + monitorId +
144
+                ", addUser=" + addUser +
145
+                ", monitorFail=" + monitorFail +
146
+                ", monitorStatus=" + monitorStatus +
147
+                ", monitorSuccess=" + monitorSuccess +
148
+                ", monitorTrans=" + monitorTrans +
149
+                ", runStatus='" + runStatus + '\'' +
150
+                ", lastExecuteTime=" + lastExecuteTime +
151
+                ", nextExecuteTime=" + nextExecuteTime +
152
+                ", categoryName='" + categoryName + '\'' +
153
+                ", transName='" + transName + '\'' +
154
+                '}';
155
+    }
156
+}

+ 83 - 0
src/main/java/com/zhaxd/core/model/KTransRecord.java

@@ -0,0 +1,83 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KTransRecord {
8
+	//转换记录ID
9
+	@SeqID(name="TRANS_RECORD_ID_SEQ")
10
+	private Integer recordId ;
11
+	//任务执行结果(1:成功;2:失败)
12
+	private Integer recordStatus ;
13
+	//转换ID
14
+	private Integer recordTrans ;
15
+	//添加人
16
+	private Integer addUser;
17
+	//转换日志记录文件保存位置
18
+	private String logFilePath ;
19
+	//启动时间
20
+	private Date startTime ;
21
+	//停止时间
22
+	private Date stopTime ;
23
+
24
+	public KTransRecord() {
25
+	}
26
+
27
+	public Integer getRecordId(){
28
+		return  recordId;
29
+	}
30
+	public void setRecordId(Integer recordId ){
31
+		this.recordId = recordId;
32
+	}
33
+
34
+	public Integer getRecordStatus(){
35
+		return  recordStatus;
36
+	}
37
+	public void setRecordStatus(Integer recordStatus ){
38
+		this.recordStatus = recordStatus;
39
+	}
40
+
41
+	public Integer getRecordTrans(){
42
+		return  recordTrans;
43
+	}
44
+	public void setRecordTrans(Integer recordTrans ){
45
+		this.recordTrans = recordTrans;
46
+	}
47
+
48
+	public String getLogFilePath(){
49
+		return  logFilePath;
50
+	}
51
+	public void setLogFilePath(String logFilePath ){
52
+		this.logFilePath = logFilePath;
53
+	}
54
+
55
+	public Date getStartTime(){
56
+		return  startTime;
57
+	}
58
+	public void setStartTime(Date startTime ){
59
+		this.startTime = startTime;
60
+	}
61
+
62
+	public Date getStopTime(){
63
+		return  stopTime;
64
+	}
65
+	public void setStopTime(Date stopTime ){
66
+		this.stopTime = stopTime;
67
+	}
68
+
69
+	@Override
70
+	public String toString() {
71
+		return "KTransRecord [recordId=" + recordId + ", recordStatus=" + recordStatus + ", recordTrans=" + recordTrans
72
+				+ ", addUser=" + addUser + ", logFilePath=" + logFilePath + ", startTime=" + startTime + ", stopTime="
73
+				+ stopTime + "]";
74
+	}
75
+
76
+	public Integer getAddUser() {
77
+		return addUser;
78
+	}
79
+
80
+	public void setAddUser(Integer addUser) {
81
+		this.addUser = addUser;
82
+	}
83
+}

+ 118 - 0
src/main/java/com/zhaxd/core/model/KUser.java

@@ -0,0 +1,118 @@
1
+package com.zhaxd.core.model;
2
+
3
+import org.beetl.sql.core.annotatoin.SeqID;
4
+
5
+import java.util.Date;
6
+
7
+public class KUser {
8
+	//用户ID
9
+	@SeqID(name="USER_ID_SEQ")
10
+	private Integer uId ;
11
+	//添加者
12
+	private Integer addUser ;
13
+	//是否删除(1:存在;0:删除)
14
+	private Integer delFlag ;
15
+	//编辑者
16
+	private Integer editUser ;
17
+	//用户账号
18
+	private String uAccount ;
19
+	//用户邮箱
20
+	private String uEmail ;
21
+	//用户昵称
22
+	private String uNickname ;
23
+	//用户密码
24
+	private String uPassword ;
25
+	//用于电话
26
+	private String uPhone ;
27
+	//添加时间
28
+	private Date addTime ;
29
+	//编辑时间
30
+	private Date editTime ;
31
+
32
+	public KUser() {
33
+	}
34
+
35
+	public Integer getuId(){
36
+		return  uId;
37
+	}
38
+	public void setuId(Integer uId ){
39
+		this.uId = uId;
40
+	}
41
+
42
+	public Integer getAddUser(){
43
+		return  addUser;
44
+	}
45
+	public void setAddUser(Integer addUser ){
46
+		this.addUser = addUser;
47
+	}
48
+
49
+	public Integer getDelFlag(){
50
+		return  delFlag;
51
+	}
52
+	public void setDelFlag(Integer delFlag ){
53
+		this.delFlag = delFlag;
54
+	}
55
+
56
+	public Integer getEditUser(){
57
+		return  editUser;
58
+	}
59
+	public void setEditUser(Integer editUser ){
60
+		this.editUser = editUser;
61
+	}
62
+
63
+	public String getuAccount(){
64
+		return  uAccount;
65
+	}
66
+	public void setuAccount(String uAccount ){
67
+		this.uAccount = uAccount;
68
+	}
69
+
70
+	public String getuEmail(){
71
+		return  uEmail;
72
+	}
73
+	public void setuEmail(String uEmail ){
74
+		this.uEmail = uEmail;
75
+	}
76
+
77
+	public String getuNickname(){
78
+		return  uNickname;
79
+	}
80
+	public void setuNickname(String uNickname ){
81
+		this.uNickname = uNickname;
82
+	}
83
+
84
+	public String getuPassword(){
85
+		return  uPassword;
86
+	}
87
+	public void setuPassword(String uPassword ){
88
+		this.uPassword = uPassword;
89
+	}
90
+
91
+	public String getuPhone(){
92
+		return  uPhone;
93
+	}
94
+	public void setuPhone(String uPhone ){
95
+		this.uPhone = uPhone;
96
+	}
97
+
98
+	public Date getAddTime(){
99
+		return  addTime;
100
+	}
101
+	public void setAddTime(Date addTime ){
102
+		this.addTime = addTime;
103
+	}
104
+
105
+	public Date getEditTime(){
106
+		return  editTime;
107
+	}
108
+	public void setEditTime(Date editTime ){
109
+		this.editTime = editTime;
110
+	}
111
+
112
+	@Override
113
+	public String toString() {
114
+		return "KUser [uId=" + uId + ", addUser=" + addUser + ", delFlag=" + delFlag + ", editUser=" + editUser
115
+				+ ", uAccount=" + uAccount + ", uEmail=" + uEmail + ", uNickname=" + uNickname + ", uPassword="
116
+				+ uPassword + ", uPhone=" + uPhone + ", addTime=" + addTime + ", editTime=" + editTime + "]";
117
+	}
118
+}

+ 74 - 0
src/main/java/com/zhaxd/web/controller/CategoryController.java

@@ -0,0 +1,74 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import com.zhaxd.common.toolkit.Constant;
4
+import com.zhaxd.core.dto.BootTablePage;
5
+import com.zhaxd.core.dto.ResultDto;
6
+import com.zhaxd.core.model.KCategory;
7
+import com.zhaxd.core.model.KUser;
8
+import com.zhaxd.web.service.CategoryService;
9
+import com.zhaxd.web.utils.JsonUtils;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.web.bind.annotation.RequestMapping;
12
+import org.springframework.web.bind.annotation.RestController;
13
+
14
+import javax.servlet.http.HttpServletRequest;
15
+import javax.servlet.http.HttpServletResponse;
16
+import java.io.IOException;
17
+
18
+@RestController
19
+@RequestMapping("/category/")
20
+public class CategoryController {
21
+    @Autowired
22
+    private CategoryService categoryService;
23
+
24
+    @RequestMapping("getSimpleList.shtml")
25
+    public String simpleList(HttpServletRequest request){
26
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
27
+        return JsonUtils.objectToJson(categoryService.getList(kUser.getuId()));
28
+    }
29
+    @RequestMapping("getList.shtml")
30
+    public String getList(Integer offset, Integer limit,String targetTable, HttpServletRequest request){
31
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
32
+        BootTablePage list = categoryService.getList(offset, limit,kUser.getuId());
33
+        return JsonUtils.objectToJson(list);
34
+    }
35
+
36
+    @RequestMapping("getCategory.shtml")
37
+    public String getQuartz(Integer categoryId){
38
+        return ResultDto.success(categoryService.getQuartz(categoryId));
39
+    }
40
+
41
+    @RequestMapping("insert.shtml")
42
+    public String insert(KCategory kCategory, HttpServletRequest request){
43
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
44
+        categoryService.insert(kCategory,kUser.getuId());
45
+        return ResultDto.success();
46
+    }
47
+    @RequestMapping("delete.shtml")
48
+    public String delete(Integer categoryId){
49
+        categoryService.delete(categoryId);
50
+        return ResultDto.success();
51
+    }
52
+    @RequestMapping("update.shtml")
53
+    public String update(KCategory kCategory, HttpServletRequest request){
54
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
55
+        try{
56
+            categoryService.update(kCategory,kUser.getuId());
57
+            return ResultDto.success();
58
+        }catch(Exception e){
59
+            return ResultDto.success(e.toString());
60
+        }
61
+    }
62
+    @RequestMapping("IsCategoryExist.shtml")
63
+    public void IsCategoryExist(Integer categoryId,String categoryName, HttpServletResponse response) {
64
+        try {
65
+            if (categoryService.IsCategoryExist(categoryId,categoryName)) {
66
+                response.getWriter().write("false");
67
+            } else {
68
+                response.getWriter().write("true");
69
+            }
70
+        } catch (IOException e) {
71
+            e.printStackTrace();
72
+        }
73
+    }
74
+}

+ 66 - 0
src/main/java/com/zhaxd/web/controller/DownLoadRecordController.java

@@ -0,0 +1,66 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import java.io.File;
4
+import java.io.IOException;
5
+
6
+import org.apache.commons.io.FileUtils;
7
+import org.apache.commons.lang.StringUtils;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.http.HttpHeaders;
10
+import org.springframework.http.HttpStatus;
11
+import org.springframework.http.MediaType;
12
+import org.springframework.http.ResponseEntity;
13
+import org.springframework.stereotype.Controller;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+
16
+import com.zhaxd.core.mapper.KJobRecordDao;
17
+import com.zhaxd.core.mapper.KTransRecordDao;
18
+import com.zhaxd.core.model.KJobRecord;
19
+import com.zhaxd.core.model.KTransRecord;
20
+
21
+@Controller
22
+@RequestMapping("/download/")
23
+public class DownLoadRecordController {
24
+
25
+	@Autowired
26
+	private KJobRecordDao kJobRecordDao;
27
+	
28
+	@Autowired
29
+	private KTransRecordDao kTransRecordDao;
30
+	
31
+	@RequestMapping("job/record.shtml")
32
+	public ResponseEntity<byte[]> jobRecord(Integer recordId){
33
+		KJobRecord kJobRecord = kJobRecordDao.unique(recordId);
34
+		String logFilePath = kJobRecord.getLogFilePath();		
35
+		HttpHeaders headers = new HttpHeaders();
36
+		String fileName = logFilePath.substring(StringUtils.lastIndexOf(logFilePath, "/") + 1, logFilePath.length());		
37
+		try {
38
+			byte[] logFileBytes = FileUtils.readFileToByteArray(new File(logFilePath));
39
+			String downFileName = new String(fileName.getBytes("UTF-8"),"iso-8859-1");
40
+			headers.setContentDispositionFormData("attachment", downFileName);     
41
+	        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
42
+	        return new ResponseEntity<byte[]>(logFileBytes, headers, HttpStatus.CREATED);
43
+		} catch (IOException e) {
44
+			e.printStackTrace();
45
+			return null;
46
+		}
47
+	}
48
+
49
+	@RequestMapping("trans/record.shtml")
50
+	public ResponseEntity<byte[]> transRecord(Integer recordId){
51
+		KTransRecord kTransRecord = kTransRecordDao.unique(recordId);
52
+		String logFilePath = kTransRecord.getLogFilePath();		
53
+		HttpHeaders headers = new HttpHeaders();
54
+		String fileName = logFilePath.substring(StringUtils.lastIndexOf(logFilePath, "/") + 1, logFilePath.length());		
55
+		try {
56
+			byte[] logFileBytes = FileUtils.readFileToByteArray(new File(logFilePath));
57
+			String downFileName = new String(fileName.getBytes("UTF-8"),"iso-8859-1");
58
+			headers.setContentDispositionFormData("attachment", downFileName);     
59
+	        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
60
+	        return new ResponseEntity<byte[]>(logFileBytes, headers, HttpStatus.CREATED);
61
+		} catch (IOException e) {
62
+			e.printStackTrace();
63
+			return null;
64
+		}
65
+	}
66
+}

+ 57 - 0
src/main/java/com/zhaxd/web/controller/IndexController.java

@@ -0,0 +1,57 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import javax.servlet.http.HttpServletRequest;
4
+import javax.servlet.http.HttpSession;
5
+
6
+import org.apache.commons.lang.StringUtils;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Controller;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.ResponseBody;
11
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
12
+
13
+import com.zhaxd.common.toolkit.Constant;
14
+import com.zhaxd.core.model.KUser;
15
+import com.zhaxd.web.service.UserService;
16
+import com.zhaxd.web.utils.JsonUtils;
17
+
18
+@Controller
19
+@RequestMapping("/index/")
20
+public class IndexController {
21
+
22
+	@Autowired
23
+	private UserService userService;
24
+	
25
+	@RequestMapping("isAdmin.shtml")
26
+	@ResponseBody
27
+	public String isAdmin(HttpServletRequest request){
28
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
29
+		if (null != kUser && userService.isAdmin(kUser.getuId())){
30
+			return JsonUtils.objectToJson(true);
31
+		}
32
+		return JsonUtils.objectToJson(false);
33
+	}
34
+	
35
+	@RequestMapping("login.shtml")
36
+	public String login(KUser kUser, RedirectAttributes attr, HttpServletRequest request){
37
+		if (null != kUser && StringUtils.isNotBlank(kUser.getuAccount()) && 
38
+				StringUtils.isNotBlank(kUser.getuPassword())){
39
+			KUser u = userService.login(kUser);
40
+			if (null != u){
41
+				request.getSession().setAttribute(Constant.SESSION_ID, u);
42
+				return "redirect:/view/indexUI.shtml";
43
+			}
44
+			attr.addFlashAttribute("errorMsg", "账号或密码错误");
45
+			return "redirect:/view/loginUI.shtml";
46
+		}
47
+		attr.addFlashAttribute("errorMsg", "账号或密码不能为空");
48
+		return "redirect:/view/loginUI.shtml";
49
+	}
50
+	
51
+	@RequestMapping("logout.shtml")
52
+	public String logout(HttpServletRequest request){
53
+		HttpSession session = request.getSession();
54
+		session.removeAttribute(Constant.SESSION_ID);
55
+		return "redirect:/view/loginUI.shtml";
56
+	}
57
+}

+ 139 - 0
src/main/java/com/zhaxd/web/controller/JobController.java

@@ -0,0 +1,139 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import java.io.IOException;
4
+import java.sql.SQLException;
5
+
6
+import javax.servlet.http.HttpServletRequest;
7
+
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+import org.springframework.web.multipart.MultipartFile;
12
+
13
+import com.zhaxd.common.toolkit.Constant;
14
+import com.zhaxd.core.dto.BootTablePage;
15
+import com.zhaxd.core.dto.ResultDto;
16
+import com.zhaxd.core.model.KJob;
17
+import com.zhaxd.core.model.KUser;
18
+import com.zhaxd.web.service.JobService;
19
+import com.zhaxd.web.utils.JsonUtils;
20
+
21
+
22
+@RestController
23
+@RequestMapping("/job/")
24
+public class JobController {
25
+
26
+    @Autowired
27
+    private JobService jobService;
28
+
29
+
30
+    @RequestMapping("getSimpleList.shtml")
31
+    public String getSimpleList(HttpServletRequest request) {
32
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
33
+        return JsonUtils.objectToJson(jobService.getList(kUser.getuId()));
34
+    }
35
+
36
+
37
+    @RequestMapping("getList.shtml")
38
+    public String getList(Integer offset, Integer limit, Integer categoryId, String jobName, HttpServletRequest request) {
39
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
40
+        BootTablePage list = jobService.getList(offset, limit, categoryId, jobName, kUser.getuId());
41
+        return JsonUtils.objectToJson(list);
42
+    }
43
+
44
+    @RequestMapping("delete.shtml")
45
+    public String delete(Integer jobId) {
46
+        jobService.delete(jobId);
47
+        return ResultDto.success();
48
+    }
49
+
50
+    @RequestMapping("uploadJob.shtml")
51
+    public String uploadJob(MultipartFile jobFile, HttpServletRequest request) {
52
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
53
+        try {
54
+            String saveFilePath = jobService.saveFile(kUser.getuId(), jobFile);
55
+            return ResultDto.success(saveFilePath);
56
+        } catch (IOException e) {
57
+            e.printStackTrace();
58
+            return null;
59
+        }
60
+    }
61
+
62
+
63
+    @RequestMapping("insert.shtml")
64
+    public String insert(KJob kJob, String customerQuarz, HttpServletRequest request) {
65
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
66
+        Integer uId = kUser.getuId();
67
+        if (jobService.check(kJob.getJobRepositoryId(), kJob.getJobPath(), uId)) {
68
+            try {
69
+                jobService.insert(kJob, uId, customerQuarz);
70
+                return ResultDto.success();
71
+            } catch (SQLException e) {
72
+                e.printStackTrace();
73
+                return ResultDto.fail("添加作业失败");
74
+            }
75
+        } else {
76
+            return ResultDto.fail("该作业已经添加过了");
77
+        }
78
+    }
79
+
80
+
81
+    @RequestMapping("getJob.shtml")
82
+    public String getJob(Integer jobId) {
83
+        return ResultDto.success(jobService.getJob(jobId));
84
+    }
85
+
86
+    @RequestMapping("update.shtml")
87
+    public String update(KJob kJob, String customerQuarz, HttpServletRequest request) {
88
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
89
+        try {
90
+            jobService.update(kJob, customerQuarz, kUser.getuId());
91
+            return ResultDto.success();
92
+        } catch (Exception e) {
93
+            return ResultDto.success(e.toString());
94
+        }
95
+    }
96
+
97
+    @RequestMapping("start.shtml")
98
+    public String start(Integer jobId) {
99
+        jobService.start(jobId);
100
+        return ResultDto.success();
101
+    }
102
+
103
+    @RequestMapping("stop.shtml")
104
+    public String stop(Integer jobId) {
105
+        jobService.stop(jobId);
106
+        return ResultDto.success();
107
+    }
108
+
109
+    @RequestMapping("startAll.shtml")
110
+    public String startAll(Integer categoryId, String jobName, HttpServletRequest request) {
111
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
112
+        jobService.startAll(categoryId, jobName, kUser.getuId());
113
+        return ResultDto.success();
114
+    }
115
+
116
+    @RequestMapping("stopAll.shtml")
117
+    public String stopAll(Integer categoryId, String jobName, HttpServletRequest request) {
118
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
119
+        jobService.stopAll(categoryId, jobName, kUser.getuId());
120
+        return ResultDto.success();
121
+    }
122
+
123
+    @RequestMapping("getStartTaskCount.shtml")
124
+    public String getStartTaskCount(Integer categoryId, String jobName, HttpServletRequest request) {
125
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
126
+        return JsonUtils.objectToJson(jobService.getStartTaskCount(categoryId, jobName, kUser.getuId()));
127
+    }
128
+
129
+    @RequestMapping("getStopTaskCount.shtml")
130
+    public String getStopTaskCount(Integer categoryId, String jobName, HttpServletRequest request) {
131
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
132
+        return JsonUtils.objectToJson(jobService.getStopTaskCount(categoryId, jobName, kUser.getuId()));
133
+    }
134
+    @RequestMapping({"getJobRunState.shtml"})
135
+    public String getJobRunState(Integer jobId) {
136
+        return JsonUtils.objectToJson(this.jobService.getJobRunState(jobId));
137
+    }
138
+
139
+}

+ 46 - 0
src/main/java/com/zhaxd/web/controller/JobMonitorController.java

@@ -0,0 +1,46 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import javax.servlet.http.HttpServletRequest;
4
+
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RestController;
8
+
9
+import com.zhaxd.common.toolkit.Constant;
10
+import com.zhaxd.core.dto.BootTablePage;
11
+import com.zhaxd.core.model.KUser;
12
+import com.zhaxd.web.service.JobMonitorService;
13
+import com.zhaxd.web.utils.JsonUtils;
14
+
15
+@RestController
16
+@RequestMapping("/job/monitor/")
17
+public class JobMonitorController {
18
+
19
+    @Autowired
20
+    private JobMonitorService jobMonitorService;
21
+
22
+    @RequestMapping("getList.shtml")
23
+    public String getList(Integer offset, Integer limit, Integer monitorStatus, Integer categoryId, String jobName, HttpServletRequest request) {
24
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
25
+        BootTablePage list = jobMonitorService.getList(offset, limit, monitorStatus,categoryId, jobName, kUser.getuId());
26
+        return JsonUtils.objectToJson(list);
27
+    }
28
+
29
+    @RequestMapping("getAllMonitorJob.shtml")
30
+    public String getAllMonitorJob(HttpServletRequest request) {
31
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
32
+        return JsonUtils.objectToJson(jobMonitorService.getAllMonitorJob(kUser.getuId()));
33
+    }
34
+
35
+    @RequestMapping("getAllSuccess.shtml")
36
+    public String getAllSuccess(HttpServletRequest request) {
37
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
38
+        return JsonUtils.objectToJson(jobMonitorService.getAllSuccess(kUser.getuId()));
39
+    }
40
+
41
+    @RequestMapping("getAllFail.shtml")
42
+    public String getAllFail(HttpServletRequest request) {
43
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
44
+        return JsonUtils.objectToJson(jobMonitorService.getAllFail(kUser.getuId()));
45
+    }
46
+}

+ 42 - 0
src/main/java/com/zhaxd/web/controller/JobRecordController.java

@@ -0,0 +1,42 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import java.io.IOException;
4
+
5
+import javax.servlet.http.HttpServletRequest;
6
+
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RestController;
10
+
11
+import com.zhaxd.common.toolkit.Constant;
12
+import com.zhaxd.core.dto.BootTablePage;
13
+import com.zhaxd.core.dto.ResultDto;
14
+import com.zhaxd.core.model.KUser;
15
+import com.zhaxd.web.service.JobRecordService;
16
+import com.zhaxd.web.utils.JsonUtils;
17
+
18
+@RestController
19
+@RequestMapping("/job/record/")
20
+public class JobRecordController {
21
+
22
+	@Autowired
23
+	private JobRecordService jobRecordService;
24
+	
25
+	@RequestMapping("getList.shtml")
26
+	public String getList(Integer offset, Integer limit, Integer jobId, HttpServletRequest request){
27
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
28
+		BootTablePage list = jobRecordService.getList(offset, limit, kUser.getuId(), jobId);
29
+		return JsonUtils.objectToJson(list);
30
+	}
31
+	
32
+	@RequestMapping("getLogContent.shtml")
33
+	public String getLogContent(Integer recordId){
34
+		try {
35
+			String logContent = jobRecordService.getLogContent(recordId);
36
+			return ResultDto.success(logContent.replace("\r\n", "<br/>"));
37
+		} catch (IOException e) {
38
+			e.printStackTrace();
39
+			return null;
40
+		} 
41
+	}
42
+}

+ 106 - 0
src/main/java/com/zhaxd/web/controller/MainController.java

@@ -0,0 +1,106 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import java.text.ParseException;
4
+import java.text.SimpleDateFormat;
5
+import java.util.ArrayList;
6
+import java.util.Calendar;
7
+import java.util.HashMap;
8
+import java.util.List;
9
+import java.util.Map;
10
+
11
+import javax.servlet.http.HttpServletRequest;
12
+
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RestController;
16
+
17
+import com.zhaxd.common.toolkit.Constant;
18
+import com.zhaxd.core.dto.BootTablePage;
19
+import com.zhaxd.core.dto.ResultDto;
20
+import com.zhaxd.core.model.KUser;
21
+import com.zhaxd.web.service.JobMonitorService;
22
+import com.zhaxd.web.service.TransMonitorService;
23
+import com.zhaxd.web.utils.JsonUtils;
24
+
25
+@RestController
26
+@RequestMapping("/main/")
27
+public class MainController {
28
+
29
+	@Autowired
30
+	private TransMonitorService transMonitorService;
31
+	
32
+	@Autowired
33
+	private JobMonitorService jobMonitorService;
34
+	
35
+	/**
36
+	 * @Title allRuning
37
+	 * @Description 
38
+	 * @param request
39
+	 * @return
40
+	 * @return String
41
+	 */
42
+	@RequestMapping("allRuning.shtml")
43
+	public String allRuning(HttpServletRequest request){
44
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
45
+		Integer allMonitorTrans = transMonitorService.getAllMonitorTrans(kUser.getuId());
46
+		Integer allMonitorJob = jobMonitorService.getAllMonitorJob(kUser.getuId());
47
+		Integer allRuning = allMonitorTrans + allMonitorJob; 
48
+		return JsonUtils.objectToJson(allRuning);
49
+	}
50
+	
51
+	/**
52
+	 * @Title getTransList
53
+	 * @Description 获取转换的Top5
54
+	 * @param request
55
+	 * @return
56
+	 * @return String
57
+	 */
58
+	@RequestMapping("getTransList.shtml")
59
+	public String getTransList(HttpServletRequest request){
60
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
61
+		BootTablePage list = transMonitorService.getList(kUser.getuId());
62
+		return JsonUtils.objectToJson(list);
63
+	}
64
+	
65
+	/**
66
+	 * @Title getJobList
67
+	 * @Description 获取作业的Top5
68
+	 * @param request
69
+	 * @return
70
+	 * @return String
71
+	 */
72
+	@RequestMapping("getJobList.shtml")
73
+	public String getJobList(HttpServletRequest request){
74
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
75
+		BootTablePage list = jobMonitorService.getList(kUser.getuId());
76
+		return JsonUtils.objectToJson(list);
77
+	}
78
+	
79
+	/**
80
+	 * 
81
+	 * @Title getKettleLine
82
+	 * @Description TODO
83
+	 * @return
84
+	 * @return String
85
+	 * @throws ParseException 
86
+	 */
87
+	@RequestMapping("getKettleLine.shtml")
88
+	public String getKettleLine(HttpServletRequest request){		
89
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
90
+		Map<String,Object> resultMap = new HashMap<String, Object>();
91
+		List<String> dateList = new ArrayList<String>();
92
+		for (int i = -6; i <= 0; i++){
93
+			Calendar instance = Calendar.getInstance();
94
+			instance.add(Calendar.DATE, i);
95
+			SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
96
+			String dateFormat = simpleDateFormat.format(instance.getTime());
97
+			dateList.add(dateFormat);
98
+		}
99
+		resultMap.put("legend", dateList);
100
+		Map<String, Object> transLine = transMonitorService.getTransLine(kUser.getuId());
101
+		resultMap.put("trans", transLine);
102
+		Map<String, Object> jobLine = jobMonitorService.getJobLine(kUser.getuId());
103
+		resultMap.put("job", jobLine);
104
+		return ResultDto.success(resultMap);
105
+	}
106
+}

+ 203 - 0
src/main/java/com/zhaxd/web/controller/PageController.java

@@ -0,0 +1,203 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import javax.servlet.http.HttpSession;
4
+
5
+import org.springframework.stereotype.Controller;
6
+import org.springframework.ui.Model;
7
+import org.springframework.web.bind.annotation.ModelAttribute;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+
10
+@Controller
11
+@RequestMapping("/view/")
12
+public class PageController {
13
+
14
+	
15
+	@RequestMapping("indexUI.shtml")
16
+	public String IndexUI(){
17
+		return "index";
18
+	}
19
+	
20
+	@RequestMapping("mainUI.shtml")
21
+	public String mainUI(){
22
+		return "main";
23
+	}
24
+	
25
+	@RequestMapping("loginUI.shtml")
26
+	public String loginUI(@ModelAttribute("errorMsg") String errorMsg, HttpSession session){
27
+		session.setAttribute("errorMsg", errorMsg);
28
+		return "login";
29
+	}
30
+	
31
+	/**==========repository start==========**/
32
+	
33
+	@RequestMapping("repostory/listUI.shtml")
34
+	public String repostoryListUI(){
35
+		return "repository/list";
36
+	}
37
+	
38
+	@RequestMapping("repository/addUI.shtml")
39
+	public String repositoryAddUI(){
40
+		return "repository/add";
41
+	}
42
+	
43
+	@RequestMapping("repository/editUI.shtml")
44
+	public String repositoryEditUI(Integer repositoryId, Model model){
45
+		model.addAttribute("repositoryId", repositoryId);
46
+		return "repository/edit";
47
+	}
48
+	
49
+	/**==========repository end==========**/
50
+	
51
+	/**==========job start==========**/
52
+	
53
+	@RequestMapping("job/listUI.shtml")
54
+	public String jobListUI(){
55
+		return "job/list";
56
+	}	
57
+	
58
+	@RequestMapping("job/rAddUI.shtml")
59
+	public String jobRAddUI(){
60
+		return "job/r-add";
61
+	}	
62
+	
63
+	@RequestMapping("job/fAddUI.shtml")
64
+	public String jobFAddUI(){
65
+		return "job/f-add";
66
+	}
67
+	
68
+	@RequestMapping("job/editUI.shtml")
69
+	public String jobEditUI(Integer jobId, Model model){
70
+		model.addAttribute("jobId", jobId);
71
+		return "job/edit";
72
+	}
73
+	
74
+	/**==========job end==========**/	
75
+	
76
+	/**==========trans start ==========**/
77
+	
78
+	@RequestMapping("trans/listUI.shtml")
79
+	public String transListUI(){
80
+		return "trans/list";
81
+	}
82
+	
83
+	@RequestMapping("trans/rAddUI.shtml")
84
+	public String transRAddUI(){
85
+		return "trans/r-add";
86
+	}
87
+	
88
+	@RequestMapping("trans/fAddUI.shtml")
89
+	public String transFAddUI(){
90
+		return "trans/f-add";
91
+	}
92
+	
93
+	@RequestMapping("trans/editUI.shtml")
94
+	public String transEditUI(Integer transId, Model model){
95
+		model.addAttribute("transId", transId);
96
+		return "trans/edit";
97
+	}
98
+	
99
+	/**==========trans end ==========**/
100
+	
101
+	/**==========user start==========**/
102
+	
103
+	@RequestMapping("user/listUI.shtml")
104
+	public String userListUI(){
105
+		return "user/list";
106
+	}
107
+	
108
+	@RequestMapping("user/addUI.shtml")
109
+	public String userAddUI(){
110
+		return "user/add";
111
+	}
112
+	
113
+	@RequestMapping("user/editUI.shtml")
114
+	public String userEditUI(Integer uId, Model model){
115
+		model.addAttribute("uId", uId);
116
+		return "user/edit";
117
+	}
118
+	
119
+	/**==========user end==========**/
120
+	
121
+	/**==========record start==========**/
122
+	
123
+	@RequestMapping("trans/record/listUI.shtml")
124
+	public String transRecordListUI(Integer transId, Model model){
125
+		model.addAttribute("transId", transId);
126
+		return "record/t-list";
127
+	}
128
+	
129
+	@RequestMapping("job/record/listUI.shtml")
130
+	public String jobRecordListUI(Integer jobId, Model model){
131
+		model.addAttribute("jobId", jobId);
132
+		return "record/j-list";
133
+	}
134
+	
135
+	/**==========record end==========**/
136
+	
137
+	/**==========monitor start==========**/
138
+	
139
+	@RequestMapping("trans/monitor/listUI.shtml")
140
+	public String transMonitorListUI(){
141
+		return "monitor/t-list";
142
+	}
143
+	
144
+	@RequestMapping("job/monitor/listUI.shtml")
145
+	public String jobMonitorListUI(){
146
+		return "monitor/j-list";
147
+	}
148
+	
149
+	/**==========monitor start==========**/
150
+
151
+	/**==========quartz start==========**/
152
+
153
+	@RequestMapping("quartz/listUI.shtml")
154
+	public String quartzListUI(){
155
+		return "quartz/list";
156
+	}
157
+
158
+	@RequestMapping("quartz/addUI.shtml")
159
+	public String quartzAddUI(){
160
+		return "quartz/add";
161
+	}
162
+
163
+	@RequestMapping("quartz/editUI.shtml")
164
+	public String quartzEditUI(Integer quartzId, Model model){
165
+		model.addAttribute("quartzId", quartzId);
166
+		return "quartz/edit";
167
+	}
168
+
169
+	/**==========quartz end==========**/
170
+
171
+	@RequestMapping("dimEtlConfig/listUI.shtml")
172
+	public String dimEtlConfigListUI(){
173
+		return "dimEtlConfig/list";
174
+	}
175
+
176
+	@RequestMapping("dimEtlConfig/addUI.shtml")
177
+	public String dimEtlConfigAddUI(){
178
+		return "dimEtlConfig/add";
179
+	}
180
+
181
+	@RequestMapping("dimEtlConfig/editUI.shtml")
182
+	public String dimEtlConfigEditUI(Integer id, Model model){
183
+		model.addAttribute("id", id);
184
+		return "dimEtlConfig/edit";
185
+	}
186
+
187
+
188
+	@RequestMapping("category/listUI.shtml")
189
+	public String categoryListUI(){
190
+		return "category/list";
191
+	}
192
+
193
+	@RequestMapping("category/addUI.shtml")
194
+	public String categoryAddUI(){
195
+		return "category/add";
196
+	}
197
+
198
+	@RequestMapping("category/editUI.shtml")
199
+	public String categoryEditUI(Integer categoryId, Model model){
200
+		model.addAttribute("categoryId", categoryId);
201
+		return "category/edit";
202
+	}
203
+}

+ 61 - 0
src/main/java/com/zhaxd/web/controller/QuartzController.java

@@ -0,0 +1,61 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import javax.servlet.http.HttpServletRequest;
4
+
5
+import com.zhaxd.core.dto.BootTablePage;
6
+import com.zhaxd.core.dto.ResultDto;
7
+import com.zhaxd.core.model.KQuartz;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import com.zhaxd.common.toolkit.Constant;
13
+import com.zhaxd.core.model.KUser;
14
+import com.zhaxd.web.service.QuartzService;
15
+import com.zhaxd.web.utils.JsonUtils;
16
+
17
+@RestController
18
+@RequestMapping("/quartz/")
19
+public class QuartzController {
20
+
21
+	@Autowired
22
+	private QuartzService quartzService;
23
+	
24
+	@RequestMapping("getSimpleList.shtml")
25
+	public String simpleList(HttpServletRequest request){
26
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
27
+		return JsonUtils.objectToJson(quartzService.getList(kUser.getuId()));
28
+	}
29
+	@RequestMapping("getQuartz.shtml")
30
+	public String getQuartz(Integer quartzId){
31
+		return ResultDto.success(quartzService.getQuartz(quartzId));
32
+	}
33
+
34
+	@RequestMapping("getList.shtml")
35
+	public String getList(Integer offset, Integer limit, HttpServletRequest request){
36
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
37
+		BootTablePage list = quartzService.getList(offset, limit, kUser.getuId());
38
+		return JsonUtils.objectToJson(list);
39
+	}
40
+	@RequestMapping("insert.shtml")
41
+	public String insert(KQuartz kQuartz, HttpServletRequest request){
42
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
43
+		quartzService.insert(kQuartz, kUser.getuId());
44
+		return ResultDto.success();
45
+	}
46
+	@RequestMapping("delete.shtml")
47
+	public String delete(Integer quartzId){
48
+		quartzService.delete(quartzId);
49
+		return ResultDto.success();
50
+	}
51
+	@RequestMapping("update.shtml")
52
+	public String update(KQuartz kQuartz, HttpServletRequest request){
53
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
54
+		try{
55
+			quartzService.update(kQuartz, kUser.getuId());
56
+			return ResultDto.success();
57
+		}catch(Exception e){
58
+			return ResultDto.success(e.toString());
59
+		}
60
+	}
61
+}

+ 158 - 0
src/main/java/com/zhaxd/web/controller/RepositoryController.java

@@ -0,0 +1,158 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import java.util.ArrayList;
4
+import java.util.HashMap;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import javax.servlet.http.HttpServletRequest;
9
+
10
+import org.pentaho.di.core.exception.KettleException;
11
+import org.springframework.beans.BeanUtils;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.RequestMapping;
14
+import org.springframework.web.bind.annotation.RestController;
15
+
16
+import com.zhaxd.common.toolkit.Constant;
17
+import com.zhaxd.core.dto.BootTablePage;
18
+import com.zhaxd.core.dto.ResultDto;
19
+import com.zhaxd.core.dto.kettle.RepositoryTree;
20
+import com.zhaxd.core.dto.web.KRepositoryDto;
21
+import com.zhaxd.core.model.KRepository;
22
+import com.zhaxd.core.model.KUser;
23
+import com.zhaxd.web.service.DataBaseRepositoryService;
24
+import com.zhaxd.web.utils.DataValidate;
25
+import com.zhaxd.web.utils.JsonUtils;
26
+
27
+@RestController
28
+@RequestMapping("/repository/")
29
+public class RepositoryController {
30
+
31
+	@Autowired
32
+	private DataBaseRepositoryService dataBaseRepositoryService;
33
+	
34
+	@RequestMapping("database/getJobTree.shtml")
35
+	public String getJobTree(Integer repositoryId){
36
+		try {
37
+			List<RepositoryTree> repositoryTreeList = dataBaseRepositoryService.getTreeList(repositoryId);
38
+			List<RepositoryTree> newRepositoryTreeList = new ArrayList<RepositoryTree>();
39
+			for(RepositoryTree repositoryTree : repositoryTreeList){
40
+				if ("0".equals(repositoryTree.getParent())){
41
+					repositoryTree.setParent("#");
42
+				}
43
+				if (repositoryTree.getId().indexOf("@") > 0){
44
+					repositoryTree.setIcon("none");
45
+				}
46
+				if (Constant.TYPE_TRANS.equals(repositoryTree.getType())){
47
+					Map<String,String> stateMap = new HashMap<String, String>();
48
+					stateMap.put("disabled", "false");
49
+					repositoryTree.setState(stateMap);
50
+				}
51
+				newRepositoryTreeList.add(repositoryTree);				
52
+			}
53
+			return JsonUtils.objectToJson(newRepositoryTreeList);
54
+		} catch (KettleException e) {
55
+			e.printStackTrace();
56
+		}
57
+		return null;
58
+	}
59
+	
60
+	@RequestMapping("database/getTransTree.shtml")
61
+	public String getTransTree(Integer repositoryId){
62
+		try {
63
+			List<RepositoryTree> repositoryTreeList = dataBaseRepositoryService.getTreeList(repositoryId);
64
+			List<RepositoryTree> newRepositoryTreeList = new ArrayList<RepositoryTree>();
65
+			for(RepositoryTree repositoryTree : repositoryTreeList){
66
+				if ("0".equals(repositoryTree.getParent())){
67
+					repositoryTree.setParent("#");
68
+				}
69
+				if (repositoryTree.getId().indexOf("@") > 0){
70
+					repositoryTree.setIcon("none");
71
+				}
72
+				if (Constant.TYPE_JOB.equals(repositoryTree.getType())){
73
+					Map<String,String> stateMap = new HashMap<String, String>();
74
+					stateMap.put("disabled", "false");
75
+					repositoryTree.setState(stateMap);
76
+				}
77
+				newRepositoryTreeList.add(repositoryTree);				
78
+			}
79
+			return JsonUtils.objectToJson(newRepositoryTreeList);
80
+		} catch (KettleException e) {
81
+			e.printStackTrace();
82
+		}
83
+		return null;		
84
+	}
85
+	
86
+	@RequestMapping("database/ckeck.shtml")
87
+	public String ckeck(KRepositoryDto kRepositoryDto){	
88
+		if (DataValidate.AllNotEmpty(kRepositoryDto)){
89
+			try {
90
+				KRepository kRepository = new KRepository();
91
+				BeanUtils.copyProperties(kRepositoryDto, kRepository);
92
+				if (dataBaseRepositoryService.ckeck(kRepository)){
93
+					return ResultDto.success("success");	
94
+				}else {
95
+					return ResultDto.success("fail");	
96
+				}
97
+			} catch (KettleException e) {
98
+				e.printStackTrace();
99
+				return ResultDto.success("fail");
100
+			}
101
+		}else {
102
+			return ResultDto.success("fail");
103
+		}		
104
+	}
105
+	
106
+	@RequestMapping("database/getSimpleList.shtml")
107
+	public String getSimpleList(HttpServletRequest request){
108
+		try {
109
+			KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
110
+			return JsonUtils.objectToJson(dataBaseRepositoryService.getList(kUser.getuId()));
111
+		} catch (KettleException e) {
112
+			e.printStackTrace();
113
+			return null;
114
+		}
115
+	}
116
+	
117
+	@RequestMapping("database/getList.shtml")
118
+	public String getList(Integer offset, Integer limit, HttpServletRequest request){
119
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
120
+		BootTablePage list = null;
121
+		list = dataBaseRepositoryService.getList(offset, limit, kUser.getuId());					
122
+		return JsonUtils.objectToJson(list);		
123
+	}
124
+	
125
+	@RequestMapping("database/getType.shtml")
126
+	public String getType(){		
127
+		return JsonUtils.objectToJson(dataBaseRepositoryService.getRepositoryTypeList());
128
+	}
129
+	
130
+	@RequestMapping("database/getAccess.shtml")
131
+	public String getAccess(){
132
+		return JsonUtils.objectToJson(dataBaseRepositoryService.getAccess());
133
+	}
134
+	
135
+	@RequestMapping("database/getKRepository.shtml")
136
+	public String getKRepository(Integer repositoryId){
137
+		return ResultDto.success(dataBaseRepositoryService.getKRepository(repositoryId));
138
+	}
139
+	
140
+	@RequestMapping("database/insert.shtml")
141
+	public String insert(KRepository kRepository, HttpServletRequest request){
142
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
143
+		dataBaseRepositoryService.insert(kRepository, kUser.getuId());
144
+		return ResultDto.success();	
145
+	}
146
+		
147
+	@RequestMapping("database/update.shtml")
148
+	public String update(KRepository kRepository, HttpServletRequest request){
149
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
150
+		dataBaseRepositoryService.update(kRepository, kUser.getuId());
151
+		return ResultDto.success();	
152
+	}
153
+	@RequestMapping("database/delete.shtml")
154
+	public String delete(Integer repositoryId){
155
+		dataBaseRepositoryService.delete(repositoryId);
156
+		return ResultDto.success();
157
+	}
158
+}

+ 134 - 0
src/main/java/com/zhaxd/web/controller/TransController.java

@@ -0,0 +1,134 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import java.io.IOException;
4
+import java.sql.SQLException;
5
+
6
+import javax.servlet.http.HttpServletRequest;
7
+
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+import org.springframework.web.multipart.MultipartFile;
12
+
13
+import com.zhaxd.common.toolkit.Constant;
14
+import com.zhaxd.core.dto.BootTablePage;
15
+import com.zhaxd.core.dto.ResultDto;
16
+import com.zhaxd.core.model.KTrans;
17
+import com.zhaxd.core.model.KUser;
18
+import com.zhaxd.web.service.TransService;
19
+import com.zhaxd.web.utils.JsonUtils;
20
+
21
+@RestController
22
+@RequestMapping("/trans/")
23
+public class TransController {
24
+
25
+    @Autowired
26
+    private TransService transService;
27
+
28
+
29
+    @RequestMapping("getSimpleList.shtml")
30
+    public String getSimpleList(HttpServletRequest request) {
31
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
32
+        return JsonUtils.objectToJson(transService.getList(kUser.getuId()));
33
+    }
34
+
35
+    @RequestMapping("getList.shtml")
36
+    public String getList(Integer offset, Integer limit, Integer categoryId, String transName, HttpServletRequest request) {
37
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
38
+        BootTablePage list = transService.getList(offset, limit, categoryId, transName, kUser.getuId());
39
+        return JsonUtils.objectToJson(list);
40
+    }
41
+
42
+    @RequestMapping("delete.shtml")
43
+    public String delete(Integer transId) {
44
+        transService.delete(transId);
45
+        return ResultDto.success();
46
+    }
47
+
48
+    @RequestMapping("uploadTrans.shtml")
49
+    public String uploadJob(MultipartFile transFile, HttpServletRequest request) {
50
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
51
+        try {
52
+            String saveFilePath = transService.saveFile(kUser.getuId(), transFile);
53
+            return ResultDto.success(saveFilePath);
54
+        } catch (IOException e) {
55
+            e.printStackTrace();
56
+            return null;
57
+        }
58
+    }
59
+
60
+    @RequestMapping("insert.shtml")
61
+    public String insert(KTrans kTrans, String customerQuarz, HttpServletRequest request) {
62
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
63
+        Integer uId = kUser.getuId();
64
+        if (transService.check(kTrans.getTransRepositoryId(), kTrans.getTransPath(), uId)) {
65
+            try {
66
+                transService.insert(kTrans, uId, customerQuarz);
67
+                return ResultDto.success();
68
+            } catch (SQLException e) {
69
+                e.printStackTrace();
70
+                return ResultDto.fail("添加作业失败");
71
+            }
72
+        } else {
73
+            return ResultDto.fail("该作业已经添加过了");
74
+        }
75
+    }
76
+
77
+    @RequestMapping("getTrans.shtml")
78
+    public String getTrans(Integer transId) {
79
+        return ResultDto.success(transService.getTrans(transId));
80
+    }
81
+
82
+    @RequestMapping("update.shtml")
83
+    public String update(KTrans kTrans, String customerQuarz, HttpServletRequest request) {
84
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
85
+        try {
86
+            transService.update(kTrans, customerQuarz, kUser.getuId());
87
+            return ResultDto.success();
88
+        } catch (Exception e) {
89
+            return ResultDto.success(e.toString());
90
+        }
91
+    }
92
+
93
+    @RequestMapping("start.shtml")
94
+    public String start(Integer transId) {
95
+        transService.start(transId);
96
+        return ResultDto.success();
97
+    }
98
+
99
+    @RequestMapping("stop.shtml")
100
+    public String stop(Integer transId) {
101
+        transService.stop(transId);
102
+        return ResultDto.success();
103
+    }
104
+
105
+    @RequestMapping("startAll.shtml")
106
+    public String startAll(Integer categoryId, String transName, HttpServletRequest request) {
107
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
108
+        transService.startAll(categoryId, transName, kUser.getuId());
109
+        return ResultDto.success();
110
+    }
111
+
112
+    @RequestMapping("stopAll.shtml")
113
+    public String stopAll(Integer categoryId, String transName, HttpServletRequest request) {
114
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
115
+        transService.stopAll(categoryId, transName, kUser.getuId());
116
+        return ResultDto.success();
117
+    }
118
+
119
+    @RequestMapping("getStartTaskCount.shtml")
120
+    public String getStartTaskCount(Integer categoryId, String transName,HttpServletRequest request) {
121
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
122
+        return JsonUtils.objectToJson(transService.getStartTaskCount(categoryId, transName, kUser.getuId()));
123
+    }
124
+
125
+    @RequestMapping("getStopTaskCount.shtml")
126
+    public String getStopTaskCount(Integer categoryId, String transName,HttpServletRequest request) {
127
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
128
+        return JsonUtils.objectToJson(transService.getStopTaskCount(categoryId, transName, kUser.getuId()));
129
+    }
130
+    @RequestMapping({"getTransRunState.shtml"})
131
+    public String getTransRunState(Integer transId) {
132
+        return JsonUtils.objectToJson(this.transService.getTransRunState(transId));
133
+    }
134
+}

+ 46 - 0
src/main/java/com/zhaxd/web/controller/TransMonitorController.java

@@ -0,0 +1,46 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import javax.servlet.http.HttpServletRequest;
4
+
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RestController;
8
+
9
+import com.zhaxd.common.toolkit.Constant;
10
+import com.zhaxd.core.dto.BootTablePage;
11
+import com.zhaxd.core.model.KUser;
12
+import com.zhaxd.web.service.TransMonitorService;
13
+import com.zhaxd.web.utils.JsonUtils;
14
+
15
+@RestController
16
+@RequestMapping("/trans/monitor/")
17
+public class TransMonitorController {
18
+
19
+    @Autowired
20
+    private TransMonitorService transMonitorService;
21
+
22
+    @RequestMapping("getList.shtml")
23
+    public String getList(Integer offset, Integer limit,Integer monitorStatus, Integer categoryId, String transName, HttpServletRequest request) {
24
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
25
+        BootTablePage list = transMonitorService.getList(offset, limit, monitorStatus,categoryId, transName, kUser.getuId());
26
+        return JsonUtils.objectToJson(list);
27
+    }
28
+
29
+    @RequestMapping("getAllMonitorTrans.shtml")
30
+    public String getAllMonitorJob(HttpServletRequest request) {
31
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
32
+        return JsonUtils.objectToJson(transMonitorService.getAllMonitorTrans(kUser.getuId()));
33
+    }
34
+
35
+    @RequestMapping("getAllSuccess.shtml")
36
+    public String getAllSuccess(HttpServletRequest request) {
37
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
38
+        return JsonUtils.objectToJson(transMonitorService.getAllSuccess(kUser.getuId()));
39
+    }
40
+
41
+    @RequestMapping("getAllFail.shtml")
42
+    public String getAllFail(HttpServletRequest request) {
43
+        KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
44
+        return JsonUtils.objectToJson(transMonitorService.getAllFail(kUser.getuId()));
45
+    }
46
+}

+ 40 - 0
src/main/java/com/zhaxd/web/controller/TransRecordController.java

@@ -0,0 +1,40 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import com.zhaxd.common.toolkit.Constant;
4
+import com.zhaxd.core.dto.BootTablePage;
5
+import com.zhaxd.core.dto.ResultDto;
6
+import com.zhaxd.core.model.KUser;
7
+import com.zhaxd.web.service.TransRecordService;
8
+import com.zhaxd.web.utils.JsonUtils;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RestController;
12
+
13
+import javax.servlet.http.HttpServletRequest;
14
+import java.io.IOException;
15
+
16
+@RestController
17
+@RequestMapping("/trans/record/")
18
+public class TransRecordController {
19
+
20
+	@Autowired
21
+	private TransRecordService transRecordService;
22
+
23
+	@RequestMapping("getList.shtml")
24
+	public String getList(Integer offset, Integer limit, Integer transId, HttpServletRequest request){
25
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
26
+		BootTablePage list = transRecordService.getList(offset, limit, kUser.getuId(), transId);
27
+		return JsonUtils.objectToJson(list);
28
+	}
29
+
30
+	@RequestMapping("getLogContent.shtml")
31
+	public String getLogContent(Integer recordId){
32
+		try {
33
+			String logContent = transRecordService.getLogContent(recordId);
34
+			return ResultDto.success(logContent.replace(System.getProperty("line.separator"), "<br/>"));
35
+		} catch (IOException e) {
36
+			e.printStackTrace();
37
+			return null;
38
+		}
39
+	}
40
+}

+ 72 - 0
src/main/java/com/zhaxd/web/controller/UserController.java

@@ -0,0 +1,72 @@
1
+package com.zhaxd.web.controller;
2
+
3
+import com.zhaxd.common.toolkit.Constant;
4
+import com.zhaxd.core.model.KUser;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RestController;
8
+
9
+import com.zhaxd.core.dto.ResultDto;
10
+import com.zhaxd.web.service.UserService;
11
+import com.zhaxd.web.utils.JsonUtils;
12
+
13
+import javax.servlet.http.HttpServletRequest;
14
+import javax.servlet.http.HttpServletResponse;
15
+import java.io.IOException;
16
+
17
+@RestController
18
+@RequestMapping("/user/")
19
+public class UserController {
20
+
21
+	@Autowired
22
+	private UserService userService;
23
+	
24
+	@RequestMapping("getList.shtml")
25
+	public String getList(Integer offset, Integer limit){
26
+		return JsonUtils.objectToJson(userService.getList(offset, limit));
27
+	}
28
+	
29
+	@RequestMapping("delete.shtml")
30
+	public String delete(Integer uId){
31
+		userService.delete(uId);
32
+		return ResultDto.success();
33
+	}
34
+	
35
+	@RequestMapping("resetPassword.shtml")
36
+	public String resetPassword(){
37
+		
38
+		return ResultDto.success();
39
+	}
40
+	@RequestMapping("insert.shtml")
41
+	public String insert(KUser kNewUser, HttpServletRequest request){
42
+		KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
43
+		userService.insert(kNewUser, kUser.getuId());
44
+		return ResultDto.success();
45
+	}
46
+	@RequestMapping("IsAccountExist.shtml")
47
+	public void IsAccountExist(String uAccount, HttpServletResponse response) {
48
+		try {
49
+			if (userService.IsAccountExist(uAccount)) {
50
+				response.getWriter().write("false");
51
+			} else {
52
+				response.getWriter().write("true");
53
+			}
54
+		} catch (IOException e) {
55
+			e.printStackTrace();
56
+		}
57
+	}
58
+	@RequestMapping("getUser.shtml")
59
+	public String getQuartz(Integer uId){
60
+		return ResultDto.success(userService.getUser(uId));
61
+	}
62
+	@RequestMapping("update.shtml")
63
+	public String update(KUser kUser, HttpServletRequest request){
64
+		KUser kLoginUser = (KUser) request.getSession().getAttribute(Constant.SESSION_ID);
65
+		try{
66
+			userService.update(kUser, kLoginUser.getuId());
67
+			return ResultDto.success();
68
+		}catch(Exception e){
69
+			return ResultDto.success(e.toString());
70
+		}
71
+	}
72
+}

+ 261 - 0
src/main/java/com/zhaxd/web/quartz/JobQuartz.java

@@ -0,0 +1,261 @@
1
+package com.zhaxd.web.quartz;
2
+
3
+import com.zhaxd.common.kettle.repository.RepositoryUtil;
4
+import com.zhaxd.common.toolkit.Constant;
5
+import com.zhaxd.core.model.KJobMonitor;
6
+import com.zhaxd.core.model.KJobRecord;
7
+import com.zhaxd.core.model.KRepository;
8
+import com.zhaxd.web.quartz.model.DBConnectionModel;
9
+import org.apache.commons.io.FileUtils;
10
+import org.apache.commons.lang.StringUtils;
11
+import org.beetl.sql.core.*;
12
+import org.beetl.sql.core.db.DBStyle;
13
+import org.beetl.sql.core.db.MySqlStyle;
14
+import org.beetl.sql.core.db.OracleStyle;
15
+import org.beetl.sql.ext.DebugInterceptor;
16
+import org.pentaho.di.core.ProgressNullMonitorListener;
17
+import org.pentaho.di.core.exception.KettleException;
18
+import org.pentaho.di.core.exception.KettleMissingPluginsException;
19
+import org.pentaho.di.core.exception.KettleXMLException;
20
+import org.pentaho.di.core.logging.KettleLogStore;
21
+import org.pentaho.di.core.logging.LogLevel;
22
+import org.pentaho.di.core.logging.LoggingBuffer;
23
+import org.pentaho.di.job.JobMeta;
24
+import org.pentaho.di.repository.RepositoryDirectoryInterface;
25
+import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
26
+import org.quartz.*;
27
+
28
+import java.io.File;
29
+import java.io.IOException;
30
+import java.sql.SQLException;
31
+import java.util.Date;
32
+
33
+@DisallowConcurrentExecution
34
+public class JobQuartz implements InterruptableJob {
35
+    private org.pentaho.di.job.Job job;
36
+
37
+    public void execute(JobExecutionContext context) throws JobExecutionException {
38
+
39
+        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
40
+        Object KRepositoryObject = jobDataMap.get(Constant.REPOSITORYOBJECT);
41
+        Object DbConnectionObject = jobDataMap.get(Constant.DBCONNECTIONOBJECT);
42
+        String jobName_str = context.getJobDetail().getKey().getName();
43
+        String[] names = jobName_str.split("@");
44
+        String jobId = String.valueOf(jobDataMap.get(Constant.JOBID));
45
+        String jobPath = String.valueOf(jobDataMap.get(Constant.JOBPATH));
46
+        String jobName = String.valueOf(jobDataMap.get(Constant.JOBNAME));
47
+        String userId = String.valueOf(jobDataMap.get(Constant.USERID));
48
+        String logLevel = String.valueOf(jobDataMap.get(Constant.LOGLEVEL));
49
+        String logFilePath = String.valueOf(jobDataMap.get(Constant.LOGFILEPATH));
50
+        Date lastExecuteTime = context.getFireTime();
51
+        Date nexExecuteTime = context.getNextFireTime();
52
+
53
+        if (null != DbConnectionObject && DbConnectionObject instanceof DBConnectionModel) {// 首先判断数据库连接对象是否正确
54
+            // 判断作业类型
55
+            if (null != KRepositoryObject && KRepositoryObject instanceof KRepository) {// 证明该作业是从资源库中获取到的
56
+                try {
57
+                    runRepositoryJob(KRepositoryObject, DbConnectionObject, jobId, jobPath, jobName, userId, logLevel,
58
+                            logFilePath, lastExecuteTime, nexExecuteTime);
59
+                } catch (KettleException e) {
60
+                    e.printStackTrace();
61
+                }
62
+            } else {
63
+                try {
64
+                    runFileJob(DbConnectionObject, jobId, jobPath, jobName, userId, logLevel, logFilePath, lastExecuteTime, nexExecuteTime);
65
+                } catch (KettleXMLException | KettleMissingPluginsException e) {
66
+                    e.printStackTrace();
67
+                }
68
+            }
69
+        }
70
+    }
71
+
72
+    /**
73
+     * @param KRepositoryObject 数据库连接对象
74
+     * @param KRepositoryObject 资源库对象
75
+     * @param jobId             作业ID
76
+     * @param jobPath           作业在资源库中的路径信息
77
+     * @param jobName           作业名称
78
+     * @param userId            作业归属者ID
79
+     * @param logLevel          作业的日志等级
80
+     * @param logFilePath       作业日志保存的根路径
81
+     * @return void
82
+     * @throws KettleException
83
+     * @Title runRepositoryJob
84
+     * @Description 运行资源库中的作业
85
+     */
86
+    public void runRepositoryJob(Object KRepositoryObject, Object DbConnectionObject, String jobId,
87
+                                 String jobPath, String jobName, String userId, String logLevel, String logFilePath, Date executeTime, Date nexExecuteTime) throws KettleException {
88
+        KRepository kRepository = (KRepository) KRepositoryObject;
89
+        Integer repositoryId = kRepository.getRepositoryId();
90
+        KettleDatabaseRepository kettleDatabaseRepository = null;
91
+        if (RepositoryUtil.KettleDatabaseRepositoryCatch.containsKey(repositoryId)) {
92
+            kettleDatabaseRepository = RepositoryUtil.KettleDatabaseRepositoryCatch.get(repositoryId);
93
+        } else {
94
+            kettleDatabaseRepository = RepositoryUtil.connectionRepository(kRepository);
95
+        }
96
+        if (null != kettleDatabaseRepository) {
97
+            RepositoryDirectoryInterface directory = kettleDatabaseRepository.loadRepositoryDirectoryTree()
98
+                    .findDirectory(jobPath);
99
+            JobMeta jobMeta = kettleDatabaseRepository.loadJob(jobName, directory, new ProgressNullMonitorListener(),
100
+                    null);
101
+            job = new org.pentaho.di.job.Job(kettleDatabaseRepository, jobMeta);
102
+            job.setDaemon(true);
103
+            job.setLogLevel(LogLevel.DEBUG);
104
+            if (StringUtils.isNotEmpty(logLevel)) {
105
+                job.setLogLevel(Constant.logger(logLevel));
106
+            }
107
+            String exception = null;
108
+            Integer recordStatus = 1;
109
+//            Date jobStartDate = null;
110
+            Date jobStopDate = null;
111
+            String logText = null;
112
+            try {
113
+//                jobStartDate = new Date();
114
+                job.run();
115
+                job.waitUntilFinished();
116
+                jobStopDate = new Date();
117
+            } catch (Exception e) {
118
+                exception = e.getMessage();
119
+                recordStatus = 2;
120
+            } finally {
121
+                if (job.isFinished()) {
122
+                    if (job.getErrors() > 0) {
123
+                        recordStatus = 2;
124
+                        if(null == job.getResult().getLogText() || "".equals(job.getResult().getLogText())){
125
+                            logText = exception;
126
+                        }
127
+                    }
128
+                    // 写入作业执行结果
129
+                    StringBuilder allLogFilePath = new StringBuilder();
130
+                    allLogFilePath.append(logFilePath).append("/").append(userId).append("/")
131
+                            .append(StringUtils.remove(jobPath, "/")).append("@").append(jobName).append("-log")
132
+                            .append("/").append(new Date().getTime()).append(".").append("txt");
133
+                    String logChannelId = job.getLogChannelId();
134
+                    LoggingBuffer appender = KettleLogStore.getAppender();
135
+                    logText = appender.getBuffer(logChannelId, true).toString();
136
+                    try {
137
+                        KJobRecord kJobRecord = new KJobRecord();
138
+                        kJobRecord.setRecordJob(Integer.parseInt(jobId));
139
+                        kJobRecord.setAddUser(Integer.parseInt(userId));
140
+                        kJobRecord.setLogFilePath(allLogFilePath.toString());
141
+                        kJobRecord.setRecordStatus(recordStatus);
142
+                        kJobRecord.setStartTime(executeTime);
143
+                        kJobRecord.setStopTime(jobStopDate);
144
+                        writeToDBAndFile(DbConnectionObject, kJobRecord, logText, executeTime, nexExecuteTime);
145
+                    } catch (IOException | SQLException e) {
146
+                        e.printStackTrace();
147
+                    }
148
+                }
149
+            }
150
+        }
151
+    }
152
+
153
+    public void runFileJob(Object DbConnectionObject, String jobId, String jobPath, String jobName,
154
+                           String userId, String logLevel, String logFilePath, Date lastExecuteTime, Date nexExecuteTime) throws KettleXMLException, KettleMissingPluginsException {
155
+        JobMeta jobMeta = new JobMeta(jobPath, null);
156
+        job = new org.pentaho.di.job.Job(null, jobMeta);
157
+        job.setDaemon(true);
158
+        job.setLogLevel(LogLevel.DEBUG);
159
+        if (StringUtils.isNotEmpty(logLevel)) {
160
+            job.setLogLevel(Constant.logger(logLevel));
161
+        }
162
+        String exception = null;
163
+        Integer recordStatus = 1;
164
+        Date jobStartDate = null;
165
+        Date jobStopDate = null;
166
+        String logText = null;
167
+        try {
168
+            jobStartDate = new Date();
169
+            job.run();
170
+            job.waitUntilFinished();
171
+            jobStopDate = new Date();
172
+        } catch (Exception e) {
173
+            exception = e.getMessage();
174
+            recordStatus = 2;
175
+        } finally {
176
+            if (null != job && job.isFinished()) {
177
+                if (job.getErrors() > 0
178
+                        && (null == job.getResult().getLogText() || "".equals(job.getResult().getLogText()))) {
179
+                    logText = exception;
180
+                }
181
+                // 写入作业执行结果
182
+                StringBuilder allLogFilePath = new StringBuilder();
183
+                allLogFilePath.append(logFilePath).append("/").append(userId).append("/")
184
+                        .append(StringUtils.remove(jobPath, "/")).append("@").append(jobName).append("-log").append("/")
185
+                        .append(new Date().getTime()).append(".").append("txt");
186
+                String logChannelId = job.getLogChannelId();
187
+                LoggingBuffer appender = KettleLogStore.getAppender();
188
+                logText = appender.getBuffer(logChannelId, true).toString();
189
+                try {
190
+                    KJobRecord kJobRecord = new KJobRecord();
191
+                    kJobRecord.setRecordJob(Integer.parseInt(jobId));
192
+                    kJobRecord.setAddUser(Integer.parseInt(userId));
193
+                    kJobRecord.setLogFilePath(allLogFilePath.toString());
194
+                    kJobRecord.setRecordStatus(recordStatus);
195
+                    kJobRecord.setStartTime(jobStartDate);
196
+                    kJobRecord.setStopTime(jobStopDate);
197
+                    writeToDBAndFile(DbConnectionObject, kJobRecord, logText, lastExecuteTime, nexExecuteTime);
198
+                } catch (IOException | SQLException e) {
199
+                    e.printStackTrace();
200
+                }
201
+            }
202
+        }
203
+    }
204
+
205
+    /**
206
+     * @param DbConnectionObject 数据库连接对象
207
+     * @param kJobRecord         作业记录信息
208
+     * @param logText            日志信息
209
+     * @return void
210
+     * @throws IOException
211
+     * @throws SQLException
212
+     * @Title writeToDBAndFile
213
+     * @Description 保存作业运行日志信息到文件和数据库
214
+     */
215
+    private void writeToDBAndFile(Object DbConnectionObject, KJobRecord kJobRecord, String logText, Date lastExecuteTime, Date nextExecuteTime)
216
+            throws IOException, SQLException {
217
+        // 将日志信息写入文件
218
+        FileUtils.writeStringToFile(new File(kJobRecord.getLogFilePath()), logText, Constant.DEFAULT_ENCODING, false);
219
+        // 写入转换运行记录到数据库
220
+        DBConnectionModel DBConnectionModel = (DBConnectionModel) DbConnectionObject;
221
+        ConnectionSource source = ConnectionSourceHelper.getSimple(DBConnectionModel.getConnectionDriveClassName(),
222
+                DBConnectionModel.getConnectionUrl(), DBConnectionModel.getConnectionUser(), DBConnectionModel.getConnectionPassword());
223
+        DBStyle dbStyle = null;
224
+        if("oracle".equalsIgnoreCase(Constant.DATASOURCE_TYPE)){
225
+            dbStyle = new OracleStyle();
226
+        }else if("mysql".equalsIgnoreCase(Constant.DATASOURCE_TYPE)){
227
+            dbStyle = new MySqlStyle();
228
+        }else{
229
+            dbStyle = new OracleStyle();
230
+        }
231
+        SQLLoader loader = new ClasspathLoader("/");
232
+        UnderlinedNameConversion nc = new UnderlinedNameConversion();
233
+        SQLManager sqlManager = new SQLManager(dbStyle, loader,
234
+                source, nc, new Interceptor[]{new DebugInterceptor()});
235
+        DSTransactionManager.start();
236
+        sqlManager.insert(kJobRecord);
237
+        KJobMonitor template = new KJobMonitor();
238
+        template.setAddUser(kJobRecord.getAddUser());
239
+        template.setMonitorJob(kJobRecord.getRecordJob());
240
+        KJobMonitor templateOne = sqlManager.templateOne(template);
241
+        templateOne.setLastExecuteTime(lastExecuteTime);
242
+        //在监控表中增加下一次执行时间
243
+        templateOne.setNextExecuteTime(nextExecuteTime);
244
+        if (kJobRecord.getRecordStatus() == 1) {// 证明成功
245
+            //成功次数加1
246
+            templateOne.setMonitorSuccess(templateOne.getMonitorSuccess() + 1);
247
+            sqlManager.updateById(templateOne);
248
+        } else if (kJobRecord.getRecordStatus() == 2) {// 证明失败
249
+            //失败次数加1
250
+            templateOne.setMonitorFail(templateOne.getMonitorFail() + 1);
251
+            sqlManager.updateById(templateOne);
252
+        }
253
+        DSTransactionManager.commit();
254
+    }
255
+
256
+    @Override
257
+    public void interrupt() throws UnableToInterruptJobException {
258
+        //stop the running job
259
+        this.job.stopAll();
260
+    }
261
+}

+ 71 - 0
src/main/java/com/zhaxd/web/quartz/QuartzListener.java

@@ -0,0 +1,71 @@
1
+package com.zhaxd.web.quartz;
2
+
3
+import com.zhaxd.common.toolkit.Constant;
4
+import com.zhaxd.core.model.KJob;
5
+import com.zhaxd.core.model.KTrans;
6
+import com.zhaxd.web.quartz.model.DBConnectionModel;
7
+import org.beetl.sql.core.*;
8
+import org.beetl.sql.core.db.DBStyle;
9
+import org.beetl.sql.core.db.MySqlStyle;
10
+import org.beetl.sql.core.db.OracleStyle;
11
+import org.beetl.sql.ext.DebugInterceptor;
12
+import org.quartz.JobDataMap;
13
+import org.quartz.JobExecutionContext;
14
+import org.quartz.JobExecutionException;
15
+import org.quartz.JobListener;
16
+
17
+import java.util.Date;
18
+
19
+public class QuartzListener implements JobListener{
20
+
21
+	@Override
22
+	public String getName() {
23
+		return new Date().getTime() + "QuartzListener";
24
+	}
25
+	@Override
26
+	public void jobToBeExecuted(JobExecutionContext context) {
27
+	}
28
+	@Override
29
+	public void jobExecutionVetoed(JobExecutionContext context) {
30
+	}
31
+	@Override
32
+	public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
33
+		String jobName = context.getJobDetail().getKey().getName();
34
+		String jobGroupName = context.getJobDetail().getKey().getGroup();
35
+		String triggerName = context.getTrigger().getKey().getName();
36
+		String triggerGroupName = context.getTrigger().getKey().getGroup();
37
+		//一次性任务,执行完之后需要移除
38
+		QuartzManager.removeJob(jobName, jobGroupName, triggerName, triggerGroupName);
39
+
40
+		JobDataMap dataMap = context.getJobDetail().getJobDataMap();
41
+		String jobId = String.valueOf(dataMap.get(Constant.TRANSID));
42
+		String jobtype = String.valueOf(dataMap.get(Constant.JOBTYPE));
43
+
44
+		Object DbConnectionObject = dataMap.get(Constant.DBCONNECTIONOBJECT);
45
+		DBConnectionModel DBConnectionModel = (DBConnectionModel) DbConnectionObject;
46
+		ConnectionSource source = ConnectionSourceHelper.getSimple(DBConnectionModel.getConnectionDriveClassName(),
47
+				DBConnectionModel.getConnectionUrl(), DBConnectionModel.getConnectionUser(), DBConnectionModel.getConnectionPassword());
48
+		DBStyle dbStyle = null;
49
+        if("oracle".equalsIgnoreCase(Constant.DATASOURCE_TYPE)){
50
+            dbStyle = new OracleStyle();
51
+        }else if("mysql".equalsIgnoreCase(Constant.DATASOURCE_TYPE)){
52
+            dbStyle = new MySqlStyle();
53
+        }else{
54
+            dbStyle = new OracleStyle();
55
+        }
56
+		SQLLoader loader = new ClasspathLoader("/");
57
+		UnderlinedNameConversion nc = new  UnderlinedNameConversion();
58
+		SQLManager sqlManager = new SQLManager(dbStyle, loader,
59
+				source, nc, new Interceptor[]{new DebugInterceptor()});
60
+		if (jobtype.equals("1")){
61
+			KJob kJob = sqlManager.unique(KJob.class,Integer.valueOf(jobId));
62
+			kJob.setJobStatus(2);
63
+			sqlManager.updateTemplateById(kJob);
64
+		}
65
+		else if (jobtype.equals("2")) {
66
+			KTrans kTrans = sqlManager.unique(KTrans.class, Integer.valueOf(jobId));
67
+			kTrans.setTransStatus(2);
68
+			sqlManager.updateTemplateById(kTrans);
69
+		}
70
+	}
71
+}

+ 231 - 0
src/main/java/com/zhaxd/web/quartz/QuartzManager.java

@@ -0,0 +1,231 @@
1
+package com.zhaxd.web.quartz;
2
+
3
+import org.quartz.*;
4
+import org.quartz.impl.StdSchedulerFactory;
5
+
6
+import java.util.Date;
7
+import java.util.Map;
8
+
9
+
10
+public class QuartzManager {
11
+
12
+    private static SchedulerFactory schedulerFactory = new StdSchedulerFactory();
13
+
14
+    /**
15
+     * @param jobName          任务名
16
+     *                         以作业为例:  JOB@1(资源库ID)@/job/mysql-mysql(JOB全路径)
17
+     * @param jobGroupName     任务组名
18
+     *                         以作业为例:  JOB_GROUP@1(用户ID)@1(资源库ID)@/job/mysql-mysql(JOB全路径)
19
+     * @param triggerName      触发器名
20
+     *                         以作业为例:  TRIGGER@1(资源库ID)@/job/mysql-mysql(JOB全路径)
21
+     * @param triggerGroupName 触发器组名
22
+     *                         以作业为例:  TRIGGER_GROUP@1(用户ID)@1(资源库ID)@/job/mysql-mysql(JOB全路径)
23
+     * @param jobClass         任务对象实例
24
+     * @param cron             时间设置,参考quartz说明文档
25
+     * @param parameter        传入的参数
26
+     * @return void
27
+     * @Title addJob
28
+     * @Description 添加一个定时任务
29
+     */
30
+    public static Date addJob(String jobName, String jobGroupName,
31
+                              String triggerName, String triggerGroupName, Class<? extends Job> jobClass, String cron, Map<String, Object> parameter) {
32
+        try {
33
+            Scheduler sched = schedulerFactory.getScheduler();
34
+            // 任务名,任务组,任务执行类
35
+            JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName, jobGroupName).build();
36
+            // 添加任务执行的参数
37
+            parameter.forEach((k, v) -> {
38
+                jobDetail.getJobDataMap().put(k, v);
39
+            });
40
+            // 触发器
41
+            TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
42
+            // 触发器名,触发器组
43
+            triggerBuilder.withIdentity(triggerName, triggerGroupName);
44
+            triggerBuilder.startNow();
45
+            // 触发器时间设定
46
+            triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cron));
47
+            // 创建Trigger对象
48
+            CronTrigger trigger = (CronTrigger) triggerBuilder.build();
49
+            // 调度容器设置JobDetail和Trigger
50
+            sched.scheduleJob(jobDetail, trigger);
51
+            // 启动  
52
+            if (!sched.isShutdown()) {
53
+                sched.start();
54
+            }
55
+            return trigger.getNextFireTime();
56
+        } catch (Exception e) {
57
+            e.printStackTrace();
58
+            return null;
59
+        }
60
+    }
61
+
62
+
63
+    public static Date addOnceJob(String jobName, String jobGroupName,
64
+                                  String triggerName, String triggerGroupName, Class<? extends Job> jobClass, Map<String, Object> parameter) {
65
+        try {
66
+            Scheduler sched = schedulerFactory.getScheduler();
67
+            // 任务名,任务组,任务执行类
68
+            JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName, jobGroupName).build();
69
+            // 添加任务执行的参数
70
+            parameter.forEach((k, v) -> {
71
+                jobDetail.getJobDataMap().put(k, v);
72
+            });
73
+            // 触发器
74
+//            TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
75
+//            // 触发器名,触发器组
76
+//            triggerBuilder.withIdentity(triggerName, triggerGroupName);
77
+//            triggerBuilder.startNow();
78
+            //立即执行
79
+//            StringBuilder cronBuilder = new StringBuilder();
80
+//            DateTime dateTime = new DateTime();
81
+//            Integer addMinute = dateTime.second() >= 58 ? 2 : 1;
82
+//            cronBuilder.append("0").append(" ")
83
+//                    .append(dateTime.minute() + addMinute).append(" ")
84
+//                    .append(dateTime.hour(true)).append(" ")
85
+//                    .append(dateTime.dayOfMonth()).append(" ")
86
+//                    .append(dateTime.monthStartFromOne()).append(" ")
87
+//                    .append("?").append(" ")
88
+//                    .append(String.valueOf(dateTime.year()));
89
+
90
+            // 触发器时间设定
91
+//            triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cronBuilder.toString()));
92
+            // 创建Trigger对象
93
+//            CronTrigger trigger = (CronTrigger) triggerBuilder.build();
94
+            // 调度容器设置JobDetail和Trigger
95
+//            sched.scheduleJob(jobDetail, trigger);
96
+//            // 添加任务执行监听器
97
+//            sched.getListenerManager().addJobListener(new QuartzListener(),
98
+//            		KeyMatcher.keyEquals(new JobKey(jobName, jobGroupName)));
99
+            //3秒后立即执行,重复次数设为0,表示只执行一次
100
+            SimpleTrigger simpleTrigger = TriggerBuilder.newTrigger().withIdentity(triggerName, triggerGroupName).startNow()
101
+                    .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(3).withRepeatCount(0))
102
+                    .build();
103
+            sched.scheduleJob(jobDetail, simpleTrigger);
104
+            // 启动
105
+            if (!sched.isShutdown()) {
106
+                sched.start();
107
+            }
108
+            return simpleTrigger.getNextFireTime();
109
+        } catch (Exception e) {
110
+            e.printStackTrace();
111
+            return null;
112
+        }
113
+    }
114
+
115
+    /**
116
+     * @param jobName
117
+     * @param jobGroupName
118
+     * @param triggerName      触发器名
119
+     * @param triggerGroupName 触发器组名
120
+     * @param cron             时间设置,参考quartz说明文档
121
+     * @Description: 修改一个任务的触发时间
122
+     */
123
+    public static void modifyJobTime(String jobName,
124
+                                     String jobGroupName, String triggerName, String triggerGroupName, String cron) {
125
+        try {
126
+            Scheduler sched = schedulerFactory.getScheduler();
127
+            TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName);
128
+            CronTrigger trigger = (CronTrigger) sched.getTrigger(triggerKey);
129
+            if (trigger == null) {
130
+                return;
131
+            }
132
+            String oldTime = trigger.getCronExpression();
133
+            if (!oldTime.equalsIgnoreCase(cron)) {
134
+                /** 方式一 :调用 rescheduleJob 开始 */
135
+                // 触发器  
136
+                TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
137
+                // 触发器名,触发器组  
138
+                triggerBuilder.withIdentity(triggerName, triggerGroupName);
139
+                triggerBuilder.startNow();
140
+                // 触发器时间设定  
141
+                triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cron));
142
+                // 创建Trigger对象
143
+                trigger = (CronTrigger) triggerBuilder.build();
144
+                // 方式一 :修改一个任务的触发时间
145
+                sched.rescheduleJob(triggerKey, trigger);
146
+                /** 方式一 :调用 rescheduleJob 结束 */
147
+
148
+                /** 方式二:先删除,然后在创建一个新的Job  */
149
+                //JobDetail jobDetail = sched.getJobDetail(JobKey.jobKey(jobName, jobGroupName));  
150
+                //Class<? extends Job> jobClass = jobDetail.getJobClass();  
151
+                //removeJob(jobName, jobGroupName, triggerName, triggerGroupName);  
152
+                //addJob(jobName, jobGroupName, triggerName, triggerGroupName, jobClass, cron); 
153
+                /** 方式二 :先删除,然后在创建一个新的Job */
154
+            }
155
+        } catch (Exception e) {
156
+            throw new RuntimeException(e);
157
+        }
158
+    }
159
+
160
+    /**
161
+     * @param jobName
162
+     * @param jobGroupName
163
+     * @param triggerName
164
+     * @param triggerGroupName
165
+     * @Description: 移除一个任务
166
+     */
167
+    public static void removeJob(String jobName, String jobGroupName,
168
+                                 String triggerName, String triggerGroupName) {
169
+        try {
170
+            Scheduler sched = schedulerFactory.getScheduler();
171
+            TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName);
172
+            sched.pauseTrigger(triggerKey);// 停止触发器  
173
+            sched.unscheduleJob(triggerKey);// 移除触发器
174
+            sched.interrupt(JobKey.jobKey(jobName, jobGroupName));
175
+            sched.deleteJob(JobKey.jobKey(jobName, jobGroupName));// 删除任务
176
+        } catch (Exception e) {
177
+            throw new RuntimeException(e);
178
+        }
179
+    }
180
+
181
+    /**
182
+     * @Description:启动所有定时任务
183
+     */
184
+    public static void startJobs() {
185
+        try {
186
+            Scheduler sched = schedulerFactory.getScheduler();
187
+            sched.start();
188
+        } catch (Exception e) {
189
+            throw new RuntimeException(e);
190
+        }
191
+    }
192
+
193
+    /**
194
+     * @Description:关闭所有定时任务
195
+     */
196
+    public static void shutdownJobs() {
197
+        try {
198
+            Scheduler sched = schedulerFactory.getScheduler();
199
+            if (!sched.isShutdown()) {
200
+                sched.shutdown();
201
+            }
202
+        } catch (Exception e) {
203
+            throw new RuntimeException(e);
204
+        }
205
+    }
206
+
207
+    /**
208
+     * @Description: 获取任务状态
209
+     * 		NONE: 不存在
210
+     * 		NORMAL: 正常
211
+     * 		PAUSED: 暂停
212
+     * 		COMPLETE:完成
213
+     * 		ERROR : 错误
214
+     * 		BLOCKED : 阻塞
215
+     * @param triggerName   触发器名
216
+     * @param triggerGroupName
217
+     * @date 2018521日 下午2:13:45
218
+     */
219
+    public static String getTriggerState(String triggerName,String triggerGroupName){
220
+        TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName);
221
+        String name = null;
222
+        try {
223
+            Scheduler sched = schedulerFactory.getScheduler();
224
+            Trigger.TriggerState triggerState = sched.getTriggerState(triggerKey);
225
+            name = triggerState.name();
226
+        } catch (SchedulerException e) {
227
+            e.printStackTrace();
228
+        }
229
+        return name;
230
+    }
231
+}

+ 271 - 0
src/main/java/com/zhaxd/web/quartz/TransQuartz.java

@@ -0,0 +1,271 @@
1
+package com.zhaxd.web.quartz;
2
+
3
+import com.zhaxd.common.kettle.repository.RepositoryUtil;
4
+import com.zhaxd.common.toolkit.Constant;
5
+import com.zhaxd.core.model.KRepository;
6
+import com.zhaxd.core.model.KTransMonitor;
7
+import com.zhaxd.core.model.KTransRecord;
8
+import com.zhaxd.web.quartz.model.DBConnectionModel;
9
+import org.apache.commons.io.FileUtils;
10
+import org.apache.commons.lang.StringUtils;
11
+import org.beetl.sql.core.*;
12
+import org.beetl.sql.core.db.DBStyle;
13
+import org.beetl.sql.core.db.MySqlStyle;
14
+import org.beetl.sql.core.db.OracleStyle;
15
+import org.beetl.sql.ext.DebugInterceptor;
16
+import org.pentaho.di.core.ProgressNullMonitorListener;
17
+import org.pentaho.di.core.exception.KettleException;
18
+import org.pentaho.di.core.exception.KettleMissingPluginsException;
19
+import org.pentaho.di.core.exception.KettleXMLException;
20
+import org.pentaho.di.core.logging.KettleLogStore;
21
+import org.pentaho.di.core.logging.LogLevel;
22
+import org.pentaho.di.core.logging.LoggingBuffer;
23
+import org.pentaho.di.repository.RepositoryDirectoryInterface;
24
+import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
25
+import org.pentaho.di.trans.Trans;
26
+import org.pentaho.di.trans.TransMeta;
27
+import org.quartz.*;
28
+
29
+import java.io.File;
30
+import java.io.IOException;
31
+import java.sql.SQLException;
32
+import java.util.Date;
33
+
34
+@DisallowConcurrentExecution
35
+public class TransQuartz implements InterruptableJob {
36
+    private Trans trans;
37
+
38
+    public void execute(JobExecutionContext context) throws JobExecutionException {
39
+        JobDataMap transDataMap = context.getJobDetail().getJobDataMap();
40
+        Object KRepositoryObject = transDataMap.get(Constant.REPOSITORYOBJECT);
41
+        Object DbConnectionObject = transDataMap.get(Constant.DBCONNECTIONOBJECT);
42
+        String transId = String.valueOf(transDataMap.get(Constant.TRANSID));
43
+        String transPath = String.valueOf(transDataMap.get(Constant.TRANSPATH));
44
+        String transName = String.valueOf(transDataMap.get(Constant.TRANSNAME));
45
+        String userId = String.valueOf(transDataMap.get(Constant.USERID));
46
+        String logLevel = String.valueOf(transDataMap.get(Constant.LOGLEVEL));
47
+        String logFilePath = String.valueOf(transDataMap.get(Constant.LOGFILEPATH));
48
+        Date lastExecuteTime = context.getFireTime();
49
+        Date nexExecuteTime = context.getNextFireTime();
50
+        if (null != DbConnectionObject && DbConnectionObject instanceof DBConnectionModel) {// 首先判断数据库连接对象是否正确
51
+            // 判断转换类型
52
+            if (null != KRepositoryObject && KRepositoryObject instanceof KRepository) {// 证明该转换是从资源库中获取到的
53
+                try {
54
+                    runRepositorytrans(KRepositoryObject, DbConnectionObject, transId, transPath, transName, userId,
55
+                            logLevel, logFilePath, lastExecuteTime, nexExecuteTime);
56
+                } catch (KettleException e) {
57
+                    e.printStackTrace();
58
+                }
59
+            } else {
60
+                try {
61
+                    runFiletrans(DbConnectionObject, transId, transPath, transName, userId, logLevel, logFilePath, lastExecuteTime, nexExecuteTime);
62
+                } catch (KettleXMLException | KettleMissingPluginsException e) {
63
+                    e.printStackTrace();
64
+                }
65
+            }
66
+        }
67
+    }
68
+
69
+    /**
70
+     * @param KRepositoryObject 数据库连接对象
71
+     * @param KRepositoryObject 资源库对象
72
+     * @param transId           转换ID
73
+     * @param transPath         转换在资源库中的路径信息
74
+     * @param transName         转换名称
75
+     * @param userId            转换归属者ID
76
+     * @param logLevel          转换的日志等级
77
+     * @param logFilePath       转换日志保存的根路径
78
+     * @return void
79
+     * @throws KettleException
80
+     * @Title runRepositorytrans
81
+     * @Description 运行资源库中的转换
82
+     */
83
+    private void runRepositorytrans(Object KRepositoryObject, Object DbConnectionObject, String transId,
84
+                                    String transPath, String transName, String userId, String logLevel, String logFilePath, Date executeTime, Date nexExecuteTime)
85
+            throws KettleException {
86
+        KRepository kRepository = (KRepository) KRepositoryObject;
87
+        Integer repositoryId = kRepository.getRepositoryId();
88
+        KettleDatabaseRepository kettleDatabaseRepository = null;
89
+        if (RepositoryUtil.KettleDatabaseRepositoryCatch.containsKey(repositoryId)) {
90
+            kettleDatabaseRepository = RepositoryUtil.KettleDatabaseRepositoryCatch.get(repositoryId);
91
+        } else {
92
+            kettleDatabaseRepository = RepositoryUtil.connectionRepository(kRepository);
93
+        }
94
+        if (null != kettleDatabaseRepository) {
95
+            RepositoryDirectoryInterface directory = kettleDatabaseRepository.loadRepositoryDirectoryTree()
96
+                    .findDirectory(transPath);
97
+            TransMeta transMeta = kettleDatabaseRepository.loadTransformation(transName, directory,
98
+                    new ProgressNullMonitorListener(), true, null);
99
+            trans = new Trans(transMeta);
100
+            trans.setLogLevel(LogLevel.DEBUG);
101
+            if (StringUtils.isNotEmpty(logLevel)) {
102
+                trans.setLogLevel(Constant.logger(logLevel));
103
+            }
104
+            String exception = null;
105
+            Integer recordStatus = 1;
106
+//            Date transStartDate = null;
107
+            Date transStopDate = null;
108
+            String logText = null;
109
+            try {
110
+//                transStartDate = new Date();
111
+                trans.execute(null);
112
+                trans.waitUntilFinished();
113
+                transStopDate = new Date();
114
+            } catch (Exception e) {
115
+                exception = e.getMessage();
116
+                recordStatus = 2;
117
+            } finally {
118
+                if (trans.isFinished()) {
119
+                    if (trans.getErrors() > 0) {
120
+                        recordStatus = 2;
121
+                        if (null == trans.getResult().getLogText() || "".equals(trans.getResult().getLogText())){
122
+                            logText = exception;
123
+                        }
124
+                    }
125
+                    // 写入转换执行结果
126
+                    StringBuilder allLogFilePath = new StringBuilder();
127
+                    allLogFilePath.append(logFilePath).append("/").append(userId).append("/")
128
+                            .append(StringUtils.remove(transPath, "/")).append("@").append(transName).append("-log")
129
+                            .append("/").append(new Date().getTime()).append(".").append("txt");
130
+                    String logChannelId = trans.getLogChannelId();
131
+                    LoggingBuffer appender = KettleLogStore.getAppender();
132
+                    logText = appender.getBuffer(logChannelId, true).toString();
133
+                    try {
134
+                        KTransRecord kTransRecord = new KTransRecord();
135
+                        kTransRecord.setRecordTrans(Integer.parseInt(transId));
136
+                        kTransRecord.setLogFilePath(allLogFilePath.toString());
137
+                        kTransRecord.setAddUser(Integer.parseInt(userId));
138
+                        kTransRecord.setRecordStatus(recordStatus);
139
+                        kTransRecord.setStartTime(executeTime);
140
+                        kTransRecord.setStopTime(transStopDate);
141
+                        writeToDBAndFile(DbConnectionObject, kTransRecord, logText, executeTime, nexExecuteTime);
142
+                    } catch (IOException | SQLException e) {
143
+                        e.printStackTrace();
144
+                    }
145
+                }
146
+            }
147
+        }
148
+    }
149
+
150
+    /**
151
+     * @param DbConnectionObject 数据库连接对象
152
+     * @param transId            装换ID
153
+     * @param transPath          转换文件所在的路径
154
+     * @param transName          转换的名称
155
+     * @param userId             用户ID
156
+     * @param logLevel           装换运行的日志等级
157
+     * @param logFilePath        转换的运行日志保存的位置
158
+     * @return void
159
+     * @throws KettleXMLException
160
+     * @throws KettleMissingPluginsException
161
+     * @Title runFiletrans
162
+     * @Description 运行文件类型的转换
163
+     */
164
+    private void runFiletrans(Object DbConnectionObject, String transId, String transPath, String transName,
165
+                              String userId, String logLevel, String logFilePath, Date lastExecuteTime, Date nexExecuteTime)
166
+            throws KettleXMLException, KettleMissingPluginsException {
167
+        TransMeta transMeta = new TransMeta(transPath);
168
+        trans = new Trans(transMeta);
169
+        trans.setLogLevel(LogLevel.DEBUG);
170
+        if (StringUtils.isNotEmpty(logLevel)) {
171
+            trans.setLogLevel(Constant.logger(logLevel));
172
+        }
173
+        String exception = null;
174
+        Integer recordStatus = 1;
175
+        Date transStartDate = null;
176
+        Date transStopDate = null;
177
+        String logText = null;
178
+        try {
179
+            transStartDate = new Date();
180
+            trans.execute(null);
181
+            trans.waitUntilFinished();
182
+            transStopDate = new Date();
183
+        } catch (Exception e) {
184
+            exception = e.getMessage();
185
+            recordStatus = 2;
186
+        } finally {
187
+            if (null != trans && trans.isFinished()) {
188
+                if (trans.getErrors() > 0
189
+                        && (null == trans.getResult().getLogText() || "".equals(trans.getResult().getLogText()))) {
190
+                    logText = exception;
191
+                }
192
+                // 写入转换执行结果
193
+                StringBuilder allLogFilePath = new StringBuilder();
194
+                allLogFilePath.append(logFilePath).append("/").append(userId).append("/")
195
+                        .append(StringUtils.remove(transPath, "/")).append("@").append(transName).append("-log")
196
+                        .append("/").append(new Date().getTime()).append(".").append("txt");
197
+                String logChannelId = trans.getLogChannelId();
198
+                LoggingBuffer appender = KettleLogStore.getAppender();
199
+                logText = appender.getBuffer(logChannelId, true).toString();
200
+                try {
201
+                    KTransRecord kTransRecord = new KTransRecord();
202
+                    kTransRecord.setRecordTrans(Integer.parseInt(transId));
203
+                    kTransRecord.setAddUser(Integer.parseInt(userId));
204
+                    kTransRecord.setLogFilePath(allLogFilePath.toString());
205
+                    kTransRecord.setRecordStatus(recordStatus);
206
+                    kTransRecord.setStartTime(transStartDate);
207
+                    kTransRecord.setStopTime(transStopDate);
208
+                    writeToDBAndFile(DbConnectionObject, kTransRecord, logText, lastExecuteTime, nexExecuteTime);
209
+                } catch (IOException | SQLException e) {
210
+                    e.printStackTrace();
211
+                }
212
+            }
213
+        }
214
+    }
215
+
216
+    /**
217
+     * @param DbConnectionObject 数据库连接对象
218
+     * @param kTransRecord       转换运行记录对象
219
+     * @param logText            日志记录
220
+     * @return void
221
+     * @throws IOException
222
+     * @throws SQLException
223
+     * @Title writeToDBAndFile
224
+     * @Description 保存转换运行日志信息到文件和数据库
225
+     */
226
+    private void writeToDBAndFile(Object DbConnectionObject, KTransRecord kTransRecord, String logText, Date lastExecuteTime, Date nextExecuteTime)
227
+            throws IOException, SQLException {
228
+        // 将日志信息写入文件
229
+        FileUtils.writeStringToFile(new File(kTransRecord.getLogFilePath()), logText, Constant.DEFAULT_ENCODING, false);
230
+        // 写入转换运行记录到数据库
231
+        DBConnectionModel DBConnectionModel = (DBConnectionModel) DbConnectionObject;
232
+        ConnectionSource source = ConnectionSourceHelper.getSimple(DBConnectionModel.getConnectionDriveClassName(),
233
+                DBConnectionModel.getConnectionUrl(), DBConnectionModel.getConnectionUser(), DBConnectionModel.getConnectionPassword());
234
+        DBStyle dbStyle = null;
235
+        if("oracle".equalsIgnoreCase(Constant.DATASOURCE_TYPE)){
236
+            dbStyle = new OracleStyle();
237
+        }else if("mysql".equalsIgnoreCase(Constant.DATASOURCE_TYPE)){
238
+            dbStyle = new MySqlStyle();
239
+        }else{
240
+            dbStyle = new OracleStyle();
241
+        }
242
+        SQLLoader loader = new ClasspathLoader("/");
243
+        UnderlinedNameConversion nc = new UnderlinedNameConversion();
244
+        SQLManager sqlManager = new SQLManager(dbStyle, loader,
245
+                source, nc, new Interceptor[]{new DebugInterceptor()});
246
+        DSTransactionManager.start();
247
+        sqlManager.insert(kTransRecord);
248
+        KTransMonitor template = new KTransMonitor();
249
+        template.setAddUser(kTransRecord.getAddUser());
250
+        template.setMonitorTrans(kTransRecord.getRecordTrans());
251
+        KTransMonitor templateOne = sqlManager.templateOne(template);
252
+        templateOne.setLastExecuteTime(lastExecuteTime);
253
+        templateOne.setNextExecuteTime(nextExecuteTime);
254
+        if (kTransRecord.getRecordStatus() == 1) {// 证明成功
255
+            //成功次数加1
256
+            templateOne.setMonitorSuccess(templateOne.getMonitorSuccess() + 1);
257
+            sqlManager.updateById(templateOne);
258
+        } else if (kTransRecord.getRecordStatus() == 2) {// 证明失败
259
+            //失败次数加1
260
+            templateOne.setMonitorFail(templateOne.getMonitorFail() + 1);
261
+            sqlManager.updateById(templateOne);
262
+        }
263
+        DSTransactionManager.commit();
264
+    }
265
+
266
+    @Override
267
+    public void interrupt() throws UnableToInterruptJobException {
268
+        //stop the running transformation
269
+        this.trans.stopAll();
270
+    }
271
+}

+ 40 - 0
src/main/java/com/zhaxd/web/quartz/model/DBConnectionModel.java

@@ -0,0 +1,40 @@
1
+package com.zhaxd.web.quartz.model;
2
+
3
+public class DBConnectionModel {
4
+
5
+	private String connectionDriveClassName;
6
+	private String connectionUrl;
7
+	private String connectionUser;
8
+	private String connectionPassword;
9
+	public String getConnectionDriveClassName() {
10
+		return connectionDriveClassName;
11
+	}
12
+	public void setConnectionDriveClassName(String connectionDriveClassName) {
13
+		this.connectionDriveClassName = connectionDriveClassName;
14
+	}
15
+	public String getConnectionUrl() {
16
+		return connectionUrl;
17
+	}
18
+	public void setConnectionUrl(String connectionUrl) {
19
+		this.connectionUrl = connectionUrl;
20
+	}
21
+	public String getConnectionUser() {
22
+		return connectionUser;
23
+	}
24
+	public void setConnectionUser(String connectionUser) {
25
+		this.connectionUser = connectionUser;
26
+	}
27
+	public String getConnectionPassword() {
28
+		return connectionPassword;
29
+	}
30
+	public void setConnectionPassword(String connectionPassword) {
31
+		this.connectionPassword = connectionPassword;
32
+	}
33
+	public DBConnectionModel(String connectionDriveClassName, String connectionUrl, String connectionUser,
34
+			String connectionPassword) {
35
+		this.connectionDriveClassName = connectionDriveClassName;
36
+		this.connectionUrl = connectionUrl;
37
+		this.connectionUser = connectionUser;
38
+		this.connectionPassword = connectionPassword;
39
+	}
40
+}

+ 79 - 0
src/main/java/com/zhaxd/web/service/CategoryService.java

@@ -0,0 +1,79 @@
1
+package com.zhaxd.web.service;
2
+
3
+import com.zhaxd.core.dto.BootTablePage;
4
+import com.zhaxd.core.mapper.KCategoryDao;
5
+import com.zhaxd.core.model.KCategory;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+
9
+import java.util.ArrayList;
10
+import java.util.Date;
11
+import java.util.List;
12
+
13
+@Service
14
+public class CategoryService {
15
+    @Autowired
16
+    private KCategoryDao kCategoryDao;
17
+  
18
+    public List<KCategory> getList(Integer uId){
19
+        List<KCategory> resultList = new ArrayList<KCategory>();
20
+        KCategory kCategory = new KCategory();
21
+        kCategory.setDelFlag(1);
22
+        kCategory.setAddUser(uId);
23
+        resultList.addAll(kCategoryDao.template(kCategory));
24
+        return resultList;
25
+    }
26
+    
27
+    public BootTablePage getList(Integer start, Integer size, Integer uId){
28
+        KCategory kCategory = new KCategory();
29
+        kCategory.setDelFlag(1);
30
+        kCategory.setAddUser(uId);
31
+        List<KCategory> kQuartzList = kCategoryDao.template(kCategory, start, size);
32
+        long allCount = kCategoryDao.templateCount(kCategory);
33
+        BootTablePage bootTablePage = new BootTablePage();
34
+        bootTablePage.setRows(kQuartzList);
35
+        bootTablePage.setTotal(allCount);
36
+        return bootTablePage;
37
+    }
38
+ 
39
+    public KCategory getQuartz(Integer categoryId){
40
+        return kCategoryDao.single(categoryId);
41
+    }
42
+    
43
+    public void insert(KCategory kCategory, Integer uId){
44
+        kCategory.setAddTime(new Date());
45
+        kCategory.setAddUser(uId);
46
+        kCategory.setEditTime(new Date());
47
+        kCategory.setEditUser(uId);
48
+        kCategory.setDelFlag(1);
49
+        kCategoryDao.insert(kCategory);
50
+    }
51
+
52
+    public void delete(Integer categoryId){
53
+        KCategory kCategory = kCategoryDao.unique(categoryId);
54
+        kCategory.setDelFlag(0);
55
+        kCategoryDao.updateById(kCategory);
56
+    }
57
+
58
+ 
59
+    public void update(KCategory kCategory, Integer uId){
60
+        kCategory.setEditTime(new Date());
61
+        kCategory.setEditUser(uId);
62
+        //只有不为null的字段才参与更新
63
+        kCategoryDao.updateTemplateById(kCategory);
64
+    }
65
+
66
+    public boolean IsCategoryExist(Integer categoryId,String categoryName) {
67
+        KCategory template = new KCategory();
68
+        template.setDelFlag(1);
69
+        template.setCategoryName(categoryName);
70
+        KCategory category = kCategoryDao.templateOne(template);
71
+        if (null == category) {
72
+            return false;
73
+        } else if(categoryId!=null&&category.getCategoryId()==categoryId){
74
+            return false;
75
+        }else{
76
+            return true;
77
+        }
78
+    }
79
+}

+ 183 - 0
src/main/java/com/zhaxd/web/service/DataBaseRepositoryService.java

@@ -0,0 +1,183 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Date;
5
+import java.util.List;
6
+
7
+import org.pentaho.di.core.exception.KettleException;
8
+import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.stereotype.Service;
11
+
12
+import com.zhaxd.common.kettle.repository.RepositoryUtil;
13
+import com.zhaxd.core.dto.BootTablePage;
14
+import com.zhaxd.core.dto.kettle.RepositoryTree;
15
+import com.zhaxd.core.mapper.KRepositoryDao;
16
+import com.zhaxd.core.mapper.KRepositoryTypeDao;
17
+import com.zhaxd.core.model.KRepository;
18
+import com.zhaxd.core.model.KRepositoryType;
19
+
20
+@Service
21
+public class DataBaseRepositoryService {
22
+
23
+	
24
+	@Autowired
25
+	private KRepositoryDao kRepositoryDao;
26
+	
27
+	@Autowired
28
+	private KRepositoryTypeDao kRepositoryTypeDao; 
29
+	
30
+	/**
31
+	 * @Title getRepositoryTreeList
32
+	 * @Description 获取数据库资源库的树形菜单
33
+	 * @param repositoryId
34
+	 * @return
35
+	 * @throws KettleException
36
+	 * @return List<RepositoryTree>
37
+	 */
38
+	public List<RepositoryTree> getTreeList(Integer repositoryId) throws KettleException{
39
+		KettleDatabaseRepository kettleDatabaseRepository = null;
40
+		List<RepositoryTree> allRepositoryTreeList = new ArrayList<RepositoryTree>();
41
+		if (RepositoryUtil.KettleDatabaseRepositoryCatch.containsKey(repositoryId)){
42
+			kettleDatabaseRepository = RepositoryUtil.KettleDatabaseRepositoryCatch.get(repositoryId);
43
+		}else {
44
+			KRepository kRepository = kRepositoryDao.unique(repositoryId);
45
+			kettleDatabaseRepository = RepositoryUtil.connectionRepository(kRepository);
46
+		}
47
+		if (null != kettleDatabaseRepository){
48
+			List<RepositoryTree> repositoryTreeList = new ArrayList<RepositoryTree>();
49
+			allRepositoryTreeList = RepositoryUtil.getAllDirectoryTreeList(kettleDatabaseRepository, "/", repositoryTreeList);	
50
+		}
51
+		return allRepositoryTreeList;
52
+	}
53
+	
54
+	/**
55
+	 * @Title ckeck
56
+	 * @Description 判断是否可以连接上资源库
57
+	 * @param kRepository
58
+	 * @return
59
+	 * @throws KettleException
60
+	 * @return boolean
61
+	 */
62
+	public boolean ckeck(KRepository kRepository) throws KettleException{
63
+		KettleDatabaseRepository kettleDatabaseRepository = RepositoryUtil.connectionRepository(kRepository);
64
+		if (kettleDatabaseRepository != null){
65
+			if (kettleDatabaseRepository.isConnected()){
66
+				return true;
67
+			}else{
68
+				return false;	
69
+			}
70
+		}else{
71
+			return false;
72
+		}
73
+	}
74
+	
75
+	/**
76
+	 * @Title getList
77
+	 * @Description 获取列表,不分页
78
+	 * @param uId 用户ID
79
+	 * @return
80
+	 * @throws KettleException
81
+	 * @return List<KRepository>
82
+	 */
83
+	public List<KRepository> getList(Integer uId) throws KettleException{
84
+		KRepository kRepository = new KRepository();
85
+		kRepository.setAddUser(uId);
86
+		kRepository.setDelFlag(1);		
87
+		return kRepositoryDao.template(kRepository);
88
+	}
89
+	
90
+	/**
91
+	 * @Title getList
92
+	 * @Description 获取列表带分页
93
+	 * @param start 其实行数
94
+	 * @param size 每页数据条数
95
+	 * @param uId 用户ID
96
+	 * @return
97
+	 * @return BootTablePage
98
+	 */
99
+	public BootTablePage getList(Integer start, Integer size, Integer uId){
100
+		KRepository kRepository = new KRepository();
101
+		kRepository.setAddUser(uId);
102
+		kRepository.setDelFlag(1);	
103
+		List<KRepository> kRepositoryList = kRepositoryDao.template(kRepository);
104
+		long allCount = kRepositoryDao.templateCount(kRepository);
105
+		BootTablePage bootTablePage = new BootTablePage();
106
+		bootTablePage.setRows(kRepositoryList);
107
+		bootTablePage.setTotal(allCount);
108
+		return bootTablePage;
109
+	}
110
+	
111
+	/**
112
+	 * @Title getRepositoryTypeList
113
+	 * @Description 获取资源库类别列表
114
+	 * @return 
115
+	 * @return List<KRepositoryType>
116
+	 */
117
+	public List<KRepositoryType> getRepositoryTypeList(){
118
+		return kRepositoryTypeDao.all();
119
+	}
120
+	
121
+	/**
122
+	 * @Title getKRepository
123
+	 * @Description 获取资源库对象
124
+	 * @param repositoryId 资源库ID
125
+	 * @return
126
+	 * @return KRepository
127
+	 */
128
+	public KRepository getKRepository(Integer repositoryId){
129
+		//如果根据主键没有获取到对象,返回null
130
+		return kRepositoryDao.single(repositoryId);
131
+	}
132
+	
133
+	/**
134
+	 * @Title getAccess
135
+	 * @Description 获取资源库访问类型
136
+	 * @return 
137
+	 * @return String[]
138
+	 */
139
+	public String[] getAccess(){
140
+		return RepositoryUtil.getDataBaseAccess();
141
+	}
142
+	
143
+	/**
144
+	 * @Title insert
145
+	 * @Description 插入资源库
146
+	 * @param kRepository 资源库对象
147
+	 * @param uId 用户ID
148
+	 * @return void
149
+	 */
150
+	public void insert(KRepository kRepository, Integer uId){
151
+		kRepository.setAddTime(new Date());
152
+		kRepository.setAddUser(uId);
153
+		kRepository.setEditTime(new Date());
154
+		kRepository.setEditUser(uId);
155
+		kRepository.setDelFlag(1);
156
+		kRepositoryDao.insert(kRepository);
157
+	}
158
+	
159
+	/**
160
+	 * @Title update
161
+	 * @Description 更新资源库
162
+	 * @param kRepository 资源库对象
163
+	 * @param uId 用户ID
164
+	 * @return void
165
+	 */
166
+	public void update(KRepository kRepository, Integer uId){
167
+		kRepository.setEditTime(new Date());
168
+		kRepository.setEditUser(uId);
169
+		//只有不为null的字段才参与更新
170
+		kRepositoryDao.updateTemplateById(kRepository);
171
+	}
172
+	/**
173
+	 * @Title delete
174
+	 * @Description 删除资源库
175
+	 * @param repositoryId 资源库ID
176
+	 * @return void
177
+	 */
178
+	public void delete(Integer repositoryId){
179
+		KRepository kRepository = kRepositoryDao.unique(repositoryId);
180
+		kRepository.setDelFlag(0);
181
+		kRepositoryDao.updateById(kRepository);
182
+	}
183
+}

+ 156 - 0
src/main/java/com/zhaxd/web/service/JobMonitorService.java

@@ -0,0 +1,156 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Collections;
5
+import java.util.HashMap;
6
+import java.util.List;
7
+import java.util.Map;
8
+
9
+import org.apache.commons.lang.StringUtils;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Service;
12
+
13
+import com.zhaxd.common.toolkit.Constant;
14
+import com.zhaxd.core.dto.BootTablePage;
15
+import com.zhaxd.core.mapper.KJobMonitorDao;
16
+import com.zhaxd.core.model.KJobMonitor;
17
+import com.zhaxd.web.utils.CommonUtils;
18
+
19
+@Service
20
+public class JobMonitorService {
21
+
22
+    @Autowired
23
+    private KJobMonitorDao kJobMonitorDao;
24
+
25
+    /**
26
+     * @param start 起始行数
27
+     * @param size  每页数据条数
28
+     * @param uId   用户ID
29
+     * @return BootTablePage
30
+     * @Title getList
31
+     * @Description 获取作业监控分页列表
32
+     */
33
+    public BootTablePage getList(Integer start, Integer size, Integer monitorStatus, Integer categoryId, String jobName, Integer uId) {
34
+        KJobMonitor template = new KJobMonitor();
35
+        template.setAddUser(uId);
36
+        template.setMonitorStatus(monitorStatus);
37
+        if(StringUtils.isNotEmpty(jobName)){
38
+            template.setJobName(jobName);
39
+        }
40
+        List<KJobMonitor> kJobMonitorList = kJobMonitorDao.pageQuery(template, start, size,categoryId);
41
+        Long allCount = kJobMonitorDao.allCount(template,categoryId);
42
+        BootTablePage bootTablePage = new BootTablePage();
43
+        bootTablePage.setRows(kJobMonitorList);
44
+        bootTablePage.setTotal(allCount);
45
+        return bootTablePage;
46
+    }
47
+
48
+    /**
49
+     * @param uId   用户ID
50
+     * @return BootTablePage
51
+     * @Title getList
52
+     * @Description 获取作业监控不分页列表
53
+     */
54
+    public BootTablePage getList(Integer uId) {
55
+        KJobMonitor template = new KJobMonitor();
56
+        template.setAddUser(uId);
57
+        template.setMonitorStatus(1);
58
+        List<KJobMonitor> kJobMonitorList = kJobMonitorDao.template(template);
59
+        Collections.sort(kJobMonitorList);
60
+        List<KJobMonitor> newKJobMonitorList = new ArrayList<KJobMonitor>();
61
+        if (kJobMonitorList.size() >= 5) {
62
+            newKJobMonitorList = kJobMonitorList.subList(0, 5);
63
+        } else {
64
+            newKJobMonitorList = kJobMonitorList;
65
+        }
66
+        BootTablePage bootTablePage = new BootTablePage();
67
+        bootTablePage.setRows(newKJobMonitorList);
68
+        bootTablePage.setTotal(5);
69
+        return bootTablePage;
70
+    }
71
+
72
+    /**
73
+     * @param uId 用户ID
74
+     * @return Integer
75
+     * @Title getAllMonitorJob
76
+     * @Description 获取所有的监控作业
77
+     */
78
+    public Integer getAllMonitorJob(Integer uId) {
79
+        KJobMonitor template = new KJobMonitor();
80
+        template.setAddUser(uId);
81
+        template.setMonitorStatus(1);
82
+        List<KJobMonitor> kJobMonitorList = kJobMonitorDao.template(template);
83
+        return kJobMonitorList.size();
84
+    }
85
+
86
+    /**
87
+     * @param uId 用户ID
88
+     * @return Integer
89
+     * @Title getAllSuccess
90
+     * @Description 获取执行成功的数
91
+     */
92
+    public Integer getAllSuccess(Integer uId) {
93
+        KJobMonitor template = new KJobMonitor();
94
+        template.setAddUser(uId);
95
+        template.setMonitorStatus(1);
96
+        List<KJobMonitor> kJobMonitorList = kJobMonitorDao.template(template);
97
+        Integer allSuccess = 0;
98
+        for (KJobMonitor KJobMonitor : kJobMonitorList) {
99
+            allSuccess += KJobMonitor.getMonitorSuccess();
100
+        }
101
+        return allSuccess;
102
+    }
103
+
104
+    /**
105
+     * @param uId 用户ID
106
+     * @return Integer
107
+     * @Title getAllFail
108
+     * @Description 获取执行失败的数
109
+     */
110
+    public Integer getAllFail(Integer uId) {
111
+        KJobMonitor template = new KJobMonitor();
112
+        template.setAddUser(uId);
113
+        template.setMonitorStatus(1);
114
+        List<KJobMonitor> kJobMonitorList = kJobMonitorDao.template(template);
115
+        Integer allSuccess = 0;
116
+        for (KJobMonitor KJobMonitor : kJobMonitorList) {
117
+            allSuccess += KJobMonitor.getMonitorFail();
118
+        }
119
+        return allSuccess;
120
+    }
121
+
122
+    /**
123
+     * @param uId 用户ID
124
+     * @return Map<String   ,   Object>
125
+     * @Title getTransLine
126
+     * @Description 获取7天内作业的折线图
127
+     */
128
+    public Map<String, Object> getJobLine(Integer uId) {
129
+        KJobMonitor template = new KJobMonitor();
130
+        template.setAddUser(uId);
131
+        List<KJobMonitor> kJobMonitorList = kJobMonitorDao.template(template);
132
+        HashMap<String, Object> resultMap = new HashMap<String, Object>();
133
+        List<Integer> resultList = new ArrayList<Integer>();
134
+        for (int i = 0; i < 7; i++) {
135
+            resultList.add(i, 0);
136
+        }
137
+        if (kJobMonitorList != null && !kJobMonitorList.isEmpty()) {
138
+            for (KJobMonitor KJobMonitor : kJobMonitorList) {
139
+                String runStatus = KJobMonitor.getRunStatus();
140
+                if (runStatus != null && runStatus.contains(",")) {
141
+                    String[] startList = runStatus.split(",");
142
+                    for (String startOnce : startList) {
143
+                        String[] startAndStopTime = startOnce.split(Constant.RUNSTATUS_SEPARATE);
144
+                        if (startAndStopTime.length != 2)
145
+                            continue;
146
+                        //得到一次任务的起始时间和结束时间的毫秒值
147
+                        resultList = CommonUtils.getEveryDayData(Long.parseLong(startAndStopTime[0]), Long.parseLong(startAndStopTime[1]), resultList);
148
+                    }
149
+                }
150
+            }
151
+        }
152
+        resultMap.put("name", "作业");
153
+        resultMap.put("data", resultList);
154
+        return resultMap;
155
+    }
156
+}

+ 59 - 0
src/main/java/com/zhaxd/web/service/JobRecordService.java

@@ -0,0 +1,59 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.io.File;
4
+import java.io.IOException;
5
+import java.util.List;
6
+
7
+import org.apache.commons.io.FileUtils;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Service;
10
+
11
+import com.zhaxd.common.toolkit.Constant;
12
+import com.zhaxd.core.dto.BootTablePage;
13
+import com.zhaxd.core.mapper.KJobRecordDao;
14
+import com.zhaxd.core.model.KJobRecord;
15
+
16
+@Service
17
+public class JobRecordService {
18
+
19
+	@Autowired
20
+	private KJobRecordDao kJobRecordDao;
21
+	
22
+	/**
23
+	 * @Title getList
24
+	 * @Description 获取带分页的列表
25
+	 * @param start 起始行数
26
+	 * @param size 每页行数
27
+	 * @param uId 用户ID
28
+	 * @param jobId 作业ID
29
+	 * @return
30
+	 * @return BootTablePage
31
+	 */
32
+	public BootTablePage getList(Integer start, Integer size, Integer uId, Integer jobId){
33
+		KJobRecord template = new KJobRecord();
34
+		template.setAddUser(uId);
35
+		if (jobId != null){
36
+			template.setRecordJob(jobId);
37
+		}
38
+		List<KJobRecord> kJobRecordList = kJobRecordDao.template(template, start, size);
39
+		long totalCount = kJobRecordDao.templateCount(template);
40
+		BootTablePage bootTablePage = new BootTablePage();
41
+		bootTablePage.setRows(kJobRecordList);
42
+		bootTablePage.setTotal(totalCount);
43
+		return bootTablePage;
44
+	}
45
+	
46
+	/**
47
+	 * @Title getLogContent
48
+	 * @Description 转换日志内容
49
+	 * @param recordId 转换记录ID
50
+	 * @return
51
+	 * @throws IOException
52
+	 * @return String
53
+	 */
54
+	public String getLogContent(Integer jobId) throws IOException{
55
+		KJobRecord kJobRecord = kJobRecordDao.unique(jobId);
56
+		String logFilePath = kJobRecord.getLogFilePath();
57
+		return FileUtils.readFileToString(new File(logFilePath), Constant.DEFAULT_ENCODING);
58
+	}
59
+}

+ 513 - 0
src/main/java/com/zhaxd/web/service/JobService.java

@@ -0,0 +1,513 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.io.IOException;
4
+import java.sql.SQLException;
5
+import java.util.Date;
6
+import java.util.HashMap;
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+import org.apache.commons.lang.StringUtils;
11
+import org.beetl.sql.core.DSTransactionManager;
12
+import org.beetl.sql.core.db.KeyHolder;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.beans.factory.annotation.Value;
15
+import org.springframework.stereotype.Service;
16
+import org.springframework.web.multipart.MultipartFile;
17
+
18
+import com.zhaxd.common.exception.SeviceException;
19
+import com.zhaxd.common.toolkit.Constant;
20
+import com.zhaxd.core.dto.BootTablePage;
21
+import com.zhaxd.core.mapper.KJobDao;
22
+import com.zhaxd.core.mapper.KJobMonitorDao;
23
+import com.zhaxd.core.mapper.KQuartzDao;
24
+import com.zhaxd.core.mapper.KRepositoryDao;
25
+import com.zhaxd.core.model.KJob;
26
+import com.zhaxd.core.model.KJobMonitor;
27
+import com.zhaxd.core.model.KQuartz;
28
+import com.zhaxd.core.model.KRepository;
29
+import com.zhaxd.web.quartz.JobQuartz;
30
+import com.zhaxd.web.quartz.QuartzManager;
31
+import com.zhaxd.web.quartz.model.DBConnectionModel;
32
+import com.zhaxd.web.utils.CommonUtils;
33
+
34
+@Service
35
+public class JobService {
36
+
37
+
38
+    @Autowired
39
+    private KJobDao kJobDao;
40
+
41
+    @Autowired
42
+    private KQuartzDao kQuartzDao;
43
+
44
+    @Autowired
45
+    private KRepositoryDao KRepositoryDao;
46
+
47
+    @Autowired
48
+    private KJobMonitorDao kJobMonitorDao;
49
+
50
+    @Value("${kettle.log.file.path}")
51
+    private String kettleLogFilePath;
52
+
53
+    @Value("${kettle.file.repository}")
54
+    private String kettleFileRepository;
55
+
56
+    @Value("${jdbc.driver}")
57
+    private String jdbcDriver;
58
+
59
+    @Value("${jdbc.url}")
60
+    private String jdbcUrl;
61
+
62
+    @Value("${jdbc.username}")
63
+    private String jdbcUsername;
64
+
65
+    @Value("${jdbc.password}")
66
+    private String jdbcPassword;
67
+
68
+    /**
69
+     * @param start 其实行数
70
+     * @param size  获取数据的条数
71
+     * @param uId   用户ID
72
+     * @return BootTablePage
73
+     * @Title getList
74
+     * @Description 获取列表
75
+     */
76
+    public BootTablePage getList(Integer start, Integer size, Integer categoryId, String jobName, Integer uId) {
77
+        KJob template = new KJob();
78
+        template.setAddUser(uId);
79
+        template.setDelFlag(1);
80
+        if (categoryId != null) {
81
+            template.setCategoryId(categoryId);
82
+        }
83
+        if (StringUtils.isNotEmpty(jobName)) {
84
+            template.setJobName(jobName);
85
+        }
86
+//		List<KJob> kJobList = kJobDao.template(template, start, size);
87
+//		Long allCount = kJobDao.templateCount(template);
88
+        List<KJob> kJobList = kJobDao.pageQuery(template, start, size);
89
+        Long allCount = kJobDao.allCount(template);
90
+        BootTablePage bootTablePage = new BootTablePage();
91
+        bootTablePage.setRows(kJobList);
92
+        bootTablePage.setTotal(allCount);
93
+        return bootTablePage;
94
+    }
95
+
96
+    /**
97
+     * @param uId 用户ID
98
+     * @return List<KJob>
99
+     * @Title getList
100
+     * @Description 获取列表
101
+     */
102
+    public List<KJob> getList(Integer uId) {
103
+        KJob template = new KJob();
104
+        template.setAddUser(uId);
105
+        template.setDelFlag(1);
106
+        return kJobDao.template(template);
107
+    }
108
+
109
+    /**
110
+     * @param jobId 作业ID
111
+     * @return void
112
+     * @Title delete
113
+     * @Description 删除作业
114
+     */
115
+    public void delete(Integer jobId) {
116
+        KJob kJob = kJobDao.unique(jobId);
117
+        kJob.setDelFlag(0);
118
+        kJobDao.updateById(kJob);
119
+    }
120
+
121
+    /**
122
+     * @param repositoryId 资源库ID
123
+     * @param jobPath      作业路径
124
+     * @param uId          用户ID
125
+     * @return boolean
126
+     * @Title check
127
+     * @Description 检查当前作业是否可以插入到数据库
128
+     */
129
+    public boolean check(Integer repositoryId, String jobPath, Integer uId) {
130
+        KJob template = new KJob();
131
+        template.setDelFlag(1);
132
+        template.setAddUser(uId);
133
+        template.setJobRepositoryId(repositoryId);
134
+        template.setJobPath(jobPath);
135
+        List<KJob> kJobList = kJobDao.template(template);
136
+        if (null != kJobList && kJobList.size() > 0) {
137
+            return false;
138
+        } else {
139
+            return true;
140
+        }
141
+    }
142
+
143
+    /**
144
+     * @param uId     用户ID
145
+     * @param jobFile 上传的作业文件
146
+     * @return String
147
+     * @throws IOException
148
+     * @Title saveFile
149
+     * @Description 保存上传的作业文件
150
+     */
151
+    public String saveFile(Integer uId, MultipartFile jobFile) throws IOException {
152
+        return CommonUtils.saveFile(uId, kettleFileRepository, jobFile);
153
+    }
154
+
155
+    /**
156
+     * @param kJob          作业信息
157
+     * @param uId           用户ID
158
+     * @param customerQuarz 自定义定时策略
159
+     * @return void
160
+     * @throws SQLException
161
+     * @Title insert
162
+     * @Description 插入作业到数据库
163
+     */
164
+    public void insert(KJob kJob, Integer uId, String customerQuarz) throws SQLException {
165
+        DSTransactionManager.start();
166
+        //补充添加作业信息
167
+        //作业基础信息
168
+        kJob.setAddUser(uId);
169
+        kJob.setAddTime(new Date());
170
+        kJob.setEditUser(uId);
171
+        kJob.setEditTime(new Date());
172
+        //作业是否被删除
173
+        kJob.setDelFlag(1);
174
+        //作业是否启动
175
+        kJob.setJobStatus(2);
176
+        if (StringUtils.isNotBlank(customerQuarz)) {
177
+            //添加任务执行的调度策略
178
+            KQuartz kQuartz = new KQuartz();
179
+            kQuartz.setAddUser(uId);
180
+            kQuartz.setAddTime(new Date());
181
+            kQuartz.setEditUser(uId);
182
+            kQuartz.setEditTime(new Date());
183
+            kQuartz.setDelFlag(1);
184
+            kQuartz.setQuartzCron(customerQuarz);
185
+            kQuartz.setQuartzDescription(kJob.getJobName() + "的定时策略");
186
+            KeyHolder kQuartzKey = kQuartzDao.insertReturnKey(kQuartz);
187
+            //插入调度策略
188
+            kJob.setJobQuartz(kQuartzKey.getInt());
189
+        } else if (StringUtils.isBlank(customerQuarz) && new Integer(0).equals(kJob.getJobQuartz())) {
190
+            kJob.setJobQuartz(1);
191
+        } else if (StringUtils.isBlank(customerQuarz) && kJob.getJobQuartz() == null) {
192
+            kJob.setJobQuartz(1);
193
+        }
194
+        kJobDao.insert(kJob);
195
+        DSTransactionManager.commit();
196
+    }
197
+
198
+    /**
199
+     * @param jobId 作业ID
200
+     * @return KJob
201
+     * @Title getJob
202
+     * @Description 获取作业信息
203
+     */
204
+    public KJob getJob(Integer jobId) {
205
+        return kJobDao.single(jobId);
206
+    }
207
+
208
+    /**
209
+     * @param kJob          作业对象
210
+     * @param customerQuarz 自定义定时策略
211
+     * @param uId           用户ID
212
+     * @return void
213
+     * @Title update
214
+     * @Description 更新作业信息
215
+     */
216
+    public void update(KJob kJob, String customerQuarz, Integer uId) {
217
+        if (StringUtils.isNotBlank(customerQuarz)) {
218
+            Integer jobQuartzId = kJob.getJobQuartz();
219
+            KQuartz kQuartz = kQuartzDao.single(jobQuartzId);
220
+            if (kQuartz.getAddUser() == uId) {// 如果更新前选择的是自定义的,这一步要更新
221
+                kQuartz.setQuartzCron(customerQuarz);
222
+                kQuartzDao.updateTemplateById(kQuartz);
223
+            } else {// 如果更新前选择的是默认的定时策略,这一步要新增一个定时策略
224
+                KQuartz kQuartzTemeplate = new KQuartz();
225
+                kQuartzTemeplate.setAddUser(uId);
226
+                kQuartzTemeplate.setAddTime(new Date());
227
+                kQuartzTemeplate.setEditUser(uId);
228
+                kQuartzTemeplate.setEditTime(new Date());
229
+                kQuartzTemeplate.setDelFlag(1);
230
+                kQuartzTemeplate.setQuartzCron(customerQuarz);
231
+                kQuartzTemeplate.setQuartzDescription(kJob.getJobName() + "的定时策略");
232
+                KeyHolder kQuartzKey = kQuartzDao.insertReturnKey(kQuartzTemeplate);
233
+                //插入调度策略
234
+                kJob.setJobQuartz(kQuartzKey.getInt());
235
+            }
236
+        }
237
+        kJobDao.updateTemplateById(kJob);
238
+    }
239
+
240
+
241
+    /**
242
+     * @param jobId 作业ID
243
+     * @return void
244
+     * @throws SeviceException
245
+     * @Title start
246
+     * @Description 启动作业
247
+     */
248
+    public void start(Integer jobId) {
249
+        // 获取到作业对象
250
+        KJob kJob = kJobDao.unique(jobId);
251
+        // 获取到定时策略对象
252
+        KQuartz kQuartz = kQuartzDao.unique(kJob.getJobQuartz());
253
+        // 定时策略
254
+        String quartzCron = kQuartz.getQuartzCron();
255
+        // 用户ID
256
+        Integer userId = kJob.getAddUser();
257
+        // 获取调度任务的基础信息
258
+        Map<String, String> quartzBasic = getQuartzBasic(kJob);
259
+        // Quartz执行时的参数
260
+        Map<String, Object> quartzParameter = getQuartzParameter(kJob);
261
+        Date nextExecuteTime = null;
262
+        try {
263
+            // 判断作业执行类型
264
+            if (new Integer(1).equals(kJob.getJobQuartz())) {//如果是只执行一次
265
+                nextExecuteTime = QuartzManager.addOnceJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
266
+                        quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"), JobQuartz.class, quartzParameter);
267
+            } else {// 如果是按照策略执行
268
+                //添加任务
269
+                nextExecuteTime = QuartzManager.addJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
270
+                        quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"),
271
+                        JobQuartz.class, quartzCron, quartzParameter);
272
+            }
273
+        } catch (Exception e) {
274
+            kJob.setJobStatus(2);
275
+            kJobDao.updateTemplateById(kJob);
276
+            return;
277
+        }
278
+        // 添加监控
279
+        addMonitor(userId, jobId, nextExecuteTime);
280
+        kJob.setJobStatus(1);
281
+        kJobDao.updateTemplateById(kJob);
282
+    }
283
+
284
+    /**
285
+     * @param jobId 作业ID
286
+     * @return void
287
+     * @throws SeviceException
288
+     * @Title stop
289
+     * @Description 停止作业
290
+     */
291
+    public void stop(Integer jobId) {
292
+        // 获取到作业对象
293
+        KJob kJob = kJobDao.unique(jobId);
294
+        // 用户ID
295
+        Integer userId = kJob.getAddUser();
296
+        // 获取调度任务的基础信息
297
+        Map<String, String> quartzBasic = getQuartzBasic(kJob);
298
+        if (new Integer(1).equals(kJob.getJobQuartz())) {//如果是只执行一次
299
+            // 一次性执行任务,不允许手动停止
300
+            QuartzManager.removeJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
301
+                    quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"));
302
+        } else {// 如果是按照策略执行
303
+            //移除任务
304
+            QuartzManager.removeJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
305
+                    quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"));
306
+        }
307
+        // 移除监控
308
+        removeMonitor(userId, jobId);
309
+        kJob.setJobStatus(2);
310
+        kJobDao.updateTemplateById(kJob);
311
+    }
312
+
313
+    /**
314
+     * @param kJob 转换对象
315
+     * @return Map<String                               ,                                                               String> 任务调度的基础信息
316
+     * @Title getQuartzBasic
317
+     * @Description 获取任务调度的基础信息
318
+     */
319
+    private Map<String, String> getQuartzBasic(KJob kJob) {
320
+        Integer userId = kJob.getAddUser();
321
+        Integer transRepositoryId = kJob.getJobRepositoryId();
322
+        String jobPath = kJob.getJobPath();
323
+        Map<String, String> quartzBasic = new HashMap<String, String>();
324
+        // 拼接Quartz的任务名称
325
+        StringBuilder jobName = new StringBuilder();
326
+        jobName.append(Constant.JOB_PREFIX).append(Constant.QUARTZ_SEPARATE)
327
+                .append(transRepositoryId).append(Constant.QUARTZ_SEPARATE)
328
+                .append(jobPath);
329
+        // 拼接Quartz的任务组名称
330
+        StringBuilder jobGroupName = new StringBuilder();
331
+        jobGroupName.append(Constant.JOB_GROUP_PREFIX).append(Constant.QUARTZ_SEPARATE)
332
+                .append(userId).append(Constant.QUARTZ_SEPARATE)
333
+                .append(transRepositoryId).append(Constant.QUARTZ_SEPARATE)
334
+                .append(jobPath);
335
+        // 拼接Quartz的触发器名称
336
+        String triggerName = StringUtils.replace(jobName.toString(), Constant.JOB_PREFIX, Constant.TRIGGER_PREFIX);
337
+        // 拼接Quartz的触发器组名称
338
+        String triggerGroupName = StringUtils.replace(jobGroupName.toString(), Constant.JOB_GROUP_PREFIX, Constant.TRIGGER_GROUP_PREFIX);
339
+        quartzBasic.put("jobName", jobName.toString());
340
+        quartzBasic.put("jobGroupName", jobGroupName.toString());
341
+        quartzBasic.put("triggerName", triggerName);
342
+        quartzBasic.put("triggerGroupName", triggerGroupName);
343
+        return quartzBasic;
344
+    }
345
+
346
+    /**
347
+     * @param kJob 转换对象
348
+     * @return Map<String                               ,                                                               Object>
349
+     * @Title getQuartzParameter
350
+     * @Description 获取任务调度的参数
351
+     */
352
+    private Map<String, Object> getQuartzParameter(KJob kJob) {
353
+        // Quartz执行时的参数
354
+        Map<String, Object> parameter = new HashMap<String, Object>();
355
+        // 资源库对象
356
+        Integer transRepositoryId = kJob.getJobRepositoryId();
357
+        KRepository kRepository = null;
358
+        if (transRepositoryId != null) {// 这里是判断是否为资源库中的转换还是文件类型的转换的关键点
359
+            kRepository = KRepositoryDao.single(transRepositoryId);
360
+        }
361
+        // 资源库对象
362
+        parameter.put(Constant.REPOSITORYOBJECT, kRepository);
363
+        // 数据库连接对象
364
+        parameter.put(Constant.DBCONNECTIONOBJECT, new DBConnectionModel(jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword));
365
+        // 转换ID
366
+        parameter.put(Constant.JOBID, kJob.getJobId());
367
+        parameter.put(Constant.JOBTYPE, 1);
368
+        String jobPath = kJob.getJobPath();
369
+        if (jobPath.contains("/")) {
370
+            int lastIndexOf = StringUtils.lastIndexOf(jobPath, "/");
371
+            String path = jobPath.substring(0, lastIndexOf);
372
+            // 转换在资源库中的路径
373
+            parameter.put(Constant.JOBPATH, StringUtils.isEmpty(path) ? "/" : path);
374
+            // 转换名称
375
+            parameter.put(Constant.JOBNAME, jobPath.substring(lastIndexOf + 1, jobPath.length()));
376
+        }
377
+        // 用户ID
378
+        parameter.put(Constant.USERID, kJob.getAddUser());
379
+        // 转换日志等级
380
+        parameter.put(Constant.LOGLEVEL, kJob.getJobLogLevel());
381
+        // 转换日志的保存位置
382
+        parameter.put(Constant.LOGFILEPATH, kettleLogFilePath);
383
+        return parameter;
384
+    }
385
+
386
+
387
+    /**
388
+     * @param userId 用户ID
389
+     * @param jobId  转换ID
390
+     * @return void
391
+     * @Title addMonitor
392
+     * @Description 添加监控
393
+     */
394
+    private void addMonitor(Integer userId, Integer jobId, Date nextExecuteTime) {
395
+        KJobMonitor template = new KJobMonitor();
396
+        template.setAddUser(userId);
397
+        template.setMonitorJob(jobId);
398
+        KJobMonitor templateOne = kJobMonitorDao.templateOne(template);
399
+        if (null != templateOne) {
400
+            templateOne.setMonitorStatus(1);
401
+            StringBuilder runStatusBuilder = new StringBuilder();
402
+            runStatusBuilder.append(templateOne.getRunStatus())
403
+                    .append(",").append(new Date().getTime()).append(Constant.RUNSTATUS_SEPARATE);
404
+            templateOne.setRunStatus(runStatusBuilder.toString());
405
+            templateOne.setNextExecuteTime(nextExecuteTime);
406
+            kJobMonitorDao.updateTemplateById(templateOne);
407
+        } else {
408
+            KJobMonitor kJobMonitor = new KJobMonitor();
409
+            kJobMonitor.setMonitorJob(jobId);
410
+            kJobMonitor.setAddUser(userId);
411
+            kJobMonitor.setMonitorSuccess(0);
412
+            kJobMonitor.setMonitorFail(0);
413
+            StringBuilder runStatusBuilder = new StringBuilder();
414
+            runStatusBuilder.append(new Date().getTime()).append(Constant.RUNSTATUS_SEPARATE);
415
+            kJobMonitor.setRunStatus(runStatusBuilder.toString());
416
+            kJobMonitor.setMonitorStatus(1);
417
+            kJobMonitor.setNextExecuteTime(nextExecuteTime);
418
+            kJobMonitorDao.insert(kJobMonitor);
419
+        }
420
+    }
421
+
422
+    /**
423
+     * @param userId 用户ID
424
+     * @param jobId  转换ID
425
+     * @return void
426
+     * @Title removeMonitor
427
+     * @Description 移除监控
428
+     */
429
+    private void removeMonitor(Integer userId, Integer jobId) {
430
+        KJobMonitor template = new KJobMonitor();
431
+        template.setAddUser(userId);
432
+        template.setMonitorJob(jobId);
433
+        KJobMonitor templateOne = kJobMonitorDao.templateOne(template);
434
+        templateOne.setMonitorStatus(2);
435
+        StringBuilder runStatusBuilder = new StringBuilder();
436
+        runStatusBuilder.append(templateOne.getRunStatus())
437
+                .append(new Date().getTime());
438
+        templateOne.setRunStatus(runStatusBuilder.toString());
439
+        kJobMonitorDao.updateTemplateById(templateOne);
440
+    }
441
+
442
+    public void startAll(Integer categoryId, String jobName, Integer uId) {
443
+        KJob template = new KJob();
444
+        template.setAddUser(uId);
445
+        template.setDelFlag(1);
446
+        template.setJobStatus(2);
447
+        if (categoryId != null) {
448
+            template.setCategoryId(categoryId);
449
+        }
450
+        if (StringUtils.isNotEmpty(jobName)) {
451
+            template.setJobName(jobName);
452
+        }
453
+        List<KJob> jobList = kJobDao.queryByCondition(template);
454
+        for (KJob kJob : jobList) {
455
+            start(kJob.getJobId());
456
+        }
457
+    }
458
+
459
+    public void stopAll(Integer categoryId, String jobName, Integer uId) {
460
+        KJob template = new KJob();
461
+        template.setAddUser(uId);
462
+        template.setDelFlag(1);
463
+        template.setJobStatus(1);//将正在运行的停止
464
+        if (categoryId != null) {
465
+            template.setCategoryId(categoryId);
466
+        }
467
+        if (StringUtils.isNotEmpty(jobName)) {
468
+            template.setJobName(jobName);
469
+        }
470
+        List<KJob> jobList = kJobDao.queryByCondition(template);
471
+        for (KJob kJob : jobList) {
472
+            stop(kJob.getJobId());
473
+        }
474
+    }
475
+
476
+    public Long getStartTaskCount(Integer categoryId, String jobName,Integer uId) {
477
+        KJob template = new KJob();
478
+        template.setAddUser(uId);
479
+        template.setDelFlag(1);
480
+        template.setJobStatus(1);
481
+        if (categoryId != null) {
482
+            template.setCategoryId(categoryId);
483
+        }
484
+        if (StringUtils.isNotEmpty(jobName)) {
485
+            template.setJobName(jobName);
486
+        }
487
+        Long startTaskCount = kJobDao.allCount(template);
488
+        return startTaskCount;
489
+    }
490
+
491
+    public Long getStopTaskCount(Integer categoryId, String jobName,Integer uId) {
492
+        KJob template = new KJob();
493
+        template.setAddUser(uId);
494
+        template.setDelFlag(1);
495
+        template.setJobStatus(2);
496
+        if (categoryId != null) {
497
+            template.setCategoryId(categoryId);
498
+        }
499
+        if (StringUtils.isNotEmpty(jobName)) {
500
+            template.setJobName(jobName);
501
+        }
502
+        Long stopTaskCount = kJobDao.allCount(template);
503
+        return stopTaskCount;
504
+    }
505
+    public String getJobRunState(Integer jobId){
506
+        // 获取到作业对象
507
+        KJob kJob = kJobDao.unique(jobId);
508
+        // 获取调度任务的基础信息
509
+        Map<String, String> quartzBasic = getQuartzBasic(kJob);
510
+
511
+        return QuartzManager.getTriggerState(quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"));
512
+    }
513
+}

+ 110 - 0
src/main/java/com/zhaxd/web/service/QuartzService.java

@@ -0,0 +1,110 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Date;
5
+import java.util.List;
6
+
7
+import org.pentaho.di.core.exception.KettleException;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Service;
10
+
11
+import com.zhaxd.core.dto.BootTablePage;
12
+import com.zhaxd.core.mapper.KQuartzDao;
13
+import com.zhaxd.core.model.KQuartz;
14
+
15
+@Service
16
+public class QuartzService {
17
+
18
+	
19
+	@Autowired
20
+	private KQuartzDao kQuartzDao; 
21
+	
22
+	/**
23
+	 * @Title getList
24
+	 * @Description 获取定时策略列表
25
+	 * @return 
26
+	 * @throws KettleException
27
+	 * @return List<KQuartz>
28
+	 */
29
+	public List<KQuartz> getList(Integer uId){
30
+		List<KQuartz> resultList = new ArrayList<KQuartz>();
31
+		KQuartz kQuartz = new KQuartz();
32
+		kQuartz.setDelFlag(1);
33
+		kQuartz.setAddUser(uId);
34
+		resultList.addAll(kQuartzDao.template(kQuartz));		
35
+		return resultList;
36
+	}
37
+	
38
+	/**
39
+	 * @Title getList
40
+	 * @Description 获取分页列表
41
+	 * @param start 起始行数
42
+	 * @param size 每页行数
43
+	 * @param uId 用户ID
44
+	 * @return
45
+	 * @throws KettleException
46
+	 * @return BootTablePage
47
+	 */
48
+	public BootTablePage getList(Integer start, Integer size, Integer uId){
49
+		KQuartz kQuartz = new KQuartz();
50
+		kQuartz.setDelFlag(1);
51
+		kQuartz.setAddUser(uId);
52
+		List<KQuartz> kQuartzList = kQuartzDao.template(kQuartz, start, size);
53
+		long allCount = kQuartzDao.templateCount(kQuartz);
54
+		BootTablePage bootTablePage = new BootTablePage();
55
+		bootTablePage.setRows(kQuartzList);
56
+		bootTablePage.setTotal(allCount);
57
+		return bootTablePage;
58
+	}
59
+	/**
60
+	 * @Title getQuartz
61
+	 * @Description 获取定时策略列表
62
+	 * @param quartzId 定时策略ID
63
+	 * @return
64
+	 * @return KQuartz
65
+	 */
66
+	public KQuartz getQuartz(Integer quartzId){
67
+		return kQuartzDao.single(quartzId);
68
+	}
69
+
70
+	/**
71
+	 * @Title insert
72
+	 * @Description 插入定时策略
73
+	 * @param kQuartz 定时策略对象
74
+	 * @param uId 用户ID
75
+	 * @return void
76
+	 */
77
+	public void insert(KQuartz kQuartz, Integer uId){
78
+		kQuartz.setAddTime(new Date());
79
+		kQuartz.setAddUser(uId);
80
+		kQuartz.setEditTime(new Date());
81
+		kQuartz.setEditUser(uId);
82
+		kQuartz.setDelFlag(1);
83
+		kQuartzDao.insert(kQuartz);
84
+	}
85
+	/**
86
+	 * @Title delete
87
+	 * @Description 删除定时策略
88
+	 * @param quartzId 定时策略ID
89
+	 * @return void
90
+	 */
91
+	public void delete(Integer quartzId){
92
+		KQuartz kQuartz = kQuartzDao.unique(quartzId);
93
+		kQuartz.setDelFlag(0);
94
+		kQuartzDao.updateById(kQuartz);
95
+	}
96
+
97
+	/**
98
+	 * @Title update
99
+	 * @Description 更新定时策略
100
+	 * @param kQuartz 定时策略对象
101
+	 * @param uId 用户ID
102
+	 * @return void
103
+	 */
104
+	public void update(KQuartz kQuartz, Integer uId){
105
+		kQuartz.setEditTime(new Date());
106
+		kQuartz.setEditUser(uId);
107
+		//只有不为null的字段才参与更新
108
+		kQuartzDao.updateTemplateById(kQuartz);
109
+	}
110
+}

+ 158 - 0
src/main/java/com/zhaxd/web/service/TransMonitorService.java

@@ -0,0 +1,158 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Collections;
5
+import java.util.HashMap;
6
+import java.util.List;
7
+import java.util.Map;
8
+
9
+import org.apache.commons.lang.StringUtils;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Service;
12
+
13
+import com.zhaxd.common.toolkit.Constant;
14
+import com.zhaxd.core.dto.BootTablePage;
15
+import com.zhaxd.core.mapper.KTransMonitorDao;
16
+import com.zhaxd.core.model.KTransMonitor;
17
+import com.zhaxd.web.utils.CommonUtils;
18
+
19
+@Service
20
+public class TransMonitorService {
21
+
22
+    @Autowired
23
+    private KTransMonitorDao kTransMonitorDao;
24
+
25
+    /**
26
+     * @param start 起始行数
27
+     * @param size  每页数据条数
28
+     * @param uId   用户ID
29
+     * @return BootTablePage
30
+     * @Title getList
31
+     * @Description 获取分页列表
32
+     */
33
+    public BootTablePage getList(Integer start, Integer size, Integer monitorStatus, Integer categoryId, String transName, Integer uId) {
34
+        KTransMonitor template = new KTransMonitor();
35
+        template.setAddUser(uId);
36
+        template.setMonitorStatus(monitorStatus);
37
+        if (StringUtils.isNotEmpty(transName)) {
38
+            template.setTransName(transName);
39
+        }
40
+        List<KTransMonitor> kTransMonitorList = kTransMonitorDao.pageQuery(template, start, size, categoryId);
41
+        Long allCount = kTransMonitorDao.allCount(template, categoryId);
42
+        BootTablePage bootTablePage = new BootTablePage();
43
+        bootTablePage.setRows(kTransMonitorList);
44
+        bootTablePage.setTotal(allCount);
45
+        return bootTablePage;
46
+    }
47
+
48
+    /**
49
+     * @param start 起始行数
50
+     * @param size  每页数据条数
51
+     * @param uId   用户ID
52
+     * @return BootTablePage
53
+     * @Title getList
54
+     * @Description 获取不分页列表
55
+     */
56
+    public BootTablePage getList(Integer uId) {
57
+        KTransMonitor template = new KTransMonitor();
58
+        template.setAddUser(uId);
59
+        template.setMonitorStatus(1);
60
+        List<KTransMonitor> kTransMonitorList = kTransMonitorDao.template(template);
61
+        Collections.sort(kTransMonitorList);
62
+        List<KTransMonitor> newKTransMonitorList = new ArrayList<KTransMonitor>();
63
+        if (kTransMonitorList.size() >= 5) {
64
+            newKTransMonitorList = kTransMonitorList.subList(0, 5);
65
+        } else {
66
+            newKTransMonitorList = kTransMonitorList;
67
+        }
68
+        BootTablePage bootTablePage = new BootTablePage();
69
+        bootTablePage.setRows(newKTransMonitorList);
70
+        bootTablePage.setTotal(5);
71
+        return bootTablePage;
72
+    }
73
+
74
+    /**
75
+     * @param uId 用户ID
76
+     * @return Integer
77
+     * @Title getAllMonitorTrans
78
+     * @Description 获取全部被监控的转换
79
+     */
80
+    public Integer getAllMonitorTrans(Integer uId) {
81
+        KTransMonitor template = new KTransMonitor();
82
+        template.setAddUser(uId);
83
+        template.setMonitorStatus(1);
84
+        List<KTransMonitor> kTransMonitorList = kTransMonitorDao.template(template);
85
+        return kTransMonitorList.size();
86
+    }
87
+
88
+    /**
89
+     * @param uId 用户ID
90
+     * @return Integer
91
+     * @Title getAllSuccess
92
+     * @Description 获取所有转换执行成功的次数的和
93
+     */
94
+    public Integer getAllSuccess(Integer uId) {
95
+        KTransMonitor template = new KTransMonitor();
96
+        template.setAddUser(uId);
97
+        template.setMonitorStatus(1);
98
+        List<KTransMonitor> kTransMonitorList = kTransMonitorDao.template(template);
99
+        Integer allSuccess = 0;
100
+        for (KTransMonitor KTransMonitor : kTransMonitorList) {
101
+            allSuccess += KTransMonitor.getMonitorSuccess();
102
+        }
103
+        return allSuccess;
104
+    }
105
+
106
+    /**
107
+     * @param uId 用户ID
108
+     * @return Integer
109
+     * @Title getAllFail
110
+     * @Description 获取所有转换执行失败的次数的和
111
+     */
112
+    public Integer getAllFail(Integer uId) {
113
+        KTransMonitor template = new KTransMonitor();
114
+        template.setAddUser(uId);
115
+        template.setMonitorStatus(1);
116
+        List<KTransMonitor> kTransMonitorList = kTransMonitorDao.template(template);
117
+        Integer allSuccess = 0;
118
+        for (KTransMonitor KTransMonitor : kTransMonitorList) {
119
+            allSuccess += KTransMonitor.getMonitorFail();
120
+        }
121
+        return allSuccess;
122
+    }
123
+
124
+    /**
125
+     * @param uId 用户ID
126
+     * @return Map<String   ,   Object>
127
+     * @Title getTransLine
128
+     * @Description 获取7天内转换的折线图
129
+     */
130
+    public Map<String, Object> getTransLine(Integer uId) {
131
+        KTransMonitor template = new KTransMonitor();
132
+        template.setAddUser(uId);
133
+        List<KTransMonitor> kTransMonitorList = kTransMonitorDao.template(template);
134
+        HashMap<String, Object> resultMap = new HashMap<String, Object>();
135
+        List<Integer> resultList = new ArrayList<Integer>();
136
+        for (int i = 0; i < 7; i++) {
137
+            resultList.add(i, 0);
138
+        }
139
+        if (kTransMonitorList != null && !kTransMonitorList.isEmpty()) {
140
+            for (KTransMonitor KTransMonitor : kTransMonitorList) {
141
+                String runStatus = KTransMonitor.getRunStatus();
142
+                if (runStatus != null && runStatus.contains(",")) {
143
+                    String[] startList = runStatus.split(",");
144
+                    for (String startOnce : startList) {
145
+                        String[] startAndStopTime = startOnce.split(Constant.RUNSTATUS_SEPARATE);
146
+                        if (startAndStopTime.length != 2)
147
+                            continue;
148
+                        //得到一次任务的起始时间和结束时间的毫秒值
149
+                        resultList = CommonUtils.getEveryDayData(Long.parseLong(startAndStopTime[0]), Long.parseLong(startAndStopTime[1]), resultList);
150
+                    }
151
+                }
152
+            }
153
+        }
154
+        resultMap.put("name", "转换");
155
+        resultMap.put("data", resultList);
156
+        return resultMap;
157
+    }
158
+}

+ 60 - 0
src/main/java/com/zhaxd/web/service/TransRecordService.java

@@ -0,0 +1,60 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.io.File;
4
+import java.io.IOException;
5
+import java.util.List;
6
+
7
+import org.apache.commons.io.FileUtils;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Service;
10
+
11
+import com.zhaxd.common.toolkit.Constant;
12
+import com.zhaxd.core.dto.BootTablePage;
13
+import com.zhaxd.core.mapper.KTransRecordDao;
14
+import com.zhaxd.core.model.KTransRecord;
15
+
16
+@Service
17
+public class TransRecordService {
18
+
19
+	@Autowired
20
+	private KTransRecordDao kTransRecordDao;
21
+	
22
+	/**
23
+	 * @Title getList
24
+	 * @Description 获取列表
25
+	 * @param start 其实行数
26
+	 * @param size 结束行数
27
+	 * @param uId 用户ID
28
+	 * @param transId 转换ID
29
+	 * @return
30
+	 * @return BootTablePage
31
+	 */
32
+	public BootTablePage getList(Integer start, Integer size, Integer uId, Integer transId){
33
+		KTransRecord template = new KTransRecord();
34
+		template.setAddUser(uId);
35
+		if (transId != null){
36
+			template.setRecordTrans(transId);
37
+		}
38
+		List<KTransRecord> kTransRecordList = kTransRecordDao.template(template, start, size);
39
+		long totalCount = kTransRecordDao.templateCount(template);
40
+		BootTablePage bootTablePage = new BootTablePage();
41
+		bootTablePage.setRows(kTransRecordList);
42
+		bootTablePage.setTotal(totalCount);
43
+		return bootTablePage;
44
+	}
45
+	
46
+	/**
47
+	 * @Title getLogContent
48
+	 * @Description 转换日志内容
49
+	 * @param recordId 转换记录ID
50
+	 * @return
51
+	 * @throws IOException
52
+	 * @return String
53
+	 */
54
+	public String getLogContent(Integer recordId) throws IOException{
55
+		KTransRecord kTransRecord = kTransRecordDao.unique(recordId);
56
+		String logFilePath = kTransRecord.getLogFilePath();
57
+		return FileUtils.readFileToString(new File(logFilePath), Constant.DEFAULT_ENCODING);
58
+	}
59
+	
60
+}

+ 510 - 0
src/main/java/com/zhaxd/web/service/TransService.java

@@ -0,0 +1,510 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.io.IOException;
4
+import java.sql.SQLException;
5
+import java.util.Date;
6
+import java.util.HashMap;
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+import org.apache.commons.lang.StringUtils;
11
+import org.beetl.sql.core.DSTransactionManager;
12
+import org.beetl.sql.core.db.KeyHolder;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.beans.factory.annotation.Value;
15
+import org.springframework.stereotype.Service;
16
+import org.springframework.web.multipart.MultipartFile;
17
+
18
+import com.zhaxd.common.toolkit.Constant;
19
+import com.zhaxd.core.dto.BootTablePage;
20
+import com.zhaxd.core.mapper.KQuartzDao;
21
+import com.zhaxd.core.mapper.KRepositoryDao;
22
+import com.zhaxd.core.mapper.KTransDao;
23
+import com.zhaxd.core.mapper.KTransMonitorDao;
24
+import com.zhaxd.core.model.KQuartz;
25
+import com.zhaxd.core.model.KRepository;
26
+import com.zhaxd.core.model.KTrans;
27
+import com.zhaxd.core.model.KTransMonitor;
28
+import com.zhaxd.web.quartz.QuartzManager;
29
+import com.zhaxd.web.quartz.TransQuartz;
30
+import com.zhaxd.web.quartz.model.DBConnectionModel;
31
+import com.zhaxd.web.utils.CommonUtils;
32
+
33
+@Service
34
+public class TransService {
35
+
36
+    @Autowired
37
+    private KTransDao kTransDao;
38
+
39
+    @Autowired
40
+    private KQuartzDao kQuartzDao;
41
+
42
+    @Autowired
43
+    private KRepositoryDao KRepositoryDao;
44
+
45
+    @Autowired
46
+    private KTransMonitorDao kTransMonitorDao;
47
+
48
+    @Value("${kettle.log.file.path}")
49
+    private String kettleLogFilePath;
50
+
51
+    @Value("${kettle.file.repository}")
52
+    private String kettleFileRepository;
53
+
54
+    @Value("${jdbc.driver}")
55
+    private String jdbcDriver;
56
+
57
+    @Value("${jdbc.url}")
58
+    private String jdbcUrl;
59
+
60
+    @Value("${jdbc.username}")
61
+    private String jdbcUsername;
62
+
63
+    @Value("${jdbc.password}")
64
+    private String jdbcPassword;
65
+
66
+    /**
67
+     * @param uId 用户ID
68
+     * @return List<KTrans>
69
+     * @Title getList
70
+     * @Description 获取列表
71
+     */
72
+    public List<KTrans> getList(Integer uId) {
73
+        KTrans template = new KTrans();
74
+        template.setAddUser(uId);
75
+        template.setDelFlag(1);
76
+        return kTransDao.template(template);
77
+    }
78
+
79
+    /**
80
+     * @param start 其实行数
81
+     * @param size  获取数据的条数
82
+     * @param uId   用户ID
83
+     * @return BootTablePage
84
+     * @Title getList
85
+     * @Description 获取列表
86
+     */
87
+    public BootTablePage getList(Integer start, Integer size, Integer CategoryId, String transName, Integer uId) {
88
+        KTrans template = new KTrans();
89
+        template.setAddUser(uId);
90
+        template.setDelFlag(1);
91
+        if (CategoryId != null) {
92
+            template.setCategoryId(CategoryId);
93
+        }
94
+        if (StringUtils.isNotEmpty(transName)) {
95
+            template.setTransName(transName);
96
+        }
97
+//		List<KTrans> kTransList = kTransDao.template(template, start, size);
98
+//		Long allCount = kTransDao.templateCount(template);
99
+        List<KTrans> kTransList = kTransDao.pageQuery(template, start, size);
100
+        Long allCount = kTransDao.allCount(template);
101
+        BootTablePage bootTablePage = new BootTablePage();
102
+        bootTablePage.setRows(kTransList);
103
+        bootTablePage.setTotal(allCount);
104
+        return bootTablePage;
105
+    }
106
+
107
+    /**
108
+     * @param kTransId 转换ID
109
+     * @return void
110
+     * @Title delete
111
+     * @Description 删除转换
112
+     */
113
+    public void delete(Integer kTransId) {
114
+        KTrans kTrans = kTransDao.unique(kTransId);
115
+        kTrans.setDelFlag(0);
116
+        kTransDao.updateById(kTrans);
117
+    }
118
+
119
+    /**
120
+     * @param repositoryId 资源库ID
121
+     * @param kTransPath   转换路径信息
122
+     * @param uId          用户ID
123
+     * @return boolean
124
+     * @Title check
125
+     * @Description 检查转换是否添加过
126
+     */
127
+    public boolean check(Integer repositoryId, String kTransPath, Integer uId) {
128
+        KTrans template = new KTrans();
129
+        template.setDelFlag(1);
130
+        template.setAddUser(uId);
131
+        template.setTransRepositoryId(repositoryId);
132
+        template.setTransPath(kTransPath);
133
+        List<KTrans> kTransList = kTransDao.template(template);
134
+        if (null != kTransList && kTransList.size() > 0) {
135
+            return false;
136
+        } else {
137
+            return true;
138
+        }
139
+    }
140
+
141
+    /**
142
+     * @param uId       用户ID
143
+     * @param transFile 需要保存的转换文件
144
+     * @return String
145
+     * @throws IOException
146
+     * @Title saveFile
147
+     * @Description 保存上传的转换文件
148
+     */
149
+    public String saveFile(Integer uId, MultipartFile transFile) throws IOException {
150
+        return CommonUtils.saveFile(uId, kettleFileRepository, transFile);
151
+    }
152
+
153
+    /**
154
+     * @param kTrans        转换对象
155
+     * @param uId           用户ID
156
+     * @param customerQuarz 用户自定义的定时策略
157
+     * @return void
158
+     * @throws SQLException
159
+     * @Title insert
160
+     * @Description 添加转换到数据库
161
+     */
162
+    public void insert(KTrans kTrans, Integer uId, String customerQuarz) throws SQLException {
163
+        DSTransactionManager.start();
164
+        //补充添加作业信息
165
+        //作业基础信息
166
+        kTrans.setAddUser(uId);
167
+        kTrans.setAddTime(new Date());
168
+        kTrans.setEditUser(uId);
169
+        kTrans.setEditTime(new Date());
170
+        //作业是否被删除
171
+        kTrans.setDelFlag(1);
172
+        //作业是否启动
173
+        kTrans.setTransStatus(2);
174
+        if (StringUtils.isNotBlank(customerQuarz)) {
175
+            //添加任务执行的调度策略
176
+            KQuartz kQuartz = new KQuartz();
177
+            kQuartz.setAddUser(uId);
178
+            kQuartz.setAddTime(new Date());
179
+            kQuartz.setEditUser(uId);
180
+            kQuartz.setEditTime(new Date());
181
+            kQuartz.setDelFlag(1);
182
+            kQuartz.setQuartzCron(customerQuarz);
183
+            kQuartz.setQuartzDescription(kTrans.getTransName() + "的定时策略");
184
+            KeyHolder kQuartzKey = kQuartzDao.insertReturnKey(kQuartz);
185
+            //插入调度策略
186
+            kTrans.setTransQuartz(kQuartzKey.getInt());
187
+        } else if (StringUtils.isBlank(customerQuarz) && new Integer(0).equals(kTrans.getTransQuartz())) {
188
+            kTrans.setTransQuartz(1);
189
+        } else if (StringUtils.isBlank(customerQuarz) && kTrans.getTransQuartz() == null) {
190
+            kTrans.setTransQuartz(1);
191
+        }
192
+        kTransDao.insert(kTrans);
193
+        DSTransactionManager.commit();
194
+    }
195
+
196
+    /**
197
+     * @param transId 转换ID
198
+     * @return KTrans
199
+     * @Title getTrans
200
+     * @Description 获取转换对象
201
+     */
202
+    public KTrans getTrans(Integer transId) {
203
+        return kTransDao.single(transId);
204
+    }
205
+
206
+    /**
207
+     * @param kTrans        转换对象
208
+     * @param customerQuarz 用户自定义的定时策略
209
+     * @param uId           用户ID
210
+     * @return void
211
+     * @Title update
212
+     * @Description 更新转换信息
213
+     */
214
+    public void update(KTrans kTrans, String customerQuarz, Integer uId) {
215
+        if (StringUtils.isNotBlank(customerQuarz)) {
216
+            Integer transQuartzId = kTrans.getTransQuartz();
217
+            KQuartz kQuartz = kQuartzDao.single(transQuartzId);
218
+            if (kQuartz.getAddUser() == uId) {// 如果更新前选择的是自定义的,这一步要更新
219
+                kQuartz.setQuartzCron(customerQuarz);
220
+                kQuartzDao.updateTemplateById(kQuartz);
221
+            } else {// 如果更新前选择的是默认的定时策略,这一步要新增一个定时策略
222
+                KQuartz kQuartzTemeplate = new KQuartz();
223
+                kQuartzTemeplate.setAddUser(uId);
224
+                kQuartzTemeplate.setAddTime(new Date());
225
+                kQuartzTemeplate.setEditUser(uId);
226
+                kQuartzTemeplate.setEditTime(new Date());
227
+                kQuartzTemeplate.setDelFlag(1);
228
+                kQuartzTemeplate.setQuartzCron(customerQuarz);
229
+                kQuartzTemeplate.setQuartzDescription(kTrans.getTransName() + "的定时策略");
230
+                KeyHolder kQuartzKey = kQuartzDao.insertReturnKey(kQuartzTemeplate);
231
+                //插入调度策略
232
+                kTrans.setTransQuartz(kQuartzKey.getInt());
233
+            }
234
+        }
235
+        kTransDao.updateTemplateById(kTrans);
236
+    }
237
+
238
+    /**
239
+     * @param transId 转换ID
240
+     * @return void
241
+     * @Title start
242
+     * @Description 启动转换
243
+     */
244
+    public void start(Integer transId) {
245
+        // 获取到转换对象
246
+        KTrans kTrans = kTransDao.unique(transId);
247
+        // 获取到定时策略对象
248
+        KQuartz kQuartz = kQuartzDao.unique(kTrans.getTransQuartz());
249
+        // 定时策略
250
+        String quartzCron = kQuartz.getQuartzCron();
251
+        // 用户ID
252
+        Integer userId = kTrans.getAddUser();
253
+        // 获取Quartz执行的基础信息
254
+        Map<String, String> quartzBasic = getQuartzBasic(kTrans);
255
+        // 获取Quartz的参数
256
+        Map<String, Object> quartzParameter = getQuartzParameter(kTrans);
257
+        Date nextExecuteTime = null;
258
+        // 添加任务
259
+        // 判断转换执行类型
260
+        try {
261
+            if (new Integer(1).equals(kTrans.getTransQuartz())) {//如果是只执行一次
262
+                nextExecuteTime = QuartzManager.addOnceJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
263
+                        quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"),
264
+                        TransQuartz.class, quartzParameter);
265
+            } else {// 如果是按照策略执行
266
+                //添加任务
267
+                nextExecuteTime = QuartzManager.addJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
268
+                        quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"),
269
+                        TransQuartz.class, quartzCron, quartzParameter);
270
+            }
271
+        } catch (Exception e) {
272
+            kTrans.setTransStatus(2);
273
+            kTransDao.updateTemplateById(kTrans);
274
+            return;
275
+        }
276
+        // 添加监控
277
+        addMonitor(userId, transId, nextExecuteTime);
278
+        kTrans.setTransStatus(1);
279
+        kTransDao.updateTemplateById(kTrans);
280
+    }
281
+
282
+    /**
283
+     * @param transId 转换ID
284
+     * @return void
285
+     * @Title stop
286
+     * @Description 停止转换
287
+     */
288
+    public void stop(Integer transId) {
289
+        // 获取到作业对象
290
+        KTrans kTrans = kTransDao.unique(transId);
291
+        // 用户ID
292
+        Integer userId = kTrans.getAddUser();
293
+        // 获取Quartz执行的基础信息
294
+        Map<String, String> quartzBasic = getQuartzBasic(kTrans);
295
+        // 移除任务
296
+        if (new Integer(1).equals(kTrans.getTransQuartz())) {//如果是只执行一次
297
+            // 一次性执行任务,不允许手动停止
298
+            QuartzManager.removeJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
299
+                    quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"));
300
+        } else {// 如果是按照策略执行
301
+            QuartzManager.removeJob(quartzBasic.get("jobName"), quartzBasic.get("jobGroupName"),
302
+                    quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"));
303
+        }
304
+        // 移除监控
305
+        removeMonitor(userId, transId);
306
+        // 更新任务状态
307
+        kTrans.setTransStatus(2);
308
+        kTransDao.updateTemplateById(kTrans);
309
+    }
310
+
311
+    /**
312
+     * @param kTrans 转换对象
313
+     * @return Map<String               ,                               String> 任务调度的基础信息
314
+     * @Title getQuartzBasic
315
+     * @Description 获取任务调度的基础信息
316
+     */
317
+    private Map<String, String> getQuartzBasic(KTrans kTrans) {
318
+        Integer userId = kTrans.getAddUser();
319
+        Integer transRepositoryId = kTrans.getTransRepositoryId();
320
+        String transPath = kTrans.getTransPath();
321
+        Map<String, String> quartzBasic = new HashMap<String, String>();
322
+        // 拼接Quartz的任务名称
323
+        StringBuilder jobName = new StringBuilder();
324
+        jobName.append(Constant.JOB_PREFIX).append(Constant.QUARTZ_SEPARATE)
325
+                .append(transRepositoryId).append(Constant.QUARTZ_SEPARATE)
326
+                .append(transPath);
327
+        // 拼接Quartz的任务组名称
328
+        StringBuilder jobGroupName = new StringBuilder();
329
+        jobGroupName.append(Constant.JOB_GROUP_PREFIX).append(Constant.QUARTZ_SEPARATE)
330
+                .append(userId).append(Constant.QUARTZ_SEPARATE)
331
+                .append(transRepositoryId).append(Constant.QUARTZ_SEPARATE)
332
+                .append(transPath);
333
+        // 拼接Quartz的触发器名称
334
+        String triggerName = StringUtils.replace(jobName.toString(), Constant.JOB_PREFIX, Constant.TRIGGER_PREFIX);
335
+        // 拼接Quartz的触发器组名称
336
+        String triggerGroupName = StringUtils.replace(jobGroupName.toString(), Constant.JOB_GROUP_PREFIX, Constant.TRIGGER_GROUP_PREFIX);
337
+        quartzBasic.put("jobName", jobName.toString());
338
+        quartzBasic.put("jobGroupName", jobGroupName.toString());
339
+        quartzBasic.put("triggerName", triggerName);
340
+        quartzBasic.put("triggerGroupName", triggerGroupName);
341
+        return quartzBasic;
342
+    }
343
+
344
+    /**
345
+     * @param kTrans 转换对象
346
+     * @return Map<String               ,                               Object>
347
+     * @Title getQuartzParameter
348
+     * @Description 获取任务调度的参数
349
+     */
350
+    private Map<String, Object> getQuartzParameter(KTrans kTrans) {
351
+        // Quartz执行时的参数
352
+        Map<String, Object> parameter = new HashMap<String, Object>();
353
+        // 资源库对象
354
+        Integer transRepositoryId = kTrans.getTransRepositoryId();
355
+        KRepository kRepository = null;
356
+        if (transRepositoryId != null) {// 这里是判断是否为资源库中的转换还是文件类型的转换的关键点
357
+            kRepository = KRepositoryDao.single(transRepositoryId);
358
+        }
359
+        // 资源库对象
360
+        parameter.put(Constant.REPOSITORYOBJECT, kRepository);
361
+        // 数据库连接对象
362
+        parameter.put(Constant.DBCONNECTIONOBJECT, new DBConnectionModel(jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword));
363
+        // 转换ID
364
+        parameter.put(Constant.TRANSID, kTrans.getTransId());
365
+        parameter.put(Constant.JOBTYPE, 2);
366
+        String transPath = kTrans.getTransPath();
367
+        if (transPath.contains("/")) {
368
+            int lastIndexOf = StringUtils.lastIndexOf(transPath, "/");
369
+            String path = transPath.substring(0, lastIndexOf);
370
+            // 转换在资源库中的路径
371
+            parameter.put(Constant.TRANSPATH, StringUtils.isEmpty(path) ? "/" : path);
372
+            // 转换名称
373
+            parameter.put(Constant.TRANSNAME, transPath.substring(lastIndexOf + 1, transPath.length()));
374
+        }
375
+        // 用户ID
376
+        parameter.put(Constant.USERID, kTrans.getAddUser());
377
+        // 转换日志等级
378
+        parameter.put(Constant.LOGLEVEL, kTrans.getTransLogLevel());
379
+        // 转换日志的保存位置
380
+        parameter.put(Constant.LOGFILEPATH, kettleLogFilePath);
381
+        return parameter;
382
+    }
383
+
384
+    /**
385
+     * @param userId  用户ID
386
+     * @param transId 转换ID
387
+     * @return void
388
+     * @Title addMonitor
389
+     * @Description 添加监控
390
+     */
391
+    private void addMonitor(Integer userId, Integer transId, Date nextExecuteTime) {
392
+        KTransMonitor template = new KTransMonitor();
393
+        template.setAddUser(userId);
394
+        template.setMonitorTrans(transId);
395
+        KTransMonitor templateOne = kTransMonitorDao.templateOne(template);
396
+        if (null != templateOne) {
397
+            templateOne.setMonitorStatus(1);
398
+            StringBuilder runStatusBuilder = new StringBuilder();
399
+            runStatusBuilder.append(templateOne.getRunStatus())
400
+                    .append(",").append(new Date().getTime()).append(Constant.RUNSTATUS_SEPARATE);
401
+            templateOne.setRunStatus(runStatusBuilder.toString());
402
+            templateOne.setNextExecuteTime(nextExecuteTime);
403
+            kTransMonitorDao.updateTemplateById(templateOne);
404
+        } else {
405
+            KTransMonitor kTransMonitor = new KTransMonitor();
406
+            kTransMonitor.setMonitorTrans(transId);
407
+            kTransMonitor.setAddUser(userId);
408
+            kTransMonitor.setMonitorSuccess(0);
409
+            kTransMonitor.setMonitorFail(0);
410
+            StringBuilder runStatusBuilder = new StringBuilder();
411
+            runStatusBuilder.append(new Date().getTime()).append(Constant.RUNSTATUS_SEPARATE);
412
+            kTransMonitor.setRunStatus(runStatusBuilder.toString());
413
+            kTransMonitor.setMonitorStatus(1);
414
+            kTransMonitor.setNextExecuteTime(nextExecuteTime);
415
+            kTransMonitorDao.insert(kTransMonitor);
416
+        }
417
+    }
418
+
419
+    /**
420
+     * @param userId  用户ID
421
+     * @param transId 转换ID
422
+     * @return void
423
+     * @Title removeMonitor
424
+     * @Description 移除监控
425
+     */
426
+    private void removeMonitor(Integer userId, Integer transId) {
427
+        KTransMonitor template = new KTransMonitor();
428
+        template.setAddUser(userId);
429
+        template.setMonitorTrans(transId);
430
+        KTransMonitor templateOne = kTransMonitorDao.templateOne(template);
431
+        templateOne.setMonitorStatus(2);
432
+        StringBuilder runStatusBuilder = new StringBuilder();
433
+        runStatusBuilder.append(templateOne.getRunStatus())
434
+                .append(new Date().getTime());
435
+        templateOne.setRunStatus(runStatusBuilder.toString());
436
+        kTransMonitorDao.updateTemplateById(templateOne);
437
+    }
438
+
439
+    public void startAll(Integer CategoryId, String transName, Integer uId) {
440
+        KTrans template = new KTrans();
441
+        template.setAddUser(uId);
442
+        template.setDelFlag(1);
443
+        template.setTransStatus(2);
444
+        if (CategoryId != null) {
445
+            template.setCategoryId(CategoryId);
446
+        }
447
+        if (StringUtils.isNotEmpty(transName)) {
448
+            template.setTransName(transName);
449
+        }
450
+        List<KTrans> jobList = kTransDao.queryByCondition(template);
451
+        for (KTrans KTrans : jobList) {
452
+            start(KTrans.getTransId());
453
+        }
454
+    }
455
+
456
+    public void stopAll(Integer CategoryId, String transName, Integer uId) {
457
+        KTrans template = new KTrans();
458
+        template.setAddUser(uId);
459
+        template.setDelFlag(1);
460
+        template.setTransStatus(1);//将正在运行的停止
461
+        if (CategoryId != null) {
462
+            template.setCategoryId(CategoryId);
463
+        }
464
+        if (StringUtils.isNotEmpty(transName)) {
465
+            template.setTransName(transName);
466
+        }
467
+        List<KTrans> jobList = kTransDao.queryByCondition(template);
468
+        for (KTrans KTrans : jobList) {
469
+            stop(KTrans.getTransId());
470
+        }
471
+    }
472
+
473
+    public Long getStartTaskCount(Integer CategoryId, String transName, Integer uId) {
474
+        KTrans template = new KTrans();
475
+        template.setAddUser(uId);
476
+        template.setDelFlag(1);
477
+        template.setTransStatus(1);
478
+        if (CategoryId != null) {
479
+            template.setCategoryId(CategoryId);
480
+        }
481
+        if (StringUtils.isNotEmpty(transName)) {
482
+            template.setTransName(transName);
483
+        }
484
+        Long startTaskCount = kTransDao.allCount(template);
485
+        return startTaskCount;
486
+    }
487
+
488
+    public Long getStopTaskCount(Integer CategoryId, String transName, Integer uId) {
489
+        KTrans template = new KTrans();
490
+        template.setAddUser(uId);
491
+        template.setDelFlag(1);
492
+        template.setTransStatus(2);
493
+        if (CategoryId != null) {
494
+            template.setCategoryId(CategoryId);
495
+        }
496
+        if (StringUtils.isNotEmpty(transName)) {
497
+            template.setTransName(transName);
498
+        }
499
+        Long stopTaskCount = kTransDao.allCount(template);
500
+        return stopTaskCount;
501
+    }
502
+    public String getTransRunState(Integer transId){
503
+        // 获取到作业对象
504
+        KTrans kTrans = kTransDao.unique(transId);
505
+        // 获取Quartz执行的基础信息
506
+        Map<String, String> quartzBasic = getQuartzBasic(kTrans);
507
+
508
+        return QuartzManager.getTriggerState(quartzBasic.get("triggerName"), quartzBasic.get("triggerGroupName"));
509
+    }
510
+}

+ 144 - 0
src/main/java/com/zhaxd/web/service/UserService.java

@@ -0,0 +1,144 @@
1
+package com.zhaxd.web.service;
2
+
3
+import java.util.Date;
4
+import java.util.List;
5
+
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+
9
+import com.zhaxd.common.toolkit.MD5Utils;
10
+import com.zhaxd.core.dto.BootTablePage;
11
+import com.zhaxd.core.mapper.KUserDao;
12
+import com.zhaxd.core.model.KUser;
13
+
14
+@Service
15
+public class UserService {
16
+
17
+	@Autowired
18
+	private KUserDao kUserDao;
19
+		
20
+	/**
21
+	 * @Title login
22
+	 * @Description 登陆
23
+	 * @param kUser 用户信息对象
24
+	 * @return
25
+	 * @return KUser
26
+	 */
27
+	public KUser login(KUser kUser){		
28
+		KUser template = new KUser();
29
+		template.setDelFlag(1);
30
+		template.setuAccount(kUser.getuAccount());
31
+		KUser user = kUserDao.templateOne(template);
32
+		if (null != user){
33
+			if (user.getuPassword().equals(MD5Utils.Encrypt(kUser.getuPassword(), true))){
34
+				return user;
35
+			}
36
+			return null;
37
+		}
38
+		return null;
39
+	}
40
+	
41
+	/**
42
+	 * @Title isAdmin
43
+	 * @Description 用户是否为管理员
44
+	 * @param uId 用户ID
45
+	 * @return
46
+	 * @return boolean
47
+	 */
48
+	public boolean isAdmin(Integer uId){
49
+		KUser kUser = kUserDao.unique(uId);
50
+		if ("admin".equals(kUser.getuAccount())){
51
+			return true;
52
+		}else {
53
+			return false;	
54
+		}
55
+	}
56
+	
57
+	/**
58
+	 * @Title getList
59
+	 * @Description 获取用户分页列表
60
+	 * @param start 其实行数
61
+	 * @param size 每页显示行数
62
+	 * @return 
63
+	 * @return BootTablePage
64
+	 */
65
+	public BootTablePage getList(Integer start, Integer size){
66
+		KUser template = new KUser();
67
+		template.setDelFlag(1);
68
+		List<KUser> kUserList = kUserDao.template(template, start, size);
69
+		long allCount = kUserDao.templateCount(template);
70
+		BootTablePage bootTablePage = new BootTablePage();
71
+		bootTablePage.setRows(kUserList);
72
+		bootTablePage.setTotal(allCount);
73
+		return bootTablePage;
74
+	}
75
+	
76
+	/**
77
+	 * @Title delete
78
+	 * @Description 删除用户
79
+	 * @param uId 用户ID
80
+	 * @return void
81
+	 */
82
+	public void delete(Integer uId){
83
+		KUser kUser = kUserDao.unique(uId);
84
+		kUser.setDelFlag(0);
85
+		kUserDao.updateById(kUser);
86
+	}
87
+	
88
+	/**
89
+	 * @Title insert
90
+	 * @Description 插入一个用户
91
+	 * @param kUser
92
+	 * @return void
93
+	 */
94
+	public void insert(KUser kUser, Integer uId){
95
+		kUser.setuPassword(MD5Utils.Encrypt(kUser.getuPassword(), true));
96
+		kUser.setAddTime(new Date());
97
+		kUser.setAddUser(uId);
98
+		kUser.setEditTime(new Date());
99
+		kUser.setEditUser(uId);
100
+		kUser.setDelFlag(1);
101
+		kUserDao.insert(kUser);
102
+	}
103
+	/**
104
+	 * @Title IsAccountExist
105
+	 * @Description 判断账号是否存在
106
+	 * @param uAccount
107
+	 * @return void
108
+	 */
109
+	public boolean IsAccountExist(String uAccount) {
110
+		KUser template = new KUser();
111
+		template.setDelFlag(1);
112
+		template.setuAccount(uAccount);
113
+		KUser user = kUserDao.templateOne(template);
114
+		if (null == user) {
115
+			return false;
116
+		} else {
117
+			return true;
118
+		}
119
+	}
120
+
121
+	/**
122
+	 * @Title getUser
123
+	 * @Description 获取 用户
124
+	 * @param uId 用户ID
125
+	 * @return
126
+	 * @return KUser
127
+	 */
128
+	public KUser getUser(Integer uId){
129
+		return kUserDao.single(uId);
130
+	}
131
+	/**
132
+	 * @Title update
133
+	 * @Description 更新用户
134
+	 * @param kUser 用户对象
135
+	 * @param uId 用户ID
136
+	 * @return void
137
+	 */
138
+	public void update(KUser kUser, Integer uId){
139
+		kUser.setEditTime(new Date());
140
+		kUser.setEditUser(uId);
141
+		//只有不为null的字段才参与更新
142
+		kUserDao.updateTemplateById(kUser);
143
+	}
144
+}

+ 76 - 0
src/main/java/com/zhaxd/web/utils/CommonUtils.java

@@ -0,0 +1,76 @@
1
+package com.zhaxd.web.utils;
2
+
3
+import java.io.File;
4
+import java.io.IOException;
5
+import java.text.ParseException;
6
+import java.text.SimpleDateFormat;
7
+import java.util.ArrayList;
8
+import java.util.Calendar;
9
+import java.util.Date;
10
+import java.util.List;
11
+
12
+import org.apache.commons.io.FileUtils;
13
+import org.springframework.web.multipart.MultipartFile;
14
+
15
+public class CommonUtils {
16
+
17
+    /**
18
+     * @param uId     用户ID
19
+     * @param jobFile 上传的作业文件
20
+     * @return String
21
+     * @throws IOException
22
+     * @Title saveFile
23
+     * @Description 保存上传的作业文件
24
+     */
25
+    public static String saveFile(Integer uId, String kettleFileRepository, MultipartFile jobFile) throws IOException {
26
+        StringBuilder allLogFilePath = new StringBuilder();
27
+        allLogFilePath.append(kettleFileRepository).append("/")
28
+                .append(uId).append("/")
29
+                .append(new Date().getTime()).append("/")
30
+                .append(jobFile.getOriginalFilename());
31
+        FileUtils.writeByteArrayToFile(new File(allLogFilePath.toString()), jobFile.getBytes());
32
+        return allLogFilePath.toString();
33
+    }
34
+
35
+    /**
36
+     * @param startTime  起始时间
37
+     * @param stopTime   结束时间
38
+     * @param resultList 递归的返回值
39
+     * @return List<Integer>
40
+     * @Title getEveryDayData
41
+     * @Description 确定每一次运行属于哪一天
42
+     */
43
+    public static List<Integer> getEveryDayData(Long startTime, Long stopTime, List<Integer> resultList) {
44
+        List<Long> timeList = new ArrayList<Long>();
45
+        try {
46
+            for (int i = -6; i <= 1; i++) {
47
+                Calendar instance = Calendar.getInstance();
48
+                instance.add(Calendar.DATE, i);
49
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
50
+                String dateFormat = simpleDateFormat.format(instance.getTime());
51
+                Long time = simpleDateFormat.parse(dateFormat).getTime();
52
+                timeList.add(time);
53
+            }
54
+        } catch (ParseException e) {
55
+            e.printStackTrace();
56
+        }
57
+        Integer startDay = 0;
58
+        Integer stopDay = 0;
59
+        for (int i = 0; i <= 6; i++) {
60
+            if (timeList.get(i) < startTime && startTime < timeList.get(i + 1)) {
61
+                startDay = i;
62
+            }
63
+            if (timeList.get(i) < stopTime && stopTime < timeList.get(i + 1)) {
64
+                stopDay = i;
65
+            }
66
+        }
67
+        if ((stopDay - startDay) > 0) {
68
+            for (int i = startDay; i <= stopDay; i++) {
69
+                resultList.set(i, resultList.get(i) + 1);
70
+            }
71
+        } else {
72
+            resultList.set(startDay, resultList.get(startDay) + 1);
73
+        }
74
+        return resultList;
75
+    }
76
+}

+ 42 - 0
src/main/java/com/zhaxd/web/utils/DataValidate.java

@@ -0,0 +1,42 @@
1
+package com.zhaxd.web.utils;
2
+
3
+import java.lang.reflect.InvocationTargetException;
4
+import java.util.ArrayList;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import org.apache.commons.beanutils.BeanUtils;
9
+import org.apache.commons.collections.CollectionUtils;
10
+import org.springframework.util.ObjectUtils;
11
+
12
+import com.zhaxd.core.dto.web.KRepositoryDto;
13
+
14
+public class DataValidate {
15
+
16
+	/**
17
+	 * @Title AllNotEmpty
18
+	 * @Description 实体类参数校验(写这个方法的时候我的内心是崩溃的)
19
+	 * @param object 实体类
20
+	 * @return
21
+	 * @return boolean
22
+	 */
23
+	public static boolean AllNotEmpty(Object object){
24
+		List<Object> returnList = new ArrayList<>();
25
+		try {
26
+			Map<?, ?> describe = BeanUtils.describe(object);
27
+			describe.forEach((k, v) -> {
28
+				if (ObjectUtils.isEmpty(v)){
29
+					returnList.add(v);
30
+				}
31
+			});
32
+		} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
33
+			e.printStackTrace();
34
+		}
35
+		return CollectionUtils.isEmpty(returnList);
36
+	}
37
+	
38
+	public static void main(String[] args){
39
+		KRepositoryDto kRepositoryDto = new KRepositoryDto();
40
+		System.out.println(DataValidate.AllNotEmpty(kRepositoryDto));
41
+	}
42
+}

+ 123 - 0
src/main/java/com/zhaxd/web/utils/DateField.java

@@ -0,0 +1,123 @@
1
+package com.zhaxd.web.utils;
2
+
3
+import java.util.Calendar;
4
+
5
+public enum DateField {
6
+
7
+	/**
8
+	 * 年
9
+	 * @see Calendar#YEAR
10
+	 */
11
+	YEAR(Calendar.YEAR),
12
+	/**
13
+	 * 月
14
+	 * @see Calendar#MONTH
15
+	 */
16
+	MONTH(Calendar.MONTH),
17
+	/**
18
+	 * 一年中第几周
19
+	 * @see Calendar#WEEK_OF_YEAR
20
+	 */
21
+	WEEK_OF_YEAR(Calendar.WEEK_OF_YEAR),
22
+	/**
23
+	 * 一月中第几周
24
+	 * @see Calendar#WEEK_OF_MONTH
25
+	 */
26
+	WEEK_OF_MONTH(Calendar.WEEK_OF_MONTH),
27
+	/**
28
+	 * 一月中的第几天
29
+	 * @see Calendar#DAY_OF_MONTH
30
+	 */
31
+	DAY_OF_MONTH(Calendar.DAY_OF_MONTH),
32
+	/**
33
+	 *一年中的第几天
34
+	 * @see Calendar#DAY_OF_YEAR
35
+	 */
36
+	DAY_OF_YEAR(Calendar.DAY_OF_YEAR),
37
+	/**
38
+	 *周几
39
+	 * @see Calendar#DAY_OF_WEEK
40
+	 */
41
+	DAY_OF_WEEK(Calendar.DAY_OF_WEEK),
42
+	/**
43
+	 * 天所在的周是这个月的第几周
44
+	 * @see Calendar#DAY_OF_WEEK_IN_MONTH
45
+	 */
46
+	DAY_OF_WEEK_IN_MONTH(Calendar.DAY_OF_WEEK_IN_MONTH),
47
+	/**
48
+	 * 上午或者下午
49
+	 * @see Calendar#AM_PM
50
+	 */
51
+	AM_PM(Calendar.AM_PM),
52
+	/**
53
+	 * 小时,用于12小时制
54
+	 * @see Calendar#HOUR
55
+	 */
56
+	HOUR(Calendar.HOUR),
57
+	/**
58
+	 * 小时,用于24小时制
59
+	 * @see Calendar#HOUR
60
+	 */
61
+	HOUR_OF_DAY(Calendar.HOUR_OF_DAY),
62
+	/**
63
+	 * 分钟
64
+	 * @see Calendar#MINUTE
65
+	 */
66
+	MINUTE(Calendar.MINUTE),
67
+	/**
68
+	 * 秒
69
+	 * @see Calendar#SECOND
70
+	 */
71
+	SECOND(Calendar.SECOND),
72
+	/**
73
+	 * 毫秒
74
+	 * @see Calendar#MILLISECOND
75
+	 */
76
+	MILLISECOND(Calendar.MILLISECOND);
77
+
78
+	// ---------------------------------------------------------------
79
+	private int value;
80
+
81
+	private DateField(int value) {
82
+		this.value = value;
83
+	}
84
+
85
+	public int getValue() {
86
+		return this.value;
87
+	}
88
+
89
+	/**
90
+	 * 将 {@link Calendar}相关值转换为DatePart枚举对象<br>
91
+	 * 
92
+	 * @param calendarPartIntValue Calendar中关于Week的int
93
+	 * @return {@link DateField}
94
+	 */
95
+	public static DateField of(int calendarPartIntValue) {
96
+		switch (calendarPartIntValue) {
97
+			case Calendar.YEAR:
98
+				return YEAR;
99
+			case Calendar.MONTH:
100
+				return MONTH;
101
+			case Calendar.WEEK_OF_YEAR:
102
+				return WEEK_OF_YEAR;
103
+			case Calendar.WEEK_OF_MONTH:
104
+				return WEEK_OF_MONTH;
105
+			case Calendar.DAY_OF_MONTH:
106
+				return DAY_OF_MONTH;
107
+			case Calendar.DAY_OF_YEAR:
108
+				return DAY_OF_YEAR;
109
+			case Calendar.DAY_OF_WEEK:
110
+				return DAY_OF_WEEK;
111
+			case Calendar.DAY_OF_WEEK_IN_MONTH:
112
+				return DAY_OF_WEEK_IN_MONTH;
113
+			case Calendar.MINUTE:
114
+				return MINUTE;
115
+			case Calendar.SECOND:
116
+				return SECOND;
117
+			case Calendar.MILLISECOND:
118
+				return MILLISECOND;
119
+			default:
120
+				return null;
121
+		}
122
+	}
123
+}

+ 241 - 0
src/main/java/com/zhaxd/web/utils/DateTime.java

@@ -0,0 +1,241 @@
1
+package com.zhaxd.web.utils;
2
+
3
+import java.util.Calendar;
4
+import java.util.Date;
5
+import java.util.Locale;
6
+import java.util.TimeZone;
7
+
8
+public class DateTime extends Date {
9
+	
10
+	private static final long serialVersionUID = 1L;
11
+	
12
+	/**
13
+	 * 现在的时间
14
+	 * 
15
+	 * @return 现在的时间
16
+	 */
17
+	public static DateTime now() {
18
+		return new DateTime();
19
+	}
20
+	
21
+	/**
22
+	 * 当前时间
23
+	 */
24
+	public DateTime() {
25
+		super();
26
+	}
27
+
28
+	/**
29
+	 * 给定日期的构造
30
+	 * 
31
+	 * @param date 日期
32
+	 */
33
+	public DateTime(Date date) {
34
+		this(date.getTime());
35
+	}
36
+
37
+	/**
38
+	 * 给定日期的构造
39
+	 * 
40
+	 * @param calendar {@link Calendar}
41
+	 */
42
+	public DateTime(Calendar calendar) {
43
+		this(calendar.getTime());
44
+	}
45
+
46
+	/**
47
+	 * 给定日期毫秒数的构造
48
+	 * 
49
+	 * @param timeMillis 日期毫秒数
50
+	 */
51
+	public DateTime(long timeMillis) {
52
+		super(timeMillis);
53
+	}
54
+	
55
+	/**
56
+	 * 获得日期的某个部分<br>
57
+	 * 例如获得年的部分,则使用 getField(DatePart.YEAR)
58
+	 * @param field 表示日期的哪个部分的枚举 {@link DateField}
59
+	 * @return 某个部分的值
60
+	 */
61
+	public int getField(DateField field){
62
+		return getField(field.getValue());
63
+	}
64
+	
65
+	/**
66
+	 * 获得日期的某个部分<br>
67
+	 * 例如获得年的部分,则使用 getField(Calendar.YEAR)
68
+	 * @param field 表示日期的哪个部分的int值 {@link Calendar}
69
+	 * @return 某个部分的值
70
+	 */
71
+	public int getField(int field){
72
+		return toCalendar().get(field);
73
+	}
74
+	
75
+	/**
76
+	 * 获得年的部分
77
+	 * 
78
+	 * @return 年的部分
79
+	 */
80
+	public int year() {
81
+		return getField(DateField.YEAR);
82
+	}
83
+
84
+	/**
85
+	 * 获得当前日期所属季度<br>
86
+	 * 1:第一季度<br>
87
+	 * 2:第二季度<br>
88
+	 * 3:第三季度<br>
89
+	 * 4:第四季度<br>
90
+	 * 
91
+	 * @return 第几个季度
92
+	 */
93
+	public int season() {
94
+		return monthStartFromOne() /3 + 1;
95
+	}
96
+	
97
+	/**
98
+	 * 获得月份,从0开始计数
99
+	 * 
100
+	 * @return 月份
101
+	 */
102
+	public int month() {
103
+		return getField(DateField.MONTH);
104
+	}
105
+	
106
+	/**
107
+	 * 获得月份,从1开始计数<br>
108
+	 * 由于{@link Calendar} 中的月份按照0开始计数,导致某些需求容易误解,因此如果想用1表示一月,2表示二月则调用此方法
109
+	 * 
110
+	 * @return 月份
111
+	 */
112
+	public int monthStartFromOne() {
113
+		return month() +1;
114
+	}
115
+
116
+	/**
117
+	 * 获得指定日期是所在年份的第几周<br>
118
+	 * 
119
+	 * @return
120
+	 */
121
+	public int weekOfYear() {
122
+		return getField(DateField.WEEK_OF_YEAR);
123
+	}
124
+
125
+	/**
126
+	 * 获得指定日期是所在月份的第几周<br>
127
+	 * 
128
+	 * @return
129
+	 */
130
+	public int weekOfMonth() {
131
+		return getField(DateField.WEEK_OF_MONTH);
132
+	}
133
+
134
+	/**
135
+	 * 获得指定日期是这个日期所在月份的第几天<br>
136
+	 * 
137
+	 * @return
138
+	 */
139
+	public int dayOfMonth() {
140
+		return getField(DateField.DAY_OF_MONTH);
141
+	}
142
+
143
+	/**
144
+	 * 获得指定日期是星期几
145
+	 * 
146
+	 * @return
147
+	 */
148
+	public int dayOfWeek() {
149
+		return getField(DateField.DAY_OF_WEEK);
150
+	}
151
+	
152
+	/**
153
+	 * 获得天所在的周是这个月的第几周
154
+	 * 
155
+	 * @return
156
+	 */
157
+	public int dayOfWeekInMonth() {
158
+		return getField(DateField.DAY_OF_WEEK_IN_MONTH);
159
+	}
160
+
161
+	/**
162
+	 * 获得指定日期的小时数部分<br>
163
+	 * 
164
+	 * @param is24HourClock 是否24小时制
165
+	 * @return 小时数
166
+	 */
167
+	public int hour(boolean is24HourClock) {
168
+		return getField(is24HourClock ? DateField.HOUR_OF_DAY : DateField.HOUR);
169
+	}
170
+
171
+	/**
172
+	 * 获得指定日期的分钟数部分<br>
173
+	 * 例如:10:04:15.250 -> 4
174
+	 * 
175
+	 * @return 分钟数
176
+	 */
177
+	public int minute() {
178
+		return getField(DateField.MINUTE);
179
+	}
180
+
181
+	/**
182
+	 * 获得指定日期的秒数部分<br>
183
+	 * 
184
+	 * @return 秒数
185
+	 */
186
+	public int second() {
187
+		return getField(DateField.SECOND);
188
+	}
189
+
190
+	/**
191
+	 * 获得指定日期的毫秒数部分<br>
192
+	 * 
193
+	 * @return 毫秒数
194
+	 */
195
+	public int millsecond() {
196
+		return getField(DateField.MILLISECOND);
197
+	}
198
+
199
+	/**
200
+	 * 转换为Calendar,默认{@link TimeZone},默认 {@link Locale}
201
+	 * 
202
+	 * @return {@link Calendar}
203
+	 */
204
+	public Calendar toCalendar() {
205
+		final Calendar cal = Calendar.getInstance();
206
+		cal.setTime(this);
207
+		return cal;
208
+	}
209
+	
210
+	/**
211
+	 * 转换为Calendar
212
+	 * @param locale 地域 {@link Locale}
213
+	 * @return {@link Calendar}
214
+	 */
215
+	public Calendar toCalendar(Locale locale) {
216
+		final Calendar cal = Calendar.getInstance(locale);
217
+		cal.setTime(this);
218
+		return cal;
219
+	}
220
+	
221
+	/**
222
+	 * 转换为Calendar
223
+	 * @param zone 时区 {@link TimeZone}
224
+	 * @return {@link Calendar}
225
+	 */
226
+	public Calendar toCalendar(TimeZone zone) {
227
+		return toCalendar(zone, Locale.getDefault(Locale.Category.FORMAT));
228
+	}
229
+	
230
+	/**
231
+	 * 转换为Calendar
232
+	 * @param zone 时区 {@link TimeZone}
233
+	 * @param locale 地域 {@link Locale}
234
+	 * @return {@link Calendar}
235
+	 */
236
+	public Calendar toCalendar(TimeZone zone, Locale locale) {
237
+		final Calendar cal = Calendar.getInstance(zone, locale);
238
+		cal.setTime(this);
239
+		return cal;
240
+	}
241
+}

+ 91 - 0
src/main/java/com/zhaxd/web/utils/JsonUtils.java

@@ -0,0 +1,91 @@
1
+package com.zhaxd.web.utils;
2
+
3
+import java.text.SimpleDateFormat;
4
+import java.util.List;
5
+
6
+import com.fasterxml.jackson.core.JsonProcessingException;
7
+import com.fasterxml.jackson.databind.JavaType;
8
+import com.fasterxml.jackson.databind.ObjectMapper;
9
+
10
+/**
11
+ * json工具类
12
+ * @author gongym
13
+ */
14
+public class JsonUtils {
15
+
16
+    // 定义jackson对象
17
+    private static final ObjectMapper MAPPER = new ObjectMapper();
18
+    /**
19
+     * 序列化中的时间格式化
20
+     */
21
+    private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
22
+
23
+    /**
24
+     * 将对象转换成json字符串。
25
+     * <p>Title: pojoToJson</p>
26
+     * <p>Description: </p>
27
+     * @param data
28
+     * @return
29
+     */
30
+    public static String objectToJson(Object data) {
31
+    	try {
32
+    		MAPPER.setDateFormat(new SimpleDateFormat(DEFAULT_DATE_FORMAT));
33
+			return MAPPER.writeValueAsString(data);
34
+		} catch (JsonProcessingException e) {
35
+			e.printStackTrace();
36
+		}
37
+    	return null;
38
+    }
39
+    
40
+    /**
41
+     * @Title: objectToJson   
42
+     * @Description: 自定义事件格式化的JSON转换   
43
+     * @param data
44
+     * @param dateFormat
45
+     * @return String        
46
+     * @throws
47
+     */
48
+    public static String objectToJson(Object data, String dateFormat) {
49
+    	try {
50
+    		MAPPER.setDateFormat(new SimpleDateFormat(dateFormat));
51
+			return MAPPER.writeValueAsString(data);
52
+		} catch (JsonProcessingException e) {
53
+			e.printStackTrace();
54
+		}
55
+    	return null;
56
+    }
57
+    
58
+    /**
59
+     * 将json结果集转化为对象
60
+     * 
61
+     * @param jsonData json数据
62
+     * @param clazz 对象中的object类型
63
+     * @return
64
+     */
65
+    public static <T> T jsonToPojo(String jsonData, Class<T> beanType) {
66
+        try {
67
+            return MAPPER.readValue(jsonData, beanType);
68
+        } catch (Exception e) {
69
+        	e.printStackTrace();
70
+        }
71
+        return null;
72
+    }
73
+    
74
+    /**
75
+     * 将json数据转换成pojo对象list
76
+     * <p>Title: jsonToList</p>
77
+     * <p>Description: </p>
78
+     * @param jsonData
79
+     * @param beanType
80
+     * @return
81
+     */
82
+    public static <T>List<T> jsonToList(String jsonData, Class<T> beanType) {
83
+    	JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType);
84
+    	try {
85
+    		return MAPPER.readValue(jsonData, javaType);
86
+		} catch (Exception e) {
87
+			e.printStackTrace();
88
+		}
89
+    	return null;
90
+    }
91
+}

File diff suppressed because it is too large
+ 4133 - 0
src/main/java/org/pentaho/di/core/database/Database.java


+ 2 - 0
src/main/resources/btsql-ext.properties

@@ -0,0 +1,2 @@
1
+PRODUCT_MODE=true
2
+OFFSET_START_ZERO=true

+ 11 - 0
src/main/resources/kettle-lifecycle-listeners.xmlbak

@@ -0,0 +1,11 @@
1
+<listeners>
2
+    
3
+    <listener id="PdiOsgiBridge">
4
+        <description>PDI-OSGI-Bridge Listener</description>
5
+        <tooltip/>
6
+        <classname>org.pentaho.di.osgi.KettleLifeCycleAdapter</classname>
7
+        <meta-classname/>
8
+        <version-browser-classname/>
9
+    </listener>
10
+    
11
+</listeners>

+ 11 - 0
src/main/resources/kettle-registry-extensions.xmlbak

@@ -0,0 +1,11 @@
1
+<registry-extensions>
2
+
3
+  <registry-extension id="PdiOsgiBridge">
4
+    <description>PDI-OSGI-Bridge Extension</description>
5
+    <tooltip/>
6
+    <classname>org.pentaho.di.osgi.registryExtension.OSGIPluginRegistryExtension</classname>
7
+    <meta-classname/>
8
+    <version-browser-classname/>
9
+  </registry-extension>
10
+
11
+</registry-extensions>

+ 473 - 0
src/main/resources/kettle-variables.xml

@@ -0,0 +1,473 @@
1
+<kettle-variables>
2
+
3
+  <kettle-variable>
4
+    <description>Do not show the developer version warning dialog at Spoon startup?</description>
5
+    <variable>KETTLE_HIDE_DEVELOPMENT_VERSION_WARNING</variable>
6
+    <default-value>N</default-value>
7
+  </kettle-variable>
8
+
9
+  <kettle-variable>
10
+    <description>System wide flag to allow lenient string to number conversion for backward compatibility. If this
11
+      setting is set to "Y", an string starting with digits will be converted successfully into a number. (example:
12
+      192.168.1.1 will be converted into 192 or 192.168 or 192168 depending on the decimal and grouping symbol). The
13
+      default (N) will be to throw an error if non-numeric symbols are found in the string.
14
+    </description>
15
+    <variable>KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION</variable>
16
+    <default-value>N</default-value>
17
+  </kettle-variable>
18
+
19
+  <kettle-variable>
20
+    <description>System wide flag to ignore timezone while writing date/timestamp value to the database.</description>
21
+    <variable>KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE</variable>
22
+    <default-value>N</default-value>
23
+  </kettle-variable>
24
+
25
+  <kettle-variable>
26
+    <description>The log size limit for all transformations and jobs that don't have the "log size limit" property set
27
+      in their respective properties.
28
+    </description>
29
+    <variable>KETTLE_LOG_SIZE_LIMIT</variable>
30
+    <default-value>0</default-value>
31
+  </kettle-variable>
32
+
33
+  <kettle-variable>
34
+    <description>The transformation log database connection default for all transformations.</description>
35
+    <variable>KETTLE_TRANS_LOG_DB</variable>
36
+  </kettle-variable>
37
+
38
+  <kettle-variable>
39
+    <description>The transformation logging schema default for all transformations</description>
40
+    <variable>KETTLE_TRANS_LOG_SCHEMA</variable>
41
+  </kettle-variable>
42
+
43
+  <kettle-variable>
44
+    <description>The transformation logging table default for all transformations</description>
45
+    <variable>KETTLE_TRANS_LOG_TABLE</variable>
46
+  </kettle-variable>
47
+
48
+  <kettle-variable>
49
+    <description>The job log database connection default for all jobs</description>
50
+    <variable>KETTLE_JOB_LOG_DB</variable>
51
+  </kettle-variable>
52
+
53
+  <kettle-variable>
54
+    <description>The job logging schema default for all jobs</description>
55
+    <variable>KETTLE_JOB_LOG_SCHEMA</variable>
56
+  </kettle-variable>
57
+
58
+  <kettle-variable>
59
+    <description>The job logging table default for all jobs</description>
60
+    <variable>KETTLE_JOB_LOG_TABLE</variable>
61
+  </kettle-variable>
62
+
63
+  <kettle-variable>
64
+    <description>The transformation performance log schema default for all transformations</description>
65
+    <variable>KETTLE_TRANS_PERFORMANCE_LOG_DB</variable>
66
+  </kettle-variable>
67
+
68
+  <kettle-variable>
69
+    <description>The transformation performance log database connection default for all transformations</description>
70
+    <variable>KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA</variable>
71
+  </kettle-variable>
72
+
73
+  <kettle-variable>
74
+    <description>The transformation performance log table default for all transformations</description>
75
+    <variable>KETTLE_TRANS_PERFORMANCE_LOG_TABLE</variable>
76
+  </kettle-variable>
77
+
78
+  <kettle-variable>
79
+    <description>The job entry log database default for all jobs</description>
80
+    <variable>KETTLE_JOBENTRY_LOG_DB</variable>
81
+  </kettle-variable>
82
+
83
+  <kettle-variable>
84
+    <description>The job entry log schema default for all jobs</description>
85
+    <variable>KETTLE_JOBENTRY_LOG_SCHEMA</variable>
86
+  </kettle-variable>
87
+
88
+  <kettle-variable>
89
+    <description>The job entry log table default for all jobs</description>
90
+    <variable>KETTLE_JOBENTRY_LOG_TABLE</variable>
91
+  </kettle-variable>
92
+
93
+  <kettle-variable>
94
+    <description>The steps log database default for all transformations</description>
95
+    <variable>KETTLE_STEP_LOG_DB</variable>
96
+  </kettle-variable>
97
+
98
+  <kettle-variable>
99
+    <description>The steps log schema default for all transformations</description>
100
+    <variable>KETTLE_STEP_LOG_SCHEMA</variable>
101
+  </kettle-variable>
102
+
103
+  <kettle-variable>
104
+    <description>The steps log table default for all transformations</description>
105
+    <variable>KETTLE_STEP_LOG_TABLE</variable>
106
+  </kettle-variable>
107
+
108
+  <kettle-variable>
109
+    <description>The log channel log database default for all transformations and jobs</description>
110
+    <variable>KETTLE_CHANNEL_LOG_DB</variable>
111
+  </kettle-variable>
112
+
113
+  <kettle-variable>
114
+    <description>The log channel log schema default for all transformations and jobs</description>
115
+    <variable>KETTLE_CHANNEL_LOG_SCHEMA</variable>
116
+  </kettle-variable>
117
+
118
+  <kettle-variable>
119
+    <description>The log channel log table default for all transformations and jobs</description>
120
+    <variable>KETTLE_CHANNEL_LOG_TABLE</variable>
121
+  </kettle-variable>
122
+
123
+  <kettle-variable>
124
+    <description>The metrics log database default for all transformations and jobs</description>
125
+    <variable>KETTLE_METRICS_LOG_DB</variable>
126
+  </kettle-variable>
127
+
128
+  <kettle-variable>
129
+    <description>The metrics log schema default for all transformations and jobs</description>
130
+    <variable>KETTLE_METRICS_LOG_SCHEMA</variable>
131
+  </kettle-variable>
132
+
133
+  <kettle-variable>
134
+    <description>The metrics log table default for all transformations and jobs</description>
135
+    <variable>KETTLE_METRICS_LOG_TABLE</variable>
136
+  </kettle-variable>
137
+
138
+  <kettle-variable>
139
+    <description>The location of the shared object file (xml) for transformations and jobs</description>
140
+    <variable>KETTLE_SHARED_OBJECTS</variable>
141
+  </kettle-variable>
142
+
143
+  <kettle-variable>
144
+    <description>NULL vs Empty String. If this setting is set to Y, an empty string and null are different. Otherwise
145
+      they are not.
146
+    </description>
147
+    <variable>KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL</variable>
148
+    <default-value>N</default-value>
149
+  </kettle-variable>
150
+
151
+  <kettle-variable>
152
+    <description>The maximum number of log lines that are kept internally by Kettle. Set to 0 to keep all rows
153
+      (default)
154
+    </description>
155
+    <variable>KETTLE_MAX_LOG_SIZE_IN_LINES</variable>
156
+    <default-value>5000</default-value>
157
+  </kettle-variable>
158
+
159
+  <kettle-variable>
160
+    <description>The maximum age (in minutes) of a log line while being kept internally by Kettle. Set to 0 to keep all
161
+      rows indefinitely (default)
162
+    </description>
163
+    <variable>KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES</variable>
164
+    <default-value>1440</default-value>
165
+  </kettle-variable>
166
+
167
+  <kettle-variable>
168
+    <description>The maximum number of job trackers kept in memory</description>
169
+    <variable>KETTLE_MAX_JOB_TRACKER_SIZE</variable>
170
+    <default-value>5000</default-value>
171
+  </kettle-variable>
172
+
173
+  <kettle-variable>
174
+    <description>The maximum number of job entry results kept in memory for logging purposes.</description>
175
+    <variable>KETTLE_MAX_JOB_ENTRIES_LOGGED</variable>
176
+    <default-value>5000</default-value>
177
+  </kettle-variable>
178
+
179
+  <kettle-variable>
180
+    <description>The maximum number of logging registry entries kept in memory for logging purposes.</description>
181
+    <variable>KETTLE_MAX_LOGGING_REGISTRY_SIZE</variable>
182
+    <default-value>10000</default-value>
183
+  </kettle-variable>
184
+
185
+  <kettle-variable>
186
+    <description>The kettle log tab refresh delay.</description>
187
+    <variable>KETTLE_LOG_TAB_REFRESH_DELAY</variable>
188
+    <default-value>1000</default-value>
189
+  </kettle-variable>
190
+
191
+  <kettle-variable>
192
+    <description>The kettle log tab refresh period.</description>
193
+    <variable>KETTLE_LOG_TAB_REFRESH_PERIOD</variable>
194
+    <default-value>1000</default-value>
195
+  </kettle-variable>
196
+
197
+  <kettle-variable>
198
+    <description>A comma delimited list of classes to scan for plugin annotations</description>
199
+    <variable>KETTLE_PLUGIN_CLASSES</variable>
200
+    <default-value/>
201
+  </kettle-variable>
202
+
203
+  <kettle-variable>
204
+    <description>A comma delimited list of packages to scan for plugin annotations (warning: slow!!)</description>
205
+    <variable>KETTLE_PLUGIN_PACKAGES</variable>
206
+    <default-value/>
207
+  </kettle-variable>
208
+
209
+  <kettle-variable>
210
+    <description>The maximum number of step performance snapshots to keep in memory. Set to 0 to keep all snapshots
211
+      indefinitely (default)
212
+    </description>
213
+    <variable>KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT</variable>
214
+    <default-value>0</default-value>
215
+  </kettle-variable>
216
+
217
+  <kettle-variable>
218
+    <description>The name of the variable that optionally contains an alternative rowset get timeout (in ms). This only
219
+      makes a difference for extremely short lived transformations.
220
+    </description>
221
+    <variable>KETTLE_ROWSET_GET_TIMEOUT</variable>
222
+    <default-value>50</default-value>
223
+  </kettle-variable>
224
+
225
+  <kettle-variable>
226
+    <description>The name of the variable that optionally contains an alternative rowset put timeout (in ms). This only
227
+      makes a difference for extremely short lived transformations.
228
+    </description>
229
+    <variable>KETTLE_ROWSET_PUT_TIMEOUT</variable>
230
+    <default-value>50</default-value>
231
+  </kettle-variable>
232
+
233
+  <kettle-variable>
234
+    <description>The name of the environment variable that will contain the alternative location of the kettle-steps.xml
235
+      file. You can use this to customize the list of available internal steps outside of the codebase.
236
+    </description>
237
+    <variable>KETTLE_CORE_STEPS_FILE</variable>
238
+    <default-value></default-value>
239
+  </kettle-variable>
240
+
241
+  <kettle-variable>
242
+    <description>The name of the environment variable that will contain the alternative location of the
243
+      kettle-job-entries.xml file.
244
+    </description>
245
+    <variable>KETTLE_CORE_JOBENTRIES_FILE</variable>
246
+    <default-value></default-value>
247
+  </kettle-variable>
248
+
249
+  <kettle-variable>
250
+    <description>Experimental! Set this variable to Y if you want to test a more efficient batching row set. Use at your
251
+      own risk.
252
+    </description>
253
+    <variable>KETTLE_BATCHING_ROWSET</variable>
254
+    <default-value>N</default-value>
255
+  </kettle-variable>
256
+
257
+  <kettle-variable>
258
+    <description>This environment variable will set a time-out after which waiting, completed or stopped transformations
259
+      and jobs will be automatically cleaned up. The default value is 1440 (one day).
260
+    </description>
261
+    <variable>KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES</variable>
262
+    <default-value>1440</default-value>
263
+  </kettle-variable>
264
+
265
+  <kettle-variable>
266
+    <description>Set this variable to an integer that will be returned as the Pan JVM exit code.</description>
267
+    <variable>KETTLE_TRANS_PAN_JVM_EXIT_CODE</variable>
268
+    <default-value></default-value>
269
+  </kettle-variable>
270
+
271
+  <kettle-variable>
272
+    <description>Set this variable to Y to disable standard Kettle logging to the console. (stdout)</description>
273
+    <variable>KETTLE_DISABLE_CONSOLE_LOGGING</variable>
274
+    <default-value>N</default-value>
275
+  </kettle-variable>
276
+
277
+  <kettle-variable>
278
+    <variable>PENTAHO_METASTORE_FOLDER</variable>
279
+    <description>You can specify an alternative location for the Pentaho client Metastore. This location defaults to
280
+      $HOME/.pentaho/metastore when this variable is not set or empty.
281
+    </description>
282
+    <default-value></default-value>
283
+  </kettle-variable>
284
+
285
+  <kettle-variable>
286
+    <description>Set this variable to Y to redirect stderr to Kettle logging.</description>
287
+    <variable>KETTLE_REDIRECT_STDERR</variable>
288
+    <default-value>N</default-value>
289
+  </kettle-variable>
290
+
291
+  <kettle-variable>
292
+    <description>Set this variable to Y to redirect stdout to Kettle logging.</description>
293
+    <variable>KETTLE_REDIRECT_STDOUT</variable>
294
+    <default-value>N</default-value>
295
+  </kettle-variable>
296
+
297
+  <kettle-variable>
298
+    <description>Set this variable to point to the Simple JNDI folder containing a jdbc.properties file (default is
299
+      simple-jndi).
300
+    </description>
301
+    <variable>KETTLE_JNDI_ROOT</variable>
302
+    <default-value></default-value>
303
+  </kettle-variable>
304
+
305
+  <kettle-variable>
306
+    <description>The name of the variable containing an alternative default number format</description>
307
+    <variable>KETTLE_DEFAULT_NUMBER_FORMAT</variable>
308
+    <default-value></default-value>
309
+  </kettle-variable>
310
+
311
+  <kettle-variable>
312
+    <description>The name of the variable containing an alternative default bignumber format</description>
313
+    <variable>KETTLE_DEFAULT_BIGNUMBER_FORMAT</variable>
314
+    <default-value></default-value>
315
+  </kettle-variable>
316
+
317
+  <kettle-variable>
318
+    <description>The name of the variable containing an alternative default integer format</description>
319
+    <variable>KETTLE_DEFAULT_INTEGER_FORMAT</variable>
320
+    <default-value></default-value>
321
+  </kettle-variable>
322
+
323
+  <kettle-variable>
324
+    <description>The name of the variable containing an alternative default date format</description>
325
+    <variable>KETTLE_DEFAULT_DATE_FORMAT</variable>
326
+    <default-value></default-value>
327
+  </kettle-variable>
328
+
329
+  <kettle-variable>
330
+    <description>The name of the variable containing an alternative default timestamp format</description>
331
+    <variable>KETTLE_DEFAULT_TIMESTAMP_FORMAT</variable>
332
+    <default-value></default-value>
333
+  </kettle-variable>
334
+
335
+  <kettle-variable>
336
+    <description>Defines the default encoding for servlets, leave it empty to use Java default encoding</description>
337
+    <variable>KETTLE_DEFAULT_SERVLET_ENCODING</variable>
338
+    <default-value></default-value>
339
+  </kettle-variable>
340
+
341
+  <kettle-variable>
342
+    <description>Set this variable to Y when you want the job/transformation fail with an error when the related logging
343
+      process (e.g. to a database) fails.
344
+    </description>
345
+    <variable>KETTLE_FAIL_ON_LOGGING_ERROR</variable>
346
+    <default-value>N</default-value>
347
+  </kettle-variable>
348
+
349
+  <kettle-variable>
350
+    <description>Set this variable to Y to precede log lines with the mapping step name and the mapping itself.
351
+    </description>
352
+    <variable>KETTLE_LOG_MARK_MAPPINGS</variable>
353
+    <default-value>N</default-value>
354
+  </kettle-variable>
355
+
356
+  <kettle-variable>
357
+    <description>Set this variable to Y to set the minimum to NULL if NULL is within an aggregate. Otherwise by default
358
+      NULL is ignored by the MIN aggregate and MIN is set to the minimum value that is not NULL. See also the variable
359
+      KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO.
360
+    </description>
361
+    <variable>KETTLE_AGGREGATION_MIN_NULL_IS_VALUED</variable>
362
+    <default-value>N</default-value>
363
+  </kettle-variable>
364
+
365
+  <kettle-variable>
366
+    <description>Set this variable to Y to return 0 when all values within an aggregate are NULL. Otherwise by default a
367
+      NULL is returned when all values are NULL.
368
+    </description>
369
+    <variable>KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO</variable>
370
+    <default-value>N</default-value>
371
+  </kettle-variable>
372
+
373
+  <kettle-variable>
374
+    <description>Set this variable to Y for backward compatibility for the Text File Output step. Setting this to Ywill add no header row at all when the append option is enabled, regardless if the file is existing or not.</description>
375
+    <variable>KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER</variable>
376
+    <default-value>N</default-value>
377
+  </kettle-variable>
378
+
379
+  <kettle-variable>
380
+    <variable>KETTLE_PASSWORD_ENCODER_PLUGIN</variable>
381
+    <description>Specifies the password encoder plugin to use by ID (Kettle is the default).</description>
382
+    <default-value>Kettle</default-value>
383
+  </kettle-variable>
384
+
385
+  <kettle-variable>
386
+    <description>Set this variable to Y to revert the Enterprise Repository node naming behavior back to the old mode.
387
+      See http://jira.pentaho.com/browse/PDI-6394 for details.
388
+    </description>
389
+    <variable>KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE</variable>
390
+    <default-value>N</default-value>
391
+  </kettle-variable>
392
+
393
+
394
+  <kettle-variable>
395
+    <description>You can use this variable to speed up hostname lookup. Hostname lookup is performed by Kettle so that it is capable of logging the server on which a job or transformation is executed.
396
+    </description>
397
+    <variable>KETTLE_SYSTEM_HOSTNAME</variable>
398
+    <default-value></default-value>
399
+  </kettle-variable>
400
+
401
+  <kettle-variable>
402
+    <description>Set this variable to Y for backward compatibility when importing a reference to a directory with a variable. When set to Y, a directory reference is always prefixed with the root path independently if variables are used or not.
403
+    </description>
404
+    <variable>KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES</variable>
405
+    <default-value>N</default-value>
406
+  </kettle-variable>
407
+
408
+   <kettle-variable>
409
+    <description>A variable to configure jetty option: acceptors for Carte</description>
410
+    <variable>KETTLE_CARTE_JETTY_ACCEPTORS</variable>
411
+  </kettle-variable>
412
+
413
+  <kettle-variable>
414
+    <description>A variable to configure jetty option: acceptQueueSize for Carte</description>
415
+    <variable>KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE</variable>
416
+  </kettle-variable>
417
+
418
+  <kettle-variable>
419
+    <description>A variable to configure jetty option: lowResourcesMaxIdleTime for Carte</description>
420
+    <variable>KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME</variable>
421
+  </kettle-variable>
422
+
423
+  <kettle-variable>
424
+    <description>Set this variable to Y for backward compatibility for the Merge Rows (diff) step. Setting this to Y will use the data from the reference stream (instead of the comparison stream) in case the compared rows are identical.</description>
425
+    <variable>KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL</variable>
426
+    <default-value>N</default-value>
427
+  </kettle-variable>
428
+
429
+  <kettle-variable>
430
+    <description>Set this variable to true if VFS should treat the user directory as the root directory when connecting via ftp. Defaults to false.</description>
431
+    <variable>vfs.sftp.userDirIsRoot</variable>
432
+    <default-value>false</default-value>
433
+  </kettle-variable>
434
+
435
+  <kettle-variable>
436
+    <description>Set this variable to Y to create S3 Object for upload based on a temporary file with data.
437
+    </description>
438
+    <variable>s3.vfs.useTempFileOnUploadData</variable>
439
+    <default-value>N</default-value>
440
+  </kettle-variable>
441
+
442
+  <kettle-variable>
443
+    <description>Set this variable to restore the directory loading behavior of the repository as it was before 6.1. Changing this to false will make repository loading more expensive</description>
444
+    <variable>KETTLE_LAZY_REPOSITORY</variable>
445
+    <default-value>true</default-value>
446
+  </kettle-variable>
447
+
448
+  <kettle-variable>
449
+    <description>Set this variable to false to preserve enclosure symbol after splitting the string in the Split fields step. Changing it to true will remove first and last enclosure symbol from the resulting string chunks.</description>
450
+    <variable>KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE</variable>
451
+    <default-value>false</default-value>
452
+  </kettle-variable>
453
+
454
+  <kettle-variable>
455
+    <description>Set this variable to false to preserve global log variables defined in transformation / job Properties -> Log panel. Changing it to true will clear it when export transformation / job.</description>
456
+    <variable>KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT</variable>
457
+    <default-value>false</default-value>
458
+  </kettle-variable>
459
+
460
+  <kettle-variable>
461
+    <description>A variable in ms to configure timeout inner http client data refinery plugin.</description>
462
+    <variable>KETTLE_DATA_REFINERY_HTTP_CLIENT_TIMEOUT</variable>
463
+    <default-value>2000</default-value>
464
+  </kettle-variable>
465
+
466
+  <kettle-variable>
467
+    <description>Set this variable to true to use a gateway for connecting to a Hadoop cluster.</description>
468
+    <variable>KETTLE_HADOOP_CLUSTER_GATEWAY_CONNECTION</variable>
469
+    <default-value>false</default-value>
470
+  </kettle-variable>
471
+
472
+</kettle-variables>
473
+

+ 24 - 0
src/main/resources/log4j.properties

@@ -0,0 +1,24 @@
1
+***********************log4j.properties***********************
2
+log4j.rootLogger=info, stdout, root, error
3
+
4
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
6
+log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r(%C:%M) - %m%n
7
+
8
+log4j.appender.root=org.apache.log4j.RollingFileAppender
9
+log4j.appender.root.File= ${catalina.base}/logs/kettle_log.log
10
+log4j.appender.root.MaxFileSize=512KB
11
+log4j.appender.root.MaxBackupIndex=5
12
+log4j.appender.root.encoding=UTF-8
13
+log4j.appender.root.layout=org.apache.log4j.PatternLayout
14
+log4j.appender.root.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r(%C:%M) - %m%n
15
+
16
+log4j.appender.error=org.apache.log4j.RollingFileAppender
17
+log4j.appender.error.File= ${catalina.base}/logs/error_log.log
18
+log4j.appender.error.MaxFileSize=512KB
19
+log4j.appender.error.MaxBackupIndex=5
20
+log4j.appender.error.encoding=UTF-8
21
+log4j.appender.error.Threshold = ERROR
22
+log4j.appender.error.append=true
23
+log4j.appender.error.layout=org.apache.log4j.PatternLayout
24
+log4j.appender.error.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r(%C:%M) - %m%n

+ 153 - 0
src/main/resources/log4j.xml

@@ -0,0 +1,153 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3
+
4
+<!-- ===================================================================== -->
5
+<!--                                                                       -->
6
+<!--  Log4j Configuration                                                  -->
7
+<!--                                                                       -->
8
+<!-- ===================================================================== -->
9
+
10
+<!--
11
+   | For more configuration information and examples see the Jakarta Log4j
12
+   | owebsite: http://jakarta.apache.org/log4j
13
+ -->
14
+
15
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
16
+
17
+   <!-- ================================= -->
18
+   <!-- Preserve messages in a local file -->
19
+   <!-- ================================= -->
20
+
21
+   <!-- A time/date based rolling appender -->
22
+   <appender name="PENTAHOFILE" class="org.apache.log4j.DailyRollingFileAppender">
23
+
24
+      <param name="File" value="logs/pdi.log"/>
25
+      <param name="Append" value="false"/>
26
+
27
+      <!-- Rollover at midnight each day -->
28
+      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
29
+
30
+      <!-- Rollover at the top of each hour
31
+      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
32
+      -->
33
+
34
+      <layout class="org.apache.log4j.PatternLayout">
35
+         <!-- The default pattern: Date Priority [Category] Message\n -->
36
+         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
37
+
38
+         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
39
+         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
40
+          -->
41
+      </layout>
42
+   </appender>
43
+
44
+   <!-- ================== -->
45
+   <!-- Log4JDBC Appenders -->
46
+   <!-- ================== -->
47
+   <!--
48
+   <appender name="sql-appender" class="org.apache.log4j.FileAppender">
49
+      <param name="File" value="logs/log4jdbc-sql.log"/>
50
+      <param name="Append" value="false"/>
51
+      <layout class="org.apache.log4j.PatternLayout">
52
+        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} &lt;%t&gt; %m%n%n"/>
53
+      </layout>
54
+   </appender>
55
+
56
+   <appender name="sql-timing-appender" class="org.apache.log4j.FileAppender">
57
+      <param name="File" value="logs/log4jdbc-sqltiming.log"/>
58
+      <param name="Append" value="false"/>
59
+      <layout class="org.apache.log4j.PatternLayout">
60
+        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%n"/>
61
+      </layout>
62
+   </appender>
63
+
64
+   <appender name="jdbc-appender" class="org.apache.log4j.FileAppender">
65
+      <param name="File" value="logs/log4jdbc-jdbc.log"/>
66
+      <param name="Append" value="false"/>
67
+      <layout class="org.apache.log4j.PatternLayout">
68
+        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/>
69
+      </layout>
70
+   </appender>
71
+
72
+   <appender name="connection-appender" class="org.apache.log4j.FileAppender">
73
+      <param name="File" value="logs/log4jdbc-connection.log"/>
74
+      <param name="Append" value="false"/>
75
+      <layout class="org.apache.log4j.PatternLayout">
76
+        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/>
77
+      </layout>
78
+   </appender>
79
+   -->
80
+   <!-- ============================== -->
81
+   <!-- Append messages to the console -->
82
+   <!-- ============================== -->
83
+
84
+   <appender name="PENTAHOCONSOLE" class="org.apache.log4j.ConsoleAppender">
85
+      <param name="Target" value="System.out"/>
86
+      <param name="Threshold" value="INFO"/>
87
+
88
+      <layout class="org.apache.log4j.PatternLayout">
89
+         <!-- The default pattern: Date Priority [Category] Message\n -->
90
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
91
+      </layout>
92
+   </appender>
93
+
94
+   <!-- ================ -->
95
+   <!-- Limit categories -->
96
+   <!-- ================ -->
97
+
98
+   <!--<category name="org.pentaho">-->
99
+     <!--<priority value="ERROR"/>-->
100
+   <!--</category>-->
101
+
102
+    <category name="org.apache.hadoop.io.retry">
103
+        <priority value="INFO" />
104
+    </category>
105
+
106
+	<category name="org.pentaho.platform.osgi">
107
+		<priority value="INFO" />
108
+	</category>
109
+	
110
+  <category name="org.pentaho.platform.engine.core.system.status">
111
+    <priority value="INFO"/>
112
+  </category>
113
+
114
+   <!-- ======================= -->
115
+   <!-- Setup the Root category -->
116
+   <!-- ======================= -->
117
+
118
+   <root>
119
+      <priority value="ERROR" />
120
+      <appender-ref ref="PENTAHOCONSOLE"/>
121
+      <!--<appender-ref ref="PENTAHOFILE"/>-->
122
+   </root>
123
+
124
+   <!-- ================ -->
125
+   <!-- Log4JDBC Loggers -->
126
+   <!-- ================ -->
127
+   <!--
128
+   <logger name="jdbc.sqlonly" additivity="false">
129
+    <level value="info"/>
130
+    <appender-ref ref="sql-appender"/>
131
+   </logger>
132
+
133
+   <logger name="jdbc.sqltiming" additivity="false">
134
+      <level value="info"/>
135
+      <appender-ref ref="sql-timing-appender"/>
136
+   </logger>
137
+
138
+   <logger name="jdbc.audit" additivity="false">
139
+      <level value="info"/>
140
+      <appender-ref ref="jdbc-appender"/>
141
+   </logger>
142
+
143
+   <logger name="jdbc.resultset" additivity="false">
144
+      <level value="info"/>
145
+      <appender-ref ref="jdbc-appender"/>
146
+   </logger>
147
+  
148
+   <logger name="jdbc.connection" additivity="false">
149
+      <level value="info"/>
150
+      <appender-ref ref="connection-appender"/>
151
+   </logger>
152
+   -->
153
+</log4j:configuration>

File diff suppressed because it is too large
+ 1092 - 0
src/main/resources/mondrian.properties


+ 19 - 0
src/main/resources/quartz.properties

@@ -0,0 +1,19 @@
1
+# Default Properties file for use by StdSchedulerFactory
2
+# to create a Quartz Scheduler Instance, if a different
3
+# properties file is not explicitly specified.
4
+#
5
+
6
+org.quartz.scheduler.instanceName: DefaultQuartzScheduler
7
+org.quartz.scheduler.rmi.export: false
8
+org.quartz.scheduler.rmi.proxy: false
9
+org.quartz.scheduler.wrapJobExecutionInUserTransaction: false
10
+
11
+org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
12
+org.quartz.threadPool.threadCount: 50
13
+org.quartz.threadPool.threadPriority: 5
14
+org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
15
+
16
+org.quartz.jobStore.misfireThreshold: 60000
17
+
18
+org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
19
+

+ 1 - 0
src/main/resources/resource/active.properties

@@ -0,0 +1 @@
1
+active.property=DEV

+ 15 - 0
src/main/resources/resource/db-DEV.properties

@@ -0,0 +1,15 @@
1
+#\u672C\u5730\u6570\u636E\u6E90\u914D\u7F6E(MySql)
2
+datasource.type=mysql
3
+beetl.db.style=org.beetl.sql.core.db.MySqlStyle
4
+jdbc.driver=com.mysql.jdbc.Driver
5
+jdbc.url=jdbc:mysql://192.168.3.109:3306/kettle?autoReconnect=true&serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false
6
+jdbc.username=root
7
+jdbc.password=100100
8
+
9
+#\u672C\u5730\u6570\u636E\u6E90\u914D\u7F6E(Oracle)
10
+#datasource.type=oracle
11
+#beetl.db.style=org.beetl.sql.core.db.OracleStyle
12
+#jdbc.driver=oracle.jdbc.OracleDriver
13
+#jdbc.url=jdbc:oracle:thin:@10.10.10.62:1521:zhcs
14
+#jdbc.username=testuser
15
+#jdbc.password=123456

+ 15 - 0
src/main/resources/resource/db-PROD.properties

@@ -0,0 +1,15 @@
1
+#\u672C\u5730\u6570\u636E\u6E90\u914D\u7F6E(MySql)
2
+datasource.type=mysql
3
+beetl.db.style=org.beetl.sql.core.db.MySqlStyle
4
+jdbc.driver=com.mysql.jdbc.Driver
5
+jdbc.url=jdbc:mysql://192.168.3.109:3306/kettle?autoReconnect=true&serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false
6
+jdbc.username=root
7
+jdbc.password=100100
8
+
9
+#\u672C\u5730\u6570\u636E\u6E90\u914D\u7F6E(Oracle)
10
+#datasource.type=oracle
11
+#beetl.db.style=org.beetl.sql.core.db.OracleStyle
12
+#jdbc.driver=oracle.jdbc.OracleDriver
13
+#jdbc.url=jdbc:oracle:thin:@10.10.10.62:1521:zhcs
14
+#jdbc.username=testuser
15
+#jdbc.password=123456

+ 29 - 0
src/main/resources/resource/kettle-DEV.properties

@@ -0,0 +1,29 @@
1
+#**********************************************************************
2
+# Kettle Properties
3
+#\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u7528\u4E8E\u521D\u59CB\u5316kettle\u73AF\u5883\u53D8\u91CF\uFF08.kettle/kettle.properties\u6240\u5728\u8DEF\u5F84\uFF09,\u6307\u5411kettle\u6839\u76EE\u5F55\uFF08\u4F8B\u5982 D:\data-integration\uFF09
4
+
5
+
6
+#kettle.home=D:\\E\\software\\software\\dev\\data-integration
7
+##tomcat\u7EDD\u5BF9\u8DEF\u5F84kettle\u4E0Bplugins\u6587\u4EF6
8
+#kettle.plugin=D:\\E\\software\\software\\dev\\apache-tomcat-8.5.32\\bin\\plugins
9
+##\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u9700\u8981\u6539\uFF0C\u6682\u65F6\u6CA1\u6709\u67E5\u51FA\u6709\u4EC0\u4E48\u7528
10
+#kettle.script=Html\\js\\libs\\url
11
+##\u65E5\u5FD7\u7EA7\u522B
12
+#kettle.loglevel=detail
13
+##kettle\u65E5\u5FD7\u5B58\u653E\u8DEF\u5F84
14
+#kettle.log.file.path=D:\\E\\software\\software\\dev\\data-integration\\logs
15
+##\u4FDD\u5B58\u4E0A\u4F20\u6587\u4EF6\u8F6C\u6362(.ktr)\u6216\u4F5C\u4E1A(.kjb)\u7684\u8DEF\u5F84,\u6B64\u529F\u80FD\u672A\u8C03\u8BD5,\u6682\u65F6\u505C\u7528,\u5F85\u5F00\u53D1
16
+#kettle.file.repository=D:\\E\\software\\software\\dev\\data-integration\\test
17
+
18
+
19
+kettle.home=/home/itsm/project/data-integration
20
+#tomcat\u7EDD\u5BF9\u8DEF\u5F84kettle\u4E0Bplugins\u6587\u4EF6
21
+kettle.plugin=/home/itsm/project/apache-tomcat-8.5.32-kettle/bin/plugins
22
+#\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u9700\u8981\u6539\uFF0C\u6682\u65F6\u6CA1\u6709\u67E5\u51FA\u6709\u4EC0\u4E48\u7528
23
+kettle.script=Html/js/libs/url
24
+#\u65E5\u5FD7\u7EA7\u522B
25
+kettle.loglevel=detail
26
+#kettle\u65E5\u5FD7\u5B58\u653E\u8DEF\u5F84
27
+kettle.log.file.path=/home/itsm/project/data-integration/logs
28
+#\u4FDD\u5B58\u4E0A\u4F20\u6587\u4EF6\u8F6C\u6362(.ktr)\u6216\u4F5C\u4E1A(.kjb)\u7684\u8DEF\u5F84,\u6B64\u529F\u80FD\u672A\u8C03\u8BD5,\u6682\u65F6\u505C\u7528,\u5F85\u5F00\u53D1
29
+kettle.file.repository=/home/itsm/project/data-integration/test

+ 14 - 0
src/main/resources/resource/kettle_PROD.properties

@@ -0,0 +1,14 @@
1
+#**********************************************************************
2
+# Kettle Properties
3
+#\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u7528\u4E8E\u521D\u59CB\u5316kettle\u73AF\u5883\u53D8\u91CF\uFF08.kettle/kettle.properties\u6240\u5728\u8DEF\u5F84\uFF09,\u6307\u5411kettle\u6839\u76EE\u5F55\uFF08\u4F8B\u5982 D:\data-integration\uFF09
4
+kettle.home=/usr/local/data-integration
5
+#\u7EDD\u5BF9\u8DEF\u5F84kettle\u4E0Bplugins\u6587\u4EF6
6
+kettle.plugin=/usr/local/apache-tomcat-8.5.39/bin/plugins
7
+#\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u9700\u8981\u6539\uFF0C\u6682\u65F6\u6CA1\u6709\u67E5\u51FA\u6709\u4EC0\u4E48\u7528
8
+kettle.script=Html/js/libs/url
9
+#\u65E5\u5FD7\u7EA7\u522B
10
+kettle.loglevel=detail
11
+#kettle\u65E5\u5FD7\u5B58\u653E\u8DEF\u5F84
12
+kettle.log.file.path=/usr/local/data-integration/logs
13
+#\u4FDD\u5B58\u4E0A\u4F20\u6587\u4EF6\u8F6C\u6362(.ktr)\u6216\u4F5C\u4E1A(.kjb)\u7684\u8DEF\u5F84,\u6B64\u529F\u80FD\u672A\u8C03\u8BD5,\u6682\u65F6\u505C\u7528,\u5F85\u5F00\u53D1
14
+kettle.file.repository=/usr/local/data-integration/test

+ 69 - 0
src/main/resources/spring/applicationContext-beetlsql.xml

@@ -0,0 +1,69 @@
1
+<beans xmlns="http://www.springframework.org/schema/beans"
2
+	xmlns:context="http://www.springframework.org/schema/context"
3
+	xmlns:p="http://www.springframework.org/schema/p"
4
+	xmlns:aop="http://www.springframework.org/schema/aop"
5
+	xmlns:tx="http://www.springframework.org/schema/tx"
6
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
8
+						http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
9
+						http://www.springframework.org/schema/context
10
+						http://www.springframework.org/schema/context/spring-context-4.3.xsd
11
+						http://www.springframework.org/schema/aop
12
+						http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
13
+						http://www.springframework.org/schema/tx
14
+						http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
15
+						http://www.springframework.org/schema/util
16
+						http://www.springframework.org/schema/util/spring-util-4.3.xsd">
17
+
18
+	<!-- 加载配置文件 -->
19
+	<bean id="dbPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
20
+        <property name="locations">
21
+            <list>
22
+                <value>classpath:resource/*-DEV.properties</value>
23
+<!--                <value>classpath:resource/*-PROD.properties</value>  -->
24
+            </list>
25
+        </property>
26
+        <property name="ignoreUnresolvablePlaceholders" value="true" />
27
+    </bean>
28
+	<!-- 数据库连接池 -->
29
+	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
30
+		destroy-method="close">
31
+		<property name="url" value="${jdbc.url}" />
32
+		<property name="username" value="${jdbc.username}" />
33
+		<property name="password" value="${jdbc.password}" />
34
+		<property name="driverClassName" value="${jdbc.driver}" />
35
+		<property name="maxActive" value="10" />
36
+		<property name="minIdle" value="5" />
37
+	</bean>
38
+	<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
39
+	<bean name="beetlSqlScannerConfigurer" class="org.beetl.sql.ext.spring4.BeetlSqlScannerConfigurer">
40
+	    <!-- 哪些类可以自动注入 -->
41
+	    <property name="basePackage" value="com.zhaxd.core.mapper"/>
42
+	    <!-- 通过类后缀 来自动注入Dao -->
43
+	    <property name="daoSuffix" value="Dao"/>
44
+	    <property name="sqlManagerFactoryBeanName" value="sqlManagerFactoryBean"/>
45
+	</bean>
46
+	<bean id="sqlManagerFactoryBean" class="org.beetl.sql.ext.spring4.SqlManagerFactoryBean">
47
+	   <property name="cs" >
48
+	        <bean class="org.beetl.sql.ext.spring4.BeetlSqlDataSource">
49
+	            <property name="masterSource" ref="dataSource"></property>
50
+	        </bean>
51
+	    </property>
52
+	    <property name="dbStyle">
53
+	        <bean class="${beetl.db.style}"/>
54
+	    </property>
55
+	    <property name="sqlLoader">
56
+	        <bean class="org.beetl.sql.core.ClasspathLoader">
57
+	            <property name="sqlRoot" value="/sql"></property>
58
+	        </bean>
59
+	    </property>
60
+	     <property name="nc">
61
+	        <bean class="org.beetl.sql.core.UnderlinedNameConversion"/>
62
+	    </property>
63
+	    <property name="interceptors">
64
+	        <list>
65
+	            <bean class="org.beetl.sql.ext.DebugInterceptor"></bean>
66
+	        </list>
67
+	    </property>
68
+	</bean>
69
+</beans>

+ 13 - 0
src/main/resources/spring/applicationContext-service.xml

@@ -0,0 +1,13 @@
1
+<beans xmlns="http://www.springframework.org/schema/beans"
2
+	xmlns:context="http://www.springframework.org/schema/context"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+	xsi:schemaLocation="http://www.springframework.org/schema/beans 
5
+						http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
6
+						http://www.springframework.org/schema/context 
7
+						http://www.springframework.org/schema/context/spring-context-4.3.xsd">
8
+	
9
+	<!-- 扫描包加载service实现类 -->
10
+	<context:component-scan base-package="com.zhaxd.web.service"/>
11
+	<!-- kettle的环境初始化 -->
12
+	<bean id="KettleEnvironmentInit" class="com.zhaxd.common.kettle.environment.StartInit"></bean>
13
+</beans>

+ 55 - 0
src/main/resources/spring/spring-mvc.xml

@@ -0,0 +1,55 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+       xmlns:context="http://www.springframework.org/schema/context"
5
+       xmlns:mvc="http://www.springframework.org/schema/mvc"
6
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
7
+						http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
8
+						http://www.springframework.org/schema/context
9
+						http://www.springframework.org/schema/context/spring-context-4.3.xsd
10
+						http://www.springframework.org/schema/mvc
11
+						http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
12
+
13
+    <!-- 扫描包 -->
14
+    <context:component-scan base-package="com.zhaxd.web.controller" />
15
+    <!-- 上传文件配置 -->
16
+    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
17
+        <property name="defaultEncoding" value="utf-8" />
18
+        <property name="maxUploadSize" value="1024000000"/>
19
+        <property name="maxInMemorySize" value="4096"/>
20
+    </bean>
21
+    <!-- 下载文件配置 -->
22
+    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> 
23
+   		<property name="messageConverters"> 
24
+    		<list>
25
+     			<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /> 
26
+   				<ref bean="stringHttpMessageConverter" /> 
27
+			</list> 
28
+		</property>
29
+	 </bean>
30
+	 <bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
31
+	 	<property name="supportedMediaTypes"> 
32
+	 		<list> 
33
+	 			<value>text/plain;charset=UTF-8</value>
34
+		 	</list>
35
+ 		</property>
36
+	</bean>
37
+    <!-- 视图解析器 -->
38
+    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
39
+        <property name="prefix" value="/WEB-INF/views/" />
40
+        <property name="suffix" value=".jsp" />
41
+    </bean>
42
+    <!-- 默认配置 -->
43
+    <mvc:annotation-driven>
44
+    	<mvc:message-converters>
45
+			<bean class="com.zhaxd.core.conf.UTF8StringHttpMessageConverter" />
46
+		</mvc:message-converters>
47
+    </mvc:annotation-driven>
48
+    <!-- 拦截器配置 -->
49
+	<mvc:interceptors>
50
+		<mvc:interceptor>
51
+			<mvc:mapping path="/**"/>
52
+			<bean class="com.zhaxd.core.conf.LoginInterceptor"/>
53
+		</mvc:interceptor>
54
+	</mvc:interceptors>
55
+</beans>

+ 62 - 0
src/main/resources/sql/mysql/kJob.md

@@ -0,0 +1,62 @@
1
+pageQuery
2
+===
3
+    *数据库表分页查询
4
+    SELECT #use("cols")# FROM 
5
+    k_job 
6
+    #use("condition")#
7
+    #use("sort")#
8
+    #use("limit")#
9
+
10
+queryByCondition
11
+===
12
+    SELECT job_Id FROM k_job #use("condition")#
13
+
14
+cols
15
+===
16
+    *列名
17
+    job_Id,
18
+    category_Id,
19
+    job_Name,
20
+    job_Description,
21
+    job_Path,
22
+    job_Quartz,
23
+    job_Status
24
+    
25
+condition
26
+===
27
+    where 1=1
28
+     @if(!isEmpty(kJob.categoryId)){
29
+            and category_id =#kJob.categoryId#
30
+     @}
31
+     @if(!isEmpty(kJob.jobName)){
32
+            and job_name like #'%'+kJob.jobName+'%'#
33
+     @}
34
+     @if(!isEmpty(kJob.addUser)){
35
+            and add_user =#kJob.addUser#
36
+     @}
37
+     @if(!isEmpty(kJob.delFlag)){
38
+            and del_flag =#kJob.delFlag#
39
+     @}
40
+     @if(!isEmpty(kJob.jobStatus)){
41
+            and job_status =#kJob.jobStatus#
42
+     @}
43
+sort
44
+===
45
+        order by add_time desc
46
+
47
+limit
48
+===
49
+    *分页
50
+    @if(!isEmpty(start)){
51
+        limit #start#   
52
+    @}
53
+    @if(!isEmpty(size)){
54
+        ,#size#
55
+    @}
56
+
57
+allCount
58
+===
59
+    *总数量
60
+    SELECT COUNT(1) FROM 
61
+    k_job
62
+    #use("condition")#

+ 56 - 0
src/main/resources/sql/mysql/kJobMonitor.md

@@ -0,0 +1,56 @@
1
+pageQuery
2
+===
3
+    *数据库表分页查询
4
+    select #use("cols")# from 
5
+    k_job kj left join k_job_monitor kjm on kjm.monitor_job=kj.job_id left join k_category kc on kj.category_id=kc.category_id
6
+    #use("condition")#
7
+    #use("sort")#
8
+    #use("limit")#
9
+
10
+cols
11
+===
12
+    *列名
13
+    category_name,
14
+    job_name,
15
+    monitor_Id,
16
+    monitor_Job,
17
+    last_Execute_Time,
18
+    next_Execute_Time,
19
+    monitor_Success,
20
+    monitor_Fail
21
+    
22
+condition
23
+===
24
+    where 1=1
25
+     @if(!isEmpty(kJobMonitor.jobName)){
26
+            and kj.job_name like #'%'+kJobMonitor.jobName+'%'#
27
+     @}
28
+     @if(!isEmpty(categoryId)){
29
+                      and kc.category_id =#categoryId#
30
+     @}
31
+     @if(!isEmpty(kJobMonitor.addUser)){
32
+                 and kjm.add_user =#kJobMonitor.addUser#
33
+     @}
34
+     @if(!isEmpty(kJobMonitor.monitorStatus)){
35
+                 and kjm.monitor_status =#kJobMonitor.monitorStatus#
36
+     @}
37
+sort
38
+===
39
+        order by last_execute_time desc
40
+
41
+limit
42
+===
43
+    *分页
44
+    @if(!isEmpty(start)){
45
+        limit #start#   
46
+    @}
47
+    @if(!isEmpty(size)){
48
+        ,#size#
49
+    @}
50
+
51
+allCount
52
+===
53
+    *总数量
54
+    SELECT COUNT(1) FROM 
55
+    k_job kj left join k_job_monitor kjm on kjm.monitor_job=kj.job_id left join k_category kc on kj.category_id=kc.category_id
56
+    #use("condition")#

+ 62 - 0
src/main/resources/sql/mysql/kTrans.md

@@ -0,0 +1,62 @@
1
+pageQuery
2
+===
3
+    *数据库表分页查询
4
+    SELECT #use("cols")# FROM 
5
+    k_trans
6
+    #use("condition")#
7
+    #use("sort")#
8
+    #use("limit")#
9
+
10
+queryByCondition
11
+===
12
+    SELECT trans_id FROM k_trans #use("condition")#
13
+
14
+cols
15
+===
16
+    *列名
17
+    trans_id,
18
+    category_Id,
19
+    trans_name,
20
+    trans_description,
21
+    trans_path,
22
+    trans_quartz,
23
+    trans_status
24
+    
25
+condition
26
+===
27
+    where 1=1
28
+     @if(!isEmpty(kTrans.categoryId)){
29
+            and category_Id =#kTrans.categoryId#
30
+     @}
31
+     @if(!isEmpty(kTrans.transName)){
32
+            and trans_name like #'%'+kTrans.transName+'%'#
33
+     @}
34
+     @if(!isEmpty(kTrans.addUser)){
35
+            and add_user =#kTrans.addUser#
36
+     @}
37
+     @if(!isEmpty(kTrans.delFlag)){
38
+            and del_flag =#kTrans.delFlag#
39
+     @}
40
+     @if(!isEmpty(kTrans.transStatus)){
41
+            and trans_Status =#kTrans.transStatus#
42
+     @}
43
+sort
44
+===
45
+        order by add_time desc
46
+
47
+limit
48
+===
49
+    *分页
50
+    @if(!isEmpty(start)){
51
+        limit #start#   
52
+    @}
53
+    @if(!isEmpty(size)){
54
+        ,#size#
55
+    @}
56
+
57
+allCount
58
+===
59
+    *总数量
60
+    SELECT COUNT(1) FROM 
61
+    k_trans
62
+    #use("condition")#

+ 56 - 0
src/main/resources/sql/mysql/kTransMonitor.md

@@ -0,0 +1,56 @@
1
+pageQuery
2
+===
3
+    *数据库表分页查询
4
+    select #use("cols")# from 
5
+    k_trans kt left join k_trans_monitor ktm on ktm.monitor_trans=kt.trans_id left join k_category kc on kt.category_id=kc.category_id
6
+    #use("condition")#
7
+    #use("sort")#
8
+    #use("limit")#
9
+
10
+cols
11
+===
12
+    *列名
13
+    category_name,
14
+    trans_name,
15
+    monitor_Id,
16
+    monitor_trans,
17
+    last_Execute_Time,
18
+    next_Execute_Time,
19
+    monitor_Success,
20
+    monitor_Fail
21
+    
22
+condition
23
+===
24
+    where 1=1
25
+     @if(!isEmpty(kTransMonitor.transName)){
26
+            and kt.trans_name like #'%'+kTransMonitor.transName+'%'#
27
+     @}
28
+     @if(!isEmpty(categoryId)){
29
+            and kc.category_id =#categoryId#
30
+     @}
31
+     @if(!isEmpty(kTransMonitor.addUser)){
32
+            and ktm.add_user =#kTransMonitor.addUser#
33
+     @}
34
+     @if(!isEmpty(kTransMonitor.monitorStatus)){
35
+             and ktm.monitor_status =#kTransMonitor.monitorStatus#
36
+     @}
37
+sort
38
+===
39
+        order by last_execute_time desc
40
+
41
+limit
42
+===
43
+    *分页
44
+    @if(!isEmpty(start)){
45
+        limit #start#   
46
+    @}
47
+    @if(!isEmpty(size)){
48
+        ,#size#
49
+    @}
50
+
51
+allCount
52
+===
53
+    *总数量
54
+    SELECT COUNT(1) FROM 
55
+    k_trans kt left join k_trans_monitor ktm on ktm.monitor_trans=kt.trans_id left join k_category kc on kt.category_id=kc.category_id
56
+    #use("condition")#

File diff suppressed because it is too large
+ 38 - 0
src/main/resources/sql/oracle/dimEtlConfig.md


+ 61 - 0
src/main/resources/sql/oracle/kJob.md

@@ -0,0 +1,61 @@
1
+pageQuery
2
+===
3
+    *数据库表分页查询
4
+    SELECT #use("cols")# from (
5
+    SELECT ROWNUM rn , t.* from (
6
+    SELECT #use("cols")# from 
7
+    k_job 
8
+    #use("condition")#
9
+    #use("sort")# )t
10
+    @if(!isEmpty(start)&&!isEmpty(size)){
11
+        where ROWNUM <= #start#+#size#
12
+    @}
13
+    ) tt
14
+    @if(!isEmpty(start)&&!isEmpty(size)){
15
+        where rn > #start#
16
+    @}
17
+
18
+queryByCondition
19
+===
20
+    SELECT job_Id FROM k_job #use("condition")#
21
+
22
+cols
23
+===
24
+    *列名
25
+    job_Id,
26
+    category_Id,
27
+    job_Name,
28
+    job_Description,
29
+    job_Path,
30
+    job_Quartz,
31
+    job_Status
32
+    
33
+condition
34
+===
35
+    where 1=1
36
+     @if(!isEmpty(kJob.categoryId)){
37
+            and category_id =#kJob.categoryId#
38
+     @}
39
+     @if(!isEmpty(kJob.jobName)){
40
+            and job_name like #'%'+kJob.jobName+'%'#
41
+     @}
42
+     @if(!isEmpty(kJob.addUser)){
43
+            and add_user =#kJob.addUser#
44
+     @}
45
+     @if(!isEmpty(kJob.delFlag)){
46
+            and del_flag =#kJob.delFlag#
47
+     @}
48
+     @if(!isEmpty(kJob.jobStatus)){
49
+            and job_status =#kJob.jobStatus#
50
+     @}
51
+sort
52
+===
53
+        order by add_time desc
54
+
55
+
56
+allCount
57
+===
58
+    *总数量
59
+    SELECT COUNT(1) FROM 
60
+    k_job
61
+    #use("condition")#

+ 64 - 0
src/main/resources/sql/oracle/kJobMonitor.md

@@ -0,0 +1,64 @@
1
+pageQuery
2
+===
3
+    *数据库表分页查询
4
+    SELECT #use("cols")# from (
5
+    SELECT ROWNUM rn , t.* from (
6
+    SELECT #use("cols")# from 
7
+    k_job kj left join k_job_monitor kjm on kjm.monitor_job=kj.job_id left join k_category kc on kj.category_id=kc.category_id
8
+    #use("condition")#
9
+    #use("sort")# )t
10
+    @if(!isEmpty(start)&&!isEmpty(size)){
11
+        where ROWNUM <= #start#+#size#
12
+    @}
13
+    ) tt
14
+    @if(!isEmpty(start)&&!isEmpty(size)){
15
+        where rn > #start#
16
+    @}
17
+
18
+cols
19
+===
20
+    *列名
21
+    category_name,
22
+    job_name,
23
+    monitor_Id,
24
+    monitor_Job,
25
+    last_Execute_Time,
26
+    next_Execute_Time,
27
+    monitor_Success,
28
+    monitor_Fail
29
+    
30
+condition
31
+===
32
+    where 1=1
33
+     @if(!isEmpty(kJobMonitor.jobName)){
34
+            and kj.job_name like #'%'+kJobMonitor.jobName+'%'#
35
+     @}
36
+     @if(!isEmpty(categoryId)){
37
+                      and kc.category_id =#categoryId#
38
+     @}
39
+     @if(!isEmpty(kJobMonitor.addUser)){
40
+                 and kjm.add_user =#kJobMonitor.addUser#
41
+     @}
42
+     @if(!isEmpty(kJobMonitor.monitorStatus)){
43
+                 and kjm.monitor_status =#kJobMonitor.monitorStatus#
44
+     @}
45
+sort
46
+===
47
+        order by last_execute_time desc
48
+
49
+limit
50
+===
51
+    *分页
52
+    @if(!isEmpty(start)){
53
+        limit #start#   
54
+    @}
55
+    @if(!isEmpty(size)){
56
+        ,#size#
57
+    @}
58
+
59
+allCount
60
+===
61
+    *总数量
62
+    SELECT COUNT(1) FROM 
63
+    k_job kj left join k_job_monitor kjm on kjm.monitor_job=kj.job_id left join k_category kc on kj.category_id=kc.category_id
64
+    #use("condition")#

+ 0 - 0
src/main/resources/sql/oracle/kTrans.md


Some files were not shown because too many files changed in this diff