qirong
2023-06-20 983a2d36e9d3ca4ff2da89bbaca687fc55e92610
随机试卷
17个文件已修改
1个文件已添加
12183 ■■■■■ 已修改文件
log/xzs.20230619.log 11886 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log/xzs.20230620.log 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/controller/admin/ExamPaperAnswerController.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/repository/QuestionMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/repository/SubjectMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/ExamPaperAnswerService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/QuestionService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/SubjectService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/SubjectServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExamPaperAnswerMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QuestionMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/SubjectMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log/xzs.20230619.log
Diff too large
log/xzs.20230620.log
New file
@@ -0,0 +1,75 @@
2023-06-20 09:12:57.126  INFO 6060 --- [restartedMain] com.mindskip.xzs.XzsApplication          : Starting XzsApplication on DESKTOP-7A2KHS1 with PID 6060 (E:\ycll\qyksxt\target\classes started by qirong in E:\ycll\qyksxt)
2023-06-20 09:12:57.132  INFO 6060 --- [restartedMain] com.mindskip.xzs.XzsApplication          : The following profiles are active: dev
2023-06-20 09:12:57.266  INFO 6060 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-06-20 09:12:57.266  INFO 6060 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-06-20 09:13:02.915  INFO 6060 --- [restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b085affb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-06-20 09:13:03.603  WARN 6060 --- [restartedMain] io.undertow.websockets.jsr               : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2023-06-20 09:13:03.672  INFO 6060 --- [restartedMain] io.undertow.servlet                      : Initializing Spring embedded WebApplicationContext
2023-06-20 09:13:03.672  INFO 6060 --- [restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 6406 ms
2023-06-20 09:13:06.270  INFO 6060 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-06-20 09:13:06.734  INFO 6060 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@78473ac7, org.springframework.security.web.context.SecurityContextPersistenceFilter@3e38d036, org.springframework.security.web.header.HeaderWriterFilter@132ee450, org.springframework.web.filter.CorsFilter@1a86a45a, org.springframework.security.web.authentication.logout.LogoutFilter@4a359a2, com.mindskip.xzs.configuration.spring.security.RestLoginAuthenticationFilter@d9d872d, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@233fcca0, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@532967a1, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@511a31e, org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter@3f209db8, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4f029ed6, org.springframework.security.web.session.SessionManagementFilter@5451993e, org.springframework.security.web.access.ExceptionTranslationFilter@13c80181, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@12e7b6c1]
2023-06-20 09:13:06.774  INFO 6060 --- [restartedMain] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2023-06-20 09:13:07.463  INFO 6060 --- [restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2023-06-20 09:13:07.502  INFO 6060 --- [restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2023-06-20 09:13:07.564  INFO 6060 --- [restartedMain] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2023-06-20 09:13:07.810  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: indexUsingPOST_1
2023-06-20 09:13:07.814  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: taskUsingPOST_1
2023-06-20 09:13:07.853  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: updateUsingPOST_1
2023-06-20 09:13:07.882  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: listUsingPOST_1
2023-06-20 09:13:07.897  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_1
2023-06-20 09:13:07.903  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_1
2023-06-20 09:13:07.947  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: editUsingPOST_1
2023-06-20 09:13:07.961  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_2
2023-06-20 09:13:07.988  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: answerSubmitUsingPOST_1
2023-06-20 09:13:07.994  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_3
2023-06-20 09:13:07.996  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: readUsingPOST_1
2023-06-20 09:13:08.010  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_4
2023-06-20 09:13:08.014  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_2
2023-06-20 09:13:08.020  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_5
2023-06-20 09:13:08.024  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_3
2023-06-20 09:13:08.028  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: deleteUsingPOST_1
2023-06-20 09:13:08.044  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: editUsingPOST_2
2023-06-20 09:13:08.058  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_6
2023-06-20 09:13:08.060  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_4
2023-06-20 09:13:08.077  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_7
2023-06-20 09:13:08.091  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_8
2023-06-20 09:13:08.097  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_5
2023-06-20 09:13:08.103  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: deleteUsingPOST_2
2023-06-20 09:13:08.105  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: editUsingPOST_3
2023-06-20 09:13:08.145  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_9
2023-06-20 09:13:08.149  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_6
2023-06-20 09:13:08.153  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: deleteUsingPOST_3
2023-06-20 09:13:08.157  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: editUsingPOST_4
2023-06-20 09:13:08.165  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_10
2023-06-20 09:13:08.169  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_7
2023-06-20 09:13:08.176  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingGET_1
2023-06-20 09:13:08.177  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingHEAD_1
2023-06-20 09:13:08.178  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingPOST_1
2023-06-20 09:13:08.179  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingPUT_1
2023-06-20 09:13:08.180  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingPATCH_1
2023-06-20 09:13:08.181  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingDELETE_1
2023-06-20 09:13:08.182  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingOPTIONS_1
2023-06-20 09:13:08.183  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: questionUploadAndReadExcelUsingTRACE_1
2023-06-20 09:13:08.198  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: deleteUsingPOST_4
2023-06-20 09:13:08.207  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: editUsingPOST_5
2023-06-20 09:13:08.226  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: pageListUsingPOST_11
2023-06-20 09:13:08.228  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: selectUsingPOST_8
2023-06-20 09:13:08.235  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: updateUsingPOST_2
2023-06-20 09:13:08.244  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: currentUsingPOST_1
2023-06-20 09:13:08.262  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: readUsingPOST_2
2023-06-20 09:13:08.273  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: updateUsingPOST_3
2023-06-20 09:13:08.276  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: currentUsingPOST_2
2023-06-20 09:13:08.277  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: logUsingPOST_1
2023-06-20 09:13:08.281  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: messagePageListUsingPOST_1
2023-06-20 09:13:08.282  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: readUsingPOST_3
2023-06-20 09:13:08.286  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: registerUsingPOST_1
2023-06-20 09:13:08.287  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: unReadCountUsingPOST_1
2023-06-20 09:13:08.291  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: updateUsingPOST_4
2023-06-20 09:13:08.294  INFO 6060 --- [restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: addUsingPOST_1
2023-06-20 09:13:08.404  INFO 6060 --- [restartedMain] org.xnio                                 : XNIO version 3.3.8.Final
2023-06-20 09:13:08.425  INFO 6060 --- [restartedMain] org.xnio.nio                             : XNIO NIO Implementation Version 3.3.8.Final
2023-06-20 09:13:08.548  INFO 6060 --- [restartedMain] o.s.b.w.e.u.UndertowServletWebServer     : Undertow started on port(s) 8000 (http) with context path ''
2023-06-20 09:13:08.554  INFO 6060 --- [restartedMain] com.mindskip.xzs.XzsApplication          : Started XzsApplication in 12.733 seconds (JVM running for 21.057)
2023-06-20 09:13:38.949  INFO 6060 --- [XNIO-1 task-1] io.undertow.servlet                      : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-06-20 09:13:38.950  INFO 6060 --- [XNIO-1 task-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-06-20 09:13:38.974  INFO 6060 --- [XNIO-1 task-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 24 ms
src/main/java/com/mindskip/xzs/controller/admin/ExamPaperAnswerController.java
@@ -3,6 +3,7 @@
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.ExamPaperAnswer;
import com.mindskip.xzs.domain.ExamPaperSubject;
import com.mindskip.xzs.domain.Subject;
import com.mindskip.xzs.domain.User;
import com.mindskip.xzs.service.*;
@@ -24,12 +25,14 @@
    private final ExamPaperAnswerService examPaperAnswerService;
    private final SubjectService subjectService;
    private final UserService userService;
    private final ExamPaperSubjectService examPaperSubjectService;
    @Autowired
    public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, SubjectService subjectService, UserService userService) {
    public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, SubjectService subjectService, UserService userService, ExamPaperSubjectService examPaperSubjectService) {
        this.examPaperAnswerService = examPaperAnswerService;
        this.subjectService = subjectService;
        this.userService = userService;
        this.examPaperSubjectService = examPaperSubjectService;
    }
@@ -43,12 +46,20 @@
            if (user == null) {
                return null;
            }
            Subject subject = subjectService.selectById(vm.getSubjectId());
//            Subject subject = subjectService.selectById(vm.getSubjectId());
            ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(vm.getId());
            Integer[] ids = examPaperSubjectService.getByExamPaperId(examPaperAnswer.getExamPaperId())
                    .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new);
            String name = "";
            if(ids.length>0){
                name = subjectService.selectByIds(ids)
                        .stream().map(Subject::getName).collect(Collectors.joining(","));
            }
            vm.setDoTime(ExamUtil.secondToVM(e.getDoTime()));
            vm.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore()));
            vm.setUserScore(ExamUtil.scoreToVM(e.getUserScore()));
            vm.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore()));
            vm.setSubjectName(subject.getName());
            vm.setSubjectName(name);
            vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            vm.setUserName(user.getUserName());
src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java
@@ -8,6 +8,7 @@
import com.mindskip.xzs.event.UserEvent;
import com.mindskip.xzs.service.ExamPaperAnswerService;
import com.mindskip.xzs.service.ExamPaperService;
import com.mindskip.xzs.service.ExamPaperSubjectService;
import com.mindskip.xzs.service.SubjectService;
import com.mindskip.xzs.utility.DateTimeUtil;
import com.mindskip.xzs.utility.ExamUtil;
@@ -24,6 +25,7 @@
import javax.validation.Valid;
import java.util.Date;
import java.util.stream.Collectors;
@RestController("StudentExamPaperAnswerController")
@RequestMapping(value = "/api/student/exampaper/answer")
@@ -33,13 +35,15 @@
    private final ExamPaperService examPaperService;
    private final SubjectService subjectService;
    private final ApplicationEventPublisher eventPublisher;
    private final ExamPaperSubjectService examPaperSubjectService;
    @Autowired
    public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher) {
    public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher, ExamPaperSubjectService examPaperSubjectService) {
        this.examPaperAnswerService = examPaperAnswerService;
        this.examPaperService = examPaperService;
        this.subjectService = subjectService;
        this.eventPublisher = eventPublisher;
        this.examPaperSubjectService = examPaperSubjectService;
    }
@@ -49,12 +53,19 @@
        PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model);
        PageInfo<ExamPaperAnswerPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
            ExamPaperAnswerPageResponseVM vm = modelMapper.map(e, ExamPaperAnswerPageResponseVM.class);
            Subject subject = subjectService.selectById(vm.getSubjectId());
            ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(vm.getId());
            Integer[] ids = examPaperSubjectService.getByExamPaperId(examPaperAnswer.getExamPaperId())
                    .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new);
            String name = "";
            if(ids.length>0){
                name = subjectService.selectByIds(ids)
                        .stream().map(Subject::getName).collect(Collectors.joining(","));
            }
            vm.setDoTime(ExamUtil.secondToVM(e.getDoTime()));
            vm.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore()));
            vm.setUserScore(ExamUtil.scoreToVM(e.getUserScore()));
            vm.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore()));
            vm.setSubjectName(subject.getName());
            vm.setSubjectName(name);
            vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            return vm;
        });
src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java
@@ -21,4 +21,6 @@
    ExamPaperAnswer getByPidUid(@Param("pid") Integer paperId, @Param("uid") Integer uid);
    List<ExamPaperAnswer> adminPage(com.mindskip.xzs.viewmodel.admin.paper.ExamPaperAnswerPageRequestVM requestVM);
    ExamPaperAnswer getById(Integer id);
}
src/main/java/com/mindskip/xzs/repository/QuestionMapper.java
@@ -19,4 +19,6 @@
    Integer selectAllCount();
    List<KeyValue> selectCountByDate(@Param("startTime") Date startTime,@Param("endTime") Date endTime);
    List<Question> getAll();
}
src/main/java/com/mindskip/xzs/repository/SubjectMapper.java
@@ -19,4 +19,6 @@
    Subject getName(String name);
    List<Subject> getNames(@Param("names") String[] names);
    List<Subject> selectByIds(@Param("ids") Integer[] ids);
}
src/main/java/com/mindskip/xzs/service/ExamPaperAnswerService.java
@@ -50,4 +50,6 @@
    List<Integer> selectMothCount();
    PageInfo<ExamPaperAnswer> adminPage(com.mindskip.xzs.viewmodel.admin.paper.ExamPaperAnswerPageRequestVM requestVM);
    ExamPaperAnswer getById(Integer id);
}
src/main/java/com/mindskip/xzs/service/QuestionService.java
@@ -4,6 +4,7 @@
import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM;
import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -24,4 +25,8 @@
    List<Integer> selectMothCount();
    Integer remove(Integer id);
    List<Question> getAll();
    List<Question> selectByIds(@Param("ids") List<Integer> ids);
}
src/main/java/com/mindskip/xzs/service/SubjectService.java
@@ -3,6 +3,7 @@
import com.mindskip.xzs.domain.Subject;
import com.mindskip.xzs.viewmodel.admin.education.SubjectPageRequestVM;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -17,4 +18,6 @@
    PageInfo<Subject> page(SubjectPageRequestVM requestVM);
    List<Subject> getNames(String[] names);
    List<Subject> selectByIds(Integer[] ids);
}
src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
@@ -275,4 +275,9 @@
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "user_score desc").doSelectPageInfo(() ->
                examPaperAnswerMapper.adminPage(requestVM));
    }
    @Override
    public ExamPaperAnswer getById(Integer id) {
        return examPaperAnswerMapper.getById(id);
    }
}
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -3,6 +3,7 @@
import com.mindskip.xzs.domain.*;
import com.mindskip.xzs.domain.TextContent;
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
import com.mindskip.xzs.domain.exam.ExamPaperQuestionItemObject;
import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject;
import com.mindskip.xzs.domain.other.KeyValue;
@@ -31,9 +32,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@@ -48,9 +47,10 @@
    private final SubjectService subjectService;
    private final ExamPaperDepartmentService examPaperDepartmentService;
    private final ExamPaperSubjectService examPaperSubjectService;
    private final QuestionSubjectService questionSubjectService;
    @Autowired
    public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService) {
    public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService) {
        super(examPaperMapper);
        this.examPaperMapper = examPaperMapper;
        this.questionMapper = questionMapper;
@@ -59,6 +59,7 @@
        this.subjectService = subjectService;
        this.examPaperDepartmentService = examPaperDepartmentService;
        this.examPaperSubjectService = examPaperSubjectService;
        this.questionSubjectService = questionSubjectService;
    }
