mem_memberhealthdoc.ktr 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <transformation>
  3. <info>
  4. <name>mem_memberhealthdoc</name>
  5. <description/>
  6. <extended_description/>
  7. <trans_version/>
  8. <trans_type>Normal</trans_type>
  9. <directory>/</directory>
  10. <parameters>
  11. </parameters>
  12. <log>
  13. <trans-log-table>
  14. <connection/>
  15. <schema/>
  16. <table/>
  17. <size_limit_lines/>
  18. <interval/>
  19. <timeout_days/>
  20. <field>
  21. <id>ID_BATCH</id>
  22. <enabled>Y</enabled>
  23. <name>ID_BATCH</name>
  24. </field>
  25. <field>
  26. <id>CHANNEL_ID</id>
  27. <enabled>Y</enabled>
  28. <name>CHANNEL_ID</name>
  29. </field>
  30. <field>
  31. <id>TRANSNAME</id>
  32. <enabled>Y</enabled>
  33. <name>TRANSNAME</name>
  34. </field>
  35. <field>
  36. <id>STATUS</id>
  37. <enabled>Y</enabled>
  38. <name>STATUS</name>
  39. </field>
  40. <field>
  41. <id>LINES_READ</id>
  42. <enabled>Y</enabled>
  43. <name>LINES_READ</name>
  44. <subject/>
  45. </field>
  46. <field>
  47. <id>LINES_WRITTEN</id>
  48. <enabled>Y</enabled>
  49. <name>LINES_WRITTEN</name>
  50. <subject/>
  51. </field>
  52. <field>
  53. <id>LINES_UPDATED</id>
  54. <enabled>Y</enabled>
  55. <name>LINES_UPDATED</name>
  56. <subject/>
  57. </field>
  58. <field>
  59. <id>LINES_INPUT</id>
  60. <enabled>Y</enabled>
  61. <name>LINES_INPUT</name>
  62. <subject/>
  63. </field>
  64. <field>
  65. <id>LINES_OUTPUT</id>
  66. <enabled>Y</enabled>
  67. <name>LINES_OUTPUT</name>
  68. <subject/>
  69. </field>
  70. <field>
  71. <id>LINES_REJECTED</id>
  72. <enabled>Y</enabled>
  73. <name>LINES_REJECTED</name>
  74. <subject/>
  75. </field>
  76. <field>
  77. <id>ERRORS</id>
  78. <enabled>Y</enabled>
  79. <name>ERRORS</name>
  80. </field>
  81. <field>
  82. <id>STARTDATE</id>
  83. <enabled>Y</enabled>
  84. <name>STARTDATE</name>
  85. </field>
  86. <field>
  87. <id>ENDDATE</id>
  88. <enabled>Y</enabled>
  89. <name>ENDDATE</name>
  90. </field>
  91. <field>
  92. <id>LOGDATE</id>
  93. <enabled>Y</enabled>
  94. <name>LOGDATE</name>
  95. </field>
  96. <field>
  97. <id>DEPDATE</id>
  98. <enabled>Y</enabled>
  99. <name>DEPDATE</name>
  100. </field>
  101. <field>
  102. <id>REPLAYDATE</id>
  103. <enabled>Y</enabled>
  104. <name>REPLAYDATE</name>
  105. </field>
  106. <field>
  107. <id>LOG_FIELD</id>
  108. <enabled>Y</enabled>
  109. <name>LOG_FIELD</name>
  110. </field>
  111. <field>
  112. <id>EXECUTING_SERVER</id>
  113. <enabled>N</enabled>
  114. <name>EXECUTING_SERVER</name>
  115. </field>
  116. <field>
  117. <id>EXECUTING_USER</id>
  118. <enabled>N</enabled>
  119. <name>EXECUTING_USER</name>
  120. </field>
  121. <field>
  122. <id>CLIENT</id>
  123. <enabled>N</enabled>
  124. <name>CLIENT</name>
  125. </field>
  126. </trans-log-table>
  127. <perf-log-table>
  128. <connection/>
  129. <schema/>
  130. <table/>
  131. <interval/>
  132. <timeout_days/>
  133. <field>
  134. <id>ID_BATCH</id>
  135. <enabled>Y</enabled>
  136. <name>ID_BATCH</name>
  137. </field>
  138. <field>
  139. <id>SEQ_NR</id>
  140. <enabled>Y</enabled>
  141. <name>SEQ_NR</name>
  142. </field>
  143. <field>
  144. <id>LOGDATE</id>
  145. <enabled>Y</enabled>
  146. <name>LOGDATE</name>
  147. </field>
  148. <field>
  149. <id>TRANSNAME</id>
  150. <enabled>Y</enabled>
  151. <name>TRANSNAME</name>
  152. </field>
  153. <field>
  154. <id>STEPNAME</id>
  155. <enabled>Y</enabled>
  156. <name>STEPNAME</name>
  157. </field>
  158. <field>
  159. <id>STEP_COPY</id>
  160. <enabled>Y</enabled>
  161. <name>STEP_COPY</name>
  162. </field>
  163. <field>
  164. <id>LINES_READ</id>
  165. <enabled>Y</enabled>
  166. <name>LINES_READ</name>
  167. </field>
  168. <field>
  169. <id>LINES_WRITTEN</id>
  170. <enabled>Y</enabled>
  171. <name>LINES_WRITTEN</name>
  172. </field>
  173. <field>
  174. <id>LINES_UPDATED</id>
  175. <enabled>Y</enabled>
  176. <name>LINES_UPDATED</name>
  177. </field>
  178. <field>
  179. <id>LINES_INPUT</id>
  180. <enabled>Y</enabled>
  181. <name>LINES_INPUT</name>
  182. </field>
  183. <field>
  184. <id>LINES_OUTPUT</id>
  185. <enabled>Y</enabled>
  186. <name>LINES_OUTPUT</name>
  187. </field>
  188. <field>
  189. <id>LINES_REJECTED</id>
  190. <enabled>Y</enabled>
  191. <name>LINES_REJECTED</name>
  192. </field>
  193. <field>
  194. <id>ERRORS</id>
  195. <enabled>Y</enabled>
  196. <name>ERRORS</name>
  197. </field>
  198. <field>
  199. <id>INPUT_BUFFER_ROWS</id>
  200. <enabled>Y</enabled>
  201. <name>INPUT_BUFFER_ROWS</name>
  202. </field>
  203. <field>
  204. <id>OUTPUT_BUFFER_ROWS</id>
  205. <enabled>Y</enabled>
  206. <name>OUTPUT_BUFFER_ROWS</name>
  207. </field>
  208. </perf-log-table>
  209. <channel-log-table>
  210. <connection/>
  211. <schema/>
  212. <table/>
  213. <timeout_days/>
  214. <field>
  215. <id>ID_BATCH</id>
  216. <enabled>Y</enabled>
  217. <name>ID_BATCH</name>
  218. </field>
  219. <field>
  220. <id>CHANNEL_ID</id>
  221. <enabled>Y</enabled>
  222. <name>CHANNEL_ID</name>
  223. </field>
  224. <field>
  225. <id>LOG_DATE</id>
  226. <enabled>Y</enabled>
  227. <name>LOG_DATE</name>
  228. </field>
  229. <field>
  230. <id>LOGGING_OBJECT_TYPE</id>
  231. <enabled>Y</enabled>
  232. <name>LOGGING_OBJECT_TYPE</name>
  233. </field>
  234. <field>
  235. <id>OBJECT_NAME</id>
  236. <enabled>Y</enabled>
  237. <name>OBJECT_NAME</name>
  238. </field>
  239. <field>
  240. <id>OBJECT_COPY</id>
  241. <enabled>Y</enabled>
  242. <name>OBJECT_COPY</name>
  243. </field>
  244. <field>
  245. <id>REPOSITORY_DIRECTORY</id>
  246. <enabled>Y</enabled>
  247. <name>REPOSITORY_DIRECTORY</name>
  248. </field>
  249. <field>
  250. <id>FILENAME</id>
  251. <enabled>Y</enabled>
  252. <name>FILENAME</name>
  253. </field>
  254. <field>
  255. <id>OBJECT_ID</id>
  256. <enabled>Y</enabled>
  257. <name>OBJECT_ID</name>
  258. </field>
  259. <field>
  260. <id>OBJECT_REVISION</id>
  261. <enabled>Y</enabled>
  262. <name>OBJECT_REVISION</name>
  263. </field>
  264. <field>
  265. <id>PARENT_CHANNEL_ID</id>
  266. <enabled>Y</enabled>
  267. <name>PARENT_CHANNEL_ID</name>
  268. </field>
  269. <field>
  270. <id>ROOT_CHANNEL_ID</id>
  271. <enabled>Y</enabled>
  272. <name>ROOT_CHANNEL_ID</name>
  273. </field>
  274. </channel-log-table>
  275. <step-log-table>
  276. <connection/>
  277. <schema/>
  278. <table/>
  279. <timeout_days/>
  280. <field>
  281. <id>ID_BATCH</id>
  282. <enabled>Y</enabled>
  283. <name>ID_BATCH</name>
  284. </field>
  285. <field>
  286. <id>CHANNEL_ID</id>
  287. <enabled>Y</enabled>
  288. <name>CHANNEL_ID</name>
  289. </field>
  290. <field>
  291. <id>LOG_DATE</id>
  292. <enabled>Y</enabled>
  293. <name>LOG_DATE</name>
  294. </field>
  295. <field>
  296. <id>TRANSNAME</id>
  297. <enabled>Y</enabled>
  298. <name>TRANSNAME</name>
  299. </field>
  300. <field>
  301. <id>STEPNAME</id>
  302. <enabled>Y</enabled>
  303. <name>STEPNAME</name>
  304. </field>
  305. <field>
  306. <id>STEP_COPY</id>
  307. <enabled>Y</enabled>
  308. <name>STEP_COPY</name>
  309. </field>
  310. <field>
  311. <id>LINES_READ</id>
  312. <enabled>Y</enabled>
  313. <name>LINES_READ</name>
  314. </field>
  315. <field>
  316. <id>LINES_WRITTEN</id>
  317. <enabled>Y</enabled>
  318. <name>LINES_WRITTEN</name>
  319. </field>
  320. <field>
  321. <id>LINES_UPDATED</id>
  322. <enabled>Y</enabled>
  323. <name>LINES_UPDATED</name>
  324. </field>
  325. <field>
  326. <id>LINES_INPUT</id>
  327. <enabled>Y</enabled>
  328. <name>LINES_INPUT</name>
  329. </field>
  330. <field>
  331. <id>LINES_OUTPUT</id>
  332. <enabled>Y</enabled>
  333. <name>LINES_OUTPUT</name>
  334. </field>
  335. <field>
  336. <id>LINES_REJECTED</id>
  337. <enabled>Y</enabled>
  338. <name>LINES_REJECTED</name>
  339. </field>
  340. <field>
  341. <id>ERRORS</id>
  342. <enabled>Y</enabled>
  343. <name>ERRORS</name>
  344. </field>
  345. <field>
  346. <id>LOG_FIELD</id>
  347. <enabled>N</enabled>
  348. <name>LOG_FIELD</name>
  349. </field>
  350. </step-log-table>
  351. <metrics-log-table>
  352. <connection/>
  353. <schema/>
  354. <table/>
  355. <timeout_days/>
  356. <field>
  357. <id>ID_BATCH</id>
  358. <enabled>Y</enabled>
  359. <name>ID_BATCH</name>
  360. </field>
  361. <field>
  362. <id>CHANNEL_ID</id>
  363. <enabled>Y</enabled>
  364. <name>CHANNEL_ID</name>
  365. </field>
  366. <field>
  367. <id>LOG_DATE</id>
  368. <enabled>Y</enabled>
  369. <name>LOG_DATE</name>
  370. </field>
  371. <field>
  372. <id>METRICS_DATE</id>
  373. <enabled>Y</enabled>
  374. <name>METRICS_DATE</name>
  375. </field>
  376. <field>
  377. <id>METRICS_CODE</id>
  378. <enabled>Y</enabled>
  379. <name>METRICS_CODE</name>
  380. </field>
  381. <field>
  382. <id>METRICS_DESCRIPTION</id>
  383. <enabled>Y</enabled>
  384. <name>METRICS_DESCRIPTION</name>
  385. </field>
  386. <field>
  387. <id>METRICS_SUBJECT</id>
  388. <enabled>Y</enabled>
  389. <name>METRICS_SUBJECT</name>
  390. </field>
  391. <field>
  392. <id>METRICS_TYPE</id>
  393. <enabled>Y</enabled>
  394. <name>METRICS_TYPE</name>
  395. </field>
  396. <field>
  397. <id>METRICS_VALUE</id>
  398. <enabled>Y</enabled>
  399. <name>METRICS_VALUE</name>
  400. </field>
  401. </metrics-log-table>
  402. </log>
  403. <maxdate>
  404. <connection/>
  405. <table/>
  406. <field/>
  407. <offset>0.0</offset>
  408. <maxdiff>0.0</maxdiff>
  409. </maxdate>
  410. <size_rowset>10000</size_rowset>
  411. <sleep_time_empty>50</sleep_time_empty>
  412. <sleep_time_full>50</sleep_time_full>
  413. <unique_connections>N</unique_connections>
  414. <feedback_shown>Y</feedback_shown>
  415. <feedback_size>50000</feedback_size>
  416. <using_thread_priorities>Y</using_thread_priorities>
  417. <shared_objects_file/>
  418. <capture_step_performance>N</capture_step_performance>
  419. <step_performance_capturing_delay>1000</step_performance_capturing_delay>
  420. <step_performance_capturing_size_limit>100</step_performance_capturing_size_limit>
  421. <dependencies>
  422. </dependencies>
  423. <partitionschemas>
  424. </partitionschemas>
  425. <slaveservers>
  426. </slaveservers>
  427. <clusterschemas>
  428. </clusterschemas>
  429. <created_user>-</created_user>
  430. <created_date>2019/06/11 11:23:16.606</created_date>
  431. <modified_user>-</modified_user>
  432. <modified_date>2019/06/11 11:23:16.606</modified_date>
  433. <key_for_session_key/>
  434. <is_key_private>N</is_key_private>
  435. </info>
  436. <notepads>
  437. </notepads>
  438. <connection>
  439. <name>mall</name>
  440. <server>192.168.50.32</server>
  441. <type>MSSQLNATIVE</type>
  442. <access>Native</access>
  443. <database>Mall</database>
  444. <port>1433</port>
  445. <username>sa</username>
  446. <password>Encrypted 2be98afc819c69e8ea300ff228dd38f99</password>
  447. <servername/>
  448. <data_tablespace/>
  449. <index_tablespace/>
  450. <attributes>
  451. <attribute>
  452. <code>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
  453. <attribute>N</attribute>
  454. </attribute>
  455. <attribute>
  456. <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
  457. <attribute>N</attribute>
  458. </attribute>
  459. <attribute>
  460. <code>IS_CLUSTERED</code>
  461. <attribute>N</attribute>
  462. </attribute>
  463. <attribute>
  464. <code>MSSQLUseIntegratedSecurity</code>
  465. <attribute>false</attribute>
  466. </attribute>
  467. <attribute>
  468. <code>MSSQL_DOUBLE_DECIMAL_SEPARATOR</code>
  469. <attribute>N</attribute>
  470. </attribute>
  471. <attribute>
  472. <code>PORT_NUMBER</code>
  473. <attribute>1433</attribute>
  474. </attribute>
  475. <attribute>
  476. <code>PRESERVE_RESERVED_WORD_CASE</code>
  477. <attribute>Y</attribute>
  478. </attribute>
  479. <attribute>
  480. <code>QUOTE_ALL_FIELDS</code>
  481. <attribute>N</attribute>
  482. </attribute>
  483. <attribute>
  484. <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
  485. <attribute>Y</attribute>
  486. </attribute>
  487. <attribute>
  488. <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
  489. <attribute>Y</attribute>
  490. </attribute>
  491. <attribute>
  492. <code>USE_POOLING</code>
  493. <attribute>N</attribute>
  494. </attribute>
  495. </attributes>
  496. </connection>
  497. <order>
  498. <hop>
  499. <from>Java 代码</from>
  500. <to>Elasticsearch bulk insert 2</to>
  501. <enabled>Y</enabled>
  502. </hop>
  503. <hop>
  504. <from>memberhealth表输入</from>
  505. <to>Java 代码</to>
  506. <enabled>Y</enabled>
  507. </hop>
  508. <hop>
  509. <from>memberhealth表输入 2</from>
  510. <to>Java 代码</to>
  511. <enabled>Y</enabled>
  512. </hop>
  513. <hop>
  514. <from>memberhealth表输入 3</from>
  515. <to>Java 代码</to>
  516. <enabled>Y</enabled>
  517. </hop>
  518. </order>
  519. <step>
  520. <name>Elasticsearch bulk insert 2</name>
  521. <type>ElasticSearchBulk</type>
  522. <description/>
  523. <distribute>Y</distribute>
  524. <custom_distribution/>
  525. <copies>1</copies>
  526. <partitioning>
  527. <method>none</method>
  528. <schema_name/>
  529. </partitioning>
  530. <general>
  531. <index>crm_memberhealth</index>
  532. <type>_doc</type>
  533. <batchSize>1000</batchSize>
  534. <timeout/>
  535. <timeoutUnit>SECONDS</timeoutUnit>
  536. <isJson>N</isJson>
  537. <idField>MemberPhone</idField>
  538. <overwriteIfExists>Y</overwriteIfExists>
  539. <useOutput>N</useOutput>
  540. <stopOnError>Y</stopOnError>
  541. </general>
  542. <fields>
  543. <field>
  544. <columnName>MemberAge</columnName>
  545. <targetName>MemberAge</targetName>
  546. </field>
  547. <field>
  548. <columnName>MemberGender</columnName>
  549. <targetName>MemberGender</targetName>
  550. </field>
  551. <field>
  552. <columnName>MemberHeight</columnName>
  553. <targetName>MemberHeight</targetName>
  554. </field>
  555. <field>
  556. <columnName>MemberId</columnName>
  557. <targetName>MemberId</targetName>
  558. </field>
  559. <field>
  560. <columnName>MemberName</columnName>
  561. <targetName>MemberName</targetName>
  562. </field>
  563. <field>
  564. <columnName>MemberPhone</columnName>
  565. <targetName>MemberPhone</targetName>
  566. </field>
  567. <field>
  568. <columnName>MemberWeight</columnName>
  569. <targetName>MemberWeight</targetName>
  570. </field>
  571. </fields>
  572. <servers>
  573. <server>
  574. <address>192.168.50.32</address>
  575. <port>9300</port>
  576. </server>
  577. </servers>
  578. <settings>
  579. <setting>
  580. <name>cluster.name</name>
  581. <value>es</value>
  582. </setting>
  583. <setting>
  584. <name>custom.fields.aliase</name>
  585. <value>mem_memberhealth</value>
  586. </setting>
  587. </settings>
  588. <attributes/>
  589. <cluster_schema/>
  590. <remotesteps>
  591. <input>
  592. </input>
  593. <output>
  594. </output>
  595. </remotesteps>
  596. <GUI>
  597. <xloc>745</xloc>
  598. <yloc>204</yloc>
  599. <draw>Y</draw>
  600. </GUI>
  601. </step>
  602. <step>
  603. <name>Java 代码</name>
  604. <type>UserDefinedJavaClass</type>
  605. <description/>
  606. <distribute>N</distribute>
  607. <custom_distribution/>
  608. <copies>20</copies>
  609. <partitioning>
  610. <method>none</method>
  611. <schema_name/>
  612. </partitioning>
  613. <definitions>
  614. <definition>
  615. <class_type>TRANSFORM_CLASS</class_type>
  616. <class_name>Processor</class_name>
  617. <class_source>import java.sql.*;
  618. import org.pentaho.di.core.database.*;
  619. import org.apache.http.HttpHost;
  620. import org.elasticsearch.ElasticsearchException;
  621. import org.elasticsearch.action.get.GetRequest;
  622. import org.elasticsearch.action.get.GetResponse;
  623. import org.elasticsearch.client.RestHighLevelClient;
  624. import org.elasticsearch.client.RequestOptions;
  625. import org.elasticsearch.client.RestClient;
  626. import org.elasticsearch.common.Strings;
  627. import org.elasticsearch.rest.RestStatus;
  628. import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
  629. import org.elasticsearch.action.update.UpdateRequest;
  630. import org.elasticsearch.action.update.UpdateResponse;
  631. import org.elasticsearch.common.xcontent.XContentBuilder;
  632. import org.elasticsearch.common.xcontent.XContentFactory;
  633. import org.elasticsearch.script.Script;
  634. import java.lang.reflect.InvocationTargetException;
  635. import java.lang.reflect.Method;
  636. import com.microsoft.sqlserver.jdbc.SQLServerException;
  637. Database database = null;
  638. PreparedStatement stat = null;
  639. PreparedStatement stat1 = null;
  640. RestHighLevelClient client = new RestHighLevelClient(
  641. RestClient.builder(
  642. new HttpHost[]{new HttpHost("192.168.50.32", 9200, "http")}));
  643. Integer index = 0;
  644. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  645. {
  646. //logBasic("start---");
  647. String type = getVariable("type");
  648. String indexs = getVariable("index");
  649. //if (indexs != null) index = Integer.parseInt(indexs);
  650. Object[] r = getRow();
  651. if (r == null) {
  652. try {
  653. if (stat!=null) {
  654. stat.close();
  655. }
  656. if (stat1!=null) {
  657. stat1.close();
  658. }
  659. if (database!=null) {
  660. database.disconnect();
  661. }
  662. if(client!=null){
  663. client.close();
  664. }
  665. }
  666. catch(Exception e) {
  667. throw new KettleException(e);
  668. }
  669. setOutputDone();
  670. return false;
  671. }
  672. synchronized(this) {
  673. r = createOutputRow(r, data.outputRowMeta.size());
  674. //获取数据库名和表名
  675. String dbName = "MemberSqlServer";//getInputRowMeta().getString(r, "conname", null );
  676. String tablename = "DataImport_heathytemp";//getInputRowMeta().getString(r, "tablename", null );
  677. String idname = "MemberId";//getInputRowMeta().getString(r, "idname", null );
  678. String sourceidname = "MemberPhone";//getInputRowMeta().getString(r, "sourceidname", null );
  679. String sourcetablename = "Orders";//getInputRowMeta().getString(r, "sourcetablename", null );
  680. if (dbName==null||tablename==null) {
  681. throw new KettleException("Unable to find field with name "+tablename+" in the input row.");
  682. }
  683. //logBasic("table---"+tablename);
  684. if(database == null){
  685. //数据库连接
  686. DatabaseMeta databaseMeta=null;
  687. try {
  688. databaseMeta = getTransMeta().findDatabase(dbName);
  689. if (databaseMeta==null) {
  690. logError("A connection with name "+dbName+" could not be found!");
  691. setErrors(1);
  692. return false;
  693. }
  694. database = new Database(getTrans(), databaseMeta);
  695. database.connect();
  696. //logBasic("success!");
  697. } catch(Exception e) {
  698. logError("Connecting to database "+dbName+" failed.", e);
  699. setErrors(1);
  700. return false;
  701. }
  702. }
  703. //查询表数据
  704. try {
  705. RowMetaInterface idxRowMeta =data.outputRowMeta;
  706. int i=0;
  707. r = createOutputRow(r, data.outputRowMeta.size());
  708. //int index = getInputRowMeta().size();
  709. // Add the index name
  710. //
  711. String Id = idxRowMeta.getString(r, idname, null);
  712. // Add the column name
  713. String DataId = idxRowMeta.getString(r, sourceidname, null);
  714. /*String sqlSelect = "select Id from "+tablename + " where DataId = '"+ DataId +"'";
  715. ResultSet resultSet = null;
  716. resultSet = database.openQuery(sqlSelect);
  717. Object[] idxRow = database.getRow(resultSet);
  718. if (database!=null) {
  719. database.closeQuery(resultSet);
  720. resultSet = null;
  721. }
  722. //if(idxRow != null){
  723. // return true;
  724. //}
  725. */
  726. //logBasic("idxRow--Id"+Id);
  727. //logBasic("idxRow--sourcetablename"+sourcetablename);
  728. //logBasic("idxRow--DataId"+DataId);
  729. GetRequest getRequest = new GetRequest(
  730. "crm_memberheathytemp", // Index
  731. "_doc", // /Type
  732. DataId); // Document id
  733. getRequest.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
  734. getRequest.storedFields(new String[]{"_none_"}); // 禁止存储任何字段
  735. boolean exists = client.exists(getRequest,RequestOptions.DEFAULT);
  736. //client.close();
  737. if(exists ){
  738. return true;
  739. }
  740. //if(!exists &amp;&amp; idxRow == null){
  741. // return true;
  742. //}
  743. //3.获得预处理对象
  744. String sql="insert into "+tablename+"(Id,DataName,DataId,Type) values (?,?,?,?);";//begin tran t2; commit tran t2
  745. //logBasic("idxRow--database"+ database);
  746. index = index + 1;
  747. if(stat == null)
  748. stat = database.prepareSQL(sql);
  749. //logBasic("idxRow--database"+ stat);
  750. //stat.addBatch(sql);
  751. //4.SQL语句占位符设置实际参数
  752. stat.setString(1, Id);//索引参数1代表着sql中的第一个?号,也就是我需要将条件sid所对应的sname数据更新为“儿童玩具测试”
  753. stat.setString(2, sourcetablename);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  754. stat.setString(3, DataId);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  755. stat.setString(4, "phone1,phone2");
  756. //stat.setString(5,MemberFriendsPhone)
  757. //stat.setString(5, index);
  758. //5.执行SQL语句
  759. boolean line = stat.execute();
  760. //int[] line = stat.executeBatch();
  761. //System.out.println("更新记录数"+ line);
  762. //6.释放资源
  763. //stat.close();
  764. //setVariable("index",String.valueOf(index));
  765. //Integer pn = Integer.parseInt(Id);
  766. //Integer curpageNum = Integer.parseInt(Id) % pagesize;
  767. //if(pn > 0 &amp;&amp; curpageNum == 0){
  768. // setVariable("page",String.valueOf(page));
  769. //}
  770. //logBasic("idxRow--getVariable"+getVariable("page"));
  771. //logBasic("idxRow--curpageNum"+curpageNum);
  772. //logBasic("idxRow--length"+i);
  773. }
  774. catch(SQLServerException e) {
  775. return true;
  776. }catch(Exception e) {
  777. throw new KettleException(e);
  778. }
  779. //释放连接
  780. //if (database!=null) {
  781. // database.disconnect();
  782. //}
  783. // Send the row on to the next step.
  784. }
  785. putRow(data.outputRowMeta, r);
  786. return true;
  787. }</class_source>
  788. </definition>
  789. </definitions>
  790. <fields>
  791. </fields>
  792. <clear_result_fields>N</clear_result_fields>
  793. <info_steps/>
  794. <target_steps/>
  795. <usage_parameters/>
  796. <attributes/>
  797. <cluster_schema/>
  798. <remotesteps>
  799. <input>
  800. </input>
  801. <output>
  802. </output>
  803. </remotesteps>
  804. <GUI>
  805. <xloc>537</xloc>
  806. <yloc>268</yloc>
  807. <draw>Y</draw>
  808. </GUI>
  809. </step>
  810. <step>
  811. <name>memberhealth表输入</name>
  812. <type>TableInput</type>
  813. <description/>
  814. <distribute>Y</distribute>
  815. <custom_distribution/>
  816. <copies>1</copies>
  817. <partitioning>
  818. <method>none</method>
  819. <schema_name/>
  820. </partitioning>
  821. <connection>mall</connection>
  822. <sql>SELECT
  823. a.BuyUserId AS MemberId,
  824. a.Consignee AS MemberName,
  825. a.Height AS MemberHeight,
  826. a.Weight AS MemberWeight,
  827. CASE WHEN b.Gender IS NULL THEN a.Sex END AS MemberGender,
  828. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) AS MemberPhone,
  829. b.age as MemberAge
  830. FROM
  831. [Mall].[dbo].[Orders] a
  832. LEFT JOIN
  833. [Mall]..PrescriptionRecord AS b ON a.OrdersCode = b.OrdersCode
  834. WHERE AConsigneePhone1 !=''
  835. order by a.BuyUserId</sql>
  836. <limit>0</limit>
  837. <lookup/>
  838. <execute_each_row>N</execute_each_row>
  839. <variables_active>N</variables_active>
  840. <lazy_conversion_active>N</lazy_conversion_active>
  841. <attributes/>
  842. <cluster_schema/>
  843. <remotesteps>
  844. <input>
  845. </input>
  846. <output>
  847. </output>
  848. </remotesteps>
  849. <GUI>
  850. <xloc>393</xloc>
  851. <yloc>156</yloc>
  852. <draw>Y</draw>
  853. </GUI>
  854. </step>
  855. <step>
  856. <name>memberhealth表输入 2</name>
  857. <type>TableInput</type>
  858. <description/>
  859. <distribute>Y</distribute>
  860. <custom_distribution/>
  861. <copies>1</copies>
  862. <partitioning>
  863. <method>none</method>
  864. <schema_name/>
  865. </partitioning>
  866. <connection>mall</connection>
  867. <sql>SELECT
  868. a.BuyUserId AS MemberId,
  869. a.Consignee AS MemberName,
  870. a.Height AS MemberHeight,
  871. a.Weight AS MemberWeight,
  872. CASE WHEN b.Gender IS NULL THEN a.Sex END AS MemberGender,
  873. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) AS MemberPhone,
  874. b.age as MemberAge
  875. FROM
  876. [Mall].[dbo].[Orders] a
  877. LEFT JOIN
  878. [Mall]..PrescriptionRecord AS b ON a.OrdersCode = b.OrdersCode
  879. WHERE AConsigneePhone2 !=''
  880. order by a.BuyUserId</sql>
  881. <limit>0</limit>
  882. <lookup/>
  883. <execute_each_row>N</execute_each_row>
  884. <variables_active>N</variables_active>
  885. <lazy_conversion_active>N</lazy_conversion_active>
  886. <attributes/>
  887. <cluster_schema/>
  888. <remotesteps>
  889. <input>
  890. </input>
  891. <output>
  892. </output>
  893. </remotesteps>
  894. <GUI>
  895. <xloc>361</xloc>
  896. <yloc>236</yloc>
  897. <draw>Y</draw>
  898. </GUI>
  899. </step>
  900. <step>
  901. <name>memberhealth表输入 3</name>
  902. <type>TableInput</type>
  903. <description/>
  904. <distribute>Y</distribute>
  905. <custom_distribution/>
  906. <copies>1</copies>
  907. <partitioning>
  908. <method>none</method>
  909. <schema_name/>
  910. </partitioning>
  911. <connection>mall</connection>
  912. <sql>SELECT
  913. a.BuyUserId AS MemberId,
  914. a.Consignee AS MemberName,
  915. a.Height AS MemberHeight,
  916. a.Weight AS MemberWeight,
  917. CASE WHEN b.Gender IS NULL THEN a.Sex END AS MemberGender,
  918. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3) AS MemberPhone,
  919. b.age as MemberAge
  920. FROM
  921. [Mall].[dbo].[Orders] a
  922. LEFT JOIN
  923. [Mall]..PrescriptionRecord AS b ON a.OrdersCode = b.OrdersCode
  924. WHERE AConsigneePhone3 !=''
  925. order by a.BuyUserId</sql>
  926. <limit>0</limit>
  927. <lookup/>
  928. <execute_each_row>N</execute_each_row>
  929. <variables_active>N</variables_active>
  930. <lazy_conversion_active>N</lazy_conversion_active>
  931. <attributes/>
  932. <cluster_schema/>
  933. <remotesteps>
  934. <input>
  935. </input>
  936. <output>
  937. </output>
  938. </remotesteps>
  939. <GUI>
  940. <xloc>412</xloc>
  941. <yloc>332</yloc>
  942. <draw>Y</draw>
  943. </GUI>
  944. </step>
  945. <step_error_handling>
  946. </step_error_handling>
  947. <slave-step-copy-partition-distribution>
  948. </slave-step-copy-partition-distribution>
  949. <slave_transformation>N</slave_transformation>
  950. <attributes/>
  951. </transformation>