From 9f8b47147d29bb2bd540fdf64f33fb516b693b11 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 13 Feb 2023 14:36:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=89=8D=E7=AB=AF=E6=9C=89=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96orgId,=20=E8=80=83=E8=AF=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20230206-zhou.sql | 2 +- .../joylink/rtss/controller/LoginController.java | 1 + .../rtss/controller/org/OrgProjectController.java | 4 +++- .../rtss/services/org/OrgProjectService.java | 4 ++++ .../rtss/services/paper/PaperUserService.java | 3 ++- .../paper/PaperUserSubmitAnswerService.java | 15 ++++----------- .../club/joylink/rtss/services/ws/StompTest.java | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/sql/20230206-zhou.sql b/sql/20230206-zhou.sql index bee8a3b4a..d551660bd 100644 --- a/sql/20230206-zhou.sql +++ b/sql/20230206-zhou.sql @@ -4,7 +4,7 @@ ALTER TABLE `rts_paper_user_question` ALTER TABLE `rts_paper_user_question` - ADD COLUMN `sub_type` bigint not NULL COMMENT '规则类型:理论题(1-单选题,2-多选题,3-判断题);实训题(4-单操实训,5-场景实训)' AFTER `type`; + ADD COLUMN `sub_type` int not NULL COMMENT '规则类型:理论题(1-单选题,2-多选题,3-判断题);实训题(4-单操实训,5-场景实训)' AFTER `type`; ALTER TABLE `rts_paper_user_question` MODIFY COLUMN tmp_answer longtext; diff --git a/src/main/java/club/joylink/rtss/controller/LoginController.java b/src/main/java/club/joylink/rtss/controller/LoginController.java index c053c1385..3c7bc1f3d 100644 --- a/src/main/java/club/joylink/rtss/controller/LoginController.java +++ b/src/main/java/club/joylink/rtss/controller/LoginController.java @@ -87,6 +87,7 @@ public class LoginController { @GetMapping(path = "/getUserInfo") public AccountVO getUserInfo(String token) { LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token); + System.out.println(String.format("%s ====%s =========== from getUserInfo",loginUserInfoVO,loginUserInfoVO.getAccountVO().getCompanyId())); return loginUserInfoVO.getAccountVO(); } diff --git a/src/main/java/club/joylink/rtss/controller/org/OrgProjectController.java b/src/main/java/club/joylink/rtss/controller/org/OrgProjectController.java index 2ce8ec697..56337db57 100644 --- a/src/main/java/club/joylink/rtss/controller/org/OrgProjectController.java +++ b/src/main/java/club/joylink/rtss/controller/org/OrgProjectController.java @@ -21,6 +21,8 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; +import static club.joylink.rtss.controller.advice.AuthenticateInterceptor.LOGIN_INFO_KEY; + /** * 组织-项目关系管理接口 */ @@ -44,7 +46,7 @@ public class OrgProjectController { * 选择登入组织(目前先查询顶级组织) */ @PutMapping("signIn/{orgId}") - public void signInOrg(@PathVariable Long orgId, @RequestAttribute LoginUserInfoVO loginInfo) { + public void signInOrg(@PathVariable Long orgId, @RequestAttribute(name = LOGIN_INFO_KEY) LoginUserInfoVO loginInfo) { orgProjectService.signInOrg(orgId, loginInfo); } diff --git a/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java b/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java index a3f19a61f..8574c1bb7 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java @@ -5,6 +5,7 @@ import club.joylink.rtss.dao.OrgDAO; import club.joylink.rtss.dao.OrgProjectDAO; import club.joylink.rtss.dao.OrgUserDAO; import club.joylink.rtss.entity.*; +import club.joylink.rtss.services.LoginSessionManager; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.vo.AccountVO; @@ -76,12 +77,15 @@ public class OrgProjectService implements IOrgProjectService { List orgList = queryOrgInfoList(orgIdList); return orgList.stream().map(OrgProjectVO::new).collect(Collectors.toList()); } + @Autowired + private LoginSessionManager loginSessionManager; @Override public void signInOrg(Long orgId, LoginUserInfoVO loginInfo) { OrgVO orgVO = iOrgService.getTopOrg(orgId); boolean orgAdmin = iOrgUserService.userIsTheRoleInThisOrg(loginInfo.getAccountVO().getId(), orgId, BusinessConsts.OrgRole.Admin); loginInfo.setOrgProjectVO(orgVO, orgAdmin); + loginSessionManager.addLoginUserInfo(loginInfo); } @Override diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java index d57e6b03a..9546d5870 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java @@ -18,6 +18,7 @@ import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor; import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor; import club.joylink.rtss.vo.paper.convertor.PaperUserQuestionConvertor; import com.google.common.base.Joiner; +import com.google.common.base.Strings; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -221,7 +222,7 @@ public class PaperUserService { if(Objects.equals(puq.getSubType(), PaperQType.SubType.Single.getValue()) && PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))){ return rule.getScore(); }else if(Objects.equals(puq.getSubType(), PaperQType.SubType.Scene.getValue())){ - if(!StringUtils.hasText(puq.getTmpAnswer())){ + if(Strings.isNullOrEmpty(puq.getTmpAnswer())){ return 0; } PaperSubmitAnswerReqVo.AnswerDetail answerDetail = JsonUtils.read(puq.getTmpAnswer(),PaperSubmitAnswerReqVo.AnswerDetail.class); diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java index 1a40271c2..16a1e0926 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java @@ -117,13 +117,12 @@ public class PaperUserSubmitAnswerService { private TrainAnswerVO submitTrainingAnswer(PaperSubmitAnswerReqVo reqVo,PaperUserQuestion puq){ BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Strings.isNullOrEmpty(reqVo.getTrainAnswerDetail().getCosplayMemberId()),"实训考试没有对应的角色"); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(CollectionUtils.isEmpty(reqVo.getTrainAnswerDetail().getTrainDetail()),"实训考试没有对应的操作"); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(reqVo.getTrainAnswerDetail().getTrainDetail().stream().anyMatch(d->Objects.isNull(d.getStepId())),"实训步骤id不能为空"); PublishedTraining2DetailRspVo detailVO = this.training2PublishService.findTrainingAllInfoById(reqVo.getPqId()); log.debug("查找对应的实训数据 type:[{}],id[{}]",reqVo.getSubType(),reqVo.getPqId()); - if(CollectionUtils.isEmpty(reqVo.getTrainAnswerDetail().getTrainDetail())){ - return new TrainAnswerVO(PaperQuestionState.Wrong, null); - } + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(detailVO),String.format("未找到对应的实训数据[%s]",reqVo.getPqId())); List stepList = JsonUtils.readCollection(detailVO.getStepJson(),ArrayList.class, Step2VO.class); @@ -136,7 +135,6 @@ public class PaperUserSubmitAnswerService { return new TrainAnswerVO(PaperQuestionState.Wrong, null); } - /** * 处理实训题答案 * @param req @@ -156,10 +154,11 @@ public class PaperUserSubmitAnswerService { private TrainAnswerVO submitTrainingAnswerForScene(PublishedTraining2DetailRspVo trainVO,PaperSubmitAnswerReqVo req,PaperUserQuestion puq){ BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(StringUtils.hasText(trainVO.getScoringRuleJson()),"场景实训没有对应的评分规则"); - List scoreList = JsonUtils.readCollection(trainVO.getScoringRuleJson(),ArrayList.class, ScoringRuleVO.class); BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(!CollectionUtils.isEmpty(scoreList),String.format("场景实训[%s]没有评分规则",req.getPqId())); + List allDetailVOList = scoreList.stream().filter(d->Objects.equals(d.getMemberId(),req.getTrainAnswerDetail().getCosplayMemberId())).flatMap(d->d.getDetails().stream()).collect(Collectors.toList()); + List answerDetailList = req.getTrainAnswerDetail().getTrainDetail(); answerDetailList = Objects.isNull(answerDetailList) ? Collections.emptyList() : answerDetailList; // BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(allDetailVOList.size() == answerDetailList.size(),String.format("场景实训[%s] 评分规则与提交的答案数量不陪配",puq.getQuestionId())); @@ -181,12 +180,6 @@ public class PaperUserSubmitAnswerService { } resultAnswerDetailList.add(answerDetail); } -/* answerDetailList = answerDetailList.stream().peek(d->{ - if(Objects.isNull(d.getScore())){ - d.setScore(0F); - d.setNotExistAppend(true); - } - }).collect(Collectors.toList());*/ req.getTrainAnswerDetail().setTrainDetail(resultAnswerDetailList); return new TrainAnswerVO(PaperQuestionState.SECEN_CUL,req.getTrainAnswerDetail()); diff --git a/src/test/java/club/joylink/rtss/services/ws/StompTest.java b/src/test/java/club/joylink/rtss/services/ws/StompTest.java index 0a7e018c4..af4eec62d 100644 --- a/src/test/java/club/joylink/rtss/services/ws/StompTest.java +++ b/src/test/java/club/joylink/rtss/services/ws/StompTest.java @@ -44,7 +44,7 @@ public class StompTest { // List list = lt.readSource("d:\\t.txt"); // runToLeft(stompSession,"001"); // runToRight(stompSession,"002"); - list = lt.query(list,"004", Section.SectionRoadType.LEFT); +// list = lt.query(list,"004", Section.SectionRoadType.LEFT); // list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT); send(stompSession,list); }