@@ -86,6 +87,59 @@
    public ExamPaper savePaperFromVM(ExamPaperEditRequestVM examPaperEditRequestVM, User user) {
        ActionEnum actionEnum = (examPaperEditRequestVM.getId() == null) ? ActionEnum.ADD : ActionEnum.UPDATE;
        Date now = new Date();
        if (examPaperEditRequestVM.getSubjectSource() != null) {
//            Map<Integer, Integer> questionList = questionService.getAll().stream().collect(Collectors.toMap(Question::getId, Question::getScore));
            Map<Integer, Integer> subjectSource = examPaperEditRequestVM.getSubjectSource();
            //总数量
            Integer sum = subjectSource.values().stream().mapToInt(Integer::intValue).sum();
            Map<Integer, Integer> map = new HashMap<>();
            Integer avg = 0;
            for (Integer key : subjectSource.keySet()) {    // key:数量
                //该标签对应的分数   多选:3 判断:3 单选:4
                Integer source = examPaperEditRequestVM.getAggregateSource() * subjectSource.get(key) / sum;
                // 多选和判断数量
                Integer multipleNumber = key * 3 / 10;
                //多选和判断分数
                Integer multipleSource = source * 3 / 10;
                List<Integer> questions = questionSubjectService.getQuestion(key)
                        .stream().map(QuestionSubject::getQuestionId).collect(Collectors.toList());
                List<Question> list = questionService.selectByIds(questions);
                Map<Integer, Integer> multiple = new HashMap<>();
                //多选
                Map<Integer, Integer> multipleMap = list.stream()
                        .filter(e -> e.getQuestionType().equals(QuestionTypeEnum.MultipleChoice.getCode()))
                        .collect(Collectors.toMap(Question::getId, Question::getScore));
                selectRandomScores(multiple, multipleMap, multipleNumber, multipleSource);
                //判断
                Map<Integer, Integer> judgmentMap = list.stream()
                        .filter(e -> e.getQuestionType().equals(QuestionTypeEnum.TrueFalse.getCode()))
                        .collect(Collectors.toMap(Question::getId, Question::getScore));
                selectRandomScores(multiple, judgmentMap, multipleNumber, multipleSource);
                //单选数量
                Integer radioNumber = key - (2 * multipleNumber);
                //单选分数
                Integer radioSource = source - (2 * multipleSource);
                //单选
                Map<Integer, Integer> radioMap = list.stream()
                        .filter(e -> e.getQuestionType().equals(QuestionTypeEnum.SingleChoice.getCode()))
                        .collect(Collectors.toMap(Question::getId, Question::getScore));
                selectRandomScores(multiple, radioMap, radioNumber, radioSource);
                ExamPaperTitleItemObject examPaperTitleItemObject = new ExamPaperTitleItemObject();
                examPaperTitleItemObject.setName("测试001");
                Integer order = 0;
                List<ExamPaperQuestionItemObject> examPaperQuestionItemObjectList = new ArrayList<>();
                for (Integer k : multiple.keySet()) {
                    ExamPaperQuestionItemObject examPaperQuestionItemObject = new ExamPaperQuestionItemObject();
                    examPaperQuestionItemObject.setId(k);
                    examPaperQuestionItemObject.setItemOrder(order++);
                    examPaperQuestionItemObjectList.add(examPaperQuestionItemObject);
                }
                examPaperTitleItemObject.setQuestionItems(examPaperQuestionItemObjectList);
            }
        }
        List<ExamPaperTitleItemVM> titleItemsVM = examPaperEditRequestVM.getTitleItems();
        List<ExamPaperTitleItemObject> frameTextContentList = frameTextContentFromVM(titleItemsVM);
        String frameTextContentStr = JsonUtil.toJsonStr(frameTextContentList);
@@ -114,8 +168,8 @@
            examPaperDepartmentService.removeByExamPaperId(examPaper.getId());
            examPaperSubjectService.removeByExamPaperId(examPaper.getId());
        }
        addExamPaperDepartment(examPaperEditRequestVM,examPaper);
        addExamPaperSubject(examPaperEditRequestVM,examPaper);
        addExamPaperDepartment(examPaperEditRequestVM, examPaper);
        addExamPaperSubject(examPaperEditRequestVM, examPaper);
        return examPaper;
    }
