| 
					
				 | 
			
			
				@@ -27,9 +27,13 @@ import lombok.RequiredArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections4.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.elasticsearch.action.search.SearchResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.elasticsearch.client.RequestOptions; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.elasticsearch.common.unit.TimeValue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.elasticsearch.index.query.BoolQueryBuilder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.elasticsearch.index.query.QueryBuilder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.elasticsearch.index.query.QueryBuilders; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.elasticsearch.search.Scroll; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.elasticsearch.search.aggregations.AggregationBuilders; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.elasticsearch.search.aggregations.Aggregations; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,6 +44,7 @@ import org.elasticsearch.search.sort.SortOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.domain.PageRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.elasticsearch.core.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.elasticsearch.core.document.Document; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,7 +135,7 @@ public class OrderBaseEsLogic { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         page.setSize(zfireParamBean.getPageSize()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         page.setRecords(BeanUtil.copyToList(orderBaseEs,OrderBaseVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //服务单标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (zfireParamBean.getPageSize() != -1 && page.getTotal() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (zfireParamBean.getPageSize() != -1 && page.getTotal() > 0 && page.getRecords().size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<String> orderBaseIds = page.getRecords() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .map(OrderBaseVO::getId) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -641,4 +646,97 @@ public class OrderBaseEsLogic { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         orderWorkerEsRepository.saveAll(pgOrderWorkerEs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<OrderBaseVO> listExport(WorkOrderZfireParam zfireParamBean) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AdminUserCom adminUser = commonLogic.getAdminUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.montage(queryBuilder1,zfireParamBean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            queryBuilder1.must( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> orderBaseId = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (zfireParamBean.getIsWait() != null && zfireParamBean.getIsWait()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<String> collect = workerOrderService.lambdaQuery() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(WorkerOrder::getPayStatus, "WAIT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),WorkerOrder::getWebsitId,  adminUser.getAdminWebsitIds()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .ne(WorkerOrder::getWorkerOrderId, "").select(WorkerOrder::getWorkerOrderId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .list().stream().map(WorkerOrder::getWorkerOrderId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (CollectionUtils.isEmpty(collect)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            orderBaseId.addAll(collect); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!CollectionUtils.isEmpty(orderBaseId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            queryBuilder1.must(QueryBuilders.termsQuery("id",orderBaseId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        NativeSearchQuery query  = new NativeSearchQueryBuilder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .withQuery(queryBuilder1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .withSort(SortBuilders.fieldSort("create_time").order(SortOrder.DESC)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .withPageable(PageRequest.of(0, 3000)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 2. 初始化 Scroll 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SearchScrollHits<OrderBaseEs> scrollHits = elasticsearchRestTemplate.searchScrollStart( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                60000, // Scroll 上下文保持时间(毫秒) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                query, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                OrderBaseEs.class, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                IndexCoordinates.of("pg_order_base") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String scrollId = scrollHits.getScrollId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int batch = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<OrderBaseEs> orderBaseVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            while (!scrollHits.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 3. 处理当前批次数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                scrollHits.forEach(hit -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    OrderBaseEs entity = hit.getContent(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    orderBaseVOS.add(entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                batch++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 4. 获取下一批次 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                scrollHits = elasticsearchRestTemplate.searchScrollContinue( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        scrollId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        60000, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        OrderBaseEs.class, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        IndexCoordinates.of("pg_order_base") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                scrollId = scrollHits.getScrollId(); // 更新 scrollId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 5. 清理 Scroll 上下文 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (scrollId != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<String> scroll = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                scroll.add(scrollId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                elasticsearchRestTemplate.searchScrollClear(scroll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<OrderBaseVO> orderBaseVOS1 = BeanUtil.copyToList(orderBaseVOS, OrderBaseVO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return orderBaseVOS1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |