配置上传

master
yz 8 months ago
parent b109048649
commit eeb745dfe7

@ -38,6 +38,6 @@ public class Constant {
public static final String THEORY = "理论考试模块";
public static final String RESOURCE = "资源中心模块";
public static final String API_URL = "http://120.79.54.255:8889";
// public static final String API_URL = "http://192.168.2.11:8889";
// public static final String API_URL = "http://192.168.2.29:8889";
}

@ -244,7 +244,7 @@ public class TeaGradeManageController {
List<String> list = Arrays.asList(caseIdList.split(","));
List<TestTestSysCaseQuestionStepWithBLOBs> resultList = null;
try {
resultList = CaseApi.getGradeReportCase(list, schoolId, systemOwner);
resultList = CaseApi.getGradeReportCase(list, schoolId,systemOwner);
} catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常");
}

@ -323,10 +323,10 @@ public class CaseApi {
*
* --questionOriginalcontentOriginal,Sort
*/
public static List<TestTestSysCaseQuestionStepWithBLOBs> getGradeReportCase(List<String> caseIdList, String schoolId, String systemOwner) throws IOException {
public static List<TestTestSysCaseQuestionStepWithBLOBs> getGradeReportCase(List<String> caseIdList, String schoolId,String systemOwner) throws IOException {
Gson gson = new Gson();
// 构建带有 schoolId 的 URL
String urlWithParams = getGradeReportCase + "?schoolId=" + URLEncoder.encode(schoolId, "UTF-8");
String urlWithParams = getGradeReportCase + "?schoolId=" + URLEncoder.encode(schoolId, "UTF-8")+"&systemOwner="+ systemOwner;
JSONObject object = HttpUtils.sendPost(
urlWithParams,
gson.toJson(caseIdList), "application/json", null);

@ -30,13 +30,13 @@ public class ResourceCenterApi {
* local:
* rsapi:
*/
public static Boolean uploadResource(MultipartFile file, String schoolId, String courseId,String type,String systemOwner,String courseName) throws IOException {
public static Boolean uploadResource(MultipartFile file, String schoolId, String courseId, String type, String systemOwner, String courseName) throws IOException {
String returnStr = HttpUtils.sendPostRequestWithMultipartFile(
uploadResource + "?schoolId=" + schoolId+"&twoId="+courseId+"&resourceType="+type+"&systemOwner="+systemOwner+"&twoName"+courseName,
uploadResource + "?schoolId=" + schoolId + "&twoId=" + courseId + "&resourceType=" + type + "&systemOwner=" + systemOwner + "&twoName" + courseName,
file);
if("true".equals(returnStr)){
if ("true".equals(returnStr)) {
return true;
}else {
} else {
return false;
}
}
@ -45,15 +45,16 @@ public class ResourceCenterApi {
* local:
* rsapi:
*/
public static List<SysResource> selectResource(String schoolId, String courseId,String systemOwner) throws IOException {
String requestBody="schoolId="+schoolId+"&twoId="+courseId+"&oneId="+systemOwner;
public static List<SysResource> selectResource(String schoolId, String courseId, String systemOwner) throws IOException {
String requestBody = "schoolId=" + schoolId + "&twoId=" + courseId + "&oneId=" + systemOwner;
JSONObject object = HttpUtils.sendPost(
selectResource,
requestBody);
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
Type listType = new TypeToken<List<SysResource>>() {}.getType();
Type listType = new TypeToken<List<SysResource>>() {
}.getType();
List<SysResource> resourceList = gson.fromJson(object.get("respString").toString(), listType);
return resourceList;
}
@ -63,15 +64,16 @@ public class ResourceCenterApi {
* rsapi:
*/
public static List<SysResource> selectResourceByChapterId(String chapterId,String systemOwner) throws IOException {
String requestBody="threeId="+chapterId+"&oneId="+systemOwner;
public static List<SysResource> selectResourceByChapterId(String chapterId, String systemOwner) throws IOException {
String requestBody = "threeId=" + chapterId + "&oneId=" + systemOwner;
JSONObject object = HttpUtils.sendPost(
selectResourceByChapterId,
requestBody);
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
Type listType = new TypeToken<List<SysResource>>() {}.getType();
Type listType = new TypeToken<List<SysResource>>() {
}.getType();
List<SysResource> resourceList = gson.fromJson(object.get("respString").toString(), listType);
return resourceList;
}
@ -82,15 +84,15 @@ public class ResourceCenterApi {
* rsapi:
*/
public static void downloadResource(String resourceDataName, String resourceId, HttpServletResponse response) throws Exception {
String downloadResourceUrl = downloadResource+"?resourceId=" + resourceId;
DownLoadUtil.downLoadFile(downloadResourceUrl,resourceDataName,response);
String downloadResourceUrl = downloadResource + "?resourceId=" + resourceId;
DownLoadUtil.downLoadFile(downloadResourceUrl, resourceDataName, response);
}
/**
*
*/
public static Map<String,Integer> getResourceTypeCount(String schoolId ,String systemOwner){
String requestBody="schoolId="+schoolId+"&systemOwner="+systemOwner;
public static Map<String, Integer> getResourceTypeCount(String schoolId, String systemOwner) {
String requestBody = "schoolId=" + schoolId + "&systemOwner=" + systemOwner;
JSONObject object = null;
try {
object = HttpUtils.sendPost(
@ -99,22 +101,23 @@ public class ResourceCenterApi {
} catch (IOException e) {
e.printStackTrace();
}
if(object==null){
if (object == null) {
return new HashMap<>();
}
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
Type listType = new TypeToken<Map<String,Integer>>() {}.getType();
Map<String,Integer> map = gson.fromJson(object.get("respString").toString(), listType);
Type listType = new TypeToken<Map<String, Integer>>() {
}.getType();
Map<String, Integer> map = gson.fromJson(object.get("respString").toString(), listType);
return map;
}
/**
*
*/
public static Integer getTotalResource(String systemOwner,String schoolId) throws IOException {
String requestBody="schoolId="+schoolId+"&systemOwner="+systemOwner;
public static Integer getTotalResource(String systemOwner, String schoolId) throws IOException {
String requestBody = "schoolId=" + schoolId + "&systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost(
getTotalResource,
requestBody);
@ -125,8 +128,8 @@ public class ResourceCenterApi {
/**
*
*/
public static String getMostPopularName(String systemOwner,String schoolId) throws IOException {
String requestBody="schoolId="+schoolId+"&systemOwner="+systemOwner;
public static String getMostPopularName(String systemOwner, String schoolId) throws IOException {
String requestBody = "schoolId=" + schoolId + "&systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost(
getMostPopularName,
requestBody);

@ -1,6 +1,5 @@
package com.sztzjy.financial_bigdata.service.stu.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.financial_bigdata.config.Constant;
@ -11,7 +10,6 @@ import com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryTestDto;
import com.sztzjy.financial_bigdata.mapper.*;
import com.sztzjy.financial_bigdata.resourceCenterAPI.ObjectiveApi;
import com.sztzjy.financial_bigdata.service.stu.ITheoryTestService;
import com.sztzjy.financial_bigdata.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -37,25 +35,25 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
// 之前没有进行考试 从客观题库表中查询 35道单选每题2分5道多选每题4分10道判断每题1分 并将id保存至理论考试表中
// 注意 开始考试后 要生成理论记录表基础数据
@Override
public List<SysObjectiveQuestions> startTheoryTest(String userId,String systemOwner) throws IOException {
public List<SysObjectiveQuestions> startTheoryTest(String userId, String systemOwner) throws IOException {
StuTheoryExamExample example = new StuTheoryExamExample();
example.createCriteria().andUserIdEqualTo(userId);
example.setOrderByClause("exam_time DESC");
List<StuTheoryExamWithBLOBs> stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example);
if (stuTheoryExams.isEmpty()) { //之前没有进行考试
List<SysObjectiveQuestions> objectiveQuestionList = GenerateTest(userId,systemOwner);
GenerateTheoryRecordFirst(userId);
List<SysObjectiveQuestions> objectiveQuestionList = GenerateTest(userId, systemOwner);
GenerateTheoryRecordFirst(userId, systemOwner);
return objectiveQuestionList;
} else { //根据考试时间排序 查询最近的一条
StuTheoryExamWithBLOBs stuTheoryExam = stuTheoryExams.get(0);
Date currentTime = new Date();
Date twoHoursAgo = new Date(currentTime.getTime() - (2 * 60 * 60 * 1000)); // 当前时间减去两个小时
if(stuTheoryExam.getAnswered()){
List<SysObjectiveQuestions> objectiveQuestionList = GenerateTest(userId,systemOwner);
if (stuTheoryExam.getAnswered()) {
List<SysObjectiveQuestions> objectiveQuestionList = GenerateTest(userId, systemOwner);
return objectiveQuestionList;
}
if (stuTheoryExam.getExamTime().before(twoHoursAgo)) { //已超出两个小时 从新生成新试卷
List<SysObjectiveQuestions> objectiveQuestionList = GenerateTest(userId,systemOwner);
List<SysObjectiveQuestions> objectiveQuestionList = GenerateTest(userId, systemOwner);
return objectiveQuestionList;
} else { //在两个小时内 返回最近的一条试卷
String singleIds = stuTheoryExam.getSingleIds();
@ -77,9 +75,9 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
}
//第一次生成理论考试记录数据 先判断是否生成过理论考试记录数据
public void GenerateTheoryRecordFirst(String userId){
public void GenerateTheoryRecordFirst(String userId, String systemOwner) {
StuTheoryRecord record = theoryRecordMapper.selectByPrimaryKey(userId);
if(record==null){
if (record == null) {
StuUser stuUser = userMapper.selectByPrimaryKey(userId);
StuTheoryRecord stuTheoryRecord = new StuTheoryRecord();
stuTheoryRecord.setUserId(userId);
@ -88,36 +86,37 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
stuTheoryRecord.setName(stuUser.getName());
stuTheoryRecord.setStudentId(stuUser.getStudentId());
stuTheoryRecord.setExamCount(0);
stuTheoryRecord.setSystemOwner(systemOwner);
theoryRecordMapper.insert(stuTheoryRecord);
}
}
public void UpdateTheoryRecord(String userId,BigDecimal score,Integer examDuration){
public void UpdateTheoryRecord(String userId, BigDecimal score, Integer examDuration) {
StuTheoryRecord record = theoryRecordMapper.selectByPrimaryKey(userId);
if(record!=null){
record.setExamCount(record.getExamCount()+1);
if(record.getHighestScore()==null){
if (record != null) {
record.setExamCount(record.getExamCount() + 1);
if (record.getHighestScore() == null) {
record.setHighestScore(score);
}else {
if(record.getHighestScore().compareTo(score)<0){
} else {
if (record.getHighestScore().compareTo(score) < 0) {
record.setHighestScore(score);
}
}
if(record.getLowestScore()==null){
if (record.getLowestScore() == null) {
record.setLowestScore(score);
}else {
if(record.getLowestScore().compareTo(score)>0){
} else {
if (record.getLowestScore().compareTo(score) > 0) {
record.setLowestScore(score);
}
}
if(record.getTotalDuration()==null){
if (record.getTotalDuration() == null) {
record.setTotalDuration(examDuration);
}else {
record.setTotalDuration(examDuration+record.getTotalDuration());
} else {
record.setTotalDuration(examDuration + record.getTotalDuration());
}
if(record.getAverageScore()==null){
if (record.getAverageScore() == null) {
record.setAverageScore(score);
}else {
} else {
Integer examCount = record.getExamCount();
BigDecimal averageScore = record.getAverageScore();
BigDecimal multiply = averageScore.multiply(BigDecimal.valueOf(examCount));
@ -130,11 +129,11 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
//随机生成100分题目
public List<SysObjectiveQuestions> GenerateTest(String userId,String systemOwner) throws IOException {
public List<SysObjectiveQuestions> GenerateTest(String userId, String systemOwner) throws IOException {
List<SysObjectiveQuestions> objectiveQuestionList1 = ObjectiveApi.selectRandomObjectiveSingle(systemOwner);
List<SysObjectiveQuestions> objectiveQuestionList2 = ObjectiveApi.selectRandomObjectiveMany(systemOwner);
List<SysObjectiveQuestions> objectiveQuestionList3 = ObjectiveApi.selectRandomObjectiveJudge(systemOwner);
List<SysObjectiveQuestions> objectiveQuestionList=new ArrayList<>();
List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>();
objectiveQuestionList.addAll(objectiveQuestionList1);
objectiveQuestionList.addAll(objectiveQuestionList2);
objectiveQuestionList.addAll(objectiveQuestionList3);
@ -202,7 +201,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
errorMapper.insert(stuError);
} else {
StuErrorWithBLOBs stuError = stuErrors.get(0);
if (stuError.getSingleIds()!=null) {
if (stuError.getSingleIds() != null) {
List<String> stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", "));
List<String> singleErrorIds = theoryTestDto.getSingleErrorIds();
@ -214,7 +213,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
} else {
stuError.setSingleIds(String.valueOf(theoryTestDto.getSingleErrorIds()));
}
if (stuError.getMultipleIds()!=null) {
if (stuError.getMultipleIds() != null) {
List<String> stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", "));
List<String> multipleErrorIds = theoryTestDto.getMultipleErrorIds();
@ -226,7 +225,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
} else {
stuError.setMultipleIds(String.valueOf(theoryTestDto.getMultipleErrorIds()));
}
if (stuError.getJudgeIds()!=null) {
if (stuError.getJudgeIds() != null) {
List<String> stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(", "));
List<String> judgeErrorIds = theoryTestDto.getJudgeErrorIds();
List<String> combinedList = new ArrayList<>(stringList);
@ -239,12 +238,12 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
}
errorMapper.updateByPrimaryKey(stuError);
}
UpdateTheoryRecord(theoryTestDto.getUserId(),theoryTestDto.getScore(),theoryTestDto.getExamDuration());
UpdateTheoryRecord(theoryTestDto.getUserId(), theoryTestDto.getScore(), theoryTestDto.getExamDuration());
return i;
}
@Override
public List<SysObjectiveQuestions> selectErrors(String userId,String schoolId,String systemOwner) throws IOException {
public List<SysObjectiveQuestions> selectErrors(String userId, String schoolId, String systemOwner) throws IOException {
StuErrorExample example = new StuErrorExample();
example.createCriteria().andUserIdEqualTo(userId);
List<StuErrorWithBLOBs> stuErrors = errorMapper.selectByExampleWithBLOBs(example);
@ -294,9 +293,9 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
List<String> stringList = Arrays.asList(error.getSingleIds().substring(1, stuErrors.get(0).getSingleIds().length() - 1).split(", "));
Set<String> set = new LinkedHashSet<>(stringList);
set.remove(objectiveQuestionId);
if(set.isEmpty()){
if (set.isEmpty()) {
error.setSingleIds(null);
}else {
} else {
List<String> list = new ArrayList<>(set);
error.setSingleIds(String.valueOf(list));
}
@ -304,25 +303,25 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
if (Constant.OBJECTIVE_TYPE_Many.equals(type)) {
Set<String> set = new LinkedHashSet<>(Arrays.asList(error.getMultipleIds().substring(1, error.getMultipleIds().length() - 1).split(", ")));
set.remove(objectiveQuestionId);
if(set.isEmpty()){
if (set.isEmpty()) {
error.setMultipleIds(null);
}else {
} else {
List<String> list = new ArrayList<>(set);
error.setMultipleIds(String.valueOf(list));
}
}
if(Constant.OBJECTIVE_TYPE_JUDGE.equals(type)){
if (Constant.OBJECTIVE_TYPE_JUDGE.equals(type)) {
Set<String> set = new LinkedHashSet<>(Arrays.asList(error.getJudgeIds().substring(1, error.getJudgeIds().length() - 1).split(", ")));
set.remove(objectiveQuestionId);
if(set.isEmpty()){
if (set.isEmpty()) {
error.setJudgeIds(null);
}else {
} else {
List<String> list = new ArrayList<>(set);
error.setJudgeIds(String.valueOf(list));
}
}
int i = errorMapper.updateByPrimaryKeyWithBLOBs(error);
return i==1;
return i == 1;
}
@Override
@ -337,7 +336,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
}
@Override
public List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size,String schoolId,String systemOwner) throws IOException {
public List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size, String schoolId, String systemOwner) throws IOException {
StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId);
String singleIds = theoryExam.getSingleIds();
ArrayList<String> idsList = new ArrayList<>();
@ -350,7 +349,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
idsList.addAll(multipleIdList);
idsList.addAll(judgeIdList);
ArrayList<String> answerList = new ArrayList<>();
if(theoryExam.getSingleStuAnswer()!=null){
if (theoryExam.getSingleStuAnswer() != null) {
String[] singleSplit = theoryExam.getSingleStuAnswer().substring(1, theoryExam.getSingleStuAnswer().length() - 1).split(",");
for (String str : singleSplit) {
if (str.equals("") || str.equals(" ")) {
@ -360,7 +359,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
}
}
}
if(theoryExam.getMultipleStuAnswer()!=null){
if (theoryExam.getMultipleStuAnswer() != null) {
String[] multipleSplit = theoryExam.getMultipleStuAnswer().substring(1, theoryExam.getMultipleStuAnswer().length() - 1).split(",");
for (String str : multipleSplit) {
if (str.equals("") || str.equals(" ")) {
@ -371,7 +370,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
}
}
}
if(theoryExam.getJudgeStuAnswer()!=null){
if (theoryExam.getJudgeStuAnswer() != null) {
String[] judgeSplit = theoryExam.getJudgeStuAnswer().substring(1, theoryExam.getJudgeStuAnswer().length() - 1).split(",");
for (String str : judgeSplit) {
if (str.equals("") || str.equals(" ")) {
@ -381,17 +380,17 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
}
}
}
List<StuTheoryExamDetailDto> detailDtos=new ArrayList<>();
if(answerList.size()==0){
List<StuTheoryExamDetailDto> detailDtos = new ArrayList<>();
if (answerList.size() == 0) {
return null;
}
for (int i = 0; i < answerList.size(); i++) {
if(answerList.get(i)==null){
answerList.set(i,"空");
if (answerList.get(i) == null) {
answerList.set(i, "空");
}
}
for (Integer i = (index-1)*size; i < (index-1)*size+size; i++) {
for (Integer i = (index - 1) * size; i < (index - 1) * size + size; i++) {
StuTheoryExamDetailDto detailDto = new StuTheoryExamDetailDto();
String objectiveQuestionId = idsList.get(i);
String stuAnswer = answerList.get(i).trim();
@ -399,22 +398,22 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
BigDecimal score = objectiveQuestion.getScore();
String content = objectiveQuestion.getContent();
String answer = objectiveQuestion.getAnswer();
if(stuAnswer.equals("true")){
stuAnswer="对";
if (stuAnswer.equals("true")) {
stuAnswer = "对";
}
if(stuAnswer.equals("false")){
stuAnswer="错";
if (stuAnswer.equals("false")) {
stuAnswer = "错";
}
if(answer.replaceAll(",","").equals(stuAnswer)){
if (answer.replaceAll(",", "").equals(stuAnswer)) {
detailDto.setScore(String.valueOf(score));
detailDto.setStatus("正确");
}else {
} else {
detailDto.setScore("0");
detailDto.setStatus("错误");
}
detailDto.setContent(content);
detailDto.setMychoice(stuAnswer);
detailDto.setAnswer(answer.replaceAll(",",""));
detailDto.setAnswer(answer.replaceAll(",", ""));
detailDtos.add(detailDto);
}
return detailDtos;
@ -430,7 +429,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
return null;
} else { //根据考试时间排序 查询最近的一条
StuTheoryExamWithBLOBs stuTheoryExam = stuTheoryExams.get(0);
if(stuTheoryExam.getAnswered()){
if (stuTheoryExam.getAnswered()) {
return null;
}
Date currentTime = new Date();

@ -180,7 +180,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
TeaTrainingDto newData = new TeaTrainingDto();
BeanUtils.copyProperties(stuTrainingWithBLOB, newData);
if (sysCourseChapter != null) {
newData.setTaskModule(sysCourseChapter.getThreeId());
newData.setTaskModule(sysCourseChapter.getThreeName());
}
if (StringUtils.isNotBlank(stuTrainingWithBLOB.getReportId())) {
String reportId = stuTrainingWithBLOB.getReportId();

Loading…
Cancel
Save