|
@@ -533,6 +533,96 @@ public class OrderManagementService {
|
|
|
}
|
|
|
return resultsList;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public ArrayList<DispatchDto> getDispatchList(DispatchSearchPram dispatchSearchPram) {
|
|
|
+
|
|
|
+ ArrayList<DispatchDto> resultsList = new ArrayList<>();
|
|
|
+ //以创建时间倒序排列
|
|
|
+ Date createDateStart = dispatchSearchPram.getCreateDateStart();
|
|
|
+ Date createDateEnd = dispatchSearchPram.getCreateDateEnd();
|
|
|
+
|
|
|
+ //分页条件
|
|
|
+ FieldSortBuilder timeSort = SortBuilders.fieldSort("createDate").order(SortOrder.DESC);
|
|
|
+ BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
|
|
+ //时间范围
|
|
|
+ RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("createDate")
|
|
|
+ .gte(createDateStart.getTime())
|
|
|
+ .lte(createDateEnd.getTime());
|
|
|
+ boolQuery.must(rangeQueryBuilder);
|
|
|
+ //筛选条件
|
|
|
+ //订单号
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getOrderId())) {
|
|
|
+ boolQuery.must(QueryBuilders.termQuery("orderId", dispatchSearchPram.getOrderId()));
|
|
|
+ }
|
|
|
+ //分发订单号
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getRecId())) {
|
|
|
+ boolQuery.must(QueryBuilders.matchQuery("recId", dispatchSearchPram.getRecId()));
|
|
|
+ }
|
|
|
+ //通道名称
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getChannelName())) {
|
|
|
+ boolQuery.must(QueryBuilders.wildcardQuery("channelName.keyword", "*" + dispatchSearchPram.getChannelName() + "*"));
|
|
|
+ }
|
|
|
+ //电话号码
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getPhoneNo())) {
|
|
|
+ String usedMobiles = dispatchSearchPram.getPhoneNo();
|
|
|
+ if (usedMobiles.contains(",")) {
|
|
|
+ String[] usedMobileList = usedMobiles.split(",");
|
|
|
+ BoolQueryBuilder temp = QueryBuilders.boolQuery();
|
|
|
+ for (String usedMobile : usedMobileList) {
|
|
|
+ temp.should(QueryBuilders.termQuery("phoneNo", usedMobile));
|
|
|
+ }
|
|
|
+ boolQuery.must(temp);
|
|
|
+ } else {
|
|
|
+ boolQuery.must(QueryBuilders.termQuery("phoneNo", usedMobiles));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //发送状态
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getSendStatus())) {
|
|
|
+ boolQuery.must(QueryBuilders.termQuery("sendStatus",dispatchSearchPram.getSendStatus()));
|
|
|
+ }
|
|
|
+ //运营商
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getPhoneOperator())) {
|
|
|
+ boolQuery.must(QueryBuilders.termQuery("phoneOperator", dispatchSearchPram.getPhoneOperator()));
|
|
|
+ }
|
|
|
+ //面额
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getFlowAmount())) {
|
|
|
+ String flowAmount = dispatchSearchPram.getFlowAmount();
|
|
|
+ if (flowAmount.contains("-")) {
|
|
|
+ String[] flowAmountSplit = flowAmount.split("-");
|
|
|
+ rangeQueryBuilder = QueryBuilders.rangeQuery("flowAmount")
|
|
|
+ .gte(flowAmountSplit[0])
|
|
|
+ .lte(flowAmountSplit[1]);
|
|
|
+ boolQuery.must(rangeQueryBuilder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //归属地
|
|
|
+ if (Strings.isNotBlank(dispatchSearchPram.getPhoneHome())) {
|
|
|
+ boolQuery.must(QueryBuilders.wildcardQuery("phoneHome.keyword", "*" + dispatchSearchPram.getPhoneHome() + "*"));
|
|
|
+ }
|
|
|
+
|
|
|
+ NativeSearchQuery query = new NativeSearchQueryBuilder()
|
|
|
+ .withSort(timeSort)
|
|
|
+ .withQuery(boolQuery)
|
|
|
+ .build();
|
|
|
+ //查询数据
|
|
|
+ try {
|
|
|
+ SearchHits<DispatchDto> hits = restTemplate.search(query, DispatchDto.class);
|
|
|
+ long total = hits.getTotalHits();
|
|
|
+ List<SearchHit<DispatchDto>> searchHits = hits.getSearchHits();
|
|
|
+ System.out.println("一共" + total + "个");
|
|
|
+ System.out.println("搜索结果" + searchHits.size() + "个");
|
|
|
+ for (SearchHit<DispatchDto> searchHit : searchHits) {
|
|
|
+ DispatchDto dispatchDto = searchHit.getContent();
|
|
|
+ resultsList.add(dispatchDto);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(String.valueOf(e));
|
|
|
+ }
|
|
|
+ return resultsList;
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|