|
@@ -18,8 +18,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -27,16 +26,17 @@ public class OrderManagementService {
|
|
@Autowired
|
|
@Autowired
|
|
private ElasticsearchRestTemplate restTemplate;
|
|
private ElasticsearchRestTemplate restTemplate;
|
|
|
|
|
|
- public String orderSearch(OrderSearchPram orderSearchPram) {
|
|
|
|
|
|
+ public Map<String,Object> orderSearch(OrderSearchPram orderSearchPram) {
|
|
//以创建时间倒序排列
|
|
//以创建时间倒序排列
|
|
|
|
+ HashMap<String, Object> pageMap = new HashMap<>();
|
|
|
|
+ ArrayList<OrderEsDto> resultsList = new ArrayList<OrderEsDto>();
|
|
Sort sort = Sort.by(Sort.Direction.DESC, "applyDate");
|
|
Sort sort = Sort.by(Sort.Direction.DESC, "applyDate");
|
|
Date applyDateStart = orderSearchPram.getApplyDateStart();
|
|
Date applyDateStart = orderSearchPram.getApplyDateStart();
|
|
Date applyDateEnd = orderSearchPram.getApplyDateEnd();
|
|
Date applyDateEnd = orderSearchPram.getApplyDateEnd();
|
|
-
|
|
|
|
int page = 0;
|
|
int page = 0;
|
|
int size = 10;
|
|
int size = 10;
|
|
if (null != orderSearchPram.getPage()) {
|
|
if (null != orderSearchPram.getPage()) {
|
|
- page = orderSearchPram.getPage();
|
|
|
|
|
|
+ page = orderSearchPram.getPage() - 1;
|
|
}
|
|
}
|
|
if (null != orderSearchPram.getSize()) {
|
|
if (null != orderSearchPram.getSize()) {
|
|
size = orderSearchPram.getSize();
|
|
size = orderSearchPram.getSize();
|
|
@@ -66,11 +66,15 @@ public class OrderManagementService {
|
|
}
|
|
}
|
|
//电话号码
|
|
//电话号码
|
|
if (Strings.isNotBlank(orderSearchPram.getUsedMobile())) {
|
|
if (Strings.isNotBlank(orderSearchPram.getUsedMobile())) {
|
|
- boolQuery.must(QueryBuilders.termQuery("usedMobile", orderSearchPram.getUsedMobile()));
|
|
|
|
- }
|
|
|
|
- //电话号码
|
|
|
|
- if (Strings.isNotBlank(orderSearchPram.getUsedMobile())) {
|
|
|
|
- boolQuery.must(QueryBuilders.termQuery("usedMobile", orderSearchPram.getUsedMobile()));
|
|
|
|
|
|
+ String usedMobiles = orderSearchPram.getUsedMobile();
|
|
|
|
+ if (usedMobiles.indexOf(",") >= 0){
|
|
|
|
+ String[] usedMobileList = usedMobiles.split(",");
|
|
|
|
+ for (String usedMobile : usedMobileList) {
|
|
|
|
+ boolQuery.should(QueryBuilders.termQuery("usedMobile", usedMobile));
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ boolQuery.must(QueryBuilders.termQuery("usedMobile", usedMobiles));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//客户名称 暂时用的ID
|
|
//客户名称 暂时用的ID
|
|
if (Strings.isNotBlank(orderSearchPram.getEnterpriseIdDesc())) {
|
|
if (Strings.isNotBlank(orderSearchPram.getEnterpriseIdDesc())) {
|
|
@@ -95,7 +99,7 @@ public class OrderManagementService {
|
|
//归属地
|
|
//归属地
|
|
if (Strings.isNotBlank(orderSearchPram.getMobileHome())) {
|
|
if (Strings.isNotBlank(orderSearchPram.getMobileHome())) {
|
|
BoolQueryBuilder tempQueryBuilder = QueryBuilders.boolQuery();
|
|
BoolQueryBuilder tempQueryBuilder = QueryBuilders.boolQuery();
|
|
- tempQueryBuilder.should(QueryBuilders.wildcardQuery("mobileHome.keyword", orderSearchPram.getMobileHome()));
|
|
|
|
|
|
+ tempQueryBuilder.should(QueryBuilders.wildcardQuery("mobileHome.keyword", "*" + orderSearchPram.getMobileHome() + "*"));
|
|
boolQuery.must(tempQueryBuilder);
|
|
boolQuery.must(tempQueryBuilder);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -110,10 +114,16 @@ public class OrderManagementService {
|
|
System.out.println("一共" + total + "个");
|
|
System.out.println("一共" + total + "个");
|
|
System.out.println("搜索结果" + searchHits.size() + "个");
|
|
System.out.println("搜索结果" + searchHits.size() + "个");
|
|
for (SearchHit<OrderEsDto> searchHit : searchHits) {
|
|
for (SearchHit<OrderEsDto> searchHit : searchHits) {
|
|
- OrderEsDto stuEntity = searchHit.getContent();
|
|
|
|
- log.info(stuEntity.toString());
|
|
|
|
|
|
+ OrderEsDto orderEsDto = searchHit.getContent();
|
|
|
|
+ resultsList.add(orderEsDto);
|
|
|
|
+// log.info(stuEntity.toString());
|
|
}
|
|
}
|
|
- return "success";
|
|
|
|
|
|
+ pageMap.put("records",resultsList);
|
|
|
|
+ pageMap.put("size",size);
|
|
|
|
+ pageMap.put("current",page + 1);
|
|
|
|
+ pageMap.put("total",total);
|
|
|
|
+ pageMap.put("pages",total%size == 0 ? (int)total/size:(int)total/size + 1);
|
|
|
|
+ return pageMap;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|