From 8d43111bd0e598bc0b2014cbfa69a32e74959dff Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 15 Dec 2021 19:24:05 +0800
Subject: [PATCH] ftp sql 同步封装

---
 src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java
index 5048244..ec41545 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
 import org.springblade.common.utils.arg;
+import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.exam.entity.ExamAnswerRecord;
 import org.springblade.modules.exam.entity.ExamSubjectChoices;
 import org.springblade.modules.exam.entity.ExamSubjectOption;
@@ -18,6 +19,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -350,11 +352,11 @@
 
 	/**
 	 * 新增答题记录
-	 * @param choices
-	 * @param preSubJectId
-	 * @param preResult
-	 * @param scoreId
-	 * @param result
+	 * @param choices 题目
+	 * @param preSubJectId 上一题题目id
+	 * @param preResult 上一题答题结果
+	 * @param scoreId 成绩 id
+	 * @param result 答题是否正确
 	 */
 	private void saveExamAns(ExamSubjectChoices choices, Long preSubJectId, String preResult, Long scoreId,boolean result) {
 		ExamAnswerRecord examAnswerRecord = new ExamAnswerRecord();
@@ -378,5 +380,17 @@
 		examAnswerRecordService.save(examAnswerRecord);
 
 		//内网数据同步...
+		String s = "insert into exam_answer_record(id,subject_choices_id,subject_choices_type,answer_option,answer" +
+			",answer_time,answer_score,answer_result,score_id) " +
+			"values(" + "'" + examAnswerRecord.getId() + "'" +
+			"," + "'" + examAnswerRecord.getSubjectChoicesId() + "'" +
+			"," + "'" + examAnswerRecord.getSubjectChoicesType() + "'" +
+			"," + "'" + examAnswerRecord.getAnswerOption() + "'" +
+			"," + "'" + examAnswerRecord.getAnswer() + "'" +
+			"," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(examAnswerRecord.getAnswerTime()) + "'" +
+			"," + "'" + examAnswerRecord.getAnswerScore() + "'" +
+			"," + "'" + examAnswerRecord.getAnswerResult() + "'" +
+			"," + "'" + examAnswerRecord.getScoreId() + "'" + ")";
+		FtpUtil.sqlFileUpload(s);
 	}
 }

--
Gitblit v1.9.3