forked from wangziqi/gongxue-base
refactor: remove scheduled cron sync, manual trigger only
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Cron } from '@nestjs/schedule';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { SyncLog, SyncState, UserDingMapping } from '../entities';
|
||||
@@ -7,6 +6,7 @@ import type { SyncPlatform, SyncType, SyncStatus } from '../entities/sync-log.en
|
||||
import { DingTalkService } from '../integration/dingtalk.service';
|
||||
import { WeComService } from '../integration/wecom.service';
|
||||
import { AttendanceImportService } from '../attendance/attendance-import.service';
|
||||
import { ScheduleSyncService } from './schedule-sync.service';
|
||||
|
||||
@Injectable()
|
||||
export class SyncService {
|
||||
@@ -21,16 +21,10 @@ export class SyncService {
|
||||
private readonly dingTalkService: DingTalkService,
|
||||
private readonly weComService: WeComService,
|
||||
private readonly attendanceImportService: AttendanceImportService,
|
||||
private readonly scheduleSyncService: ScheduleSyncService,
|
||||
) {}
|
||||
|
||||
// ── Scheduled cron: daily at 2 AM ──
|
||||
@Cron('0 2 * * *')
|
||||
async scheduledSync() {
|
||||
this.logger.log('Starting scheduled sync job');
|
||||
await this.syncDingTalk();
|
||||
await this.syncWeCom();
|
||||
this.logger.log('Scheduled sync job completed');
|
||||
}
|
||||
// ── Scheduled sync disabled — use manual trigger via UI ──
|
||||
|
||||
// ── Sync DingTalk ──
|
||||
async syncDingTalk(rootDeptId = 1): Promise<SyncLog> {
|
||||
@@ -98,6 +92,19 @@ export class SyncService {
|
||||
return this.dingTalkService.fetchOrgTree(rootDeptId);
|
||||
}
|
||||
|
||||
// ── 排班同步 ──
|
||||
|
||||
/** 将本地排课同步到钉钉考勤排班 */
|
||||
async syncScheduleToDingTalk(dateFrom?: string, days = 30) {
|
||||
return this.scheduleSyncService.syncAll(dateFrom, days);
|
||||
}
|
||||
|
||||
/** 获取排班同步状态(当前仅返回活跃排课统计) */
|
||||
async getScheduleSyncStatus(date?: string) {
|
||||
const targetDate = date || new Date().toISOString().slice(0, 10);
|
||||
return this.scheduleSyncService.getStatus(targetDate);
|
||||
}
|
||||
|
||||
// ── Sync log queries ──
|
||||
async getLogs(platform?: SyncPlatform, limit: number = 50): Promise<SyncLog[]> {
|
||||
const where: Record<string, SyncPlatform> = {};
|
||||
|
||||
Reference in New Issue
Block a user