diff --git a/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java b/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java index 67d262d82..61ff7e9cb 100644 --- a/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java +++ b/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java @@ -31,4 +31,4 @@ public interface PaperCompositionDAO { int updateByPrimaryKeySelective(PaperComposition record); int updateByPrimaryKey(PaperComposition record); -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java b/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java index e2cf37f90..7a5fc9fb1 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java @@ -5,8 +5,8 @@ import java.time.LocalDateTime; import lombok.Data; /** - * @author - * + * @author + * */ @Data public class PaperComposition implements Serializable { @@ -26,9 +26,9 @@ public class PaperComposition implements Serializable { private String profile; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 启用起始时间 @@ -66,9 +66,9 @@ public class PaperComposition implements Serializable { private LocalDateTime updateTime; /** - * 试卷蓝图状态:1-正在编辑,2-封存(不能修改),3-已经被使用(不能修改删除) + * 试卷蓝图状态:1-正在编辑,2-封存(不能修改),3-已经被使用(不能修改删除);定于见PaperCompositionState */ private Integer state; private static final long serialVersionUID = 1L; -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java b/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java index e364da0a2..399256f4b 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java @@ -325,73 +325,73 @@ public class PaperCompositionExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andCompanyIdEqualTo(String value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andCompanyIdNotEqualTo(String value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andCompanyIdGreaterThan(String value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andCompanyIdGreaterThanOrEqualTo(String value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andCompanyIdLessThan(String value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andCompanyIdLessThanOrEqualTo(String value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andCompanyIdLike(String value) { + addCriterion("company_id like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andCompanyIdNotLike(String value) { + addCriterion("company_id not like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andCompanyIdBetween(String value1, String value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andCompanyIdNotBetween(String value1, String value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } @@ -970,4 +970,4 @@ public class PaperCompositionExample { this(condition, value, secondValue, null); } } -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java b/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java index 350678982..bb793ae03 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java @@ -30,7 +30,7 @@ public class PaperRule implements Serializable { private Integer subtype; /** - * 筛选题目的标签,即根据标签来筛选题目 + * 筛选题目的标签,即根据标签来筛选题目;List的json */ private String tags; diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java index 764838744..246a6623f 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java @@ -26,9 +26,9 @@ public class PaperUser implements Serializable { private Long pcId; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 用户最终得分 diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java index 9416d1ec7..519ecb62c 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java @@ -305,73 +305,73 @@ public class PaperUserExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andCompanyIdEqualTo(String value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andCompanyIdNotEqualTo(String value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andCompanyIdGreaterThan(String value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andCompanyIdGreaterThanOrEqualTo(String value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andCompanyIdLessThan(String value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andCompanyIdLessThanOrEqualTo(String value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andCompanyIdLike(String value) { + addCriterion("company_id like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andCompanyIdNotLike(String value) { + addCriterion("company_id not like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andCompanyIdBetween(String value1, String value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andCompanyIdNotBetween(String value1, String value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java index d966f7ecf..26715d391 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java @@ -20,9 +20,9 @@ public class PaperUserQuestion implements Serializable { private Long puId; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 试题类型:1-理论题,2-实训题 diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java index 984c9e4d3..4b4e3a415 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java @@ -244,73 +244,73 @@ public class PaperUserQuestionExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andCompanyIdEqualTo(String value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andCompanyIdNotEqualTo(String value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andCompanyIdGreaterThan(String value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andCompanyIdGreaterThanOrEqualTo(String value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andCompanyIdLessThan(String value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andCompanyIdLessThanOrEqualTo(String value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andCompanyIdLike(String value) { + addCriterion("company_id like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andCompanyIdNotLike(String value) { + addCriterion("company_id not like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andCompanyIdBetween(String value1, String value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andCompanyIdNotBetween(String value1, String value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java b/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java index 0e070c1f6..00d824a3a 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java @@ -37,12 +37,12 @@ public class PaperCompositionService { @Transactional(rollbackFor = Exception.class) public CreatePaperCompositionRspVo createPaperComposition(CreatePaperCompositionReqVo req, AccountVO user) { //根据项目和名称来查,如果存在则结束 - List pcList = this.findCompositionByProjectAndName(req.getProjectCode(), req.getName()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在:projectCode=" + req.getProjectCode() + " name=" + req.getName()); + List pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName()); // PaperComposition newPc = new PaperComposition(); newPc.setName(req.getName()); - newPc.setProjectCode(req.getProjectCode()); + newPc.setCompanyId(req.getCompanyId()); newPc.setProfile(req.getProfile()); newPc.setCreateTime(LocalDateTime.now()); newPc.setUpdateTime(LocalDateTime.now()); @@ -51,14 +51,14 @@ public class PaperCompositionService { int newRt = compositionDAO.insertSelective(newPc); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(newRt > 0, "存储试卷定义失败"); // - pcList = this.findCompositionByProjectAndName(req.getProjectCode(), req.getName()); + pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName()); newPc = pcList.get(0); // CreatePaperCompositionRspVo rsp = new CreatePaperCompositionRspVo(); rsp.setId(newPc.getId()); rsp.setName(newPc.getName()); rsp.setProfile(newPc.getProfile()); - rsp.setProjectCode(newPc.getProjectCode()); + rsp.setCompanyId(newPc.getCompanyId()); return rsp; } @@ -70,17 +70,17 @@ public class PaperCompositionService { PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId()); assertPaperCompositionCanModify(curPc); // - List pcList = this.findCompositionByProjectAndName(req.getProjectCode(), req.getName()); + List pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName()); if (!CollectionUtils.isEmpty(pcList)) { boolean exist = pcList.stream().anyMatch(c -> { return c.getId().compareTo(curPc.getId()) != 0; }); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(exist, "试卷定义已经存在:projectCode=" + req.getProjectCode() + " name=" + req.getName()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(exist, "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName()); } // curPc.setName(req.getName()); curPc.setProfile(req.getProfile()); - curPc.setProjectCode(req.getProjectCode()); + curPc.setCompanyId(req.getCompanyId()); curPc.setUpdateTime(LocalDateTime.now()); compositionDAO.updateByPrimaryKeySelective(curPc); } @@ -193,11 +193,11 @@ public class PaperCompositionService { pcExCriteria.andNameEqualTo(req.getName()); } } - if (null != req.getProjectCode()) { + if (null != req.getCompanyId()) { if (req.getProjectCodeLike()) { - pcExCriteria.andProjectCodeLike(req.getProjectCode()); + pcExCriteria.andCompanyIdLike(String.format("%%%s%%",req.getCompanyId())); } else { - pcExCriteria.andProjectCodeEqualTo(req.getProjectCode()); + pcExCriteria.andCompanyIdEqualTo(req.getCompanyId()); } } if (null != req.getProfile()) { @@ -272,9 +272,9 @@ public class PaperCompositionService { * 根据试卷蓝图的项目和名称查找项目 */ @Transactional(readOnly = true) - public List findCompositionByProjectAndName(String projectCode, String name) { + public List findCompositionByCompanyIdAndName(String companyId, String name) { PaperCompositionExample example = new PaperCompositionExample(); - example.createCriteria().andProjectCodeEqualTo(projectCode).andNameEqualTo(name); + example.createCriteria().andCompanyIdEqualTo(companyId).andNameEqualTo(name); List list = compositionDAO.selectByExample(example); return list; } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java index c658745b6..f24d55af6 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java @@ -11,6 +11,7 @@ import club.joylink.rtss.entity.paper.question.PaperQuestionExample; import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.entity.training2.PublishedTraining2Example; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.paper.CreatePaperRspVo; import club.joylink.rtss.vo.paper.PaperCompositionState; @@ -67,14 +68,14 @@ public class PaperUserCreateService { List ruleList = compositionService.findRuleByPcId(pcId); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(ruleList, "试卷定义没有规则定义,无法生成用户试卷,pcId = " + pcId); // - String projectCode = composition.getProjectCode(); + String companyId = composition.getCompanyId(); // 标记封存的试卷蓝图已使用 compositionService.usePaperComposition(pcId); // 创建用户试卷 PaperUser paper = new PaperUser(); paper.setUserId(user.getId()); paper.setPcId(pcId); - paper.setProjectCode(projectCode); + paper.setCompanyId(companyId); paper.setCreateTime(LocalDateTime.now()); paperUserDAO.insertSelective(paper); paper = paperUserService.findByUserIdAndPcId(user.getId(), pcId); @@ -83,7 +84,7 @@ public class PaperUserCreateService { // CreatePaperRspVo rsp = new CreatePaperRspVo(); rsp.setPaperName(composition.getName()); - rsp.setProjectCode(projectCode); + rsp.setCompanyId(companyId); rsp.setId(paper.getId()); return rsp; } @@ -99,7 +100,7 @@ public class PaperUserCreateService { this.dispatcherCommonQuestion(pu, pc, rule); break; case Training: - this.dispatcherTrainingQuestion(pu,pc,rule); + this.dispatcherTrainingQuestion(pu, pc, rule); break; } }); @@ -115,7 +116,7 @@ public class PaperUserCreateService { //符合条件的题目数目 long count = questionDAO.countByExample(questionExample); PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " projectCode = " + pc.getProjectCode() + " ruleType = " + subType.name() + " ruleSum = " + qSum); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum); //引入随机数 //每页记录数 final int pageSize = 5; @@ -154,7 +155,7 @@ public class PaperUserCreateService { PaperUserQuestion puq = new PaperUserQuestion(); puq.setState(PaperQuestionState.Undo.getValue()); puq.setPuId(pu.getId()); - puq.setProjectCode(pc.getProjectCode()); + puq.setCompanyId(pc.getCompanyId()); puq.setType(PaperQType.GroupType.getItem(rule.getType()).getValue()); puq.setQuestionId(q.getId()); paperUserQuestionDAO.insertSelective(puq); @@ -171,7 +172,7 @@ public class PaperUserCreateService { //符合条件的题目数目 long count = trainingDAO.countByExample(questionExample); PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的实训题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " projectCode = " + pc.getProjectCode() + " ruleType = " + subType.name() + " ruleSum = " + qSum); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的实训题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum); //引入随机数 //每页记录数 final int pageSize = 5; @@ -210,18 +211,19 @@ public class PaperUserCreateService { PaperUserQuestion puq = new PaperUserQuestion(); puq.setState(PaperQuestionState.Undo.getValue()); puq.setPuId(pu.getId()); - puq.setProjectCode(pc.getProjectCode()); + puq.setCompanyId(pc.getCompanyId()); puq.setType(PaperQType.GroupType.getItem(rule.getType()).getValue()); puq.setQuestionId(q.getId()); paperUserQuestionDAO.insertSelective(puq); }); } + /** * 生成根据tag查询的条件 */ private PublishedTraining2Example trainingQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule, Boolean isGreaterThan, Long id) { - String tags = rule.getTags();//规则标签,逗号分隔 - String[] tagArray = null != tags && tags.length() > 0 ? tags.split(",") : null; + String tags = rule.getTags();//规则标签,list json + List tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null; PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); // PublishedTraining2Example questionExample = new PublishedTraining2Example(); @@ -248,17 +250,18 @@ public class PaperUserCreateService { } return questionExample; } + /** * 生成根据tag查询的条件 */ private PaperQuestionExample commonQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule, Boolean isGreaterThan, Long id) { - String tags = rule.getTags();//规则标签,逗号分隔 - String[] tagArray = null != tags && tags.length() > 0 ? tags.split(",") : null; + String tags = rule.getTags();//规则标签,list json + List tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null; PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); // PaperQuestionExample questionExample = new PaperQuestionExample(); if (null == tagArray) { - PaperQuestionExample.Criteria c = questionExample.createCriteria().andProjectCodeEqualTo(pc.getProjectCode()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0); + PaperQuestionExample.Criteria c = questionExample.createCriteria().andProjectCodeEqualTo(pc.getCompanyId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0); if (null != isGreaterThan && null != id) { if (isGreaterThan) { c.andIdGreaterThan(id); @@ -268,7 +271,7 @@ public class PaperUserCreateService { } } else { for (String tag : tagArray) { - PaperQuestionExample.Criteria c = questionExample.or().andProjectCodeEqualTo(pc.getProjectCode()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andRaceLableLike(String.format("%%%s%%", tag)); + PaperQuestionExample.Criteria c = questionExample.or().andProjectCodeEqualTo(pc.getCompanyId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andRaceLableLike(String.format("%%%s%%", tag)); if (null != isGreaterThan && null != id) { if (isGreaterThan) { c.andIdGreaterThan(id); 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 a13ed5955..441017813 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java @@ -128,7 +128,7 @@ public class PaperUserService { PaperSubmitRspVo rsp = new PaperSubmitRspVo(); rsp.setPuId(puId); rsp.setName(composition.getName()); - rsp.setProjectCode(composition.getProjectCode()); + rsp.setCompanyId(composition.getCompanyId()); rsp.setDuration(paperTime); rsp.setScore(scoreCommon + scoreTraining); rsp.setCommonScore(scoreCommon); diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java index 0f1f2ca10..43975f765 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java @@ -18,8 +18,8 @@ public class CreatePaperCompositionReqVo { private String profile; /** - * 项目code + * 组织id */ @NotNull - private String projectCode; + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java index 0e1589735..8bcec04fe 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java @@ -22,7 +22,7 @@ public class CreatePaperCompositionRspVo { private String profile; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java index 22872a9d4..bbd99e4e0 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java @@ -18,9 +18,9 @@ public class CreatePaperRspVo { @JsonSerialize(using = ToStringSerializer.class) private Long id; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 试卷名称 */ diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java index 21ce929cc..03d33bb7a 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java @@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; @Data public class CreatePaperRuleReqVo { @@ -28,7 +30,7 @@ public class CreatePaperRuleReqVo { /** * 筛选题目的标签,即根据标签来筛选题目 */ - private String tags; + private List tags; /** * 该类型题目数量 diff --git a/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java index adf39ba4f..99c059fa1 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java @@ -32,10 +32,10 @@ public class FindPaperCompositionPageReqVo extends PageQueryVO { */ private Boolean nameLike = true; /** - * 项目code
+ * 组织id
* 选填
*/ - private String projectCode; + private String companyId; /** * 项目code--是否模糊查询,默认false
* 选填
diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java index 89a8f66da..44d9828e5 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java @@ -25,7 +25,7 @@ public class PaperCompositionBasicVo { private String profile; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java index b70098dbb..6073e8892 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.List; @Data public class PaperRuleVo { @@ -35,7 +36,7 @@ public class PaperRuleVo { /** * 筛选题目的标签,即根据标签来筛选题目 */ - private String tags; + private List tags; /** * 该类型题目数量 diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java index 4627dad98..5b1d3a5cb 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java @@ -23,9 +23,9 @@ public class PaperSubmitRspVo { */ private String name; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 及格分 */ diff --git a/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java b/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java index c06d10bd8..da2daa72d 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java +++ b/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java @@ -1,40 +1,54 @@ package club.joylink.rtss.vo.paper.convertor; import club.joylink.rtss.entity.paper.PaperRule; +import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.paper.CreatePaperRuleReqVo; import club.joylink.rtss.vo.paper.PaperQType; import club.joylink.rtss.vo.paper.PaperRuleVo; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; public class PaperRuleConvertor { - public static PaperRuleVo convert(PaperRule from){ + public static PaperRuleVo convert(PaperRule from) { PaperRuleVo to = new PaperRuleVo(); to.setId(from.getId()); to.setPcId(from.getPcId()); to.setType(PaperQType.GroupType.getItem(from.getType())); to.setSubtype(PaperQType.SubType.getItem(from.getSubtype())); - to.setTags(from.getTags()); + to.setTags(JsonUtils.readCollection(from.getTags(),ArrayList.class,String.class)); to.setScore(from.getScore()); to.setSum(from.getSum()); return to; } - public static PaperRule convert(PaperRuleVo from){ + + public static PaperRule convert(PaperRuleVo from) { PaperRule to = new PaperRule(); to.setId(from.getId()); to.setPcId(from.getPcId()); to.setType(from.getType().getValue()); to.setSubtype(from.getSubtype().getValue()); - to.setTags(from.getTags()); + if (!CollectionUtils.isEmpty(from.getTags())) { + to.setTags(JsonUtils.writeValueAsString(from.getTags())); + } else { + to.setTags(JsonUtils.writeValueAsString(new ArrayList())); + } to.setScore(from.getScore()); to.setSum(from.getSum()); return to; } - public static PaperRule convert(CreatePaperRuleReqVo from){ + + public static PaperRule convert(CreatePaperRuleReqVo from) { PaperRule to = new PaperRule(); to.setPcId(from.getPcId()); to.setType(from.getType().getValue()); to.setSubtype(from.getSubtype().getValue()); - to.setTags(from.getTags()); + if (!CollectionUtils.isEmpty(from.getTags())) { + to.setTags(JsonUtils.writeValueAsString(from.getTags())); + } else { + to.setTags(JsonUtils.writeValueAsString(new ArrayList())); + } to.setScore(from.getScore()); to.setSum(from.getSum()); return to; diff --git a/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml b/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml index 04be99f98..66d2134da 100644 --- a/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml +++ b/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml @@ -5,7 +5,7 @@ - + @@ -74,7 +74,7 @@ - id, `name`, profile, project_code, start_time, end_time, valid_duration, pass_score, + id, `name`, profile, company_id, start_time, end_time, valid_duration, pass_score, creator_id, create_time, update_time, `state` select @@ -113,11 +113,11 @@ insert into paper_user (id, user_id, pc_id, - project_code, score, start_time, + company_id, score, start_time, end_time, cause, create_time ) values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{pcId,jdbcType=BIGINT}, - #{projectCode,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, + #{companyId,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{cause,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP} ) @@ -133,8 +133,8 @@ pc_id, - - project_code, + + company_id, score, @@ -162,8 +162,8 @@ #{pcId,jdbcType=BIGINT}, - - #{projectCode,jdbcType=VARCHAR}, + + #{companyId,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, @@ -200,8 +200,8 @@ pc_id = #{record.pcId,jdbcType=BIGINT}, - - project_code = #{record.projectCode,jdbcType=VARCHAR}, + + company_id = #{record.companyId,jdbcType=VARCHAR}, score = #{record.score,jdbcType=INTEGER}, @@ -228,7 +228,7 @@ set id = #{record.id,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT}, pc_id = #{record.pcId,jdbcType=BIGINT}, - project_code = #{record.projectCode,jdbcType=VARCHAR}, + company_id = #{record.companyId,jdbcType=VARCHAR}, score = #{record.score,jdbcType=INTEGER}, start_time = #{record.startTime,jdbcType=TIMESTAMP}, end_time = #{record.endTime,jdbcType=TIMESTAMP}, @@ -247,8 +247,8 @@ pc_id = #{pcId,jdbcType=BIGINT}, - - project_code = #{projectCode,jdbcType=VARCHAR}, + + company_id = #{companyId,jdbcType=VARCHAR}, score = #{score,jdbcType=INTEGER}, @@ -272,7 +272,7 @@ update paper_user set user_id = #{userId,jdbcType=BIGINT}, pc_id = #{pcId,jdbcType=BIGINT}, - project_code = #{projectCode,jdbcType=VARCHAR}, + company_id = #{companyId,jdbcType=VARCHAR}, score = #{score,jdbcType=INTEGER}, start_time = #{startTime,jdbcType=TIMESTAMP}, end_time = #{endTime,jdbcType=TIMESTAMP}, diff --git a/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml b/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml index 118f0341b..6132aa104 100644 --- a/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml +++ b/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml @@ -4,7 +4,7 @@ - + @@ -68,7 +68,7 @@ - id, pu_id, project_code, `type`, question_id, `state` + id, pu_id, company_id, `type`, question_id, `state`