This commit is contained in:
DU 2021-03-30 09:38:39 +08:00
commit e757d5c50e
44 changed files with 1092 additions and 734 deletions

26
sql/20210326-zhangsai.sql Normal file
View File

@ -0,0 +1,26 @@
alter table exam_definition modify lesson_id bigint null comment '所属课程ID',
add map_id bigint not null comment '地图id' after id;
-- 更新exam_definition的map_id字段
UPDATE exam_definition SET map_id =( SELECT map_id FROM ls_lesson WHERE exam_definition.lesson_id = ls_lesson.id)
-- 更新exam_definition的type字段
UPDATE exam_definition SET type =( SELECT prd_type FROM ls_lesson WHERE exam_definition.lesson_id = ls_lesson.id)
alter table org_exam
modify org_id bigint not null,
add creator_id bigint not null,
add create_time datetime not null;
ALTER TABLE `org_exam`
ADD COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT FIRST ,
ADD PRIMARY KEY (`id`);
-- org_lesson表添加主键
ALTER TABLE `org_lesson`
ADD COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT FIRST ,
ADD PRIMARY KEY (`id`);

View File

@ -3,10 +3,7 @@ package club.joylink.rtss.controller;
import club.joylink.rtss.constants.RoleEnum;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.services.org.IOrgLessonService;
import club.joylink.rtss.services.org.IOrgScoringRuleService;
import club.joylink.rtss.services.org.IOrgService;
import club.joylink.rtss.services.org.IOrgUserService;
import club.joylink.rtss.services.org.*;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.LessonVO;
@ -39,6 +36,9 @@ public class OrgController {
@Autowired
private IOrgScoringRuleService iOrgScoringRuleService;
@Autowired
private IOrgExamService iOrgExamService;
@ApiOperation(value = "创建顶级组织")
@PostMapping
public CompanyVO create(@RequestBody @Validated CompanyVO company, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) UserVO user) {
@ -183,15 +183,15 @@ public class OrgController {
iOrgService.createCls(createVO, loginInfo);
}
@ApiOperation("分页查询班级")
@ApiOperation("分页查询当前登录项目所属组织下的班级")
@GetMapping("/paged/cls")
public PageVO<DepartmentVO> pagedQuerySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgService.pagedQueryCls(queryVO, loginInfo);
}
@ApiOperation("查询班级")
@ApiOperation("查询当前登录项目所属组织下的班级")
@GetMapping("/list/cls")
public List<DepartmentVO> querySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
public List<DepartmentVO> queryCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgService.queryCls(queryVO, loginInfo);
}
@ -241,8 +241,8 @@ public class OrgController {
@ApiOperation("查询规则能够应用到的组织")
@GetMapping("/orgScoringRule/{ruleId}/canApplyTo")
public List<DepartmentVO> queryRuleCanApplyTo(@PathVariable Long ruleId) {
return iOrgScoringRuleService.queryRuleCanApplyTo(ruleId);
public List<DepartmentVO> queryRuleCanApplyTo(@PathVariable Long ruleId, @RequestAttribute UserVO user) {
return iOrgScoringRuleService.queryRuleCanApplyTo(ruleId, user);
}
@ApiOperation("将评价规则应用到")
@ -257,4 +257,17 @@ public class OrgController {
public PageVO<DepartmentVO> adminPagedQueryOrg(OrgQueryVO queryVO) {
return iOrgService.adminPagedQueryOrg(queryVO);
}
@ApiOperation("给班级安排考试")
@PostMapping("/orgExam/{clsId}")
public void createOrgExam(@PathVariable Long clsId, @RequestBody List<Long> examIds, @RequestAttribute UserVO user) {
iOrgExamService.create(clsId, examIds, user);
}
@ApiOperation("查询班级安排的考试id")
@GetMapping("/orgExam/{clsId}/list")
public List<String> queryOrgExam(@PathVariable Long clsId, @RequestAttribute UserVO user) {
return iOrgExamService.queryOrgExam(clsId, user);
}
}

View File

@ -7,7 +7,6 @@ import club.joylink.rtss.vo.client.ExamDefinitionQueryVO;
import club.joylink.rtss.vo.client.ExamDefinitionVO;
import club.joylink.rtss.vo.client.ExamsLessonVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.validGroup.ExamDefinitionCheck;
import club.joylink.rtss.vo.client.validGroup.ExamDefinitionRulesCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,30 +26,17 @@ public class ExamController {
@ApiOperation(value = "创建考试")
@PostMapping(path = "")
public void create(@RequestBody @Validated(value = {ExamDefinitionCheck.class, ExamDefinitionRulesCheck.class})
ExamDefinitionVO examDefinitionVO, @RequestAttribute @ApiIgnore UserVO user) {
public void create(@RequestBody @Validated ExamDefinitionVO examDefinitionVO, @RequestAttribute @ApiIgnore UserVO user) {
iExamService.create(examDefinitionVO, user);
}
// @ApiOperation(value = "贵装备创建考试")
// @PostMapping(path = "/project/GZB")
// public void createGZBExam(@RequestBody @Validated(value = {ExamDefinitionCheck.class, ExamDefinitionRulesCheck.class})
// ExamDefinitionVO examDefinitionVO, @RequestAttribute @ApiIgnore UserVO user) {
// iExamService.createGZBExam(examDefinitionVO, user);
// }
@ApiOperation(value = "检查分数是否合理")
@GetMapping(path = "/checkScore")
public boolean checkScore(@Validated(value = ExamDefinitionRulesCheck.class) ExamDefinitionVO examDefinitionVO) {
return iExamService.checkScore(examDefinitionVO);
}
// @ApiOperation(value = "查询课程下的章节信息")
// @GetMapping(path = "/{lessonId}/chapter")
// public CommonJsonResponse queryChapterInfo(@PathVariable(required = true) String lessonId) {
// return CommonJsonResponse.newSuccessResponse(iExamService.queryChapterInfo(lessonId));
// }
@Deprecated
@ApiOperation(value = "查询课程所属产品下有实训的实训类型")
@GetMapping(path = "/{lessonId}/trainingTypes")
public List<String> queryTrainingTypes(@PathVariable Long lessonId) {
@ -77,17 +63,10 @@ public class ExamController {
@ApiOperation(value = "删除试题")
@DeleteMapping(path = "/{id}")
public void deleteExam(@PathVariable String id, @ApiIgnore @RequestAttribute UserVO user) {
public void deleteExam(@PathVariable Long id, @ApiIgnore @RequestAttribute UserVO user) {
iExamService.deleteExam(id, user);
}
// @ApiOperation(value = "查询章节下允许创建的最多题目数量")
// @GetMapping(path = "/trainingNum/{lessonId}/{chapterId}")
// public CommonJsonResponse queryTrainingNum(@PathVariable(required = true) String lessonId, @PathVariable(required = true) String chapterId) {
// int trainingNum = iExamService.queryTrainingNum(lessonId, chapterId);
// return CommonJsonResponse.newSuccessResponse(trainingNum);
// }
@ApiOperation(value = "根据课程和实训类型查询实训数量")
@GetMapping(path = "/trainingNum/{lessonId}/{trainingType}")
public Long queryTrainingNum(@PathVariable Long lessonId, @PathVariable String trainingType, String operateType) {
@ -118,7 +97,7 @@ public class ExamController {
return this.iExamService.pagedQueryByLoginProject(queryVO, loginInfo);
}
@ApiOperation(value = "不分页查询当前登录项目下自己创建的试卷")
@ApiOperation(value = "不分页查询当前登录项目下的试卷")
@GetMapping("/list/loginProject")
public List<ExamDefinitionVO> listQueryExamByLoginProject(ExamDefinitionQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return this.iExamService.listQueryExamByLoginProject(queryVO, loginInfo);
@ -129,4 +108,10 @@ public class ExamController {
public List<ExamDefinitionVO> listQueryOrgExamOfSelf(Long clsId, @RequestAttribute LoginUserInfoVO loginInfo) {
return this.iExamService.listQueryOrgExamICreated(clsId, loginInfo);
}
@ApiOperation("查询试卷")
@GetMapping("/list/{mapId}")
public List<ExamDefinitionVO> listQuery(@PathVariable Long mapId, String prdType) {
return iExamService.queryBasicInfo(mapId, prdType);
}
}

View File

@ -61,12 +61,6 @@ public class LessonController {
return this.iOrgUserService.getLessonsByDepart(departId);
}
@ApiOperation(value = "根据课程获取关联班级信息列表")
@GetMapping(path = "/{lessonId}/departs")
public List<DepartmentVO> queryClassByLesson(@PathVariable Long lessonId) {
return this.iOrgUserService.getDepartsByLesson(lessonId);
}
@ApiOperation(value = "获取课程列表")
@GetMapping(path = "/listOfMap")
public List<LessonVO> queryLessonsOfMap(Long mapId) {

View File

@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.constraints.NotBlank;
import java.util.Map;
import java.util.Set;
@Api(tags = { "实训数据管理接口" })
@ -195,4 +196,10 @@ public class TrainingV1Controller {
public TrainingNewVO loadTraining(@PathVariable String group, @PathVariable Long id) {
return iTrainingService.loadTraining(group, id);
}
@ApiOperation("查询实训、操作类型及数量")
@GetMapping("/trainingTypeAndQuantity")
public Map<String, Map<String, Long>> queryTrainingTypeAndQuantity(Long mapId, String prdType) {
return iTrainingService.queryTrainingTypeAndQuantity(mapId, prdType);
}
}

View File

@ -2,11 +2,15 @@ package club.joylink.rtss.dao;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.OrgExample;
import club.joylink.rtss.vo.client.ExamDefinitionVO;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* OrgDAO继承基类
*/
@Repository
public interface OrgDAO extends MyBatisBaseDao<Org, Long, OrgExample> {
}
List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status);
}

View File

@ -14,20 +14,13 @@ import java.util.List;
*/
@Repository
public interface OrgLessonDAO extends MyBatisBaseDao<OrgLesson, OrgLesson, OrgLessonExample> {
@Select("<script>" +
"SELECT cd.* " +
"FROM org cd INNER JOIN org_lesson dl " +
"ON cd.id = dl.org_id " +
"AND lesson_id = #{lessonId} " +
"</script>")
List<Org> getDeparts(@Param("lessonId") Long lessonId);
@Select("<script>" +
"SELECT `name` " +
"SELECT org.`name` " +
"FROM org " +
"INNER JOIN org_lesson " +
"ON id = org_id " +
"AND lesson_id = #{lessonId} " +
"ON org.id = org_lesson.org_id " +
"AND org_lesson.lesson_id = #{lessonId} " +
"</script>")
List<String> getClassNames(@Param("lessonId") Long lessonId);
}

View File

@ -4,12 +4,17 @@ import java.io.Serializable;
import java.time.LocalDateTime;
/**
* exam_definition
* @author
* 考试定义表
*/
public class ExamDefinition implements Serializable {
private Long id;
/**
* 地图id
*/
private Long mapId;
/**
* 所属课程ID
*/
@ -85,6 +90,14 @@ public class ExamDefinition implements Serializable {
this.id = id;
}
public Long getMapId() {
return mapId;
}
public void setMapId(Long mapId) {
this.mapId = mapId;
}
public Long getLessonId() {
return lessonId;
}
@ -202,6 +215,7 @@ public class ExamDefinition implements Serializable {
}
ExamDefinition other = (ExamDefinition) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId()))
&& (this.getLessonId() == null ? other.getLessonId() == null : this.getLessonId().equals(other.getLessonId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
@ -222,6 +236,7 @@ public class ExamDefinition implements Serializable {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode());
result = prime * result + ((getLessonId() == null) ? 0 : getLessonId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
@ -245,6 +260,7 @@ public class ExamDefinition implements Serializable {
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", mapId=").append(mapId);
sb.append(", lessonId=").append(lessonId);
sb.append(", name=").append(name);
sb.append(", type=").append(type);

View File

@ -185,6 +185,66 @@ public class ExamDefinitionExample {
return (Criteria) this;
}
public Criteria andMapIdIsNull() {
addCriterion("map_id is null");
return (Criteria) this;
}
public Criteria andMapIdIsNotNull() {
addCriterion("map_id is not null");
return (Criteria) this;
}
public Criteria andMapIdEqualTo(Long value) {
addCriterion("map_id =", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotEqualTo(Long value) {
addCriterion("map_id <>", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThan(Long value) {
addCriterion("map_id >", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThanOrEqualTo(Long value) {
addCriterion("map_id >=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThan(Long value) {
addCriterion("map_id <", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThanOrEqualTo(Long value) {
addCriterion("map_id <=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdIn(List<Long> values) {
addCriterion("map_id in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotIn(List<Long> values) {
addCriterion("map_id not in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdBetween(Long value1, Long value2) {
addCriterion("map_id between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotBetween(Long value1, Long value2) {
addCriterion("map_id not between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andLessonIdIsNull() {
addCriterion("lesson_id is null");
return (Criteria) this;

View File

@ -1,18 +1,33 @@
package club.joylink.rtss.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* org_exam
* @author
* @author
* 学生的试卷和班级关系
*/
public class OrgExam implements Serializable {
private Long id;
private Long examId;
private Long orgId;
private Long creatorId;
private LocalDateTime createTime;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getExamId() {
return examId;
}
@ -29,6 +44,22 @@ public class OrgExam implements Serializable {
this.orgId = orgId;
}
public Long getCreatorId() {
return creatorId;
}
public void setCreatorId(Long creatorId) {
this.creatorId = creatorId;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
@Override
public boolean equals(Object that) {
if (this == that) {
@ -41,16 +72,22 @@ public class OrgExam implements Serializable {
return false;
}
OrgExam other = (OrgExam) that;
return (this.getExamId() == null ? other.getExamId() == null : this.getExamId().equals(other.getExamId()))
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()));
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getExamId() == null ? other.getExamId() == null : this.getExamId().equals(other.getExamId()))
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
&& (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getExamId() == null) ? 0 : getExamId().hashCode());
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
return result;
}
@ -60,10 +97,13 @@ public class OrgExam implements Serializable {
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", examId=").append(examId);
sb.append(", orgId=").append(orgId);
sb.append(", creatorId=").append(creatorId);
sb.append(", createTime=").append(createTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.entity;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -124,6 +125,66 @@ public class OrgExamExample {
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andExamIdIsNull() {
addCriterion("exam_id is null");
return (Criteria) this;
@ -194,55 +255,175 @@ public class OrgExamExample {
return (Criteria) this;
}
public Criteria andOrgIdEqualTo(Integer value) {
public Criteria andOrgIdEqualTo(Long value) {
addCriterion("org_id =", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdNotEqualTo(Integer value) {
public Criteria andOrgIdNotEqualTo(Long value) {
addCriterion("org_id <>", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdGreaterThan(Integer value) {
public Criteria andOrgIdGreaterThan(Long value) {
addCriterion("org_id >", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdGreaterThanOrEqualTo(Integer value) {
public Criteria andOrgIdGreaterThanOrEqualTo(Long value) {
addCriterion("org_id >=", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdLessThan(Integer value) {
public Criteria andOrgIdLessThan(Long value) {
addCriterion("org_id <", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdLessThanOrEqualTo(Integer value) {
public Criteria andOrgIdLessThanOrEqualTo(Long value) {
addCriterion("org_id <=", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdIn(List<Integer> values) {
public Criteria andOrgIdIn(List<Long> values) {
addCriterion("org_id in", values, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdNotIn(List<Integer> values) {
public Criteria andOrgIdNotIn(List<Long> values) {
addCriterion("org_id not in", values, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdBetween(Integer value1, Integer value2) {
public Criteria andOrgIdBetween(Long value1, Long value2) {
addCriterion("org_id between", value1, value2, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdNotBetween(Integer value1, Integer value2) {
public Criteria andOrgIdNotBetween(Long value1, Long value2) {
addCriterion("org_id not between", value1, value2, "orgId");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;
}
public Criteria andCreatorIdIsNotNull() {
addCriterion("creator_id is not null");
return (Criteria) this;
}
public Criteria andCreatorIdEqualTo(Long value) {
addCriterion("creator_id =", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotEqualTo(Long value) {
addCriterion("creator_id <>", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThan(Long value) {
addCriterion("creator_id >", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
addCriterion("creator_id >=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThan(Long value) {
addCriterion("creator_id <", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
addCriterion("creator_id <=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdIn(List<Long> values) {
addCriterion("creator_id in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotIn(List<Long> values) {
addCriterion("creator_id not in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdBetween(Long value1, Long value2) {
addCriterion("creator_id between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
addCriterion("creator_id not between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(LocalDateTime value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(LocalDateTime value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(LocalDateTime value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(LocalDateTime value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<LocalDateTime> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<LocalDateTime> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
}
/**

View File

@ -8,6 +8,8 @@ import java.time.LocalDateTime;
* 班级课程表
*/
public class OrgLesson implements Serializable {
private Long id;
/**
* 课程id
*/
@ -30,6 +32,14 @@ public class OrgLesson implements Serializable {
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getLessonId() {
return lessonId;
}
@ -74,7 +84,8 @@ public class OrgLesson implements Serializable {
return false;
}
OrgLesson other = (OrgLesson) that;
return (this.getLessonId() == null ? other.getLessonId() == null : this.getLessonId().equals(other.getLessonId()))
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getLessonId() == null ? other.getLessonId() == null : this.getLessonId().equals(other.getLessonId()))
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
&& (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
@ -84,6 +95,7 @@ public class OrgLesson implements Serializable {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getLessonId() == null) ? 0 : getLessonId().hashCode());
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
@ -97,6 +109,7 @@ public class OrgLesson implements Serializable {
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", lessonId=").append(lessonId);
sb.append(", orgId=").append(orgId);
sb.append(", creatorId=").append(creatorId);

View File

@ -125,6 +125,66 @@ public class OrgLessonExample {
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andLessonIdIsNull() {
addCriterion("lesson_id is null");
return (Criteria) this;

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.*;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.org.IOrgExamService;
import club.joylink.rtss.services.org.IOrgLessonService;
import club.joylink.rtss.services.org.IOrgService;
import club.joylink.rtss.services.org.IOrgUserService;
@ -11,18 +12,17 @@ import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.*;
import club.joylink.rtss.vo.client.org.DepartmentVO;
import club.joylink.rtss.vo.client.map.MapVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -71,31 +71,28 @@ public class ExamService implements IExamService {
@Autowired
private IOrgLessonService iOrgLessonService;
@Autowired
private IOrgExamService iOrgExamService;
/**
* 创建考试定义
*/
@Override
public void create(ExamDefinitionVO examDefinitionVO, UserVO userVO) {
examDefinitionVO.setCreatorId(userVO.getId());
//检查分数是否合理
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(checkScore(examDefinitionVO));
//检查考试名称和考试规则是否唯一
checkName(examDefinitionVO);
//检查考试名称是否唯一
confirmNameUnique(null, examDefinitionVO.getMapId(), examDefinitionVO.getPrdType(), examDefinitionVO.getName(), BusinessConsts.STATUS_USE);
//插入考试定义表数据
ExamDefinition examDefinition = examDefinitionVO.toDB();
examDefinition.setCreatorId(userVO.getId());
examDefinition.setCreateTime(LocalDateTime.now());
examDefinition.setStatus(BusinessConsts.STATUS_USE);
// 判断是否是管理员并设置试用
if (this.iSysUserService.isAdmin(userVO) && examDefinitionVO.getTrial()) {
examDefinition.setTrial(true);
} else {
examDefinition.setTrial(false);
}
examDefinitionDAO.insert(examDefinition);
//插入试卷班级关系
if (!CollectionUtils.isEmpty(examDefinitionVO.getClasses())) {
examDefinitionVO.getClasses().forEach(departmentVO -> iOrgUserService.addDepartExam(examDefinition.getId(), departmentVO.getId()));
}
// //插入试卷班级关系
// if (!CollectionUtils.isEmpty(examDefinitionVO.getClasses())) {
// examDefinitionVO.getClasses().forEach(departmentVO -> iOrgUserService.addDepartExam(examDefinition.getId(), departmentVO.getId()));
// }
//插入试题规则表数据
List<ExamDefinitionRulesVO> examDefinitionRulesVOList = examDefinitionVO.getExamDefinitionRulesVOList();
examDefinitionRulesVOList.forEach(examDefinitionRulesVO -> {
@ -105,94 +102,25 @@ public class ExamService implements IExamService {
});
}
private void checkExam(ExamDefinitionVO examDefinitionVO) {
//一个课程下考试名称查重
ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
examDefinitionExample.createCriteria().andLessonIdEqualTo(examDefinitionVO.getLessonId()).andNameEqualTo(examDefinitionVO.getName());
List<ExamDefinition> examDefinitionList = examDefinitionDAO.selectByExample(examDefinitionExample);
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertCollectionEmpty(examDefinitionList);
//考试规则查重
//查询已创建的考试规则数据
int rulesNum = examDefinitionVO.getExamDefinitionRulesVOList().stream().map(ExamDefinitionRulesVO::getNum).reduce(Integer::sum).orElse(0);
List<Long> examIdList = examDefinitionDAO.selectByRulesNumAndFullPoint(rulesNum, examDefinitionVO.getFullPoint(), examDefinitionVO.getLessonId());
if (!CollectionUtils.isEmpty(examIdList)) {
//处理待校验数据
Map<String, List<ExamDefinitionRulesVO>> trainingTypeMap = examDefinitionVO.getExamDefinitionRulesVOList()
.stream().collect(Collectors.groupingBy(ExamDefinitionRulesVO::getTrainingType));
for (Long examId : examIdList) {
ExamDefinitionRulesExample examDefinitionRulesExample = new ExamDefinitionRulesExample();
examDefinitionRulesExample.createCriteria().andExamIdEqualTo(examId);
List<ExamDefinitionRules> examDefinitionRulesList = definitionRulesDAO.selectByExample(examDefinitionRulesExample);
Map<String, List<ExamDefinitionRulesVO>> existTrainingTypeMap = ExamDefinitionRulesVO.convert2VOList(examDefinitionRulesList)
.stream().collect(Collectors.groupingBy(ExamDefinitionRulesVO::getTrainingType));
//检查dataMap和map数据是否一样
trainingTypeLoop:
for (Entry<String, List<ExamDefinitionRulesVO>> entry : trainingTypeMap.entrySet()) {
String trainingType = entry.getKey();
// 校验实训类型
if (null == existTrainingTypeMap.get(trainingType) || existTrainingTypeMap.get(trainingType).size() != entry.getValue().size()) {
break;
}
// 校验操作类型
Map<String, ExamDefinitionRulesVO> dataMap = entry.getValue().stream()
.collect(Collectors.toMap(ExamDefinitionRulesVO::getOperateType, Function.identity()));
Map<String, ExamDefinitionRulesVO> map = existTrainingTypeMap.get(trainingType).stream()
.collect(Collectors.toMap(ExamDefinitionRulesVO::getOperateType, Function.identity()));
for (Entry<String, ExamDefinitionRulesVO> en : dataMap.entrySet()) {
String operateType = en.getKey();
if (null == map.get(operateType) || !en.getValue().equals(map.get(operateType))) {
break trainingTypeLoop;
} else {
rulesNum -= en.getValue().getNum();
}
}
}
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertNotTrue(0 == rulesNum);
}
/**
* 确认名称唯一
*
* @param id 试卷的id更新时检查名称重复需要去掉自己
* @param status
*/
private void confirmNameUnique(Long id, long mapId, @NonNull String type, @NonNull String name, String status) {
// //一个课程下考试名称查重
// ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
// examDefinitionExample.createCriteria().andLessonIdEqualTo(examDefinitionVO.getLessonId()).andNameEqualTo(examDefinitionVO.getName());
// List<ExamDefinition> examDefinitionList = examDefinitionDAO.selectByExample(examDefinitionExample);
// BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertCollectionEmpty(examDefinitionList);
ExamDefinitionExample example = new ExamDefinitionExample();
ExamDefinitionExample.Criteria criteria = example.createCriteria().andMapIdEqualTo(mapId).andTypeEqualTo(type).andNameEqualTo(name);
if (id != null) {
criteria.andIdNotEqualTo(id);
}
}
// /**
// * GZB创建考试定义
// */
// @Transactional
// @Override
// public void createGZBExam(ExamDefinitionVO examDefinitionVO, UserVO userVO) {
// examDefinitionVO.setCreatorId(userVO.getId());
//
// //检查分数是否合理
// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(checkScore(examDefinitionVO));
// //检查考试名称和考试规则是否唯一
// checkName(examDefinitionVO);
// //插入考试定义表数据
// ExamDefinition examDefinition = examDefinitionVO.toDB();
// examDefinition.setCreateTime(LocalDateTime.now());
// examDefinition.setStatus(BusinessConsts.STATUS_USE);
// // 判断是否是管理员并设置试用
// if(this.iSysUserService.isAdmin(userVO) && examDefinitionVO.getTrial()) {
// examDefinition.setTrial(true);
// }else {
// examDefinition.setTrial(false);
// }
// examDefinitionDAO.insert(examDefinition);
// //插入试卷班级关系
// if(!CollectionUtils.isEmpty(examDefinitionVO.getClasses())) {
// examDefinitionVO.getClasses().forEach(departmentVO -> iCompanyService.addDepartExam(examDefinition.getId(),departmentVO.getId()));
// }
// //插入试题规则表数据
// List<ExamDefinitionRulesVO> examDefinitionRulesVOList = examDefinitionVO.getExamDefinitionRulesVOList();
// examDefinitionRulesVOList.forEach(examDefinitionRulesVO -> {
// ExamDefinitionRules examDefinitionRules = examDefinitionRulesVO.toDB();
// examDefinitionRules.setExamId(examDefinition.getId());
// definitionRulesDAO.insert(examDefinitionRules);
// });
// }
private void checkName(ExamDefinitionVO examDefinitionVO) {
//一个课程下考试名称查重
ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
examDefinitionExample.createCriteria().andLessonIdEqualTo(examDefinitionVO.getLessonId()).andNameEqualTo(examDefinitionVO.getName());
List<ExamDefinition> examDefinitionList = examDefinitionDAO.selectByExample(examDefinitionExample);
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertCollectionEmpty(examDefinitionList);
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(examDefinitionDAO.countByExample(example) == 0,
"名称重复");
}
/**
@ -217,38 +145,6 @@ public class ExamService implements IExamService {
return defineFullScore == realFullScore;
}
// /**
// * 查询课程下有实训的章节信息
// * @param lessonId
// * @return
// */
// @Override
// public List<ExamChapterInfoVO> queryChapterInfo(String lessonId) {
// //返回的结果
// List<ExamChapterInfoVO> examChapterInfoVOList = new ArrayList<>();
//
// //查询数据
// List<Long> lessonIds = new ArrayList<>();
// lessonIds.add(Long.valueOf(lessonId));
// List<LessonChapterVO> chapterVos = this.lsLessonChapterMapper.selectChapterTrainingByLessonIds(lessonIds);
//
// //检测章节是否为空
// if (chapterVos.size() == 0) {
// throw new DBException(ExceptionMapping.DATA_NOT_EXIST);
// }
//
// //转换为VO对象
// chapterVos.forEach(lessonChapterVO -> {
// ExamChapterInfoVO examChapterInfoVO = new ExamChapterInfoVO();
// examChapterInfoVO.setId(lessonChapterVO.getId());
// examChapterInfoVO.setName(lessonChapterVO.getName());
//
// examChapterInfoVOList.add(examChapterInfoVO);
// });
//
// return examChapterInfoVOList;
// }
@Override
public List<String> queryTrainingTypes(Long lessonId) {
// 获取课程课程所属产品编码
@ -265,8 +161,6 @@ public class ExamService implements IExamService {
/**
* 查询试题定义的详细信息
*
* @param examId
*/
@Override
public ExamDefinitionVO queryExamInfo(Long examId) {
@ -287,7 +181,6 @@ public class ExamService implements IExamService {
examDefinitionRulesVOList.add(examDefinitionRulesVO);
});
ExamDefinitionVO examDefinitionVO = new ExamDefinitionVO(examDefinition);
examDefinitionVO.setClasses(iOrgUserService.getDepartsByExamId(examId));
examDefinitionVO.setExamDefinitionRulesVOList(examDefinitionRulesVOList);
return examDefinitionVO;
@ -301,47 +194,15 @@ public class ExamService implements IExamService {
//查询课程信息
LessonVO lessonVO = iLessonService.getLessonInfo(lessonId);
// MapVO mapVO = iMapService.findMapBaseInfoById(lessonVO.getMapId());
// BusinessConsts.Lesson.PrdInfo prdInfo = BusinessConsts.Lesson.PrdInfo.getBy(lessonVO.getPrdType());
// String defaultLessonName = String.join("-", mapVO.getName(), prdInfo.getName());
// lessonVO.setSystemFault(Objects.equals(lessonVO.getName(),defaultLessonName));
// 如果用户关联班级 查找班级关联试卷
List<Long> examIds = null;
// List<UserDepartRelVO> userDepartRelVOS = this.iOrgUserService.getDepartRefByUserId(userVO.getId());
// if (!CollectionUtils.isEmpty(userDepartRelVOS)) {
// examIds = new ArrayList<>();
// for (UserDepartRelVO udr : userDepartRelVOS) {
// examIds.addAll(iOrgUserService.getExamIdsByDepartId(udr.getDepartmentId()));
// }
// }
//查询课程下的试题信息
ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
examDefinitionExample.createCriteria().andLessonIdEqualTo(lessonId).andStatusEqualTo(BusinessConsts.STATUS_USE);
List<ExamDefinition> examDefinitionList = examDefinitionDAO.selectByExample(examDefinitionExample);
// 检测试题是否有效
LocalDateTime now = LocalDateTime.now();
Iterator<ExamDefinition> iterator = examDefinitionList.iterator();
while (iterator.hasNext()) {
ExamDefinition exam = iterator.next();
if (null != exam.getEndTime() && now.isAfter(exam.getEndTime())) {
this.forceOffline(exam);
iterator.remove();
} else if (!lessonVO.isSystemFault() && Objects.nonNull(examIds)
// && !Objects.equals(exam.getName(),defaultLessonName+"试卷")
&& !examIds.contains(exam.getId())) {
iterator.remove();
}
}
//转换为VO
ExamsLessonVO examsLessonVO = new ExamsLessonVO(lessonVO);
List<ExamDefinitionVO> examDefinitionVOList = new ArrayList<>();
examDefinitionList.forEach(examDefinition -> {
ExamDefinitionVO exam = new ExamDefinitionVO(examDefinition);
// 试卷存在班级关系获取班级列表
List<DepartmentVO> departs = iOrgUserService.getDepartsByExamId(examDefinition.getId());
if (!CollectionUtils.isEmpty(departs)) {
exam.setClasses(departs);
}
examDefinitionVOList.add(exam);
});
examsLessonVO.setExamDefinitionList(examDefinitionVOList);
@ -422,49 +283,27 @@ public class ExamService implements IExamService {
* 删除指定ID的考试信息
*/
@Override
public void deleteExam(String id, UserVO userVO) {
public void deleteExam(Long id, UserVO userVO) {
//判断是否已有用户参与考试如果有不能删除考试定义
UserExamExample userExamExample = new UserExamExample();
userExamExample.createCriteria().andExamIdEqualTo(Long.parseLong(id));
userExamExample.createCriteria().andExamIdEqualTo(id);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(userExamMapper.countByExample(userExamExample) > 0,
String.format("试卷[%s]已被使用", id));
//删除考试信息和规则信息
ExamDefinition examDefinition = examDefinitionDAO.selectByPrimaryKey(Long.parseLong(id));
ExamDefinition examDefinition = examDefinitionDAO.selectByPrimaryKey(id);
if (examDefinition == null) {
return;
}
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertEquals(userVO.getId(), examDefinition.getCreatorId(),
String.format("你不是试卷[%s]的创建者", examDefinition.getId()));
// BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(examDefinition != null && userVO.getId().equals(examDefinition.getCreatorId()),
// "试卷不存在或你不是试卷创建者");
ExamDefinitionRulesExample example = new ExamDefinitionRulesExample();
example.createCriteria().andExamIdEqualTo(Long.parseLong(id));
example.createCriteria().andExamIdEqualTo(id);
definitionRulesDAO.deleteByExample(example);
examDefinitionDAO.deleteByPrimaryKey(Long.parseLong(id));
examDefinitionDAO.deleteByPrimaryKey(id);
}
// /**
// * 查询章节下允许创建的最多题目数量
// *
// * @param lessonId
// * @param chapterId
// * @return
// */
// @Override
// public int queryTrainingNum(String lessonId, String chapterId) {
// Long chapterIdLong = ConvertUtil.str2Long(chapterId);
// Long lessonIdLong = ConvertUtil.str2Long(lessonId);
//
// //查询课程章节实训映射表信息
// LsRelChapterTrainingExample example = new LsRelChapterTrainingExample();
// example.setDistinct(true);
// example.createCriteria().andChapterIdEqualTo(chapterIdLong).andLessonIdEqualTo(lessonIdLong);
// List<LsRelChapterTraining> lsRelChapterTrainingList = lsRelChapterTrainingMapper.selectByExample(example);
//
// return lsRelChapterTrainingList.size();
// }
@Override
public Long queryTrainingNum(Long lessonId, String trainingType, String operateType) {
// 获取课程数据
@ -514,27 +353,41 @@ public class ExamService implements IExamService {
return examDefinitionDAO.selectByExample(example);
}
private void forceOffline(ExamDefinition exam) {
exam.setStatus(BusinessConsts.STATUS_NOT_USE);
this.examDefinitionDAO.updateByPrimaryKey(exam);
@Override
public List<ExamDefinitionVO> queryBasicInfo(Long mapId, String prdType) {
return ExamDefinitionVO.convert(findEntities(mapId, prdType));
}
@Override
public void copy(Long fromMapId, Long toMapId, UserVO user) {
/* 拷贝考试定义 */
List<ExamDefinition> exams = findEntities(fromMapId, null);
Map<Long, Long> old_new_examIdMap = new HashMap<>();
exams.forEach(examDefinition -> {
Long oldId = examDefinition.getId();
examDefinition.setId(null);
examDefinition.setMapId(toMapId);
examDefinition.setCreatorId(user.getId());
examDefinition.setCreateTime(LocalDateTime.now());
examDefinitionDAO.insert(examDefinition);
old_new_examIdMap.put(oldId, examDefinition.getId());
});
/* 拷贝考试规则 */
ExamDefinitionRulesExample ruleExample = new ExamDefinitionRulesExample();
ruleExample.createCriteria().andExamIdIn(new ArrayList<>(old_new_examIdMap.keySet()));
definitionRulesDAO.selectByExample(ruleExample).forEach(rule->{
rule.setId(null);
rule.setExamId(old_new_examIdMap.get(rule.getExamId()));
definitionRulesDAO.insert(rule);
});
}
@Override
public void update(Long id, ExamDefinitionVO examDefinitionVO) {
ExamDefinition examDefinition = this.examDefinitionDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(examDefinition);
if (!CollectionUtils.isEmpty(iOrgUserService.getDepartsByExamId(id))) {
iOrgUserService.deleteDepartsExam(id);
}
if (!CollectionUtils.isEmpty(examDefinitionVO.getClasses())) {
examDefinitionVO.getClasses().forEach(departmentVO -> iOrgUserService.addDepartExam(id, departmentVO.getId()));
}
//考试名称查重
String name = examDefinitionVO.getName();
ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
examDefinitionExample.createCriteria().andNameEqualTo(name).andIdNotEqualTo(id);
List<ExamDefinition> examDefinitionList = examDefinitionDAO.selectByExample(examDefinitionExample);
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertCollectionEmpty(examDefinitionList);
confirmNameUnique(examDefinition.getId(), examDefinition.getMapId(), examDefinition.getType(), examDefinitionVO.getName(), BusinessConsts.STATUS_USE);
examDefinition.setName(examDefinitionVO.getName());
examDefinition.setTrial(examDefinitionVO.getTrial());
examDefinition.setStartTime(examDefinitionVO.getStartTime());
@ -542,59 +395,6 @@ public class ExamService implements IExamService {
this.examDefinitionDAO.updateByPrimaryKey(examDefinition);
}
@Override
@Transactional
public void copy(Map<Long, Long> lessonRelationMap, UserVO user) {
ArrayList<Long> lessonIdList = new ArrayList<>(lessonRelationMap.keySet());
List<ExamDefinition> examList = findEntityByLessonIdList(lessonIdList);
for (ExamDefinition exam : examList) {
//因为考试定义的id要变先将考试规则查出来
ExamDefinitionRulesExample rulesExample = new ExamDefinitionRulesExample();
rulesExample.createCriteria()
.andExamIdEqualTo(exam.getId());
List<ExamDefinitionRules> rulesList = examDefinitionRulesDAO.selectByExample(rulesExample);
//拷贝考试定义
exam.setLessonId(lessonRelationMap.get(exam.getLessonId()));
exam.setCreatorId(user.getId());
exam.setCreateTime(LocalDateTime.now());
exam.setId(null);
examDefinitionDAO.insertSelective(exam);
for (ExamDefinitionRules rules : rulesList) {
rules.setId(null);
rules.setExamId(exam.getId());
examDefinitionRulesDAO.insertSelective(rules);
}
}
// ExamDefinitionExample examExample = new ExamDefinitionExample();
// examExample.createCriteria()
// .andLessonIdEqualTo(sourceLessonId);
// List<ExamDefinition> definitionList = this.examDefinitionDAO.selectByExample(examExample);
// if(!CollectionUtils.isEmpty(definitionList)) {
// definitionList.forEach(definition -> {
// // 拷贝考试定义
// Long oldId = definition.getId();
// definition.setId(null);
// definition.setLessonId(targetLessonId);
// definition.setCreatorId(user.getId());
// this.examDefinitionDAO.insert(definition);
// Long newId = definition.getId();
// // 拷贝考试规则
// ExamDefinitionRulesExample example = new ExamDefinitionRulesExample();
// example.createCriteria()
// .andExamIdEqualTo(oldId);
// List<ExamDefinitionRules> ruleList = this.definitionRulesDAO.selectByExample(example);
// if(!CollectionUtils.isEmpty(ruleList)) {
// ruleList.forEach(rules -> {
// rules.setId(null);
// rules.setExamId(newId);
// this.definitionRulesDAO.insert(rules);
// });
// }
// });
// }
}
@Override
public List<ExamDefinition> findEntities(Long lessonId) {
ExamDefinitionExample example = new ExamDefinitionExample();
@ -604,43 +404,38 @@ public class ExamService implements IExamService {
@Override
public PageVO<ExamDefinitionVO> pagedQueryByLoginProject(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) {
List<Long> lessonIds;
if (queryVO.getLessonId() != null) {
lessonIds = List.of(queryVO.getLessonId());
} else {
List<LessonVO> lessonVOS = iLessonService.queryNonDefaultLessons(null, loginInfo.getProject(), BusinessConsts.STATUS_USE);
lessonIds = lessonVOS.stream().map(LessonVO::getId).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(lessonIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
List<OrgLesson> orgLessons = iOrgLessonService.findEntitiesByLessonIds(lessonIds);
Map<Long, List<Long>> lessonOrgMap = orgLessons.stream()
.collect(Collectors.groupingBy(OrgLesson::getLessonId, Collectors.mapping(OrgLesson::getOrgId, Collectors.toList())));
ExamDefinitionExample example = new ExamDefinitionExample();
ExamDefinitionExample.Criteria criteria = example.createCriteria().andLessonIdIn(lessonIds);
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
if (StringUtils.hasText(queryVO.getCreatorName())) {
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(UserVO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(creatorIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
criteria.andCreatorIdIn(creatorIds);
}
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<ExamDefinition> page = (Page<ExamDefinition>) examDefinitionDAO.selectByExample(example);
Map<Long, SysUser> creatorMap = iSysUserService.findEntity(page.stream().map(ExamDefinition::getCreatorId).collect(Collectors.toList()), null)
.stream().collect(Collectors.toMap(SysUser::getId, Function.identity()));
List<ExamDefinitionVO> list = page.getResult().stream().map(examDefinition -> {
ExamDefinitionVO vo = new ExamDefinitionVO(examDefinition, creatorMap.get(examDefinition.getCreatorId()));
vo.setClsIds(lessonOrgMap.get(vo.getLessonId()));
return vo;
}).collect(Collectors.toList());
return PageVO.convert(page, list);
PageVO<ExamDefinitionVO> empty = new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
List<Long> creatorIds = null;
if (StringUtils.hasText(queryVO.getCreatorName())) {
List<UserVO> creators = iSysUserService.findUserByName(queryVO.getCreatorName());
if (CollectionUtils.isEmpty(creators))
return empty;
creatorIds = creators.stream().map(UserVO::getId).collect(Collectors.toList());
}
List<Long> mapIds = iMapService.findOnlineMapByProjectCode(loginInfo.getProject().name())
.stream().map(MapVO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(mapIds))
return empty;
ExamDefinitionExample example = new ExamDefinitionExample();
ExamDefinitionExample.Criteria criteria = example.createCriteria().andMapIdIn(mapIds);
if (!CollectionUtils.isEmpty(creatorIds))
criteria.andCreatorIdIn(creatorIds);
if (StringUtils.hasText(queryVO.getName()))
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<ExamDefinition> page = (Page<ExamDefinition>) examDefinitionDAO.selectByExample(example);
creatorIds = page.stream().map(ExamDefinition::getCreatorId).collect(Collectors.toList());
Map<Long, SysUser> creatorMap = iSysUserService.findEntity(creatorIds, null)
.stream().collect(Collectors.toMap(SysUser::getId, Function.identity()));
Map<Long, List<Long>> examId_orgId_map = iOrgService.queryByExamIds(page.stream().map(ExamDefinition::getId).collect(Collectors.toList()), BusinessConsts.Org.Status.VALID)
.stream().collect(Collectors.toMap(ExamDefinitionVO::getId, ExamDefinitionVO::getClsIds));
List<ExamDefinitionVO> vos = page.stream().map(exam -> {
ExamDefinitionVO vo = new ExamDefinitionVO(exam, creatorMap.get(exam.getCreatorId()));
vo.setClsIds(examId_orgId_map.get(exam.getId()));
return vo;
})
.collect(Collectors.toList());
return PageVO.convert(page, vos);
}
@Override
@ -650,7 +445,7 @@ public class ExamService implements IExamService {
Org topOrg = iOrgService.getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
List<Org> clsList = iOrgService.findEntitiesByParentId(topOrg.getId(), "id", BusinessConsts.Org.Status.VALID);
List<Long> clsIds = clsList.stream().map(Org::getId).collect(Collectors.toList());
lessonIds = iOrgLessonService.findEntitiesByOrgIds(clsIds).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
lessonIds = iOrgLessonService.findEntitiesByOrgIds(clsIds).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
} else {
lessonIds = iOrgLessonService.findEntitiesByOrgId(clsId, null).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
}
@ -661,30 +456,24 @@ public class ExamService implements IExamService {
@Override
public List<ExamDefinitionVO> listQueryExamByLoginProject(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) {
List<Long> lessonIds;
if (queryVO.getLessonId() != null) {
lessonIds = List.of(queryVO.getLessonId());
} else {
lessonIds = iLessonService.queryByLoginProject(new LessonQueryVO(), loginInfo).stream().map(LessonVO::getId).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(lessonIds)) {
return new ArrayList<>();
} else {
List<OrgLesson> orgLessons = iOrgLessonService.findEntitiesByLessonIds(lessonIds);
Map<Long, List<Long>> lessonOrgMap = orgLessons.stream()
.collect(Collectors.groupingBy(OrgLesson::getLessonId, Collectors.mapping(OrgLesson::getOrgId, Collectors.toList())));
ExamDefinitionExample example = new ExamDefinitionExample();
ExamDefinitionExample.Criteria criteria = example.createCriteria().andLessonIdIn(lessonIds).andCreatorIdEqualTo(loginInfo.getUserVO().getId());
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
List<ExamDefinition> exams = examDefinitionDAO.selectByExample(example);
return exams.stream().map(examDefinition -> {
ExamDefinitionVO vo = new ExamDefinitionVO(examDefinition);
vo.setClsIds(lessonOrgMap.get(vo.getLessonId()));
return vo;
}).collect(Collectors.toList());
}
List<Long> mapIds = iMapService.findOnlineMapByProjectCode(loginInfo.getProject().name())
.stream().map(MapVO::getId).collect(Collectors.toList());
ExamDefinitionExample example = new ExamDefinitionExample();
example.createCriteria().andMapIdIn(mapIds);
return ExamDefinitionVO.convert(examDefinitionDAO.selectByExample(example));
}
private List<ExamDefinition> findEntities(long mapId, String prdType) {
ExamDefinitionExample example = new ExamDefinitionExample();
ExamDefinitionExample.Criteria criteria = example.createCriteria().andMapIdEqualTo(mapId);
if (StringUtils.hasText(prdType))
criteria.andTypeEqualTo(prdType);
return examDefinitionDAO.selectByExample(example);
}
private void forceOffline(@NonNull ExamDefinition exam) {
exam.setStatus(BusinessConsts.STATUS_NOT_USE);
this.examDefinitionDAO.updateByPrimaryKey(exam);
}
private List<ExamDefinition> findEntityByLessonIdList(List<Long> lessonIdList) {

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.vo.client.ExamDefinitionQueryVO;
import club.joylink.rtss.vo.client.ExamDefinitionVO;
import club.joylink.rtss.vo.client.ExamsLessonVO;
import club.joylink.rtss.vo.client.PageVO;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@ -17,8 +18,6 @@ public interface IExamService {
*/
void create(ExamDefinitionVO examDefinitionVO, UserVO userVO);
// void createGZBExam(ExamDefinitionVO examDefinitionVO, UserVO userVO);
/**
* 检查分数定义是否合理
*/
@ -47,13 +46,8 @@ public interface IExamService {
/**
* 删除指定ID的考试信息
*/
void deleteExam(String id, UserVO userVO);
void deleteExam(Long id, UserVO userVO);
// /**
// * 查询章节下允许创建的最多题目数量
// */
// int queryTrainingNum(String lessonId, String chapterId);
/**
* 根据课程和实训类型查询实训数量
*/
@ -74,8 +68,6 @@ public interface IExamService {
*/
void update(Long id, ExamDefinitionVO examDefinitionVO);
void copy(Map<Long, Long> lessonRelationMap, UserVO user);
/**
* 根据课程id查询考试
*/
@ -99,4 +91,9 @@ public interface IExamService {
ExamDefinition getEntity(Long examId);
List<ExamDefinition> findEntities(List<Long> examIds);
List<ExamDefinitionVO> queryBasicInfo(Long mapId, String prdType);
@Transactional
void copy(Long fromMapId, Long toMapId, UserVO user);
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.services;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.entity.LsLesson;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.*;
@ -42,7 +43,7 @@ public interface ILessonService {
*/
LessonVO getLessonInfo(Long id);
LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType);
LsLesson findEntity(long mapId, String name, String prdType, String status);
LessonVO findSysFaultByMapAndPrdType(Long mapId, String prdType);

View File

@ -200,7 +200,7 @@ public class LessonService implements ILessonService {
@Override
@Transactional
public void publish(LessonVO lessonVo, LessonPublishVO publishVO) {
LessonVO publishedLesson = this.findByMapAndNameAndPrdType(publishVO.getMapId(), publishVO.getName(), publishVO.getPrdType());
LsLesson publishedLesson = this.findEntity(publishVO.getMapId(), publishVO.getName(), publishVO.getPrdType(), BusinessConsts.STATUS_USE);
lessonVo.apply(publishVO);
LsLesson newLesson = lessonVo.toPublic();
newLesson.setUpdateTime(LocalDateTime.now());
@ -210,67 +210,29 @@ public class LessonService implements ILessonService {
// 新发布
newLesson.setId(null);
this.lessonDAO.insert(newLesson);
//存在班级条件就创建课程班级关系
if (!CollectionUtils.isEmpty(publishVO.getClassIdList())) {
addRelLessonClass(publishVO, newLesson.getId());
}
// // 自动创建商品
// iGoodsService.autoCreateTeachAndExamGoods(newLesson);
} else {
//默认课程
// MapVO mapVO = iMapService.findMapBaseInfoById(publishVO.getMapId());
// BusinessConsts.Lesson.PrdInfo prdInfo = BusinessConsts.Lesson.PrdInfo.getBy(publishVO.getPrdType());
// String defaultLessonName = String.join("-", mapVO.getName(), prdInfo.getName());
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(publishVO.isCoverSameNameLesson(),
"与已有课程同名,请修改名称");
LessonVO sysFaultLesson = findSysFaultByMapAndPrdType(publishVO.getMapId(), publishVO.getPrdType());
if (sysFaultLesson != null) {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(Objects.equals(publishVO.getName(), sysFaultLesson.getName()), "与系统默认课程重名,请修改名称");
}
// 更新
newLesson.setId(publishedLesson.getId());
this.lessonDAO.updateByPrimaryKey(newLesson);
//课程存在,预备检查与班级的关系
OrgLessonExample departmentLessonExample = new OrgLessonExample();
departmentLessonExample.createCriteria().andLessonIdEqualTo(publishedLesson.getId());
List<OrgLesson> departmentLessonRefs = this.departmentLessonDAO.selectByExample(departmentLessonExample);
if (!CollectionUtils.isEmpty(publishVO.getClassIdList())) {
if (!CollectionUtils.isEmpty(departmentLessonRefs)) {
List<Long> existedClassIds = departmentLessonRefs.stream().map(OrgLesson::getOrgId).collect(Collectors.toList());
Collections.sort(existedClassIds);
Collections.sort(publishVO.getClassIdList());
if (!existedClassIds.equals(publishVO.getClassIdList())) {
//清除现有课程班级关系
this.departmentLessonDAO.deleteByExample(departmentLessonExample);
addRelLessonClass(publishVO, publishedLesson.getId());
}
} else {
addRelLessonClass(publishVO, publishedLesson.getId());
}
} else {
if (!CollectionUtils.isEmpty(departmentLessonRefs)) {
this.departmentLessonDAO.deleteByExample(departmentLessonExample);
}
}
// if(!lessonVo.getName().equals(publishedLesson.getName())) {
// // 自动创建商品
// iGoodsService.autoUpdateTeachAndExamGoods(newLesson);
// }
}
this.buildAndInsertLessonVersion(newLesson);
this.saveChapterDetail(newLesson, lessonVo);
}
@Override
public LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType) {
public LsLesson findEntity(long mapId, @NonNull String name, @NonNull String prdType, String status) {
LsLessonExample lessonExample = new LsLessonExample();
lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name).andPrdTypeEqualTo(prdType);
Criteria criteria = lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name).andPrdTypeEqualTo(prdType);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
List<LsLesson> lessonList = this.lessonDAO.selectByExample(lessonExample);
if (CollectionUtils.isEmpty(lessonList)) {
return null;
}
return new LessonVO(lessonList.get(0));
return lessonList.get(0);
}
@Override
@ -358,8 +320,6 @@ public class LessonService implements ILessonService {
this.userTrainingStatsMapper.deleteByExample(userTrainingExample);
lessonDAO.deleteByPrimaryKey(lessonId);
// // 自动删除关联商品
// this.iGoodsService.autoDeleteTeachAndExamGoods(lsLesson.getCode());
}
/**
@ -435,6 +395,9 @@ public class LessonService implements ILessonService {
public void updateNameAndRemarks(Long id, String name, String remarks, UserVO user) {
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(id);
if (Objects.nonNull(lesson)) {
LsLesson sameNameLesson = findEntity(lesson.getMapId(), name, lesson.getPrdType(), BusinessConsts.STATUS_USE);
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(sameNameLesson == null || sameNameLesson.getId().equals(lesson.getId()),
"名称重复");
lesson.setName(name);
lesson.setRemarks(remarks);
this.lessonDAO.updateByPrimaryKey(lesson);
@ -641,17 +604,18 @@ public class LessonService implements ILessonService {
}
private void generateLessonBy(UserVO userVO, MapVO mapVO, BusinessConsts.Lesson.PrdInfo prdLessonInfo, String prdType) {
Long mapId = mapVO.getId();
//课程
LsLesson lesson = new LsLesson();
lesson.setUpdateTime(LocalDateTime.now());
lesson.setStatus(BusinessConsts.STATUS_USE);
lesson.setCreatorId(userVO.getId());
lesson.setMapId(mapVO.getId());
lesson.setMapId(mapId);
lesson.setName(String.join("-", mapVO.getName(), prdLessonInfo.getName()));
lesson.setPrdType(prdType);
lesson.setRemarks(prdLessonInfo.getRemarks());
lesson.setSysfault(true);
LessonVO existedDefaultLesson = this.findSysFaultByMapAndPrdType(mapVO.getId(), prdType);
LessonVO existedDefaultLesson = this.findSysFaultByMapAndPrdType(mapId, prdType);
if (Objects.nonNull(existedDefaultLesson)) {
lesson.setId(existedDefaultLesson.getId());
lessonDAO.updateByPrimaryKey(lesson);
@ -694,7 +658,7 @@ public class LessonService implements ILessonService {
List<Training> examTrainings = new ArrayList<>(20);
int orderNum = 1;
Random random = new Random();
Map<String, Map<String, List<Training>>> trainings = iTrainingV1Service.findEntities(mapVO.getId(), prdType)
Map<String, Map<String, List<Training>>> trainings = iTrainingV1Service.findEntities(mapId, prdType)
.stream().collect(Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType)));
for (BusinessConsts.Training.Type type : BusinessConsts.Training.Type.values()) {
Map<String, List<Training>> collect = trainings.get(type.name());
@ -731,7 +695,9 @@ public class LessonService implements ILessonService {
return;
}
ExamDefinition examDefinition = new ExamDefinition();
examDefinition.setMapId(mapId);
examDefinition.setLessonId(lesson.getId());
examDefinition.setType(prdType);
examDefinition.setName(lesson.getName() + "试卷");
examDefinition.setDuration(1800);
examDefinition.setCreatorId(userVO.getId());

View File

@ -173,9 +173,12 @@ public class MapService implements IMapService {
Objects.requireNonNull(projectCode, "项目编号不能为空");
MapInfoExample example = new MapInfoExample();
example.setOrderByClause("order_number");
example.createCriteria()
.andStatusEqualTo(MapStatus.Online.getCode())
.andProjectCodeEqualTo(projectCode);
MapInfoExample.Criteria criteria = example.createCriteria().andStatusEqualTo(MapStatus.Online.getCode());
if (Project.DEFAULT.name().equals(projectCode)) {
criteria.andProjectCodeIsNull();
} else {
criteria.andProjectCodeEqualTo(projectCode);
}
List<MapInfo> list = mapInfoDAO.selectByExample(example);
return MapVO.convert2VOList(list);
}
@ -642,10 +645,8 @@ public class MapService implements IMapService {
.copyAllOfMapAndPrd(id, mapNewVO.getId());
//拷贝课程
Map<Long, Long> lessonRelationMap = iLessonService.copy(id, mapNewVO.getId(), relMap, user);
if (!CollectionUtils.isEmpty(lessonRelationMap)) {
//拷贝考试
iExamService.copy(lessonRelationMap, user);
}
//拷贝考试
iExamService.copy(id, mapNewVO.getId(), user);
//拷贝system
this.iMapSystemService.copyOfMap(id, mapNewVO.getId());
// //拷贝剧本

View File

@ -13,6 +13,7 @@ import club.joylink.rtss.services.org.IOrgService;
import club.joylink.rtss.services.org.IOrgUserService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.ExamDefinitionVO;
import club.joylink.rtss.vo.client.LessonVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.TreeNode;
@ -66,6 +67,9 @@ public class MapSystemService implements IMapSystemService {
@Autowired
private IOrgLessonService iOrgLessonService;
@Autowired
private IExamService iExamService;
@Override
@Transactional
public void generateSystem(Long mapId) {
@ -223,42 +227,21 @@ public class MapSystemService implements IMapSystemService {
mapSystemDetailVO.setPermissionList(permissionVOList);
} else if (MapSystemType.Lesson.name().equals(mapSystem.getType()) || MapSystemType.Exam.name().equals(mapSystem.getType())) {
// Org topOrg = iOrgService.findEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
List<LessonVO> lessonVOList;
// if (!Project.CGY.equals(loginInfo.getProject()) && topOrg != null) { //由于成都工业的特殊性先防一下
// lessonVOList = new ArrayList<>();
// LessonVO defaultLesson = iLessonService.findSysFaultByMapAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType());
// if (defaultLesson != null && MapStatus.Online.getCode().equals(defaultLesson.getStatus())) {
// lessonVOList.add(defaultLesson);
// }
// List<LessonVO> lessonsICreated = iLessonService.queryNonDefaultLessons(loginInfo.getUserVO().getId(),
// loginInfo.getProject(), BusinessConsts.STATUS_USE);
// lessonVOList.addAll(lessonsICreated);
// //如果当前用户有所属班级查询所属有效班级关联的有效课程
// List<OrgUser> orgUsers = iOrgUserService.findEntities(loginInfo.getUserVO().getId(), null);
// List<Long> orgIds = orgUsers.stream().map(OrgUser::getOrgId).collect(Collectors.toList());
// List<Long> validOrgIds = iOrgService.findEntities(orgIds, BusinessConsts.Org.Status.VALID)
// .stream().map(Org::getId).collect(Collectors.toList());
// Set<Long> lessonIdSet = lessonVOList.stream().map(LessonVO::getId).collect(Collectors.toSet());
// List<Long> orgLessonIds = iOrgLessonService.findEntitiesByOrgIds(validOrgIds).stream().map(OrgLesson::getLessonId)
// .filter(lessonId -> !lessonIdSet.contains(lessonId)).distinct().collect(Collectors.toList());
// lessonVOList.addAll(iLessonService.queryByIds(orgLessonIds, BusinessConsts.STATUS_USE));
// //
// } else {
lessonVOList = iLessonService.getByMapIdAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType());
// }
//查询课程
List<LessonVO> lessonVOList = iLessonService.getByMapIdAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType());
if (CollectionUtils.isEmpty(lessonVOList)) {
return mapSystemDetailVO;
}
//查询课程关联的班级列表
lessonVOList.forEach(lessonVO -> {
lessonVOList.forEach(lessonVO -> { //查询课程关联的班级列表
List<String> classNames = this.iOrgUserService.getDepartNamesByLesson(lessonVO.getId());
if (!CollectionUtils.isEmpty(classNames)) {
lessonVO.setClassNames(classNames);
}
});
mapSystemDetailVO.setLessonList(lessonVOList);
//查询考试
List<ExamDefinitionVO> examVOS = iExamService.queryBasicInfo(mapSystem.getMapId(), mapSystem.getPrdType());
mapSystemDetailVO.setExamList(examVOS);
} else if (MapSystemType.Plan.name().equals(mapSystem.getType())) {
List<RunPlanVO> planVOList = iRunPlanDraftService.queryListByMapId(mapSystem.getMapId(), userVO);
mapSystemDetailVO.setPlanList(planVOList);

View File

@ -75,18 +75,15 @@ public class UserExamService implements IUserExamService {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(examDef);
// 判断是否有权限
if (!examDef.getTrial()) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.SECOND, examDef.getDuration());
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId());
groupSimulationService.confirmHasPermission(userVO, lesson.getMapId(), lesson.getPrdType());
// List<UserPermissionVO> examPermission = iUserPermissionService.getExamUserPermission(userVO, lesson.getMapId(), lesson.getPrdType(), lesson.getId());
// BusinessExceptionAssertEnum.SIMULATION_PERMISSION_NOT_AVAILABLE.assertCollectionNotEmpty(examPermission);
groupSimulationService.confirmHasPermission(userVO, examDef.getMapId(), examDef.getType());
}
// 判断是否在考试时间之内
LocalDateTime now = LocalDateTime.now();
if (examDef.getStartTime() != null) {
LocalDateTime now = LocalDateTime.now();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isAfter(examDef.getStartTime()) && now.isBefore(examDef.getEndTime()));
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isAfter(examDef.getStartTime()), "考试尚未开始");
}
if (examDef.getEndTime() != null) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isBefore(examDef.getEndTime()), "考试已经结束");
}
// 保存用户考试信息
UserExam userExam = new UserExam();
@ -102,11 +99,11 @@ public class UserExamService implements IUserExamService {
ruleExample.createCriteria().andExamIdEqualTo(examId);
List<ExamDefinitionRules> rules = this.examDefinitionRulesDAO.selectByExample(ruleExample);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(rules);
//确认课程存在
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId());
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(lesson);
// //确认课程存在
// LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId());
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(lesson);
//查询实训生成试卷
Map<String, Map<String, List<Training>>> trainings = iTrainingService.findEntities(lesson.getMapId(), lesson.getPrdType())
Map<String, Map<String, List<Training>>> trainings = iTrainingService.findEntities(examDef.getMapId(), examDef.getType())
.stream().collect(Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType)));
for (ExamDefinitionRules rule : rules) {
List<Training> collect;
@ -306,7 +303,8 @@ public class UserExamService implements IUserExamService {
@Override
public PageVO<UserExamVO> pagedQueryOrgUserExamResult(Long orgId, Long examId, PageQueryVO queryVO) {
List<Long> userIds = iOrgUserService.findEntitiesByOrgId(orgId, BusinessConsts.OrgRole.Student).stream().map(OrgUser::getUserId).collect(Collectors.toList());
List<Long> userIds = iOrgUserService.findEntitiesByOrgId(orgId, BusinessConsts.OrgRole.Student)
.stream().map(OrgUser::getUserId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(userIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
@ -323,7 +321,8 @@ public class UserExamService implements IUserExamService {
Map<Long, UserExam> userExamMap = userExamMapper.selectByExample(example).stream()
.collect(Collectors.toMap(UserExam::getUserId, Function.identity()));
Map<Long, SysUser> userMap = iSysUserService.findEntity(userIds, "id").stream().collect(Collectors.toMap(SysUser::getId, Function.identity()));
Map<Long, SysUser> userMap = iSysUserService.findEntity(userIds, "id")
.stream().collect(Collectors.toMap(SysUser::getId, Function.identity()));
Org topOrg = iOrgService.getTopOrgEntity(orgId, BusinessConsts.Org.Status.VALID);
List<UserExamVO> vos = userIds.stream().map(userId -> {
UserExam userExam = userExamMap.get(userId);

View File

@ -0,0 +1,17 @@
package club.joylink.rtss.services.org;
import club.joylink.rtss.entity.OrgExam;
import club.joylink.rtss.vo.UserVO;
import java.util.List;
public interface IOrgExamService {
void create(Long clsId, List<Long> examIds, UserVO user);
List<OrgExam> findEntities(long orgId, Long creatorId);
List<OrgExam> findEntities(List<Long> examIds, Long creatorId);
List<String> queryOrgExam(Long clsId, UserVO user);
}

View File

@ -23,7 +23,7 @@ public interface IOrgLessonService {
*/
List<OrgLesson> findEntitiesByOrgIds(List<Long> orgIds);
List<OrgLesson> findEntitiesByLessonIds(List<Long> lessonIds);
List<OrgLesson> findEntitiesByLessonIds(List<Long> lessonIds, Long creatorId);
List<OrgLesson> findEntitiesByLessonId(Long lessonId);

View File

@ -57,5 +57,5 @@ public interface IOrgScoringRuleService {
* 查询评价规则能应用到的组织
* @return
*/
List<DepartmentVO> queryRuleCanApplyTo(Long ruleId);
List<DepartmentVO> queryRuleCanApplyTo(Long ruleId, UserVO user);
}

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.constants.Project;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.ExamDefinitionVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.org.DepartmentVO;
@ -64,4 +65,9 @@ public interface IOrgService {
PageVO<DepartmentVO> adminPagedQueryOrg(OrgQueryVO queryVO);
CompanyVO get(Long id);
/**
* 查询这些考试关联的班级
*/
List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status);
}

View File

@ -17,8 +17,6 @@ public interface IOrgUserService {
*/
CompanyVO userScanCodeBindCompanyManager(Long userId, Long companyId);
boolean isCompanyUser(Long userId);
DepartmentVO createDepart(DepartmentVO departmentVO);
void updateDepartInfo(Long id, DepartmentVO departmentVO);
@ -33,8 +31,6 @@ public interface IOrgUserService {
List<DepartmentVO> getDepartAndChild(Long companyId, Long deptId);
List<UserDepartRelVO> getDepartRefByUserId(Long userId);
void addDepartUserInfo(UserVO user, UserDepartRelVO userDepartRelVO);
void updateDepartUserInfo(UserVO user, UserDepartRelVO userDepartRelVO);
@ -48,14 +44,6 @@ public interface IOrgUserService {
void importCompanyUserInfo(UserVO user, Long clsId, List<ImportOrgUserVO> importOrgUsers);
List<DepartmentVO> getDepartsByLesson(Long lessonId);
List<DepartmentVO> getDepartsByExamId(Long examId);
void deleteDepartsExam(Long examId);
void addDepartExam(Long examId, Long departId);
List<OrgLesson> getDepartLessonRefs(Long departId);
List<LessonVO> getLessonsByDepart(Long departId);

View File

@ -0,0 +1,73 @@
package club.joylink.rtss.services.org;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.OrgExamDAO;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.OrgExam;
import club.joylink.rtss.entity.OrgExamExample;
import club.joylink.rtss.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class OrgExamService implements IOrgExamService {
@Autowired
private IOrgService iOrgService;
@Autowired
private IOrgUserService iOrgUserService;
@Autowired
private OrgExamDAO orgExamDAO;
@Override
public void create(Long clsId, List<Long> examIds, UserVO user) {
Org topOrg = iOrgService.getTopOrgEntity(clsId, BusinessConsts.Org.Status.VALID);
iOrgUserService.confirmIsTheRoleInThisOrg(user.getId(), topOrg.getId(), BusinessConsts.OrgRole.Admin);
delete(clsId, user.getId());
LocalDateTime createTime = LocalDateTime.now();
examIds.forEach(examId -> {
OrgExam orgExam = new OrgExam();
orgExam.setOrgId(clsId);
orgExam.setExamId(examId);
orgExam.setCreatorId(user.getId());
orgExam.setCreateTime(createTime);
orgExamDAO.insert(orgExam);
});
}
@Override
public List<OrgExam> findEntities(long orgId, Long creatorId) {
OrgExamExample example = new OrgExamExample();
OrgExamExample.Criteria criteria = example.createCriteria().andOrgIdEqualTo(orgId);
if (creatorId != null) {
criteria.andCreatorIdEqualTo(creatorId);
}
return orgExamDAO.selectByExample(example);
}
@Override
public List<OrgExam> findEntities(List<Long> examIds, Long creatorId) {
OrgExamExample example = new OrgExamExample();
OrgExamExample.Criteria criteria = example.createCriteria().andExamIdIn(examIds);
if (creatorId != null) {
criteria.andCreatorIdEqualTo(creatorId);
}
return orgExamDAO.selectByExample(example);
}
@Override
public List<String> queryOrgExam(Long clsId, UserVO user) {
return findEntities(clsId, user.getId()).stream().map(orgExam -> String.valueOf(orgExam.getExamId())).collect(Collectors.toList());
}
private void delete(long orgId, long creatorId) {
OrgExamExample example = new OrgExamExample();
example.createCriteria().andOrgIdEqualTo(orgId).andCreatorIdEqualTo(creatorId);
orgExamDAO.deleteByExample(example);
}
}

View File

@ -77,12 +77,15 @@ public class OrgLessonService implements IOrgLessonService {
}
@Override
public List<OrgLesson> findEntitiesByLessonIds(List<Long> lessonIds) {
public List<OrgLesson> findEntitiesByLessonIds(List<Long> lessonIds, Long creatorId) {
if (CollectionUtils.isEmpty(lessonIds)) {
return new ArrayList<>();
} else {
OrgLessonExample example = new OrgLessonExample();
example.createCriteria().andLessonIdIn(lessonIds);
OrgLessonExample.Criteria criteria = example.createCriteria().andLessonIdIn(lessonIds);
if (creatorId != null) {
criteria.andCreatorIdEqualTo(creatorId);
}
return orgLessonDAO.selectByExample(example);
}
}

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.services.org;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.OrgDAO;
import club.joylink.rtss.dao.OrgScoringRuleDAO;
import club.joylink.rtss.dao.OrgScoringRuleRelDAO;
import club.joylink.rtss.entity.*;
@ -24,6 +23,7 @@ import com.github.pagehelper.PageHelper;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -64,7 +64,7 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
private IOrgLessonService iOrgLessonService;
@Autowired
private OrgDAO orgDAO;
private IOrgExamService iOrgExamService;
@Override
@ -79,15 +79,23 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
}
// TODO: 2021/3/24 评价规则应用到班级之后不能修改班级排课检查应用规则算分时0处理老师和班级的关系不要了
@Transactional
@Override
public void updateScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(orgScoringRuleVO.getId(), "id不能为null");
this.check4Update(orgScoringRuleVO);
OrgScoringRuleWithBLOBs entity = getRuleEntity(orgScoringRuleVO.getId());
OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.cover4Update(entity);
OrgScoringRuleWithBLOBs rule = getRuleEntity(orgScoringRuleVO.getId());
orgScoringRuleVO.cover4Update(rule);
rule.setUpdateId(user.getId());
rule.setUpdateTime(LocalDateTime.now());
orgScoringRuleDAO.updateByPrimaryKeyWithBLOBs(rule);
/*更新rel表*/
OrgScoringRuleRelExample relExample = new OrgScoringRuleRelExample();
relExample.createCriteria().andRuleIdEqualTo(rule.getId());
OrgScoringRuleRel rel = new OrgScoringRuleRel();
rel.setRuleSchoolYear(rule.getSchoolYear());
rel.setRuleTerm(rule.getTerm());
orgScoringRuleRelDAO.updateByExampleSelective(rel, relExample);
}
@Override
@ -207,6 +215,10 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
OrgScoringRuleRel rel = new OrgScoringRuleRel();
rel.setOrgId(orgId);
rel.setRuleId(ruleId);
rel.setRuleOrgId(rule.getOrgId());
rel.setRuleSchoolYear(rule.getSchoolYear());
rel.setRuleTerm(rule.getTerm());
rel.setRuleCreatorId(rule.getCreatorId());
return rel;
}).collect(Collectors.toList());
orgScoringRuleRelDAO.batchInsert(rels);
@ -214,42 +226,25 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
}
@Override
public List<DepartmentVO> queryRuleCanApplyTo(Long ruleId) {
public List<DepartmentVO> queryRuleCanApplyTo(Long ruleId, UserVO user) {
OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId);
OrgScoringRuleVO vo = OrgScoringRuleVO.buildDetails(rule, null);
Set<Long> lessonIdSet = new HashSet<>(vo.getAllLessonIds());
List<Long> lessonIds = vo.getAllLessonIds();
List<Long> examIds = vo.getAllExamIds();
if (!CollectionUtils.isEmpty(examIds)) {
List<ExamDefinition> examDefinitions = iExamService.findEntities(examIds);
examDefinitions.forEach(examDefinition -> lessonIdSet.add(examDefinition.getLessonId()));
List<Long> clsIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(lessonIds) && !CollectionUtils.isEmpty(examIds)) { //取课程和考试关联的班级的交集
clsIds.addAll(iOrgLessonService.findEntitiesByLessonIds(lessonIds, user.getId())
.stream().map(OrgLesson::getOrgId).collect(Collectors.toList()));
clsIds.retainAll(iOrgExamService.findEntities(examIds, user.getId())
.stream().map(OrgExam::getOrgId).collect(Collectors.toList()));
} else if (!CollectionUtils.isEmpty(lessonIds)) {
clsIds.addAll(iOrgLessonService.findEntitiesByLessonIds(lessonIds, user.getId())
.stream().map(OrgLesson::getOrgId).collect(Collectors.toList()));
} else {
clsIds.addAll(iOrgExamService.findEntities(examIds, user.getId())
.stream().map(OrgExam::getOrgId).collect(Collectors.toList()));
}
OrgExample orgExample = new OrgExample();
OrgExample.Criteria criteria = orgExample.createCriteria()
.andParentIdEqualTo(rule.getOrgId())
.andCreatorIdEqualTo(rule.getCreatorId())
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (!CollectionUtils.isEmpty(lessonIdSet)) {
List<OrgLesson> orgLessonList = iOrgLessonService.findEntitiesByLessonIds(new ArrayList<>(lessonIdSet));
if (CollectionUtils.isEmpty(orgLessonList)) {
return new ArrayList<>();
} else {
Map<Long, Set<Long>> org_lessons_map = orgLessonList.stream().collect(Collectors.groupingBy(OrgLesson::getOrgId,
Collectors.mapping(OrgLesson::getLessonId, Collectors.toSet())));
List<Long> orgIds = org_lessons_map.entrySet().stream().filter(entry -> entry.getValue().containsAll(lessonIdSet))
.map(Map.Entry::getKey).collect(Collectors.toList());
if (CollectionUtils.isEmpty(orgIds)) {
return new ArrayList<>();
} else {
criteria.andIdIn(orgIds);
}
}
}
return orgDAO.selectByExample(orgExample).stream().map(org -> {
DepartmentVO departmentVO = new DepartmentVO();
departmentVO.setId(org.getId());
departmentVO.setName(org.getName());
return departmentVO;
}).collect(Collectors.toList());
return DepartmentVO.convert2VOList(iOrgService.findEntities(clsIds, BusinessConsts.Org.Status.VALID));
}
private void check4Update(OrgScoringRuleVO orgScoringRuleVO) {
@ -272,7 +267,7 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
.andIdIn(ruleIds);
List<OrgScoringRule> rules = orgScoringRuleDAO.selectByExample(ruleExample);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionEmpty(rules,
"该规则应用到的班级有些已被同学年同学期的其它规则应用到");
"该规则应用到的班级有些已被应用了同学年同学期的其它规则");
}
}
}

View File

@ -10,6 +10,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.ExamDefinitionVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.org.DepartmentVO;
@ -47,16 +48,17 @@ public class OrgService implements IOrgService {
@Transactional
@Override
public CompanyVO createTopOrg(CompanyVO companyVO, UserVO user) {
//检查
/* 检查 */
if (StringUtils.hasText(companyVO.getProjectCode())) {
Org org = findEntity(Project.valueOf(companyVO.getProjectCode()), BusinessConsts.Org.Status.VALID);
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNull(org, "项目已被绑定到其他单位!");
}
//名称检查
OrgExample example = new OrgExample();
example.createCriteria().andNameEqualTo(companyVO.getName()).andStatusEqualTo(BusinessConsts.Org.Status.VALID);
example.createCriteria().andNameEqualTo(companyVO.getName());
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(orgDAO.countByExample(example) == 0,
"名称重复");
//处理
/* 处理 */
Org entity = companyVO.toDB();
entity.setCreatorId(user.getId());
entity.setCreateTime(LocalDateTime.now());
@ -123,7 +125,7 @@ public class OrgService implements IOrgService {
}
@Override
public Org findEntity(Project project, String status) {
public Org findEntity(@NonNull Project project, String status) {
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria().andProjectCodeEqualTo(project.name());
if (StringUtils.hasText(status)) {
@ -164,7 +166,7 @@ public class OrgService implements IOrgService {
}
@Override
public List<Org> findEntitiesByParentId(Long parentId, String orderBy, String status) {
public List<Org> findEntitiesByParentId(@NonNull Long parentId, String orderBy, String status) {
OrgExample example = new OrgExample();
if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy);
@ -270,10 +272,18 @@ public class OrgService implements IOrgService {
return new CompanyVO(entity);
}
@Override
public List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status) {
if (CollectionUtils.isEmpty(examIds)) {
return new ArrayList<>();
}
return orgDAO.queryByExamIds(examIds, status);
}
/**
* 创建非顶级组织
*/
private Org createNonTopOrg(@NonNull String name, @NonNull Long parentId, @NonNull Long rootId, Long creatorId) {
private Org createNonTopOrg(@NonNull String name, @NonNull Long parentId, @NonNull Long rootId, @NonNull Long creatorId) {
//检查顶级组织
confirmIsTopOrg(rootId);
//检查同级同名组织

View File

@ -80,13 +80,6 @@ public class OrgUserService implements IOrgUserService {
// companyUserDAO.updateByExampleSelective(cu,e);
// }
@Override
public boolean isCompanyUser(Long userId) {
OrgUserExample e = new OrgUserExample();
e.createCriteria().andUserIdEqualTo(userId);
return orgUserDAO.countByExample(e) > 0;
}
//************************************部门管理**********************************************
/**
@ -115,6 +108,7 @@ public class OrgUserService implements IOrgUserService {
/**
* 查询部门信息
*
* @param deptId
*/
@Override
@ -128,6 +122,7 @@ public class OrgUserService implements IOrgUserService {
/**
* 根据单位id查询部门及其子部门信息
*
* @param companyId
*/
@Override
@ -194,14 +189,6 @@ public class OrgUserService implements IOrgUserService {
return ucrs.get(0);
}
@Override
public List<UserDepartRelVO> getDepartRefByUserId(Long userId) {
OrgUserExample e = new OrgUserExample();
e.createCriteria().andUserIdEqualTo(userId).andRoleNotEqualTo(BusinessConsts.OrgRole.Admin.name());
List<OrgUser> departmentUserRefs = this.orgUserDAO.selectByExample(e);
return UserDepartRelVO.convert2VOList(departmentUserRefs);
}
/**
* 添加部门-职位-用户关系
*/
@ -338,7 +325,8 @@ public class OrgUserService implements IOrgUserService {
/**
* 导入组织用户
* @param topOrg 导入的组织所属的顶级组织
*
* @param topOrg 导入的组织所属的顶级组织
* @param orgId
* @param orgUserIdSet 导入的组织当前已有的成员
*/
@ -370,36 +358,6 @@ public class OrgUserService implements IOrgUserService {
//---------------------------课程 / 考试 / 部门-----------------------------------------
@Override
public List<DepartmentVO> getDepartsByLesson(Long lessonId) {
List<Org> classes = this.orgLessonDAO.getDeparts(lessonId);
return DepartmentVO.convert2VOList(classes);
}
@Override
public List<DepartmentVO> getDepartsByExamId(Long examId) {
OrgExamExample example = new OrgExamExample();
example.createCriteria().andExamIdEqualTo(examId);
List<Org> classes = this.orgExamDAO.getDepartsByExamId(examId);
return DepartmentVO.convert2VOList(classes);
}
@Override
public void deleteDepartsExam(Long examId) {
OrgExamExample example = new OrgExamExample();
example.createCriteria().andExamIdEqualTo(examId);
orgExamDAO.deleteByExample(example);
}
//TODO 判是否存在
@Override
public void addDepartExam(Long examId, Long departId) {
OrgExam departmentExam = new OrgExam();
departmentExam.setExamId(examId);
departmentExam.setOrgId(departId);
orgExamDAO.insert(departmentExam);
}
@Override
public List<OrgLesson> getDepartLessonRefs(Long departId) {
OrgLessonExample example = new OrgLessonExample();
@ -416,8 +374,7 @@ public class OrgUserService implements IOrgUserService {
@Override
public List<String> getDepartNamesByLesson(Long LessonId) {
List<String> classes = this.orgLessonDAO.getClassNames(LessonId);
return classes;
return this.orgLessonDAO.getClassNames(LessonId);
}
@Transactional
@ -451,7 +408,7 @@ public class OrgUserService implements IOrgUserService {
* 该用户在该组织中是否是这个角色
*/
@Override
public boolean isTheRoleInThisOrg(Long userId, Long orgId, BusinessConsts.OrgRole role) {
public boolean isTheRoleInThisOrg(@NonNull Long userId, @NonNull Long orgId, @NonNull BusinessConsts.OrgRole role) {
OrgUserExample example = new OrgUserExample();
example.createCriteria()
.andUserIdEqualTo(userId)

View File

@ -190,4 +190,10 @@ public interface ITrainingV1Service {
List<Training> findEntities(Long mapId, String prdType);
List<Training> findEntities(@NonNull Long mapId);
/**
* 查询实训类型及其数量
* @return
*/
Map<String, Map<String, Long>> queryTrainingTypeAndQuantity(Long mapId, String prdType);
}

View File

@ -36,11 +36,12 @@ import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* 实训 服务
* @author sheng
*
* @author sheng
*/
@Service
@Slf4j
@ -207,7 +208,7 @@ public class TrainingV1Service implements ITrainingV1Service {
public void nextStep(Long id, String group, TrainingStepVO step) {
Assert.hasText(group, "group不能为空");
TrainingNewVO trainingVO = this.groupTrainingDataCache.getTrainingByGroup(group);
if(Objects.nonNull(trainingVO)) {
if (Objects.nonNull(trainingVO)) {
trainingVO.nextStep(step);
}
}
@ -218,7 +219,7 @@ public class TrainingV1Service implements ITrainingV1Service {
Assert.hasText(group, "group不能为空");
int time = Integer.parseInt(usedTime);
TrainingResultVO result = this.score(group, mode, time);
if(lessonId != 0) {
if (lessonId != 0) {
// 不是从演示进入保存数据用于统计
UserTrainingStats userTraining = new UserTrainingStats();
userTraining.setUserId(userVO.getId());
@ -239,11 +240,11 @@ public class TrainingV1Service implements ITrainingV1Service {
private TrainingResultVO score(String group, String mode, int usedTime) {
TrainingNewVO training = this.groupTrainingDataCache.getTrainingByGroup(group);
if(this.isOperateCorrect(training)) {
if (this.isOperateCorrect(training)) {
// 测验/考试模式
if(mode.equals(BusinessConsts.Training.Mode.Mode04) || mode.equals(BusinessConsts.Training.Mode.Mode05)) {
if (mode.equals(BusinessConsts.Training.Mode.Mode04) || mode.equals(BusinessConsts.Training.Mode.Mode05)) {
float score = 0f;
if(training.getMaxDuration() >= usedTime) {
if (training.getMaxDuration() >= usedTime) {
score = calculateScore(training, usedTime, 5L, false);
return new TrainingResultVO(true, score);
}
@ -256,18 +257,19 @@ public class TrainingV1Service implements ITrainingV1Service {
/**
* 实训操作是否正确
*
* @return
*/
private boolean isOperateCorrect(TrainingNewVO training) {
List<TrainingStepVO> steps = training.getSteps();
List<TrainingStepVO> actualSteps = training.getActualSteps();
boolean correct = true;
if(!CollectionUtils.isEmpty(steps) && !CollectionUtils.isEmpty(actualSteps)
if (!CollectionUtils.isEmpty(steps) && !CollectionUtils.isEmpty(actualSteps)
&& steps.size() == actualSteps.size()) {
for(int i=0; i<steps.size(); ++i) {
for (int i = 0; i < steps.size(); ++i) {
TrainingStepVO step = steps.get(i);
TrainingStepVO actualStep = actualSteps.get(i);
if(!step.isCorrect(actualStep)) {
if (!step.isCorrect(actualStep)) {
correct = false;
break;
}
@ -375,19 +377,20 @@ public class TrainingV1Service implements ITrainingV1Service {
/**
* 计算分数
*
* @param current
* @param usedTime
* @return
*/
private float calculateScore(TrainingNewVO current, int usedTime, long point, boolean isFloat) {
float score = 0f;
if(usedTime <= current.getMinDuration()) {
if (usedTime <= current.getMinDuration()) {
score = point;
}else {
score = (current.getMaxDuration() - usedTime + 1) * point/(current.getMaxDuration() - current.getMinDuration() + 1);
if(isFloat) {
long mod = (current.getMaxDuration() - usedTime + 1) * point%(current.getMaxDuration() - current.getMinDuration() + 1);
if(mod >= 5) {
} else {
score = (current.getMaxDuration() - usedTime + 1) * point / (current.getMaxDuration() - current.getMinDuration() + 1);
if (isFloat) {
long mod = (current.getMaxDuration() - usedTime + 1) * point % (current.getMaxDuration() - current.getMinDuration() + 1);
if (mod >= 5) {
score += 0.5f;
}
}
@ -408,16 +411,16 @@ public class TrainingV1Service implements ITrainingV1Service {
public TrainingResultVO judgeAndCalculate(Long id, String group, String mode, int usedTime, long point, boolean isFloat) {
TrainingNewVO current = this.groupTrainingDataCache.getTrainingByGroup(group);
if(isOperateCorrect(current)) {
if (isOperateCorrect(current)) {
// 测验/考试模式
if(mode.equals(BusinessConsts.Training.Mode.Mode04) || mode.equals(BusinessConsts.Training.Mode.Mode05)) {
if (mode.equals(BusinessConsts.Training.Mode.Mode04) || mode.equals(BusinessConsts.Training.Mode.Mode05)) {
float score = 0f;
if(current.getMaxDuration() >= usedTime) {
if (current.getMaxDuration() >= usedTime) {
score = calculateScore(current, usedTime, point, isFloat);
}else{
} else {
return new TrainingResultVO(false, BusinessConsts.Exam.QuestionCause.OVERTIME);
}
if(score == point ){
if (score == point) {
return new TrainingResultVO(true, score, BusinessConsts.Exam.QuestionCause.PERFECT);
}
return new TrainingResultVO(true, score, BusinessConsts.Exam.QuestionCause.CORRECT);
@ -431,7 +434,7 @@ public class TrainingV1Service implements ITrainingV1Service {
@Override
@Transactional
public void batchSaveAutoGenerateTrainings(List<TrainingNewVO> trainingVOList) {
if(!CollectionUtils.isEmpty(trainingVOList)) {
if (!CollectionUtils.isEmpty(trainingVOList)) {
LocalDateTime now = LocalDateTime.now();
Long userId = UserVO.system().getId();
List<TrainingWithBLOBs> list = new ArrayList<>();
@ -444,12 +447,12 @@ public class TrainingV1Service implements ITrainingV1Service {
training.setScenes(JsonUtils.writeValueAsString(trainingVO.getScenes()));
list.add(training);
//防止数据包溢出
if(list.size()>5){
if (list.size() > 5) {
trainingDAO.batchInsert(list);
list.clear();
}
});
if(list.size()>0){
if (list.size() > 0) {
trainingDAO.batchInsert(list);
}
}
@ -485,19 +488,20 @@ public class TrainingV1Service implements ITrainingV1Service {
@Override
public void deleteAutoGenerateTrainingBy(Long mapId) {
TrainingExample example = new TrainingExample();
example.createCriteria().andMapIdEqualTo(mapId);
List<Long> ids = this.trainingDAO.selectIdsByExample(example);
this.batchDeleteTrainingAndReferenceData(ids);
TrainingExample example = new TrainingExample();
example.createCriteria().andMapIdEqualTo(mapId);
List<Long> ids = this.trainingDAO.selectIdsByExample(example);
this.batchDeleteTrainingAndReferenceData(ids);
}
/**
* 批量删除实训
*
* @param ids
*/
@Transactional
public void batchDeleteTrainingAndReferenceData(List<Long> ids) {
if(!CollectionUtils.isEmpty(ids)) {
if (!CollectionUtils.isEmpty(ids)) {
// 删除实训=章节关系
this.iLessonDraftService.deleteChapterRelByTrainingIdList(ids);
this.iLessonService.deleteChapterRelByTrainingIdList(ids);
@ -519,17 +523,17 @@ public class TrainingV1Service implements ITrainingV1Service {
Integer maxDuration = config.getMaxDuration();
String remarks = config.getRemarks();
TrainingWithBLOBs update = new TrainingWithBLOBs();
if((Objects.nonNull(minDuration)
|| Objects.nonNull(maxDuration)
|| StringUtils.hasText(remarks))
if ((Objects.nonNull(minDuration)
|| Objects.nonNull(maxDuration)
|| StringUtils.hasText(remarks))
&& !CollectionUtils.isEmpty(config.getOperateType())) {
if(Objects.nonNull(minDuration)) {
if (Objects.nonNull(minDuration)) {
update.setMinDuration(minDuration);
}
if(Objects.nonNull(maxDuration)) {
if (Objects.nonNull(maxDuration)) {
update.setMaxDuration(maxDuration);
}
if(StringUtils.hasText(remarks)) {
if (StringUtils.hasText(remarks)) {
update.setRemarks(remarks);
}
config.getOperateType().forEach(operateType -> {
@ -567,7 +571,7 @@ public class TrainingV1Service implements ITrainingV1Service {
.andMapIdEqualTo(sourceMapId);
List<TrainingWithBLOBs> trainings = this.trainingDAO.selectByExampleWithBLOBs(example);
Map<Long, Long> relMap = new HashMap<>();
if(!CollectionUtils.isEmpty(trainings)) {
if (!CollectionUtils.isEmpty(trainings)) {
trainings.forEach(training -> {
Long oldId = training.getId();
training.setId(null);
@ -582,6 +586,7 @@ public class TrainingV1Service implements ITrainingV1Service {
/**
* 删除实训-关联删除
*
* @param training
*/
@Transactional
@ -603,6 +608,7 @@ public class TrainingV1Service implements ITrainingV1Service {
/**
* 根据实训id删除用户实训记录
*
* @param trainingId
*/
private void deleteUserTrainingRecordByTrainingId(Long trainingId) {
@ -613,6 +619,7 @@ public class TrainingV1Service implements ITrainingV1Service {
/**
* 根据实训id列表删除用户实训记录
*
* @param trainingIdList
*/
private void deleteUserTrainingRecordByTrainingIds(List<Long> trainingIdList) {
@ -624,39 +631,39 @@ public class TrainingV1Service implements ITrainingV1Service {
@Override
public PageVO<TrainingNewVO> pagedQueryTrainings(TrainingQueryVO trainingQueryVO) {
MapInfo mapInfo = null;
if (!ObjectUtils.isEmpty(trainingQueryVO.getMapId())){
if (!ObjectUtils.isEmpty(trainingQueryVO.getMapId())) {
mapInfo = mapInfoDAO.selectByPrimaryKey(trainingQueryVO.getMapId());
}
PageHelper.startPage(trainingQueryVO.getPageNum(), trainingQueryVO.getPageSize());
TrainingExample example = new TrainingExample();
example.setOrderByClause("id desc");
TrainingExample.Criteria criteria = example.createCriteria();
if(StringUtils.hasText(trainingQueryVO.getName())) {
if (StringUtils.hasText(trainingQueryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", trainingQueryVO.getName()));
}
if(StringUtils.hasText(trainingQueryVO.getGenerateType())) {
if(BusinessConsts.Training.GenerateType.GenerateType01.equals(trainingQueryVO.getGenerateType())) {
if (StringUtils.hasText(trainingQueryVO.getGenerateType())) {
if (BusinessConsts.Training.GenerateType.GenerateType01.equals(trainingQueryVO.getGenerateType())) {
criteria.andAuthorIdEqualTo(UserVO.system().getId());
}else if(BusinessConsts.Training.GenerateType.GenerateType02.equals(trainingQueryVO.getGenerateType())) {
} else if (BusinessConsts.Training.GenerateType.GenerateType02.equals(trainingQueryVO.getGenerateType())) {
criteria.andAuthorIdNotEqualTo(UserVO.system().getId());
}
}
// if(StringUtils.hasText(trainingQueryVO.getSkinCode())) {
// criteria.andSkinCodeEqualTo(trainingQueryVO.getSkinCode());
// }
if (!ObjectUtils.isEmpty(mapInfo)){
if (!ObjectUtils.isEmpty(mapInfo)) {
criteria.andMapIdEqualTo(mapInfo.getId());
}
if(StringUtils.hasText(trainingQueryVO.getPrdType())) {
if (StringUtils.hasText(trainingQueryVO.getPrdType())) {
criteria.andPrdTypeEqualTo(trainingQueryVO.getPrdType());
}
if(StringUtils.hasText(trainingQueryVO.getType())) {
if (StringUtils.hasText(trainingQueryVO.getType())) {
criteria.andTypeEqualTo(trainingQueryVO.getType());
}
if(StringUtils.hasText(trainingQueryVO.getOperateType())) {
if (StringUtils.hasText(trainingQueryVO.getOperateType())) {
criteria.andOperateTypeEqualTo(trainingQueryVO.getOperateType());
}
if(StringUtils.hasText(trainingQueryVO.getStatus())) {
if (StringUtils.hasText(trainingQueryVO.getStatus())) {
criteria.andStatusEqualTo(trainingQueryVO.getStatus());
}
Page<Training> trainings = (Page<Training>) this.trainingDAO.selectByExample(example);
@ -690,9 +697,12 @@ public class TrainingV1Service implements ITrainingV1Service {
}
@Override
public List<Training> findEntities(@NonNull Long mapId, @NonNull String prdType) {
public List<Training> findEntities(@NonNull Long mapId, String prdType) {
TrainingExample example = new TrainingExample();
example.createCriteria().andMapIdEqualTo(mapId).andPrdTypeEqualTo(prdType);
TrainingExample.Criteria criteria = example.createCriteria().andMapIdEqualTo(mapId);
if (StringUtils.hasText(prdType)) {
criteria.andPrdTypeEqualTo(prdType);
}
return trainingDAO.selectByExample(example);
}
@ -702,4 +712,13 @@ public class TrainingV1Service implements ITrainingV1Service {
example.createCriteria().andMapIdEqualTo(mapId);
return trainingDAO.selectByExample(example);
}
@Override
public Map<String, Map<String, Long>> queryTrainingTypeAndQuantity(Long mapId, String prdType) {
List<Training> trainings = findEntities(mapId, prdType);
return trainings.stream().collect(
Collectors.groupingBy(Training::getType,
Collectors.groupingBy(Training::getOperateType,
Collectors.counting())));
}
}

View File

@ -327,9 +327,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override
public String examSimulation(Long examId, LoginUserInfoVO loginUserInfoVO) {
ExamDefinitionVO examDefinitionVO = this.iExamService.queryExamInfo(examId);
LessonVO lessonVO = this.iLessonService.getLessonInfo(examDefinitionVO.getLessonId());
Simulation simulation = this.create(loginUserInfoVO, lessonVO.getMapId(),
MapPrdTypeEnum.getMapPrdTypeEnumByCode(lessonVO.getPrdType()),
Simulation simulation = this.create(loginUserInfoVO, examDefinitionVO.getMapId(),
MapPrdTypeEnum.getMapPrdTypeEnumByCode(examDefinitionVO.getPrdType()),
Simulation.FunctionalType.EXAM);
return simulation.getGroup();
}

View File

@ -27,13 +27,13 @@ public class ExamDefinitionRulesVO {
/**
* 题目数量
*/
@NotBlank(message = "题目数量不能为空")
@NotNull(message = "题目数量不能为空")
private Integer num;
/**
* 每题分数
*/
@NotBlank(message = "每题分数不能为空")
@NotNull(message = "每题分数不能为空")
private Integer point;
/**

View File

@ -5,7 +5,6 @@ import club.joylink.rtss.entity.SysUser;
import club.joylink.rtss.vo.client.org.DepartmentVO;
import club.joylink.rtss.vo.client.validGroup.ExamDefinitionCheck;
import club.joylink.rtss.vo.client.validGroup.ExamDefinitionRulesCheck;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@ -13,15 +12,19 @@ import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.CollectionUtils;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ApiModel(value = "考试定义")
@NoArgsConstructor
@ -34,41 +37,39 @@ public class ExamDefinitionVO {
/**
* 所属课程ID
*/
@NotNull(message = "课程ID不能为空", groups = {ExamDefinitionCheck.class})
private Long lessonId;
private String lessonName;
@NotNull(message = "地图id不能为空")
private Long mapId;
/**
* 考试名称
*/
@NotBlank(message = "考试名称不能为空", groups = {ExamDefinitionCheck.class})
@NotBlank(message = "考试名称不能为空")
private String name;
/**
* 考试类型数据字典值
*/
@NotBlank(message = "考试类型不能为空")
private String type;
private String prdType;
/**
* 考试时长:单位s
*/
@Min(value = 1, groups = {ExamDefinitionCheck.class})
@Min(value = 1)
private Integer duration;
/**
* 考试开始时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
/**
* 考试结束时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
/**
@ -79,13 +80,13 @@ public class ExamDefinitionVO {
/**
* 满分
*/
@Min(value = 1, groups = {ExamDefinitionRulesCheck.class})
@Min(value = 1)
private Integer fullPoint;
/**
* 及格分
*/
@Min(value = 0, groups = {ExamDefinitionCheck.class})
@Min(value = 0)
private Integer passingPoint;
/**
@ -129,9 +130,17 @@ public class ExamDefinitionVO {
private List<Long> clsIds;
@Valid
@NotNull(message = "考试规则不能为空", groups = {ExamDefinitionCheck.class, ExamDefinitionRulesCheck.class})
@NotNull(message = "考试规则不能为空")
private List<ExamDefinitionRulesVO> examDefinitionRulesVOList;
public static List<ExamDefinitionVO> convert(List<ExamDefinition> exams) {
if (CollectionUtils.isEmpty(exams)) {
return new ArrayList<>();
} else {
return exams.stream().map(ExamDefinitionVO::new).collect(Collectors.toList());
}
}
@ApiIgnore
public String getCreatorIdStr() {
return String.valueOf(this.creatorId);
@ -140,8 +149,9 @@ public class ExamDefinitionVO {
public ExamDefinitionVO(ExamDefinition examDefinition) {
this.id = examDefinition.getId();
this.lessonId = examDefinition.getLessonId();
this.mapId = examDefinition.getMapId();
this.name = examDefinition.getName();
this.type = examDefinition.getType();
this.prdType = examDefinition.getType();
this.duration = examDefinition.getDuration();
this.startTime = examDefinition.getStartTime();
this.endTime = examDefinition.getEndTime();
@ -156,24 +166,25 @@ public class ExamDefinitionVO {
public ExamDefinitionVO(ExamDefinition examDefinition, SysUser creator) {
this(examDefinition);
this.creatorName = creator.getName();
this.creatorNickname = creator.getNickname();
if (creator != null) {
this.creatorName = creator.getName();
this.creatorNickname = creator.getNickname();
}
}
public ExamDefinition toDB() {
ExamDefinition definition = new ExamDefinition();
definition.setLessonId(this.getLessonId());
definition.setMapId(this.mapId);
definition.setName(this.getName());
definition.setType(this.getType());
definition.setType(this.getPrdType());
definition.setDuration(this.getDuration());
definition.setStartTime(this.getStartTime());
definition.setEndTime(this.getEndTime());
definition.setFullPoint(this.getFullPoint());
definition.setPassingPoint(this.getPassingPoint());
definition.setCreatorId(this.getCreatorId());
definition.setCreateTime(this.getCreateTime());
definition.setRemarks(this.getRemarks());
definition.setStatus(this.getStatus());
definition.setTrial(Objects.requireNonNullElse(trial, false));
return definition;
}

View File

@ -18,6 +18,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
@ -131,7 +132,7 @@ public class MapVO {
if (!CollectionUtils.isEmpty(list)) {
return list.stream().map(MapVO::new).collect(Collectors.toList());
}
return null;
return new ArrayList<>();
}

View File

@ -25,6 +25,8 @@ public class CompanyVO {
private String projectCode;
private String code;
public CompanyVO(Org entity) {
this.id = entity.getId();
this.name = entity.getName();

View File

@ -74,9 +74,11 @@ public class DepartmentVO {
public DepartmentVO(Org entity, Integer numberOfPeople, SysUser creator) {
this(entity, numberOfPeople);
this.creatorId = creator.getId();
this.creatorName = creator.getName();
this.creatorNickName = creator.getNickname();
if (creator != null) {
this.creatorId = creator.getId();
this.creatorName = creator.getName();
this.creatorNickName = creator.getNickname();
}
}
public static List<DepartmentVO> convert2VOList(List<Org> dataList) {

View File

@ -122,11 +122,10 @@ public class OrgScoringRuleVO {
return rule;
}
public OrgScoringRuleWithBLOBs cover4Update(OrgScoringRuleWithBLOBs entity) {
public void cover4Update(OrgScoringRuleWithBLOBs entity) {
entity.setSchoolYear(schoolYear);
entity.setTerm(term);
entity.setFinalScoringRule(JsonUtils.writeValueAsString(scoringRules));
return entity;
}
/**

View File

@ -3,6 +3,7 @@
<mapper namespace="club.joylink.rtss.dao.ExamDefinitionDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.ExamDefinition">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="map_id" jdbcType="BIGINT" property="mapId" />
<result column="lesson_id" jdbcType="BIGINT" property="lessonId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="type" jdbcType="VARCHAR" property="type" />
@ -15,7 +16,7 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="trial" jdbcType="BIT" property="trial" />
<result column="trial" jdbcType="TINYINT" property="trial" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -76,8 +77,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, lesson_id, `name`, `type`, duration, start_time, end_time, full_point, passing_point,
creator_id, create_time, remarks, `status`, trial
id, map_id, lesson_id, `name`, `type`, duration, start_time, end_time, full_point,
passing_point, creator_id, create_time, remarks, `status`, trial
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.ExamDefinitionExample" resultMap="BaseResultMap">
select
@ -118,20 +119,23 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.ExamDefinition" useGeneratedKeys="true">
insert into exam_definition (lesson_id, `name`, `type`,
duration, start_time, end_time,
full_point, passing_point, creator_id,
create_time, remarks, `status`,
trial)
values (#{lessonId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{duration,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{fullPoint,jdbcType=INTEGER}, #{passingPoint,jdbcType=INTEGER}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{trial,jdbcType=BIT})
insert into exam_definition (map_id, lesson_id, `name`,
`type`, duration, start_time,
end_time, full_point, passing_point,
creator_id, create_time, remarks,
`status`, trial)
values (#{mapId,jdbcType=BIGINT}, #{lessonId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{duration,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP},
#{endTime,jdbcType=TIMESTAMP}, #{fullPoint,jdbcType=INTEGER}, #{passingPoint,jdbcType=INTEGER},
#{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{trial,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.ExamDefinition" useGeneratedKeys="true">
insert into exam_definition
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mapId != null">
map_id,
</if>
<if test="lessonId != null">
lesson_id,
</if>
@ -173,6 +177,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mapId != null">
#{mapId,jdbcType=BIGINT},
</if>
<if test="lessonId != null">
#{lessonId,jdbcType=BIGINT},
</if>
@ -210,7 +217,7 @@
#{status,jdbcType=VARCHAR},
</if>
<if test="trial != null">
#{trial,jdbcType=BIT},
#{trial,jdbcType=TINYINT},
</if>
</trim>
</insert>
@ -226,6 +233,9 @@
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.mapId != null">
map_id = #{record.mapId,jdbcType=BIGINT},
</if>
<if test="record.lessonId != null">
lesson_id = #{record.lessonId,jdbcType=BIGINT},
</if>
@ -263,7 +273,7 @@
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.trial != null">
trial = #{record.trial,jdbcType=BIT},
trial = #{record.trial,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
@ -273,6 +283,7 @@
<update id="updateByExample" parameterType="map">
update exam_definition
set id = #{record.id,jdbcType=BIGINT},
map_id = #{record.mapId,jdbcType=BIGINT},
lesson_id = #{record.lessonId,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
@ -285,7 +296,7 @@
create_time = #{record.createTime,jdbcType=TIMESTAMP},
remarks = #{record.remarks,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
trial = #{record.trial,jdbcType=BIT}
trial = #{record.trial,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -293,6 +304,9 @@
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.ExamDefinition">
update exam_definition
<set>
<if test="mapId != null">
map_id = #{mapId,jdbcType=BIGINT},
</if>
<if test="lessonId != null">
lesson_id = #{lessonId,jdbcType=BIGINT},
</if>
@ -330,14 +344,15 @@
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="trial != null">
trial = #{trial,jdbcType=BIT},
trial = #{trial,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.ExamDefinition">
update exam_definition
set lesson_id = #{lessonId,jdbcType=BIGINT},
set map_id = #{mapId,jdbcType=BIGINT},
lesson_id = #{lessonId,jdbcType=BIGINT},
`name` = #{name,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
duration = #{duration,jdbcType=INTEGER},
@ -349,7 +364,7 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
trial = #{trial,jdbcType=BIT}
trial = #{trial,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -73,7 +73,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, parent_id, root_id, project_code, code, creator_id, create_time, update_id,
id, `name`, parent_id, root_id, project_code, code, creator_id, create_time, update_id,
update_time, `status`
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.OrgExample" resultMap="BaseResultMap">
@ -99,7 +99,7 @@
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from org
where id = #{id,jdbcType=BIGINT}
@ -115,13 +115,13 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.Org" useGeneratedKeys="true">
insert into org (`name`, parent_id, root_id,
project_code, code, creator_id,
create_time, update_id, update_time,
insert into org (`name`, parent_id, root_id,
project_code, code, creator_id,
create_time, update_id, update_time,
`status`)
values (#{name,jdbcType=VARCHAR}, #{parentId,jdbcType=BIGINT}, #{rootId,jdbcType=BIGINT},
#{projectCode,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
values (#{name,jdbcType=VARCHAR}, #{parentId,jdbcType=BIGINT}, #{rootId,jdbcType=BIGINT},
#{projectCode,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
#{status,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.Org" useGeneratedKeys="true">
@ -305,4 +305,25 @@
`status` = #{status,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<!-- 自定义 -->
<resultMap id="queryByExamIdsResultMap" type="club.joylink.rtss.vo.client.ExamDefinitionVO">
<result column="exam_id" property="id"/>
<collection property="clsIds" ofType="Long" javaType="List">
<result column="org_id"/>
</collection>
</resultMap>
<select id="queryByExamIds" resultMap="queryByExamIdsResultMap">
SELECT
*
FROM
org
JOIN org_exam ON org.id = org_exam.org_id
where org_exam.exam_id in
<foreach collection="examIds" item="examId" open="(" separator="," close=")">
#{examId}
</foreach>
<if test="'' != status">
and org.status = #{status}
</if>
</select>
</mapper>

View File

@ -2,8 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.rtss.dao.OrgExamDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.OrgExam">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="exam_id" jdbcType="BIGINT" property="examId" />
<result column="org_id" jdbcType="INTEGER" property="orgId" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="creator_id" jdbcType="BIGINT" property="creatorId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -64,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
exam_id, org_id
id, exam_id, org_id, creator_id, create_time
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.OrgExamExample" resultMap="BaseResultMap">
select
@ -88,17 +91,29 @@
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from org_exam
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from org_exam
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.OrgExamExample">
delete from org_exam
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.OrgExam">
insert into org_exam (exam_id, org_id)
values (#{examId,jdbcType=BIGINT}, #{orgId,jdbcType=INTEGER})
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgExam" useGeneratedKeys="true">
insert into org_exam (exam_id, org_id, creator_id,
create_time)
values (#{examId,jdbcType=BIGINT}, #{orgId,jdbcType=BIGINT}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.OrgExam">
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgExam" useGeneratedKeys="true">
insert into org_exam
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="examId != null">
@ -107,13 +122,25 @@
<if test="orgId != null">
org_id,
</if>
<if test="creatorId != null">
creator_id,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="examId != null">
#{examId,jdbcType=BIGINT},
</if>
<if test="orgId != null">
#{orgId,jdbcType=INTEGER},
#{orgId,jdbcType=BIGINT},
</if>
<if test="creatorId != null">
#{creatorId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
@ -126,11 +153,20 @@
<update id="updateByExampleSelective" parameterType="map">
update org_exam
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.examId != null">
exam_id = #{record.examId,jdbcType=BIGINT},
</if>
<if test="record.orgId != null">
org_id = #{record.orgId,jdbcType=INTEGER},
org_id = #{record.orgId,jdbcType=BIGINT},
</if>
<if test="record.creatorId != null">
creator_id = #{record.creatorId,jdbcType=BIGINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
@ -139,10 +175,39 @@
</update>
<update id="updateByExample" parameterType="map">
update org_exam
set exam_id = #{record.examId,jdbcType=BIGINT},
org_id = #{record.orgId,jdbcType=INTEGER}
set id = #{record.id,jdbcType=BIGINT},
exam_id = #{record.examId,jdbcType=BIGINT},
org_id = #{record.orgId,jdbcType=BIGINT},
creator_id = #{record.creatorId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.OrgExam">
update org_exam
<set>
<if test="examId != null">
exam_id = #{examId,jdbcType=BIGINT},
</if>
<if test="orgId != null">
org_id = #{orgId,jdbcType=BIGINT},
</if>
<if test="creatorId != null">
creator_id = #{creatorId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.OrgExam">
update org_exam
set exam_id = #{examId,jdbcType=BIGINT},
org_id = #{orgId,jdbcType=BIGINT},
creator_id = #{creatorId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -2,6 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.rtss.dao.OrgLessonDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.OrgLesson">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="lesson_id" jdbcType="BIGINT" property="lessonId" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="creator_id" jdbcType="BIGINT" property="creatorId" />
@ -66,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
lesson_id, org_id, creator_id, create_time
id, lesson_id, org_id, creator_id, create_time
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.OrgLessonExample" resultMap="BaseResultMap">
select
@ -90,19 +91,29 @@
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from org_lesson
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from org_lesson
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.OrgLessonExample">
delete from org_lesson
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.OrgLesson">
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgLesson" useGeneratedKeys="true">
insert into org_lesson (lesson_id, org_id, creator_id,
create_time)
values (#{lessonId,jdbcType=BIGINT}, #{orgId,jdbcType=BIGINT}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.OrgLesson">
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgLesson" useGeneratedKeys="true">
insert into org_lesson
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="lessonId != null">
@ -142,6 +153,9 @@
<update id="updateByExampleSelective" parameterType="map">
update org_lesson
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.lessonId != null">
lesson_id = #{record.lessonId,jdbcType=BIGINT},
</if>
@ -161,7 +175,8 @@
</update>
<update id="updateByExample" parameterType="map">
update org_lesson
set lesson_id = #{record.lessonId,jdbcType=BIGINT},
set id = #{record.id,jdbcType=BIGINT},
lesson_id = #{record.lessonId,jdbcType=BIGINT},
org_id = #{record.orgId,jdbcType=BIGINT},
creator_id = #{record.creatorId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}
@ -169,4 +184,30 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.OrgLesson">
update org_lesson
<set>
<if test="lessonId != null">
lesson_id = #{lessonId,jdbcType=BIGINT},
</if>
<if test="orgId != null">
org_id = #{orgId,jdbcType=BIGINT},
</if>
<if test="creatorId != null">
creator_id = #{creatorId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.OrgLesson">
update org_lesson
set lesson_id = #{lessonId,jdbcType=BIGINT},
org_id = #{orgId,jdbcType=BIGINT},
creator_id = #{creatorId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -195,10 +195,10 @@
</update>
<!-- 自定义 -->
<insert id="batchInsert">
insert into org_scoring_rule_rel (org_id, rule_id)
insert into org_scoring_rule_rel (org_id, rule_id, rule_org_id, rule_school_year, rule_term, rule_creator_id)
values
<foreach collection="rels" item="rel" separator=",">
(#{rel.orgId}, #{rel.ruleId})
(#{rel.orgId}, #{rel.ruleId}, #{rel.ruleOrgId}, #{rel.ruleSchoolYear}, #{rel.ruleTerm}, #{rel.ruleCreatorId})
</foreach>
</insert>
</mapper>