Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-10-09 11:28:46 +08:00
commit 04f217b7bf
12 changed files with 176 additions and 156 deletions

View File

@ -6,9 +6,8 @@ CREATE TABLE `paper_question` (
`question` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题内容', `question` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题内容',
`create_user_id` bigint DEFAULT NULL COMMENT '创建者id', `create_user_id` bigint DEFAULT NULL COMMENT '创建者id',
`create_time` datetime DEFAULT NULL COMMENT '创建时间', `create_time` datetime DEFAULT NULL COMMENT '创建时间',
`project_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '项目code', `org_id` bigint DEFAULT NULL COMMENT '公司组织id',
`company_id` bigint DEFAULT NULL COMMENT '公司组织id', `tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签',
`race_lable` 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_option` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题选项',
`question_answer` varchar(255) DEFAULT NULL COMMENT '答案,号隔开', `question_answer` varchar(255) DEFAULT NULL COMMENT '答案,号隔开',
`is_del` int DEFAULT '0' COMMENT '是否删除0=否1=是', `is_del` int DEFAULT '0' COMMENT '是否删除0=否1=是',

View File

@ -24,7 +24,6 @@ import java.util.List;
@RequestMapping(path = "/api/question/org") @RequestMapping(path = "/api/question/org")
public class PagerQuestionBankController { public class PagerQuestionBankController {
@Autowired @Autowired
private PagerQuestionService questionBankService; private PagerQuestionService questionBankService;
@ -33,7 +32,7 @@ public class PagerQuestionBankController {
*/ */
@GetMapping(path = "/paging") @GetMapping(path = "/paging")
public PageVO<PaperQuestionVO> pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) { public PageVO<PaperQuestionVO> pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setCompanyId(loginInfo.getTopOrgId()); queryVO.setOrgId(loginInfo.getTopOrgId());
return questionBankService.pagingQueryQuestions(queryVO,false); return questionBankService.pagingQueryQuestions(queryVO,false);
} }
@ -43,7 +42,7 @@ public class PagerQuestionBankController {
@GetMapping(path = "") @GetMapping(path = "")
public List<PaperQuestionVO> queryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) { public List<PaperQuestionVO> queryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setCompanyId(loginInfo.getTopOrgId()); queryVO.setOrgId(loginInfo.getTopOrgId());
return questionBankService.queryQuestions(queryVO,false); return questionBankService.queryQuestions(queryVO,false);
} }
@ -59,20 +58,18 @@ public class PagerQuestionBankController {
* 添加题目 * 添加题目
*/ */
@PostMapping(path = "") @PostMapping(path = "")
public void addQuestion(@Validated @RequestBody PaperQuestionVO questionVO, @RequestAttribute LoginUserInfoVO loginInfo, public void addQuestion(@Validated @RequestBody PaperQuestionVO questionVO, @RequestAttribute LoginUserInfoVO loginInfo) {
@RequestAttribute AccountVO user) { questionVO.setOrgId(loginInfo.getTopOrgId());
questionVO.setCompanyId(loginInfo.getTopOrgId()); questionBankService.saveOrUpdate(questionVO, loginInfo.getAccountVO());
questionBankService.saveOrUpdate(questionVO, user);
} }
/** /**
* 导入项目或单位试题库 * 导入项目或单位试题库
*/ */
@PostMapping(path = "/import") @PostMapping(path = "/import")
public void importProjectQuestion(@Validated @RequestBody List<PaperQuestionVO> questions, @RequestAttribute LoginUserInfoVO loginInfo, public void importProjectQuestion(@Validated @RequestBody List<PaperQuestionVO> questions, @RequestAttribute LoginUserInfoVO loginInfo) {
@RequestAttribute AccountVO user, @RequestParam( name = "id") Long companyId) {
questionBankService.importProjectQuestion(questions, loginInfo.getProject(), companyId, user); questionBankService.importProjectQuestion(questions, loginInfo.getTopOrgId(), loginInfo.getAccountVO());
} }
/** /**
@ -81,7 +78,7 @@ public class PagerQuestionBankController {
* @return * @return
*/ */
@GetMapping(path = "/lable") @GetMapping(path = "/lable")
public Collection<String> findAllLable(@RequestAttribute LoginUserInfoVO loginInfo /*@PathVariable Long companyId*/) { public Collection<String> findAllLable(@RequestAttribute LoginUserInfoVO loginInfo) {
return this.questionBankService.findAllLable(loginInfo.getTopOrgId()); return this.questionBankService.findAllLable(loginInfo.getTopOrgId());
} }
@ -94,7 +91,7 @@ public class PagerQuestionBankController {
@PostMapping(path = "/lable/question") @PostMapping(path = "/lable/question")
public List<PaperQuestionVO> findByLable(@RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PagerLableQueryVO queryVO) { public List<PaperQuestionVO> 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}") @PutMapping(path = "/{questionId}")
public void updateQuestion(@PathVariable Long questionId, @RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PaperQuestionVO questionVO, @RequestAttribute AccountVO user) { public void updateQuestion(@PathVariable Long questionId, @RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PaperQuestionVO questionVO, @RequestAttribute AccountVO user) {
questionVO.setId(questionId); questionVO.setId(questionId);
questionVO.setCompanyId(loginInfo.getTopOrgId()); questionVO.setOrgId(loginInfo.getTopOrgId());
questionBankService.saveOrUpdate(questionVO, user); questionBankService.saveOrUpdate(questionVO, user);
} }

View File

@ -24,7 +24,7 @@ public interface PaperQuestionDAO {
// " and project_code = #{projectCode} "+ // " and project_code = #{projectCode} "+
// " </otherwise>" + // " </otherwise>" +
// "</choose>" + // "</choose>" +
" and company_id = #{companyId,jdbcType=BIGINT} " + " and org_id = #{companyId,jdbcType=BIGINT} " +
// "<if test=\"companyIdList != null and companyIdList.size > 0\">"+ // "<if test=\"companyIdList != null and companyIdList.size > 0\">"+
// "<foreach collection=\"companyIdList\" open=\" and company_id in (\" close=\")\" item=\"d\" separator=\",\">"+ // "<foreach collection=\"companyIdList\" open=\" and company_id in (\" close=\")\" item=\"d\" separator=\",\">"+
// " #{d} "+ // " #{d} "+

View File

@ -31,27 +31,25 @@ public class PaperQuestion implements Serializable {
*/ */
private LocalDateTime createTime; private LocalDateTime createTime;
/**
* 项目code
*/
private String projectCode;
/** /**
* 公司组织id * 公司组织id
*/ */
private Long companyId; private Long orgId;
/** /**
* 标签 * 标签
*/ */
private String raceLable; private String tags;
/**
* 答案,号隔开
*/
private String questionAnswer;
/** /**
* 是否删除0=1= * 是否删除0=1=
*/ */
private Integer isDel; private Integer isDel;
private String questionAnswer;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -184,7 +184,10 @@ public class PaperQuestionExample {
addCriterion("id not between", value1, value2, "id"); addCriterion("id not between", value1, value2, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andQuestionLike(String value) {
addCriterion("`question` like", value, "question");
return (Criteria) this;
}
public Criteria andTypeIsNull() { public Criteria andTypeIsNull() {
addCriterion("`type` is null"); addCriterion("`type` is null");
return (Criteria) this; return (Criteria) this;
@ -225,10 +228,6 @@ public class PaperQuestionExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTopicLike(String value) {
addCriterion("`topic` like", value, "topic");
return (Criteria) this;
}
public Criteria andTypeLike(String value) { public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type"); addCriterion("`type` like", value, "type");
return (Criteria) this; return (Criteria) this;
@ -379,203 +378,203 @@ public class PaperQuestionExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeIsNull() { public Criteria andOrgIdIsNull() {
addCriterion("project_code is null"); addCriterion("org_id is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeIsNotNull() { public Criteria andOrgIdIsNotNull() {
addCriterion("project_code is not null"); addCriterion("org_id is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeEqualTo(String value) { public Criteria andOrgIdEqualTo(Long value) {
addCriterion("project_code =", value, "projectCode"); addCriterion("org_id =", value, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeNotEqualTo(String value) { public Criteria andOrgIdNotEqualTo(Long value) {
addCriterion("project_code <>", value, "projectCode"); addCriterion("org_id <>", value, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeGreaterThan(String value) { public Criteria andOrgIdGreaterThan(Long value) {
addCriterion("project_code >", value, "projectCode"); addCriterion("org_id >", value, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { public Criteria andOrgIdGreaterThanOrEqualTo(Long value) {
addCriterion("project_code >=", value, "projectCode"); addCriterion("org_id >=", value, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeLessThan(String value) { public Criteria andOrgIdLessThan(Long value) {
addCriterion("project_code <", value, "projectCode"); addCriterion("org_id <", value, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeLessThanOrEqualTo(String value) { public Criteria andOrgIdLessThanOrEqualTo(Long value) {
addCriterion("project_code <=", value, "projectCode"); addCriterion("org_id <=", value, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeLike(String value) { public Criteria andOrgIdIn(List<Long> values) {
addCriterion("project_code like", value, "projectCode"); addCriterion("org_id in", values, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeNotLike(String value) { public Criteria andOrgIdNotIn(List<Long> values) {
addCriterion("project_code not like", value, "projectCode"); addCriterion("org_id not in", values, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeIn(List<String> values) { public Criteria andOrgIdBetween(Long value1, Long value2) {
addCriterion("project_code in", values, "projectCode"); addCriterion("org_id between", value1, value2, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeNotIn(List<String> values) { public Criteria andOrgIdNotBetween(Long value1, Long value2) {
addCriterion("project_code not in", values, "projectCode"); addCriterion("org_id not between", value1, value2, "orgId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeBetween(String value1, String value2) { public Criteria andTagsIsNull() {
addCriterion("project_code between", value1, value2, "projectCode"); addCriterion("tags is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectCodeNotBetween(String value1, String value2) { public Criteria andTagsIsNotNull() {
addCriterion("project_code not between", value1, value2, "projectCode"); addCriterion("tags is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdIsNull() { public Criteria andTagsEqualTo(String value) {
addCriterion("company_id is null"); addCriterion("tags =", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdIsNotNull() { public Criteria andTagsNotEqualTo(String value) {
addCriterion("company_id is not null"); addCriterion("tags <>", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdEqualTo(Long value) { public Criteria andTagsGreaterThan(String value) {
addCriterion("company_id =", value, "companyId"); addCriterion("tags >", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdNotEqualTo(Long value) { public Criteria andTagsGreaterThanOrEqualTo(String value) {
addCriterion("company_id <>", value, "companyId"); addCriterion("tags >=", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdGreaterThan(Long value) { public Criteria andTagsLessThan(String value) {
addCriterion("company_id >", value, "companyId"); addCriterion("tags <", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdGreaterThanOrEqualTo(Long value) { public Criteria andTagsLessThanOrEqualTo(String value) {
addCriterion("company_id >=", value, "companyId"); addCriterion("tags <=", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdLessThan(Long value) { public Criteria andTagsLike(String value) {
addCriterion("company_id <", value, "companyId"); addCriterion("tags like", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdLessThanOrEqualTo(Long value) { public Criteria andTagsNotLike(String value) {
addCriterion("company_id <=", value, "companyId"); addCriterion("tags not like", value, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdIn(List<Long> values) { public Criteria andTagsIn(List<String> values) {
addCriterion("company_id in", values, "companyId"); addCriterion("tags in", values, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdNotIn(List<Long> values) { public Criteria andTagsNotIn(List<String> values) {
addCriterion("company_id not in", values, "companyId"); addCriterion("tags not in", values, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdBetween(Long value1, Long value2) { public Criteria andTagsBetween(String value1, String value2) {
addCriterion("company_id between", value1, value2, "companyId"); addCriterion("tags between", value1, value2, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCompanyIdNotBetween(Long value1, Long value2) { public Criteria andTagsNotBetween(String value1, String value2) {
addCriterion("company_id not between", value1, value2, "companyId"); addCriterion("tags not between", value1, value2, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableIsNull() { public Criteria andQuestionAnswerIsNull() {
addCriterion("race_lable is null"); addCriterion("question_answer is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableIsNotNull() { public Criteria andQuestionAnswerIsNotNull() {
addCriterion("race_lable is not null"); addCriterion("question_answer is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableEqualTo(String value) { public Criteria andQuestionAnswerEqualTo(String value) {
addCriterion("race_lable =", value, "raceLable"); addCriterion("question_answer =", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableNotEqualTo(String value) { public Criteria andQuestionAnswerNotEqualTo(String value) {
addCriterion("race_lable <>", value, "raceLable"); addCriterion("question_answer <>", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableGreaterThan(String value) { public Criteria andQuestionAnswerGreaterThan(String value) {
addCriterion("race_lable >", value, "raceLable"); addCriterion("question_answer >", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableGreaterThanOrEqualTo(String value) { public Criteria andQuestionAnswerGreaterThanOrEqualTo(String value) {
addCriterion("race_lable >=", value, "raceLable"); addCriterion("question_answer >=", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableLessThan(String value) { public Criteria andQuestionAnswerLessThan(String value) {
addCriterion("race_lable <", value, "raceLable"); addCriterion("question_answer <", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableLessThanOrEqualTo(String value) { public Criteria andQuestionAnswerLessThanOrEqualTo(String value) {
addCriterion("race_lable <=", value, "raceLable"); addCriterion("question_answer <=", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableLike(String value) { public Criteria andQuestionAnswerLike(String value) {
addCriterion("race_lable like", value, "raceLable"); addCriterion("question_answer like", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableNotLike(String value) { public Criteria andQuestionAnswerNotLike(String value) {
addCriterion("race_lable not like", value, "raceLable"); addCriterion("question_answer not like", value, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableIn(List<String> values) { public Criteria andQuestionAnswerIn(List<String> values) {
addCriterion("race_lable in", values, "raceLable"); addCriterion("question_answer in", values, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableNotIn(List<String> values) { public Criteria andQuestionAnswerNotIn(List<String> values) {
addCriterion("race_lable not in", values, "raceLable"); addCriterion("question_answer not in", values, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableBetween(String value1, String value2) { public Criteria andQuestionAnswerBetween(String value1, String value2) {
addCriterion("race_lable between", value1, value2, "raceLable"); addCriterion("question_answer between", value1, value2, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRaceLableNotBetween(String value1, String value2) { public Criteria andQuestionAnswerNotBetween(String value1, String value2) {
addCriterion("race_lable not between", value1, value2, "raceLable"); addCriterion("question_answer not between", value1, value2, "questionAnswer");
return (Criteria) this; return (Criteria) this;
} }

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.entity.paper.question; package club.joylink.rtss.entity.paper.question;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data; import lombok.Data;
/** /**

View File

@ -36,9 +36,16 @@ public class PagerQuestionService {
@Resource @Resource
private PaperQuestionDAO questionDAO; private PaperQuestionDAO questionDAO;
/**
* 查询列表
* @param queryVO
* @param isPaging
* @param companyIdCanNull 是否允许公司组织id可以为空true=管理使用false = 组织使用
* @return
*/
private Object queryQuestions(QuestionQueryVO queryVO, boolean isPaging,boolean companyIdCanNull){ private Object queryQuestions(QuestionQueryVO queryVO, boolean isPaging,boolean companyIdCanNull){
if(Objects.equals(false,companyIdCanNull)){ if(Objects.equals(false,companyIdCanNull)){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getCompanyId()),"题目答案不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getOrgId()),"题目答案不能为空");
} }
if(isPaging){ if(isPaging){
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
@ -46,14 +53,14 @@ public class PagerQuestionService {
PaperQuestionExample example = new PaperQuestionExample(); PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria(); PaperQuestionExample.Criteria criteria = example.createCriteria();
if (StringUtils.hasText(queryVO.getTopic())) { if (StringUtils.hasText(queryVO.getTopic())) {
criteria.andTopicLike(String.format("%%%s%%", queryVO.getTopic())); criteria.andQuestionLike(String.format("%%%s%%", queryVO.getTopic()));
} }
if (StringUtils.hasText(queryVO.getType())) { if (StringUtils.hasText(queryVO.getType())) {
criteria.andTypeEqualTo(queryVO.getType()); criteria.andTypeEqualTo(queryVO.getType());
} }
if(Objects.nonNull(queryVO.getCompanyId())){ if(Objects.nonNull(queryVO.getOrgId())){
criteria.andCompanyIdEqualTo(queryVO.getCompanyId()); criteria.andOrgIdEqualTo(queryVO.getOrgId());
} }
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
return questionDAO.selectByExampleWithBLOBs(example); return questionDAO.selectByExampleWithBLOBs(example);
@ -109,15 +116,12 @@ public class PagerQuestionService {
public boolean answer(Long questionId,List<Integer> answerIds){ public boolean answer(Long questionId,List<Integer> answerIds){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds),"题目答案不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds),"题目答案不能为空");
PaperQuestionVO vo = this.getQuestion(questionId,true); PaperQuestionVO vo = this.getQuestion(questionId,true);
List<Integer> newAnswerList = answerIds.stream().filter(Objects::nonNull)/*.map(String::trim)*/.distinct().collect(Collectors.toList()); List<Integer> newAnswerList = answerIds.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
// List<Integer> optionList = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).map(d->d.getId()).collect(Collectors.toList());
if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType()) if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType())
|| Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){ || Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!");
}else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){ }else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个");
// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < optionList.size(),"多选题答案与标准答案数量不匹配");
} }
// List<Integer> sourceOptionList = Lists.newArrayList(); // List<Integer> sourceOptionList = Lists.newArrayList();
// sourceOptionList.addAll(optionList); // sourceOptionList.addAll(optionList);
@ -126,7 +130,7 @@ public class PagerQuestionService {
// return true; // return true;
// } // }
Collections.sort(answerIds); Collections.sort(answerIds);
String answerStr = Joiner.on(",").join(answerIds); String answerStr = Joiner.on(",").skipNulls().join(answerIds);
if(Objects.equals(answerStr,vo.getQuestionAnswer())){ if(Objects.equals(answerStr,vo.getQuestionAnswer())){
return true; return true;
} }
@ -149,25 +153,24 @@ public class PagerQuestionService {
List<Long> ids = this.queryFromProjectCode(projectCode); List<Long> ids = this.queryFromProjectCode(projectCode);
criteria.andCompanyIdIn(ids); criteria.andCompanyIdIn(ids);
}*/ }*/
criteria.andCompanyIdEqualTo(companyId); criteria.andOrgIdEqualTo(companyId);
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
List<PaperQuestion> lableList = this.questionDAO.selectByExample(example); List<PaperQuestion> lableList = this.questionDAO.selectByExample(example);
if(CollectionUtils.isEmpty(lableList)){ if(CollectionUtils.isEmpty(lableList)){
return Collections.emptyList(); 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()); .trimResults().splitToStream(d)).collect(Collectors.toSet());
} }
/** /**
* 根据公司id和标签或类型查询 * 根据公司id和标签或类型查询
* * @param companyId
* @param queryVO * @param queryVO
* @param random
* @return * @return
*/ */
public List<PaperQuestionVO> queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO, boolean random) { public List<PaperQuestionVO> queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO) {
/*boolean isDefault = Project.isDefault(projectCode); /*boolean isDefault = Project.isDefault(projectCode);
List<Long> idList = null; List<Long> idList = null;
if(Objects.equals(false,isDefault)){ if(Objects.equals(false,isDefault)){
@ -186,7 +189,7 @@ public class PagerQuestionService {
* @param accountVO * @param accountVO
*/ */
public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO 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,"题库目前只支持单选,多选和判断"); this.checkQuestionType(questionVO,"题库目前只支持单选,多选和判断");
if (questionVO.isSelect() || questionVO.isJudge()) { if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO,"单选或判断题正确答案有且只有一个!"); this.checkQuestionTypeForSelectAndJudge(questionVO,"单选或判断题正确答案有且只有一个!");
@ -230,7 +233,7 @@ public class PagerQuestionService {
} }
@Transactional @Transactional
public void importProjectQuestion(List<PaperQuestionVO> questions, String projectCode, Long companyId, AccountVO accountVO) { public void importProjectQuestion(List<PaperQuestionVO> questions, Long companyId, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(companyId),"组织id不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(companyId),"组织id不能为空");
questions.forEach(questionVO -> { questions.forEach(questionVO -> {
String topic = questionVO.getQuestion(); String topic = questionVO.getQuestion();
@ -246,18 +249,19 @@ public class PagerQuestionService {
//默认项目导入题考虑是否有单位关联 //默认项目导入题考虑是否有单位关联
PaperQuestionExample example = new PaperQuestionExample(); PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria(); 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 -> { questions.forEach(questionVO -> {
questionVO.setProjectCode(projectCode); // questionVO.setProjectCode(projectCode);
PaperQuestionWithBLOBs question = questionVO.convert2DB(); PaperQuestionWithBLOBs question = questionVO.convert2DB();
// question.setProjectCode(null); // question.setProjectCode(null);
question.setCompanyId(companyId); question.setOrgId(companyId);
question.setCreateUserId(accountVO.getId()); question.setCreateUserId(accountVO.getId());
question.setCreateTime(LocalDateTime.now()); question.setCreateTime(LocalDateTime.now());
question.setCompanyId(companyId);
questionDAO.insert(question); questionDAO.insert(question);
}); });

View File

@ -19,39 +19,49 @@ public abstract class AbstractVoiceService implements IVoiceService2 {
private final MinioClientUtil voiceRecognitionUtil; private final MinioClientUtil voiceRecognitionUtil;
private final static String SYNTHESIS_FOLDER = "synthesis"; private final static String SYNTHESIS_FOLDER = "synthesis";
private final static String RECOGNITION_FOLDER = "recognition"; private final static String RECOGNITION_FOLDER = "recognition";
public AbstractVoiceService(MinioClientConfig minioClientConfig){ public AbstractVoiceService(MinioClientConfig minioClientConfig){
this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig,SYNTHESIS_FOLDER); this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig,SYNTHESIS_FOLDER);
this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig,RECOGNITION_FOLDER); this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig,RECOGNITION_FOLDER);
} }
/**
* 语音识别
* @param vo
* @return
*/
public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo){ public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo){
String fileName = String.format("%s.wav",System.currentTimeMillis()); String fileName = String.format("%s.wav",System.currentTimeMillis());
this.uploadFile(vo.getData(),fileName,RECOGNITION_FOLDER); this.uploadFile(voiceRecognitionUtil,vo.getData(),fileName,RECOGNITION_FOLDER);
String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName); String filePath = this.voiceRecognitionUtil.getDownLoadPath(fileName);
VoiceAsrResult voiceResult = this.recognition(vo); VoiceAsrResult voiceResult = this.recognition(vo);
return new VoiceRecognitionResult(filePath,voiceResult.getResult().get(0)); return new VoiceRecognitionResult(filePath,voiceResult.getResult().get(0));
} }
/**
* 语音合成
* @param vo
* @return
*/
public VoiceCompose synthesis(BaseVoiceSynthesisVO vo){ public VoiceCompose synthesis(BaseVoiceSynthesisVO vo){
String md5Code = vo.md5Code(); String md5Code = vo.md5Code();
String fileName = String.format("%s.wav",md5Code); String fileName = String.format("%s.wav",md5Code);
if(Objects.equals(false,this.voiceSynthesisUtil.checkFileIsExist(fileName))){ if(Objects.equals(false,this.voiceSynthesisUtil.checkFileIsExist(fileName))){
byte[] data = this.voiceSynthesis(vo); byte[] data = this.voiceSynthesis(vo);
this.uploadFile(data,fileName,SYNTHESIS_FOLDER); this.uploadFile(voiceSynthesisUtil,data,fileName,SYNTHESIS_FOLDER);
} }
String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName); String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName);
return new VoiceCompose(filePath,md5Code,vo.getMessage()); 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{ try{
this.voiceSynthesisUtil.uploadBytes(data,fileName); minioClient.uploadBytes(data,fileName);
}catch (SimulationException e){ }catch (SimulationException e){
log.error("文件上传失败 folder:{},文件名:{} errmsg:{}",folder,fileName,e.getMessage(),e); log.error("文件上传失败 folder:{},文件名:{} errmsg:{}",folder,fileName,e.getMessage(),e);
throw e; throw e;
} }
} }
} }

View File

@ -52,9 +52,9 @@ public class PaperQuestionVO implements Cloneable {
private String createUserName; private String createUserName;
private String projectCode; // private String projectCode;
private Long companyId; private Long orgId;
private String raceLable; private String tags;
private String questionAnswer; private String questionAnswer;
private String answer; private String answer;
@ -68,9 +68,9 @@ public class PaperQuestionVO implements Cloneable {
this.id = question.getId(); this.id = question.getId();
this.type = question.getType(); this.type = question.getType();
this.question = question.getQuestion(); this.question = question.getQuestion();
this.projectCode = question.getProjectCode(); // this.projectCode = question.getProjectCode();
this.companyId = question.getCompanyId(); this.orgId = question.getOrgId();
this.raceLable = question.getRaceLable(); this.tags = question.getTags();
this.optionList = JsonUtils.readCollection(question.getQuestionOption(),ArrayList.class, PaperQuestionOptionVO2.class); this.optionList = JsonUtils.readCollection(question.getQuestionOption(),ArrayList.class, PaperQuestionOptionVO2.class);
String dd = Objects.isNull(question.getQuestionAnswer()) ? "" : question.getQuestionAnswer(); String dd = Objects.isNull(question.getQuestionAnswer()) ? "" : question.getQuestionAnswer();
this.answer = dd; this.answer = dd;
@ -88,8 +88,8 @@ public class PaperQuestionVO implements Cloneable {
question.setId(this.id); question.setId(this.id);
question.setType(type); question.setType(type);
question.setQuestion(this.question); question.setQuestion(this.question);
question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode); // question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode);
question.setCompanyId(companyId); question.setOrgId(this.orgId);
this.setOptionId(question); this.setOptionId(question);
String dd = JsonUtils.writeValueAsString(this.optionList); String dd = JsonUtils.writeValueAsString(this.optionList);
@ -98,7 +98,7 @@ public class PaperQuestionVO implements Cloneable {
listMap.forEach(d->d.remove("correct")); listMap.forEach(d->d.remove("correct"));
question.setQuestionOption(JsonUtils.writeValueAsString(listMap)); question.setQuestionOption(JsonUtils.writeValueAsString(listMap));
question.setRaceLable(this.raceLable); question.setTags(this.tags);
question.setIsDel(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); question.setIsDel(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
// question.setQuestionAnswer(this.answer); // question.setQuestionAnswer(this.answer);
return question; return question;

View File

@ -13,6 +13,6 @@ public class QuestionQueryVO extends PageQueryVO {
private String type; private String type;
// private String projectCode; // private String projectCode;
private Long companyId; private Long orgId;
} }

View File

@ -4,7 +4,6 @@ import club.joylink.rtss.util.EncryptUtil;
import lombok.Data; import lombok.Data;
@Data @Data
public class BaseVoiceSynthesisVO { public class BaseVoiceSynthesisVO {
/** /**
* 消息 * 消息
@ -27,7 +26,7 @@ public class BaseVoiceSynthesisVO {
*/ */
private String per; private String per;
/** /**
* 是否启用默认参数 * 是否启用服务商的默认参数
*/ */
private boolean defaultParam = true; private boolean defaultParam = true;

View File

@ -10,7 +10,13 @@ import java.util.Base64;
@Data @Data
@Slf4j @Slf4j
public class VoiceRecognitionVO { public class VoiceRecognitionVO {
/**
* 文件二进制数据
*/
private byte[] data; private byte[] data;
/**
* 文件contentType
*/
private String fileContentType; private String fileContentType;
public VoiceRecognitionVO(byte[] data){ public VoiceRecognitionVO(byte[] data){
@ -23,17 +29,26 @@ public class VoiceRecognitionVO {
} }
/**
* 加载上传的文件
* @param file
* @return
*/
public static VoiceRecognitionVO load(MultipartFile file){ public static VoiceRecognitionVO load(MultipartFile file){
try { try {
VoiceRecognitionVO vo = new VoiceRecognitionVO(file.getBytes(),file.getContentType()); VoiceRecognitionVO vo = new VoiceRecognitionVO(file.getBytes(),file.getContentType());
return vo; return vo;
} catch (IOException e) { } 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); throw new RuntimeException(e);
} }
} }
/**
* 加载base64
* @param base64Str
* @return
*/
public static VoiceRecognitionVO load(String base64Str){ public static VoiceRecognitionVO load(String base64Str){
int index = base64Str.indexOf("base64,"); int index = base64Str.indexOf("base64,");
String base64 = base64Str.substring(index + "base64,".length()); String base64 = base64Str.substring(index + "base64,".length());