|
|
@@ -11,6 +11,9 @@ import com.uas.platform.b2b.erp.model.B2BVendor;
|
|
|
import com.uas.platform.b2b.erp.model.SaleTenderErp;
|
|
|
import com.uas.platform.b2b.erp.model.SaleTenderItemErp;
|
|
|
import com.uas.platform.b2b.model.*;
|
|
|
+import com.uas.platform.b2b.service.BrandService;
|
|
|
+import com.uas.platform.b2b.service.ComponentService;
|
|
|
+import com.uas.platform.b2b.service.KindService;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateFactory;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
@@ -34,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
|
* 搜索实现
|
|
|
- *
|
|
|
+ *
|
|
|
* @author sunyj
|
|
|
* @since 2016年11月11日 上午10:43:25
|
|
|
*/
|
|
|
@@ -135,9 +138,6 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
@Autowired
|
|
|
private ProductDao productDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ComponentDao componentDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private EnterpriseDao enterpriseDao;
|
|
|
|
|
|
@@ -156,9 +156,6 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
@Autowired
|
|
|
private VendorDao vendorDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private BrandDao brandDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private PurcInquiryDao purcInquiryDao;
|
|
|
|
|
|
@@ -171,9 +168,6 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
@Autowired
|
|
|
private CartDao cartDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private KindDao kindDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SaleTenderDao saleTenderDao;
|
|
|
|
|
|
@@ -184,7 +178,13 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
private SaleQuotationDoneDao saleQuotationDoneDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private SaleTenderQuestionDao saleTenderQuestionDao;
|
|
|
+ private ComponentService componentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BrandService brandService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KindService kindService;
|
|
|
|
|
|
/**
|
|
|
* 联想词size
|
|
|
@@ -230,7 +230,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
}
|
|
|
|
|
|
private <T> void sortByProperty(List<T> content, Class<T> targetCls, String properyName,
|
|
|
- final List<Long> propertyList) {
|
|
|
+ final List<Long> propertyList) {
|
|
|
final Field field = getPropertyField(targetCls, properyName);
|
|
|
if (null != field)
|
|
|
Collections.sort(content, new Comparator<T>() {
|
|
|
@@ -264,7 +264,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
|
|
|
/**
|
|
|
* 将id的SPage信息、数据合并
|
|
|
- *
|
|
|
+ *
|
|
|
* @param idsPage
|
|
|
* id的SPage信息
|
|
|
* @param content
|
|
|
@@ -288,7 +288,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
|
|
|
/**
|
|
|
* 委外加工单
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
@Override
|
|
|
public SPage<MakeOrder> searchMakeOrderIds(String keyword, PageParams pageParams) {
|
|
|
@@ -322,7 +322,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
|
|
|
/**
|
|
|
* 不良品入库单
|
|
|
- *
|
|
|
+ *
|
|
|
* @param keyword
|
|
|
* @param pageParams
|
|
|
* @return
|
|
|
@@ -373,7 +373,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
// }
|
|
|
List<PurchaseInquiryItem> content = purchaseInquiryItemDao.findAll(new Specification<PurchaseInquiryItem>() {
|
|
|
public Predicate toPredicate(Root<PurchaseInquiryItem> root, CriteriaQuery<?> query,
|
|
|
- CriteriaBuilder builder) {
|
|
|
+ CriteriaBuilder builder) {
|
|
|
query.where(factory.toPredicate(root, query, builder));
|
|
|
return null;
|
|
|
}
|
|
|
@@ -470,7 +470,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
return toSPage(idsPage, content);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 平台发货单
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -745,7 +745,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
@Override
|
|
|
public SPage<Component> searchProductComponentCheckIds(String keyword, PageParams pageParams) {
|
|
|
SPage<Long> idsPage = searchService.searchIds(keyword, Table_name.PRODUCT$COMPONENT, pageParams);
|
|
|
- List<Component> content = componentDao.findAll(idsPage.getContent());
|
|
|
+ List<Component> content = componentService.findAll(idsPage.getContent());
|
|
|
sortByProperty(content, Component.class, "id", idsPage.getContent());
|
|
|
return toSPage(idsPage, content);
|
|
|
}
|
|
|
@@ -766,15 +766,15 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
return toSPage(idsPage, content);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public SPage<PagingReleaseDetail> searchPagingReleaseDetailIds(String keyword, PageParams pageParams) {
|
|
|
+ @Override
|
|
|
+ public SPage<PagingReleaseDetail> searchPagingReleaseDetailIds(String keyword, PageParams pageParams) {
|
|
|
SPage<Long> idsPage = searchService.searchIds(keyword, Table_name.PURC$PAGINGRELEASEDETAIL, pageParams);
|
|
|
List<PagingReleaseDetail> content = pagingReleaseDetailDao.findAll(idsPage.getContent());
|
|
|
sortByProperty(content, PagingReleaseDetail.class, "id", idsPage.getContent());
|
|
|
return toSPage(idsPage, content);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 招标单
|
|
|
* @param keyword
|
|
|
* @param pageParams
|
|
|
@@ -855,15 +855,15 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
* @param pageParams
|
|
|
* @return
|
|
|
*/
|
|
|
- @Override
|
|
|
- public SPage<Vendor> searchCustCheckIds(String keyword, PageParams pageParams) {
|
|
|
+ @Override
|
|
|
+ public SPage<Vendor> searchCustCheckIds(String keyword, PageParams pageParams) {
|
|
|
SPage<Long> idsPage = searchService.searchIds(keyword, Table_name.PURC$VENDORS_CUST, pageParams);
|
|
|
List<Vendor> content = vendorDao.findAll(idsPage.getContent());
|
|
|
sortByProperty(content, Vendor.class, "id", idsPage.getContent());
|
|
|
return toSPage(idsPage, content);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 供应商
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -936,8 +936,8 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Component getComponentByCode(String code) {
|
|
|
- List<Component> comps = componentDao.findByCode(code);
|
|
|
+ public Component getComponentByCode(String code) throws Exception {
|
|
|
+ List<Component> comps = componentService.findByCode(code);
|
|
|
Component cmp = new Component();
|
|
|
if(!CollectionUtils.isEmpty(comps)){
|
|
|
cmp = comps.get(0);// 因为只能带一个,选找到的第一个
|
|
|
@@ -946,11 +946,11 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getSimilarComponents(String keyword) {
|
|
|
+ public List<Map<String, Object>> getSimilarComponents(String keyword) throws Exception {
|
|
|
SPage<String> codePages = searchService.similar(keyword, Table_name.PRODUCT$COMPONENT, SIMILAR_NUM, "cmp_code");
|
|
|
List<Component> contents = new ArrayList<>();
|
|
|
for (String code : codePages.getContent()) {
|
|
|
- List<Component> components = componentDao.findByCode(code);
|
|
|
+ List<Component> components = componentService.findByCode(code);
|
|
|
if (!CollectionUtils.isEmpty(components)) {
|
|
|
Component component = components.get(0);
|
|
|
contents.add(component);
|
|
|
@@ -986,15 +986,15 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
// }
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getSimilarBrands(String keyword) {
|
|
|
+ public List<Map<String, Object>> getSimilarBrands(String keyword) throws Exception {
|
|
|
List<String> brandList = similarBrands(keyword);
|
|
|
List<Brand> contents = new ArrayList<>();
|
|
|
for (String brand : brandList) {
|
|
|
- List<Brand> temps = brandDao.findByNameCn(brand);
|
|
|
+ List<Brand> temps = brandService.findByNameCn(brand);
|
|
|
if (!CollectionUtils.isEmpty(temps)) {
|
|
|
contents.add(temps.get(0));
|
|
|
} else { // 中文品牌找不到,找英文的
|
|
|
- temps = brandDao.findByNameEn(brand);
|
|
|
+ temps = brandService.findByNameEn(brand);
|
|
|
if (!CollectionUtils.isEmpty(temps)) {
|
|
|
contents.add(temps.get(0));
|
|
|
}
|
|
|
@@ -1039,18 +1039,18 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getSimilarBrandsByCode(String keyword) {
|
|
|
+ public List<Map<String, Object>> getSimilarBrandsByCode(String keyword) throws Exception {
|
|
|
List<String> brandList = similarBrandsByCode(keyword);
|
|
|
List<Brand> contents = new ArrayList<>();
|
|
|
List<Map<String, Object>> brands = new ArrayList<>();
|
|
|
for (String brand : brandList) {
|
|
|
if (keyword.matches(CHINESE_REGEXP)) {
|
|
|
- List<Brand> temps = brandDao.findByNameCn(brand);
|
|
|
+ List<Brand> temps = brandService.findByNameCn(brand);
|
|
|
if (!CollectionUtils.isEmpty(temps)) {
|
|
|
contents.add(temps.get(0));
|
|
|
}
|
|
|
} else {
|
|
|
- List<Brand> temps = brandDao.findByNameEn(brand);
|
|
|
+ List<Brand> temps = brandService.findByNameEn(brand);
|
|
|
if (!CollectionUtils.isEmpty(temps)) {
|
|
|
contents.add(temps.get(0));
|
|
|
}
|
|
|
@@ -1113,21 +1113,14 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getSimilarKinds(String keyword) {
|
|
|
+ public List<Map<String, Object>> getSimilarKinds(String keyword) throws Exception {
|
|
|
List<String> kindList = similarKinds(keyword);
|
|
|
List<Kind> contents = new ArrayList<>();
|
|
|
List<Map<String, Object>> kinds = new ArrayList<>();
|
|
|
for (String kind : kindList) {
|
|
|
- if (keyword.matches(ENGLISH_REGEXP)) {
|
|
|
- List<Kind> temps = kindDao.findByNameEn(kind);
|
|
|
- if (!CollectionUtils.isEmpty(temps)) {
|
|
|
- contents.add(temps.get(0));
|
|
|
- }
|
|
|
- } else {
|
|
|
- List<Kind> temps = kindDao.findByNameCn(kind);
|
|
|
- if (!CollectionUtils.isEmpty(temps)) {
|
|
|
- contents.add(temps.get(0));
|
|
|
- }
|
|
|
+ List<Kind> temps = kindService.findByNameCn(kind);
|
|
|
+ if (!CollectionUtils.isEmpty(temps)) {
|
|
|
+ contents.add(temps.get(0));
|
|
|
}
|
|
|
}
|
|
|
for (Kind kind : contents) {
|
|
|
@@ -1335,8 +1328,8 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Kind getKindByKeyword(String keyword) {
|
|
|
- return kindDao.findByNameCn(keyword).get(0);
|
|
|
+ public Kind getKindByKeyword(String keyword) throws Exception {
|
|
|
+ return kindService.findByNameCn(keyword).get(0);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1360,9 +1353,7 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
|
|
|
@Override
|
|
|
public SPage<SaleTenderQuestion> searchSaleTenderQuestion(String keyword, PageParams pageParams) {
|
|
|
- SPage<Long> idsPage = searchService.searchIds(keyword, Table_name.SALE$TENDERQUESTION, pageParams);
|
|
|
- List<SaleTenderQuestion> content = saleTenderQuestionDao.findAll(idsPage.getContent());
|
|
|
- sortByProperty(content, SaleTenderQuestion.class, "id", idsPage.getContent());
|
|
|
- return toSPage(idsPage, content);
|
|
|
+ return null;
|
|
|
}
|
|
|
+
|
|
|
}
|