|
@@ -194,7 +194,7 @@ public class OrderBaseEsLogic {
|
|
.stream()
|
|
.stream()
|
|
.map(OrderBaseVO::getId)
|
|
.map(OrderBaseVO::getId)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
- Map<String, List<PgOrderFlag>> mapList = orderFlagLogic.list(orderBaseIds);
|
|
|
|
|
|
+ Map<String, List<PgOrderFlag>> mapList = orderFlagLogic.list(orderBaseIds,year);
|
|
|
|
|
|
List<WorkerOrder> workerOrderList = workerOrderService.lambdaQuery().in(WorkerOrder::getWorkerOrderId, orderBaseIds)
|
|
List<WorkerOrder> workerOrderList = workerOrderService.lambdaQuery().in(WorkerOrder::getWorkerOrderId, orderBaseIds)
|
|
.eq(WorkerOrder::getPayStatus, MaterialExamineStatusEnum.PAID.getKey())
|
|
.eq(WorkerOrder::getPayStatus, MaterialExamineStatusEnum.PAID.getKey())
|
|
@@ -407,8 +407,10 @@ public class OrderBaseEsLogic {
|
|
}*/
|
|
}*/
|
|
}
|
|
}
|
|
|
|
|
|
- public List<Map<String, Object>> countStatus(String startTime, String endTime, String orderSmallType, String orderSmallTypeText) {
|
|
|
|
|
|
+ public List<Map<String, Object>> countStatus(String startTime, String endTime, String orderSmallType, String orderSmallTypeText,HttpServletRequest request) {
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
+
|
|
|
|
+ String year = CommonUtils.getYear(request);
|
|
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
|
|
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
|
|
|
|
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
@@ -443,15 +445,15 @@ public class OrderBaseEsLogic {
|
|
.lte(endTime)
|
|
.lte(endTime)
|
|
))))
|
|
))))
|
|
.build();
|
|
.build();
|
|
- SearchHits response = elasticsearchRestTemplate.search(searchQuery, OrderBaseEs.class);
|
|
|
|
|
|
|
|
|
|
+ SearchHits response = this.search(searchQuery,year);
|
|
HashMap<String, Object> dyy = new HashMap<>();
|
|
HashMap<String, Object> dyy = new HashMap<>();
|
|
- dyy.put("total",this.getWorkerOrderCountResult(response.getAggregations(),"DYY"));
|
|
|
|
- dyy.put("orderStatus","DYY");
|
|
|
|
-
|
|
|
|
|
|
+ dyy.put("total", this.getWorkerOrderCountResult(response.getAggregations(), "DYY"));
|
|
|
|
+ dyy.put("orderStatus", "DYY");
|
|
maps.add(dyy);
|
|
maps.add(dyy);
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
//待抢单
|
|
//待抢单
|
|
NativeSearchQuery searchQueryDqd = new NativeSearchQueryBuilder()
|
|
NativeSearchQuery searchQueryDqd = new NativeSearchQueryBuilder()
|
|
.withQuery(queryBuilder)
|
|
.withQuery(queryBuilder)
|
|
@@ -459,12 +461,12 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("DQD", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("DQD", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termQuery("order_status","DQD")))))
|
|
.must(QueryBuilders.termQuery("order_status","DQD")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responsedqd = elasticsearchRestTemplate.search(searchQueryDqd, OrderBaseEs.class);
|
|
|
|
|
|
+
|
|
|
|
+ SearchHits responsedqd = this.search(searchQueryDqd,year);
|
|
|
|
|
|
HashMap<String, Object> dqd = new HashMap<>();
|
|
HashMap<String, Object> dqd = new HashMap<>();
|
|
dqd.put("total",this.getWorkerOrderCountResult(responsedqd.getAggregations(),"DQD"));
|
|
dqd.put("total",this.getWorkerOrderCountResult(responsedqd.getAggregations(),"DQD"));
|
|
dqd.put("orderStatus","DQD");
|
|
dqd.put("orderStatus","DQD");
|
|
-
|
|
|
|
maps.add(dqd);
|
|
maps.add(dqd);
|
|
|
|
|
|
|
|
|
|
@@ -476,7 +478,7 @@ public class OrderBaseEsLogic {
|
|
.must(QueryBuilders.termsQuery("order_status","DSHPG","CJ","YPD","DXSPD","DZBPG","DWDSPGP","DXSSPGP",
|
|
.must(QueryBuilders.termsQuery("order_status","DSHPG","CJ","YPD","DXSPD","DZBPG","DWDSPGP","DXSSPGP",
|
|
"DTJXSSPGP","DZBSPGP","DFZXPD","DFZXSPGP")))))
|
|
"DTJXSSPGP","DZBSPGP","DFZXPD","DFZXSPGP")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseDshpg = elasticsearchRestTemplate.search(searchQueryDshpg, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseDshpg =this.search(searchQueryDshpg,year);
|
|
|
|
|
|
HashMap<String, Object> dshpg = new HashMap<>();
|
|
HashMap<String, Object> dshpg = new HashMap<>();
|
|
dshpg.put("total",this.getWorkerOrderCountResult(responseDshpg.getAggregations(),"DSHPG"));
|
|
dshpg.put("total",this.getWorkerOrderCountResult(responseDshpg.getAggregations(),"DSHPG"));
|
|
@@ -492,7 +494,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("DWDPG", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("DWDPG", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termsQuery("order_status","DWDPG","DWDPD")))))
|
|
.must(QueryBuilders.termsQuery("order_status","DWDPG","DWDPD")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseDwdpg = elasticsearchRestTemplate.search(searchQueryDwdpg, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseDwdpg = this.search(searchQueryDwdpg,year);
|
|
|
|
|
|
HashMap<String, Object> DWDPG = new HashMap<>();
|
|
HashMap<String, Object> DWDPG = new HashMap<>();
|
|
DWDPG.put("total",this.getWorkerOrderCountResult(responseDwdpg.getAggregations(),"DWDPG"));
|
|
DWDPG.put("total",this.getWorkerOrderCountResult(responseDwdpg.getAggregations(),"DWDPG"));
|
|
@@ -510,7 +512,7 @@ public class OrderBaseEsLogic {
|
|
.should(QueryBuilders.termsQuery("order_status", "DJD")))
|
|
.should(QueryBuilders.termsQuery("order_status", "DJD")))
|
|
)))
|
|
)))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseDJD = elasticsearchRestTemplate.search(searchQueryDJD, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseDJD = this.search(searchQueryDJD,year);
|
|
|
|
|
|
HashMap<String, Object> DJD = new HashMap<>();
|
|
HashMap<String, Object> DJD = new HashMap<>();
|
|
DJD.put("total",this.getWorkerOrderCountResult(responseDJD.getAggregations(),"DJD"));
|
|
DJD.put("total",this.getWorkerOrderCountResult(responseDJD.getAggregations(),"DJD"));
|
|
@@ -526,7 +528,7 @@ public class OrderBaseEsLogic {
|
|
.must(QueryBuilders.termsQuery("order_status","FWZ","GCSZT","BFWG",
|
|
.must(QueryBuilders.termsQuery("order_status","FWZ","GCSZT","BFWG",
|
|
"DSM","WDBH", "XSBH","TJXSBH","ZBBH","FZXBH")))))
|
|
"DSM","WDBH", "XSBH","TJXSBH","ZBBH","FZXBH")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseFWZ = elasticsearchRestTemplate.search(searchQueryfwz, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseFWZ = this.search(searchQueryfwz,year);
|
|
|
|
|
|
HashMap<String, Object> FWZ = new HashMap<>();
|
|
HashMap<String, Object> FWZ = new HashMap<>();
|
|
FWZ.put("total",this.getWorkerOrderCountResult(responseFWZ.getAggregations(),"FWZ"));
|
|
FWZ.put("total",this.getWorkerOrderCountResult(responseFWZ.getAggregations(),"FWZ"));
|
|
@@ -543,7 +545,7 @@ public class OrderBaseEsLogic {
|
|
.must(QueryBuilders.termQuery("is_exception",true))
|
|
.must(QueryBuilders.termQuery("is_exception",true))
|
|
.mustNot(QueryBuilders.termsQuery("order_status", "YWG", "YWGO", "YJS")))))
|
|
.mustNot(QueryBuilders.termsQuery("order_status", "YWG", "YWGO", "YJS")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseYCD = elasticsearchRestTemplate.search(searchQueryYCD, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseYCD = this.search(searchQueryYCD,year);
|
|
|
|
|
|
HashMap<String, Object> YCD = new HashMap<>();
|
|
HashMap<String, Object> YCD = new HashMap<>();
|
|
YCD.put("total",this.getWorkerOrderCountResult(responseYCD.getAggregations(),"YCD"));
|
|
YCD.put("total",this.getWorkerOrderCountResult(responseYCD.getAggregations(),"YCD"));
|
|
@@ -558,7 +560,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("YWG", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("YWG", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termsQuery("order_status","YWG","GCSZX","WDWG","YWGO")))))
|
|
.must(QueryBuilders.termsQuery("order_status","YWG","GCSZX","WDWG","YWGO")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseYWG = elasticsearchRestTemplate.search(searchQueryYWGDJS, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseYWG = this.search(searchQueryYWGDJS,year);
|
|
|
|
|
|
HashMap<String, Object> YWG = new HashMap<>();
|
|
HashMap<String, Object> YWG = new HashMap<>();
|
|
YWG.put("total",this.getWorkerOrderCountResult(responseYWG.getAggregations(),"YWG"));
|
|
YWG.put("total",this.getWorkerOrderCountResult(responseYWG.getAggregations(),"YWG"));
|
|
@@ -574,7 +576,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("YJS", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("YJS", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termsQuery("order_status","YJS","LRCD")))))
|
|
.must(QueryBuilders.termsQuery("order_status","YJS","LRCD")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseYJS = elasticsearchRestTemplate.search(searchQueryYJS, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseYJS = this.search(searchQueryYJS,year);
|
|
|
|
|
|
HashMap<String, Object> YJS = new HashMap<>();
|
|
HashMap<String, Object> YJS = new HashMap<>();
|
|
YJS.put("total",this.getWorkerOrderCountResult(responseYJS.getAggregations(),"YJS"));
|
|
YJS.put("total",this.getWorkerOrderCountResult(responseYJS.getAggregations(),"YJS"));
|
|
@@ -589,7 +591,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("YQX", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("YQX", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termsQuery("order_status","YZP","YQX","FWZT","YCGB","FWQX","FL")))))
|
|
.must(QueryBuilders.termsQuery("order_status","YZP","YQX","FWZT","YCGB","FWQX","FL")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseYQX = elasticsearchRestTemplate.search(searchQueryYQX, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseYQX = this.search(searchQueryYQX,year);
|
|
|
|
|
|
HashMap<String, Object> YQX = new HashMap<>();
|
|
HashMap<String, Object> YQX = new HashMap<>();
|
|
YQX.put("total",this.getWorkerOrderCountResult(responseYQX.getAggregations(),"YQX"));
|
|
YQX.put("total",this.getWorkerOrderCountResult(responseYQX.getAggregations(),"YQX"));
|
|
@@ -605,7 +607,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("PJSQZ", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("PJSQZ", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termQuery("parts_apply_status","ING")))))
|
|
.must(QueryBuilders.termQuery("parts_apply_status","ING")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responsePJSQZ = elasticsearchRestTemplate.search(searchQueryPJSQZ, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responsePJSQZ = this.search(searchQueryPJSQZ,year);
|
|
|
|
|
|
HashMap<String, Object> PJSQZ = new HashMap<>();
|
|
HashMap<String, Object> PJSQZ = new HashMap<>();
|
|
PJSQZ.put("total",this.getWorkerOrderCountResult(responsePJSQZ.getAggregations(),"PJSQZ"));
|
|
PJSQZ.put("total",this.getWorkerOrderCountResult(responsePJSQZ.getAggregations(),"PJSQZ"));
|
|
@@ -621,7 +623,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("PJYDH", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("PJYDH", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termQuery("parts_apply_status","END")))))
|
|
.must(QueryBuilders.termQuery("parts_apply_status","END")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responsePJYDH = elasticsearchRestTemplate.search(searchQueryPJYDH, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responsePJYDH = this.search(searchQueryPJYDH,year);
|
|
|
|
|
|
HashMap<String, Object> PJYDH = new HashMap<>();
|
|
HashMap<String, Object> PJYDH = new HashMap<>();
|
|
PJYDH.put("total",this.getWorkerOrderCountResult(responsePJYDH.getAggregations(),"PJYDH"));
|
|
PJYDH.put("total",this.getWorkerOrderCountResult(responsePJYDH.getAggregations(),"PJYDH"));
|
|
@@ -637,7 +639,7 @@ public class OrderBaseEsLogic {
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("PJYQX", QueryBuilders.boolQuery()
|
|
.addAggregation(this.getAggs(AggregationBuilders.filter("PJYQX", QueryBuilders.boolQuery()
|
|
.must(QueryBuilders.termQuery("parts_apply_status","CANCEL")))))
|
|
.must(QueryBuilders.termQuery("parts_apply_status","CANCEL")))))
|
|
.build();
|
|
.build();
|
|
- SearchHits responsePJYQX = elasticsearchRestTemplate.search(searchQueryPJYQX, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responsePJYQX = this.search(searchQueryPJYQX,year);
|
|
|
|
|
|
HashMap<String, Object> PJYQX = new HashMap<>();
|
|
HashMap<String, Object> PJYQX = new HashMap<>();
|
|
PJYQX.put("total",this.getWorkerOrderCountResult(responsePJYQX.getAggregations(),"PJYQX"));
|
|
PJYQX.put("total",this.getWorkerOrderCountResult(responsePJYQX.getAggregations(),"PJYQX"));
|
|
@@ -664,7 +666,7 @@ public class OrderBaseEsLogic {
|
|
.must(QueryBuilders.termsQuery("id",orderBaseId))
|
|
.must(QueryBuilders.termsQuery("id",orderBaseId))
|
|
)))
|
|
)))
|
|
.build();
|
|
.build();
|
|
- SearchHits responseDZF = elasticsearchRestTemplate.search(searchQueryDZF, OrderBaseEs.class);
|
|
|
|
|
|
+ SearchHits responseDZF = this.search(searchQueryDZF,year);
|
|
DZF.put("total",this.getWorkerOrderCountResult(responseDZF.getAggregations(),"DZF"));
|
|
DZF.put("total",this.getWorkerOrderCountResult(responseDZF.getAggregations(),"DZF"));
|
|
DZF.put("orderStatus","DZF");
|
|
DZF.put("orderStatus","DZF");
|
|
|
|
|
|
@@ -675,6 +677,27 @@ public class OrderBaseEsLogic {
|
|
return maps;
|
|
return maps;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private SearchHits search(NativeSearchQuery searchQuery,String year) {
|
|
|
|
+
|
|
|
|
+ if (year.equals("2023")) {
|
|
|
|
+ SearchHits response = elasticsearchRestTemplate.search(searchQuery, OrderBase2023Es.class);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ if (year.equals("2024")) {
|
|
|
|
+ SearchHits response = elasticsearchRestTemplate.search(searchQuery, OrderBase2024Es.class);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (year.equals("2022") || Convert.toInt(year) < 2022) {
|
|
|
|
+ SearchHits response = elasticsearchRestTemplate.search(searchQuery, OrderBase2022Es.class);
|
|
|
|
+ return response;
|
|
|
|
+ }else {
|
|
|
|
+ SearchHits response = elasticsearchRestTemplate.search(searchQuery, OrderBaseEs.class);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public AbstractAggregationBuilder<?> getAggs(FilterAggregationBuilder filter) {
|
|
public AbstractAggregationBuilder<?> getAggs(FilterAggregationBuilder filter) {
|
|
return filter.subAggregation(AggregationBuilders.sum("total_mac_sum").field("total_num"))
|
|
return filter.subAggregation(AggregationBuilders.sum("total_mac_sum").field("total_num"))
|
|
.subAggregation(AggregationBuilders.terms("order_type_group").field("order_type")
|
|
.subAggregation(AggregationBuilders.terms("order_type_group").field("order_type")
|
|
@@ -727,10 +750,12 @@ public class OrderBaseEsLogic {
|
|
orderWorkerEsRepository.saveAll(pgOrderWorkerEs);
|
|
orderWorkerEsRepository.saveAll(pgOrderWorkerEs);
|
|
}
|
|
}
|
|
|
|
|
|
- public List<OrderBaseVO> listExport(WorkOrderZfireParam zfireParamBean) {
|
|
|
|
|
|
+ public List<OrderBaseVO> listExport(WorkOrderZfireParam zfireParamBean,HttpServletRequest request) {
|
|
|
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
|
|
|
|
+ String year = CommonUtils.getYear(request);
|
|
|
|
+
|
|
BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery();
|
|
BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery();
|
|
this.montage(queryBuilder1,zfireParamBean);
|
|
this.montage(queryBuilder1,zfireParamBean);
|
|
|
|
|
|
@@ -774,51 +799,199 @@ public class OrderBaseEsLogic {
|
|
|
|
|
|
|
|
|
|
// 2. 初始化 Scroll
|
|
// 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<OrderBaseVO> orderBaseVOS1 = new ArrayList<>();
|
|
|
|
|
|
- if (scrollHits.getTotalHits() > 60000)
|
|
|
|
- throw new RemoteServiceException("数据超过六万上限,请分批导出");
|
|
|
|
|
|
+ if (year.equals("2023")) {
|
|
|
|
+
|
|
|
|
+ List<OrderBase2023Es> orderBaseVOS = new ArrayList<>();
|
|
|
|
+ SearchScrollHits<OrderBase2023Es> scrollHits = elasticsearchRestTemplate.searchScrollStart(
|
|
|
|
+ 60000, // Scroll 上下文保持时间(毫秒)
|
|
|
|
+ query,
|
|
|
|
+ OrderBase2023Es.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base_2023")
|
|
|
|
+ );
|
|
|
|
|
|
- List<OrderBaseEs> orderBaseVOS = new ArrayList<>();
|
|
|
|
|
|
+ String scrollId = scrollHits.getScrollId();
|
|
|
|
+ int batch = 0;
|
|
|
|
|
|
- try {
|
|
|
|
- while (!scrollHits.isEmpty()) {
|
|
|
|
- // 3. 处理当前批次数据
|
|
|
|
- scrollHits.forEach(hit -> {
|
|
|
|
- OrderBaseEs entity = hit.getContent();
|
|
|
|
- orderBaseVOS.add(entity);
|
|
|
|
- });
|
|
|
|
|
|
+ if (scrollHits.getTotalHits() > 60000)
|
|
|
|
+ throw new RemoteServiceException("数据超过六万上限,请分批导出");
|
|
|
|
|
|
- batch++;
|
|
|
|
|
|
|
|
- // 4. 获取下一批次
|
|
|
|
- scrollHits = elasticsearchRestTemplate.searchScrollContinue(
|
|
|
|
- scrollId,
|
|
|
|
- 60000,
|
|
|
|
- OrderBaseEs.class,
|
|
|
|
- IndexCoordinates.of("pg_order_base")
|
|
|
|
- );
|
|
|
|
- scrollId = scrollHits.getScrollId(); // 更新 scrollId
|
|
|
|
|
|
+ try {
|
|
|
|
+ while (!scrollHits.isEmpty()) {
|
|
|
|
+ // 3. 处理当前批次数据
|
|
|
|
+ scrollHits.forEach(hit -> {
|
|
|
|
+ OrderBase2023Es entity = hit.getContent();
|
|
|
|
+ orderBaseVOS.add(entity);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ batch++;
|
|
|
|
+
|
|
|
|
+ // 4. 获取下一批次
|
|
|
|
+ scrollHits = elasticsearchRestTemplate.searchScrollContinue(
|
|
|
|
+ scrollId,
|
|
|
|
+ 60000,
|
|
|
|
+ OrderBase2023Es.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base_2023")
|
|
|
|
+ );
|
|
|
|
+ scrollId = scrollHits.getScrollId(); // 更新 scrollId
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ // 5. 清理 Scroll 上下文
|
|
|
|
+ if (scrollId != null) {
|
|
|
|
+ List<String> scroll = new ArrayList<>();
|
|
|
|
+ scroll.add(scrollId);
|
|
|
|
+ elasticsearchRestTemplate.searchScrollClear(scroll);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- } finally {
|
|
|
|
- // 5. 清理 Scroll 上下文
|
|
|
|
- if (scrollId != null) {
|
|
|
|
- List<String> scroll = new ArrayList<>();
|
|
|
|
- scroll.add(scrollId);
|
|
|
|
- elasticsearchRestTemplate.searchScrollClear(scroll);
|
|
|
|
|
|
+
|
|
|
|
+ orderBaseVOS1 = BeanUtil.copyToList(orderBaseVOS,OrderBaseVO.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (year.equals("2024")) {
|
|
|
|
+
|
|
|
|
+ List<OrderBase2024Es> orderBaseVOS = new ArrayList<>();
|
|
|
|
+ SearchScrollHits<OrderBase2024Es> scrollHits = elasticsearchRestTemplate.searchScrollStart(
|
|
|
|
+ 60000, // Scroll 上下文保持时间(毫秒)
|
|
|
|
+ query,
|
|
|
|
+ OrderBase2024Es.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base_2024")
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ String scrollId = scrollHits.getScrollId();
|
|
|
|
+ int batch = 0;
|
|
|
|
+
|
|
|
|
+ if (scrollHits.getTotalHits() > 60000)
|
|
|
|
+ throw new RemoteServiceException("数据超过六万上限,请分批导出");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ while (!scrollHits.isEmpty()) {
|
|
|
|
+ // 3. 处理当前批次数据
|
|
|
|
+ scrollHits.forEach(hit -> {
|
|
|
|
+ OrderBase2024Es entity = hit.getContent();
|
|
|
|
+ orderBaseVOS.add(entity);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ batch++;
|
|
|
|
+
|
|
|
|
+ // 4. 获取下一批次
|
|
|
|
+ scrollHits = elasticsearchRestTemplate.searchScrollContinue(
|
|
|
|
+ scrollId,
|
|
|
|
+ 60000,
|
|
|
|
+ OrderBase2024Es.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base_2024")
|
|
|
|
+ );
|
|
|
|
+ scrollId = scrollHits.getScrollId(); // 更新 scrollId
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ // 5. 清理 Scroll 上下文
|
|
|
|
+ if (scrollId != null) {
|
|
|
|
+ List<String> scroll = new ArrayList<>();
|
|
|
|
+ scroll.add(scrollId);
|
|
|
|
+ elasticsearchRestTemplate.searchScrollClear(scroll);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ orderBaseVOS1 = BeanUtil.copyToList(orderBaseVOS,OrderBaseVO.class);
|
|
}
|
|
}
|
|
|
|
|
|
- List<OrderBaseVO> orderBaseVOS1 = BeanUtil.copyToList(orderBaseVOS, OrderBaseVO.class);
|
|
|
|
|
|
|
|
|
|
+ if (year.equals("2022") || Convert.toInt(year) < 2022) {
|
|
|
|
+
|
|
|
|
+ List<OrderBase2022Es> orderBaseVOS = new ArrayList<>();
|
|
|
|
+ SearchScrollHits<OrderBase2022Es> scrollHits = elasticsearchRestTemplate.searchScrollStart(
|
|
|
|
+ 60000, // Scroll 上下文保持时间(毫秒)
|
|
|
|
+ query,
|
|
|
|
+ OrderBase2022Es.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base_2022")
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ String scrollId = scrollHits.getScrollId();
|
|
|
|
+ int batch = 0;
|
|
|
|
+
|
|
|
|
+ if (scrollHits.getTotalHits() > 60000)
|
|
|
|
+ throw new RemoteServiceException("数据超过六万上限,请分批导出");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ while (!scrollHits.isEmpty()) {
|
|
|
|
+ // 3. 处理当前批次数据
|
|
|
|
+ scrollHits.forEach(hit -> {
|
|
|
|
+ OrderBase2022Es entity = hit.getContent();
|
|
|
|
+ orderBaseVOS.add(entity);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ batch++;
|
|
|
|
+
|
|
|
|
+ // 4. 获取下一批次
|
|
|
|
+ scrollHits = elasticsearchRestTemplate.searchScrollContinue(
|
|
|
|
+ scrollId,
|
|
|
|
+ 60000,
|
|
|
|
+ OrderBase2022Es.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base_2022")
|
|
|
|
+ );
|
|
|
|
+ scrollId = scrollHits.getScrollId(); // 更新 scrollId
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ // 5. 清理 Scroll 上下文
|
|
|
|
+ if (scrollId != null) {
|
|
|
|
+ List<String> scroll = new ArrayList<>();
|
|
|
|
+ scroll.add(scrollId);
|
|
|
|
+ elasticsearchRestTemplate.searchScrollClear(scroll);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ orderBaseVOS1 = BeanUtil.copyToList(orderBaseVOS,OrderBaseVO.class);
|
|
|
|
+ }else {
|
|
|
|
+
|
|
|
|
+ List<OrderBaseEs> orderBaseVOS = new ArrayList<>();
|
|
|
|
+ SearchScrollHits<OrderBaseEs> scrollHits = elasticsearchRestTemplate.searchScrollStart(
|
|
|
|
+ 60000, // Scroll 上下文保持时间(毫秒)
|
|
|
|
+ query,
|
|
|
|
+ OrderBaseEs.class,
|
|
|
|
+ IndexCoordinates.of("pg_order_base")
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ String scrollId = scrollHits.getScrollId();
|
|
|
|
+ int batch = 0;
|
|
|
|
+
|
|
|
|
+ if (scrollHits.getTotalHits() > 60000)
|
|
|
|
+ throw new RemoteServiceException("数据超过六万上限,请分批导出");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ orderBaseVOS1 = BeanUtil.copyToList(orderBaseVOS,OrderBaseVO.class);
|
|
|
|
+ }
|
|
|
|
|
|
List<String> orderBaseIds = orderBaseVOS1
|
|
List<String> orderBaseIds = orderBaseVOS1
|
|
.stream()
|
|
.stream()
|