‘linchangsheng’ 1 month ago
parent
commit
501f6e26f8

+ 34 - 16
mall-server-api/src/main/java/com/gree/mall/manager/logic/big/BigLogic.java

@@ -750,15 +750,24 @@ public class BigLogic {
             List<Integer> unitNum = new ArrayList<>();
             List<Integer> unitNumWwg = new ArrayList<>();
 
+            BoolQueryBuilder queryBuilderWG = QueryBuilders.boolQuery();
+
+            if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+                queryBuilderWG.must(
+                        QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                                .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+                );
+            }
+            queryBuilderWG.must(QueryBuilders.termsQuery("order_status", status));
+            queryBuilderWG.must(QueryBuilders.termsQuery("order_small_type_text", orderSmallType.getOrderSmallTypeText()));
+
+            queryBuilderWG.must(QueryBuilders.rangeQuery("over_time")
+                    .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))), "yyyy-MM-dd HH:mm:ss"))
+                    .lte(DateUtil.format(DateUtil.endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss")));
+
+
             NativeSearchQuery searchQueryWG = new NativeSearchQueryBuilder()
-                    .withQuery(QueryBuilders.boolQuery()
-                            .must(QueryBuilders.termsQuery("order_status", status))
-                            .must(QueryBuilders.termsQuery("order_small_type_text", orderSmallType.getOrderSmallTypeText()))
-                            .must(QueryBuilders.rangeQuery("over_time")
-                                    .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))), "yyyy-MM-dd HH:mm:ss"))
-                                    .lte(DateUtil.format(DateUtil.endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss")))
-                            .must(QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                            ))
+                    .withQuery(queryBuilderWG)
                     .withPageable(PageRequest.of(1, 1))
                     .addAggregation(AggregationBuilders.dateHistogram("WG")
                             .field("over_time")
@@ -770,16 +779,25 @@ public class BigLogic {
 
             var aggregationsWG = responseWG.getAggregations();
 
+            BoolQueryBuilder queryBuilderWWG = QueryBuilders.boolQuery();
+
+            if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+                queryBuilderWWG.must(
+                        QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                                .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+                );
+            }
+            queryBuilderWWG.mustNot(QueryBuilders.termsQuery("order_status", status));
+            queryBuilderWWG.must(QueryBuilders.termsQuery("order_small_type_text", orderSmallType.getOrderSmallTypeText()));
+
+            queryBuilderWWG.must(QueryBuilders.rangeQuery("create_time")
+                    .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))), "yyyy-MM-dd HH:mm:ss"))
+                    .lte(DateUtil.format(DateUtil.endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss")));
+
+
 
             NativeSearchQuery searchQueryWWG = new NativeSearchQueryBuilder()
-                    .withQuery(QueryBuilders.boolQuery()
-                            .must(QueryBuilders.termsQuery("order_status", status))
-                            .must(QueryBuilders.termsQuery("order_small_type_text", orderSmallType.getOrderSmallTypeText()))
-                            .must(QueryBuilders.rangeQuery("create_time")
-                                    .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))), "yyyy-MM-dd HH:mm:ss"))
-                                    .lte(DateUtil.format(DateUtil.endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss")))
-                            .must(QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                            ))
+                    .withQuery(queryBuilderWWG)
                     .withPageable(PageRequest.of(1, 1))
                     .addAggregation(AggregationBuilders.dateHistogram("WWG")
                             .field("create_time")

+ 83 - 40
mall-server-api/src/main/java/com/gree/mall/manager/logic/workorder/OrderBaseCountLogic.java

@@ -244,16 +244,25 @@ public class OrderBaseCountLogic {
             }
         }
 
+        BoolQueryBuilder queryBuilderWGD = QueryBuilders.boolQuery();
+
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+            queryBuilderWGD.must(
+                    QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                            .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+            );
+        }
+        queryBuilderWGD.must(
+        QueryBuilders.boolQuery()
+                .must(QueryBuilders.termsQuery("order_status",orderStatus))
+                .must(  QueryBuilders.rangeQuery("over_time")
+                        .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-6))),"yyyy-MM-dd HH:mm:ss"))
+                        .lte(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")))
+        );
+
 
         NativeSearchQuery searchQueryWGD = new NativeSearchQueryBuilder()
-                .withQuery(QueryBuilders.boolQuery()
-                                .must(QueryBuilders.termsQuery("order_status",orderStatus))
-                        .must(  QueryBuilders.rangeQuery("over_time")
-                                .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-6))),"yyyy-MM-dd HH:mm:ss"))
-                                .lte(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")))
-                .must( QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                        .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds())))
-                )
+                .withQuery(queryBuilderWGD)
                 .withSourceFilter(new FetchSourceFilter(new String[]{"create_time"}, null))
                 .withPageable(PageRequest.of(1, 1))
                 .addAggregation(AggregationBuilders.dateHistogram("WGD")
@@ -280,18 +289,24 @@ public class OrderBaseCountLogic {
             }
         }
 
+        BoolQueryBuilder queryBuilderJXZ = QueryBuilders.boolQuery();
 
