const syncWritingEvidencePrefix = '同步自动核对:'; function hasSyncWritingPlan(appointment) { return appointment?.kcid === '398' && ['primary_writing', 'middle_writing', 'high_writing'].includes(appointment.courseCategoryKey) && String(appointment.categoryEvidence || '').startsWith(syncWritingEvidencePrefix); } async function syncWritingHasTeachingEvidence(db, companyId, common, appointment) { return Boolean(await db.oneOrNone(` SELECT 1 WHERE EXISTS ( SELECT 1 FROM "CourseCreditReservation" WHERE company=$1 AND "appointmentId"=$2 ) OR EXISTS ( SELECT 1 FROM "LessonRecord" WHERE company=$1 AND yyds::text=ANY($3::text[]) ) OR EXISTS ( SELECT 1 FROM "LessonRecordFact" WHERE company=$1 AND yyds::text=ANY($3::text[]) ) OR EXISTS ( SELECT 1 FROM "LessonCompletionReport" WHERE company=$1 AND ("appointmentId"=$2 OR "appointmentGeneralId"::text=ANY($3::text[])) ) `, [companyId, common.objectId, [String(common.generalId), String(appointment.id)]])); }