etl_all_OrdersPrescription.ktr 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <transformation>
  3. <info>
  4. <name>etl_all_OrdersPrescription</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/07/12 17:22:11.899</created_date>
  431. <modified_user>-</modified_user>
  432. <modified_date>2019/07/12 17:22:11.899</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>219.128.77.96Mall</name>
  440. <server>219.128.77.96</server>
  441. <type>MSSQLNATIVE</type>
  442. <access>Native</access>
  443. <database>Mall</database>
  444. <port>1433</port>
  445. <username>caixukun</username>
  446. <password>Encrypted 2be98afc86aa7f2e4a801a5508cc2fe83</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. <connection>
  498. <name>mall</name>
  499. <server>192.168.50.32</server>
  500. <type>MSSQLNATIVE</type>
  501. <access>Native</access>
  502. <database>Mall</database>
  503. <port>1433</port>
  504. <username>sa</username>
  505. <password>Encrypted 2be98afc86aa7f297aa15a478c7d38f99</password>
  506. <servername/>
  507. <data_tablespace/>
  508. <index_tablespace/>
  509. <attributes>
  510. <attribute>
  511. <code>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
  512. <attribute>N</attribute>
  513. </attribute>
  514. <attribute>
  515. <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
  516. <attribute>N</attribute>
  517. </attribute>
  518. <attribute>
  519. <code>IS_CLUSTERED</code>
  520. <attribute>N</attribute>
  521. </attribute>
  522. <attribute>
  523. <code>MSSQLUseIntegratedSecurity</code>
  524. <attribute>false</attribute>
  525. </attribute>
  526. <attribute>
  527. <code>MSSQL_DOUBLE_DECIMAL_SEPARATOR</code>
  528. <attribute>N</attribute>
  529. </attribute>
  530. <attribute>
  531. <code>PORT_NUMBER</code>
  532. <attribute>1433</attribute>
  533. </attribute>
  534. <attribute>
  535. <code>PRESERVE_RESERVED_WORD_CASE</code>
  536. <attribute>Y</attribute>
  537. </attribute>
  538. <attribute>
  539. <code>QUOTE_ALL_FIELDS</code>
  540. <attribute>N</attribute>
  541. </attribute>
  542. <attribute>
  543. <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
  544. <attribute>Y</attribute>
  545. </attribute>
  546. <attribute>
  547. <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
  548. <attribute>Y</attribute>
  549. </attribute>
  550. <attribute>
  551. <code>USE_POOLING</code>
  552. <attribute>N</attribute>
  553. </attribute>
  554. </attributes>
  555. </connection>
  556. <order>
  557. <hop>
  558. <from>Java 代码</from>
  559. <to>表输出</to>
  560. <enabled>Y</enabled>
  561. </hop>
  562. <hop>
  563. <from>表输入</from>
  564. <to>Java 代码</to>
  565. <enabled>Y</enabled>
  566. </hop>
  567. </order>
  568. <step>
  569. <name>Java 代码</name>
  570. <type>UserDefinedJavaClass</type>
  571. <description/>
  572. <distribute>Y</distribute>
  573. <custom_distribution/>
  574. <copies>10</copies>
  575. <partitioning>
  576. <method>none</method>
  577. <schema_name/>
  578. </partitioning>
  579. <definitions>
  580. <definition>
  581. <class_type>TRANSFORM_CLASS</class_type>
  582. <class_name>Processor</class_name>
  583. <class_source>import java.sql.*;
  584. import org.pentaho.di.core.database.*;
  585. import org.apache.http.HttpHost;
  586. import org.elasticsearch.ElasticsearchException;
  587. import org.elasticsearch.action.get.GetRequest;
  588. import org.elasticsearch.action.get.GetResponse;
  589. import org.elasticsearch.client.RestHighLevelClient;
  590. import org.elasticsearch.client.RequestOptions;
  591. import org.elasticsearch.client.RestClient;
  592. import org.elasticsearch.common.Strings;
  593. import org.elasticsearch.rest.RestStatus;
  594. import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
  595. import org.elasticsearch.action.update.UpdateRequest;
  596. import org.elasticsearch.action.update.UpdateResponse;
  597. import org.elasticsearch.common.xcontent.XContentBuilder;
  598. import org.elasticsearch.common.xcontent.XContentFactory;
  599. import org.elasticsearch.script.Script;
  600. import java.lang.reflect.InvocationTargetException;
  601. import java.lang.reflect.Method;
  602. import com.microsoft.sqlserver.jdbc.SQLServerException;
  603. Database database = null;
  604. PreparedStatement stat = null;
  605. PreparedStatement stat1 = null;
  606. RestHighLevelClient client = new RestHighLevelClient(
  607. RestClient.builder(
  608. new HttpHost[]{new HttpHost("192.168.50.32", 9200, "http")}));
  609. Integer index = 0;
  610. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  611. {
  612. //logBasic("start---");
  613. Object[] r = getRow();
  614. if (r == null) {
  615. try {
  616. if (stat!=null) {
  617. stat.close();
  618. }
  619. if (stat1!=null) {
  620. stat1.close();
  621. }
  622. if (database!=null) {
  623. database.disconnect();
  624. }
  625. if(client!=null){
  626. client.close();
  627. }
  628. }
  629. catch(Exception e) {
  630. throw new KettleException(e);
  631. }
  632. setOutputDone();
  633. return false;
  634. }
  635. synchronized(this) {
  636. r = createOutputRow(r, data.outputRowMeta.size());
  637. //获取数据库名和表名
  638. String dbName = "mall";
  639. String tablename = "PrescriptionRecord";//getInputRowMeta().getString(r, "tablename", null );
  640. String sourceidname = "Id";//getInputRowMeta().getString(r, "sourceidname", null );
  641. if (dbName==null||tablename==null) {
  642. throw new KettleException("Unable to find field with name "+tablename+" in the input row.");
  643. }
  644. //logBasic("table---"+tablename);
  645. if(database == null){
  646. //数据库连接
  647. DatabaseMeta databaseMeta=null;
  648. try {
  649. databaseMeta = getTransMeta().findDatabase(dbName);
  650. if (databaseMeta==null) {
  651. logError("A connection with name "+dbName+" could not be found!");
  652. setErrors(1);
  653. return false;
  654. }
  655. database = new Database(getTrans(), databaseMeta);
  656. database.connect();
  657. //logBasic("success!");
  658. } catch(Exception e) {
  659. logError("Connecting to database "+dbName+" failed.", e);
  660. setErrors(1);
  661. return false;
  662. }
  663. }
  664. //查询表数据
  665. try {
  666. RowMetaInterface idxRowMeta =data.outputRowMeta;
  667. int i=0;
  668. r = createOutputRow(r, data.outputRowMeta.size());
  669. //int index = getInputRowMeta().size();
  670. // Add the column name
  671. String DataId = idxRowMeta.getString(r, sourceidname, null);
  672. String sqlSelect = "select Id from "+tablename + " where Id = '"+ DataId +"'";
  673. ResultSet resultSet = null;
  674. resultSet = database.openQuery(sqlSelect);
  675. Object[] idxRow = database.getRow(resultSet);
  676. if (database!=null) {
  677. database.closeQuery(resultSet);
  678. resultSet = null;
  679. idxRowMeta = null;
  680. }
  681. if(idxRow != null){
  682. return true;
  683. }
  684. //logBasic("idxRow--Id"+Id);
  685. //logBasic("idxRow--sourcetablename"+sourcetablename);
  686. //logBasic("idxRow--DataId"+DataId);
  687. /*
  688. GetRequest getRequest = new GetRequest(
  689. "crm_order_routingphone", // Index
  690. "_doc", // /Type
  691. DataId); // Document id
  692. getRequest.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
  693. getRequest.storedFields(new String[]{"_none_"}); // 禁止存储任何字段
  694. boolean exists = client.exists(getRequest,RequestOptions.DEFAULT);
  695. //client.close();
  696. if(exists ){
  697. return true;
  698. }
  699. //if(!exists &amp;&amp; idxRow == null){
  700. // return true;
  701. //}
  702. */
  703. /*
  704. //3.获得预处理对象
  705. String sql="insert into "+tablename+" values (?,?,?,?);";//begin tran t2; commit tran t2
  706. //logBasic("idxRow--database"+ database);
  707. if(stat == null)
  708. stat = database.prepareSQL(sql);
  709. //logBasic("idxRow--database"+ stat);
  710. //stat.addBatch(sql);
  711. //4.SQL语句占位符设置实际参数
  712. stat.setString(1, Id);//索引参数1代表着sql中的第一个?号,也就是我需要将条件sid所对应的sname数据更新为“儿童玩具测试”
  713. stat.setString(2, sourcetablename);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  714. stat.setString(3, DataId);//索引参数2代表着sql中的第二个?号,也就是条件是sid为3
  715. stat.setString(4, "phone1");
  716. //stat.setInt(5, index);
  717. //5.执行SQL语句
  718. boolean line = stat.execute();
  719. //int[] line = stat.executeBatch();
  720. //System.out.println("更新记录数"+ line);
  721. //6.释放资源
  722. //stat.close();
  723. */
  724. }
  725. catch(SQLServerException e) {
  726. return true;
  727. }catch(Exception e) {
  728. throw new KettleException(e);
  729. }
  730. //释放连接
  731. //if (database!=null) {
  732. // database.disconnect();
  733. //}
  734. // Send the row on to the next step.
  735. }
  736. putRow(data.outputRowMeta, r);
  737. return true;
  738. }</class_source>
  739. </definition>
  740. </definitions>
  741. <fields>
  742. </fields>
  743. <clear_result_fields>N</clear_result_fields>
  744. <info_steps/>
  745. <target_steps/>
  746. <usage_parameters/>
  747. <attributes/>
  748. <cluster_schema/>
  749. <remotesteps>
  750. <input>
  751. </input>
  752. <output>
  753. </output>
  754. </remotesteps>
  755. <GUI>
  756. <xloc>352</xloc>
  757. <yloc>80</yloc>
  758. <draw>Y</draw>
  759. </GUI>
  760. </step>
  761. <step>
  762. <name>表输入</name>
  763. <type>TableInput</type>
  764. <description/>
  765. <distribute>Y</distribute>
  766. <custom_distribution/>
  767. <copies>1</copies>
  768. <partitioning>
  769. <method>none</method>
  770. <schema_name/>
  771. </partitioning>
  772. <connection>219.128.77.96Mall</connection>
  773. <sql>
  774. SELECT * FROM PrescriptionRecord a
  775. where a.CreationDate > '2019-05-01 17:56:29'
  776. and datediff(day,DATEADD(d,0,DATEDIFF(d,0,getdate())-10),CreationDate )>0
  777. order by CreationDate asc
  778. </sql>
  779. <limit>0</limit>
  780. <lookup/>
  781. <execute_each_row>N</execute_each_row>
  782. <variables_active>N</variables_active>
  783. <lazy_conversion_active>N</lazy_conversion_active>
  784. <attributes/>
  785. <cluster_schema/>
  786. <remotesteps>
  787. <input>
  788. </input>
  789. <output>
  790. </output>
  791. </remotesteps>
  792. <GUI>
  793. <xloc>192</xloc>
  794. <yloc>96</yloc>
  795. <draw>Y</draw>
  796. </GUI>
  797. </step>
  798. <step>
  799. <name>表输出</name>
  800. <type>TableOutput</type>
  801. <description/>
  802. <distribute>Y</distribute>
  803. <custom_distribution/>
  804. <copies>1</copies>
  805. <partitioning>
  806. <method>none</method>
  807. <schema_name/>
  808. </partitioning>
  809. <connection>mall</connection>
  810. <schema>dbo</schema>
  811. <table>PrescriptionRecord</table>
  812. <commit>1000</commit>
  813. <truncate>N</truncate>
  814. <ignore_errors>N</ignore_errors>
  815. <use_batch>Y</use_batch>
  816. <specify_fields>N</specify_fields>
  817. <partitioning_enabled>N</partitioning_enabled>
  818. <partitioning_field/>
  819. <partitioning_daily>N</partitioning_daily>
  820. <partitioning_monthly>Y</partitioning_monthly>
  821. <tablename_in_field>N</tablename_in_field>
  822. <tablename_field/>
  823. <tablename_in_table>Y</tablename_in_table>
  824. <return_keys>N</return_keys>
  825. <return_field/>
  826. <fields>
  827. </fields>
  828. <attributes/>
  829. <cluster_schema/>
  830. <remotesteps>
  831. <input>
  832. </input>
  833. <output>
  834. </output>
  835. </remotesteps>
  836. <GUI>
  837. <xloc>400</xloc>
  838. <yloc>192</yloc>
  839. <draw>Y</draw>
  840. </GUI>
  841. </step>
  842. <step_error_handling>
  843. </step_error_handling>
  844. <slave-step-copy-partition-distribution>
  845. </slave-step-copy-partition-distribution>
  846. <slave_transformation>N</slave_transformation>
  847. <attributes/>
  848. </transformation>