-        NativeSearchQuery searchQueryJXZ= new NativeSearchQueryBuilder()
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+            queryBuilderJXZ.must(
+                    QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                            .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+            );
+        }
+        queryBuilderJXZ.must(
+                QueryBuilders.rangeQuery("create_time")
+                        .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-6))),"yyyy-MM-dd HH:mm:ss"))
+                        .lte(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")));
+
+        queryBuilderJXZ.mustNot(QueryBuilders.termsQuery("order_status",orderStatus))
+                .mustNot(QueryBuilders.termsQuery("order_status",orderStatusQx));
 
-                .withQuery(QueryBuilders.boolQuery()
-                        .must(  QueryBuilders.rangeQuery("create_time")
-                                .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-6))),"yyyy-MM-dd HH:mm:ss"))
-                                .lte(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")))
-                        .must( QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                                .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds())))
-                        .mustNot(QueryBuilders.termsQuery("order_status",orderStatus))
-                        .mustNot(QueryBuilders.termsQuery("order_status",orderStatusQx))
-                )
+        NativeSearchQuery searchQueryJXZ= new NativeSearchQueryBuilder()
+                .withQuery(queryBuilderJXZ)
                 .withSourceFilter(new FetchSourceFilter(new String[]{"create_time"}, null))
                 .withPageable(PageRequest.of(1, 1))
                 .addAggregation(AggregationBuilders.dateHistogram("JXZ")
@@ -325,14 +340,23 @@ public class OrderBaseCountLogic {
         orderBaseCountBean.setQtddqs(qtddqs);
 
 
+        BoolQueryBuilder queryBuilderQTSM = QueryBuilders.boolQuery();
 
-        NativeSearchQuery searchQueryQTSM= new NativeSearchQueryBuilder()
-                .withQuery(QueryBuilders.boolQuery()
-                        .must( QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                                .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds())))
-                        .must(QueryBuilders.rangeQuery("appointment_time")
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+            queryBuilderQTSM.must(
+                    QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                            .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+            );
+        }
+
+        queryBuilderQTSM.must(
+                QueryBuilders.rangeQuery("appointment_time")
                         .gte(DateUtil.format(DateUtil.beginOfDay(new Date()),"yyyy-MM-dd HH:mm:ss"))
-                        .lte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (7))),"yyyy-MM-dd HH:mm:ss"))))
+                        .lte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (7))),"yyyy-MM-dd HH:mm:ss")));
+
+
+        NativeSearchQuery searchQueryQTSM= new NativeSearchQueryBuilder()
+                .withQuery(queryBuilderQTSM)
                 .withPageable(PageRequest.of(1, 1))
                 .addAggregation(AggregationBuilders.dateHistogram("QTDSM")
                         .field("appointment_time")
@@ -366,15 +390,27 @@ public class OrderBaseCountLogic {
 
         Map<String,List<Long>> wglxfb = new HashMap<>();
 
+
+        BoolQueryBuilder queryBuilderAZ = QueryBuilders.boolQuery();
+
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+            queryBuilderAZ.must(
+                    QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                            .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+            );
+        }
+
+        queryBuilderAZ.must(
+                QueryBuilders.termsQuery("order_type_text",OrderTypeEnum.INSTALL.getRemark()));
+
+        queryBuilderAZ.must(
+                QueryBuilders.rangeQuery("over_time")
+                        .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))),"yyyy-MM-dd HH:mm:ss"))
+                        .lte(DateUtil.format(DateUtil.endOfDay(new Date()),"yyyy-MM-dd HH:mm:ss")));
+
+
         NativeSearchQuery searchQueryAZ= new NativeSearchQueryBuilder()
-                .withQuery(QueryBuilders.boolQuery()
-                        .must( QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                                .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds())))
-                        .must(QueryBuilders.boolQuery()
-                                .must(QueryBuilders.termsQuery("order_type_text",OrderTypeEnum.INSTALL.getRemark()))
-                                .must(QueryBuilders.rangeQuery("over_time")
-                                        .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))),"yyyy-MM-dd HH:mm:ss"))
-                                        .lte(DateUtil.format(DateUtil.endOfDay(new Date()),"yyyy-MM-dd HH:mm:ss")))))
+                .withQuery(queryBuilderAZ)
                 .withPageable(PageRequest.of(1, 1))
                 .addAggregation(AggregationBuilders.dateHistogram("AZ")
                         .field("over_time")
@@ -400,15 +436,22 @@ public class OrderBaseCountLogic {
         }
 
 
+        BoolQueryBuilder queryBuilderWX = QueryBuilders.boolQuery();
+
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+            queryBuilderWX.must(
+                    QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
+                            .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds()))
+            );
+        }
+        queryBuilderWX.must(QueryBuilders.termsQuery("order_type_text",OrderTypeEnum.REPAIR.getRemark()));
+
+        queryBuilderWX.must(QueryBuilders.rangeQuery("over_time")
+                .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))),"yyyy-MM-dd HH:mm:ss"))
+                .lte(DateUtil.format(DateUtil.endOfDay(new Date()),"yyyy-MM-dd HH:mm:ss")));
+
         NativeSearchQuery searchQueryWX= new NativeSearchQueryBuilder()
-                .withQuery(QueryBuilders.boolQuery()
-                        .must( QueryBuilders.boolQuery().should(QueryBuilders.termsQuery("create_websit_id", adminUser.getAdminWebsitIds()))
-                                .should(QueryBuilders.termsQuery("websit_id", adminUser.getAdminWebsitIds())))
-                        .must(QueryBuilders.boolQuery()
-                                .must(QueryBuilders.termsQuery("order_type_text",OrderTypeEnum.REPAIR.getRemark()))
-                                .must(QueryBuilders.rangeQuery("over_time")
-                                        .gte(DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), (-29))),"yyyy-MM-dd HH:mm:ss"))
-                                        .lte(DateUtil.format(DateUtil.endOfDay(new Date()),"yyyy-MM-dd HH:mm:ss")))))
+                .withQuery(queryBuilderWX)
                 .withPageable(PageRequest.of(1, 1))
                 .addAggregation(AggregationBuilders.dateHistogram("WX")
                         .field("over_time")