diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java index 05f9ca8..55615ed 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java +++ b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java @@ -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"; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/TokenProvider.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/TokenProvider.java index d8e6453..9af1387 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/config/security/TokenProvider.java +++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/TokenProvider.java @@ -20,6 +20,7 @@ import java.util.List; @Component public class TokenProvider { + private final static String SECRET = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAghgsx+OLLThi7c+/HgCaRla8n+/QLHt++uscoK22dMeaVa3WJvRb5C5qtHGzj9V74pI96JpxdWWCN3Zr1QtanQIDAQABAkB2fWRUD1jVMBVS+rPctLnPNPMKTRdzXGv0SC5D3tRfGZqdcfsmZg8hzBVndHxngmwZS73d+hPjofcdefDDnXq1AiEAz/r1AMF7fweN70mbKgBJuTja37puJMsH2Szwrvb5jlcCIQCgIaLZ5d9J7OomL0NwH8ghba/xgBEpKzErfGbFnTfeKwIgc8ptczFFV1DWZb2eJIEqinOr79l0jwl2YiQSD+cyw1sCIHqxCvv1Wx5jPgy/zeYNE+Q5DMP3Ii7u/x+Yk436JiI9AiEAio84hFm44YTUuV7YCYsbyvnCn/vtcAaqZlczbeHlP1I="; private final static long EXP_TIME = 1000 * 60 * 60 * 4; diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java index 0dbf14d..d6daf4f 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java @@ -44,7 +44,7 @@ public class ExerciseExperimentalTraining { @ApiOperation("**获取案例题基础信息") @AnonymousAccess public ResultEntity getCaseInfo(@RequestParam String chapterId) { - List sysCaseQuestions= null; + List sysCaseQuestions = null; try { sysCaseQuestions = CaseApi.selectCaseByChapterId(chapterId); } catch (IOException e) { @@ -77,10 +77,6 @@ public class ExerciseExperimentalTraining { } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据根据案例题IDS批量查询失败"); } - for (int i = 0; i < stepList.size(); i++) { - stepList.get(0).setAnswer(""); - stepList.get(0).setAnswerOriginal(""); - } return new ResultEntity<>(HttpStatus.OK, "获取案例题基础信息查询成功", stepList); } @@ -108,7 +104,7 @@ public class ExerciseExperimentalTraining { @AnonymousAccess @ApiOperation("实训演练页面查询") @PostMapping("getCourseChapter") - public ResultEntity> getIndexTheoryTest(@RequestParam String userId,@RequestParam String systemOwner) { + public ResultEntity> getIndexTheoryTest(@RequestParam String userId, @RequestParam String systemOwner) { // List sysCourseList = sysCourseMapper.getBySchoolId(); List sysCourseList = null; try { @@ -116,9 +112,11 @@ public class ExerciseExperimentalTraining { } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心获取内置二级目录失败"); } + if (sysCourseList.isEmpty()) { + return null; + } List dtoList = new ArrayList<>(); - // 批量查询所有章节 List courseIds = sysCourseList.stream() .map(SysTwoCatalog::getTwoId) @@ -129,25 +127,36 @@ public class ExerciseExperimentalTraining { } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据课程IDList查询章节集合失败"); } + if (sysCourseChapters.isEmpty()) { + //三级为空返回二级的信息 + for (SysTwoCatalog sysTwoCatalog : sysCourseList) { + SysCourseDto newDto = new SysCourseDto(); + newDto.setCourseId(sysTwoCatalog.getTwoId()); + newDto.setSequence(sysTwoCatalog.getSort()); + newDto.setCourseName(sysTwoCatalog.getTwoName()); + newDto.setSchoolId(sysTwoCatalog.getCreator()); + dtoList.add(newDto); + return new ResultEntity>(dtoList); + } + } // 批量查询所有案例题步骤 SysCaseQuestionStepExample stepExample = new SysCaseQuestionStepExample(); stepExample.setOrderByClause("sort"); - List sysCaseQuestionSteps= null; + List sysCaseQuestionSteps = null; try { sysCaseQuestionSteps = CaseApi.selectAllStepBySystemOwner(systemOwner); } catch (IOException e) { e.printStackTrace(); } - Map> caseStepsMap = sysCaseQuestionSteps.stream() .collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getCaseId)); // 批量查询案例题ID Map> caseIdMap = null; try { - caseIdMap = CaseApi.getMapChapterIdAndCaseIdsByCourseIdAndChapterId(sysCourseChapters,systemOwner); + caseIdMap = CaseApi.getMapChapterIdAndCaseIdsByCourseIdAndChapterId(sysCourseChapters, systemOwner); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心查询失败"); } @@ -156,7 +165,7 @@ public class ExerciseExperimentalTraining { List progressByChapterIds = stuTrainingMapper.getByUserIdAndChapterIds(userId, sysCourseChapters.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList())); Map progressMap = progressByChapterIds.stream() - .collect(Collectors.toMap(StuTraining::getChapterId,stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO), (p1, p2) -> p1)); + .collect(Collectors.toMap(StuTraining::getChapterId, stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO), (p1, p2) -> p1)); // 构建结果列表 for (SysTwoCatalog sysCourse : sysCourseList) { @@ -182,12 +191,12 @@ public class ExerciseExperimentalTraining { // 获取案例题步骤信息 List caseIds = caseIdMap.get(chapter.getThreeId()); if (caseIds != null && !caseIds.isEmpty()) { - Listlist =new ArrayList<>(); + List list = new ArrayList<>(); for (String caseId : caseIds) { List steps = caseStepsMap.get(caseId); if (steps != null && !steps.isEmpty()) { for (TestTestSysCaseQuestionStepWithBLOBs step : steps) { - AAA aaa =new AAA(); + AAA aaa = new AAA(); aaa.setStepID(step.getCaseStepId()); aaa.setTitle(step.getTitle()); aaa.setSort(step.getSort()); @@ -240,9 +249,9 @@ public class ExerciseExperimentalTraining { } catch (IOException e) { return false; } - if(resourceDataList.size()>0){ + if (resourceDataList.size() > 0) { return true; - }else { + } else { return false; } } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java index b15f378..ac0f0f1 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java @@ -1,7 +1,6 @@ package com.sztzjy.financial_bigdata.controller.stu; import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; -import com.sztzjy.financial_bigdata.config.Constant; import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.entity.resource_entity.SysTwoCatalog; import com.sztzjy.financial_bigdata.entity.stu_dto.AllModuleProgressDto; @@ -172,13 +171,16 @@ public class StuIndexController { @AnonymousAccess @ApiOperation("设置资源学习人数和学习时长") @PostMapping("setResourceNum") - public void setResourceNum(@RequestParam String schoolId, @ApiParam("学习时长,单位分钟") @RequestParam Integer time) { + public void setResourceNum(@RequestParam String schoolId, + @ApiParam("学习时长,单位分钟") @RequestParam Integer time, + @RequestParam String systemOwner) { SysResourceLearning sysResourceLearning = sysResourceLearningMapper.selectByPrimaryKey(schoolId); if (sysResourceLearning == null) { //第一次 新增一条 SysResourceLearning newData = new SysResourceLearning(); newData.setSchoolId(schoolId); newData.setLearningTime(time); newData.setLearningNum(1); + newData.setSystemOwner(systemOwner); sysResourceLearningMapper.insert(newData); } else { if (sysResourceLearning.getLearningNum() == null) { diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java index 701e204..36adcb0 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java @@ -5,10 +5,12 @@ import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.entity.StuTrainingExample; import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs; import com.sztzjy.financial_bigdata.entity.SysKnowledgeSummary; +import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample; import com.sztzjy.financial_bigdata.entity.resource_entity.TestSysKnowledgeSummary; import com.sztzjy.financial_bigdata.entity.stu_dto.ReceivingObject; import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper; import com.sztzjy.financial_bigdata.mapper.SysKnowledgeSummaryMapper; +import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper; import com.sztzjy.financial_bigdata.resourceCenterAPI.KnowledgeSummaryApi; import com.sztzjy.financial_bigdata.util.PdfUtil; import com.sztzjy.financial_bigdata.util.ResultEntity; diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java index 8e66e43..e4d8575 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java @@ -81,7 +81,7 @@ public class TeaGradeManageController { @ApiParam("系统名称") @RequestParam String systemOwner) { List teaExamManages = teaExamManageMapper.selectBySchoolIdAndSystemOwner(schoolId, systemOwner); - if (teaExamManages.isEmpty()) { + if (teaExamManages == null || teaExamManages.isEmpty()) { return null; } List teaExamManageCountDtos = new ArrayList<>(); @@ -574,8 +574,8 @@ public class TeaGradeManageController { for (int i = 0; i < twoCatalogs.size(); i++) { HashMap hashMap = new HashMap<>(); SysTwoCatalog sysTwoCatalog = twoCatalogs.get(i); - hashMap.put("course_id",sysTwoCatalog.getTwoId()); - hashMap.put("course_name",sysTwoCatalog.getTwoName()); + hashMap.put("course_id", sysTwoCatalog.getTwoId()); + hashMap.put("course_name", sysTwoCatalog.getTwoName()); list.add(hashMap); } } catch (IOException e) { @@ -610,7 +610,7 @@ public class TeaGradeManageController { @RequestParam(required = false) String classId, @ApiParam("学号/姓名搜索框") @RequestParam(required = false) String keyWord, @RequestParam String systemOwner) { - return new ResultEntity<>(iTeaGradeManageService.getTheoryInfo(index, size, schoolId, classId, keyWord,systemOwner)); + return new ResultEntity<>(iTeaGradeManageService.getTheoryInfo(index, size, schoolId, classId, keyWord, systemOwner)); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java index 90407e8..3a198c0 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java @@ -363,8 +363,12 @@ public class UserController { @AnonymousAccess @PostMapping("/selectAllClassNameBySchoolId") @ApiOperation("班级下拉框") - public ResultEntity>> selectAllClassNameBySchoolId(@RequestParam String schoolId) { - return new ResultEntity<>(classMapper.selectAllClassNameBySchoolId(schoolId)); + public ResultEntity>> selectAllClassNameBySchoolId(@RequestParam String schoolId,@RequestParam String systemOwner) { + StuUserExample example =new StuUserExample(); + example.createCriteria().andSchoolIdEqualTo(schoolId); + List list = stuUserMapper.selectByExample(example); + String schoolName = list.get(0).getSchoolName(); + return new ResultEntity<>(classMapper.selectAllClassNameBySchoolId(schoolName,systemOwner)); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java index 60da85c..dd7853c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java @@ -33,8 +33,9 @@ public interface StuClassMapper { int updateByPrimaryKey(StuClass record); - @Select("SELECT DISTINCT s.class_name, s.class_id FROM stu_class s, stu_userinfo u WHERE #{schoolId}= u.school_id;") - List> selectAllClassNameBySchoolId(@Param("schoolId")String schoolId); + @Select("SELECT class_name, class_id FROM stu_class WHERE school_name = #{schoolName} and system_owner =#{systemOwner}") + List> selectAllClassNameBySchoolId(@Param("schoolName")String schoolName, + @Param("systemOwner")String systemOwner); @Select("SELECT s.class_name FROM stu_class s, stu_userinfo u WHERE s.class_id = u.class_id and s.class_id = #{classId};") String selectClassNameByClassId(@Param("classId")String classId); diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java index cec3bbf..17611bf 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java @@ -67,4 +67,9 @@ public interface StuUserMapper { List selectByPrimaryKeys(@Param("userIds") List userIds); List selectTeaExamAndUserDtos(@Param("schoolId")String schoolId,@Param("keyWord") String keyWord, @Param("classId")String classId); + + List getByNameAndStudentID(@Param("schoolId")String schoolId, + @Param("keyWord") String keyWord, + @Param("classId")String classId, + @Param("systemOwner") String systemOwner); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java index 8901037..e8734da 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java @@ -323,10 +323,10 @@ public class CaseApi { * 单独接口 * 考试模式--成绩报告案例题questionOriginal所属章节,contentOriginal为考核点数量,Sort为序号 */ - public static List getGradeReportCase(List caseIdList, String schoolId, String systemOwner) throws IOException { + public static List getGradeReportCase(List 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); @@ -345,6 +345,9 @@ public class CaseApi { JSONObject object = HttpUtils.sendPost( selectAllStepBySystemOwner, requestBody); + if(object==null){ + return null; + } Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CourseAPI.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CourseAPI.java index c6b45e6..b5618b7 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CourseAPI.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CourseAPI.java @@ -169,6 +169,9 @@ public class CourseAPI { JSONObject object = HttpUtils.sendPost( urlWithParams, gson.toJson(courseIds), "application/json", null); + if(object==null){ + return null; + } Type listType = new TypeToken>() { }.getType(); List list = gson.fromJson(object.get("respString").toString(), listType); diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java index 018c660..ab49955 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java @@ -238,7 +238,7 @@ public class ObjectiveApi { *根据章节ID 随机获取十道内置题目 */ public static List selectRandomObjectiveByChapterId(String chapterId) throws IOException { - String requestBody = "threeId="+chapterId; + String requestBody = "chapterId="+chapterId; JSONObject object = HttpUtils.sendPost( selectRandomObjectiveByChapterId, requestBody); @@ -327,6 +327,9 @@ public class ObjectiveApi { JSONObject object = HttpUtils.sendPost( selectCountSingle, requestBody); + if(object==null){ + return 0; + } String respString = object.get("respString").toString(); return Integer.valueOf(respString); @@ -339,6 +342,9 @@ public class ObjectiveApi { JSONObject object = HttpUtils.sendPost( selectCountMany, requestBody); + if(object==null){ + return 0; + } String respString = object.get("respString").toString(); return Integer.valueOf(respString); @@ -351,6 +357,9 @@ public class ObjectiveApi { JSONObject object = HttpUtils.sendPost( selectCountJudge, requestBody); + if(object==null){ + return 0; + } String respString = object.get("respString").toString(); return Integer.valueOf(respString); diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java index 4a00c1c..a1f3da0 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java @@ -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 selectResource(String schoolId, String courseId,String systemOwner) throws IOException { - String requestBody="schoolId="+schoolId+"&twoId="+courseId+"&oneId="+systemOwner; + public static List 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>() {}.getType(); + Type listType = new TypeToken>() { + }.getType(); List resourceList = gson.fromJson(object.get("respString").toString(), listType); return resourceList; } @@ -63,15 +64,16 @@ public class ResourceCenterApi { * rsapi:根据章节查看资源文件列表 */ - public static List selectResourceByChapterId(String chapterId,String systemOwner) throws IOException { - String requestBody="threeId="+chapterId+"&oneId="+systemOwner; + public static List 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>() {}.getType(); + Type listType = new TypeToken>() { + }.getType(); List 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 getResourceTypeCount(String schoolId ,String systemOwner){ - String requestBody="schoolId="+schoolId+"&systemOwner="+systemOwner; + public static Map 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>() {}.getType(); - Map map = gson.fromJson(object.get("respString").toString(), listType); + Type listType = new TypeToken>() { + }.getType(); + Map 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); diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java index e3d37f1..8aba520 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java @@ -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 startTheoryTest(String userId,String systemOwner) throws IOException { + public List startTheoryTest(String userId, String systemOwner) throws IOException { StuTheoryExamExample example = new StuTheoryExamExample(); example.createCriteria().andUserIdEqualTo(userId); example.setOrderByClause("exam_time DESC"); List stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example); if (stuTheoryExams.isEmpty()) { //之前没有进行考试 - List objectiveQuestionList = GenerateTest(userId,systemOwner); - GenerateTheoryRecordFirst(userId); + List 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 objectiveQuestionList = GenerateTest(userId,systemOwner); + if (stuTheoryExam.getAnswered()) { + List objectiveQuestionList = GenerateTest(userId, systemOwner); return objectiveQuestionList; } if (stuTheoryExam.getExamTime().before(twoHoursAgo)) { //已超出两个小时 从新生成新试卷 - List objectiveQuestionList = GenerateTest(userId,systemOwner); + List 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 GenerateTest(String userId,String systemOwner) throws IOException { + public List GenerateTest(String userId, String systemOwner) throws IOException { List objectiveQuestionList1 = ObjectiveApi.selectRandomObjectiveSingle(systemOwner); List objectiveQuestionList2 = ObjectiveApi.selectRandomObjectiveMany(systemOwner); List objectiveQuestionList3 = ObjectiveApi.selectRandomObjectiveJudge(systemOwner); - List objectiveQuestionList=new ArrayList<>(); + List 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 stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", ")); List 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 stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", ")); List 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 stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(", ")); List judgeErrorIds = theoryTestDto.getJudgeErrorIds(); List combinedList = new ArrayList<>(stringList); @@ -237,14 +236,14 @@ public class TheoryTestServiceImpl implements ITheoryTestService { } else { stuError.setJudgeIds(String.valueOf(theoryTestDto.getJudgeErrorIds())); } - errorMapper.updateByPrimaryKey(stuError); + errorMapper.updateByPrimaryKeySelective(stuError); } - UpdateTheoryRecord(theoryTestDto.getUserId(),theoryTestDto.getScore(),theoryTestDto.getExamDuration()); + UpdateTheoryRecord(theoryTestDto.getUserId(), theoryTestDto.getScore(), theoryTestDto.getExamDuration()); return i; } @Override - public List selectErrors(String userId,String schoolId,String systemOwner) throws IOException { + public List selectErrors(String userId, String schoolId, String systemOwner) throws IOException { StuErrorExample example = new StuErrorExample(); example.createCriteria().andUserIdEqualTo(userId); List stuErrors = errorMapper.selectByExampleWithBLOBs(example); @@ -294,9 +293,9 @@ public class TheoryTestServiceImpl implements ITheoryTestService { List stringList = Arrays.asList(error.getSingleIds().substring(1, stuErrors.get(0).getSingleIds().length() - 1).split(", ")); Set set = new LinkedHashSet<>(stringList); set.remove(objectiveQuestionId); - if(set.isEmpty()){ + if (set.isEmpty()) { error.setSingleIds(null); - }else { + } else { List 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 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 list = new ArrayList<>(set); error.setMultipleIds(String.valueOf(list)); } } - if(Constant.OBJECTIVE_TYPE_JUDGE.equals(type)){ + if (Constant.OBJECTIVE_TYPE_JUDGE.equals(type)) { Set 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 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 getTheoryTestDetail(String theoryExamId, Integer index, Integer size,String schoolId,String systemOwner) throws IOException { + public List getTheoryTestDetail(String theoryExamId, Integer index, Integer size, String schoolId, String systemOwner) throws IOException { StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId); String singleIds = theoryExam.getSingleIds(); ArrayList idsList = new ArrayList<>(); @@ -350,7 +349,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { idsList.addAll(multipleIdList); idsList.addAll(judgeIdList); ArrayList 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 detailDtos=new ArrayList<>(); - if(answerList.size()==0){ + List 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(); diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java index c80eab0..4175c92 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java @@ -1,6 +1,7 @@ package com.sztzjy.financial_bigdata.service.tea; import com.sztzjy.financial_bigdata.entity.SysCaseQuestionStep; +import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs; import com.sztzjy.financial_bigdata.entity.stu_dto.StuCommitCaseDto; import java.io.IOException; @@ -15,7 +16,7 @@ public interface ITeaCaseStepService { Boolean deleteCaseStep(String caseStepId, String schoolId); - SysCaseQuestionStep selectCaseStepDetails(String caseStepId); + TestTestSysCaseQuestionStepWithBLOBs selectCaseStepDetails(String caseStepId) throws IOException; Boolean commitCase(StuCommitCaseDto commitCaseDto) throws IOException; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java index a6c71b5..bdef376 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java @@ -82,9 +82,9 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService { } @Override - public SysCaseQuestionStep selectCaseStepDetails(String caseStepId) { - SysCaseQuestionStep sysCaseQuestionStep = caseQuestionStepMapper.selectByPrimaryKey(caseStepId); - return sysCaseQuestionStep; + public TestTestSysCaseQuestionStepWithBLOBs selectCaseStepDetails(String caseStepId) throws IOException { + TestTestSysCaseQuestionStepWithBLOBs testTestSysCaseQuestionStepWithBLOBs = CaseApi.selectCaseStepDetails(caseStepId); + return testTestSysCaseQuestionStepWithBLOBs; } @Override @@ -93,8 +93,8 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService { StuTrainingStepRecordExample example = new StuTrainingStepRecordExample(); example.createCriteria().andUserIdEqualTo(commitCaseDto.getUserId()).andCaseStepIdEqualTo(commitCaseDto.getCaseStepId()); List stuTrainingStepRecords = trainingStepRecordMapper.selectByExample(example); - if(stuTrainingStepRecords==null){ //未答过该步骤题目 新增数据到stepRecord表中 - SysCaseQuestionStep dbCaseQuestionStep = selectCaseStepDetails(commitCaseDto.getCaseStepId()); + if(stuTrainingStepRecords.isEmpty()){ //未答过该步骤题目 新增数据到stepRecord表中 + TestTestSysCaseQuestionStepWithBLOBs dbCaseQuestionStep = selectCaseStepDetails(commitCaseDto.getCaseStepId()); StuTrainingStepRecord stepRecord = new StuTrainingStepRecord(); stepRecord.setRecordId(String.valueOf(UUID.randomUUID())); stepRecord.setUserId(commitCaseDto.getUserId()); @@ -128,7 +128,7 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService { stepRecord.setScore("0"); //再修改学生实训表中的部分参数 先获取学生实训表中的数据 StuTrainingWithBLOBs training = trainingMapper.selectByPrimaryKey(commitCaseDto.getStuTrainingId()); - //如果案例题学生的实验实训完成情况=0 则实训进度+1否则 实训进度不加 并累加案例题学生得分 修改实验实训完成状态 + //如果案例题学生的实验实训完成情况=0 则实训进度+1否则 实训进度不加 修改实验实训完成状态 if(training.getExpTrainingCompleteStatus()==null){ if(training.getProgress()==null){ training.setProgress(BigDecimal.ONE); @@ -139,8 +139,6 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService { } if(training.getCaseStuScore()==null){ training.setCaseStuScore(sysCaseQuestionStep.getScore()); - }else { - training.setCaseStuScore(training.getCaseStuScore().add(sysCaseQuestionStep.getScore())); } trainingMapper.updateByPrimaryKeyWithBLOBs(training); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java index fb8198a..0483b1d 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java @@ -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(); @@ -289,20 +289,9 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { private List getTeaTrainingInfoDTOS(String schoolId, String keyWord, String classId, String systemOwner) { - StuUserExample userExample = new StuUserExample(); - StuUserExample.Criteria criteria = userExample.createCriteria(); - criteria.andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4); - if (StringUtils.isNotBlank(classId)) { - criteria.andClassIdEqualTo(classId); - } - if (StringUtils.isNotBlank(keyWord)) { - userExample.or().andSchoolIdEqualTo(schoolId).andStudentIdEqualTo(keyWord); - userExample.or().andSchoolIdEqualTo(schoolId).andNameEqualTo(keyWord); - } + List stuUsers =userMapper.getByNameAndStudentID(schoolId,keyWord,classId,systemOwner); // 查询学生用户列表 - List stuUsers = userMapper.selectByExample(userExample); - if (stuUsers.isEmpty()) { return Collections.emptyList(); } diff --git a/src/main/resources/mapper/StuUserMapper.xml b/src/main/resources/mapper/StuUserMapper.xml index 18cf150..85d8d20 100644 --- a/src/main/resources/mapper/StuUserMapper.xml +++ b/src/main/resources/mapper/StuUserMapper.xml @@ -409,7 +409,8 @@ role_id,create_time,school_id,school_name,status) VALUES (#{student.userid}, #{student.name}, #{student.studentId}, #{student.classId}, #{student.username}, - #{student.password}, #{student.phone}, #{student.email},#{student.major},#{student.zyUserid},#{student.systemOnwer},#{student.roleId}, + #{student.password}, #{student.phone}, + #{student.email},#{student.major},#{student.zyUserid},#{student.systemOnwer},#{student.roleId}, #{student.createTime},#{student.schoolId},#{student.schoolName},#{student.status}) @@ -454,7 +455,7 @@ u.role_id = 4 AND u.school_id = #{schoolId} - AND (u.name = #{keyWord} OR u.student_id = #{keyWord}) + AND student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%') AND u.class_id = #{classId} @@ -476,5 +477,22 @@ )GROUP BY class_id ) AS subquery; + \ No newline at end of file