mem_memberfriends.ktr 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <transformation>
  3. <info>
  4. <name>mem_memberfriends</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>5</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/06/10 16:15:14.565</created_date>
  432. <modified_user>-</modified_user>
  433. <modified_date>2019/06/10 16:15:14.565</modified_date>
  434. <key_for_session_key/>
  435. <is_key_private>N</is_key_private>
  436. </info>
  437. <notepads>
  438. </notepads>
  439. <connection>
  440. <name>mall</name>
  441. <server>192.168.50.32</server>
  442. <type>MSSQLNATIVE</type>
  443. <access>Native</access>
  444. <database>Mall</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>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
  454. <attribute>N</attribute>
  455. </attribute>
  456. <attribute>
  457. <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
  458. <attribute>N</attribute>
  459. </attribute>
  460. <attribute>
  461. <code>IS_CLUSTERED</code>
  462. <attribute>N</attribute>
  463. </attribute>
  464. <attribute>
  465. <code>MSSQLUseIntegratedSecurity</code>
  466. <attribute>false</attribute>
  467. </attribute>
  468. <attribute>
  469. <code>MSSQL_DOUBLE_DECIMAL_SEPARATOR</code>
  470. <attribute>N</attribute>
  471. </attribute>
  472. <attribute>
  473. <code>PORT_NUMBER</code>
  474. <attribute>1433</attribute>
  475. </attribute>
  476. <attribute>
  477. <code>PRESERVE_RESERVED_WORD_CASE</code>
  478. <attribute>Y</attribute>
  479. </attribute>
  480. <attribute>
  481. <code>QUOTE_ALL_FIELDS</code>
  482. <attribute>N</attribute>
  483. </attribute>
  484. <attribute>
  485. <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
  486. <attribute>Y</attribute>
  487. </attribute>
  488. <attribute>
  489. <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
  490. <attribute>Y</attribute>
  491. </attribute>
  492. <attribute>
  493. <code>USE_POOLING</code>
  494. <attribute>N</attribute>
  495. </attribute>
  496. </attributes>
  497. </connection>
  498. <connection>
  499. <name>memberdata</name>
  500. <server>192.168.50.32</server>
  501. <type>MSSQLNATIVE</type>
  502. <access>Native</access>
  503. <database>MemberData</database>
  504. <port>1433</port>
  505. <username>sa</username>
  506. <password>Encrypted 2be98afc819c69e8ea300ff228dd38f99</password>
  507. <servername/>
  508. <data_tablespace/>
  509. <index_tablespace/>
  510. <attributes>
  511. <attribute>
  512. <code>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
  513. <attribute>N</attribute>
  514. </attribute>
  515. <attribute>
  516. <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
  517. <attribute>N</attribute>
  518. </attribute>
  519. <attribute>
  520. <code>IS_CLUSTERED</code>
  521. <attribute>N</attribute>
  522. </attribute>
  523. <attribute>
  524. <code>MSSQLUseIntegratedSecurity</code>
  525. <attribute>false</attribute>
  526. </attribute>
  527. <attribute>
  528. <code>MSSQL_DOUBLE_DECIMAL_SEPARATOR</code>
  529. <attribute>N</attribute>
  530. </attribute>
  531. <attribute>
  532. <code>PORT_NUMBER</code>
  533. <attribute>1433</attribute>
  534. </attribute>
  535. <attribute>
  536. <code>PRESERVE_RESERVED_WORD_CASE</code>
  537. <attribute>Y</attribute>
  538. </attribute>
  539. <attribute>
  540. <code>QUOTE_ALL_FIELDS</code>
  541. <attribute>N</attribute>
  542. </attribute>
  543. <attribute>
  544. <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
  545. <attribute>Y</attribute>
  546. </attribute>
  547. <attribute>
  548. <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
  549. <attribute>Y</attribute>
  550. </attribute>
  551. <attribute>
  552. <code>USE_POOLING</code>
  553. <attribute>N</attribute>
  554. </attribute>
  555. </attributes>
  556. </connection>
  557. <order>
  558. <hop>
  559. <from>memberfriends表输入</from>
  560. <to>Java 代码</to>
  561. <enabled>Y</enabled>
  562. </hop>
  563. <hop>
  564. <from>Java 代码</from>
  565. <to>表输出</to>
  566. <enabled>Y</enabled>
  567. </hop>
  568. <hop>
  569. <from>Java 代码</from>
  570. <to>Elasticsearch bulk insert</to>
  571. <enabled>Y</enabled>
  572. </hop>
  573. <hop>
  574. <from>memberfriends表输入 3</from>
  575. <to>Java 代码</to>
  576. <enabled>Y</enabled>
  577. </hop>
  578. <hop>
  579. <from>memberfriends表输入 2</from>
  580. <to>Java 代码</to>
  581. <enabled>Y</enabled>
  582. </hop>
  583. </order>
  584. <step>
  585. <name>memberfriends表输入</name>
  586. <type>TableInput</type>
  587. <description/>
  588. <distribute>Y</distribute>
  589. <custom_distribution/>
  590. <copies>1</copies>
  591. <partitioning>
  592. <method>none</method>
  593. <schema_name/>
  594. </partitioning>
  595. <connection>mall</connection>
  596. <sql>select
  597. concat(dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1),'_',dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2))
  598. as PhoneId
  599. ,CreationDate AS MemberCrtTime
  600. ,BuyUserId as MemberId
  601. ,dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) as MemberPhone
  602. ,dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) as MemberFriendsPhone
  603. from Orders
  604. where
  605. AConsigneePhone1 !=''
  606. AND AConsigneePhone1 !=AConsigneePhone2
  607. AND AConsigneePhone2 !=''</sql>
  608. <limit>0</limit>
  609. <lookup/>
  610. <execute_each_row>N</execute_each_row>
  611. <variables_active>N</variables_active>
  612. <lazy_conversion_active>N</lazy_conversion_active>
  613. <attributes/>
  614. <cluster_schema/>
  615. <remotesteps>
  616. <input>
  617. </input>
  618. <output>
  619. </output>
  620. </remotesteps>
  621. <GUI>
  622. <xloc>64</xloc>
  623. <yloc>112</yloc>
  624. <draw>Y</draw>
  625. </GUI>
  626. </step>
  627. <step>
  628. <name>Java 代码</name>
  629. <type>UserDefinedJavaClass</type>
  630. <description/>
  631. <distribute>N</distribute>
  632. <custom_distribution/>
  633. <copies>20</copies>
  634. <partitioning>
  635. <method>none</method>
  636. <schema_name/>
  637. </partitioning>
  638. <definitions>
  639. <definition>
  640. <class_type>TRANSFORM_CLASS</class_type>
  641. <class_name>Processor</class_name>
  642. <class_source>import java.sql.*;
  643. import org.pentaho.di.core.database.*;
  644. import org.apache.http.HttpHost;
  645. import org.elasticsearch.ElasticsearchException;
  646. import org.elasticsearch.action.get.GetRequest;
  647. import org.elasticsearch.action.get.GetResponse;
  648. import org.elasticsearch.client.RestHighLevelClient;
  649. import org.elasticsearch.client.RequestOptions;
  650. import org.elasticsearch.client.RestClient;
  651. import org.elasticsearch.common.Strings;
  652. import org.elasticsearch.rest.RestStatus;
  653. import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
  654. import org.elasticsearch.action.update.UpdateRequest;
  655. import org.elasticsearch.action.update.UpdateResponse;
  656. import org.elasticsearch.common.xcontent.XContentBuilder;
  657. import org.elasticsearch.common.xcontent.XContentFactory;
  658. import org.elasticsearch.script.Script;
  659. import java.lang.reflect.InvocationTargetException;
  660. import java.lang.reflect.Method;
  661. import com.microsoft.sqlserver.jdbc.SQLServerException;
  662. Database database = null;
  663. PreparedStatement stat = null;
  664. PreparedStatement stat1 = null;
  665. RestHighLevelClient client = new RestHighLevelClient(
  666. RestClient.builder(
  667. new HttpHost[]{new HttpHost("192.168.50.32", 9200, "http")}));
  668. Integer index = 0;
  669. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  670. {
  671. //logBasic("start---");
  672. String type = getVariable("type");
  673. String indexs = getVariable("index");
  674. //if (indexs != null) index = Integer.parseInt(indexs);
  675. Object[] r = getRow();
  676. if (r == null) {
  677. try {
  678. if (stat!=null) {
  679. stat.close();
  680. }
  681. if (stat1!=null) {
  682. stat1.close();
  683. }
  684. if (database!=null) {
  685. database.disconnect();
  686. }
  687. if(client!=null){
  688. client.close();
  689. }
  690. }
  691. catch(Exception e) {
  692. throw new KettleException(e);
  693. }
  694. setOutputDone();
  695. return false;
  696. }
  697. synchronized(this) {
  698. r = createOutputRow(r, data.outputRowMeta.size());
  699. //获取数据库名和表名
  700. String dbName = "MemberSqlServer";//getInputRowMeta().getString(r, "conname", null );
  701. String tablename = "DataImport_Friend";//getInputRowMeta().getString(r, "tablename", null );
  702. String idname = "MemberPhone";//getInputRowMeta().getString(r, "idname", null );
  703. String sourceidname = "PhoneId";//getInputRowMeta().getString(r, "sourceidname", null );
  704. String sourcetablename = "Orders";//getInputRowMeta().getString(r, "sourcetablename", null );
  705. if (dbName==null||tablename==null) {
  706. throw new KettleException("Unable to find field with name "+tablename+" in the input row.");
  707. }
  708. //logBasic("table---"+tablename);
  709. if(database == null){
  710. //数据库连接
  711. DatabaseMeta databaseMeta=null;
  712. try {
  713. databaseMeta = getTransMeta().findDatabase(dbName);
  714. if (databaseMeta==null) {
  715. logError("A connection with name "+dbName+" could not be found!");
  716. setErrors(1);
  717. return false;
  718. }
  719. database = new Database(getTrans(), databaseMeta);
  720. database.connect();
  721. //logBasic("success!");
  722. } catch(Exception e) {
  723. logError("Connecting to database "+dbName+" failed.", e);
  724. setErrors(1);
  725. return false;
  726. }
  727. }
  728. //查询表数据
  729. try {
  730. RowMetaInterface idxRowMeta =data.outputRowMeta;
  731. int i=0;
  732. r = createOutputRow(r, data.outputRowMeta.size());
  733. //int index = getInputRowMeta().size();
  734. // Add the index name
  735. //
  736. String Id = idxRowMeta.getString(r, idname, null);
  737. // Add the column name
  738. String DataId = idxRowMeta.getString(r, sourceidname, null);
  739. /*String sqlSelect = "select Id from "+tablename + " where DataId = '"+ DataId +"'";
  740. ResultSet resultSet = null;
  741. resultSet = database.openQuery(sqlSelect);
  742. Object[] idxRow = database.getRow(resultSet);
  743. if (database!=null) {
  744. database.closeQuery(resultSet);
  745. resultSet = null;
  746. }
  747. //if(idxRow != null){
  748. // return true;
  749. //}
  750. */
  751. //logBasic("idxRow--Id"+Id);
  752. //logBasic("idxRow--sourcetablename"+sourcetablename);
  753. //logBasic("idxRow--DataId"+DataId);
  754. GetRequest getRequest = new GetRequest(
  755. "crm_memberfriends", // Index
  756. "_doc", // /Type
  757. DataId); // Document id
  758. getRequest.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
  759. getRequest.storedFields(new String[]{"_none_"}); // 禁止存储任何字段
  760. boolean exists = client.exists(getRequest,RequestOptions.DEFAULT);
  761. //client.close();
  762. if(exists ){
  763. return true;
  764. }
  765. //if(!exists &amp;&amp; idxRow == null){
  766. // return true;
  767. //}
  768. //3.获得预处理对象
  769. String sql="insert into "+tablename+"(Id,DataName,DataId,Type) values (?,?,?,?);";//begin tran t2; commit tran t2
  770. //logBasic("idxRow--database"+ database);
  771. index = index + 1;
  772. if(stat == null)
  773. stat = database.prepareSQL(sql);
  774. //logBasic("idxRow--database"+ stat);
  775. //stat.addBatch(sql);
  776. //4.SQL语句占位符设置实际参数
  777. stat.setString(1, Id);//索引参数1代表着sql中的第一个?号,也就是我需要将条件sid所对应的sname数据更新为“儿童玩具测试”
  778. stat.setString(2, sourcetablename);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  779. stat.setString(3, DataId);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  780. stat.setString(4, "phone1,phone2");
  781. //stat.setString(5,MemberFriendsPhone)
  782. //stat.setString(5, index);
  783. //5.执行SQL语句
  784. boolean line = stat.execute();
  785. //int[] line = stat.executeBatch();
  786. //System.out.println("更新记录数"+ line);
  787. //6.释放资源
  788. //stat.close();
  789. //setVariable("index",String.valueOf(index));
  790. //Integer pn = Integer.parseInt(Id);
  791. //Integer curpageNum = Integer.parseInt(Id) % pagesize;
  792. //if(pn > 0 &amp;&amp; curpageNum == 0){
  793. // setVariable("page",String.valueOf(page));
  794. //}
  795. //logBasic("idxRow--getVariable"+getVariable("page"));
  796. //logBasic("idxRow--curpageNum"+curpageNum);
  797. //logBasic("idxRow--length"+i);
  798. }
  799. catch(SQLServerException e) {
  800. return true;
  801. }catch(Exception e) {
  802. throw new KettleException(e);
  803. }
  804. //释放连接
  805. //if (database!=null) {
  806. // database.disconnect();
  807. //}
  808. // Send the row on to the next step.
  809. }
  810. putRow(data.outputRowMeta, r);
  811. return true;
  812. }</class_source>
  813. </definition>
  814. </definitions>
  815. <fields>
  816. </fields>
  817. <clear_result_fields>N</clear_result_fields>
  818. <info_steps/>
  819. <target_steps/>
  820. <usage_parameters/>
  821. <attributes/>
  822. <cluster_schema/>
  823. <remotesteps>
  824. <input>
  825. </input>
  826. <output>
  827. </output>
  828. </remotesteps>
  829. <GUI>
  830. <xloc>224</xloc>
  831. <yloc>112</yloc>
  832. <draw>Y</draw>
  833. </GUI>
  834. </step>
  835. <step>
  836. <name>表输出</name>
  837. <type>TableOutput</type>
  838. <description/>
  839. <distribute>Y</distribute>
  840. <custom_distribution/>
  841. <copies>1</copies>
  842. <partitioning>
  843. <method>none</method>
  844. <schema_name/>
  845. </partitioning>
  846. <connection>memberdata</connection>
  847. <schema/>
  848. <table>mem_MemberFriends</table>
  849. <commit>1000</commit>
  850. <truncate>N</truncate>
  851. <ignore_errors>N</ignore_errors>
  852. <use_batch>Y</use_batch>
  853. <specify_fields>Y</specify_fields>
  854. <partitioning_enabled>N</partitioning_enabled>
  855. <partitioning_field/>
  856. <partitioning_daily>N</partitioning_daily>
  857. <partitioning_monthly>Y</partitioning_monthly>
  858. <tablename_in_field>N</tablename_in_field>
  859. <tablename_field/>
  860. <tablename_in_table>Y</tablename_in_table>
  861. <return_keys>N</return_keys>
  862. <return_field/>
  863. <fields>
  864. <field>
  865. <column_name>phoneid</column_name>
  866. <stream_name>phoneid</stream_name>
  867. </field>
  868. <field>
  869. <column_name>MemberCrtTime</column_name>
  870. <stream_name>MemberCrtTime</stream_name>
  871. </field>
  872. <field>
  873. <column_name>MemberId</column_name>
  874. <stream_name>MemberId</stream_name>
  875. </field>
  876. <field>
  877. <column_name>MemberPhone</column_name>
  878. <stream_name>MemberPhone</stream_name>
  879. </field>
  880. <field>
  881. <column_name>MemberFriendsPhone</column_name>
  882. <stream_name>MemberFriendsPhone</stream_name>
  883. </field>
  884. </fields>
  885. <attributes/>
  886. <cluster_schema/>
  887. <remotesteps>
  888. <input>
  889. </input>
  890. <output>
  891. </output>
  892. </remotesteps>
  893. <GUI>
  894. <xloc>224</xloc>
  895. <yloc>256</yloc>
  896. <draw>Y</draw>
  897. </GUI>
  898. </step>
  899. <step>
  900. <name>Elasticsearch bulk insert</name>
  901. <type>ElasticSearchBulk</type>
  902. <description/>
  903. <distribute>Y</distribute>
  904. <custom_distribution/>
  905. <copies>1</copies>
  906. <partitioning>
  907. <method>none</method>
  908. <schema_name/>
  909. </partitioning>
  910. <general>
  911. <index>crm_memberfriends</index>
  912. <type>_doc</type>
  913. <batchSize>1000</batchSize>
  914. <timeout/>
  915. <timeoutUnit>SECONDS</timeoutUnit>
  916. <isJson>N</isJson>
  917. <idField>PhoneId</idField>
  918. <overwriteIfExists>Y</overwriteIfExists>
  919. <useOutput>N</useOutput>
  920. <stopOnError>Y</stopOnError>
  921. </general>
  922. <fields>
  923. <field>
  924. <columnName>MemberCrtTime</columnName>
  925. <targetName>MemberCrtTime</targetName>
  926. </field>
  927. <field>
  928. <columnName>MemberFriendsPhone</columnName>
  929. <targetName>MemberFriendsPhone</targetName>
  930. </field>
  931. <field>
  932. <columnName>MemberId</columnName>
  933. <targetName>MemberId</targetName>
  934. </field>
  935. <field>
  936. <columnName>MemberPhone</columnName>
  937. <targetName>MemberPhone</targetName>
  938. </field>
  939. <field>
  940. <columnName>PhoneId</columnName>
  941. <targetName>PhoneId</targetName>
  942. </field>
  943. </fields>
  944. <servers>
  945. <server>
  946. <address>192.168.50.32</address>
  947. <port>9300</port>
  948. </server>
  949. </servers>
  950. <settings>
  951. <setting>
  952. <name>cluster.name</name>
  953. <value>es</value>
  954. </setting>
  955. <setting>
  956. <name>custom.fields.aliase</name>
  957. <value>mem_memberfriends</value>
  958. </setting>
  959. </settings>
  960. <attributes/>
  961. <cluster_schema/>
  962. <remotesteps>
  963. <input>
  964. </input>
  965. <output>
  966. </output>
  967. </remotesteps>
  968. <GUI>
  969. <xloc>416</xloc>
  970. <yloc>80</yloc>
  971. <draw>Y</draw>
  972. </GUI>
  973. </step>
  974. <step>
  975. <name>memberfriends表输入 2</name>
  976. <type>TableInput</type>
  977. <description/>
  978. <distribute>Y</distribute>
  979. <custom_distribution/>
  980. <copies>1</copies>
  981. <partitioning>
  982. <method>none</method>
  983. <schema_name/>
  984. </partitioning>
  985. <connection>mall</connection>
  986. <sql>select
  987. concat(dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2),'_',dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3))
  988. as PhoneId
  989. ,CreationDate AS MemberCrtTime
  990. ,BuyUserId as MemberId
  991. ,dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) as MemberPhone
  992. ,dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) as MemberFriendsPhone
  993. from Orders
  994. where
  995. AConsigneePhone2 !=''
  996. AND AConsigneePhone2 !=AConsigneePhone3
  997. AND AConsigneePhone3 !=''</sql>
  998. <limit>0</limit>
  999. <lookup/>
  1000. <execute_each_row>N</execute_each_row>
  1001. <variables_active>N</variables_active>
  1002. <lazy_conversion_active>N</lazy_conversion_active>
  1003. <attributes/>
  1004. <cluster_schema/>
  1005. <remotesteps>
  1006. <input>
  1007. </input>
  1008. <output>
  1009. </output>
  1010. </remotesteps>
  1011. <GUI>
  1012. <xloc>80</xloc>
  1013. <yloc>288</yloc>
  1014. <draw>Y</draw>
  1015. </GUI>
  1016. </step>
  1017. <step>
  1018. <name>memberfriends表输入 3</name>
  1019. <type>TableInput</type>
  1020. <description/>
  1021. <distribute>Y</distribute>
  1022. <custom_distribution/>
  1023. <copies>1</copies>
  1024. <partitioning>
  1025. <method>none</method>
  1026. <schema_name/>
  1027. </partitioning>
  1028. <connection>mall</connection>
  1029. <sql>select
  1030. concat(dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1),'_',dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3))
  1031. as PhoneId
  1032. ,CreationDate AS MemberCrtTime
  1033. ,BuyUserId as MemberId
  1034. ,dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) as MemberPhone
  1035. ,dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3) as MemberFriendsPhone
  1036. from Orders
  1037. where
  1038. AConsigneePhone1 !=''
  1039. AND AConsigneePhone1 !=AConsigneePhone3
  1040. AND AConsigneePhone3 !=''</sql>
  1041. <limit>0</limit>
  1042. <lookup/>
  1043. <execute_each_row>N</execute_each_row>
  1044. <variables_active>N</variables_active>
  1045. <lazy_conversion_active>N</lazy_conversion_active>
  1046. <attributes/>
  1047. <cluster_schema/>
  1048. <remotesteps>
  1049. <input>
  1050. </input>
  1051. <output>
  1052. </output>
  1053. </remotesteps>
  1054. <GUI>
  1055. <xloc>80</xloc>
  1056. <yloc>208</yloc>
  1057. <draw>Y</draw>
  1058. </GUI>
  1059. </step>
  1060. <step_error_handling>
  1061. </step_error_handling>
  1062. <slave-step-copy-partition-distribution>
  1063. </slave-step-copy-partition-distribution>
  1064. <slave_transformation>N</slave_transformation>
  1065. <attributes/>
  1066. </transformation>