SearchService.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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 brandName
  193. * @param size 指定的联想词数目
  194. * @return 包括id、uuid、nameCn、nameEn
  195. */
  196. public List<Map<String, Object>> getSimilarBrands(String brandName, Integer size) throws IOException;
  197. /**
  198. * 根据输入的类目名获取联想词
  199. *
  200. * @param kindName
  201. * @param size 指定的联想词数目
  202. * @return 包括id、nameCn、level、isLeaf
  203. */
  204. public List<Map<String, Object>> getSimilarKinds(String kindName, 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>> getSimilarLeafKinds(String kindName, Integer size) throws IOException;
  213. /**
  214. * 根据输入的类目名和指定的类目级别获取联想词
  215. *
  216. * @param kindName
  217. * @param level
  218. * @param size 指定的联想词数目
  219. * @return 包括id、nameCn、level、isLeaf
  220. */
  221. public List<Map<String, Object>> getSimilarKindsByLevel(String kindName, Short level, Integer size) throws IOException;
  222. /**
  223. * 根据类目id、属性id、属性值获取联想词
  224. *
  225. * @param kindId
  226. * 类目id
  227. * @param propertyId
  228. * 属性id
  229. * @param keyword
  230. * (可选) 属性值(部分字符)
  231. * @param topNum
  232. * (可选) 获取的最大数目
  233. * @return 相似的属性值,包括propertyValue
  234. */
  235. public List<Map<String, String>> getSimilarPropertyValues(Long kindId, Long propertyId, String keyword, Long topNum);
  236. /**
  237. * 根据关键词搜索批次(关键词可能是器件、类目、品牌)
  238. *
  239. * @param keyword
  240. * 关键词
  241. * @param pageParams
  242. * 翻页、过滤、排序等信息
  243. * <p>
  244. * 关于过滤,通过键值对指定过滤条件,键为
  245. * {@link com.uas.search.constant.model.PageParams.FilterField}
  246. * ,值的类型由键决定:
  247. * </p>
  248. *
  249. * <table border=1 cellpadding=5 cellspacing=0 summary=
  250. * "Fields and types">
  251. * <tr>
  252. * <th>Field</th>
  253. * <th>Type</th>
  254. * </tr>
  255. * <tr>
  256. * <td>GOODS_KINDID</td>
  257. * <td>List(Long)</td>
  258. * </tr>
  259. * <tr>
  260. * <td>GOODS_BRANDID</td>
  261. * <td>List(Long)</td>
  262. * </tr>
  263. * <tr>
  264. * <td>GOODS_STORE_TYPE</td>
  265. * <td>List(String)</td>
  266. * </tr>
  267. * <tr>
  268. * <td>GOODS_CRNAME</td>
  269. * <td>List(String)</td>
  270. * </tr>
  271. * <tr>
  272. * <td>GOODS_MINPRICERMB</td>
  273. * <td>Double</td>
  274. * </tr>
  275. * <tr>
  276. * <td>GOODS_MAXPRICERMB</td>
  277. * <td>Double</td>
  278. * </tr>
  279. * <tr>
  280. * <td>GOODS_MINPRICEUSD</td>
  281. * <td>Double</td>
  282. * </tr>
  283. * <tr>
  284. * <td>GOODS_MAXPRICEUSD</td>
  285. * <td>Double</td>
  286. * </tr>
  287. * </table>
  288. *
  289. * @return 器件id、批次id和分页信息
  290. */
  291. public Map<String, Object> getGoodsIds(String keyword, PageParams pageParams) throws IOException;
  292. /**
  293. * 根据关键词搜索 PCB 批次
  294. *
  295. * @param keyword
  296. * 关键词
  297. * @param pageParams
  298. * 翻页、过滤、排序等信息
  299. * <p>
  300. * 关于过滤,通过键值对指定过滤条件,键为
  301. * {@link com.uas.search.constant.model.PageParams.FilterField}
  302. * ,值的类型由键决定:
  303. * </p>
  304. *
  305. * <table border=1 cellpadding=5 cellspacing=0 summary=
  306. * "Fields and types">
  307. * <tr>
  308. * <th>Field</th>
  309. * <th>Type</th>
  310. * </tr>
  311. * <tr>
  312. * <td>GOODS_KINDID</td>
  313. * <td>List(Long)</td>
  314. * </tr>
  315. * <tr>
  316. * <td>GOODS_BRANDID</td>
  317. * <td>List(Long)</td>
  318. * </tr>
  319. * <tr>
  320. * <td>GOODS_CRNAME</td>
  321. * <td>List(String)</td>
  322. * </tr>
  323. * <tr>
  324. * <td>GOODS_MINPRICERMB</td>
  325. * <td>Double</td>
  326. * </tr>
  327. * <tr>
  328. * <td>GOODS_MAXPRICERMB</td>
  329. * <td>Double</td>
  330. * </tr>
  331. * <tr>
  332. * <td>GOODS_MINPRICEUSD</td>
  333. * <td>Double</td>
  334. * </tr>
  335. * <tr>
  336. * <td>GOODS_MAXPRICEUSD</td>
  337. * <td>Double</td>
  338. * </tr>
  339. * </table>
  340. *
  341. * @return PCB id、批次 id 和分页信息
  342. */
  343. Map<String, Object> getPCBGoodsIds(String keyword, PageParams pageParams) throws IOException;
  344. /**
  345. * 搜索批次时,统计指定信息
  346. *
  347. * @param keyword
  348. * 关键词
  349. * @param collectedField
  350. * 需要统计的信息
  351. * @param filters
  352. * 过滤条件,值的类型由键决定:
  353. *
  354. * <table border=1 cellpadding=5 cellspacing=0 summary=
  355. * "Fields and types">
  356. * <tr>
  357. * <th>Field</th>
  358. * <th>Type</th>
  359. * </tr>
  360. * <tr>
  361. * <td>GOODS_KINDID</td>
  362. * <td>List(Long)</td>
  363. * </tr>
  364. * <tr>
  365. * <td>GOODS_BRANDID</td>
  366. * <td>List(Long)</td>
  367. * </tr>
  368. * <tr>
  369. * <td>GOODS_STORE_TYPE</td>
  370. * <td>List(String)</td>
  371. * </tr>
  372. * <tr>
  373. * <td>GOODS_CRNAME</td>
  374. * <td>List(String)</td>
  375. * </tr>
  376. * </table>
  377. *
  378. * @return 统计的信息(由collectedField决定)
  379. *
  380. * <table border=1 cellpadding=5 cellspacing=0 summary=
  381. * "Collected fields and messages">
  382. * <tr>
  383. * <th>Collected field</th>
  384. * <th>Message</th>
  385. * </tr>
  386. * <tr>
  387. * <td>GOODS_KIND</td>
  388. * <td>ki_id、ki_name_cn</td>
  389. * </tr>
  390. * <tr>
  391. * <td>GOODS_BRAND</td>
  392. * <td>br_id、br_uuid、br_name_cn、br_name_en</td>
  393. * </tr>
  394. * <tr>
  395. * <td>GOODS_STORE_TYPE</td>
  396. * <td>store_type</td>
  397. * </tr>
  398. * <tr>
  399. * <td>GOODS_CRNAME</td>
  400. * <td>cr_name</td>
  401. * </tr>
  402. * </table>
  403. */
  404. public List<Map<String, Object>> collectBySearchGoods(String keyword, CollectField collectedField,
  405. Map<FilterField, Object> filters) throws IOException;
  406. /**
  407. * 搜索 PCB 批次时,统计指定信息
  408. *
  409. * @param keyword
  410. * 关键词
  411. * @param collectedField
  412. * 需要统计的信息
  413. * @param filters
  414. * 过滤条件,值的类型由键决定:
  415. *
  416. * <table border=1 cellpadding=5 cellspacing=0 summary=
  417. * "Fields and types">
  418. * <tr>
  419. * <th>Field</th>
  420. * <th>Type</th>
  421. * </tr>
  422. * <tr>
  423. * <td>GOODS_KINDID</td>
  424. * <td>List(Long)</td>
  425. * </tr>
  426. * <tr>
  427. * <td>GOODS_BRANDID</td>
  428. * <td>List(Long)</td>
  429. * </tr>
  430. * <tr>
  431. * <td>GOODS_CRNAME</td>
  432. * <td>List(String)</td>
  433. * </tr>
  434. * </table>
  435. *
  436. * @return 统计的信息(由collectedField决定)
  437. *
  438. * <table border=1 cellpadding=5 cellspacing=0 summary=
  439. * "Collected fields and messages">
  440. * <tr>
  441. * <th>Collected field</th>
  442. * <th>Message</th>
  443. * </tr>
  444. * <tr>
  445. * <td>GOODS_KIND</td>
  446. * <td>ki_id、ki_name_cn</td>
  447. * </tr>
  448. * <tr>
  449. * <td>GOODS_BRAND</td>
  450. * <td>br_id、br_uuid、br_name_cn、br_name_en</td>
  451. * </tr>
  452. * <tr>
  453. * <td>GOODS_CRNAME</td>
  454. * <td>cr_name</td>
  455. * </tr>
  456. * </table>
  457. */
  458. List<Map<String, Object>> collectBySearchPCBGoods(String keyword, CollectField collectedField,
  459. Map<FilterField, Object> filters) throws IOException;
  460. /**
  461. * 根据id获取类目
  462. *
  463. * @param id
  464. * @return
  465. */
  466. public Kind getKind(Long id) throws IOException;
  467. /**
  468. * 根据id获取品牌
  469. *
  470. * @param id
  471. * @return
  472. */
  473. public Brand getBrand(Long id) throws IOException;
  474. /**
  475. * 根据id获取器件
  476. *
  477. * @param id
  478. * @return
  479. */
  480. public Component getComponent(Long id) throws IOException;
  481. /**
  482. * 根据id获取批次
  483. *
  484. * @param id
  485. * @return
  486. */
  487. public Goods getGoods(String id) throws IOException;
  488. /**
  489. * 根据id获取 PCB 批次
  490. *
  491. * @param id
  492. * @return
  493. */
  494. public PCBGoods getPCBGoods(String id) throws IOException;
  495. /**
  496. * 分页获取本地指定表的索引中的数据
  497. *
  498. * @param tableName
  499. * 表名
  500. * @param keyword
  501. * 关键词,可为空,默认正则搜索空串
  502. * @param field
  503. * 搜索字段,可为空,默认取各表索引中的id字段
  504. * @param tokenized
  505. * 是否分词,可为空,默认不分词
  506. * @param page
  507. * 页码
  508. * @param size
  509. * 分页大小
  510. * @return
  511. */
  512. public SPage<Object> getObjects(String tableName, String keyword, String field, Boolean tokenized, @NotEmpty("page") Integer page, @NotEmpty("size") Integer size) throws IOException;
  513. /**
  514. * 查询物料
  515. * @param enUU 企业UU
  516. * @param keyword 关键词
  517. * @param page 页码
  518. * @param size 尺寸
  519. * @param type all 全部 standard 标准 nStandard 非标
  520. * @return idPage
  521. * @throws IOException 输入异常
  522. */
  523. SPage<Long> getProductIds(Long enUU, String keyword, Integer page, Integer size, String type) throws IOException;
  524. /**
  525. * 根据id获取物料
  526. *
  527. * @param id
  528. * @return
  529. */
  530. V_Products getProduct(Long id) throws IOException;
  531. /**
  532. * 获取标准型号联想词
  533. * @param keyword 关键词
  534. * @param size 尺寸
  535. * @return
  536. */
  537. List<Map<String,Object>> getSimilarPCmpCodes(String keyword, Integer size);
  538. /**
  539. * 获取类目联想词
  540. * @param keyword 关键词
  541. * @param size 尺寸
  542. * @return
  543. */
  544. List<Map<String,Object>> getSimilarKind(String keyword, Integer size);
  545. }