Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
walker-sheng 2021-03-23 18:27:45 +08:00
commit ca2ea3a606
38 changed files with 1594 additions and 380 deletions

15
sql/20210322-zhangsai.sql Normal file
View File

@ -0,0 +1,15 @@
-- 评价规则表添加字段
alter table org_scoring_rule
add `name` varchar(64) not null comment '名称' after id;
-- 创建表
create table org_scoring_rule_rel
(
org_id int not null,
rule_id bigint not null
)
comment '班级与评价规则关联表';
-- 组织表添加字段
alter table org
add status varchar(1) not null comment '状态';

View File

@ -789,4 +789,11 @@ public interface BusinessConsts {
enum OrgRole { enum OrgRole {
Admin,Teacher, Student Admin,Teacher, Student
} }
interface Org{
interface Status {
String DELETE = "0";
String VALID = "1";
}
}
} }

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.controller; package club.joylink.rtss.controller;
import club.joylink.rtss.constants.RoleEnum;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor; 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.IOrgLessonService;
import club.joylink.rtss.services.org.IOrgScoringRuleService; import club.joylink.rtss.services.org.IOrgScoringRuleService;
import club.joylink.rtss.services.org.IOrgService; import club.joylink.rtss.services.org.IOrgService;
@ -52,9 +54,8 @@ public class OrgController {
@ApiOperation(value = "分页获取公司列表") @ApiOperation(value = "分页获取公司列表")
@GetMapping("paging") @GetMapping("paging")
public PageVO<CompanyVO> pagingQueryAll(CompanyQueryVO queryVO) { public PageVO<CompanyVO> pagingQueryAll(OrgQueryVO queryVO) {
PageVO<CompanyVO> list = iOrgUserService.queryPageOrganizations(queryVO); return iOrgUserService.queryPageOrganizations(queryVO);
return list;
} }
@ApiOperation(value = "删除公司信息") @ApiOperation(value = "删除公司信息")
@ -164,10 +165,10 @@ public class OrgController {
iOrgUserService.deleteDepartUserInfo(user, userDepartRelVO); iOrgUserService.deleteDepartUserInfo(user, userDepartRelVO);
} }
@ApiOperation(value = "分页获取单位部门成员信息") @ApiOperation(value = "分页获取班级学生信息")
@GetMapping("/dept/{deptId}/departUserInfo") @GetMapping("/dept/{clsId}/departUserInfo")
public PageVO<CompanyDepartUserVO> getCompanyUserInfo(@RequestAttribute @ApiIgnore UserVO user, @PathVariable Integer deptId, CompanyUserQueryVO companyUserQueryVO) { public PageVO<CompanyDepartUserVO> getCompanyUserInfo(@RequestAttribute @ApiIgnore UserVO user, @PathVariable Integer clsId, CompanyUserQueryVO companyUserQueryVO) {
return iOrgUserService.getCompanyDepartUserInfoList(user, deptId, companyUserQueryVO); return iOrgUserService.getCompanyDepartUserInfoList(user, clsId, companyUserQueryVO);
} }
@ApiOperation(value = "导入单位成员信息") @ApiOperation(value = "导入单位成员信息")
@ -206,28 +207,22 @@ public class OrgController {
iOrgService.createCls(createVO, loginInfo); iOrgService.createCls(createVO, loginInfo);
} }
@ApiOperation("分页查询所有班级")
@GetMapping("/paged/cls")
public PageVO<DepartmentVO> pagedQueryCls(CompanyQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgService.pagedQueryCls(queryVO, loginInfo, false);
}
@ApiOperation("分页查询个人创建的班级") @ApiOperation("分页查询个人创建的班级")
@GetMapping("/paged/cls/self") @GetMapping("/paged/cls/self")
public PageVO<DepartmentVO> pagedQuerySelfCls(CompanyQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { public PageVO<DepartmentVO> pagedQuerySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgService.pagedQueryCls(queryVO, loginInfo, true); return iOrgService.pagedQueryCls(queryVO, loginInfo, true);
} }
@ApiOperation("查询个人创建的班级") @ApiOperation("查询个人创建的班级")
@GetMapping("/list/cls/self") @GetMapping("/list/cls/self")
public List<DepartmentVO> querySelfCls(CompanyQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { public List<DepartmentVO> querySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgService.queryCls(queryVO, loginInfo, true); return iOrgService.queryCls(queryVO, loginInfo, true);
} }
@ApiOperation("创建评价规则") @ApiOperation("创建评价规则")
@PostMapping("/orgScoringRule") @PostMapping("/orgScoringRule")
public void createScoringRule(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute UserVO user) { public void createScoringRule(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute LoginUserInfoVO loginInfo) {
iOrgScoringRuleService.createScoringRule(orgScoringRuleVO, user); iOrgScoringRuleService.createScoringRule(orgScoringRuleVO, loginInfo);
} }
@ApiOperation("保存评价规则") @ApiOperation("保存评价规则")
@ -245,8 +240,8 @@ public class OrgController {
@ApiOperation("查询自己创建的指定评价规则详细信息") @ApiOperation("查询自己创建的指定评价规则详细信息")
@GetMapping("/orgScoringRule/details/self/{orgId}/{schoolYear}/{term}") @GetMapping("/orgScoringRule/details/self/{orgId}/{schoolYear}/{term}")
public OrgScoringRuleVO queryOrgScoringRuleDetails(@PathVariable Integer orgId, @PathVariable String schoolYear, public OrgScoringRuleVO queryOrgScoringRuleDetails(@PathVariable Integer orgId, @PathVariable String schoolYear,
@PathVariable Integer term, @RequestAttribute UserVO user) { @PathVariable Integer term, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgScoringRuleService.queryOrgScoringRuleDetails(orgId, schoolYear, term, user); return iOrgScoringRuleService.queryOrgScoringRuleDetails(orgId, schoolYear, term, loginInfo);
} }
@ApiOperation("查询指定评价规则详细信息") @ApiOperation("查询指定评价规则详细信息")
@ -255,17 +250,11 @@ public class OrgController {
return iOrgScoringRuleService.getOrgScoringRuleDetails(ruleId); return iOrgScoringRuleService.getOrgScoringRuleDetails(ruleId);
} }
@ApiOperation("使用评价规则评分")
@GetMapping("/orgScoringRule/score")
public List<OrgScoringResultVO> score(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute UserVO user) {
return iOrgScoringRuleService.score(orgScoringRuleVO, user);
}
@ApiOperation("使用评价规则评分") @ApiOperation("使用评价规则评分")
@GetMapping("/orgScoringRule/score/{orgId}/{schoolYear}/{term}") @GetMapping("/orgScoringRule/score/{orgId}/{schoolYear}/{term}")
public List<OrgScoringResultVO> score(@PathVariable Integer orgId, @PathVariable String schoolYear, public List<OrgScoringResultVO> score(@PathVariable Integer orgId, @PathVariable String schoolYear,
@PathVariable Integer term, @RequestAttribute UserVO user) { @PathVariable Integer term, @RequestAttribute LoginUserInfoVO loginInfo) {
return iOrgScoringRuleService.score(orgId, schoolYear, term , user); return iOrgScoringRuleService.score(orgId, schoolYear, term, loginInfo);
} }
@ApiOperation("删除评分规则") @ApiOperation("删除评分规则")
@ -273,4 +262,23 @@ public class OrgController {
public void deleteScoringRule(@PathVariable Long ruleId, @RequestAttribute UserVO user) { public void deleteScoringRule(@PathVariable Long ruleId, @RequestAttribute UserVO user) {
iOrgScoringRuleService.deleteRuleOfSelf(ruleId, user.getId()); iOrgScoringRuleService.deleteRuleOfSelf(ruleId, user.getId());
} }
@ApiOperation("查询规则能够应用到的组织")
@GetMapping("/orgScoringRule/{ruleId}/canApplyTo")
public List<DepartmentVO> queryRuleCanApplyTo(@PathVariable Long ruleId) {
return iOrgScoringRuleService.queryRuleCanApplyTo(ruleId);
}
@ApiOperation("将评价规则应用到")
@PostMapping("/orgScoringRule/{ruleId}/apply")
public void applyOrgScoringRule(@PathVariable Long ruleId, @RequestBody List<Integer> orgIds) {
iOrgScoringRuleService.applyOrgScoringRule(ruleId, orgIds);
}
@Role(RoleEnum.Admin)
@ApiOperation("管理员查看非顶级组织")
@GetMapping("/org/admin/paged")
public PageVO<DepartmentVO> adminPagedQueryOrg(OrgQueryVO queryVO) {
return iOrgService.adminPagedQueryOrg(queryVO);
}
} }

View File

@ -112,15 +112,21 @@ public class ExamController {
this.iExamService.update(id, examDefinitionVO); this.iExamService.update(id, examDefinitionVO);
} }
@ApiOperation(value = "分页查询自己创建的试卷") @ApiOperation(value = "分页查询当前登录项目下自己创建的试卷")
@GetMapping("/paged/org/self") @GetMapping("/paged/loginProject/self")
public PageVO<ExamDefinitionVO> pagedQuerySelfExam(ExamDefinitionQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { public PageVO<ExamDefinitionVO> pagedQuerySelfExam(ExamDefinitionQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return this.iExamService.pagedQuerySelfExam4OrgTeacher(queryVO, loginInfo); return this.iExamService.pagedQueryExamICreated(queryVO, loginInfo);
} }
@ApiOperation(value = "不分页查询自己为指定班级创建的试卷") @ApiOperation(value = "不分页查询当前登录项目下自己创建的试卷")
@GetMapping("/list/loginProject/self")
public List<ExamDefinitionVO> listQueryExamICreated(ExamDefinitionQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
return this.iExamService.listQueryExamICreated(queryVO, loginInfo);
}
@ApiOperation(value = "不分页查询组织下自己创建的试卷")
@GetMapping("/list/org/self") @GetMapping("/list/org/self")
public List<ExamDefinitionVO> listQuerySelfExam(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) { public List<ExamDefinitionVO> listQueryOrgExamOfSelf(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) {
return this.iExamService.listQueryOrgExamOfSelf(clsId, loginInfo); return this.iExamService.listQueryOrgExamICreated(clsId, loginInfo);
} }
} }

View File