@@ -219,8 +273,8 @@
        }).collect(Collectors.toList());
    }
    private void addExamPaperDepartment(ExamPaperEditRequestVM examPaperEditRequestVM, ExamPaper examPaper){
        List<ExamPaperDepartment> list = Arrays.asList(examPaperEditRequestVM.getDepartmentIds()).stream().map(e->{
    private void addExamPaperDepartment(ExamPaperEditRequestVM examPaperEditRequestVM, ExamPaper examPaper) {
        List<ExamPaperDepartment> list = Arrays.asList(examPaperEditRequestVM.getDepartmentIds()).stream().map(e -> {
            ExamPaperDepartment examPaperDepartment = new ExamPaperDepartment();
            examPaperDepartment.setExamPaperId(examPaper.getId());
            examPaperDepartment.setDepartmentId(e);
@@ -230,8 +284,8 @@
        examPaperDepartmentService.saves(list);
    }
    private void addExamPaperSubject(ExamPaperEditRequestVM examPaperEditRequestVM, ExamPaper examPaper){
        List<ExamPaperSubject> subjectList = Arrays.asList(examPaperEditRequestVM.getSubjectId()).stream().map(e->{
    private void addExamPaperSubject(ExamPaperEditRequestVM examPaperEditRequestVM, ExamPaper examPaper) {
        List<ExamPaperSubject> subjectList = Arrays.asList(examPaperEditRequestVM.getSubjectId()).stream().map(e -> {
            ExamPaperSubject examPaperSubject = new ExamPaperSubject();
            examPaperSubject.setSubjectId(e);
            examPaperSubject.setExamPaperId(examPaper.getId());
@@ -240,4 +294,40 @@
        }).collect(Collectors.toList());
        examPaperSubjectService.saves(subjectList);
    }
    public static void selectRandomScores(Map<Integer, Integer> result, Map<Integer, Integer> scoresMap, int quantity, int totalScore) {
//        Map<Integer, Integer> selectedScoresMap = new HashMap<>();
        if (quantity <= 0 || totalScore <= 0 || scoresMap.isEmpty()) {
            return; // 返回空Map
        }
        List<Integer> keys = new ArrayList<>(scoresMap.keySet());
        List<Integer> values = new ArrayList<>(scoresMap.values());
        Random random = new Random();
        int remainingQuantity = quantity;
        int remainingScore = totalScore;
        for (int i = 0; i < quantity - 1; i++) {
            int index = random.nextInt(values.size());
            int score = values.get(index);
            if (score <= remainingScore) {
                result.put(keys.get(index), score);
                remainingQuantity--;
                remainingScore -= score;
                values.remove(index);
                keys.remove(index);
            }
        }
        if (!values.isEmpty()) {
            int index = random.nextInt(values.size());
            int score = values.get(index);
            result.put(keys.get(index), remainingScore); // 最后一个分数为剩余的分数
        }
    }
}
src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
@@ -239,5 +239,15 @@
        return questionSubjectService.removes(list.toArray(new Integer[list.size()]));
    }
    @Override
    public List<Question> getAll() {
        return questionMapper.getAll();
    }
    @Override
    public List<Question> selectByIds(List<Integer> ids) {
        return questionMapper.selectByIds(ids);
    }
}
src/main/java/com/mindskip/xzs/service/impl/SubjectServiceImpl.java
@@ -59,4 +59,9 @@
        return subjectMapper.getNames(names);
    }
    @Override
    public List<Subject> selectByIds(Integer[] ids) {
        return subjectMapper.selectByIds(ids);
    }
}
src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java
@@ -10,6 +10,7 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Map;
public class ExamPaperEditRequestVM {
@@ -35,6 +36,11 @@
    //部门ids
    private Integer[] departmentIds;
    private Map<Integer,Integer> subjectSource;
    private Integer aggregateSource;
    public Integer getId() {
@@ -117,4 +123,19 @@
        this.departmentIds = departmentIds;
    }
    public Map<Integer, Integer> getSubjectSource() {
        return subjectSource;
    }
    public void setSubjectSource(Map<Integer, Integer> subjectSource) {
        this.subjectSource = subjectSource;
    }
    public Integer getAggregateSource() {
        return aggregateSource;
    }
    public void setAggregateSource(Integer aggregateSource) {
        this.aggregateSource = aggregateSource;
    }
}
src/main/resources/mapper/ExamPaperAnswerMapper.xml
@@ -265,5 +265,11 @@
      </if>
    </where>
  </select>
  <select id="getById" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM t_exam_paper_answer
    where id = #{id}
  </select>
</mapper>
src/main/resources/mapper/QuestionMapper.xml
@@ -234,4 +234,8 @@
        GROUP BY create_time
    </select>
  <select id="getAll"  resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List"/>
        from t_question where  deleted=0
  </select>
</mapper>
src/main/resources/mapper/SubjectMapper.xml
@@ -156,4 +156,15 @@
  </select>
  <select id="selectByIds" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_subject
    where id in
    <foreach item="id" collection="ids" open="(" separator=","
             close=")">
      #{id}
    </foreach>
  </select>
</mapper>