| 
														
															@@ -1,8 +1,6 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 package com.gree.mall.manager.logic.workorder; 
														 | 
														
														 | 
														
															 package com.gree.mall.manager.logic.workorder; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.core.bean.BeanUtil; 
														 | 
														
														 | 
														
															 import cn.hutool.core.bean.BeanUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import cn.hutool.core.collection.CollectionUtil; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import cn.hutool.core.collection.ListUtil; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.core.convert.Convert; 
														 | 
														
														 | 
														
															 import cn.hutool.core.convert.Convert; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.core.date.DateUtil; 
														 | 
														
														 | 
														
															 import cn.hutool.core.date.DateUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.baomidou.mybatisplus.core.metadata.IPage; 
														 | 
														
														 | 
														
															 import com.baomidou.mybatisplus.core.metadata.IPage; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -10,7 +8,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.gree.mall.manager.bean.admin.AdminUserCom; 
														 | 
														
														 | 
														
															 import com.gree.mall.manager.bean.admin.AdminUserCom; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.gree.mall.manager.bean.es.*; 
														 | 
														
														 | 
														
															 import com.gree.mall.manager.bean.es.*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.gree.mall.manager.bean.listvo.param.WorkOrderZfireParam; 
														 | 
														
														 | 
														
															 import com.gree.mall.manager.bean.listvo.param.WorkOrderZfireParam; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import com.gree.mall.manager.bean.listvo.workorder.OperatorLogBean; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.gree.mall.manager.bean.listvo.workorder.OrderBaseVO; 
														 | 
														
														 | 
														
															 import com.gree.mall.manager.bean.listvo.workorder.OrderBaseVO; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.gree.mall.manager.commonmapper.CommonMapper; 
														 | 
														
														 | 
														
															 import com.gree.mall.manager.commonmapper.CommonMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.gree.mall.manager.enums.MaterialExamineStatusEnum; 
														 | 
														
														 | 
														
															 import com.gree.mall.manager.enums.MaterialExamineStatusEnum; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -141,20 +138,6 @@ public class OrderBaseEsLogic { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         page.setSize(zfireParamBean.getPageSize()); 
														 | 
														
														 | 
														
															         page.setSize(zfireParamBean.getPageSize()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         page.setRecords(BeanUtil.copyToList(orderBaseEs, OrderBaseVO.class)); 
														 | 
														
														 | 
														
															         page.setRecords(BeanUtil.copyToList(orderBaseEs, OrderBaseVO.class)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        List<OperatorLogBean> operatorList = null; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (page.getSize() > 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            final List<String> orderBaseIds = page.getRecords().stream().map(OrderBaseVO::getId).distinct().collect(Collectors.toList()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (CollectionUtil.isNotEmpty(orderBaseIds)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                operatorList = commonMapper.selectLastOrderOperatorLog(year, orderBaseIds); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Map<String, List<OperatorLogBean>> operatorMap = null; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (CollectionUtil.isNotEmpty(operatorList)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            operatorMap = operatorList.stream() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    .collect(Collectors.groupingBy(OperatorLogBean::getOrderBaseId)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //服务单标识 
														 | 
														
														 | 
														
															         //服务单标识 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (zfireParamBean.getPageSize() != -1 && page.getTotal() > 0 && page.getRecords().size() > 0) { 
														 | 
														
														 | 
														
															         if (zfireParamBean.getPageSize() != -1 && page.getTotal() > 0 && page.getRecords().size() > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             List<String> orderBaseIds = page.getRecords() 
														 | 
														
														 | 
														
															             List<String> orderBaseIds = page.getRecords() 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -176,10 +159,6 @@ public class OrderBaseEsLogic { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     BigDecimal bigDecimal = workerOrders.stream().map(WorkerOrder::getTotalAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); 
														 | 
														
														 | 
														
															                     BigDecimal bigDecimal = workerOrders.stream().map(WorkerOrder::getTotalAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     orderBaseVO.setWorkerPrice(bigDecimal); 
														 | 
														
														 | 
														
															                     orderBaseVO.setWorkerPrice(bigDecimal); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (Objects.nonNull(operatorMap) && operatorMap.containsKey(orderBaseVO.getId())) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    orderBaseVO.setLastFeedbackRecord(operatorMap.get(orderBaseVO.getId()).get(0).getContent()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return page; 
														 | 
														
														 | 
														
															         return page; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -997,32 +976,33 @@ public class OrderBaseEsLogic { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 .eq(WorkerOrder::getPayStatus, MaterialExamineStatusEnum.PAID.getKey()) 
														 | 
														
														 | 
														
															                 .eq(WorkerOrder::getPayStatus, MaterialExamineStatusEnum.PAID.getKey()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 .select(WorkerOrder::getWorkerOrderId, WorkerOrder::getTotalAmount).list(); 
														 | 
														
														 | 
														
															                 .select(WorkerOrder::getWorkerOrderId, WorkerOrder::getTotalAmount).list(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        List<OperatorLogBean> operatorList = new ArrayList<>(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (CollectionUtil.isNotEmpty(orderBaseIds)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            final List<List<String>> pageList = ListUtil.split(orderBaseIds, 10000); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            for (List<String> orderIdPageList : pageList) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                operatorList.addAll(commonMapper.selectLastOrderOperatorLog(year, orderIdPageList)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 预处理:将workerOrderList按workerOrderId分组(O(m)时间复杂度) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, List<WorkerOrder>> workerOrderMap = workerOrderList.stream() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .collect(Collectors.groupingBy(WorkerOrder::getWorkerOrderId)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Map<String, List<OperatorLogBean>> operatorMap = null; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (CollectionUtil.isNotEmpty(operatorList)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            operatorMap = operatorList.stream() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    .collect(Collectors.groupingBy(OperatorLogBean::getOrderBaseId)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 提前判断workerOrderList是否为空(避免循环内重复判断) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        boolean isWorkerOrderListEmpty = CollectionUtils.isEmpty(workerOrderList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (OrderBaseVO orderBaseVO : orderBaseVOS1) { 
														 | 
														
														 | 
														
															         for (OrderBaseVO orderBaseVO : orderBaseVOS1) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            List<WorkerOrder> workerOrders = workerOrderList.stream() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    .filter(item -> item.getWorkerOrderId().equals(orderBaseVO.getId())).collect(Collectors.toList()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (!CollectionUtils.isEmpty(workerOrderList)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                BigDecimal bigDecimal = workerOrders.stream().map(WorkerOrder::getTotalAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            List<WorkerOrder> workerOrders = workerOrderList.stream() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    .filter(item -> item.getWorkerOrderId().equals(orderBaseVO.getId())).collect(Collectors.toList()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            if (!CollectionUtils.isEmpty(workerOrderList)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                BigDecimal bigDecimal = workerOrders.stream().map(WorkerOrder::getTotalAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                orderBaseVO.setWorkerPrice(bigDecimal); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+// 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 从Map中直接获取匹配的WorkerOrder列表(O(1)时间复杂度) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            List<WorkerOrder> workerOrders = workerOrderMap.getOrDefault(orderBaseVO.getId(), Collections.emptyList()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 计算总金额(若workerOrderList非空时才执行) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (!isWorkerOrderListEmpty && !workerOrders.isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                BigDecimal bigDecimal = workerOrders.stream() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        .map(WorkerOrder::getTotalAmount) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        .reduce(BigDecimal::add) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        .orElse(BigDecimal.ZERO); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 orderBaseVO.setWorkerPrice(bigDecimal); 
														 | 
														
														 | 
														
															                 orderBaseVO.setWorkerPrice(bigDecimal); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (Objects.nonNull(operatorMap) && operatorMap.containsKey(orderBaseVO.getId())) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                orderBaseVO.setLastFeedbackRecord(operatorMap.get(orderBaseVO.getId()).get(0).getContent()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return orderBaseVOS1; 
														 | 
														
														 | 
														
															         return orderBaseVOS1; 
														 |