@ -132,10 +132,10 @@ public class LessonController {
@ApiOperation(value = "查询用户当前登录的项目下的课程") @ApiOperation(value = "查询用户当前登录的项目下的课程")
@GetMapping(path = "/unPaged/self") @GetMapping(path = "/unPaged/self")
public List<LessonVO> queryPersonalLesson(@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginInfo) { public List<LessonVO> queryPersonalLesson(@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginInfo) {
return iLessonService.queryPersonalLesson(loginInfo); return iLessonService.queryLessonICreatedInLoginProject(loginInfo);
} }
@ApiOperation(value = "查询自己给指定班级创建的试卷") @ApiOperation(value = "查询自己给指定班级创建的课程")
@GetMapping(path = "/list/org/self") @GetMapping(path = "/list/org/self")
public List<LessonVO> queryOrgLessonOfSelf(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) { public List<LessonVO> queryOrgLessonOfSelf(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) {
return iLessonService.queryOrgLessonOfSelf(clsId, loginInfo); return iLessonService.queryOrgLessonOfSelf(clsId, loginInfo);

View File

@ -0,0 +1,15 @@
package club.joylink.rtss.dao;
import club.joylink.rtss.entity.OrgScoringRuleRel;
import club.joylink.rtss.entity.OrgScoringRuleRelExample;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* OrgScoringRuleRelDAO继承基类
*/
@Repository
public interface OrgScoringRuleRelDAO extends MyBatisBaseDao<OrgScoringRuleRel, OrgScoringRuleRel, OrgScoringRuleRelExample> {
void batchInsert(List<OrgScoringRuleRel> rels);
}

View File

@ -36,7 +36,7 @@ public class Org implements Serializable {
private String code; private String code;
/** /**
* 创建时间 * 创建
*/ */
private Long creatorId; private Long creatorId;
@ -55,6 +55,11 @@ public class Org implements Serializable {
*/ */
private LocalDateTime updateTime; private LocalDateTime updateTime;
/**
* 状态
*/
private String status;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Integer getId() {
@ -137,6 +142,14 @@ public class Org implements Serializable {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override @Override
public boolean equals(Object that) { public boolean equals(Object that) {
if (this == that) { if (this == that) {
@ -158,7 +171,8 @@ public class Org implements Serializable {
&& (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId())) && (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateId() == null ? other.getUpdateId() == null : this.getUpdateId().equals(other.getUpdateId())) && (this.getUpdateId() == null ? other.getUpdateId() == null : this.getUpdateId().equals(other.getUpdateId()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())); && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
} }
@Override @Override
@ -175,6 +189,7 @@ public class Org implements Serializable {
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateId() == null) ? 0 : getUpdateId().hashCode()); result = prime * result + ((getUpdateId() == null) ? 0 : getUpdateId().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
return result; return result;
} }
@ -194,8 +209,9 @@ public class Org implements Serializable {
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", updateId=").append(updateId); sb.append(", updateId=").append(updateId);
sb.append(", updateTime=").append(updateTime); sb.append(", updateTime=").append(updateTime);
sb.append(", status=").append(status);
sb.append(", serialVersionUID=").append(serialVersionUID); sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -754,6 +754,76 @@ public class OrgExample {
addCriterion("update_time not between", value1, value2, "updateTime"); addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
} }
/** /**
@ -850,4 +920,4 @@ public class OrgExample {
this(condition, value, secondValue, null); this(condition, value, secondValue, null);
} }
} }
} }

View File

@ -4,14 +4,19 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* @author * @author
* 组织评分规则 * 组织评分规则
*/ */
public class OrgScoringRule implements Serializable { public class OrgScoringRule implements Serializable {
private Long id; private Long id;
/** /**
* 组织班级id * 名称
*/
private String name;
/**
* 该规则属于哪个顶级组织
*/ */
private Integer orgId; private Integer orgId;
@ -55,6 +60,14 @@ public class OrgScoringRule implements Serializable {
this.id = id; this.id = id;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getOrgId() { public Integer getOrgId() {
return orgId; return orgId;
} }
@ -124,6 +137,7 @@ public class OrgScoringRule implements Serializable {
} }
OrgScoringRule other = (OrgScoringRule) that; OrgScoringRule other = (OrgScoringRule) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId())) && (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
&& (this.getSchoolYear() == null ? other.getSchoolYear() == null : this.getSchoolYear().equals(other.getSchoolYear())) && (this.getSchoolYear() == null ? other.getSchoolYear() == null : this.getSchoolYear().equals(other.getSchoolYear()))
&& (this.getTerm() == null ? other.getTerm() == null : this.getTerm().equals(other.getTerm())) && (this.getTerm() == null ? other.getTerm() == null : this.getTerm().equals(other.getTerm()))
@ -138,6 +152,7 @@ public class OrgScoringRule implements Serializable {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode()); result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
result = prime * result + ((getSchoolYear() == null) ? 0 : getSchoolYear().hashCode()); result = prime * result + ((getSchoolYear() == null) ? 0 : getSchoolYear().hashCode());
result = prime * result + ((getTerm() == null) ? 0 : getTerm().hashCode()); result = prime * result + ((getTerm() == null) ? 0 : getTerm().hashCode());
@ -155,6 +170,7 @@ public class OrgScoringRule implements Serializable {
sb.append(" ["); sb.append(" [");
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", name=").append(name);
sb.append(", orgId=").append(orgId); sb.append(", orgId=").append(orgId);
sb.append(", schoolYear=").append(schoolYear); sb.append(", schoolYear=").append(schoolYear);
sb.append(", term=").append(term); sb.append(", term=").append(term);

View File

@ -185,6 +185,76 @@ public class OrgScoringRuleExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andOrgIdIsNull() { public Criteria andOrgIdIsNull() {
addCriterion("org_id is null"); addCriterion("org_id is null");
return (Criteria) this; return (Criteria) this;

View File

@ -0,0 +1,69 @@
package club.joylink.rtss.entity;
import java.io.Serializable;
/**
* @author
* 班级与评价规则关联表
*/
public class OrgScoringRuleRel implements Serializable {
private Integer orgId;
private Long ruleId;
private static final long serialVersionUID = 1L;
public Integer getOrgId() {
return orgId;
}
public void setOrgId(Integer orgId) {
this.orgId = orgId;
}
public Long getRuleId() {
return ruleId;
}
public void setRuleId(Long ruleId) {
this.ruleId = ruleId;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
OrgScoringRuleRel other = (OrgScoringRuleRel) that;
return (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
&& (this.getRuleId() == null ? other.getRuleId() == null : this.getRuleId().equals(other.getRuleId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
result = prime * result + ((getRuleId() == null) ? 0 : getRuleId().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", orgId=").append(orgId);
sb.append(", ruleId=").append(ruleId);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,342 @@
package club.joylink.rtss.entity;
import java.util.ArrayList;
import java.util.List;
public class OrgScoringRuleRelExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public OrgScoringRuleRelExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andOrgIdIsNull() {
addCriterion("org_id is null");
return (Criteria) this;
}
public Criteria andOrgIdIsNotNull() {
addCriterion("org_id is not null");
return (Criteria) this;
}
public Criteria andOrgIdEqualTo(Integer value) {
addCriterion("org_id =", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdNotEqualTo(Integer value) {
addCriterion("org_id <>", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdGreaterThan(Integer value) {
addCriterion("org_id >", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdGreaterThanOrEqualTo(Integer value) {
addCriterion("org_id >=", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdLessThan(Integer value) {
addCriterion("org_id <", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdLessThanOrEqualTo(Integer value) {
addCriterion("org_id <=", value, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdIn(List<Integer> values) {
addCriterion("org_id in", values, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdNotIn(List<Integer> values) {
addCriterion("org_id not in", values, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdBetween(Integer value1, Integer value2) {
addCriterion("org_id between", value1, value2, "orgId");
return (Criteria) this;
}
public Criteria andOrgIdNotBetween(Integer value1, Integer value2) {
addCriterion("org_id not between", value1, value2, "orgId");
return (Criteria) this;
}
public Criteria andRuleIdIsNull() {
addCriterion("rule_id is null");
return (Criteria) this;
}
public Criteria andRuleIdIsNotNull() {
addCriterion("rule_id is not null");
return (Criteria) this;
}
public Criteria andRuleIdEqualTo(Long value) {
addCriterion("rule_id =", value, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdNotEqualTo(Long value) {
addCriterion("rule_id <>", value, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdGreaterThan(Long value) {
addCriterion("rule_id >", value, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdGreaterThanOrEqualTo(Long value) {
addCriterion("rule_id >=", value, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdLessThan(Long value) {
addCriterion("rule_id <", value, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdLessThanOrEqualTo(Long value) {
addCriterion("rule_id <=", value, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdIn(List<Long> values) {
addCriterion("rule_id in", values, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdNotIn(List<Long> values) {
addCriterion("rule_id not in", values, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdBetween(Long value1, Long value2) {
addCriterion("rule_id between", value1, value2, "ruleId");
return (Criteria) this;
}
public Criteria andRuleIdNotBetween(Long value1, Long value2) {
addCriterion("rule_id not between", value1, value2, "ruleId");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -3,7 +3,7 @@ package club.joylink.rtss.entity;
import java.io.Serializable; import java.io.Serializable;
/** /**
* @author * @author
* 组织评分规则 * 组织评分规则
*/ */
public class OrgScoringRuleWithBLOBs extends OrgScoringRule implements Serializable { public class OrgScoringRuleWithBLOBs extends OrgScoringRule implements Serializable {
@ -48,6 +48,7 @@ public class OrgScoringRuleWithBLOBs extends OrgScoringRule implements Serializa
} }
OrgScoringRuleWithBLOBs other = (OrgScoringRuleWithBLOBs) that; OrgScoringRuleWithBLOBs other = (OrgScoringRuleWithBLOBs) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId())) && (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
&& (this.getSchoolYear() == null ? other.getSchoolYear() == null : this.getSchoolYear().equals(other.getSchoolYear())) && (this.getSchoolYear() == null ? other.getSchoolYear() == null : this.getSchoolYear().equals(other.getSchoolYear()))
&& (this.getTerm() == null ? other.getTerm() == null : this.getTerm().equals(other.getTerm())) && (this.getTerm() == null ? other.getTerm() == null : this.getTerm().equals(other.getTerm()))
@ -64,6 +65,7 @@ public class OrgScoringRuleWithBLOBs extends OrgScoringRule implements Serializa
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode()); result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
result = prime * result + ((getSchoolYear() == null) ? 0 : getSchoolYear().hashCode()); result = prime * result + ((getSchoolYear() == null) ? 0 : getSchoolYear().hashCode());
result = prime * result + ((getTerm() == null) ? 0 : getTerm().hashCode()); result = prime * result + ((getTerm() == null) ? 0 : getTerm().hashCode());

View File

@ -14,7 +14,6 @@ import club.joylink.rtss.vo.client.*;
import club.joylink.rtss.vo.client.org.DepartmentVO; import club.joylink.rtss.vo.client.org.DepartmentVO;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -445,6 +444,7 @@ public class ExamService implements IExamService {
examDefinitionDAO.deleteByPrimaryKey(Long.parseLong(id)); examDefinitionDAO.deleteByPrimaryKey(Long.parseLong(id));
} }
// /** // /**
// * 查询章节下允许创建的最多题目数量 // * 查询章节下允许创建的最多题目数量
// * // *
@ -465,7 +465,6 @@ public class ExamService implements IExamService {
// //
// return lsRelChapterTrainingList.size(); // return lsRelChapterTrainingList.size();
// } // }
@Override @Override
public Long queryTrainingNum(Long lessonId, String trainingType, String operateType) { public Long queryTrainingNum(Long lessonId, String trainingType, String operateType) {
// 获取课程数据 // 获取课程数据
@ -501,6 +500,20 @@ public class ExamService implements IExamService {
forceOffline(exam); forceOffline(exam);
} }
@Override
public ExamDefinition getEntity(Long examId) {
ExamDefinition entity = examDefinitionDAO.selectByPrimaryKey(examId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity, String.format("考试[%s]不存在", examId));
return entity;
}
@Override
public List<ExamDefinition> findEntities(List<Long> examIds) {
ExamDefinitionExample example = new ExamDefinitionExample();
example.createCriteria().andIdIn(examIds);
return examDefinitionDAO.selectByExample(example);
}
private void forceOffline(ExamDefinition exam) { private void forceOffline(ExamDefinition exam) {
exam.setStatus(BusinessConsts.STATUS_NOT_USE); exam.setStatus(BusinessConsts.STATUS_NOT_USE);
this.examDefinitionDAO.updateByPrimaryKey(exam); this.examDefinitionDAO.updateByPrimaryKey(exam);
@ -590,41 +603,79 @@ public class ExamService implements IExamService {
} }
@Override @Override
public PageVO<ExamDefinitionVO> pagedQuerySelfExam4OrgTeacher(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) { public PageVO<ExamDefinitionVO> pagedQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) {
List<OrgLesson> orgLessons; List<Long> lessonIds;
if (queryVO.getLessonId() != null) { if (queryVO.getLessonId() != null) {
orgLessons = iOrgLessonService.findEntities(queryVO.getLessonId()); lessonIds = List.of(queryVO.getLessonId());
} else { } else {
Org topOrg = iOrgService.getEntity(loginInfo.getProject()); lessonIds = iLessonService.queryLessonICreatedInLoginProject(loginInfo).stream().map(LessonVO::getId).collect(Collectors.toList());
List<Integer> clsIds = iOrgService.findEntitiesByParentId(topOrg.getId(), null).stream().map(Org::getId).collect(Collectors.toList());
orgLessons = iOrgLessonService.findEntities(clsIds);
} }
if (CollectionUtils.isEmpty(lessonIds)) {
Map<Long, List<OrgLesson>> lessonOrgMap = orgLessons.stream().collect(Collectors.groupingBy(OrgLesson::getLessonId)); return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
List<Long> lessonIds = orgLessons.stream().map(OrgLesson::getLessonId).collect(Collectors.toList()); } else {
ExamDefinitionExample example = new ExamDefinitionExample(); List<OrgLesson> orgLessons = iOrgLessonService.findEntitiesByLessonIds(lessonIds);
ExamDefinitionExample.Criteria criteria = example.createCriteria().andLessonIdIn(lessonIds).andCreatorIdEqualTo(loginInfo.getUserVO().getId()); Map<Long, List<Integer>> lessonOrgMap = orgLessons.stream()
if (StringUtils.hasText(queryVO.getName())) { .collect(Collectors.groupingBy(OrgLesson::getLessonId, Collectors.mapping(OrgLesson::getOrgId, Collectors.toList())));
criteria.andNameLike(String.format("%%%s%%", queryVO.getName())); 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()));
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<ExamDefinition> page = (Page<ExamDefinition>) examDefinitionDAO.selectByExample(example);
List<ExamDefinitionVO> list = page.getResult().stream().map(examDefinition -> {
ExamDefinitionVO vo = new ExamDefinitionVO(examDefinition);
vo.setClsIds(lessonOrgMap.get(vo.getLessonId()));
return vo;
}).collect(Collectors.toList());
return PageVO.convert(page, list);
} }
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<ExamDefinition> page = (Page<ExamDefinition>) examDefinitionDAO.selectByExample(example);
List<ExamDefinitionVO> list = page.getResult().stream().map(examDefinition -> {
ExamDefinitionVO vo = new ExamDefinitionVO(examDefinition);
vo.setClsIds(lessonOrgMap.get(vo.getLessonId()).stream().map(OrgLesson::getOrgId).collect(Collectors.toList()));
return vo;
}).collect(Collectors.toList());
return PageVO.convert(page, list);
} }
@Override @Override
public List<ExamDefinitionVO> listQueryOrgExamOfSelf(@NonNull Integer clsId, LoginUserInfoVO loginInfo) { public List<ExamDefinitionVO> listQueryOrgExamICreated(Integer clsId, LoginUserInfoVO loginInfo) {
List<Long> lessonIds = iOrgLessonService.findEntities(clsId).stream().map(OrgLesson::getLessonId).collect(Collectors.toList()); List<Long> lessonIds;
if (clsId == null) {
Org topOrg = iOrgService.getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
List<Org> clsList = iOrgService.findEntitiesByParentId(topOrg.getId(), "id", BusinessConsts.Org.Status.VALID);
List<Integer> clsIds = clsList.stream().map(Org::getId).collect(Collectors.toList());
lessonIds = iOrgLessonService.findEntitiesByOrgIds(clsIds).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
} else {
lessonIds = iOrgLessonService.findEntities(clsId).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
}
return findEntityByLessonIdList(lessonIds).stream() return findEntityByLessonIdList(lessonIds).stream()
.filter(exam -> loginInfo.getUserVO().getId().equals(exam.getCreatorId())) .filter(exam -> loginInfo.getUserVO().getId().equals(exam.getCreatorId()))
.map(ExamDefinitionVO::new).collect(Collectors.toList()); .map(ExamDefinitionVO::new).collect(Collectors.toList());
} }
@Override
public List<ExamDefinitionVO> listQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) {
List<Long> lessonIds;
if (queryVO.getLessonId() != null) {
lessonIds = List.of(queryVO.getLessonId());
} else {
lessonIds = iLessonService.queryLessonICreatedInLoginProject(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<Integer>> 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());
}
}
private List<ExamDefinition> findEntityByLessonIdList(List<Long> lessonIdList) { private List<ExamDefinition> findEntityByLessonIdList(List<Long> lessonIdList) {
if (CollectionUtils.isEmpty(lessonIdList)) { if (CollectionUtils.isEmpty(lessonIdList)) {
return new ArrayList<>(); return new ArrayList<>();

View File

@ -49,11 +49,11 @@ public interface IExamService {
*/ */
void deleteExam(String id, UserVO userVO); void deleteExam(String id, UserVO userVO);
// /** // /**
// * 查询章节下允许创建的最多题目数量 // * 查询章节下允许创建的最多题目数量
// */ // */
// int queryTrainingNum(String lessonId, String chapterId); // int queryTrainingNum(String lessonId, String chapterId);
/** /**
* 根据课程和实训类型查询实训数量 * 根据课程和实训类型查询实训数量
*/ */
@ -84,10 +84,19 @@ public interface IExamService {
/** /**
* 分页查询组织老师个人创建的考试 * 分页查询组织老师个人创建的考试
*/ */
PageVO<ExamDefinitionVO> pagedQuerySelfExam4OrgTeacher(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo); PageVO<ExamDefinitionVO> pagedQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo);
/** /**
* 不分页查询组织老师个人创建的考试 * 不分页查询组织老师个人创建的考试
*/ */
List<ExamDefinitionVO> listQueryOrgExamOfSelf(Integer clsId, LoginUserInfoVO loginInfo); List<ExamDefinitionVO> listQueryOrgExamICreated(Integer clsId, LoginUserInfoVO loginInfo);
/**
* 查询当前项目下创建的考试
*/
List<ExamDefinitionVO> listQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo);
ExamDefinition getEntity(Long examId);
List<ExamDefinition> findEntities(List<Long> examIds);
} }

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.services; package club.joylink.rtss.services;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.*; import club.joylink.rtss.vo.client.*;
@ -153,12 +154,17 @@ public interface ILessonService {
PageVO<LessonVO> pagedQueryPersonalLesson(LessonQueryVO queryVO, LoginUserInfoVO loginInfo); PageVO<LessonVO> pagedQueryPersonalLesson(LessonQueryVO queryVO, LoginUserInfoVO loginInfo);
/** /**
* 查询用户当前登录的项目下的课程仅课程的信息 * 查询自己创建的当前登录的项目下的课程仅课程的信息
*/ */
List<LessonVO> queryPersonalLesson(LoginUserInfoVO loginInfo); List<LessonVO> queryLessonICreatedInLoginProject(LoginUserInfoVO loginInfo);
/** /**
* 查询自己为指定班级创建的课程 * 查询自己为指定班级创建的课程
*/ */
List<LessonVO> queryOrgLessonOfSelf(Integer clsId, LoginUserInfoVO loginInfo); List<LessonVO> queryOrgLessonOfSelf(Integer clsId, LoginUserInfoVO loginInfo);
/**
* 查询由该用户创建的在这个项目下的课程
*/
List<LessonVO> queryLessons(Long userId, Project project);
} }

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.services;
import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.MapStatus; import club.joylink.rtss.constants.MapStatus;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.dao.*; import club.joylink.rtss.dao.*;
import club.joylink.rtss.entity.*; import club.joylink.rtss.entity.*;
import club.joylink.rtss.entity.LsLessonExample.Criteria; import club.joylink.rtss.entity.LsLessonExample.Criteria;
@ -573,20 +574,8 @@ public class LessonService implements ILessonService {
} }
@Override @Override
public List<LessonVO> queryPersonalLesson(LoginUserInfoVO loginInfo) { public List<LessonVO> queryLessonICreatedInLoginProject(LoginUserInfoVO loginInfo) {
List<MapVO> maps = iMapService.findOnlineMapByProjectCode(loginInfo.getProject().name()); return queryLessons(loginInfo.getUserVO().getId(), loginInfo.getProject());
if (CollectionUtils.isEmpty(maps)) {
return new ArrayList<>();
} else {
List<Long> mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList());
LsLessonExample example = new LsLessonExample();
example.createCriteria()
.andMapIdIn(mapIds)
.andCreatorIdEqualTo(loginInfo.getUserVO().getId())
.andSysfaultEqualTo(false);
List<LsLesson> list = lessonDAO.selectByExample(example);
return LessonVO.convert(list);
}
} }
@Override @Override
@ -597,6 +586,23 @@ public class LessonService implements ILessonService {
.filter(lesson->loginInfo.getUserVO().getId().equals(lesson.getCreatorId())).map(LessonVO::new).collect(Collectors.toList()); .filter(lesson->loginInfo.getUserVO().getId().equals(lesson.getCreatorId())).map(LessonVO::new).collect(Collectors.toList());
} }
@Override
public List<LessonVO> queryLessons(Long userId, Project project) {
List<MapVO> maps = iMapService.findOnlineMapByProjectCode(project.name());
if (CollectionUtils.isEmpty(maps)) {
return new ArrayList<>();
} else {
List<Long> mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList());
LsLessonExample example = new LsLessonExample();
example.createCriteria()
.andMapIdIn(mapIds)
.andCreatorIdEqualTo(userId)
.andSysfaultEqualTo(false);
List<LsLesson> list = lessonDAO.selectByExample(example);
return LessonVO.convert(list);
}
}
private List<LsLesson> findLessonEntities(List<Long> lessonIds) { private List<LsLesson> findLessonEntities(List<Long> lessonIds) {
if (CollectionUtils.isEmpty(lessonIds)) { if (CollectionUtils.isEmpty(lessonIds)) {
return new ArrayList<>(); return new ArrayList<>();

View File

@ -324,7 +324,7 @@ public class UserExamService implements IUserExamService {
.collect(Collectors.toMap(UserExam::getUserId, Function.identity())); .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); Org topOrg = iOrgService.getTopOrgEntity(orgId, BusinessConsts.Org.Status.VALID);
List<UserExamVO> vos = userIds.stream().map(userId -> { List<UserExamVO> vos = userIds.stream().map(userId -> {
UserExam userExam = userExamMap.get(userId); UserExam userExam = userExamMap.get(userId);
UserExamVO vo; UserExamVO vo;

View File

@ -88,7 +88,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
// 删除旧联锁数据保存新联锁数据 // 删除旧联锁数据保存新联锁数据
this.draftMapService.cleanAndSaveCiData(mapId, approachSectionVOList, this.draftMapService.cleanAndSaveCiData(mapId, approachSectionVOList,
routeVOList, overlapVOList, flsVOList, autoSignalNewVOList, routeVOList, overlapVOList, flsVOList, autoSignalNewVOList,
autoReentryVOList,destinationCodeDefinitionVOList, result.getRoutingList(),result.getStationRunLevelList()); autoReentryVOList, destinationCodeDefinitionVOList, result.getRoutingList(), result.getStationRunLevelList());
return result.convert2VO(); return result.convert2VO();
} }
@ -324,6 +324,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
Boolean leftFrontTurnBack = null; Boolean leftFrontTurnBack = null;
Station rightStation = null; Station rightStation = null;
Boolean rightFrontTurnBack = null; Boolean rightFrontTurnBack = null;
Route route = null;
int codeNum = 1; int codeNum = 1;
for (int i = 0; i < stationList.size(); i++) { for (int i = 0; i < stationList.size(); i++) {
@ -352,7 +353,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
rightFrontTurnBack = endTbSection.isNormalStandTrack(); rightFrontTurnBack = endTbSection.isNormalStandTrack();
destinationCodeDefinitionList.add( destinationCodeDefinitionList.add(
new DestinationCodeDefinition(code, type, description, startSection, section, right, necessarySections, new DestinationCodeDefinition(code, type, description, startSection, section, right, necessarySections,
leftStation, leftFrontTurnBack, rightStation, rightFrontTurnBack, null, null) leftStation, leftFrontTurnBack, rightStation, rightFrontTurnBack, route, null, null)
); );
} }
} }
@ -373,13 +374,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
return new CiGenerateResult(errorList, approachList, return new CiGenerateResult(errorList, approachList,
autoSignalList, generatedRouteList, generatedOverlapList, flsList, autoSignalList, generatedRouteList, generatedOverlapList, flsList,
generateCycleList, generateRoutingList,generatedStationRunLevelList, destinationCodeDefinitionList); generateCycleList, generateRoutingList, generatedStationRunLevelList, destinationCodeDefinitionList);
} }
/** /**
* 筛选站后折返轨优先右行站台折返 * 筛选站后折返轨优先右行站台折返
*
* @param stations 所有车站 * @param stations 所有车站
* @param right 是否是右端车站 * @param right 是否是右端车站
*/ */
private List<Section> queryFrontTurnBackList(List<Station> stations, Station station, boolean right) { private List<Section> queryFrontTurnBackList(List<Station> stations, Station station, boolean right) {
List<Section> turnBackList = station.getTurnBackList(); List<Section> turnBackList = station.getTurnBackList();
@ -425,6 +427,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 筛选站前折返轨 * 筛选站前折返轨
*
* @param right 是否是右端车站 * @param right 是否是右端车站
*/ */
private List<Section> queryAfterTurnBackList(Station station, boolean right) { private List<Section> queryAfterTurnBackList(Station station, boolean right) {
@ -506,12 +509,13 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 生成进路 * 生成进路
* @param start 始端信号机 *
* @param routeCodeGenerator 进路code生成器 * @param start 始端信号机
* @param overlapMap 已经构建的延续保护数据mapkey-信号机codeval-延续保护路径 * @param routeCodeGenerator 进路code生成器
* @param overlapMap 已经构建的延续保护数据mapkey-信号机codeval-延续保护路径
* @param overlapCodeGenerator 延续保护code生成器 * @param overlapCodeGenerator 延续保护code生成器
* @param config 生成配置 * @param config 生成配置
* @param errorList 生成错误信息 * @param errorList 生成错误信息
*/ */
private List<Route> generateRoute(Signal start, CodeGenerator routeCodeGenerator, private List<Route> generateRoute(Signal start, CodeGenerator routeCodeGenerator,
Map<String, List<RouteOverlap>> overlapMap, Map<String, List<RouteOverlap>> overlapMap,
@ -575,7 +579,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
routeList.add(route); routeList.add(route);
++index; ++index;
} }
} else if(config.isOverlapSettingByTrigger()) { // 触发建立进路不绑定延续保护 } else if (config.isOverlapSettingByTrigger()) { // 触发建立进路不绑定延续保护
String code = routeCodeGenerator.next(); String code = routeCodeGenerator.next();
String name = String.format("%s-%s", start.getName(), endName); String name = String.format("%s-%s", start.getName(), endName);
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath, Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath,
@ -594,13 +598,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
} }
} }
} else { } else {
errorList.add(String.format("以[%s(%s)]为始端信号的进路未搜索到",start.getName(), start.getCode())); errorList.add(String.format("以[%s(%s)]为始端信号的进路未搜索到", start.getName(), start.getCode()));
} }
return routeList; return routeList;
} }
/** /**
* 查询距给给定信号机最近的信号机 * 查询距给给定信号机最近的信号机
*
* @param signal * @param signal
* @param sectionPath * @param sectionPath
* @return * @return
@ -629,6 +634,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 根据信号机配置删除不需要的基本进路 * 根据信号机配置删除不需要的基本进路
*
* @param signalList * @param signalList
* @param generatedRouteList * @param generatedRouteList
*/ */
@ -672,6 +678,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 构建道岔定位侧防 * 构建道岔定位侧防
*
* @param aSwitch * @param aSwitch
* @param fpCodeGenerator * @param fpCodeGenerator
* @return * @return
@ -761,6 +768,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 构建道岔反位侧防 * 构建道岔反位侧防
*
* @param aSwitch * @param aSwitch
* @param fpCodeGenerator * @param fpCodeGenerator
* @return * @return
@ -848,9 +856,9 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
Section routingEndSection = (Section) deviceMap.get(routing.getEndSectionCode()); Section routingEndSection = (Section) deviceMap.get(routing.getEndSectionCode());
Boolean right = routing.getRight(); Boolean right = routing.getRight();
List<MapRoutingSectionNewVO> sectionCodeList = routing.getParkSectionCodeList(); List<MapRoutingSectionNewVO> sectionCodeList = routing.getParkSectionCodeList();
for (int i = 0; i < sectionCodeList.size()-1; i++) { for (int i = 0; i < sectionCodeList.size() - 1; i++) {
Section startSection = (Section) deviceMap.get(sectionCodeList.get(i).getSectionCode()); Section startSection = (Section) deviceMap.get(sectionCodeList.get(i).getSectionCode());
Section endSection = (Section) deviceMap.get(sectionCodeList.get(i+1).getSectionCode()); Section endSection = (Section) deviceMap.get(sectionCodeList.get(i + 1).getSectionCode());
//已创建 //已创建
boolean exist = false; boolean exist = false;
for (MapStationRunLevelVO vo : generatedStationRunLevelList) { for (MapStationRunLevelVO vo : generatedStationRunLevelList) {
@ -900,7 +908,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
String.format("%s(%s)->%s(%s)", String.format("%s(%s)->%s(%s)",
routingStartSection.getStation().getName(), routingStartSection.getName(), routingStartSection.getStation().getName(), routingStartSection.getName(),
routingEndSection.getStation().getName(), routingEndSection.getName()), routingEndSection.getStation().getName(), routingEndSection.getName()),
!right ? "右向":"左向")); !right ? "右向" : "左向"));
runLevelVO.setRight(!right); runLevelVO.setRight(!right);
} }
} }
@ -1143,6 +1151,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 生成折返进路 * 生成折返进路
*
* @param routeList * @param routeList
* @param routeCodeGenerator * @param routeCodeGenerator
* @param config * @param config
@ -1221,6 +1230,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 查询进路终端信号机的临近反向信号机 * 查询进路终端信号机的临近反向信号机
*
* @param end * @param end
* @return * @return
*/ */
@ -1248,13 +1258,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 生成进路的敌对关系 * 生成进路的敌对关系
*
* @param routeList * @param routeList
*/ */
private void buildRouteConflict(List<Route> routeList) { private void buildRouteConflict(List<Route> routeList) {
// 敌对进路两进路方向相反且始端信号机在同一区段或有共同区段但无冲突道岔 // 敌对进路两进路方向相反且始端信号机在同一区段或有共同区段但无冲突道岔
for (int i = 0; i < routeList.size(); i++) { for (int i = 0; i < routeList.size(); i++) {
Route route1 = routeList.get(i); Route route1 = routeList.get(i);
for (int j = i+1; j < routeList.size(); j++) { for (int j = i + 1; j < routeList.size(); j++) {
Route route2 = routeList.get(j); Route route2 = routeList.get(j);
if (route1.containConflictRoute(route2)) { if (route1.containConflictRoute(route2)) {
continue; continue;
@ -1283,14 +1294,15 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 构造进路对象 * 构造进路对象
*
* @param code * @param code
* @param name * @param name
* @param start 始端信号机 * @param start 始端信号机
* @param end 终端信号机 * @param end 终端信号机
* @param endButton 建立方式为按钮点选方式时终端按钮信号机 * @param endButton 建立方式为按钮点选方式时终端按钮信号机
* @param sectionPath * @param sectionPath
* @param routeOverlap * @param routeOverlap
* @param alwaysGreen 进路始端信号是否总是开绿灯 * @param alwaysGreen 进路始端信号是否总是开绿灯
* @return * @return
*/ */
private Route buildRoute(String code, String name, private Route buildRoute(String code, String name,
@ -1372,9 +1384,10 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 根据路径创建延续保护 * 根据路径创建延续保护
* @param end 延续保护始端信号机 *
* @param end 延续保护始端信号机
* @param overlapCodeGenerator code生成器 * @param overlapCodeGenerator code生成器
* @param config 配置 * @param config 配置
* @param errorList * @param errorList
* @return * @return
*/ */
@ -1456,7 +1469,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
if (routeOverlap.containRpSwitch()) { if (routeOverlap.containRpSwitch()) {
routeOverlap.setName(routeOverlap.getName() + "_2"); routeOverlap.setName(routeOverlap.getName() + "_2");
} else { } else {
routeOverlap.setName(routeOverlap.getName()+"_1"); routeOverlap.setName(routeOverlap.getName() + "_1");
} }
} }
} else if (list.size() > 2) { } else if (list.size() > 2) {
@ -1562,11 +1575,12 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 获取延续保护路径 * 获取延续保护路径
*
* @param section * @param section
* @param right 方向 * @param right 方向
* @param tempPath 临时路径 * @param tempPath 临时路径
* @param overlapPathList 最终结果列表 * @param overlapPathList 最终结果列表
* @param config 生成配置参数 * @param config 生成配置参数
* @param errorList * @param errorList
*/ */
private void getOverlapPathOf(Section section, boolean right, private void getOverlapPathOf(Section section, boolean right,
@ -1663,12 +1677,13 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 获取可走的进路路径 * 获取可走的进路路径
* @param section 下一个区段 *
* @param ground 是否查询地面信号 * @param section 下一个区段
* @param tempPath 临时路径 * @param ground 是否查询地面信号
* @param tempPath 临时路径
* @param routePathList 最终结果 * @param routePathList 最终结果
* @param config 生成配置参数 * @param config 生成配置参数
* @param errorList 错误信息 * @param errorList 错误信息
*/ */
private void getRoutePathOf(Signal startSignal, Section section, boolean ground, private void getRoutePathOf(Signal startSignal, Section section, boolean ground,
SectionPath tempPath, List<SectionPath> routePathList, SectionPath tempPath, List<SectionPath> routePathList,
@ -1768,6 +1783,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 生成接近区段 * 生成接近区段
*
* @param signal * @param signal
* @param config * @param config
*/ */
@ -1786,7 +1802,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
List<Section> logicApproachList = new ArrayList<>(); List<Section> logicApproachList = new ArrayList<>();
List<Section> sectionList = sectionPath.getSectionList(); List<Section> sectionList = sectionPath.getSectionList();
for (Section phySection : sectionList) { for (Section phySection : sectionList) {
if(len >= 600) break; if (len >= 600) break;
if (phySection.isSwitchTrack()) { if (phySection.isSwitchTrack()) {
len += phySection.getLen(); len += phySection.getLen();
logicApproachList.add(phySection); logicApproachList.add(phySection);
@ -1805,7 +1821,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
for (Section logic : sortedList) { for (Section logic : sortedList) {
logicApproachList.add(logic); logicApproachList.add(logic);
len += logic.getLen(); len += logic.getLen();
if(len >= 600) break; if (len >= 600) break;
} }
} }
sectionPath.setLogicList(logicApproachList); sectionPath.setLogicList(logicApproachList);
@ -1874,8 +1890,8 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
} else { } else {
throw BusinessExceptionAssertEnum.DATA_ERROR.exception( throw BusinessExceptionAssertEnum.DATA_ERROR.exception(
String.format("地图基础数据有错误:区段[%s(%s)]关联了道岔[%s(%s)],却不是此道岔的关联区段", String.format("地图基础数据有错误:区段[%s(%s)]关联了道岔[%s(%s)],却不是此道岔的关联区段",
section.getName(), section.getCode(), section.getName(), section.getCode(),
relSwitch.getName(), relSwitch.getCode())); relSwitch.getName(), relSwitch.getCode()));
} }
} else { } else {
tempPath.addSection(section); tempPath.addSection(section);
@ -1886,6 +1902,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
/** /**
* 生成自动信号 * 生成自动信号
*
* @param signal * @param signal
* @param autoSignalGenerator * @param autoSignalGenerator
* @param errorList * @param errorList

View File

@ -16,7 +16,9 @@ public interface IOrgLessonService {
/** /**
* 查询这些组织的课程关联关系 * 查询这些组织的课程关联关系
*/ */
List<OrgLesson> findEntities(List<Integer> orgIds); List<OrgLesson> findEntitiesByOrgIds(List<Integer> orgIds);
List<OrgLesson> findEntitiesByLessonIds(List<Long> lessonIds);
List<OrgLesson> findEntities(Long lessonId); List<OrgLesson> findEntities(Long lessonId);

View File

@ -1,10 +1,13 @@
package club.joylink.rtss.services.org; package club.joylink.rtss.services.org;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.DepartmentVO;
import club.joylink.rtss.vo.client.org.OrgScoringResultVO; import club.joylink.rtss.vo.client.org.OrgScoringResultVO;
import club.joylink.rtss.vo.client.org.OrgScoringRuleQueryVO; import club.joylink.rtss.vo.client.org.OrgScoringRuleQueryVO;
import club.joylink.rtss.vo.client.org.OrgScoringRuleVO; import club.joylink.rtss.vo.client.org.OrgScoringRuleVO;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -12,19 +15,13 @@ public interface IOrgScoringRuleService {
/** /**
* 创建评分规则 * 创建评分规则
*/ */
void createScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user); void createScoringRule(OrgScoringRuleVO orgScoringRuleVO, LoginUserInfoVO loginInfo);
/** /**
* 更新评分规则 * 更新评分规则
*/ */
void updateScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user); void updateScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user);
/**
* 使用评分规则评分
* @return
*/
List<OrgScoringResultVO> score(OrgScoringRuleVO orgScoringRuleVO, UserVO user);
/** /**
* 查询自己创建的评价规则基础信息 * 查询自己创建的评价规则基础信息
*/ */
@ -33,7 +30,7 @@ public interface IOrgScoringRuleService {
/** /**
* 查询自己创建的指定评价规则的详细信息 * 查询自己创建的指定评价规则的详细信息
*/ */
OrgScoringRuleVO queryOrgScoringRuleDetails(Integer orgId, String schoolYear, Integer term, UserVO user); OrgScoringRuleVO queryOrgScoringRuleDetails(Integer orgId, String schoolYear, Integer term, LoginUserInfoVO loginInfo);
/** /**
* 根据id获取规则详情 * 根据id获取规则详情
@ -48,5 +45,17 @@ public interface IOrgScoringRuleService {
/** /**
* 使用评分规则进行评分 * 使用评分规则进行评分
*/ */
List<OrgScoringResultVO> score(Integer orgId, String schoolYear, Integer term, UserVO user); List<OrgScoringResultVO> score(Integer orgId, String schoolYear, Integer term, LoginUserInfoVO loginInfo);
/**
* 将评价规则应用到
*/
@Transactional
void applyOrgScoringRule(Long ruleId, List<Integer> orgIds);
/**
* 查询评价规则能应用到的组织
* @return
*/
List<DepartmentVO> queryRuleCanApplyTo(Long ruleId);
} }

View File

@ -5,10 +5,10 @@ import club.joylink.rtss.entity.Org;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyQueryVO;
import club.joylink.rtss.vo.client.org.CompanyVO; import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.org.DepartmentVO; import club.joylink.rtss.vo.client.org.DepartmentVO;
import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO; import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO;
import club.joylink.rtss.vo.client.org.OrgQueryVO;
import java.util.List; import java.util.List;
@ -19,7 +19,7 @@ public interface IOrgService {
Org getEntity(Integer orgId); Org getEntity(Integer orgId);
Org getEntity(Project project); Org getEntity(Project project, String status);
CompanyVO updateOrg(Integer id, CompanyVO companyVO, UserVO user); CompanyVO updateOrg(Integer id, CompanyVO companyVO, UserVO user);
@ -28,21 +28,28 @@ public interface IOrgService {
*/ */
void deleteNonTopOrg(Integer nonTopOrgId); void deleteNonTopOrg(Integer nonTopOrgId);
List<Org> findEntitiesByParentId(Integer parentId, String orderBy); List<Org> findEntitiesByParentId(Integer parentId, String orderBy, String status);
/** /**
* 分页查询自己创建的班级 * 分页查询自己创建的班级
* @param self 是否仅查询自己创建的 * @param self 是否仅查询自己创建的
*/ */
PageVO<DepartmentVO> pagedQueryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self); PageVO<DepartmentVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self);
/** /**
* 查询自己创建的班级 * 查询自己创建的班级
*/ */
List<DepartmentVO> queryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self); List<DepartmentVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self);
/** /**
* 获取该组织所属的顶级组织 * 获取该组织所属的顶级组织
*/ */
Org getTopOrgEntity(Integer orgId); Org getTopOrgEntity(Integer orgId, String status);
List<Org> findEntities(List<Integer> orgIds, String status);
/**
* 管理员分页查询组织
*/
PageVO<DepartmentVO> adminPagedQueryOrg(OrgQueryVO queryVO);
} }

View File

@ -23,7 +23,7 @@ public interface IOrgUserService {
boolean isExistWithCompanyName(String name); boolean isExistWithCompanyName(String name);
PageVO<CompanyVO> queryPageOrganizations(CompanyQueryVO queryVO); PageVO<CompanyVO> queryPageOrganizations(OrgQueryVO queryVO);
/** /**
* 用户绑定为单位管理员 * 用户绑定为单位管理员
@ -96,4 +96,6 @@ public interface IOrgUserService {
void createOrgUser(Integer orgId, Long userId, BusinessConsts.OrgRole role); void createOrgUser(Integer orgId, Long userId, BusinessConsts.OrgRole role);
List<OrgUser> findEntities(Integer orgId, BusinessConsts.OrgRole role); List<OrgUser> findEntities(Integer orgId, BusinessConsts.OrgRole role);
List<OrgUser> findEntities(List<Integer> orgIds, BusinessConsts.OrgRole role);
} }

View File

@ -14,7 +14,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class OrgLessonService implements IOrgLessonService{ public class OrgLessonService implements IOrgLessonService {
@Autowired @Autowired
private OrgLessonDAO orgLessonDAO; private OrgLessonDAO orgLessonDAO;
@ -45,14 +45,14 @@ public class OrgLessonService implements IOrgLessonService{
List<OrgLesson> orgLessons = findEntitiesByOrgId(orgId); List<OrgLesson> orgLessons = findEntitiesByOrgId(orgId);
if (CollectionUtils.isEmpty(orgLessons)) { if (CollectionUtils.isEmpty(orgLessons)) {
return new ArrayList<>(); return new ArrayList<>();
} else{ } else {
List<Long> lessonIds = orgLessons.stream().map(OrgLesson::getLessonId).collect(Collectors.toList()); List<Long> lessonIds = orgLessons.stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
return iLessonService.queryByIds(lessonIds); return iLessonService.queryByIds(lessonIds);
} }
} }
@Override @Override
public List<OrgLesson> findEntities(List<Integer> orgIds) { public List<OrgLesson> findEntitiesByOrgIds(List<Integer> orgIds) {
if (CollectionUtils.isEmpty(orgIds)) { if (CollectionUtils.isEmpty(orgIds)) {
return new ArrayList<>(); return new ArrayList<>();
} else { } else {
@ -62,6 +62,17 @@ public class OrgLessonService implements IOrgLessonService{
} }
} }
@Override
public List<OrgLesson> findEntitiesByLessonIds(List<Long> lessonIds) {
if (CollectionUtils.isEmpty(lessonIds)) {
return new ArrayList<>();
} else {
OrgLessonExample example = new OrgLessonExample();
example.createCriteria().andLessonIdIn(lessonIds);
return orgLessonDAO.selectByExample(example);
}
}
@Override @Override
public List<OrgLesson> findEntities(Long lessonId) { public List<OrgLesson> findEntities(Long lessonId) {
OrgLessonExample example = new OrgLessonExample(); OrgLessonExample example = new OrgLessonExample();

View File

@ -1,16 +1,21 @@
package club.joylink.rtss.services.org; package club.joylink.rtss.services.org;
import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.OrgDAO;
import club.joylink.rtss.dao.OrgScoringRuleDAO; import club.joylink.rtss.dao.OrgScoringRuleDAO;
import club.joylink.rtss.dao.OrgScoringRuleRelDAO;
import club.joylink.rtss.entity.*; import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IExamService;
import club.joylink.rtss.services.ISysUserService; import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.services.IUserExamService; import club.joylink.rtss.services.IUserExamService;
import club.joylink.rtss.services.IUserUsageStatsService; import club.joylink.rtss.services.IUserUsageStatsService;
import club.joylink.rtss.services.user.ISysUserLoginService; import club.joylink.rtss.services.user.ISysUserLoginService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.UserRankStatsVO; import club.joylink.rtss.vo.client.UserRankStatsVO;
import club.joylink.rtss.vo.client.org.DepartmentVO;
import club.joylink.rtss.vo.client.org.OrgScoringResultVO; import club.joylink.rtss.vo.client.org.OrgScoringResultVO;
import club.joylink.rtss.vo.client.org.OrgScoringRuleQueryVO; import club.joylink.rtss.vo.client.org.OrgScoringRuleQueryVO;
import club.joylink.rtss.vo.client.org.OrgScoringRuleVO; import club.joylink.rtss.vo.client.org.OrgScoringRuleVO;
@ -23,10 +28,8 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.function.Function;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -52,12 +55,26 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
@Autowired @Autowired
private ISysUserService iSysUserService; private ISysUserService iSysUserService;
@Autowired
private IExamService iExamService;
@Autowired
private OrgScoringRuleRelDAO orgScoringRuleRelDAO;
@Autowired
private IOrgLessonService iOrgLessonService;
@Autowired
private OrgDAO orgDAO;
@Override @Override
public void createScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user) { public void createScoringRule(OrgScoringRuleVO orgScoringRuleVO, LoginUserInfoVO loginInfo) {
this.check4Create(orgScoringRuleVO, user.getId()); Org topOrg = iOrgService.getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
this.check4Create(orgScoringRuleVO, topOrg.getId(), loginInfo.getUserVO().getId());
OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.convert2DB(); OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.convert2DB();
rule.setCreatorId(user.getId()); rule.setOrgId(topOrg.getId());
rule.setCreatorId(loginInfo.getUserVO().getId());
rule.setCreateTime(LocalDateTime.now()); rule.setCreateTime(LocalDateTime.now());
orgScoringRuleDAO.insert(rule); orgScoringRuleDAO.insert(rule);
} }
@ -65,46 +82,27 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
@Override @Override
public void updateScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user) { public void updateScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(orgScoringRuleVO.getId(), "id不能为null"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(orgScoringRuleVO.getId(), "id不能为null");
this.check4Update(orgScoringRuleVO, user.getId()); this.check4Update(orgScoringRuleVO);
OrgScoringRuleWithBLOBs entity = getEntity(orgScoringRuleVO.getId()); OrgScoringRuleWithBLOBs entity = getRuleEntity(orgScoringRuleVO.getId());
OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.cover4Update(entity); OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.cover4Update(entity);
rule.setUpdateId(user.getId()); rule.setUpdateId(user.getId());
rule.setUpdateTime(LocalDateTime.now()); rule.setUpdateTime(LocalDateTime.now());
orgScoringRuleDAO.updateByPrimaryKeyWithBLOBs(rule); orgScoringRuleDAO.updateByPrimaryKeyWithBLOBs(rule);
} }
@Override
public List<OrgScoringResultVO> score(@NonNull OrgScoringRuleVO orgScoringRuleVO, @NonNull UserVO user) {
orgScoringRuleVO.check4Use();
List<OrgUser> students = iOrgUserService.findEntities(orgScoringRuleVO.getOrgId(), BusinessConsts.OrgRole.Student);
List<Long> userIds = students.stream().map(OrgUser::getUserId).collect(Collectors.toList());
Org topOrg = iOrgService.getTopOrgEntity(orgScoringRuleVO.getOrgId());
List<String> projects = List.of(topOrg.getProjectCode().split(","));
int totalWeight = orgScoringRuleVO.calculateTotalWeight();
Map<Long, Integer> usualScoreMap = new HashMap<>();
if (orgScoringRuleVO.getUsualScoringRule() != null) {
usualScoreMap = this.score(userIds, orgScoringRuleVO.getUsualScoringRule(), totalWeight, projects);
}
Map<Long, Integer> finalScoreMap = new HashMap<>();
if (orgScoringRuleVO.getFinalScoringRule() != null) {
finalScoreMap = this.score(userIds, orgScoringRuleVO.getFinalScoringRule(), totalWeight, projects);
}
List<OrgScoringResultVO> list = new ArrayList<>();
List<SysUser> users = iSysUserService.findEntity(userIds, "id");
for (SysUser sysUser : users) {
Long userId = sysUser.getId();
String account = sysUser.getAccount().substring(0, sysUser.getAccount().indexOf(topOrg.getCode()));
list.add(new OrgScoringResultVO(userId, account, sysUser.getName(), usualScoreMap.get(userId), finalScoreMap.get(userId)));
}
return list;
}
@Override @Override
public PageVO<OrgScoringRuleVO> queryBasicInfo(OrgScoringRuleQueryVO queryVO, UserVO user) { public PageVO<OrgScoringRuleVO> queryBasicInfo(OrgScoringRuleQueryVO queryVO, UserVO user) {
List<Long> ruleIds = null;
if (queryVO.getOrgId() != null) {
ruleIds = findRelEntities(queryVO.getOrgId()).stream().map(OrgScoringRuleRel::getRuleId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(ruleIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
}
}
OrgScoringRuleExample example = new OrgScoringRuleExample(); OrgScoringRuleExample example = new OrgScoringRuleExample();
OrgScoringRuleExample.Criteria criteria = example.createCriteria().andCreatorIdEqualTo(user.getId()); OrgScoringRuleExample.Criteria criteria = example.createCriteria().andCreatorIdEqualTo(user.getId());
if (queryVO.getOrgId() != null) { if (!CollectionUtils.isEmpty(ruleIds)) {
criteria.andOrgIdEqualTo(queryVO.getOrgId()); criteria.andIdIn(ruleIds);
} }
if (StringUtils.hasText(queryVO.getSchoolYear())) { if (StringUtils.hasText(queryVO.getSchoolYear())) {
criteria.andSchoolYearEqualTo(queryVO.getSchoolYear()); criteria.andSchoolYearEqualTo(queryVO.getSchoolYear());
@ -114,21 +112,45 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
} }
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<OrgScoringRule> page = (Page<OrgScoringRule>) orgScoringRuleDAO.selectByExample(example); Page<OrgScoringRule> page = (Page<OrgScoringRule>) orgScoringRuleDAO.selectByExample(example);
List<OrgScoringRuleVO> voList = page.stream().map(OrgScoringRuleVO::buildBasicInfo).collect(Collectors.toList()); if (CollectionUtils.isEmpty(page)) {
return PageVO.convert(page, voList); return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
Map<Long, List<Integer>> rule_org_map = findRelEntities(page.stream().map(OrgScoringRule::getId).collect(Collectors.toList()))
.stream().collect(Collectors.groupingBy(OrgScoringRuleRel::getRuleId,
Collectors.mapping(OrgScoringRuleRel::getOrgId, Collectors.toList())));
List<OrgScoringRuleVO> voList = page.stream().map(rule -> OrgScoringRuleVO.buildBasicInfo(rule, rule_org_map.get(rule.getId())))
.collect(Collectors.toList());
return PageVO.convert(page, voList);
}
} }
@Override @Override
public OrgScoringRuleVO queryOrgScoringRuleDetails(Integer orgId, String schoolYear, Integer term, UserVO user) { public OrgScoringRuleVO queryOrgScoringRuleDetails(Integer orgId, String schoolYear, Integer term, LoginUserInfoVO loginInfo) {
Org topOrg = iOrgService.getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
OrgScoringRuleExample example = new OrgScoringRuleExample(); OrgScoringRuleExample example = new OrgScoringRuleExample();
example.createCriteria() example.createCriteria()
.andOrgIdEqualTo(orgId) .andOrgIdEqualTo(topOrg.getId())
.andCreatorIdEqualTo(loginInfo.getUserVO().getId())
.andSchoolYearEqualTo(schoolYear) .andSchoolYearEqualTo(schoolYear)
.andTermEqualTo(term) .andTermEqualTo(term);
.andCreatorIdEqualTo(user.getId());
List<OrgScoringRuleWithBLOBs> rules = orgScoringRuleDAO.selectByExampleWithBLOBs(example); List<OrgScoringRuleWithBLOBs> rules = orgScoringRuleDAO.selectByExampleWithBLOBs(example);
if (!CollectionUtils.isEmpty(rules)) { if (!CollectionUtils.isEmpty(rules)) {
return OrgScoringRuleVO.buildDetails(rules.get(0)); List<Long> ruleIds = rules.stream().map(OrgScoringRule::getId).collect(Collectors.toList());
List<OrgScoringRuleRel> rels = findRelEntities(ruleIds);
if (CollectionUtils.isEmpty(rels)) {
return null;
} else {
OrgScoringRuleRel rel = rels.stream().filter(orgRuleRel -> orgRuleRel.getOrgId().equals(orgId)).limit(1).findAny().orElse(null);
if (rel == null) {
return null;
} else {
OrgScoringRuleWithBLOBs rule = rules.stream().filter(orgRule -> orgRule.getId().equals(rel.getRuleId()))
.limit(1).findAny().orElse(null);
List<Integer> orgIds = rels.stream().filter(orgRuleRel -> orgRuleRel.getRuleId().equals(rule.getId()))
.map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList());
return OrgScoringRuleVO.buildDetails(rule, orgIds);
}
}
} else { } else {
return null; return null;
} }
@ -136,13 +158,14 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
@Override @Override
public OrgScoringRuleVO getOrgScoringRuleDetails(Long ruleId) { public OrgScoringRuleVO getOrgScoringRuleDetails(Long ruleId) {
OrgScoringRuleWithBLOBs rule = orgScoringRuleDAO.selectByPrimaryKey(ruleId); OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId);
return OrgScoringRuleVO.buildDetails(rule); List<Integer> orgIds = findRelEntities(ruleId).stream().map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList());
return OrgScoringRuleVO.buildDetails(rule, orgIds);
} }
@Override @Override
public void deleteRuleOfSelf(@NonNull Long id, @NonNull Long userId) { public void deleteRuleOfSelf(@NonNull Long id, @NonNull Long userId) {
OrgScoringRuleWithBLOBs rule = findEntity(id); OrgScoringRuleWithBLOBs rule = findRuleEntity(id);
if (rule != null) { if (rule != null) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertEquals(rule.getCreatorId(), userId, BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertEquals(rule.getCreatorId(), userId,
"非本人创建的评价规则不能删除"); "非本人创建的评价规则不能删除");
@ -151,77 +174,247 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
} }
@Override @Override
public List<OrgScoringResultVO> score(@NonNull Integer orgId, @NonNull String schoolYear, @NonNull Integer term, UserVO user) { public List<OrgScoringResultVO> score(@NonNull Integer orgId, @NonNull String schoolYear, @NonNull Integer term, LoginUserInfoVO loginInfo) {
OrgScoringRuleVO ruleVO = queryOrgScoringRuleDetails(orgId, schoolYear, term, user); OrgScoringRuleVO ruleVO = queryOrgScoringRuleDetails(orgId, schoolYear, term, loginInfo);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(ruleVO, "评价规则不存在"); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(ruleVO, "评价规则不存在");
return score(ruleVO, user); return score(ruleVO, orgId);
} }
private Map<Long, Integer> score(List<Long> userIds, @NonNull OrgScoringRuleVO.ScoringRule rule, int totalWeight, List<String> projects) { @Override
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(userIds); public void applyOrgScoringRule(Long ruleId, List<Integer> orgIds) {
Map<Long, Integer> scoreMap = new HashMap<>(); //校验
for (Long userId : userIds) { if (!CollectionUtils.isEmpty(orgIds)) {
int score = 0; OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId);
OrgScoringRuleExample ruleExample = new OrgScoringRuleExample();
ruleExample.createCriteria()
.andOrgIdEqualTo(rule.getOrgId())
.andCreatorIdEqualTo(rule.getCreatorId())
.andSchoolYearEqualTo(rule.getSchoolYear())
.andTermEqualTo(rule.getTerm())
.andIdNotEqualTo(ruleId);
List<OrgScoringRule> otherRules = orgScoringRuleDAO.selectByExample(ruleExample); //与操作的规则同顶级组织同创建者同学年同学期的其它规则
if (!CollectionUtils.isEmpty(otherRules)) {
List<Long> otherRuleIds = otherRules.stream()
.map(OrgScoringRule::getId).collect(Collectors.toList());
OrgScoringRuleRelExample relExample = new OrgScoringRuleRelExample();
relExample.createCriteria()
.andRuleIdIn(otherRuleIds)
.andOrgIdIn(orgIds);
List<OrgScoringRuleRel> relList = orgScoringRuleRelDAO.selectByExample(relExample);
if (!CollectionUtils.isEmpty(relList)) {
List<Integer> ruleRelOrgIds = relList.stream().map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList());
Map<Integer, Org> orgMap = iOrgService.findEntities(ruleRelOrgIds, BusinessConsts.Org.Status.VALID).stream().collect(Collectors.toMap(Org::getId, Function.identity()));
Map<Long, OrgScoringRule> ruleMap = otherRules.stream().collect(Collectors.toMap(OrgScoringRule::getId, Function.identity()));
StringBuilder builder = new StringBuilder();
relList.forEach(rel -> {
Org org = orgMap.get(rel.getOrgId());
if (org != null) {
builder.append(String.format("组织[%s]已被应用规则[%s]", org.getName(), ruleMap.get(rel.getRuleId()).getName()));
builder.append("\n");
}
});
throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception(builder.toString());
}
}
}
//处理
deleteRelEntities(ruleId);
if (!CollectionUtils.isEmpty(orgIds)) {
List<OrgScoringRuleRel> rels = orgIds.stream().map(orgId -> {
OrgScoringRuleRel rel = new OrgScoringRuleRel();
rel.setOrgId(orgId);
rel.setRuleId(ruleId);
return rel;
}).collect(Collectors.toList());
orgScoringRuleRelDAO.batchInsert(rels);
}
}
@Override
public List<DepartmentVO> queryRuleCanApplyTo(Long ruleId) {
OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId);
OrgScoringRuleVO vo = OrgScoringRuleVO.buildDetails(rule, null);
OrgScoringRuleVO.ScoringRule scoringRule = vo.getScoringRule();
Set<Long> lessonIdSet = new HashSet<>();
if (!CollectionUtils.isEmpty(scoringRule.getLearningTimeList())) {
scoringRule.getLearningTimeList().forEach(learningTime -> lessonIdSet.addAll(learningTime.getLessonIds()));
}
if (!CollectionUtils.isEmpty(scoringRule.getExams())) {
List<Long> examIds = scoringRule.getExams().stream().map(OrgScoringRuleVO.Exam::getExamId).collect(Collectors.toList());
List<ExamDefinition> examDefinitions = iExamService.findEntities(examIds);
examDefinitions.forEach(examDefinition -> lessonIdSet.add(examDefinition.getLessonId()));
}
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<Integer, Set<Long>> org_lessons_map = orgLessonList.stream().collect(Collectors.groupingBy(OrgLesson::getOrgId,
Collectors.mapping(OrgLesson::getLessonId, Collectors.toSet())));
List<Integer> 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());
}
private void check4Update(OrgScoringRuleVO orgScoringRuleVO) {
orgScoringRuleVO.check4Save();
OrgScoringRuleWithBLOBs rule = getRuleEntity(orgScoringRuleVO.getId());
if (!rule.getSchoolYear().equals(orgScoringRuleVO.getSchoolYear()) || !rule.getTerm().equals(orgScoringRuleVO.getTerm())) { //学年或学期有改动
List<Integer> relOrgList = findRelEntities(rule.getId()).stream()
.map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList()); //要更新的评价规则关联的组织id
if (!CollectionUtils.isEmpty(relOrgList)) {
OrgScoringRuleRelExample relExample = new OrgScoringRuleRelExample();
relExample.createCriteria().andOrgIdIn(relOrgList).andRuleIdNotEqualTo(rule.getId());
List<Long> ruleIds = orgScoringRuleRelDAO.selectByExample(relExample).stream()
.map(OrgScoringRuleRel::getRuleId).collect(Collectors.toList()); //要更新的评价规则应用到的组织关联的其它规则
OrgScoringRuleExample ruleExample = new OrgScoringRuleExample();
ruleExample.createCriteria()
.andOrgIdEqualTo(rule.getOrgId())
.andCreatorIdEqualTo(rule.getCreatorId())
.andSchoolYearEqualTo(orgScoringRuleVO.getSchoolYear())
.andTermEqualTo(orgScoringRuleVO.getTerm())
.andIdIn(ruleIds);
List<OrgScoringRule> rules = orgScoringRuleDAO.selectByExample(ruleExample);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionEmpty(rules,
"该规则应用到的班级有些已被同学年同学期的其它规则应用到");
}
}
}
private List<OrgScoringResultVO> score(@NonNull OrgScoringRuleVO orgScoringRuleVO, Integer clsId) {
//校验
orgScoringRuleVO.check4Use();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(orgScoringRuleVO.getOrgIds(),
String.format("评价规则[%s]未被应用到任何一个班级", orgScoringRuleVO.getId()));
if (clsId != null) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(orgScoringRuleVO.getOrgIds())
&& orgScoringRuleVO.getOrgIds().contains(clsId),
String.format("评价规则[%s]可应用的班级不包含[%s]", orgScoringRuleVO.getId(), clsId));
}
List<OrgUser> students;
if (clsId == null) {
students = iOrgUserService.findEntities(orgScoringRuleVO.getOrgIds(), BusinessConsts.OrgRole.Student);
} else {
students = iOrgUserService.findEntities(clsId, BusinessConsts.OrgRole.Student);
}
List<Long> userIds = students.stream().map(OrgUser::getUserId).collect(Collectors.toList());
List<SysUser> users = iSysUserService.findEntity(userIds, "id");
Org topOrg = iOrgService.getTopOrgEntity(orgScoringRuleVO.getOrgIds().get(0), BusinessConsts.Org.Status.VALID);
List<OrgScoringResultVO> results = users.stream().map(sysUser -> {
String account = sysUser.getAccount().substring(0, sysUser.getAccount().indexOf(topOrg.getCode()));
return new OrgScoringResultVO(sysUser.getId(), account, sysUser.getName());
}).collect(Collectors.toList());
List<String> projects = List.of(topOrg.getProjectCode().split(","));
this.score(results, orgScoringRuleVO.getScoringRule(), projects);
return results;
}
private void check4Create(OrgScoringRuleVO orgScoringRuleVO, Integer orgId, Long userId) {
orgScoringRuleVO.check4Save();
confirmNameUnique(orgScoringRuleVO, orgId, userId);
}
private void confirmNameUnique(OrgScoringRuleVO orgScoringRuleVO, Integer orgId, Long userId) {
OrgScoringRuleExample example = new OrgScoringRuleExample();
example.createCriteria().andOrgIdEqualTo(orgId).andCreatorIdEqualTo(userId).andNameEqualTo(orgScoringRuleVO.getName());
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(orgScoringRuleDAO.countByExample(example) == 0,
"有重名的规则");
}
private void score(List<OrgScoringResultVO> results, @NonNull OrgScoringRuleVO.ScoringRule rule, List<String> projects) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(results);
Map<Long, Integer> examScoreMap = new HashMap<>(); //考试及其满分
for (OrgScoringResultVO result : results) {
Long userId = result.getUserId();
//考勤分 //考勤分
OrgScoringRuleVO.Attendance attendance = rule.getAttendance(); OrgScoringRuleVO.Attendance attendance = rule.getAttendance();
if (attendance != null) { if (attendance != null) {
int loginDays = iSysUserLoginService.getLoginDays(userId, attendance.getStartDate(), attendance.getEndDate(), projects); int loginDays = iSysUserLoginService.getLoginDays(userId, attendance.getStartDate(), attendance.getEndDate(), projects);
score += attendance.calculateScore(loginDays, totalWeight); result.setAttendanceScore(attendance.calculateScore(loginDays));
} }
//课时分 //课时分
List<OrgScoringRuleVO.LearningTime> learningTimeList = rule.getLearningTimeList(); List<OrgScoringRuleVO.LearningTime> learningTimeList = rule.getLearningTimeList();
if (!CollectionUtils.isEmpty(learningTimeList)) { if (!CollectionUtils.isEmpty(learningTimeList)) {
for (OrgScoringRuleVO.LearningTime learningTime : learningTimeList) { int score = learningTimeList.stream().mapToInt(learningTime -> {
UserRankStatsVO vo = iUserUsageStatsService.statisticsLessonLearningDuration(learningTime.getLessonIds(), userId); UserRankStatsVO vo = iUserUsageStatsService.statisticsLessonLearningDuration(learningTime.getLessonIds(), userId);
score += learningTime.calculateScore(vo.getDuration(), totalWeight); return learningTime.calculateScore(vo.getDuration());
} }).sum();
result.setLearningTimeScore(score);
} }
//考试分 //考试分
List<OrgScoringRuleVO.Exam> exams = rule.getExams(); List<OrgScoringRuleVO.Exam> exams = rule.getExams();
if (!CollectionUtils.isEmpty(exams)) { if (!CollectionUtils.isEmpty(exams)) {
for (OrgScoringRuleVO.Exam exam : exams) { int score = exams.stream().mapToInt(exam -> {
Integer examScore = iUserExamService.queryHeightScoreOfUserExam(userId, exam.getExamId()); Integer userScore = iUserExamService.queryHeightScoreOfUserExam(userId, exam.getExamId());
score += exam.calculateScore(examScore, totalWeight); Integer examFullMarks = examScoreMap.get(exam.getExamId());
} if (examFullMarks == null) {
ExamDefinition examDefinition = iExamService.getEntity(exam.getExamId());
examFullMarks = examDefinition.getFullPoint();
examScoreMap.put(exam.getExamId(), examFullMarks);
}
return exam.calculateScore(userScore, examFullMarks);
}).sum();
result.setExamScore(score);
} }
scoreMap.put(userId, score);
} }
return scoreMap;
} }
private void check4Create(OrgScoringRuleVO vo, Long userId) { private OrgScoringRuleWithBLOBs getRuleEntity(Long id) {
vo.check4Save();
OrgScoringRuleExample example = new OrgScoringRuleExample();
OrgScoringRuleExample.Criteria criteria = example.createCriteria()
.andOrgIdEqualTo(vo.getOrgId())
.andSchoolYearEqualTo(vo.getSchoolYear())
.andTermEqualTo(vo.getTerm())
.andCreatorIdEqualTo(userId);
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(orgScoringRuleDAO.countByExample(example) == 0,
String.format("该班级在学年[%s]学期[%s]的评价规则已存在", vo.getSchoolYear(), vo.getTerm()));
}
private void check4Update(OrgScoringRuleVO vo, Long userId) {
vo.check4Save();
OrgScoringRuleExample example = new OrgScoringRuleExample();
OrgScoringRuleExample.Criteria criteria = example.createCriteria()
.andOrgIdEqualTo(vo.getOrgId())
.andSchoolYearEqualTo(vo.getSchoolYear())
.andTermEqualTo(vo.getTerm())
.andCreatorIdEqualTo(userId)
.andIdNotEqualTo(vo.getId());
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(orgScoringRuleDAO.countByExample(example) == 0,
String.format("该班级在学年[%s]学期[%s]的评价规则已存在", vo.getSchoolYear(), vo.getTerm()));
}
private OrgScoringRuleWithBLOBs getEntity(Long id) {
OrgScoringRuleWithBLOBs entity = orgScoringRuleDAO.selectByPrimaryKey(id); OrgScoringRuleWithBLOBs entity = orgScoringRuleDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity, BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity,
String.format("id[%s]的评分规则不存在", id)); String.format("id[%s]的评分规则不存在", id));
return entity; return entity;
} }
private OrgScoringRuleWithBLOBs findEntity(Long id) { private OrgScoringRuleWithBLOBs findRuleEntity(Long id) {
return orgScoringRuleDAO.selectByPrimaryKey(id); return orgScoringRuleDAO.selectByPrimaryKey(id);
} }
private List<OrgScoringRule> findBasicRuleEntities(Integer orgId, Long creatorId) {
OrgScoringRuleExample example = new OrgScoringRuleExample();
example.createCriteria().andOrgIdEqualTo(orgId).andCreatorIdEqualTo(creatorId);
return orgScoringRuleDAO.selectByExample(example);
}
private List<OrgScoringRuleRel> findRelEntities(Integer orgId) {
OrgScoringRuleRelExample example = new OrgScoringRuleRelExample();
example.createCriteria().andOrgIdEqualTo(orgId);
return orgScoringRuleRelDAO.selectByExample(example);
}
private List<OrgScoringRuleRel> findRelEntities(Long ruleId) {
OrgScoringRuleRelExample example = new OrgScoringRuleRelExample();
example.createCriteria().andRuleIdEqualTo(ruleId);
return orgScoringRuleRelDAO.selectByExample(example);
}
private List<OrgScoringRuleRel> findRelEntities(List<Long> ruleIds) {
OrgScoringRuleRelExample example = new OrgScoringRuleRelExample();
example.createCriteria().andRuleIdIn(ruleIds);
return orgScoringRuleRelDAO.selectByExample(example);
}
private void deleteRelEntities(Long ruleId) {
OrgScoringRuleRelExample relExample = new OrgScoringRuleRelExample();
relExample.createCriteria().andRuleIdEqualTo(ruleId);
orgScoringRuleRelDAO.deleteByExample(relExample);
}
} }

View File

@ -9,10 +9,10 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyQueryVO;
import club.joylink.rtss.vo.client.org.CompanyVO; import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.org.DepartmentVO; import club.joylink.rtss.vo.client.org.DepartmentVO;
import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO; import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO;
import club.joylink.rtss.vo.client.org.OrgQueryVO;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import lombok.NonNull; import lombok.NonNull;
@ -23,11 +23,12 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class OrgService implements IOrgService{ public class OrgService implements IOrgService {
@Autowired @Autowired
private OrgDAO orgDAO; private OrgDAO orgDAO;
@ -44,7 +45,7 @@ public class OrgService implements IOrgService{
@Override @Override
public void createCls(NonTopOrgCreateVO createVO, LoginUserInfoVO loginInfo) { public void createCls(NonTopOrgCreateVO createVO, LoginUserInfoVO loginInfo) {
//检查 //检查
Org topOrg = getEntity(loginInfo.getProject()); Org topOrg = getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
Integer topOrgId = topOrg.getId(); Integer topOrgId = topOrg.getId();
Long userId = loginInfo.getUserVO().getId(); Long userId = loginInfo.getUserVO().getId();
iOrgUserService.confirmIsTheRoleInThisOrg(userId, topOrgId, BusinessConsts.OrgRole.Admin); iOrgUserService.confirmIsTheRoleInThisOrg(userId, topOrgId, BusinessConsts.OrgRole.Admin);
@ -60,9 +61,12 @@ public class OrgService implements IOrgService{
} }
@Override @Override
public Org getEntity(Project project) { public Org getEntity(Project project, String status) {
OrgExample example = new OrgExample(); OrgExample example = new OrgExample();
example.createCriteria().andProjectCodeEqualTo(project.name()); OrgExample.Criteria criteria = example.createCriteria().andProjectCodeEqualTo(project.name());
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
List<Org> orgs = orgDAO.selectByExample(example); List<Org> orgs = orgDAO.selectByExample(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, String.format("关联项目为[%s]的组织不存在", project)); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, String.format("关联项目为[%s]的组织不存在", project));
return orgs.get(0); return orgs.get(0);
@ -88,55 +92,98 @@ public class OrgService implements IOrgService{
@Override @Override
public void deleteNonTopOrg(Integer nonTopOrgId) { public void deleteNonTopOrg(Integer nonTopOrgId) {
confirmIsNonTopOrg(nonTopOrgId); confirmIsNonTopOrg(nonTopOrgId);
orgDAO.deleteByPrimaryKey(nonTopOrgId); Org org = new Org();
org.setId(nonTopOrgId);
org.setStatus(BusinessConsts.Org.Status.DELETE);
orgDAO.updateByPrimaryKeySelective(org);
} }
@Override @Override
public List<Org> findEntitiesByParentId(Integer parentId, String orderBy) { public List<Org> findEntitiesByParentId(Integer parentId, String orderBy, String status) {
OrgExample example = new OrgExample(); OrgExample example = new OrgExample();
if (StringUtils.hasText(orderBy)) { if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy); example.setOrderByClause(orderBy);
} }
example.createCriteria().andParentIdEqualTo(parentId); OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(parentId);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example); return orgDAO.selectByExample(example);
} }
@Override @Override
public PageVO<DepartmentVO> pagedQueryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { public PageVO<DepartmentVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) {
OrgExample example = buildQueryClsExample(queryVO, loginInfo, self); OrgExample example = buildQueryClsExample(queryVO, loginInfo.getUserVO().getId(), loginInfo.getProject(), self);
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example); Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
List<DepartmentVO> list = page.getResult().stream().map(entity -> { List<DepartmentVO> list = page.getResult().stream().map(entity -> {
DepartmentVO vo = new DepartmentVO(entity); int numberOfPeople = iOrgUserService.getQuantities(entity.getId(), BusinessConsts.OrgRole.Student);
vo.setNumberOfPeople(iOrgUserService.getQuantities(vo.getId(), BusinessConsts.OrgRole.Student)); return new DepartmentVO(entity, numberOfPeople);
return vo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return PageVO.convert(page, list); return PageVO.convert(page, list);
} }
@Override @Override
public List<DepartmentVO> queryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { public List<DepartmentVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) {
OrgExample example = buildQueryClsExample(queryVO, loginInfo, self);; OrgExample example = buildQueryClsExample(queryVO, loginInfo.getUserVO().getId(), loginInfo.getProject(), self);
List<Org> clsList = orgDAO.selectByExample(example); List<Org> clsList = orgDAO.selectByExample(example);
return clsList.stream().map(DepartmentVO::new).collect(Collectors.toList()); return clsList.stream().map(DepartmentVO::new).collect(Collectors.toList());
} }
@Override @Override
public Org getTopOrgEntity(Integer orgId) { public Org getTopOrgEntity(Integer orgId, String status) {
Org entity = getEntity(orgId); Org entity = getEntity(orgId);
return getEntity(entity.getRootId()); return getEntity(entity.getRootId());
} }
private OrgExample buildQueryClsExample(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { @Override
Org topOrg = getEntity(loginInfo.getProject()); public List<Org> findEntities(List<Integer> orgIds, String status) {
OrgExample example = new OrgExample(); if (CollectionUtils.isEmpty(orgIds)) {
OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(topOrg.getId()); return new ArrayList<>();
if (self) { } else {
criteria.andCreatorIdEqualTo(loginInfo.getUserVO().getId()); OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria().andIdIn(orgIds);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example);
} }
if (StringUtils.hasText(queryVO.getName())) { }
@Override
public PageVO<DepartmentVO> adminPagedQueryOrg(OrgQueryVO queryVO) {
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria()
.andParentIdIsNotNull().andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (queryVO.getTopOrgId() != null) {
criteria.andRootIdEqualTo(queryVO.getTopOrgId());
}
if (queryVO.getName() != null) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName())); criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
} }
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
List<DepartmentVO> list = page.stream().map(org -> {
int studentNum = iOrgUserService.getQuantities(org.getId(), BusinessConsts.OrgRole.Student);
return new DepartmentVO(org, studentNum);
}).collect(Collectors.toList());
return PageVO.convert(page, list);
}
private OrgExample buildQueryClsExample(OrgQueryVO queryVO, Long userId, Project project, boolean self) {
Org topOrg = getEntity(project, BusinessConsts.Org.Status.VALID);
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria()
.andParentIdEqualTo(topOrg.getId())
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (self) {
criteria.andCreatorIdEqualTo(userId);
}
if (queryVO != null) {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
}
return example; return example;
} }
@ -147,7 +194,7 @@ public class OrgService implements IOrgService{
//检查顶级组织 //检查顶级组织
confirmIsTopOrg(rootId); confirmIsTopOrg(rootId);
//检查同级同名组织 //检查同级同名组织
List<Org> entities = findEntitiesByParentId(parentId, null); List<Org> entities = findEntitiesByParentId(parentId, null, BusinessConsts.Org.Status.VALID);
if (!CollectionUtils.isEmpty(entities)) { if (!CollectionUtils.isEmpty(entities)) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)), BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)),
String.format("上级为[%s]的同名组织已存在", parentId)); String.format("上级为[%s]的同名组织已存在", parentId));
@ -185,12 +232,15 @@ public class OrgService implements IOrgService{
String.format("组织[%s]是顶级组织", id)); String.format("组织[%s]是顶级组织", id));
} }
private List<Org> findEntitiesByRootId(Integer rootId, String orderBy) { private List<Org> findEntitiesByRootId(Integer rootId, String orderBy, String status) {
OrgExample example = new OrgExample(); OrgExample example = new OrgExample();
if (StringUtils.hasText(orderBy)) { if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy); example.setOrderByClause(orderBy);
} }
example.createCriteria().andRootIdEqualTo(rootId); OrgExample.Criteria criteria = example.createCriteria().andRootIdEqualTo(rootId);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
List<Org> orgs = orgDAO.selectByExample(example); List<Org> orgs = orgDAO.selectByExample(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs,
String.format("没有顶级组织id为[%s]的组织", rootId)); String.format("没有顶级组织id为[%s]的组织", rootId));

View File

@ -66,7 +66,7 @@ public class OrgUserService implements IOrgUserService {
@Override @Override
public PageVO<CompanyVO> queryPageOrganizations(CompanyQueryVO queryVO) { public PageVO<CompanyVO> queryPageOrganizations(OrgQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
OrgExample example = new OrgExample(); OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria(); OrgExample.Criteria criteria = example.createCriteria();
@ -569,6 +569,19 @@ public class OrgUserService implements IOrgUserService {
return orgUserDAO.selectByExample(example); return orgUserDAO.selectByExample(example);
} }
@Override
public List<OrgUser> findEntities(List<Integer> orgIds, BusinessConsts.OrgRole role) {
if (CollectionUtils.isEmpty(orgIds)) {
return new ArrayList<>();
} else {
OrgUserExample example = new OrgUserExample();
example.createCriteria()
.andOrgIdIn(orgIds)
.andRoleEqualTo(role.name());
return orgUserDAO.selectByExample(example);
}
}
private String nextCompanyCode() { private String nextCompanyCode() {
OrgExample e = new OrgExample(); OrgExample e = new OrgExample();
e.setLimit(1); e.setLimit(1);

View File

@ -434,7 +434,11 @@ public class AtsStationService {
* 计轴预复位 * 计轴预复位
*/ */
public void preReset(Simulation simulation, Station station) { public void preReset(Simulation simulation, Station station) {
station.getPreResetValidDuration().set(60 * 1000); if (station.isCentralized()) {
station.getPreResetValidDuration().set(60 * 1000);
} else {
station.getDeviceStation().getPreResetValidDuration().set(60 * 1000);
}
} }
/** /**

View File

@ -631,9 +631,9 @@ public class CiApiServiceImpl implements CiApiService {
VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), section.debugStr() + "计轴未占用,无需预复位"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), section.debugStr() + "计轴未占用,无需预复位");
if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) {
Station station = axleSection.getStation(); Station deviceStation = axleSection.getDeviceStation();
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(station, section.debugStr() + "没有所属"); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(station.isPreReset(), station.debugStr() + "需处于预复位状态"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态");
} }
return virtualAxleCounter; return virtualAxleCounter;
} }

View File

@ -550,6 +550,7 @@ public class InterlockBuilder2 {
Station rightStation = null; Station rightStation = null;
Boolean leftFrontTurnBack = null; Boolean leftFrontTurnBack = null;
Boolean rightFrontTurnBack = null; Boolean rightFrontTurnBack = null;
Route route = null;
List<Section> runPath = null; List<Section> runPath = null;
List<Route> routes = null; List<Route> routes = null;
@ -677,7 +678,7 @@ public class InterlockBuilder2 {
break; break;
} }
DestinationCodeDefinition destinationCodeDefinition = new DestinationCodeDefinition(code, type, description, startSection, section, DestinationCodeDefinition destinationCodeDefinition = new DestinationCodeDefinition(code, type, description, startSection, section,
right, necessarySections, leftStation, leftFrontTurnBack, rightStation, rightFrontTurnBack, runPath, routes); right, necessarySections, leftStation, leftFrontTurnBack, rightStation, rightFrontTurnBack, route, runPath, routes);
destinationMap.put(code, destinationCodeDefinition); destinationMap.put(code, destinationCodeDefinition);
} }
} }

View File

@ -53,6 +53,11 @@ public class DestinationCodeDefinition {
*/ */
private Boolean rightFrontTurnBack; private Boolean rightFrontTurnBack;
/**
* 必选进路
*/
private Route necessaryRoute;
//根据目的地码的定义数据生成路径 //根据目的地码的定义数据生成路径
/** /**
* 目的地码代表的运行路径物理区段 * 目的地码代表的运行路径物理区段
@ -62,12 +67,12 @@ public class DestinationCodeDefinition {
private List<Route> routes; private List<Route> routes;
public DestinationCodeDefinition(String code, Type type, Section section) { public DestinationCodeDefinition(String code, Type type, Section section) {
this(code, type, null, null, section, null, null, null, null, null, null, null, null); this(code, type, null, null, section, null, null, null, null, null, null, null, null, null);
} }
public DestinationCodeDefinition(String code, Type type, String description, Section startSection, Section section, Boolean right, public DestinationCodeDefinition(String code, Type type, String description, Section startSection, Section section, Boolean right,
List<Section> necessarySections, Station leftStation, Boolean leftFrontTurnBack, List<Section> necessarySections, Station leftStation, Boolean leftFrontTurnBack,
Station rightStation, Boolean rightFrontTurnBack, List<Section> runPath, List<Route> routes) { Station rightStation, Boolean rightFrontTurnBack, Route route, List<Section> runPath, List<Route> routes) {
this.code = code; this.code = code;
this.type = type; this.type = type;
this.description = description; this.description = description;
@ -79,6 +84,7 @@ public class DestinationCodeDefinition {
this.leftFrontTurnBack = leftFrontTurnBack; this.leftFrontTurnBack = leftFrontTurnBack;
this.rightStation = rightStation; this.rightStation = rightStation;
this.rightFrontTurnBack = rightFrontTurnBack; this.rightFrontTurnBack = rightFrontTurnBack;
this.necessaryRoute = route;
this.runPath = runPath; this.runPath = runPath;
this.routes = routes; this.routes = routes;
} }

View File

@ -65,6 +65,11 @@ public class MapDestinationCodeDefinitionVO {
*/ */
private Boolean stationBFrontTurnBack; private Boolean stationBFrontTurnBack;
/**
* 必选进路
*/
private String necessaryRouteCode;
/** /**
* 目前仅用来生成目的地码数据 * 目前仅用来生成目的地码数据
*/ */
@ -95,6 +100,9 @@ public class MapDestinationCodeDefinitionVO {
if (definition.getRightFrontTurnBack() != null) { if (definition.getRightFrontTurnBack() != null) {
vo.stationBFrontTurnBack = definition.getRightFrontTurnBack(); vo.stationBFrontTurnBack = definition.getRightFrontTurnBack();
} }
if (definition.getNecessaryRoute() != null) {
vo.necessaryRouteCode = definition.getNecessaryRoute().getCode();
}
return vo; return vo;
} }

View File

@ -2,14 +2,15 @@ package club.joylink.rtss.vo.client.org;
import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class CompanyQueryVO extends PageQueryVO { @NoArgsConstructor
public class OrgQueryVO extends PageQueryVO {
private String name; private String name;
private Integer topOrgId;
} }

View File

@ -17,16 +17,24 @@ public class OrgScoringResultVO {
private String username; private String username;
private Integer usualScore; private Integer attendanceScore;
private Integer finalScore; private Integer learningTimeScore;
public OrgScoringResultVO(Long userId, String account, String username, Integer usualScore, Integer finalScore) { private Integer examScore;
public OrgScoringResultVO(Long userId, String account, String username, Integer attendanceScore, Integer learningTimeScore, Integer examScore) {
this.userId = userId; this.userId = userId;
this.account = account; this.account = account;
this.username = username; this.username = username;
this.usualScore = usualScore; this.attendanceScore = attendanceScore;
this.finalScore = finalScore; this.learningTimeScore = learningTimeScore;
this.examScore = examScore;
} }
public OrgScoringResultVO(Long userId, String account, String username) {
this.userId = userId;
this.account = account;
this.username = username;
}
} }

View File

@ -14,8 +14,10 @@ import org.springframework.util.StringUtils;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* 评分规则 * 评分规则
@ -27,10 +29,12 @@ public class OrgScoringRuleVO {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
private String name;
/** /**
* 组织班级id * 组织班级id
*/ */
private Integer orgId; private List<Integer> orgIds;
/** /**
* 学年 * 学年
@ -42,15 +46,15 @@ public class OrgScoringRuleVO {
*/ */
private Integer term; private Integer term;
/** // /**
* 平时分评价规则 // * 平时分评价规则
*/ // */
private ScoringRule usualScoringRule; // private ScoringRule usualScoringRule;
/** /**
* 期末分评价规则 * 评价规则
*/ */
private ScoringRule finalScoringRule; private ScoringRule scoringRule;
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long creatorId; private Long creatorId;
@ -65,10 +69,11 @@ public class OrgScoringRuleVO {
/** /**
* 构建基础信息 * 构建基础信息
*/ */
public static OrgScoringRuleVO buildBasicInfo(OrgScoringRule rule) { public static OrgScoringRuleVO buildBasicInfo(OrgScoringRule rule, List<Integer> orgIds) {
OrgScoringRuleVO vo = new OrgScoringRuleVO(); OrgScoringRuleVO vo = new OrgScoringRuleVO();
vo.setId(rule.getId()); vo.setId(rule.getId());
vo.setOrgId(rule.getOrgId()); vo.setName(rule.getName());
vo.setOrgIds(Objects.requireNonNullElseGet(orgIds, ArrayList::new));
vo.setSchoolYear(rule.getSchoolYear()); vo.setSchoolYear(rule.getSchoolYear());
vo.setTerm(rule.getTerm()); vo.setTerm(rule.getTerm());
vo.setCreatorId(rule.getCreatorId()); vo.setCreatorId(rule.getCreatorId());
@ -81,13 +86,10 @@ public class OrgScoringRuleVO {
/** /**
* 构建详细信息 * 构建详细信息
*/ */
public static OrgScoringRuleVO buildDetails(OrgScoringRuleWithBLOBs rule) { public static OrgScoringRuleVO buildDetails(OrgScoringRuleWithBLOBs rule, List<Integer> orgIds) {
OrgScoringRuleVO vo = buildBasicInfo(rule); OrgScoringRuleVO vo = buildBasicInfo(rule, orgIds);
if (StringUtils.hasText(rule.getUsualScoringRule())) {
vo.setUsualScoringRule(JsonUtils.read(rule.getUsualScoringRule(), ScoringRule.class));
}
if (StringUtils.hasText(rule.getFinalScoringRule())) { if (StringUtils.hasText(rule.getFinalScoringRule())) {
vo.setFinalScoringRule(JsonUtils.read(rule.getFinalScoringRule(), ScoringRule.class)); vo.setScoringRule(JsonUtils.read(rule.getFinalScoringRule(), ScoringRule.class));
} }
return vo; return vo;
} }
@ -96,7 +98,6 @@ public class OrgScoringRuleVO {
* 检查以确保评分规则能够保存 * 检查以确保评分规则能够保存
*/ */
public void check4Save() { public void check4Save() {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(orgId, "班级不能不选");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(schoolYear, "学年不能不选"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(schoolYear, "学年不能不选");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(term, "学期不能不选"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(term, "学期不能不选");
} }
@ -106,45 +107,31 @@ public class OrgScoringRuleVO {
*/ */
public void check4Use() { public void check4Use() {
check4Save(); check4Save();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(usualScoringRule != null || finalScoringRule != null, BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(scoringRule, "评价规则未填写");
"平时分和期末分评价规则至少有一个"); scoringRule.check4Use();
if (usualScoringRule != null) {
usualScoringRule.check4Use(true);
}
if (finalScoringRule != null) {
finalScoringRule.check4Use(false);
}
} }
public OrgScoringRuleWithBLOBs convert2DB() { public OrgScoringRuleWithBLOBs convert2DB() {
OrgScoringRuleWithBLOBs rule = new OrgScoringRuleWithBLOBs(); OrgScoringRuleWithBLOBs rule = new OrgScoringRuleWithBLOBs();
rule.setId(id); rule.setId(id);
rule.setOrgId(orgId); rule.setName(name);
rule.setSchoolYear(schoolYear); rule.setSchoolYear(schoolYear);
rule.setTerm(term); rule.setTerm(term);
rule.setUsualScoringRule(JsonUtils.writeValueAsString(usualScoringRule)); if (scoringRule != null) {
rule.setFinalScoringRule(JsonUtils.writeValueAsString(finalScoringRule)); rule.setFinalScoringRule(JsonUtils.writeValueAsString(scoringRule));
}
return rule; return rule;
} }
public OrgScoringRuleWithBLOBs cover4Update(OrgScoringRuleWithBLOBs entity) { public OrgScoringRuleWithBLOBs cover4Update(OrgScoringRuleWithBLOBs entity) {
entity.setOrgId(orgId);
entity.setSchoolYear(schoolYear); entity.setSchoolYear(schoolYear);
entity.setTerm(term); entity.setTerm(term);
entity.setUsualScoringRule(JsonUtils.writeValueAsString(usualScoringRule)); entity.setFinalScoringRule(JsonUtils.writeValueAsString(scoringRule));
entity.setFinalScoringRule(JsonUtils.writeValueAsString(finalScoringRule));
return entity; return entity;
} }
public int calculateTotalWeight() { public int calculateTotalMarks() {
int totalWeight = 0; return scoringRule.calculateTotalMarks();
if (usualScoringRule != null) {
totalWeight += usualScoringRule.calculateTotalWeight();
}
if (finalScoringRule != null) {
totalWeight += usualScoringRule.calculateTotalWeight();
}
return totalWeight;
} }
/** /**
@ -172,40 +159,33 @@ public class OrgScoringRuleVO {
/** /**
* 获取总权重 * 获取总权重
*/ */
public int calculateTotalWeight() { public int calculateTotalMarks() {
int weight = 0; int weight = 0;
if (this.attendance != null) { if (this.attendance != null) {
weight += this.attendance.getWeight(); weight += this.attendance.getFullMarks();
} }
if (!CollectionUtils.isEmpty(learningTimeList)) { if (!CollectionUtils.isEmpty(learningTimeList)) {
for (LearningTime learningTime : learningTimeList) { for (LearningTime learningTime : learningTimeList) {
weight += learningTime.getWeight(); weight += learningTime.getFullMarks();
} }
} }
if (!CollectionUtils.isEmpty(exams)) { if (!CollectionUtils.isEmpty(exams)) {
for (Exam exam : exams) { for (Exam exam : exams) {
weight += exam.getWeight(); weight += exam.getFullMarks();
} }
} }
return weight; return weight;
} }
public void check4Use(boolean usual) { public void check4Use() {
if (usual) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(attendance != null
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(attendance != null || !CollectionUtils.isEmpty(learningTimeList) || !CollectionUtils.isEmpty(exams),
|| !CollectionUtils.isEmpty(learningTimeList) || !CollectionUtils.isEmpty(exams), "评价规则的细则未填写");
"平时成绩评价细则不能为空"); if (attendance != null) {
} else { attendance.check4Use();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(exams,
"期末成绩评价细则不能为空");
} }
if (usual) { if (!CollectionUtils.isEmpty(learningTimeList)) {
if (attendance != null) { learningTimeList.forEach(LearningTime::check4Use);
attendance.check4Use();
}
if (!CollectionUtils.isEmpty(learningTimeList)) {
learningTimeList.forEach(LearningTime::check4Use);
}
} }
if (!CollectionUtils.isEmpty(exams)) { if (!CollectionUtils.isEmpty(exams)) {
exams.forEach(Exam::check4Use); exams.forEach(Exam::check4Use);
@ -243,23 +223,23 @@ public class OrgScoringRuleVO {
private Map<Integer, Integer> scoringRules; private Map<Integer, Integer> scoringRules;
/** /**
* 权重百分数 * 满分
*/ */
private Integer weight; private Integer fullMarks;
/** /**
* 根据登录天数计算得分 * 根据登录天数计算得分
*/ */
public int calculateScore(int loginDays, int totalWeight) { public int calculateScore(int loginDays) {
double score = Math.min((double) loginDays / days4FullMarks, 1) * 100; double percent = Math.min((double) loginDays / days4FullMarks, 1);
return (int) (score * weight / totalWeight); return (int) (percent * fullMarks);
} }
public void check4Use() { public void check4Use() {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(startDate, "考勤评分的开始时间不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(startDate, "考勤评价的开始时间未填写");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(endDate, "考勤评分的截止时间不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(endDate, "考勤评价的截止时间未填写");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(days4FullMarks, "满分的考勤次数不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(days4FullMarks, "满分的考勤次数未填写");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(weight, "考勤评分的权重不能不填"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(fullMarks, "考勤评价的满分未填写");
} }
} }
@ -286,20 +266,20 @@ public class OrgScoringRuleVO {
*/ */
private Map<Integer, Integer> scoringRules; private Map<Integer, Integer> scoringRules;
private Integer weight; private Integer fullMarks;
public int calculateScore(Long durationInSecond, int totalWeight) { public int calculateScore(Long durationInSecond) {
if (durationInSecond == null) { if (durationInSecond == null) {
return 0; return 0;
} }
double score = Math.min(1, durationInSecond / (duration4FullMarks * 60d)) * 100; double percent = Math.min(1, durationInSecond / (duration4FullMarks * 60d));
return (int) (score * weight / totalWeight); return (int) (percent * fullMarks);
} }
public void check4Use() { public void check4Use() {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(lessonIds, "学习时长评分所选课程不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(lessonIds, "学习时长评价课程未选择");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(duration4FullMarks, "学习时长评分的满分学习时长不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(duration4FullMarks, "学习时长评价的满分学习时长未填写");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(weight, "学习时长评分的权重不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(fullMarks, "学习时长评价的总分未填写");
} }
} }
@ -310,18 +290,24 @@ public class OrgScoringRuleVO {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long examId; private Long examId;
private Integer weight; private Integer fullMarks;
public int calculateScore(Integer examScore, int totalWeight) { /**
if (examScore == null) { * 计算得分
* @param userScore 用户考试得分
* @param examFullMarks 考试满分
*/
public int calculateScore(Integer userScore, int examFullMarks) {
if (userScore == null) {
return 0; return 0;
} }
return (int) (examScore * (double) weight / totalWeight); double percent = (double) userScore / examFullMarks;
return (int) (percent * fullMarks);
} }
public void check4Use() { public void check4Use() {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(examId, "考试评份所选的考试不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(examId, "考试评价的考试未选择");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(weight, "考试评分的权重不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(fullMarks, "考试评价的满分未填写");
} }
} }
} }

View File

@ -12,6 +12,7 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_id" jdbcType="BIGINT" property="updateId" /> <result column="update_id" jdbcType="BIGINT" property="updateId" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -72,8 +73,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <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 update_time, `status`
</sql> </sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.OrgExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="club.joylink.rtss.entity.OrgExample" resultMap="BaseResultMap">
select select
@ -98,7 +99,7 @@
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from org from org
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@ -114,14 +115,14 @@
</if> </if>
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.Org" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.Org" useGeneratedKeys="true">
insert into org (`name`, parent_id, root_id, insert into org (`name`, parent_id, root_id,
project_code, code, creator_id, project_code, code, creator_id,
create_time, update_id, update_time create_time, update_id, update_time,
) `status`)
values (#{name,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{rootId,jdbcType=INTEGER}, values (#{name,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{rootId,jdbcType=INTEGER},
#{projectCode,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT}, #{projectCode,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP} #{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
) #{status,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.Org" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.Org" useGeneratedKeys="true">
insert into org insert into org
@ -153,6 +154,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time, update_time,
</if> </if>
<if test="status != null">
`status`,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null"> <if test="name != null">
@ -182,6 +186,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.OrgExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="club.joylink.rtss.entity.OrgExample" resultType="java.lang.Long">
@ -223,6 +230,9 @@
<if test="record.updateTime != null"> <if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -239,7 +249,8 @@
creator_id = #{record.creatorId,jdbcType=BIGINT}, creator_id = #{record.creatorId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_id = #{record.updateId,jdbcType=BIGINT}, update_id = #{record.updateId,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=TIMESTAMP} update_time = #{record.updateTime,jdbcType=TIMESTAMP},
`status` = #{record.status,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -274,6 +285,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
@ -287,7 +301,8 @@
creator_id = #{creatorId,jdbcType=BIGINT}, creator_id = #{creatorId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_id = #{updateId,jdbcType=BIGINT}, update_id = #{updateId,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP},
`status` = #{status,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>

View File

@ -3,6 +3,7 @@
<mapper namespace="club.joylink.rtss.dao.OrgScoringRuleDAO"> <mapper namespace="club.joylink.rtss.dao.OrgScoringRuleDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.OrgScoringRule"> <resultMap id="BaseResultMap" type="club.joylink.rtss.entity.OrgScoringRule">
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="org_id" jdbcType="INTEGER" property="orgId" /> <result column="org_id" jdbcType="INTEGER" property="orgId" />
<result column="school_year" jdbcType="VARCHAR" property="schoolYear" /> <result column="school_year" jdbcType="VARCHAR" property="schoolYear" />
<result column="term" jdbcType="INTEGER" property="term" /> <result column="term" jdbcType="INTEGER" property="term" />
@ -74,7 +75,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, org_id, school_year, term, creator_id, create_time, update_id, update_time id, `name`, org_id, school_year, term, creator_id, create_time, update_id, update_time
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
usual_scoring_rule, final_scoring_rule usual_scoring_rule, final_scoring_rule
@ -144,18 +145,21 @@
</if> </if>
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs" useGeneratedKeys="true">
insert into org_scoring_rule (org_id, school_year, term, insert into org_scoring_rule (`name`, org_id, school_year,
creator_id, create_time, update_id, term, creator_id, create_time,
update_time, usual_scoring_rule, final_scoring_rule update_id, update_time, usual_scoring_rule,
) final_scoring_rule)
values (#{orgId,jdbcType=INTEGER}, #{schoolYear,jdbcType=VARCHAR}, #{term,jdbcType=INTEGER}, values (#{name,jdbcType=VARCHAR}, #{orgId,jdbcType=INTEGER}, #{schoolYear,jdbcType=VARCHAR},
#{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, #{term,jdbcType=INTEGER}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{usualScoringRule,jdbcType=LONGVARCHAR}, #{finalScoringRule,jdbcType=LONGVARCHAR} #{updateId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{usualScoringRule,jdbcType=LONGVARCHAR},
) #{finalScoringRule,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs" useGeneratedKeys="true">
insert into org_scoring_rule insert into org_scoring_rule
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
`name`,
</if>
<if test="orgId != null"> <if test="orgId != null">
org_id, org_id,
</if> </if>
@ -185,6 +189,9 @@
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="orgId != null"> <if test="orgId != null">
#{orgId,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER},
</if> </if>
@ -226,6 +233,9 @@
<if test="record.id != null"> <if test="record.id != null">
id = #{record.id,jdbcType=BIGINT}, id = #{record.id,jdbcType=BIGINT},
</if> </if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.orgId != null"> <if test="record.orgId != null">
org_id = #{record.orgId,jdbcType=INTEGER}, org_id = #{record.orgId,jdbcType=INTEGER},
</if> </if>
@ -261,6 +271,7 @@
<update id="updateByExampleWithBLOBs" parameterType="map"> <update id="updateByExampleWithBLOBs" parameterType="map">
update org_scoring_rule update org_scoring_rule
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
org_id = #{record.orgId,jdbcType=INTEGER}, org_id = #{record.orgId,jdbcType=INTEGER},
school_year = #{record.schoolYear,jdbcType=VARCHAR}, school_year = #{record.schoolYear,jdbcType=VARCHAR},
term = #{record.term,jdbcType=INTEGER}, term = #{record.term,jdbcType=INTEGER},
@ -277,6 +288,7 @@
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update org_scoring_rule update org_scoring_rule
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
org_id = #{record.orgId,jdbcType=INTEGER}, org_id = #{record.orgId,jdbcType=INTEGER},
school_year = #{record.schoolYear,jdbcType=VARCHAR}, school_year = #{record.schoolYear,jdbcType=VARCHAR},
term = #{record.term,jdbcType=INTEGER}, term = #{record.term,jdbcType=INTEGER},
@ -291,6 +303,9 @@
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs"> <update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs">
update org_scoring_rule update org_scoring_rule
<set> <set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="orgId != null"> <if test="orgId != null">
org_id = #{orgId,jdbcType=INTEGER}, org_id = #{orgId,jdbcType=INTEGER},
</if> </if>
@ -323,7 +338,8 @@
</update> </update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs"> <update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.OrgScoringRuleWithBLOBs">
update org_scoring_rule update org_scoring_rule
set org_id = #{orgId,jdbcType=INTEGER}, set `name` = #{name,jdbcType=VARCHAR},
org_id = #{orgId,jdbcType=INTEGER},
school_year = #{schoolYear,jdbcType=VARCHAR}, school_year = #{schoolYear,jdbcType=VARCHAR},
term = #{term,jdbcType=INTEGER}, term = #{term,jdbcType=INTEGER},
creator_id = #{creatorId,jdbcType=BIGINT}, creator_id = #{creatorId,jdbcType=BIGINT},
@ -336,7 +352,8 @@
</update> </update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.OrgScoringRule"> <update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.OrgScoringRule">
update org_scoring_rule update org_scoring_rule
set org_id = #{orgId,jdbcType=INTEGER}, set `name` = #{name,jdbcType=VARCHAR},
org_id = #{orgId,jdbcType=INTEGER},
school_year = #{schoolYear,jdbcType=VARCHAR}, school_year = #{schoolYear,jdbcType=VARCHAR},
term = #{term,jdbcType=INTEGER}, term = #{term,jdbcType=INTEGER},
creator_id = #{creatorId,jdbcType=BIGINT}, creator_id = #{creatorId,jdbcType=BIGINT},

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.rtss.dao.OrgScoringRuleRelDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.OrgScoringRuleRel">
<result column="org_id" jdbcType="INTEGER" property="orgId" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
org_id, rule_id
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.OrgScoringRuleRelExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from org_scoring_rule_rel
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.OrgScoringRuleRelExample">
delete from org_scoring_rule_rel
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.OrgScoringRuleRel">
insert into org_scoring_rule_rel (org_id, rule_id)
values (#{orgId,jdbcType=INTEGER}, #{ruleId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.OrgScoringRuleRel">
insert into org_scoring_rule_rel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orgId != null">
org_id,
</if>
<if test="ruleId != null">
rule_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orgId != null">
#{orgId,jdbcType=INTEGER},
</if>
<if test="ruleId != null">
#{ruleId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.OrgScoringRuleRelExample" resultType="java.lang.Long">
select count(*) from org_scoring_rule_rel
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update org_scoring_rule_rel
<set>
<if test="record.orgId != null">
org_id = #{record.orgId,jdbcType=INTEGER},
</if>
<if test="record.ruleId != null">
rule_id = #{record.ruleId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update org_scoring_rule_rel
set org_id = #{record.orgId,jdbcType=INTEGER},
rule_id = #{record.ruleId,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<!-- 自定义 -->
<insert id="batchInsert">
insert into org_scoring_rule_rel (org_id, rule_id)
values
<foreach collection="rels" item="rel" separator=",">
(#{rel.orgId}, #{rel.ruleId})
</foreach>
</insert>
</mapper>