mem_memberheathytemp_doc.ktr 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <transformation>
  3. <info>
  4. <name>mem_memberheathytemp_doc</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/10 13:44:56.679</created_date>
  431. <modified_user>-</modified_user>
  432. <modified_date>2019/06/10 13:44:56.679</modified_date>
  433. <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</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>memberheathytemp表输入</from>
  500. <to>Java 代码</to>
  501. <enabled>Y</enabled>
  502. </hop>
  503. <hop>
  504. <from>Java 代码</from>
  505. <to>Elasticsearch bulk insert 2</to>
  506. <enabled>Y</enabled>
  507. </hop>
  508. <hop>
  509. <from>memberheathytemp表输入 2</from>
  510. <to>Java 代码</to>
  511. <enabled>Y</enabled>
  512. </hop>
  513. <hop>
  514. <from>memberheathytemp表输入 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_temp</index>
  532. <type>_doc</type>
  533. <batchSize>1000</batchSize>
  534. <timeout/>
  535. <timeoutUnit>SECONDS</timeoutUnit>
  536. <isJson>N</isJson>
  537. <idField>Id</idField>
  538. <overwriteIfExists>Y</overwriteIfExists>
  539. <useOutput>N</useOutput>
  540. <stopOnError>Y</stopOnError>
  541. </general>
  542. <fields>
  543. <field>
  544. <columnName>DiseaseClassCode</columnName>
  545. <targetName>DiseaseClassCode</targetName>
  546. </field>
  547. <field>
  548. <columnName>MemTerminalId</columnName>
  549. <targetName>MemTerminalId</targetName>
  550. </field>
  551. <field>
  552. <columnName>MemberAge</columnName>
  553. <targetName>MemberAge</targetName>
  554. </field>
  555. <field>
  556. <columnName>MemberGender</columnName>
  557. <targetName>MemberGender</targetName>
  558. </field>
  559. <field>
  560. <columnName>MemberHeight</columnName>
  561. <targetName>MemberHeight</targetName>
  562. </field>
  563. <field>
  564. <columnName>MemberId</columnName>
  565. <targetName>MemberId</targetName>
  566. </field>
  567. <field>
  568. <columnName>MemberName</columnName>
  569. <targetName>MemberName</targetName>
  570. </field>
  571. <field>
  572. <columnName>MemberPhone1</columnName>
  573. <targetName>MemberPhone1</targetName>
  574. </field>
  575. <field>
  576. <columnName>MemberPhone2</columnName>
  577. <targetName>MemberPhone2</targetName>
  578. </field>
  579. <field>
  580. <columnName>MemberPhone3</columnName>
  581. <targetName>MemberPhone3</targetName>
  582. </field>
  583. <field>
  584. <columnName>MemberUpdateTime</columnName>
  585. <targetName>MemberUpdateTime</targetName>
  586. </field>
  587. <field>
  588. <columnName>MemberWeight</columnName>
  589. <targetName>MemberWeight</targetName>
  590. </field>
  591. </fields>
  592. <servers>
  593. <server>
  594. <address>192.168.50.32</address>
  595. <port>9300</port>
  596. </server>
  597. </servers>
  598. <settings>
  599. <setting>
  600. <name>cluster.name</name>
  601. <value>es</value>
  602. </setting>
  603. <setting>
  604. <name>custom.fields.aliase</name>
  605. <value>mem_memberhealth_temp</value>
  606. </setting>
  607. </settings>
  608. <attributes/>
  609. <cluster_schema/>
  610. <remotesteps>
  611. <input>
  612. </input>
  613. <output>
  614. </output>
  615. </remotesteps>
  616. <GUI>
  617. <xloc>784</xloc>
  618. <yloc>128</yloc>
  619. <draw>Y</draw>
  620. </GUI>
  621. </step>
  622. <step>
  623. <name>Java 代码</name>
  624. <type>UserDefinedJavaClass</type>
  625. <description/>
  626. <distribute>N</distribute>
  627. <custom_distribution/>
  628. <copies>20</copies>
  629. <partitioning>
  630. <method>none</method>
  631. <schema_name/>
  632. </partitioning>
  633. <definitions>
  634. <definition>
  635. <class_type>TRANSFORM_CLASS</class_type>
  636. <class_name>Processor</class_name>
  637. <class_source>import java.sql.*;
  638. import org.pentaho.di.core.database.*;
  639. import org.apache.http.HttpHost;
  640. import org.elasticsearch.ElasticsearchException;
  641. import org.elasticsearch.action.get.GetRequest;
  642. import org.elasticsearch.action.get.GetResponse;
  643. import org.elasticsearch.client.RestHighLevelClient;
  644. import org.elasticsearch.client.RequestOptions;
  645. import org.elasticsearch.client.RestClient;
  646. import org.elasticsearch.common.Strings;
  647. import org.elasticsearch.rest.RestStatus;
  648. import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
  649. import org.elasticsearch.action.update.UpdateRequest;
  650. import org.elasticsearch.action.update.UpdateResponse;
  651. import org.elasticsearch.common.xcontent.XContentBuilder;
  652. import org.elasticsearch.common.xcontent.XContentFactory;
  653. import org.elasticsearch.script.Script;
  654. import java.lang.reflect.InvocationTargetException;
  655. import java.lang.reflect.Method;
  656. import com.microsoft.sqlserver.jdbc.SQLServerException;
  657. Database database = null;
  658. PreparedStatement stat = null;
  659. PreparedStatement stat1 = null;
  660. RestHighLevelClient client = new RestHighLevelClient(
  661. RestClient.builder(
  662. new HttpHost[]{new HttpHost("192.168.50.32", 9200, "http")}));
  663. Integer index = 0;
  664. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  665. {
  666. //logBasic("start---");
  667. String type = getVariable("type");
  668. String indexs = getVariable("index");
  669. //if (indexs != null) index = Integer.parseInt(indexs);
  670. Object[] r = getRow();
  671. if (r == null) {
  672. try {
  673. if (stat!=null) {
  674. stat.close();
  675. }
  676. if (stat1!=null) {
  677. stat1.close();
  678. }
  679. if (database!=null) {
  680. database.disconnect();
  681. }
  682. if(client!=null){
  683. client.close();
  684. }
  685. }
  686. catch(Exception e) {
  687. throw new KettleException(e);
  688. }
  689. setOutputDone();
  690. return false;
  691. }
  692. synchronized(this) {
  693. r = createOutputRow(r, data.outputRowMeta.size());
  694. //获取数据库名和表名
  695. String dbName = "MemberSqlServer";//getInputRowMeta().getString(r, "conname", null );
  696. String tablename = "DataImport_heathytemp";//getInputRowMeta().getString(r, "tablename", null );
  697. String idname = "MemberId";//getInputRowMeta().getString(r, "idname", null );
  698. String sourceidname = "Id";//getInputRowMeta().getString(r, "sourceidname", null );
  699. String sourcetablename = "Orders";//getInputRowMeta().getString(r, "sourcetablename", null );
  700. if (dbName==null||tablename==null) {
  701. throw new KettleException("Unable to find field with name "+tablename+" in the input row.");
  702. }
  703. //logBasic("table---"+tablename);
  704. if(database == null){
  705. //数据库连接
  706. DatabaseMeta databaseMeta=null;
  707. try {
  708. databaseMeta = getTransMeta().findDatabase(dbName);
  709. if (databaseMeta==null) {
  710. logError("A connection with name "+dbName+" could not be found!");
  711. setErrors(1);
  712. return false;
  713. }
  714. database = new Database(getTrans(), databaseMeta);
  715. database.connect();
  716. //logBasic("success!");
  717. } catch(Exception e) {
  718. logError("Connecting to database "+dbName+" failed.", e);
  719. setErrors(1);
  720. return false;
  721. }
  722. }
  723. //查询表数据
  724. try {
  725. RowMetaInterface idxRowMeta =data.outputRowMeta;
  726. int i=0;
  727. r = createOutputRow(r, data.outputRowMeta.size());
  728. //int index = getInputRowMeta().size();
  729. // Add the index name
  730. //
  731. String Id = idxRowMeta.getString(r, idname, null);
  732. // Add the column name
  733. String DataId = idxRowMeta.getString(r, sourceidname, null);
  734. /*String sqlSelect = "select Id from "+tablename + " where DataId = '"+ DataId +"'";
  735. ResultSet resultSet = null;
  736. resultSet = database.openQuery(sqlSelect);
  737. Object[] idxRow = database.getRow(resultSet);
  738. if (database!=null) {
  739. database.closeQuery(resultSet);
  740. resultSet = null;
  741. }
  742. //if(idxRow != null){
  743. // return true;
  744. //}
  745. */
  746. //logBasic("idxRow--Id"+Id);
  747. //logBasic("idxRow--sourcetablename"+sourcetablename);
  748. //logBasic("idxRow--DataId"+DataId);
  749. GetRequest getRequest = new GetRequest(
  750. "crm_memberheathytemp", // Index
  751. "_doc", // /Type
  752. DataId); // Document id
  753. getRequest.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
  754. getRequest.storedFields(new String[]{"_none_"}); // 禁止存储任何字段
  755. boolean exists = client.exists(getRequest,RequestOptions.DEFAULT);
  756. //client.close();
  757. if(exists ){
  758. return true;
  759. }
  760. //if(!exists &amp;&amp; idxRow == null){
  761. // return true;
  762. //}
  763. //3.获得预处理对象
  764. String sql="insert into "+tablename+"(Id,DataName,DataId,Type) values (?,?,?,?);";//begin tran t2; commit tran t2
  765. //logBasic("idxRow--database"+ database);
  766. index = index + 1;
  767. if(stat == null)
  768. stat = database.prepareSQL(sql);
  769. //logBasic("idxRow--database"+ stat);
  770. //stat.addBatch(sql);
  771. //4.SQL语句占位符设置实际参数
  772. stat.setString(1, Id);//索引参数1代表着sql中的第一个?号,也就是我需要将条件sid所对应的sname数据更新为“儿童玩具测试”
  773. stat.setString(2, sourcetablename);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  774. stat.setString(3, DataId);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  775. stat.setString(4, "phone1,phone2");
  776. //stat.setString(5,MemberFriendsPhone)
  777. //stat.setString(5, index);
  778. //5.执行SQL语句
  779. boolean line = stat.execute();
  780. //int[] line = stat.executeBatch();
  781. //System.out.println("更新记录数"+ line);
  782. //6.释放资源
  783. //stat.close();
  784. //setVariable("index",String.valueOf(index));
  785. //Integer pn = Integer.parseInt(Id);
  786. //Integer curpageNum = Integer.parseInt(Id) % pagesize;
  787. //if(pn > 0 &amp;&amp; curpageNum == 0){
  788. // setVariable("page",String.valueOf(page));
  789. //}
  790. //logBasic("idxRow--getVariable"+getVariable("page"));
  791. //logBasic("idxRow--curpageNum"+curpageNum);
  792. //logBasic("idxRow--length"+i);
  793. }
  794. catch(SQLServerException e) {
  795. return true;
  796. }catch(Exception e) {
  797. throw new KettleException(e);
  798. }
  799. //释放连接
  800. //if (database!=null) {
  801. // database.disconnect();
  802. //}
  803. // Send the row on to the next step.
  804. }
  805. putRow(data.outputRowMeta, r);
  806. return true;
  807. }</class_source>
  808. </definition>
  809. </definitions>
  810. <fields>
  811. </fields>
  812. <clear_result_fields>N</clear_result_fields>
  813. <info_steps/>
  814. <target_steps/>
  815. <usage_parameters/>
  816. <attributes/>
  817. <cluster_schema/>
  818. <remotesteps>
  819. <input>
  820. </input>
  821. <output>
  822. </output>
  823. </remotesteps>
  824. <GUI>
  825. <xloc>576</xloc>
  826. <yloc>192</yloc>
  827. <draw>Y</draw>
  828. </GUI>
  829. </step>
  830. <step>
  831. <name>memberheathytemp表输入</name>
  832. <type>TableInput</type>
  833. <description/>
  834. <distribute>Y</distribute>
  835. <custom_distribution/>
  836. <copies>1</copies>
  837. <partitioning>
  838. <method>none</method>
  839. <schema_name/>
  840. </partitioning>
  841. <connection>mall</connection>
  842. <sql>SELECT
  843. a.BuyUserId AS Id ,
  844. a.BuyUserId AS MemberId
  845. ,a.Consignee AS MemberName,
  846. a.Height AS MemberHeight,
  847. a.Weight AS MemberWeight,
  848. CASE WHEN b.Gender IS NULL THEN a.Sex END AS MemberGender,
  849. a.OrderTime AS MemberUpdateTime,
  850. a.DiseaseClassCode,
  851. a.OriginType AS MemTerminalId,
  852. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) AS MemberPhone1,
  853. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) AS MemberPhone2,
  854. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3) AS MemberPhone3,
  855. b.age as MemberAge
  856. FROM
  857. [Mall].[dbo].[Orders] a
  858. LEFT JOIN
  859. [Mall]..PrescriptionRecord AS b ON a.OrdersCode = b.OrdersCode
  860. WHERE AConsigneePhone1 !=''
  861. order by a.BuyUserId</sql>
  862. <limit>0</limit>
  863. <lookup/>
  864. <execute_each_row>N</execute_each_row>
  865. <variables_active>N</variables_active>
  866. <lazy_conversion_active>N</lazy_conversion_active>
  867. <attributes/>
  868. <cluster_schema/>
  869. <remotesteps>
  870. <input>
  871. </input>
  872. <output>
  873. </output>
  874. </remotesteps>
  875. <GUI>
  876. <xloc>432</xloc>
  877. <yloc>80</yloc>
  878. <draw>Y</draw>
  879. </GUI>
  880. </step>
  881. <step>
  882. <name>memberheathytemp表输入 2</name>
  883. <type>TableInput</type>
  884. <description/>
  885. <distribute>Y</distribute>
  886. <custom_distribution/>
  887. <copies>1</copies>
  888. <partitioning>
  889. <method>none</method>
  890. <schema_name/>
  891. </partitioning>
  892. <connection>mall</connection>
  893. <sql>SELECT
  894. a.BuyUserId AS Id ,
  895. a.BuyUserId AS MemberId
  896. ,a.Consignee AS MemberName,
  897. a.Height AS MemberHeight,
  898. a.Weight AS MemberWeight,
  899. CASE WHEN b.Gender IS NULL THEN a.Sex END AS MemberGender,
  900. a.OrderTime AS MemberUpdateTime,
  901. a.DiseaseClassCode,
  902. a.OriginType AS MemTerminalId,
  903. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) AS MemberPhone1,
  904. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) AS MemberPhone2,
  905. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3) AS MemberPhone3,
  906. b.age as MemberAge
  907. FROM
  908. [Mall].[dbo].[Orders] a
  909. LEFT JOIN
  910. [Mall]..PrescriptionRecord AS b ON a.OrdersCode = b.OrdersCode
  911. where AConsigneePhone2 !=''
  912. order by a.BuyUserId</sql>
  913. <limit>0</limit>
  914. <lookup/>
  915. <execute_each_row>N</execute_each_row>
  916. <variables_active>N</variables_active>
  917. <lazy_conversion_active>N</lazy_conversion_active>
  918. <attributes/>
  919. <cluster_schema/>
  920. <remotesteps>
  921. <input>
  922. </input>
  923. <output>
  924. </output>
  925. </remotesteps>
  926. <GUI>
  927. <xloc>400</xloc>
  928. <yloc>160</yloc>
  929. <draw>Y</draw>
  930. </GUI>
  931. </step>
  932. <step>
  933. <name>memberheathytemp表输入 3</name>
  934. <type>TableInput</type>
  935. <description/>
  936. <distribute>Y</distribute>
  937. <custom_distribution/>
  938. <copies>1</copies>
  939. <partitioning>
  940. <method>none</method>
  941. <schema_name/>
  942. </partitioning>
  943. <connection>mall</connection>
  944. <sql>SELECT
  945. a.BuyUserId AS Id ,
  946. a.BuyUserId AS MemberId
  947. ,a.Consignee AS MemberName,
  948. a.Height AS MemberHeight,
  949. a.Weight AS MemberWeight,
  950. CASE WHEN b.Gender IS NULL THEN a.Sex END AS MemberGender,
  951. a.OrderTime AS MemberUpdateTime,
  952. a.DiseaseClassCode,
  953. a.OriginType AS MemTerminalId,
  954. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3) AS MemberPhone1,
  955. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) AS MemberPhone2,
  956. Mall.dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) AS MemberPhone3,
  957. b.age as MemberAge
  958. FROM
  959. [Mall].[dbo].[Orders] a
  960. LEFT JOIN
  961. [Mall]..PrescriptionRecord AS b ON a.OrdersCode = b.OrdersCode
  962. where AConsigneePhone3 !=''
  963. order by a.BuyUserId</sql>
  964. <limit>0</limit>
  965. <lookup/>
  966. <execute_each_row>N</execute_each_row>
  967. <variables_active>N</variables_active>
  968. <lazy_conversion_active>N</lazy_conversion_active>
  969. <attributes/>
  970. <cluster_schema/>
  971. <remotesteps>
  972. <input>
  973. </input>
  974. <output>
  975. </output>
  976. </remotesteps>
  977. <GUI>
  978. <xloc>451</xloc>
  979. <yloc>256</yloc>
  980. <draw>Y</draw>
  981. </GUI>
  982. </step>
  983. <step_error_handling>
  984. </step_error_handling>
  985. <slave-step-copy-partition-distribution>
  986. </slave-step-copy-partition-distribution>
  987. <slave_transformation>N</slave_transformation>
  988. <attributes/>
  989. </transformation>