|
|
@@ -1022,7 +1022,12 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
|
|
|
@Override
|
|
|
public Component getComponentByCode(String code) {
|
|
|
- return componentDao.findByCode(code).get(0); // 因为只能带一个,选找到的第一个
|
|
|
+ List<Component> comps = componentDao.findByCode(code);
|
|
|
+ Component cmp = new Component();
|
|
|
+ if(!CollectionUtils.isEmpty(comps)){
|
|
|
+ cmp = comps.get(0);// 因为只能带一个,选找到的第一个
|
|
|
+ }
|
|
|
+ return cmp;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1030,20 +1035,25 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
|
|
|
SPage<String> codePages = searchService.similar(keyword, Table_name.PRODUCT$COMPONENT, SIMILAR_NUM, "cmp_code");
|
|
|
List<Component> contents = new ArrayList<>();
|
|
|
for (String code : codePages.getContent()) {
|
|
|
- Component component = componentDao.findByCode(code).get(0);
|
|
|
- contents.add(component);
|
|
|
+ List<Component> components = componentDao.findByCode(code);
|
|
|
+ if (!CollectionUtils.isEmpty(components)) {
|
|
|
+ Component component = components.get(0);
|
|
|
+ contents.add(component);
|
|
|
+ }
|
|
|
}
|
|
|
List<Map<String, Object>> components = new ArrayList<Map<String, Object>>();
|
|
|
- for (Component component : contents) {
|
|
|
- Map<String, Object> temp = new HashMap<>();
|
|
|
- temp.put("id", component.getId());
|
|
|
- temp.put("uuid", component.getUuid());
|
|
|
- temp.put("code", component.getCode());
|
|
|
- temp.put("brandCn", component.getBrand().getNameCn());
|
|
|
- temp.put("brandEn", component.getBrand().getNameEn());
|
|
|
- temp.put("kindCn", component.getKind().getNameCn());
|
|
|
- temp.put("kindEn", component.getKind().getNameEn());
|
|
|
- components.add(temp);
|
|
|
+ if (!CollectionUtils.isEmpty(contents)) {
|
|
|
+ for (Component component : contents) {
|
|
|
+ Map<String, Object> temp = new HashMap<>();
|
|
|
+ temp.put("id", component.getId());
|
|
|
+ temp.put("uuid", component.getUuid());
|
|
|
+ temp.put("code", component.getCode());
|
|
|
+ temp.put("brandCn", component.getBrand().getNameCn());
|
|
|
+ temp.put("brandEn", component.getBrand().getNameEn());
|
|
|
+ temp.put("kindCn", component.getKind().getNameCn());
|
|
|
+ temp.put("kindEn", component.getKind().getNameEn());
|
|
|
+ components.add(temp);
|
|
|
+ }
|
|
|
}
|
|
|
return components;
|
|
|
}
|