diff --git a/sql/20220921-zhouyin.sql b/sql/20220921-zhouyin.sql index d89a99d66..7a938cfe3 100644 --- a/sql/20220921-zhouyin.sql +++ b/sql/20220921-zhouyin.sql @@ -6,9 +6,8 @@ CREATE TABLE `paper_question` ( `question` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题内容', `create_user_id` bigint DEFAULT NULL COMMENT '创建者id', `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `project_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '项目code', - `company_id` bigint DEFAULT NULL COMMENT '公司组织id', - `race_lable` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签', + `org_id` bigint DEFAULT NULL COMMENT '公司组织id', + `tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签', `question_option` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题选项', `question_answer` varchar(255) DEFAULT NULL COMMENT '答案,号隔开', `is_del` int DEFAULT '0' COMMENT '是否删除0=否,1=是', diff --git a/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java index 125901166..a3e76e6bc 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java @@ -24,7 +24,6 @@ import java.util.List; @RequestMapping(path = "/api/question/org") public class PagerQuestionBankController { - @Autowired private PagerQuestionService questionBankService; @@ -33,7 +32,7 @@ public class PagerQuestionBankController { */ @GetMapping(path = "/paging") public PageVO pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) { - queryVO.setCompanyId(loginInfo.getTopOrgId()); + queryVO.setOrgId(loginInfo.getTopOrgId()); return questionBankService.pagingQueryQuestions(queryVO,false); } @@ -43,7 +42,7 @@ public class PagerQuestionBankController { @GetMapping(path = "") public List queryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) { - queryVO.setCompanyId(loginInfo.getTopOrgId()); + queryVO.setOrgId(loginInfo.getTopOrgId()); return questionBankService.queryQuestions(queryVO,false); } @@ -59,20 +58,18 @@ public class PagerQuestionBankController { * 添加题目 */ @PostMapping(path = "") - public void addQuestion(@Validated @RequestBody PaperQuestionVO questionVO, @RequestAttribute LoginUserInfoVO loginInfo, - @RequestAttribute AccountVO user) { - questionVO.setCompanyId(loginInfo.getTopOrgId()); - questionBankService.saveOrUpdate(questionVO, user); + public void addQuestion(@Validated @RequestBody PaperQuestionVO questionVO, @RequestAttribute LoginUserInfoVO loginInfo) { + questionVO.setOrgId(loginInfo.getTopOrgId()); + questionBankService.saveOrUpdate(questionVO, loginInfo.getAccountVO()); } /** * 导入项目或单位试题库 */ @PostMapping(path = "/import") - public void importProjectQuestion(@Validated @RequestBody List questions, @RequestAttribute LoginUserInfoVO loginInfo, - @RequestAttribute AccountVO user, @RequestParam( name = "id") Long companyId) { + public void importProjectQuestion(@Validated @RequestBody List questions, @RequestAttribute LoginUserInfoVO loginInfo) { - questionBankService.importProjectQuestion(questions, loginInfo.getProject(), companyId, user); + questionBankService.importProjectQuestion(questions, loginInfo.getTopOrgId(), loginInfo.getAccountVO()); } /** @@ -81,7 +78,7 @@ public class PagerQuestionBankController { * @return */ @GetMapping(path = "/lable") - public Collection findAllLable(@RequestAttribute LoginUserInfoVO loginInfo /*@PathVariable Long companyId*/) { + public Collection findAllLable(@RequestAttribute LoginUserInfoVO loginInfo) { return this.questionBankService.findAllLable(loginInfo.getTopOrgId()); } @@ -94,7 +91,7 @@ public class PagerQuestionBankController { @PostMapping(path = "/lable/question") public List findByLable(@RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PagerLableQueryVO queryVO) { - return this.questionBankService.queryQuestionsForRaceLable(loginInfo.getTopOrgId(),queryVO, false); + return this.questionBankService.queryQuestionsForRaceLable(loginInfo.getTopOrgId(),queryVO); } @@ -109,7 +106,7 @@ public class PagerQuestionBankController { @PutMapping(path = "/{questionId}") public void updateQuestion(@PathVariable Long questionId, @RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PaperQuestionVO questionVO, @RequestAttribute AccountVO user) { questionVO.setId(questionId); - questionVO.setCompanyId(loginInfo.getTopOrgId()); + questionVO.setOrgId(loginInfo.getTopOrgId()); questionBankService.saveOrUpdate(questionVO, user); } diff --git a/src/main/java/club/joylink/rtss/dao/paper/PaperQuestionDAO.java b/src/main/java/club/joylink/rtss/dao/paper/PaperQuestionDAO.java index ac11d71ca..af87d9172 100644 --- a/src/main/java/club/joylink/rtss/dao/paper/PaperQuestionDAO.java +++ b/src/main/java/club/joylink/rtss/dao/paper/PaperQuestionDAO.java @@ -24,7 +24,7 @@ public interface PaperQuestionDAO { // " and project_code = #{projectCode} "+ // " " + // "" + - " and company_id = #{companyId,jdbcType=BIGINT} " + + " and org_id = #{companyId,jdbcType=BIGINT} " + // " 0\">"+ // ""+ // " #{d} "+ diff --git a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java index 13772f75c..7d5af4fa5 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java +++ b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java @@ -31,27 +31,25 @@ public class PaperQuestion implements Serializable { */ private LocalDateTime createTime; - /** - * 项目code - */ - private String projectCode; - /** * 公司组织id */ - private Long companyId; + private Long orgId; /** * 标签 */ - private String raceLable; + private String tags; + + /** + * 答案,号隔开 + */ + private String questionAnswer; /** * 是否删除0=否,1=是 */ private Integer isDel; - - private String questionAnswer; private static final long serialVersionUID = 1L; } diff --git a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionExample.java b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionExample.java index fb9f185b3..417e2211d 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionExample.java @@ -184,7 +184,10 @@ public class PaperQuestionExample { addCriterion("id not between", value1, value2, "id"); return (Criteria) this; } - + public Criteria andQuestionLike(String value) { + addCriterion("`question` like", value, "question"); + return (Criteria) this; + } public Criteria andTypeIsNull() { addCriterion("`type` is null"); return (Criteria) this; @@ -225,10 +228,6 @@ public class PaperQuestionExample { return (Criteria) this; } - public Criteria andTopicLike(String value) { - addCriterion("`topic` like", value, "topic"); - return (Criteria) this; - } public Criteria andTypeLike(String value) { addCriterion("`type` like", value, "type"); return (Criteria) this; @@ -379,203 +378,203 @@ public class PaperQuestionExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andOrgIdIsNull() { + addCriterion("org_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andOrgIdIsNotNull() { + addCriterion("org_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andOrgIdEqualTo(Long value) { + addCriterion("org_id =", value, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andOrgIdNotEqualTo(Long value) { + addCriterion("org_id <>", value, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andOrgIdGreaterThan(Long value) { + addCriterion("org_id >", value, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andOrgIdGreaterThanOrEqualTo(Long value) { + addCriterion("org_id >=", value, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andOrgIdLessThan(Long value) { + addCriterion("org_id <", value, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andOrgIdLessThanOrEqualTo(Long value) { + addCriterion("org_id <=", value, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andOrgIdIn(List values) { + addCriterion("org_id in", values, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andOrgIdNotIn(List values) { + addCriterion("org_id not in", values, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andOrgIdBetween(Long value1, Long value2) { + addCriterion("org_id between", value1, value2, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andOrgIdNotBetween(Long value1, Long value2) { + addCriterion("org_id not between", value1, value2, "orgId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andTagsIsNull() { + addCriterion("tags is null"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andTagsIsNotNull() { + addCriterion("tags is not null"); return (Criteria) this; } - public Criteria andCompanyIdIsNull() { - addCriterion("company_id is null"); + public Criteria andTagsEqualTo(String value) { + addCriterion("tags =", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdIsNotNull() { - addCriterion("company_id is not null"); + public Criteria andTagsNotEqualTo(String value) { + addCriterion("tags <>", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdEqualTo(Long value) { - addCriterion("company_id =", value, "companyId"); + public Criteria andTagsGreaterThan(String value) { + addCriterion("tags >", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdNotEqualTo(Long value) { - addCriterion("company_id <>", value, "companyId"); + public Criteria andTagsGreaterThanOrEqualTo(String value) { + addCriterion("tags >=", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdGreaterThan(Long value) { - addCriterion("company_id >", value, "companyId"); + public Criteria andTagsLessThan(String value) { + addCriterion("tags <", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdGreaterThanOrEqualTo(Long value) { - addCriterion("company_id >=", value, "companyId"); + public Criteria andTagsLessThanOrEqualTo(String value) { + addCriterion("tags <=", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdLessThan(Long value) { - addCriterion("company_id <", value, "companyId"); + public Criteria andTagsLike(String value) { + addCriterion("tags like", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdLessThanOrEqualTo(Long value) { - addCriterion("company_id <=", value, "companyId"); + public Criteria andTagsNotLike(String value) { + addCriterion("tags not like", value, "tags"); return (Criteria) this; } - public Criteria andCompanyIdIn(List values) { - addCriterion("company_id in", values, "companyId"); + public Criteria andTagsIn(List values) { + addCriterion("tags in", values, "tags"); return (Criteria) this; } - public Criteria andCompanyIdNotIn(List values) { - addCriterion("company_id not in", values, "companyId"); + public Criteria andTagsNotIn(List values) { + addCriterion("tags not in", values, "tags"); return (Criteria) this; } - public Criteria andCompanyIdBetween(Long value1, Long value2) { - addCriterion("company_id between", value1, value2, "companyId"); + public Criteria andTagsBetween(String value1, String value2) { + addCriterion("tags between", value1, value2, "tags"); return (Criteria) this; } - public Criteria andCompanyIdNotBetween(Long value1, Long value2) { - addCriterion("company_id not between", value1, value2, "companyId"); + public Criteria andTagsNotBetween(String value1, String value2) { + addCriterion("tags not between", value1, value2, "tags"); return (Criteria) this; } - public Criteria andRaceLableIsNull() { - addCriterion("race_lable is null"); + public Criteria andQuestionAnswerIsNull() { + addCriterion("question_answer is null"); return (Criteria) this; } - public Criteria andRaceLableIsNotNull() { - addCriterion("race_lable is not null"); + public Criteria andQuestionAnswerIsNotNull() { + addCriterion("question_answer is not null"); return (Criteria) this; } - public Criteria andRaceLableEqualTo(String value) { - addCriterion("race_lable =", value, "raceLable"); + public Criteria andQuestionAnswerEqualTo(String value) { + addCriterion("question_answer =", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableNotEqualTo(String value) { - addCriterion("race_lable <>", value, "raceLable"); + public Criteria andQuestionAnswerNotEqualTo(String value) { + addCriterion("question_answer <>", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableGreaterThan(String value) { - addCriterion("race_lable >", value, "raceLable"); + public Criteria andQuestionAnswerGreaterThan(String value) { + addCriterion("question_answer >", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableGreaterThanOrEqualTo(String value) { - addCriterion("race_lable >=", value, "raceLable"); + public Criteria andQuestionAnswerGreaterThanOrEqualTo(String value) { + addCriterion("question_answer >=", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableLessThan(String value) { - addCriterion("race_lable <", value, "raceLable"); + public Criteria andQuestionAnswerLessThan(String value) { + addCriterion("question_answer <", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableLessThanOrEqualTo(String value) { - addCriterion("race_lable <=", value, "raceLable"); + public Criteria andQuestionAnswerLessThanOrEqualTo(String value) { + addCriterion("question_answer <=", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableLike(String value) { - addCriterion("race_lable like", value, "raceLable"); + public Criteria andQuestionAnswerLike(String value) { + addCriterion("question_answer like", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableNotLike(String value) { - addCriterion("race_lable not like", value, "raceLable"); + public Criteria andQuestionAnswerNotLike(String value) { + addCriterion("question_answer not like", value, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableIn(List values) { - addCriterion("race_lable in", values, "raceLable"); + public Criteria andQuestionAnswerIn(List values) { + addCriterion("question_answer in", values, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableNotIn(List values) { - addCriterion("race_lable not in", values, "raceLable"); + public Criteria andQuestionAnswerNotIn(List values) { + addCriterion("question_answer not in", values, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableBetween(String value1, String value2) { - addCriterion("race_lable between", value1, value2, "raceLable"); + public Criteria andQuestionAnswerBetween(String value1, String value2) { + addCriterion("question_answer between", value1, value2, "questionAnswer"); return (Criteria) this; } - public Criteria andRaceLableNotBetween(String value1, String value2) { - addCriterion("race_lable not between", value1, value2, "raceLable"); + public Criteria andQuestionAnswerNotBetween(String value1, String value2) { + addCriterion("question_answer not between", value1, value2, "questionAnswer"); return (Criteria) this; } diff --git a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionWithBLOBs.java b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionWithBLOBs.java index 23102bbdb..28c80d318 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionWithBLOBs.java +++ b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestionWithBLOBs.java @@ -1,7 +1,6 @@ package club.joylink.rtss.entity.paper.question; import java.io.Serializable; - import lombok.Data; /** diff --git a/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java b/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java index 3c4bb569c..a8a093a7a 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java @@ -36,9 +36,16 @@ public class PagerQuestionService { @Resource private PaperQuestionDAO questionDAO; + /** + * 查询列表 + * @param queryVO + * @param isPaging + * @param companyIdCanNull 是否允许公司组织id可以为空,true=管理使用,false = 组织使用 + * @return + */ private Object queryQuestions(QuestionQueryVO queryVO, boolean isPaging,boolean companyIdCanNull){ if(Objects.equals(false,companyIdCanNull)){ - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getCompanyId()),"题目答案不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getOrgId()),"题目答案不能为空"); } if(isPaging){ PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); @@ -46,14 +53,14 @@ public class PagerQuestionService { PaperQuestionExample example = new PaperQuestionExample(); PaperQuestionExample.Criteria criteria = example.createCriteria(); if (StringUtils.hasText(queryVO.getTopic())) { - criteria.andTopicLike(String.format("%%%s%%", queryVO.getTopic())); + criteria.andQuestionLike(String.format("%%%s%%", queryVO.getTopic())); } if (StringUtils.hasText(queryVO.getType())) { criteria.andTypeEqualTo(queryVO.getType()); } - if(Objects.nonNull(queryVO.getCompanyId())){ - criteria.andCompanyIdEqualTo(queryVO.getCompanyId()); + if(Objects.nonNull(queryVO.getOrgId())){ + criteria.andOrgIdEqualTo(queryVO.getOrgId()); } criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); return questionDAO.selectByExampleWithBLOBs(example); @@ -109,15 +116,12 @@ public class PagerQuestionService { public boolean answer(Long questionId,List answerIds){ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds),"题目答案不能为空"); PaperQuestionVO vo = this.getQuestion(questionId,true); - List newAnswerList = answerIds.stream().filter(Objects::nonNull)/*.map(String::trim)*/.distinct().collect(Collectors.toList()); -// List optionList = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).map(d->d.getId()).collect(Collectors.toList()); - + List newAnswerList = answerIds.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType()) || Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!"); }else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个"); -// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < optionList.size(),"多选题答案与标准答案数量不匹配"); } // List sourceOptionList = Lists.newArrayList(); // sourceOptionList.addAll(optionList); @@ -126,7 +130,7 @@ public class PagerQuestionService { // return true; // } Collections.sort(answerIds); - String answerStr = Joiner.on(",").join(answerIds); + String answerStr = Joiner.on(",").skipNulls().join(answerIds); if(Objects.equals(answerStr,vo.getQuestionAnswer())){ return true; } @@ -149,25 +153,24 @@ public class PagerQuestionService { List ids = this.queryFromProjectCode(projectCode); criteria.andCompanyIdIn(ids); }*/ - criteria.andCompanyIdEqualTo(companyId); + criteria.andOrgIdEqualTo(companyId); criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); List lableList = this.questionDAO.selectByExample(example); if(CollectionUtils.isEmpty(lableList)){ return Collections.emptyList(); } - return lableList.stream().map(PaperQuestion::getRaceLable).filter(Objects::nonNull).flatMap(d-> Splitter.on(",").omitEmptyStrings() + return lableList.stream().map(PaperQuestion::getTags).filter(Objects::nonNull).flatMap(d-> Splitter.on(",").omitEmptyStrings() .trimResults().splitToStream(d)).collect(Collectors.toSet()); } /** * 根据公司id和标签或类型查询 - * + * @param companyId * @param queryVO - * @param random * @return */ - public List queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO, boolean random) { + public List queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO) { /*boolean isDefault = Project.isDefault(projectCode); List idList = null; if(Objects.equals(false,isDefault)){ @@ -186,7 +189,7 @@ public class PagerQuestionService { * @param accountVO */ public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO accountVO) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(questionVO.getCompanyId()),"组织id不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(questionVO.getOrgId()),"组织id不能为空"); this.checkQuestionType(questionVO,"题库目前只支持单选,多选和判断"); if (questionVO.isSelect() || questionVO.isJudge()) { this.checkQuestionTypeForSelectAndJudge(questionVO,"单选或判断题正确答案有且只有一个!"); @@ -230,7 +233,7 @@ public class PagerQuestionService { } @Transactional - public void importProjectQuestion(List questions, String projectCode, Long companyId, AccountVO accountVO) { + public void importProjectQuestion(List questions, Long companyId, AccountVO accountVO) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(companyId),"组织id不能为空"); questions.forEach(questionVO -> { String topic = questionVO.getQuestion(); @@ -246,18 +249,19 @@ public class PagerQuestionService { //默认项目导入题考虑是否有单位关联 PaperQuestionExample example = new PaperQuestionExample(); PaperQuestionExample.Criteria criteria = example.createCriteria(); + criteria.andOrgIdEqualTo(companyId); + PaperQuestionWithBLOBs pq = new PaperQuestionWithBLOBs(); + pq.setIsDel(BusinessConsts.DBLogicDelete.DELETE.ordinal()); + questionDAO.updateByExampleSelective(pq,example); - criteria.andCompanyIdEqualTo(companyId); - - questionDAO.deleteByExample(example); +// questionDAO.deleteByExample(example); questions.forEach(questionVO -> { - questionVO.setProjectCode(projectCode); +// questionVO.setProjectCode(projectCode); PaperQuestionWithBLOBs question = questionVO.convert2DB(); // question.setProjectCode(null); - question.setCompanyId(companyId); + question.setOrgId(companyId); question.setCreateUserId(accountVO.getId()); question.setCreateTime(LocalDateTime.now()); - question.setCompanyId(companyId); questionDAO.insert(question); }); diff --git a/src/main/java/club/joylink/rtss/services/voice/AbstractVoiceService.java b/src/main/java/club/joylink/rtss/services/voice/AbstractVoiceService.java index 23db13581..522ebf56d 100644 --- a/src/main/java/club/joylink/rtss/services/voice/AbstractVoiceService.java +++ b/src/main/java/club/joylink/rtss/services/voice/AbstractVoiceService.java @@ -19,39 +19,49 @@ public abstract class AbstractVoiceService implements IVoiceService2 { private final MinioClientUtil voiceRecognitionUtil; private final static String SYNTHESIS_FOLDER = "synthesis"; private final static String RECOGNITION_FOLDER = "recognition"; + public AbstractVoiceService(MinioClientConfig minioClientConfig){ this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig,SYNTHESIS_FOLDER); this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig,RECOGNITION_FOLDER); } + + /** + * 语音识别 + * @param vo + * @return + */ public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo){ String fileName = String.format("%s.wav",System.currentTimeMillis()); - this.uploadFile(vo.getData(),fileName,RECOGNITION_FOLDER); - String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName); + this.uploadFile(voiceRecognitionUtil,vo.getData(),fileName,RECOGNITION_FOLDER); + String filePath = this.voiceRecognitionUtil.getDownLoadPath(fileName); VoiceAsrResult voiceResult = this.recognition(vo); return new VoiceRecognitionResult(filePath,voiceResult.getResult().get(0)); } + /** + * 语音合成 + * @param vo + * @return + */ public VoiceCompose synthesis(BaseVoiceSynthesisVO vo){ String md5Code = vo.md5Code(); String fileName = String.format("%s.wav",md5Code); if(Objects.equals(false,this.voiceSynthesisUtil.checkFileIsExist(fileName))){ byte[] data = this.voiceSynthesis(vo); - this.uploadFile(data,fileName,SYNTHESIS_FOLDER); + this.uploadFile(voiceSynthesisUtil,data,fileName,SYNTHESIS_FOLDER); } String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName); return new VoiceCompose(filePath,md5Code,vo.getMessage()); } - private void uploadFile(byte[] data,String fileName,String folder){ + private void uploadFile(MinioClientUtil minioClient ,byte[] data,String fileName,String folder){ try{ - this.voiceSynthesisUtil.uploadBytes(data,fileName); + minioClient.uploadBytes(data,fileName); }catch (SimulationException e){ log.error("文件上传失败 folder:{},文件名:{} errmsg:{}",folder,fileName,e.getMessage(),e); throw e; } - - } } diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java index 22eb5ba7f..1e0f61da5 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java @@ -52,9 +52,9 @@ public class PaperQuestionVO implements Cloneable { private String createUserName; - private String projectCode; - private Long companyId; - private String raceLable; +// private String projectCode; + private Long orgId; + private String tags; private String questionAnswer; private String answer; @@ -68,9 +68,9 @@ public class PaperQuestionVO implements Cloneable { this.id = question.getId(); this.type = question.getType(); this.question = question.getQuestion(); - this.projectCode = question.getProjectCode(); - this.companyId = question.getCompanyId(); - this.raceLable = question.getRaceLable(); +// this.projectCode = question.getProjectCode(); + this.orgId = question.getOrgId(); + this.tags = question.getTags(); this.optionList = JsonUtils.readCollection(question.getQuestionOption(),ArrayList.class, PaperQuestionOptionVO2.class); String dd = Objects.isNull(question.getQuestionAnswer()) ? "" : question.getQuestionAnswer(); this.answer = dd; @@ -88,8 +88,8 @@ public class PaperQuestionVO implements Cloneable { question.setId(this.id); question.setType(type); question.setQuestion(this.question); - question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode); - question.setCompanyId(companyId); +// question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode); + question.setOrgId(this.orgId); this.setOptionId(question); String dd = JsonUtils.writeValueAsString(this.optionList); @@ -98,7 +98,7 @@ public class PaperQuestionVO implements Cloneable { listMap.forEach(d->d.remove("correct")); question.setQuestionOption(JsonUtils.writeValueAsString(listMap)); - question.setRaceLable(this.raceLable); + question.setTags(this.tags); question.setIsDel(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); // question.setQuestionAnswer(this.answer); return question; diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java index 653325f98..7c435724a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java @@ -13,6 +13,6 @@ public class QuestionQueryVO extends PageQueryVO { private String type; // private String projectCode; - private Long companyId; + private Long orgId; } diff --git a/src/main/java/club/joylink/rtss/vo/client/voice/BaseVoiceSynthesisVO.java b/src/main/java/club/joylink/rtss/vo/client/voice/BaseVoiceSynthesisVO.java index 3fb5a4243..53ebf6259 100644 --- a/src/main/java/club/joylink/rtss/vo/client/voice/BaseVoiceSynthesisVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/voice/BaseVoiceSynthesisVO.java @@ -4,7 +4,6 @@ import club.joylink.rtss.util.EncryptUtil; import lombok.Data; @Data - public class BaseVoiceSynthesisVO { /** * 消息 @@ -27,7 +26,7 @@ public class BaseVoiceSynthesisVO { */ private String per; /** - * 是否启用默认参数 + * 是否启用服务商的默认参数 */ private boolean defaultParam = true; diff --git a/src/main/java/club/joylink/rtss/vo/client/voice/VoiceRecognitionVO.java b/src/main/java/club/joylink/rtss/vo/client/voice/VoiceRecognitionVO.java index e7d48f142..e0ecb24e2 100644 --- a/src/main/java/club/joylink/rtss/vo/client/voice/VoiceRecognitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/voice/VoiceRecognitionVO.java @@ -10,7 +10,13 @@ import java.util.Base64; @Data @Slf4j public class VoiceRecognitionVO { + /** + * 文件二进制数据 + */ private byte[] data; + /** + * 文件contentType + */ private String fileContentType; public VoiceRecognitionVO(byte[] data){ @@ -23,17 +29,26 @@ public class VoiceRecognitionVO { } - - + /** + * 加载上传的文件 + * @param file + * @return + */ public static VoiceRecognitionVO load(MultipartFile file){ try { VoiceRecognitionVO vo = new VoiceRecognitionVO(file.getBytes(),file.getContentType()); return vo; } catch (IOException e) { - log.error("加载数据失败 file{}",file.getOriginalFilename() + " errMsg:{}",file.getOriginalFilename(),e.getMessage(),e); + log.error("加载数据失败 file{} errMsg:{}",file.getOriginalFilename() ,e.getMessage(),e); throw new RuntimeException(e); } } + + /** + * 加载base64 + * @param base64Str + * @return + */ public static VoiceRecognitionVO load(String base64Str){ int index = base64Str.indexOf("base64,"); String base64 = base64Str.substring(index + "base64,".length());