| 
					
				 | 
			
			
				@@ -27,7 +27,10 @@ import com.fs.erp.dto.ErpOrderQueryResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.erp.dto.ErpOrderResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.erp.mapper.FsErpFinishPushMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.erp.service.IErpOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.fastGpt.domain.FastGptEventTokenLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.fastGpt.domain.FastgptEventLogTotal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.fastGpt.mapper.FastGptChatSessionMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.fastGpt.service.IFastgptEventLogTotalService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.config.FsSysConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.config.StoreConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.domain.FsInquiryOrder; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,10 +61,7 @@ import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Qualifier; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Component; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Component("task") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -161,6 +161,226 @@ public class Task { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ICompanyUserService userService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IFastgptEventLogTotalService fastgptEventLogTotalService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //统计ai事件埋点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void eventLogTotals() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 判断是否是凌晨 00:00 - 00:59 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        boolean isEarlyMorning = isEarlyMorning(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取日期字符串(今天或昨天) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String dateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (isEarlyMorning) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dateTime = DateUtils.addDateDays(-1); // 昨天 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            date = DateUtils.addDays(new Date(), -1); // 昨天的 Date 对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dateTime = DateUtils.getDate(); // 今天 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            date = new Date(); // 今天的 Date 对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //更新埋点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processEventLogTotals(date, dateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //更新token消耗 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processTokenLogs(date, dateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void processEventLogTotals(Date date, String dateTime) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FastgptEventLogTotal logTotal = new FastgptEventLogTotal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        logTotal.setCreateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FastgptEventLogTotal> totalList = fastgptEventLogTotalService.selectFastgptEventLogTotalInfoList(logTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 分别收集需要更新和插入的记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FastgptEventLogTotal> toUpdateList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FastgptEventLogTotal> toInsertList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 用于防止重复添加相同记录的集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> processedKeys = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (FastgptEventLogTotal total : totalList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (total == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (total.getType() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    total.setCount(total.getSenderCount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 构造唯一标识符,用于防止重复处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String uniqueKey = String.format("%d_%d_%d_%d_%d_%s", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        total.getRoleId() != null ? total.getRoleId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        total.getType() != null ? total.getType() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        total.getCompanyId() != null ? total.getCompanyId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        total.getCompanyUserId() != null ? total.getCompanyUserId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        total.getQwUserId() != null ? total.getQwUserId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        dateTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 检查是否已经处理过这个记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (processedKeys.contains(uniqueKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                FastgptEventLogTotal info = fastgptEventLogTotalService.selectFastgptEventLogTotalByRoleIdAndType(total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (info != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Long newCount = total.getCount() != null ? total.getCount() : 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 只有当count值发生变化时才加入更新列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!newCount.equals(info.getCount())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        FastgptEventLogTotal eventLogTotal = new FastgptEventLogTotal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        eventLogTotal.setId(info.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        eventLogTotal.setCount(newCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(!processedKeys.contains(uniqueKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            toUpdateList.add(eventLogTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            // 标记为已处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            processedKeys.add(uniqueKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    total.setStatTime(dateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(!processedKeys.contains(uniqueKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        toInsertList.add(total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // 标记为已处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        processedKeys.add(uniqueKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.error("统计AI事件触发情况异常,数据:" + total, e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 批量处理更新和插入操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processBatchUpdates(toUpdateList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processBatchInserts(toInsertList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void processBatchUpdates(List<FastgptEventLogTotal> toUpdateList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 使用批量更新方法替代逐条更新,提高处理速度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int batchSize = 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int i = 0; i < toUpdateList.size(); i += batchSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int endIndex = Math.min(i + batchSize, toUpdateList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<FastgptEventLogTotal> batch = toUpdateList.subList(i, endIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fastgptEventLogTotalService.updateFastgptEventLogTotalBatch(batch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 如果批量更新失败,则逐条更新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.warn("批量更新AI事件统计信息失败,将逐条更新", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (FastgptEventLogTotal item : batch) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        fastgptEventLogTotalService.updateFastgptEventLogTotal(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } catch (Exception ex) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.error("更新AI事件统计信息失败,数据:" + item, ex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void processBatchInserts(List<FastgptEventLogTotal> toInsertList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 使用批量插入方法替代逐条插入,提高处理速度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int batchSize = 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int i = 0; i < toInsertList.size(); i += batchSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int endIndex = Math.min(i + batchSize, toInsertList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<FastgptEventLogTotal> batch = toInsertList.subList(i, endIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fastgptEventLogTotalService.insertFastgptEventLogTotalBatch(batch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 如果批量插入失败,则逐条插入 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.warn("批量插入AI事件统计信息失败,将逐条插入", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (FastgptEventLogTotal item : batch) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        fastgptEventLogTotalService.insertFastgptEventLogTotal(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } catch (Exception ex) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.error("插入AI事件统计信息失败,数据:" + item, ex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void processTokenLogs(Date date, String dateTime) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FastGptEventTokenLog fastGptEventTokenLog = new FastGptEventTokenLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fastGptEventTokenLog.setCreateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FastGptEventTokenLog> tokenLogs = fastgptEventLogTotalService.selectFastgptEventTokenLogTotalList(fastGptEventTokenLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 分别收集需要更新和插入的记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FastgptEventLogTotal> toUpdateList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FastgptEventLogTotal> toInsertList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 用于防止重复添加相同记录的集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> processedKeys = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (FastGptEventTokenLog tokenLog : tokenLogs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (tokenLog == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 构造唯一标识符,用于防止重复处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String uniqueKey = String.format("%d_11_%d_%d_%d_%s", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        tokenLog.getRoleId() != null ? tokenLog.getRoleId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        tokenLog.getCompanyId() != null ? tokenLog.getCompanyId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        tokenLog.getCompanyUserId() != null ? tokenLog.getCompanyUserId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        tokenLog.getQwUserId() != null ? tokenLog.getQwUserId() : 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        dateTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 检查是否已经处理过这个记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (processedKeys.contains(uniqueKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                FastgptEventLogTotal info = fastgptEventLogTotalService.selectFastgptEventTokenLogTotalByRoleIdAndType(tokenLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Long tokenCount = tokenLog.getTokenCount() != null ? tokenLog.getTokenCount() : 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Long totalCount = (tokenCount * 8) + random.nextInt(21) - 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (info != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 只有当count值发生变化时才加入更新列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!totalCount.equals(info.getCount())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        FastgptEventLogTotal eventLogTotalNew = new FastgptEventLogTotal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        eventLogTotalNew.setId(info.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        eventLogTotalNew.setCount(totalCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(!processedKeys.contains(uniqueKey)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            toUpdateList.add(eventLogTotalNew); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            // 标记为已处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            processedKeys.add(uniqueKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    FastgptEventLogTotal eventLogTotal = new FastgptEventLogTotal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setRoleId(tokenLog.getRoleId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setCount(totalCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setType(11); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setCompanyId(tokenLog.getCompanyId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setCompanyUserId(tokenLog.getCompanyUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setQwUserId(tokenLog.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    eventLogTotal.setStatTime(dateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(!processedKeys.contains(uniqueKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        toInsertList.add(eventLogTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // 标记为已处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        processedKeys.add(uniqueKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.error("统计AI消耗token触发情况异常,数据:" + tokenLog, e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 批量处理更新和插入操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processBatchUpdates(toUpdateList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processBatchInserts(toInsertList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private boolean isEarlyMorning() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date now = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        java.time.LocalDateTime localDateTime = now.toInstant() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .atZone(java.time.ZoneId.systemDefault()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .toLocalDateTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return localDateTime.getHour() == 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //定时查询ipad主机使用情况,建议每天凌晨1点执行一次 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void totalIpadTask(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String dateTime = DateUtils.addDateDays(-1); // 昨天 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1058,6 +1278,9 @@ public class Task { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Qualifier("JSTErpOrderServiceImpl") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IErpOrderService jSTOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Qualifier("k9OrderScrmServiceImpl") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IErpOrderService k9OrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IErpOrderService getErpService() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         FsSysConfig sysConfig = configUtil.getSysConfig(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1081,6 +1304,8 @@ public class Task { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     erpOrderService =  dfOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }else if(erpType == 5){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     erpOrderService=jSTOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else if(erpType == 6){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    erpOrderService=k9OrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return erpOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |