Quellcode durchsuchen

调整同步逻辑

xyx vor 1 Woche
Ursprung
Commit
49c5b1ce27

+ 4 - 25
fs-service/src/main/java/com/fs/sop/service/impl/QwSopTempServiceImpl.java

@@ -645,7 +645,9 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
         }
         List<QwSopTempContent> contentList = qwSopTempContentService.listByTempIds(tempIds);
 
-        CountDownLatch latch = new CountDownLatch(tempList.size());
+        qwSopTempDayService.removeByTempIds(tempIds);
+        qwSopTempRulesService.removeByTempIds(tempIds);
+        qwSopTempContentService.removeByTempIds(tempIds);
         // 对每个模板执行同步操作
         for (QwSopTemp temp : tempList) {
             // 构造timeList timeDesc time
@@ -676,31 +678,8 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
             // 插入课程id
             temp.setCourseId(courseId);
             temp.setOpenOfficial("1");
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            temp.setCreateTime(sdf.format(new Date()));
-            temp.setId(UUID.randomUUID().toString());
-            qwSopTempMapper.insertQwSopTemp(temp);
             // 重新生成该模板的规则和内容
-            threadPoolTaskExecutor.execute(() -> {
-                try {
-                    createSopTempRules(temp);
-                } catch (Exception e) {
-                    log.error("同步模板规则和内容失败", e);
-                } finally {
-                    latch.countDown();
-                }
-            });
-
-        }
-
-        try {
-            latch.await();
-            qwSopTempMapper.deleteQwSopTempByIds(tempIds.toArray(new String[0]));
-            qwSopTempDayService.removeByTempIds(tempIds);
-            qwSopTempRulesService.removeByTempIds(tempIds);
-            qwSopTempContentService.removeByTempIds(tempIds);
-        } catch (InterruptedException e) {
-            log.error("等待线程执行完成时被中断", e);
+            threadPoolTaskExecutor.execute(() -> createSopTempRules(temp));
         }
     }