SearchService.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. package com.uas.search.service;
  2. import com.uas.search.annotation.NotEmpty;
  3. import com.uas.search.constant.model.CollectField;
  4. import com.uas.search.constant.model.PageParams;
  5. import com.uas.search.constant.model.PageParams.FilterField;
  6. import com.uas.search.constant.model.SPage;
  7. import com.uas.search.model.*;
  8. import java.io.IOException;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Set;
  12. /**
  13. * 搜索服务的接口
  14. *
  15. * @author suntg
  16. * @since 2016年7月29日下午4:58:45
  17. */
  18. public interface SearchService {
  19. /**
  20. * 根据关键字搜索产品类目id
  21. *
  22. * @param keyword
  23. * 关键词
  24. * @param page
  25. * 页码
  26. * @param size
  27. * 页大小
  28. * @return 符合条件的类目id
  29. */
  30. public SPage<Long> getKindIds(String keyword, Integer page, Integer size) throws IOException;
  31. /**
  32. * 根据关键词搜索产品类目
  33. *
  34. * @param keyword
  35. * 关键词
  36. * @param page
  37. * 页码
  38. * @param size
  39. * 页大小
  40. * @return
  41. */
  42. public SPage<Map<String, Object>> getKinds(String keyword, Integer page, Integer size) throws IOException;
  43. /**
  44. * 根据关键词搜索产品品牌id
  45. *
  46. * @param keyword
  47. * 关键词
  48. * @param page
  49. * 页码
  50. * @param size
  51. * 页大小
  52. * @return 符合条件的品牌id
  53. */
  54. public SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws IOException;
  55. /**
  56. * 根据关键词搜索产品品牌
  57. *
  58. * @param keyword
  59. * 关键词
  60. * @param page
  61. * 页码
  62. * @param size
  63. * 页大小
  64. * @return 符合条件的品牌
  65. */
  66. public SPage<Map<String, Object>> getBrands(String keyword, Integer page, Integer size) throws IOException;
  67. /**
  68. * 根据关键词搜索品牌(精确命中后,提供卖家信息)
  69. * @param keyword 关键词
  70. * @param page 页码
  71. * @param size 页数
  72. * @return
  73. * @throws IOException
  74. */
  75. SPage<Map<String, Object>> getBrandsAndSellers(String keyword, Integer page, Integer size) throws IOException;
  76. /**
  77. * 根据关键词搜索品牌(精确命中后,提供卖家信息)
  78. * @param keyword 关键词
  79. * @param page 页码
  80. * @param size 页数
  81. * @return
  82. * @throws IOException
  83. */
  84. Map<String, Object> getSellersWithKind(String keyword, Integer page, Integer size) throws IOException;
  85. /**
  86. * 根据关键词搜索产品(关键词可能是器件、类目、品牌,甚至可能是类目、品牌的混合)
  87. *
  88. * @param keyword
  89. * 关键词
  90. * @param params
  91. * 翻页、过滤等信息
  92. * <p>
  93. * 关于过滤,通过键值对指定过滤条件,键为
  94. * {@link com.uas.search.constant.model.PageParams.FilterField}
  95. * ,值的类型由键决定:
  96. * </p>
  97. *
  98. * <table border=1 cellpadding=5 cellspacing=0 summary=
  99. * "Fields and types">
  100. * <tr>
  101. * <th>Field</th>
  102. * <th>Type</th>
  103. * </tr>
  104. * <tr>
  105. * <td>COMPONENT_KINDID</td>
  106. * <td>Long</td>
  107. * </tr>
  108. * <tr>
  109. * <td>COMPONENT_BRANDID</td>
  110. * <td>Long</td>
  111. * </tr>
  112. * <tr>
  113. * <td>COMPONENT_PROPERTIES</td>
  114. * <td>键值对,键值分别为属性id、属性值</td>
  115. * </tr>
  116. * <tr>
  117. * <td>COMPONENT_HAS_RESERVE</td>
  118. * <td>Boolean</td>
  119. * </tr>
  120. * <tr>
  121. * <td>COMPONENT_HAS_SAMPLE</td>
  122. * <td>Boolean</td>
  123. * </tr>
  124. * <tr>
  125. * <td>COMPONENT_HAS_ORIGINAL</td>
  126. * <td>Boolean</td>
  127. * </tr>
  128. * <tr>
  129. * <td>COMPONENT_HAS_INACTION_STOCK</td>
  130. * <td>Boolean</td>
  131. * </tr>
  132. * </table>
  133. *
  134. * @return
  135. */
  136. public Map<String, Object> getComponentIds(String keyword, PageParams params) ;
  137. /**
  138. * 根据产品搜索获取产品类目id的统计
  139. *
  140. * @param keyword
  141. * @param brandId
  142. * (可选)
  143. * @return
  144. */
  145. public Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) ;
  146. /**
  147. * 根据产品搜索获取产品类目的统计
  148. *
  149. * @param keyword
  150. * @param brandId
  151. * (可选)
  152. * @return
  153. */
  154. public Set<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId) ;
  155. /**
  156. * 根据产品搜索获取产品品牌id的统计
  157. *
  158. * @param keyword
  159. * @param kindId
  160. * (可选)
  161. * @return
  162. */
  163. public Set<Long> getBrandIdsBySearchComponent(String keyword, String kindId) ;
  164. /**
  165. * 根据产品搜索获取产品品牌的统计
  166. *
  167. * @param keyword
  168. * @param kindId
  169. * (可选)
  170. * @return
  171. */
  172. public Set<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) ;
  173. /**
  174. * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取,数量不足,才会获取下一个)
  175. *
  176. * @param keyword
  177. * @param size 指定的联想词数目
  178. * @return
  179. */
  180. public List<String> getSimilarKeywords(String keyword, Integer size) ;
  181. /**
  182. * 根据输入的原厂型号获取联想词
  183. *
  184. * @param componentCode
  185. * @param size 指定的联想词数目
  186. * @return 包括id、uuid、code
  187. */
  188. public List<Map<String, Object>> getSimilarComponents(String componentCode, Integer size) ;
  189. /**
  190. * 根据输入的物料型号获取联想词
  191. *
  192. * @param code
  193. * @param size 指定的联想词数目
  194. * @return 包括id、uuid、code
  195. */
  196. List<Map<String, Object>> getSimilarProducts(String code, Integer size) ;
  197. /**
  198. * 根据输入的品牌获取联想词
  199. *
  200. * @param brandName
  201. * @param size 指定的联想词数目
  202. * @return 包括id、uuid、nameCn、nameEn
  203. */
  204. public List<Map<String, Object>> getSimilarBrands(String brandName, Integer size) throws IOException;
  205. /**
  206. * 根据输入的类目名获取联想词
  207. *
  208. * @param kindName
  209. * @param size 指定的联想词数目
  210. * @return 包括id、nameCn、level、isLeaf
  211. */
  212. public List<Map<String, Object>> getSimilarKinds(String kindName, Integer size) throws IOException;
  213. /**
  214. * 根据输入的类目名获取末级类目联想词
  215. *
  216. * @param kindName
  217. * @param size 指定的联想词数目
  218. * @return 包括id、nameCn、level、isLeaf
  219. */
  220. public List<Map<String, Object>> getSimilarLeafKinds(String kindName, Integer size) throws IOException;
  221. /**
  222. * 根据输入的类目名和指定的类目级别获取联想词
  223. *
  224. * @param kindName
  225. * @param level
  226. * @param size 指定的联想词数目
  227. * @return 包括id、nameCn、level、isLeaf
  228. */
  229. public List<Map<String, Object>> getSimilarKindsByLevel(String kindName, Short level, Integer size) throws IOException;
  230. /**
  231. * 根据类目id、属性id、属性值获取联想词
  232. *
  233. * @param kindId
  234. * 类目id
  235. * @param propertyId
  236. * 属性id
  237. * @param keyword
  238. * (可选) 属性值(部分字符)
  239. * @param topNum
  240. * (可选) 获取的最大数目
  241. * @return 相似的属性值,包括propertyValue
  242. */
  243. public List<Map<String, String>> getSimilarPropertyValues(Long kindId, Long propertyId, String keyword, Long topNum);
  244. /**
  245. * 根据关键词搜索批次(关键词可能是器件、类目、品牌)
  246. *
  247. * @param keyword
  248. * 关键词
  249. * @param pageParams
  250. * 翻页、过滤、排序等信息
  251. * <p>
  252. * 关于过滤,通过键值对指定过滤条件,键为
  253. * {@link com.uas.search.constant.model.PageParams.FilterField}
  254. * ,值的类型由键决定:
  255. * </p>
  256. *
  257. * <table border=1 cellpadding=5 cellspacing=0 summary=
  258. * "Fields and types">
  259. * <tr>
  260. * <th>Field</th>
  261. * <th>Type</th>
  262. * </tr>
  263. * <tr>
  264. * <td>GOODS_KINDID</td>
  265. * <td>List(Long)</td>
  266. * </tr>
  267. * <tr>
  268. * <td>GOODS_BRANDID</td>
  269. * <td>List(Long)</td>
  270. * </tr>
  271. * <tr>
  272. * <td>GOODS_STORE_TYPE</td>
  273. * <td>List(String)</td>
  274. * </tr>
  275. * <tr>
  276. * <td>GOODS_CRNAME</td>
  277. * <td>List(String)</td>
  278. * </tr>
  279. * <tr>
  280. * <td>GOODS_MINPRICERMB</td>
  281. * <td>Double</td>
  282. * </tr>
  283. * <tr>
  284. * <td>GOODS_MAXPRICERMB</td>
  285. * <td>Double</td>
  286. * </tr>
  287. * <tr>
  288. * <td>GOODS_MINPRICEUSD</td>
  289. * <td>Double</td>
  290. * </tr>
  291. * <tr>
  292. * <td>GOODS_MAXPRICEUSD</td>
  293. * <td>Double</td>
  294. * </tr>
  295. * </table>
  296. *
  297. * @return 器件id、批次id和分页信息
  298. */
  299. public Map<String, Object> getGoodsIds(String keyword, PageParams pageParams) throws IOException;
  300. /**
  301. * 根据关键词搜索 PCB 批次
  302. *
  303. * @param keyword
  304. * 关键词
  305. * @param pageParams
  306. * 翻页、过滤、排序等信息
  307. * <p>
  308. * 关于过滤,通过键值对指定过滤条件,键为
  309. * {@link com.uas.search.constant.model.PageParams.FilterField}
  310. * ,值的类型由键决定:
  311. * </p>
  312. *
  313. * <table border=1 cellpadding=5 cellspacing=0 summary=
  314. * "Fields and types">
  315. * <tr>
  316. * <th>Field</th>
  317. * <th>Type</th>
  318. * </tr>
  319. * <tr>
  320. * <td>GOODS_KINDID</td>
  321. * <td>List(Long)</td>
  322. * </tr>
  323. * <tr>
  324. * <td>GOODS_BRANDID</td>
  325. * <td>List(Long)</td>
  326. * </tr>
  327. * <tr>
  328. * <td>GOODS_CRNAME</td>
  329. * <td>List(String)</td>
  330. * </tr>
  331. * <tr>
  332. * <td>GOODS_MINPRICERMB</td>
  333. * <td>Double</td>
  334. * </tr>
  335. * <tr>
  336. * <td>GOODS_MAXPRICERMB</td>
  337. * <td>Double</td>
  338. * </tr>
  339. * <tr>
  340. * <td>GOODS_MINPRICEUSD</td>
  341. * <td>Double</td>
  342. * </tr>
  343. * <tr>
  344. * <td>GOODS_MAXPRICEUSD</td>
  345. * <td>Double</td>
  346. * </tr>
  347. * </table>
  348. *
  349. * @return PCB id、批次 id 和分页信息
  350. */
  351. Map<String, Object> getPCBGoodsIds(String keyword, PageParams pageParams) throws IOException;
  352. /**
  353. * 搜索批次时,统计指定信息
  354. *
  355. * @param keyword
  356. * 关键词
  357. * @param collectedField
  358. * 需要统计的信息
  359. * @param filters
  360. * 过滤条件,值的类型由键决定:
  361. *
  362. * <table border=1 cellpadding=5 cellspacing=0 summary=
  363. * "Fields and types">
  364. * <tr>
  365. * <th>Field</th>
  366. * <th>Type</th>
  367. * </tr>
  368. * <tr>
  369. * <td>GOODS_KINDID</td>
  370. * <td>List(Long)</td>
  371. * </tr>
  372. * <tr>
  373. * <td>GOODS_BRANDID</td>
  374. * <td>List(Long)</td>
  375. * </tr>
  376. * <tr>
  377. * <td>GOODS_STORE_TYPE</td>
  378. * <td>List(String)</td>
  379. * </tr>
  380. * <tr>
  381. * <td>GOODS_CRNAME</td>
  382. * <td>List(String)</td>
  383. * </tr>
  384. * </table>
  385. *
  386. * @return 统计的信息(由collectedField决定)
  387. *
  388. * <table border=1 cellpadding=5 cellspacing=0 summary=
  389. * "Collected fields and messages">
  390. * <tr>
  391. * <th>Collected field</th>
  392. * <th>Message</th>
  393. * </tr>
  394. * <tr>
  395. * <td>GOODS_KIND</td>
  396. * <td>ki_id、ki_name_cn</td>
  397. * </tr>
  398. * <tr>
  399. * <td>GOODS_BRAND</td>
  400. * <td>br_id、br_uuid、br_name_cn、br_name_en</td>
  401. * </tr>
  402. * <tr>
  403. * <td>GOODS_STORE_TYPE</td>
  404. * <td>store_type</td>
  405. * </tr>
  406. * <tr>
  407. * <td>GOODS_CRNAME</td>
  408. * <td>cr_name</td>
  409. * </tr>
  410. * </table>
  411. */
  412. public List<Map<String, Object>> collectBySearchGoods(String keyword, CollectField collectedField,
  413. Map<FilterField, Object> filters) throws IOException;
  414. /**
  415. * 搜索 PCB 批次时,统计指定信息
  416. *
  417. * @param keyword
  418. * 关键词
  419. * @param collectedField
  420. * 需要统计的信息
  421. * @param filters
  422. * 过滤条件,值的类型由键决定:
  423. *
  424. * <table border=1 cellpadding=5 cellspacing=0 summary=
  425. * "Fields and types">
  426. * <tr>
  427. * <th>Field</th>
  428. * <th>Type</th>
  429. * </tr>
  430. * <tr>
  431. * <td>GOODS_KINDID</td>
  432. * <td>List(Long)</td>
  433. * </tr>
  434. * <tr>
  435. * <td>GOODS_BRANDID</td>
  436. * <td>List(Long)</td>
  437. * </tr>
  438. * <tr>
  439. * <td>GOODS_CRNAME</td>
  440. * <td>List(String)</td>
  441. * </tr>
  442. * </table>
  443. *
  444. * @return 统计的信息(由collectedField决定)
  445. *
  446. * <table border=1 cellpadding=5 cellspacing=0 summary=
  447. * "Collected fields and messages">
  448. * <tr>
  449. * <th>Collected field</th>
  450. * <th>Message</th>
  451. * </tr>
  452. * <tr>
  453. * <td>GOODS_KIND</td>
  454. * <td>ki_id、ki_name_cn</td>
  455. * </tr>
  456. * <tr>
  457. * <td>GOODS_BRAND</td>
  458. * <td>br_id、br_uuid、br_name_cn、br_name_en</td>
  459. * </tr>
  460. * <tr>
  461. * <td>GOODS_CRNAME</td>
  462. * <td>cr_name</td>
  463. * </tr>
  464. * </table>
  465. */
  466. List<Map<String, Object>> collectBySearchPCBGoods(String keyword, CollectField collectedField,
  467. Map<FilterField, Object> filters) throws IOException;
  468. /**
  469. * 根据id获取类目
  470. *
  471. * @param id
  472. * @return
  473. */
  474. public Kind getKind(Long id) throws IOException;
  475. /**
  476. * 根据id获取品牌
  477. *
  478. * @param id
  479. * @return
  480. */
  481. public Brand getBrand(Long id) throws IOException;
  482. /**
  483. * 根据id获取器件
  484. *
  485. * @param id
  486. * @return
  487. */
  488. public Component getComponent(Long id) throws IOException;
  489. /**
  490. * 根据id获取批次
  491. *
  492. * @param id
  493. * @return
  494. */
  495. public Goods getGoods(String id) throws IOException;
  496. /**
  497. * 根据id获取 PCB 批次
  498. *
  499. * @param id
  500. * @return
  501. */
  502. public PCBGoods getPCBGoods(String id) throws IOException;
  503. /**
  504. * 分页获取本地指定表的索引中的数据
  505. *
  506. * @param tableName
  507. * 表名
  508. * @param keyword
  509. * 关键词,可为空,默认正则搜索空串
  510. * @param field
  511. * 搜索字段,可为空,默认取各表索引中的id字段
  512. * @param tokenized
  513. * 是否分词,可为空,默认不分词
  514. * @param page
  515. * 页码
  516. * @param size
  517. * 分页大小
  518. * @return
  519. */
  520. public SPage<Object> getObjects(String tableName, String keyword, String field, Boolean tokenized, @NotEmpty("page") Integer page, @NotEmpty("size") Integer size) throws IOException;
  521. /**
  522. * 查询物料
  523. * @param enUU 企业UU
  524. * @param keyword 关键词
  525. * @param page 页码
  526. * @param size 尺寸
  527. * @param type all 全部 standard 标准 nStandard 非标
  528. * @return idPage
  529. * @throws IOException 输入异常
  530. */
  531. SPage<Long> getProductIds(Long enUU, String keyword, Integer page, Integer size, String type) throws IOException;
  532. /**
  533. * 根据id获取物料
  534. *
  535. * @param id
  536. * @return
  537. */
  538. V_Products getProduct(Long id) throws IOException;
  539. /**
  540. * 获取标准型号联想词
  541. * @param keyword 关键词
  542. * @param size 尺寸
  543. * @return
  544. */
  545. List<Map<String,Object>> getSimilarPCmpCodes(String keyword, Integer size);
  546. /**
  547. * 获取类目联想词
  548. * @param keyword 关键词
  549. * @param size 尺寸
  550. * @return
  551. */
  552. List<Map<String,Object>> getSimilarKind(String keyword, Integer size);
  553. }