mem_memberbase_query_page.ktr 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <transformation>
  3. <info>
  4. <name>mem_memberbase_query_page</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>10000</size_rowset>
  412. <sleep_time_empty>50</sleep_time_empty>
  413. <sleep_time_full>50</sleep_time_full>
  414. <unique_connections>N</unique_connections>
  415. <feedback_shown>Y</feedback_shown>
  416. <feedback_size>50000</feedback_size>
  417. <using_thread_priorities>Y</using_thread_priorities>
  418. <shared_objects_file/>
  419. <capture_step_performance>N</capture_step_performance>
  420. <step_performance_capturing_delay>1000</step_performance_capturing_delay>
  421. <step_performance_capturing_size_limit>100</step_performance_capturing_size_limit>
  422. <dependencies>
  423. </dependencies>
  424. <partitionschemas>
  425. </partitionschemas>
  426. <slaveservers>
  427. </slaveservers>
  428. <clusterschemas>
  429. </clusterschemas>
  430. <created_user>-</created_user>
  431. <created_date>2019/05/26 19:55:18.893</created_date>
  432. <modified_user>-</modified_user>
  433. <modified_date>2019/05/26 19:55:18.893</modified_date>
  434. <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
  435. <is_key_private>N</is_key_private>
  436. </info>
  437. <notepads>
  438. </notepads>
  439. <connection>
  440. <name>MallSqlserver</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>EXTRA_OPTION_MSSQLNATIVE.defaultRowPrefetch</code>
  454. <attribute>200</attribute>
  455. </attribute>
  456. <attribute>
  457. <code>EXTRA_OPTION_MSSQLNATIVE.readTimeout</code>
  458. <attribute>60</attribute>
  459. </attribute>
  460. <attribute>
  461. <code>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
  462. <attribute>N</attribute>
  463. </attribute>
  464. <attribute>
  465. <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
  466. <attribute>N</attribute>
  467. </attribute>
  468. <attribute>
  469. <code>INITIAL_POOL_SIZE</code>
  470. <attribute>100</attribute>
  471. </attribute>
  472. <attribute>
  473. <code>IS_CLUSTERED</code>
  474. <attribute>N</attribute>
  475. </attribute>
  476. <attribute>
  477. <code>MAXIMUM_POOL_SIZE</code>
  478. <attribute>300</attribute>
  479. </attribute>
  480. <attribute>
  481. <code>MSSQLUseIntegratedSecurity</code>
  482. <attribute>false</attribute>
  483. </attribute>
  484. <attribute>
  485. <code>MSSQL_DOUBLE_DECIMAL_SEPARATOR</code>
  486. <attribute>N</attribute>
  487. </attribute>
  488. <attribute>
  489. <code>PORT_NUMBER</code>
  490. <attribute>1433</attribute>
  491. </attribute>
  492. <attribute>
  493. <code>PRESERVE_RESERVED_WORD_CASE</code>
  494. <attribute>Y</attribute>
  495. </attribute>
  496. <attribute>
  497. <code>QUOTE_ALL_FIELDS</code>
  498. <attribute>N</attribute>
  499. </attribute>
  500. <attribute>
  501. <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
  502. <attribute>Y</attribute>
  503. </attribute>
  504. <attribute>
  505. <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
  506. <attribute>Y</attribute>
  507. </attribute>
  508. <attribute>
  509. <code>USE_POOLING</code>
  510. <attribute>Y</attribute>
  511. </attribute>
  512. </attributes>
  513. </connection>
  514. <order>
  515. <hop>
  516. <from>Java 代码</from>
  517. <to>Elasticsearch bulk insert 2</to>
  518. <enabled>Y</enabled>
  519. </hop>
  520. <hop>
  521. <from>表输入 2</from>
  522. <to>Java 代码</to>
  523. <enabled>Y</enabled>
  524. </hop>
  525. </order>
  526. <step>
  527. <name>Elasticsearch bulk insert 2</name>
  528. <type>ElasticSearchBulk</type>
  529. <description/>
  530. <distribute>Y</distribute>
  531. <custom_distribution/>
  532. <copies>1</copies>
  533. <partitioning>
  534. <method>none</method>
  535. <schema_name/>
  536. </partitioning>
  537. <general>
  538. <index>crm_memberbase</index>
  539. <type>_doc</type>
  540. <batchSize>5000</batchSize>
  541. <timeout>100</timeout>
  542. <timeoutUnit>SECONDS</timeoutUnit>
  543. <isJson>N</isJson>
  544. <idField>MemberKey</idField>
  545. <overwriteIfExists>Y</overwriteIfExists>
  546. <useOutput>N</useOutput>
  547. <stopOnError>Y</stopOnError>
  548. </general>
  549. <fields>
  550. <field>
  551. <columnName>HasOrder</columnName>
  552. <targetName>HasOrder</targetName>
  553. </field>
  554. <field>
  555. <columnName>MemReceiverMobile</columnName>
  556. <targetName>MemReceiverMobile</targetName>
  557. </field>
  558. <field>
  559. <columnName>MemReceiverPhone</columnName>
  560. <targetName>MemReceiverPhone</targetName>
  561. </field>
  562. <field>
  563. <columnName>MemUsualAddress</columnName>
  564. <targetName>MemUsualAddress</targetName>
  565. </field>
  566. <field>
  567. <columnName>MemUsualAreaCode</columnName>
  568. <targetName>MemUsualAreaCode</targetName>
  569. </field>
  570. <field>
  571. <columnName>MemUsualCityCode</columnName>
  572. <targetName>MemUsualCityCode</targetName>
  573. </field>
  574. <field>
  575. <columnName>MemUsualPhone</columnName>
  576. <targetName>MemUsualPhone</targetName>
  577. </field>
  578. <field>
  579. <columnName>MemUsualProvinceCode</columnName>
  580. <targetName>MemUsualProvinceCode</targetName>
  581. </field>
  582. <field>
  583. <columnName>MemberGender</columnName>
  584. <targetName>MemberGender</targetName>
  585. </field>
  586. <field>
  587. <columnName>MemberKey</columnName>
  588. <targetName>MemberKey</targetName>
  589. </field>
  590. <field>
  591. <columnName>MemberNickName</columnName>
  592. <targetName>MemberNickName</targetName>
  593. </field>
  594. <field>
  595. <columnName>OriginType</columnName>
  596. <targetName>OriginType</targetName>
  597. </field>
  598. <field>
  599. <columnName>RegisterDay</columnName>
  600. <targetName>RegisterDay</targetName>
  601. </field>
  602. <field>
  603. <columnName>RegisterMonth</columnName>
  604. <targetName>RegisterMonth</targetName>
  605. </field>
  606. <field>
  607. <columnName>RegisterTime</columnName>
  608. <targetName>RegisterTime</targetName>
  609. </field>
  610. <field>
  611. <columnName>RegisterYear</columnName>
  612. <targetName>RegisterYear</targetName>
  613. </field>
  614. <field>
  615. <columnName>order_join_field</columnName>
  616. <targetName>order_join_field</targetName>
  617. </field>
  618. </fields>
  619. <servers>
  620. <server>
  621. <address>192.168.50.32</address>
  622. <port>9300</port>
  623. </server>
  624. </servers>
  625. <settings>
  626. <setting>
  627. <name>cluster.name</name>
  628. <value>es</value>
  629. </setting>
  630. </settings>
  631. <attributes/>
  632. <cluster_schema/>
  633. <remotesteps>
  634. <input>
  635. </input>
  636. <output>
  637. </output>
  638. </remotesteps>
  639. <GUI>
  640. <xloc>464</xloc>
  641. <yloc>128</yloc>
  642. <draw>Y</draw>
  643. </GUI>
  644. </step>
  645. <step>
  646. <name>Java 代码</name>
  647. <type>UserDefinedJavaClass</type>
  648. <description/>
  649. <distribute>Y</distribute>
  650. <custom_distribution/>
  651. <copies>100</copies>
  652. <partitioning>
  653. <method>none</method>
  654. <schema_name/>
  655. </partitioning>
  656. <definitions>
  657. <definition>
  658. <class_type>TRANSFORM_CLASS</class_type>
  659. <class_name>Processor</class_name>
  660. <class_source>import java.sql.*;
  661. import org.pentaho.di.core.database.*;
  662. Database database = null;
  663. PreparedStatement stat = null;
  664. ResultSet resultSet = null;
  665. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  666. {
  667. int page = Integer.parseInt(getVariable("page"));
  668. int pagesize = Integer.parseInt(getVariable("pagesize"));
  669. Object[] r = getRow();
  670. if (r == null) {
  671. try {
  672. if (stat!=null) {
  673. stat.close();
  674. }
  675. if (database!=null) {
  676. database.disconnect();
  677. }
  678. //if (database!=null) {
  679. //database.closeQuery(resultSet);
  680. //}
  681. }
  682. catch(Exception e) {
  683. throw new KettleException(e);
  684. }
  685. setOutputDone();
  686. return false;
  687. }
  688. r = createOutputRow(r, data.outputRowMeta.size());
  689. //获取数据库名和表名
  690. String dbName = "MemberSqlserver";//getInputRowMeta().getString(r, "conname", null );
  691. String tablename = "DataImport";//getInputRowMeta().getString(r, "tablename", null );
  692. String idname = "MemberKey";//getInputRowMeta().getString(r, "idname", null );
  693. String sourceidname = "MemUsualPhone";//getInputRowMeta().getString(r, "sourceidname", null );
  694. String sourcetablename = "Order";//getInputRowMeta().getString(r, "sourcetablename", null );
  695. if (dbName==null||tablename==null) {
  696. throw new KettleException("Unable to find field with name "+tablename+" in the input row.");
  697. }
  698. //logBasic("table---"+tablename);
  699. if(database == null){
  700. //数据库连接
  701. DatabaseMeta databaseMeta=null;
  702. try {
  703. databaseMeta = getTransMeta().findDatabase(dbName);
  704. if (databaseMeta==null) {
  705. logError("A connection with name "+dbName+" could not be found!");
  706. setErrors(1);
  707. return false;
  708. }
  709. database = new Database(getTrans(), databaseMeta);
  710. database.connect();
  711. //logBasic("success!");
  712. } catch(Exception e) {
  713. logError("Connecting to database "+dbName+" failed.", e);
  714. setErrors(1);
  715. return false;
  716. }
  717. }//else{
  718. // database.connect();
  719. //}
  720. //查询表数据
  721. try {
  722. RowMetaInterface idxRowMeta =data.outputRowMeta;
  723. int i=0;
  724. r = createOutputRow(r, data.outputRowMeta.size());
  725. //int index = getInputRowMeta().size();
  726. // Add the index name
  727. //
  728. String Id = idxRowMeta.getString(r, idname, null);
  729. // Add the column name
  730. String DataId = idxRowMeta.getString(r, sourceidname, null);
  731. String sqlSelect = "select Id from "+tablename + " where DataId = '"+ DataId +"'";
  732. resultSet = database.openQuery(sqlSelect);
  733. Object[] idxRow = database.getRow(resultSet);
  734. if(idxRow!=null){
  735. if (database!=null) {
  736. database.closeQuery(resultSet);
  737. resultSet = null;
  738. }
  739. return true;
  740. }
  741. //logBasic("idxRow--Id"+Id);
  742. //logBasic("idxRow--sourcetablename"+sourcetablename);
  743. //logBasic("idxRow--DataId"+DataId);
  744. //3.获得预处理对象
  745. String sql=" insert into "+tablename+" values (?,?,?)";
  746. //logBasic("idxRow--database"+ database);
  747. stat = database.prepareSQL(sql);
  748. //logBasic("idxRow--database"+ stat);
  749. //stat.addBatch(sql);
  750. //4.SQL语句占位符设置实际参数
  751. stat.setString(1, Id);//索引参数1代表着sql中的第一个?号,也就是我需要将条件sid所对应的sname数据更新为“儿童玩具测试”
  752. stat.setString(2, sourcetablename);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  753. stat.setString(3, DataId);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  754. //5.执行SQL语句
  755. boolean line = stat.execute();
  756. //int[] line = stat.executeBatch();
  757. //System.out.println("更新记录数"+ line);
  758. //6.释放资源
  759. //stat.close();
  760. Integer pn = Integer.parseInt(Id);
  761. Integer curpageNum = Integer.parseInt(Id) % pagesize;
  762. //logBasic("idxRow--getVariable"+getVariable("page"));
  763. //logBasic("idxRow--curpageNum"+curpageNum);
  764. if(pn > 0 &amp;&amp; curpageNum == 0){
  765. setVariable("page",String.valueOf(page));
  766. }
  767. //logBasic("idxRow--length"+i);
  768. }
  769. catch(Exception e) {
  770. throw new KettleException(e);
  771. }
  772. //释放连接
  773. //if (database!=null) {
  774. // database.disconnect();
  775. //database = null;
  776. //}
  777. //if (stat!=null) {
  778. // stat.close();
  779. // stat = null;
  780. //}
  781. // Send the row on to the next step.
  782. putRow(data.outputRowMeta, r);
  783. return true;
  784. }</class_source>
  785. </definition>
  786. </definitions>
  787. <fields>
  788. </fields>
  789. <clear_result_fields>N</clear_result_fields>
  790. <info_steps/>
  791. <target_steps/>
  792. <usage_parameters/>
  793. <attributes/>
  794. <cluster_schema/>
  795. <remotesteps>
  796. <input>
  797. </input>
  798. <output>
  799. </output>
  800. </remotesteps>
  801. <GUI>
  802. <xloc>352</xloc>
  803. <yloc>64</yloc>
  804. <draw>Y</draw>
  805. </GUI>
  806. </step>
  807. <step>
  808. <name>表输入 2</name>
  809. <type>TableInput</type>
  810. <description/>
  811. <distribute>Y</distribute>
  812. <custom_distribution/>
  813. <copies>1</copies>
  814. <partitioning>
  815. <method>none</method>
  816. <schema_name/>
  817. </partitioning>
  818. <connection>MallSqlserver</connection>
  819. <sql>
  820. select ROW_NUMBER() over (order by AConsigneePhone2 asc ) as MemberKey,
  821. case when sex= ''then 1 else sex end as MemberGender,
  822. Consignee as MemberNickName,
  823. case when AConsigneePhone2= '' then
  824. (case
  825. when AconsigneePhone1!='' then dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1)
  826. else ''end)
  827. ELSE dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) end as MemUsualPhone,--电话号码
  828. case when AConsigneePhone3= '' then ''
  829. ELSE dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone1) end as MemPhone1,--
  830. case when AConsigneePhone3= '' then ''
  831. ELSE dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone2) end as MemPhone2,--
  832. case when AConsigneePhone1= '' then ''
  833. ELSE dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',AConsigneePhone3) end as MemPhone3,--
  834. case when ADeliveryAddress= '' then ''
  835. ELSE dbo.DesDecryptFixKey('123456','123456e10adc3949ba59abbe56e057f20f883e',ADeliveryAddress) end as MemUsualAddress,
  836. OriginType,
  837. ( select CONVERT(varchar(100), min(b.OrderTime), 20) from orders b where b.AConsigneePhone2=a.AConsigneePhone2
  838. and b.OrderTime!='1800/01/01 00:00:00'
  839. group by b.AConsigneePhone2
  840. )
  841. as RegisterTime,
  842. case when b0.Level= 3 then a.RegionCode else null end as MemUsualAreaCode,
  843. case when b1.Level= 2 then b.ParentCode else b.AreaCode end as MemUsualCityCode,
  844. case when c1.Level= 1 then c.ParentCode else c.AreaCode end as MemUsualProvinceCode
  845. ,'true' as HasOrder
  846. ,convert(varchar,datepart(year,getdate())) as RegisterYear
  847. ,convert(varchar,datepart(month,getdate())) as RegisterMonth
  848. ,convert(varchar,datepart(day,getdate())) as RegisterDay
  849. ,'Member' as order_join_field
  850. from orders a
  851. left join Areamap b0 on b0.MappingCode=a.RegionCode
  852. left join AreaRegion b on b.AreaCode=a.RegionCode left join Areamap b1 on b1.MappingCode=b.ParentCode
  853. left join AreaRegion c on c.AreaCode=b.ParentCode left join Areamap c1 on c1.MappingCode=c.ParentCode
  854. where 1=1 and (a.AConsigneePhone2!= '' or a.AConsigneePhone1!= '')
  855. order by AConsigneePhone2 asc
  856. offset ((${page}-1)*${pagesize}) rows fetch NEXT (${pagesize}) rows only
  857. --offset 0 rows fetch NEXT 2 rows only
  858. </sql>
  859. <limit>0</limit>
  860. <lookup/>
  861. <execute_each_row>N</execute_each_row>
  862. <variables_active>Y</variables_active>
  863. <lazy_conversion_active>N</lazy_conversion_active>
  864. <attributes/>
  865. <cluster_schema/>
  866. <remotesteps>
  867. <input>
  868. </input>
  869. <output>
  870. </output>
  871. </remotesteps>
  872. <GUI>
  873. <xloc>224</xloc>
  874. <yloc>64</yloc>
  875. <draw>Y</draw>
  876. </GUI>
  877. </step>
  878. <step_error_handling>
  879. </step_error_handling>
  880. <slave-step-copy-partition-distribution>
  881. </slave-step-copy-partition-distribution>
  882. <slave_transformation>N</slave_transformation>
  883. <attributes/>
  884. </transformation>