Kaynağa Gözat

修正商业项目查询工单数据问题

wangchenghong 3 yıl önce
ebeveyn
işleme
fd2b58c449

+ 8 - 5
src/main/java/com/persagy/apm/energy/report/common/service/impl/WorkOrderPlatformServiceImpl.java

@@ -56,8 +56,8 @@ public class WorkOrderPlatformServiceImpl implements PlatformService {
     private Double getWorkOrderCompleteRate(String projectId, Date reportDate) {
         Double completeRate = null;
         try {
-            Integer workCount = getWorkOrderNumByParam(projectId, reportDate, "ask_end_time");
-            Integer dealCount = getWorkOrderNumByParam(projectId, reportDate, "create_time");
+            Integer workCount = getWorkOrderNumByParam(projectId, reportDate, "create_time", null);
+            Integer dealCount = getWorkOrderNumByParam(projectId, reportDate, "ask_end_time", "8");
             if (null != workCount && workCount != 0 && null != dealCount) {
                 completeRate = DataUtils.parseDouble(dealCount) / workCount * 100;
             }
@@ -68,11 +68,11 @@ public class WorkOrderPlatformServiceImpl implements PlatformService {
         return completeRate;
     }
 
-    private Integer getWorkOrderNumByParam(String projectId, Date reportDate, String timeType) {
+    private Integer getWorkOrderNumByParam(String projectId, Date reportDate, String timeType, String orderState) {
         try {
             String startTime = DateUtils.date2Str(reportDate, DateUtils.SDFSECOND);
             String endTime = DateUtils.date2Str(DateUtils.getMonthOff(reportDate, 1), DateUtils.SDFSECOND);
-            BoolQueryBuilder queryOrderNumBuilder = createQueryParam(projectId, timeType, startTime, endTime);
+            BoolQueryBuilder queryOrderNumBuilder = createQueryParam(projectId, timeType, startTime, endTime, orderState);
             NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
             nativeSearchQueryBuilder.withQuery(queryOrderNumBuilder);
             NativeSearchQuery query = nativeSearchQueryBuilder.build();
@@ -86,7 +86,7 @@ public class WorkOrderPlatformServiceImpl implements PlatformService {
         return null;
     }
 
-    private BoolQueryBuilder createQueryParam(String pjId, String timeType, String startTime, String endTime) {
+    private BoolQueryBuilder createQueryParam(String pjId, String timeType, String startTime, String endTime, String orderState) {
         BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
         queryBuilder.must(QueryBuilders.matchQuery("project_id", pjId));
         //时间查询
@@ -106,6 +106,9 @@ public class WorkOrderPlatformServiceImpl implements PlatformService {
                 }
             }
         }
+        if (StringUtils.isNotEmpty(orderState)) {
+            queryBuilder.must(QueryBuilders.matchQuery("order_state", orderState));
+        }
         return queryBuilder;
     }