mem_memberbase_append_memberId.ktr 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <transformation>
  3. <info>
  4. <name>mem_memberbase_append_memberId</name>
  5. <description/>
  6. <extended_description/>
  7. <trans_version/>
  8. <trans_type>Normal</trans_type>
  9. <trans_status>0</trans_status>
  10. <directory>/</directory>
  11. <parameters>
  12. </parameters>
  13. <log>
  14. <trans-log-table>
  15. <connection/>
  16. <schema/>
  17. <table/>
  18. <size_limit_lines/>
  19. <interval/>
  20. <timeout_days/>
  21. <field>
  22. <id>ID_BATCH</id>
  23. <enabled>Y</enabled>
  24. <name>ID_BATCH</name>
  25. </field>
  26. <field>
  27. <id>CHANNEL_ID</id>
  28. <enabled>Y</enabled>
  29. <name>CHANNEL_ID</name>
  30. </field>
  31. <field>
  32. <id>TRANSNAME</id>
  33. <enabled>Y</enabled>
  34. <name>TRANSNAME</name>
  35. </field>
  36. <field>
  37. <id>STATUS</id>
  38. <enabled>Y</enabled>
  39. <name>STATUS</name>
  40. </field>
  41. <field>
  42. <id>LINES_READ</id>
  43. <enabled>Y</enabled>
  44. <name>LINES_READ</name>
  45. <subject/>
  46. </field>
  47. <field>
  48. <id>LINES_WRITTEN</id>
  49. <enabled>Y</enabled>
  50. <name>LINES_WRITTEN</name>
  51. <subject/>
  52. </field>
  53. <field>
  54. <id>LINES_UPDATED</id>
  55. <enabled>Y</enabled>
  56. <name>LINES_UPDATED</name>
  57. <subject/>
  58. </field>
  59. <field>
  60. <id>LINES_INPUT</id>
  61. <enabled>Y</enabled>
  62. <name>LINES_INPUT</name>
  63. <subject/>
  64. </field>
  65. <field>
  66. <id>LINES_OUTPUT</id>
  67. <enabled>Y</enabled>
  68. <name>LINES_OUTPUT</name>
  69. <subject/>
  70. </field>
  71. <field>
  72. <id>LINES_REJECTED</id>
  73. <enabled>Y</enabled>
  74. <name>LINES_REJECTED</name>
  75. <subject/>
  76. </field>
  77. <field>
  78. <id>ERRORS</id>
  79. <enabled>Y</enabled>
  80. <name>ERRORS</name>
  81. </field>
  82. <field>
  83. <id>STARTDATE</id>
  84. <enabled>Y</enabled>
  85. <name>STARTDATE</name>
  86. </field>
  87. <field>
  88. <id>ENDDATE</id>
  89. <enabled>Y</enabled>
  90. <name>ENDDATE</name>
  91. </field>
  92. <field>
  93. <id>LOGDATE</id>
  94. <enabled>Y</enabled>
  95. <name>LOGDATE</name>
  96. </field>
  97. <field>
  98. <id>DEPDATE</id>
  99. <enabled>Y</enabled>
  100. <name>DEPDATE</name>
  101. </field>
  102. <field>
  103. <id>REPLAYDATE</id>
  104. <enabled>Y</enabled>
  105. <name>REPLAYDATE</name>
  106. </field>
  107. <field>
  108. <id>LOG_FIELD</id>
  109. <enabled>Y</enabled>
  110. <name>LOG_FIELD</name>
  111. </field>
  112. <field>
  113. <id>EXECUTING_SERVER</id>
  114. <enabled>N</enabled>
  115. <name>EXECUTING_SERVER</name>
  116. </field>
  117. <field>
  118. <id>EXECUTING_USER</id>
  119. <enabled>N</enabled>
  120. <name>EXECUTING_USER</name>
  121. </field>
  122. <field>
  123. <id>CLIENT</id>
  124. <enabled>N</enabled>
  125. <name>CLIENT</name>
  126. </field>
  127. </trans-log-table>
  128. <perf-log-table>
  129. <connection/>
  130. <schema/>
  131. <table/>
  132. <interval/>
  133. <timeout_days/>
  134. <field>
  135. <id>ID_BATCH</id>
  136. <enabled>Y</enabled>
  137. <name>ID_BATCH</name>
  138. </field>
  139. <field>
  140. <id>SEQ_NR</id>
  141. <enabled>Y</enabled>
  142. <name>SEQ_NR</name>
  143. </field>
  144. <field>
  145. <id>LOGDATE</id>
  146. <enabled>Y</enabled>
  147. <name>LOGDATE</name>
  148. </field>
  149. <field>
  150. <id>TRANSNAME</id>
  151. <enabled>Y</enabled>
  152. <name>TRANSNAME</name>
  153. </field>
  154. <field>
  155. <id>STEPNAME</id>
  156. <enabled>Y</enabled>
  157. <name>STEPNAME</name>
  158. </field>
  159. <field>
  160. <id>STEP_COPY</id>
  161. <enabled>Y</enabled>
  162. <name>STEP_COPY</name>
  163. </field>
  164. <field>
  165. <id>LINES_READ</id>
  166. <enabled>Y</enabled>
  167. <name>LINES_READ</name>
  168. </field>
  169. <field>
  170. <id>LINES_WRITTEN</id>
  171. <enabled>Y</enabled>
  172. <name>LINES_WRITTEN</name>
  173. </field>
  174. <field>
  175. <id>LINES_UPDATED</id>
  176. <enabled>Y</enabled>
  177. <name>LINES_UPDATED</name>
  178. </field>
  179. <field>
  180. <id>LINES_INPUT</id>
  181. <enabled>Y</enabled>
  182. <name>LINES_INPUT</name>
  183. </field>
  184. <field>
  185. <id>LINES_OUTPUT</id>
  186. <enabled>Y</enabled>
  187. <name>LINES_OUTPUT</name>
  188. </field>
  189. <field>
  190. <id>LINES_REJECTED</id>
  191. <enabled>Y</enabled>
  192. <name>LINES_REJECTED</name>
  193. </field>
  194. <field>
  195. <id>ERRORS</id>
  196. <enabled>Y</enabled>
  197. <name>ERRORS</name>
  198. </field>
  199. <field>
  200. <id>INPUT_BUFFER_ROWS</id>
  201. <enabled>Y</enabled>
  202. <name>INPUT_BUFFER_ROWS</name>
  203. </field>
  204. <field>
  205. <id>OUTPUT_BUFFER_ROWS</id>
  206. <enabled>Y</enabled>
  207. <name>OUTPUT_BUFFER_ROWS</name>
  208. </field>
  209. </perf-log-table>
  210. <channel-log-table>
  211. <connection/>
  212. <schema/>
  213. <table/>
  214. <timeout_days/>
  215. <field>
  216. <id>ID_BATCH</id>
  217. <enabled>Y</enabled>
  218. <name>ID_BATCH</name>
  219. </field>
  220. <field>
  221. <id>CHANNEL_ID</id>
  222. <enabled>Y</enabled>
  223. <name>CHANNEL_ID</name>
  224. </field>
  225. <field>
  226. <id>LOG_DATE</id>
  227. <enabled>Y</enabled>
  228. <name>LOG_DATE</name>
  229. </field>
  230. <field>
  231. <id>LOGGING_OBJECT_TYPE</id>
  232. <enabled>Y</enabled>
  233. <name>LOGGING_OBJECT_TYPE</name>
  234. </field>
  235. <field>
  236. <id>OBJECT_NAME</id>
  237. <enabled>Y</enabled>
  238. <name>OBJECT_NAME</name>
  239. </field>
  240. <field>
  241. <id>OBJECT_COPY</id>
  242. <enabled>Y</enabled>
  243. <name>OBJECT_COPY</name>
  244. </field>
  245. <field>
  246. <id>REPOSITORY_DIRECTORY</id>
  247. <enabled>Y</enabled>
  248. <name>REPOSITORY_DIRECTORY</name>
  249. </field>
  250. <field>
  251. <id>FILENAME</id>
  252. <enabled>Y</enabled>
  253. <name>FILENAME</name>
  254. </field>
  255. <field>
  256. <id>OBJECT_ID</id>
  257. <enabled>Y</enabled>
  258. <name>OBJECT_ID</name>
  259. </field>
  260. <field>
  261. <id>OBJECT_REVISION</id>
  262. <enabled>Y</enabled>
  263. <name>OBJECT_REVISION</name>
  264. </field>
  265. <field>
  266. <id>PARENT_CHANNEL_ID</id>
  267. <enabled>Y</enabled>
  268. <name>PARENT_CHANNEL_ID</name>
  269. </field>
  270. <field>
  271. <id>ROOT_CHANNEL_ID</id>
  272. <enabled>Y</enabled>
  273. <name>ROOT_CHANNEL_ID</name>
  274. </field>
  275. </channel-log-table>
  276. <step-log-table>
  277. <connection/>
  278. <schema/>
  279. <table/>
  280. <timeout_days/>
  281. <field>
  282. <id>ID_BATCH</id>
  283. <enabled>Y</enabled>
  284. <name>ID_BATCH</name>
  285. </field>
  286. <field>
  287. <id>CHANNEL_ID</id>
  288. <enabled>Y</enabled>
  289. <name>CHANNEL_ID</name>
  290. </field>
  291. <field>
  292. <id>LOG_DATE</id>
  293. <enabled>Y</enabled>
  294. <name>LOG_DATE</name>
  295. </field>
  296. <field>
  297. <id>TRANSNAME</id>
  298. <enabled>Y</enabled>
  299. <name>TRANSNAME</name>
  300. </field>
  301. <field>
  302. <id>STEPNAME</id>
  303. <enabled>Y</enabled>
  304. <name>STEPNAME</name>
  305. </field>
  306. <field>
  307. <id>STEP_COPY</id>
  308. <enabled>Y</enabled>
  309. <name>STEP_COPY</name>
  310. </field>
  311. <field>
  312. <id>LINES_READ</id>
  313. <enabled>Y</enabled>
  314. <name>LINES_READ</name>
  315. </field>
  316. <field>
  317. <id>LINES_WRITTEN</id>
  318. <enabled>Y</enabled>
  319. <name>LINES_WRITTEN</name>
  320. </field>
  321. <field>
  322. <id>LINES_UPDATED</id>
  323. <enabled>Y</enabled>
  324. <name>LINES_UPDATED</name>
  325. </field>
  326. <field>
  327. <id>LINES_INPUT</id>
  328. <enabled>Y</enabled>
  329. <name>LINES_INPUT</name>
  330. </field>
  331. <field>
  332. <id>LINES_OUTPUT</id>
  333. <enabled>Y</enabled>
  334. <name>LINES_OUTPUT</name>
  335. </field>
  336. <field>
  337. <id>LINES_REJECTED</id>
  338. <enabled>Y</enabled>
  339. <name>LINES_REJECTED</name>
  340. </field>
  341. <field>
  342. <id>ERRORS</id>
  343. <enabled>Y</enabled>
  344. <name>ERRORS</name>
  345. </field>
  346. <field>
  347. <id>LOG_FIELD</id>
  348. <enabled>N</enabled>
  349. <name>LOG_FIELD</name>
  350. </field>
  351. </step-log-table>
  352. <metrics-log-table>
  353. <connection/>
  354. <schema/>
  355. <table/>
  356. <timeout_days/>
  357. <field>
  358. <id>ID_BATCH</id>
  359. <enabled>Y</enabled>
  360. <name>ID_BATCH</name>
  361. </field>
  362. <field>
  363. <id>CHANNEL_ID</id>
  364. <enabled>Y</enabled>
  365. <name>CHANNEL_ID</name>
  366. </field>
  367. <field>
  368. <id>LOG_DATE</id>
  369. <enabled>Y</enabled>
  370. <name>LOG_DATE</name>
  371. </field>
  372. <field>
  373. <id>METRICS_DATE</id>
  374. <enabled>Y</enabled>
  375. <name>METRICS_DATE</name>
  376. </field>
  377. <field>
  378. <id>METRICS_CODE</id>
  379. <enabled>Y</enabled>
  380. <name>METRICS_CODE</name>
  381. </field>
  382. <field>
  383. <id>METRICS_DESCRIPTION</id>
  384. <enabled>Y</enabled>
  385. <name>METRICS_DESCRIPTION</name>
  386. </field>
  387. <field>
  388. <id>METRICS_SUBJECT</id>
  389. <enabled>Y</enabled>
  390. <name>METRICS_SUBJECT</name>
  391. </field>
  392. <field>
  393. <id>METRICS_TYPE</id>
  394. <enabled>Y</enabled>
  395. <name>METRICS_TYPE</name>
  396. </field>
  397. <field>
  398. <id>METRICS_VALUE</id>
  399. <enabled>Y</enabled>
  400. <name>METRICS_VALUE</name>
  401. </field>
  402. </metrics-log-table>
  403. </log>
  404. <maxdate>
  405. <connection/>
  406. <table/>
  407. <field/>
  408. <offset>0.0</offset>
  409. <maxdiff>0.0</maxdiff>
  410. </maxdate>
  411. <size_rowset>3</size_rowset>
  412. <sleep_time_empty>50</sleep_time_empty>
  413. <sleep_time_full>50</sleep_time_full>
  414. <unique_connections>N</unique_connections>
  415. <feedback_shown>Y</feedback_shown>
  416. <feedback_size>50000</feedback_size>
  417. <using_thread_priorities>Y</using_thread_priorities>
  418. <shared_objects_file/>
  419. <capture_step_performance>N</capture_step_performance>
  420. <step_performance_capturing_delay>1000</step_performance_capturing_delay>
  421. <step_performance_capturing_size_limit>100</step_performance_capturing_size_limit>
  422. <dependencies>
  423. </dependencies>
  424. <partitionschemas>
  425. </partitionschemas>
  426. <slaveservers>
  427. </slaveservers>
  428. <clusterschemas>
  429. </clusterschemas>
  430. <created_user>-</created_user>
  431. <created_date>2019/05/21 19:06:33.293</created_date>
  432. <modified_user>-</modified_user>
  433. <modified_date>2019/05/21 19:06:33.293</modified_date>
  434. <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
  435. <is_key_private>N</is_key_private>
  436. </info>
  437. <notepads>
  438. </notepads>
  439. <connection>
  440. <name>MemberSqlserver</name>
  441. <server>192.168.50.32</server>
  442. <type>MSSQLNATIVE</type>
  443. <access>Native</access>
  444. <database>MemberData</database>
  445. <port>1433</port>
  446. <username>sa</username>
  447. <password>Encrypted 2be98afc819c69e8ea300ff228dd38f99</password>
  448. <servername/>
  449. <data_tablespace/>
  450. <index_tablespace/>
  451. <attributes>
  452. <attribute>
  453. <code>EXTRA_OPTION_MSSQLNATIVE.instance</code>
  454. <attribute>MemberData</attribute>
  455. </attribute>
  456. <attribute>
  457. <code>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
  458. <attribute>N</attribute>
  459. </attribute>
  460. <attribute>
  461. <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
  462. <attribute>N</attribute>
  463. </attribute>
  464. <attribute>
  465. <code>INITIAL_POOL_SIZE</code>
  466. <attribute>100</attribute>
  467. </attribute>
  468. <attribute>
  469. <code>IS_CLUSTERED</code>
  470. <attribute>N</attribute>
  471. </attribute>
  472. <attribute>
  473. <code>MAXIMUM_POOL_SIZE</code>
  474. <attribute>300</attribute>
  475. </attribute>
  476. <attribute>
  477. <code>MSSQLUseIntegratedSecurity</code>
  478. <attribute>false</attribute>
  479. </attribute>
  480. <attribute>
  481. <code>MSSQL_DOUBLE_DECIMAL_SEPARATOR</code>
  482. <attribute>N</attribute>
  483. </attribute>
  484. <attribute>
  485. <code>PORT_NUMBER</code>
  486. <attribute>1433</attribute>
  487. </attribute>
  488. <attribute>
  489. <code>PRESERVE_RESERVED_WORD_CASE</code>
  490. <attribute>Y</attribute>
  491. </attribute>
  492. <attribute>
  493. <code>QUOTE_ALL_FIELDS</code>
  494. <attribute>N</attribute>
  495. </attribute>
  496. <attribute>
  497. <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
  498. <attribute>Y</attribute>
  499. </attribute>
  500. <attribute>
  501. <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
  502. <attribute>Y</attribute>
  503. </attribute>
  504. <attribute>
  505. <code>USE_POOLING</code>
  506. <attribute>Y</attribute>
  507. </attribute>
  508. </attributes>
  509. </connection>
  510. <order>
  511. <hop>
  512. <from>表输入 2</from>
  513. <to>Java 代码</to>
  514. <enabled>Y</enabled>
  515. </hop>
  516. </order>
  517. <step>
  518. <name>Java 代码</name>
  519. <type>UserDefinedJavaClass</type>
  520. <description/>
  521. <distribute>Y</distribute>
  522. <custom_distribution/>
  523. <copies>10</copies>
  524. <partitioning>
  525. <method>none</method>
  526. <schema_name/>
  527. </partitioning>
  528. <definitions>
  529. <definition>
  530. <class_type>TRANSFORM_CLASS</class_type>
  531. <class_name>Processor</class_name>
  532. <class_source>import java.sql.*;
  533. import org.pentaho.di.core.database.*;
  534. import org.apache.http.HttpHost;
  535. import org.elasticsearch.ElasticsearchException;
  536. import org.elasticsearch.action.get.GetRequest;
  537. import org.elasticsearch.action.get.GetResponse;
  538. import org.elasticsearch.client.RestHighLevelClient;
  539. import org.elasticsearch.client.RequestOptions;
  540. import org.elasticsearch.client.RestClient;
  541. import org.elasticsearch.common.Strings;
  542. import org.elasticsearch.rest.RestStatus;
  543. import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
  544. import org.elasticsearch.action.update.UpdateRequest;
  545. import org.elasticsearch.action.update.UpdateResponse;
  546. import org.elasticsearch.common.xcontent.XContentBuilder;
  547. import org.elasticsearch.common.xcontent.XContentFactory;
  548. import org.elasticsearch.script.Script;
  549. Database database = null;
  550. PreparedStatement stat = null;
  551. PreparedStatement stat1 = null;
  552. RestHighLevelClient client = new RestHighLevelClient(
  553. RestClient.builder(
  554. new HttpHost[]{new HttpHost("192.168.50.32", 9200, "http")}));
  555. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  556. {
  557. //logBasic("start---");
  558. Object[] r = getRow();
  559. if (r == null) {
  560. try {
  561. if (stat!=null) {
  562. stat.close();
  563. }
  564. if (stat1!=null) {
  565. stat1.close();
  566. }
  567. if (database!=null) {
  568. database.disconnect();
  569. }
  570. if(client!=null){
  571. client.close();
  572. }
  573. }
  574. catch(Exception e) {
  575. throw new KettleException(e);
  576. }
  577. setOutputDone();
  578. return false;
  579. }
  580. synchronized(this) {
  581. r = createOutputRow(r, data.outputRowMeta.size());
  582. //获取数据库名和表名
  583. String dbName = "MemberSqlServer";//getInputRowMeta().getString(r, "conname", null );
  584. String tablename = "DataImport";//getInputRowMeta().getString(r, "tablename", null );
  585. String idname = "Id";//getInputRowMeta().getString(r, "idname", null );
  586. String idname1 = "MemPhone1";//getInputRowMeta().getString(r, "idname", null );
  587. String idname2 = "MemPhone2";//getInputRowMeta().getString(r, "idname", null );
  588. String idname3 = "MemPhone3";//getInputRowMeta().getString(r, "idname", null );
  589. String idname4 = "MemberId";//getInputRowMeta().getString(r, "idname", null );
  590. String idname5 = "OrdersCode";//getInputRowMeta().getString(r, "idname", null );
  591. String sourceidname = "DataId";//getInputRowMeta().getString(r, "sourceidname", null );
  592. String sourcetablename = "Order";//getInputRowMeta().getString(r, "sourcetablename", null );
  593. if (dbName==null||tablename==null) {
  594. throw new KettleException("Unable to find field with name "+tablename+" in the input row.");
  595. }
  596. //logBasic("table---"+tablename);
  597. if(database == null){
  598. //数据库连接
  599. DatabaseMeta databaseMeta=null;
  600. try {
  601. databaseMeta = getTransMeta().findDatabase(dbName);
  602. if (databaseMeta==null) {
  603. logError("A connection with name "+dbName+" could not be found!");
  604. setErrors(1);
  605. return false;
  606. }
  607. database = new Database(getTrans(), databaseMeta);
  608. database.connect();
  609. //logBasic("success!");
  610. } catch(Exception e) {
  611. logError("Connecting to database "+dbName+" failed.", e);
  612. setErrors(1);
  613. return false;
  614. }
  615. }
  616. //查询表数据
  617. try {
  618. RowMetaInterface idxRowMeta =data.outputRowMeta;
  619. int i=0;
  620. r = createOutputRow(r, data.outputRowMeta.size());
  621. //int index = getInputRowMeta().size();
  622. // Add the index name
  623. //
  624. String Id = idxRowMeta.getString(r, idname, null);
  625. String Id1 = idxRowMeta.getString(r, idname1, null);
  626. String Id2 = idxRowMeta.getString(r, idname2, null);
  627. String Id3 = idxRowMeta.getString(r, idname3, null);
  628. String Id4 = idxRowMeta.getString(r, idname4, null);
  629. String Id5 = idxRowMeta.getString(r, idname5, null);
  630. // Add the column name
  631. String DataId = idxRowMeta.getString(r, sourceidname, null);
  632. /*//String sqlSelect = "select Id from "+tablename + " where DataId = '"+ DataId +"'";
  633. String sqlSelect = "select Id from "+tablename + "_mem where Id = '"+ Id +"'";
  634. ResultSet resultSet = null;
  635. resultSet = database.openQuery(sqlSelect);
  636. Object[] idxRow = database.getRow(resultSet);
  637. if(idxRow!=null){
  638. if (database!=null) {
  639. database.closeQuery(resultSet);
  640. }
  641. return true;
  642. }*/
  643. //logBasic("idxRow--Id"+Id);
  644. //logBasic("idxRow--sourcetablename"+sourcetablename);
  645. //logBasic("idxRow--DataId"+DataId);
  646. GetRequest getRequest = new GetRequest(
  647. "crm_memberbase", // Index
  648. "_doc", // Type
  649. Id); // Document id
  650. getRequest.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
  651. getRequest.storedFields(new String[]{"_none_"}); // 禁止存储任何字段
  652. boolean exists = client.exists(getRequest,RequestOptions.DEFAULT);
  653. //client.close();
  654. if(exists) {
  655. UpdateRequest updateRequest = new UpdateRequest();
  656. updateRequest.index("crm_memberbase");
  657. updateRequest.type("_doc");
  658. updateRequest.id(Id);
  659. updateRequest.doc(XContentFactory.jsonBuilder()
  660. .startObject()
  661. .field(idname1, Id1)
  662. .field(idname2, Id2)
  663. .field(idname3, Id3)
  664. .field(idname4, Id4)
  665. .field(idname5, Id5)
  666. .endObject());
  667. client.update(updateRequest,RequestOptions.DEFAULT);
  668. }
  669. //logBasic("idxRow--length"+i);
  670. }
  671. catch(Exception e) {
  672. throw new KettleException(e);
  673. }
  674. //释放连接
  675. //if (database!=null) {
  676. // database.disconnect();
  677. //}
  678. // Send the row on to the next step.
  679. }
  680. putRow(data.outputRowMeta, r);
  681. return true;
  682. }</class_source>
  683. </definition>
  684. </definitions>
  685. <fields>
  686. </fields>
  687. <clear_result_fields>N</clear_result_fields>
  688. <info_steps/>
  689. <target_steps/>
  690. <usage_parameters/>
  691. <attributes/>
  692. <cluster_schema/>
  693. <remotesteps>
  694. <input>
  695. </input>
  696. <output>
  697. </output>
  698. </remotesteps>
  699. <GUI>
  700. <xloc>288</xloc>
  701. <yloc>96</yloc>
  702. <draw>Y</draw>
  703. </GUI>
  704. </step>
  705. <step>
  706. <name>表输入 2</name>
  707. <type>TableInput</type>
  708. <description/>
  709. <distribute>Y</distribute>
  710. <custom_distribution/>
  711. <copies>1</copies>
  712. <partitioning>
  713. <method>none</method>
  714. <schema_name/>
  715. </partitioning>
  716. <connection>MemberSqlserver</connection>
  717. <sql>
  718. select *
  719. --,concat('{"name": "Order","parent": "',MemKey,'"}')as order_join_field
  720. from (
  721. SELECT
  722. row_number() over (order by AConsigneePhone2 asc ) as MemKey,
  723. AconsigneePhone2,
  724. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AconsigneePhone1 ) as MemPhone1,
  725. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AconsigneePhone2 ) as MemPhone2,
  726. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AconsigneePhone3 ) as MemPhone3,
  727. BuyUserId as MemberId
  728. , OrdersCode
  729. from Mall..Orders
  730. where 1=1 and (AconsigneePhone1!='' or AconsigneePhone2!='')
  731. --order by AConsigneePhone2 asc
  732. --offset 0 rows fetch NEXT 2 rows only
  733. )a
  734. left join MemberData..DataImport as b on a.MemKey = b.Id
  735. --dbo.DesEncryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',b.dataid ) = (case when AConsigneePhone2= '' then
  736. --(case
  737. -- when AconsigneePhone1!='' then AconsigneePhone1
  738. -- else ''end)
  739. -- ELSE AconsigneePhone2 end)
  740. where
  741. 1=1
  742. and b.Id is not null
  743. and MemKey >(108-1)*5000 --and MemKey &lt;= 10
  744. --MemKey >((${page}-1)*${pagesize}) and MemKey &lt;= ((${page}-1)*${pagesize} + (${pagesize}))
  745. --order by a.AConsigneePhone2 asc
  746. --offset ((14-1)*5000) rows --fetch next (10) rows only</sql>
  747. <limit>0</limit>
  748. <lookup/>
  749. <execute_each_row>N</execute_each_row>
  750. <variables_active>N</variables_active>
  751. <lazy_conversion_active>N</lazy_conversion_active>
  752. <attributes/>
  753. <cluster_schema/>
  754. <remotesteps>
  755. <input>
  756. </input>
  757. <output>
  758. </output>
  759. </remotesteps>
  760. <GUI>
  761. <xloc>192</xloc>
  762. <yloc>32</yloc>
  763. <draw>Y</draw>
  764. </GUI>
  765. </step>
  766. <step_error_handling>
  767. </step_error_handling>
  768. <slave-step-copy-partition-distribution>
  769. </slave-step-copy-partition-distribution>
  770. <slave_transformation>N</slave_transformation>
  771. <attributes/>
  772. </transformation>