Bläddra i källkod

Merge remote-tracking branch 'origin/mqy20260511'

mqy20260511
humanleft 4 dagar sedan
förälder
incheckning
c62801ac4c

+ 35
- 35
iot-platform/src/main/java/com/iot/platform/task/VehicleSyncTask.java Visa fil

@@ -343,40 +343,40 @@ public class VehicleSyncTask {
343 343
      * 更新指标信息
344 344
      * 根据公司去查询
345 345
      */
346
-    @Scheduled(fixedDelay = 30000)
347
-    public void insertIndicators() {
348
-        String lockKey = "lock:vehicle-sync:insertIndicators";
349
-        if (!tryLock(lockKey, 60)) {
350
-            log.debug("获取锁失败,跳过本次执行: {}", lockKey);
351
-            return;
352
-        }
353
-        try {
354
-            doInsertIndicators();
355
-        } finally {
356
-            unlock(lockKey);
357
-        }
358
-    }
346
+//    @Scheduled(fixedDelay = 30000)
347
+//    public void insertIndicators() {
348
+//        String lockKey = "lock:vehicle-sync:insertIndicators";
349
+//        if (!tryLock(lockKey, 60)) {
350
+//            log.debug("获取锁失败,跳过本次执行: {}", lockKey);
351
+//            return;
352
+//        }
353
+//        try {
354
+//            doInsertIndicators();
355
+//        } finally {
356
+//            unlock(lockKey);
357
+//        }
358
+//    }
359 359
 
360
-    private void doInsertIndicators() {
361
-        try {
362
-            LocalDate today = LocalDate.now();
363
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
364
-            String day = today.format(formatter);
365
-            List<SysCompany> sysCompanyList = sysCompanyService.selectcompany();
366
-            for (SysCompany sysCompany : sysCompanyList) {
367
-                Integer countworkorder = sysWorkorderService.selectworkordercount(sysCompany.getCompanyId(), day);
368
-                Double countprofit = sysWorkorderService.selectwokroderprofit(sysCompany.getCompanyId(), day);
369
-                Integer count = sysIndicatorsService.selectcarcount(sysCompany.getCompanyId(), day);
370
-                if (count <= 0) {
371
-                    sysIndicatorsService.insertindicators(countworkorder, countprofit, sysCompany.getCompanyId(), day);
372
-                } else {
373
-                    sysIndicatorsService.updateindicators(countworkorder, countprofit, sysCompany.getCompanyId(), day);
374
-                }
375
-            }
376
-        } catch (DataAccessException e) {
377
-            log.error("数据库操作失败: {}", e.getMessage(), e);
378
-        } catch (Exception e) {
379
-            log.error("更新指标信息失败: {}", e.getMessage(), e);
380
-        }
381
-    }
360
+//    private void doInsertIndicators() {
361
+//        try {
362
+//            LocalDate today = LocalDate.now();
363
+//            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
364
+//            String day = today.format(formatter);
365
+//            List<SysCompany> sysCompanyList = sysCompanyService.selectcompany();
366
+//            for (SysCompany sysCompany : sysCompanyList) {
367
+//                Integer countworkorder = sysWorkorderService.selectworkordercount(sysCompany.getCompanyId(), day);
368
+//                Double countprofit = sysWorkorderService.selectwokroderprofit(sysCompany.getCompanyId(), day);
369
+//                Integer count = sysIndicatorsService.selectcarcount(sysCompany.getCompanyId(), day);
370
+//                if (count <= 0) {
371
+//                    sysIndicatorsService.insertindicators(countworkorder, countprofit, sysCompany.getCompanyId(), day);
372
+//                } else {
373
+//                    sysIndicatorsService.updateindicators(countworkorder, countprofit, sysCompany.getCompanyId(), day);
374
+//                }
375
+//            }
376
+//        } catch (DataAccessException e) {
377
+//            log.error("数据库操作失败: {}", e.getMessage(), e);
378
+//        } catch (Exception e) {
379
+//            log.error("更新指标信息失败: {}", e.getMessage(), e);
380
+//        }
381
+//    }
382 382
 }

+ 11
- 11
iot-platform/src/test/java/com/iot/platform/task/VehicleSyncTaskTest.java Visa fil

@@ -181,17 +181,17 @@ class VehicleSyncTaskTest {
181 181
         verify(sysrealtimeService, never()).createrealtime(anyString());
182 182
     }
183 183
 
184
-    @Test
185
-    @DisplayName("insertIndicators: 公司列表为空时不应抛异常")
186
-    void insertIndicators_emptyCompanyList_noException() {
187
-        when(valueOps.setIfAbsent(anyString(), eq("1"), anyLong(), any())).thenReturn(true);
188
-        when(sysCompanyService.selectcompany()).thenReturn(Collections.emptyList());
189
-        when(stringRedisTemplate.delete(anyString())).thenReturn(true);
190
-
191
-        task.insertIndicators();
192
-
193
-        verify(sysWorkorderService, never()).selectworkordercount(anyString(), anyString());
194
-    }
184
+//    @Test
185
+//    @DisplayName("insertIndicators: 公司列表为空时不应抛异常")
186
+//    void insertIndicators_emptyCompanyList_noException() {
187
+//        when(valueOps.setIfAbsent(anyString(), eq("1"), anyLong(), any())).thenReturn(true);
188
+//        when(sysCompanyService.selectcompany()).thenReturn(Collections.emptyList());
189
+//        when(stringRedisTemplate.delete(anyString())).thenReturn(true);
190
+//
191
+//        task.insertIndicators();
192
+//
193
+//        verify(sysWorkorderService, never()).selectworkordercount(anyString(), anyString());
194
+//    }
195 195
 
196 196
     @Test
197 197
     @DisplayName("webhook 调用失败时不应中断主流程")

Laddar…
Avbryt
Spara