From d930f18d52307573137a11921f14dbecffb72c41 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 23 Mar 2021 11:18:44 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=BD=A6=E7=AB=99=E9=A2=84=E5=A4=8D?= =?UTF-8?q?=E4=BD=8D=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/ATS/service/AtsStationService.java | 6 +++++- .../rtss/simulation/cbtc/CI/CiApiServiceImpl.java | 6 +++--- .../cbtc/data/map/DestinationCodeDefinition.java | 10 ++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index eaa8be8f7..31226a195 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -434,7 +434,11 @@ public class AtsStationService { * 计轴预复位 */ 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); + } } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index 8df73da68..42d91c523 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -631,9 +631,9 @@ public class CiApiServiceImpl implements CiApiService { VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), section.debugStr() + "计轴未占用,无需预复位"); if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { - Station station = axleSection.getStation(); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(station, section.debugStr() + "没有所属车站"); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(station.isPreReset(), station.debugStr() + "需处于预复位状态"); + Station deviceStation = axleSection.getDeviceStation(); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中站"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态"); } return virtualAxleCounter; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java index 39939313f..214260355 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java @@ -53,6 +53,11 @@ public class DestinationCodeDefinition { */ private Boolean rightFrontTurnBack; + /** + * 必选进路 + */ + private Route necessaryRoute; + //根据目的地码的定义数据,生成路径 /** * 目的地码代表的运行路径(物理区段) @@ -62,12 +67,12 @@ public class DestinationCodeDefinition { private List routes; 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, List
necessarySections, Station leftStation, Boolean leftFrontTurnBack, - Station rightStation, Boolean rightFrontTurnBack, List
runPath, List routes) { + Station rightStation, Boolean rightFrontTurnBack, Route route, List
runPath, List routes) { this.code = code; this.type = type; this.description = description; @@ -79,6 +84,7 @@ public class DestinationCodeDefinition { this.leftFrontTurnBack = leftFrontTurnBack; this.rightStation = rightStation; this.rightFrontTurnBack = rightFrontTurnBack; + this.necessaryRoute = route; this.runPath = runPath; this.routes = routes; } From bd5d1e9d4b86e84f728004b3a84c0b92998e1367 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 23 Mar 2021 13:24:45 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=9B=AE=E7=9A=84=E5=9C=B0=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91=E6=8A=A5=E9=94=99=E6=B6=88?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DraftMapCiDataGeneratorImpl.java | 85 +++++++++++-------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 179f70111..b44cc8284 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -88,7 +88,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { // 删除旧联锁数据,保存新联锁数据 this.draftMapService.cleanAndSaveCiData(mapId, approachSectionVOList, routeVOList, overlapVOList, flsVOList, autoSignalNewVOList, - autoReentryVOList,destinationCodeDefinitionVOList, result.getRoutingList(),result.getStationRunLevelList()); + autoReentryVOList, destinationCodeDefinitionVOList, result.getRoutingList(), result.getStationRunLevelList()); return result.convert2VO(); } @@ -324,6 +324,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { Boolean leftFrontTurnBack = null; Station rightStation = null; Boolean rightFrontTurnBack = null; + Route route = null; int codeNum = 1; for (int i = 0; i < stationList.size(); i++) { @@ -352,7 +353,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { rightFrontTurnBack = endTbSection.isNormalStandTrack(); destinationCodeDefinitionList.add( 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, autoSignalList, generatedRouteList, generatedOverlapList, flsList, - generateCycleList, generateRoutingList,generatedStationRunLevelList, destinationCodeDefinitionList); + generateCycleList, generateRoutingList, generatedStationRunLevelList, destinationCodeDefinitionList); } /** * 筛选站后折返轨(优先右行站台折返) + * * @param stations 所有车站 - * @param right 是否是右端车站 + * @param right 是否是右端车站 */ private List
queryFrontTurnBackList(List stations, Station station, boolean right) { List
turnBackList = station.getTurnBackList(); @@ -425,6 +427,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 筛选站前折返轨 + * * @param right 是否是右端车站 */ private List
queryAfterTurnBackList(Station station, boolean right) { @@ -506,12 +509,13 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 生成进路 - * @param start 始端信号机 - * @param routeCodeGenerator 进路code生成器 - * @param overlapMap 已经构建的延续保护数据map(key-信号机code,val-延续保护路径) + * + * @param start 始端信号机 + * @param routeCodeGenerator 进路code生成器 + * @param overlapMap 已经构建的延续保护数据map(key-信号机code,val-延续保护路径) * @param overlapCodeGenerator 延续保护code生成器 - * @param config 生成配置 - * @param errorList 生成错误信息 + * @param config 生成配置 + * @param errorList 生成错误信息 */ private List generateRoute(Signal start, CodeGenerator routeCodeGenerator, Map> overlapMap, @@ -575,7 +579,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { routeList.add(route); ++index; } - } else if(config.isOverlapSettingByTrigger()) { // 触发建立,进路不绑定延续保护 + } else if (config.isOverlapSettingByTrigger()) { // 触发建立,进路不绑定延续保护 String code = routeCodeGenerator.next(); String name = String.format("%s-%s", start.getName(), endName); Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath, @@ -594,13 +598,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } } } else { - errorList.add(String.format("以[%s(%s)]为始端信号的进路未搜索到",start.getName(), start.getCode())); + errorList.add(String.format("以[%s(%s)]为始端信号的进路未搜索到", start.getName(), start.getCode())); } return routeList; } /** * 查询距给给定信号机最近的信号机 + * * @param signal * @param sectionPath * @return @@ -629,6 +634,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 根据信号机配置,删除不需要的基本进路 + * * @param signalList * @param generatedRouteList */ @@ -672,6 +678,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 构建道岔定位侧防 + * * @param aSwitch * @param fpCodeGenerator * @return @@ -761,6 +768,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 构建道岔反位侧防 + * * @param aSwitch * @param fpCodeGenerator * @return @@ -848,9 +856,9 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { Section routingEndSection = (Section) deviceMap.get(routing.getEndSectionCode()); Boolean right = routing.getRight(); List 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 endSection = (Section) deviceMap.get(sectionCodeList.get(i+1).getSectionCode()); + Section endSection = (Section) deviceMap.get(sectionCodeList.get(i + 1).getSectionCode()); //已创建 boolean exist = false; for (MapStationRunLevelVO vo : generatedStationRunLevelList) { @@ -900,7 +908,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { String.format("%s(%s)->%s(%s)", routingStartSection.getStation().getName(), routingStartSection.getName(), routingEndSection.getStation().getName(), routingEndSection.getName()), - !right ? "右向":"左向")); + !right ? "右向" : "左向")); runLevelVO.setRight(!right); } } @@ -1143,6 +1151,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 生成折返进路 + * * @param routeList * @param routeCodeGenerator * @param config @@ -1221,6 +1230,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 查询进路终端信号机的临近反向信号机 + * * @param end * @return */ @@ -1248,13 +1258,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 生成进路的敌对关系 + * * @param routeList */ private void buildRouteConflict(List routeList) { // 敌对进路:两进路方向相反,且始端信号机在同一区段或有共同区段,但无冲突道岔 for (int i = 0; i < routeList.size(); 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); if (route1.containConflictRoute(route2)) { continue; @@ -1283,14 +1294,15 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 构造进路对象 + * * @param code * @param name - * @param start 始端信号机 - * @param end 终端信号机 - * @param endButton 建立方式为按钮点选方式时,终端按钮信号机 + * @param start 始端信号机 + * @param end 终端信号机 + * @param endButton 建立方式为按钮点选方式时,终端按钮信号机 * @param sectionPath * @param routeOverlap - * @param alwaysGreen 进路始端信号是否总是开绿灯 + * @param alwaysGreen 进路始端信号是否总是开绿灯 * @return */ private Route buildRoute(String code, String name, @@ -1372,9 +1384,10 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 根据路径创建延续保护 - * @param end 延续保护始端信号机 + * + * @param end 延续保护始端信号机 * @param overlapCodeGenerator code生成器 - * @param config 配置 + * @param config 配置 * @param errorList * @return */ @@ -1455,7 +1468,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { if (routeOverlap.containRpSwitch()) { routeOverlap.setName(routeOverlap.getName() + "_2"); } else { - routeOverlap.setName(routeOverlap.getName()+"_1"); + routeOverlap.setName(routeOverlap.getName() + "_1"); } } } else if (list.size() > 2) { @@ -1560,11 +1573,12 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 获取延续保护路径 + * * @param section - * @param right 方向 - * @param tempPath 临时路径 + * @param right 方向 + * @param tempPath 临时路径 * @param overlapPathList 最终结果列表 - * @param config 生成配置参数 + * @param config 生成配置参数 * @param errorList */ private void getOverlapPathOf(Section section, boolean right, @@ -1661,12 +1675,13 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 获取可走的进路路径 - * @param section 下一个区段 - * @param ground 是否查询地面信号 - * @param tempPath 临时路径 + * + * @param section 下一个区段 + * @param ground 是否查询地面信号 + * @param tempPath 临时路径 * @param routePathList 最终结果 - * @param config 生成配置参数 - * @param errorList 错误信息 + * @param config 生成配置参数 + * @param errorList 错误信息 */ private void getRoutePathOf(Signal startSignal, Section section, boolean ground, SectionPath tempPath, List routePathList, @@ -1766,6 +1781,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 生成接近区段 + * * @param signal * @param config */ @@ -1784,7 +1800,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { List
logicApproachList = new ArrayList<>(); List
sectionList = sectionPath.getSectionList(); for (Section phySection : sectionList) { - if(len >= 600) break; + if (len >= 600) break; if (phySection.isSwitchTrack()) { len += phySection.getLen(); logicApproachList.add(phySection); @@ -1803,7 +1819,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { for (Section logic : sortedList) { logicApproachList.add(logic); len += logic.getLen(); - if(len >= 600) break; + if (len >= 600) break; } } sectionPath.setLogicList(logicApproachList); @@ -1872,8 +1888,8 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } else { throw BusinessExceptionAssertEnum.DATA_ERROR.exception( String.format("地图基础数据有错误:区段[%s(%s)]关联了道岔[%s(%s)],却不是此道岔的关联区段", - section.getName(), section.getCode(), - relSwitch.getName(), relSwitch.getCode())); + section.getName(), section.getCode(), + relSwitch.getName(), relSwitch.getCode())); } } else { tempPath.addSection(section); @@ -1884,6 +1900,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { /** * 生成自动信号 + * * @param signal * @param autoSignalGenerator * @param errorList From e5282d6c0d302b6294817e5226164374d7a260b4 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 23 Mar 2021 16:47:56 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=99=E5=AD=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E8=AF=84=E4=BB=B7=E8=A7=84=E5=88=99?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9B=E7=BB=84=E7=BB=87=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=80=BB=E8=BE=91=E5=88=A0=E9=99=A4=EF=BC=88?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E5=96=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20210322-zhangsai.sql | 15 + .../rtss/constants/BusinessConsts.java | 7 + .../rtss/controller/OrgController.java | 62 +-- .../controller/publish/ExamController.java | 18 +- .../controller/publish/LessonController.java | 4 +- .../rtss/dao/OrgScoringRuleRelDAO.java | 15 + .../java/club/joylink/rtss/entity/Org.java | 22 +- .../club/joylink/rtss/entity/OrgExample.java | 72 +++- .../joylink/rtss/entity/OrgScoringRule.java | 20 +- .../rtss/entity/OrgScoringRuleExample.java | 70 ++++ .../rtss/entity/OrgScoringRuleRel.java | 69 ++++ .../rtss/entity/OrgScoringRuleRelExample.java | 342 ++++++++++++++++ .../rtss/entity/OrgScoringRuleWithBLOBs.java | 4 +- .../joylink/rtss/services/ExamService.java | 101 +++-- .../joylink/rtss/services/IExamService.java | 15 +- .../joylink/rtss/services/ILessonService.java | 10 +- .../joylink/rtss/services/LessonService.java | 34 +- .../rtss/services/UserExamService.java | 2 +- .../rtss/services/org/IOrgLessonService.java | 4 +- .../services/org/IOrgScoringRuleService.java | 27 +- .../rtss/services/org/IOrgService.java | 19 +- .../rtss/services/org/IOrgUserService.java | 4 +- .../rtss/services/org/OrgLessonService.java | 17 +- .../services/org/OrgScoringRuleService.java | 377 +++++++++++++----- .../joylink/rtss/services/org/OrgService.java | 102 +++-- .../rtss/services/org/OrgUserService.java | 15 +- .../{CompanyQueryVO.java => OrgQueryVO.java} | 7 +- .../vo/client/org/OrgScoringResultVO.java | 18 +- .../rtss/vo/client/org/OrgScoringRuleVO.java | 146 +++---- src/main/resources/mybatis/mapper/OrgDAO.xml | 43 +- .../mybatis/mapper/OrgScoringRuleDAO.xml | 39 +- .../mybatis/mapper/OrgScoringRuleRelDAO.xml | 156 ++++++++ 32 files changed, 1517 insertions(+), 339 deletions(-) create mode 100644 sql/20210322-zhangsai.sql create mode 100644 src/main/java/club/joylink/rtss/dao/OrgScoringRuleRelDAO.java create mode 100644 src/main/java/club/joylink/rtss/entity/OrgScoringRuleRel.java create mode 100644 src/main/java/club/joylink/rtss/entity/OrgScoringRuleRelExample.java rename src/main/java/club/joylink/rtss/vo/client/org/{CompanyQueryVO.java => OrgQueryVO.java} (58%) create mode 100644 src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml diff --git a/sql/20210322-zhangsai.sql b/sql/20210322-zhangsai.sql new file mode 100644 index 000000000..9fd19e1db --- /dev/null +++ b/sql/20210322-zhangsai.sql @@ -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 '状态'; diff --git a/src/main/java/club/joylink/rtss/constants/BusinessConsts.java b/src/main/java/club/joylink/rtss/constants/BusinessConsts.java index 594581f55..f0e0e5c38 100644 --- a/src/main/java/club/joylink/rtss/constants/BusinessConsts.java +++ b/src/main/java/club/joylink/rtss/constants/BusinessConsts.java @@ -789,4 +789,11 @@ public interface BusinessConsts { enum OrgRole { Admin,Teacher, Student } + + interface Org{ + interface Status { + String DELETE = "0"; + String VALID = "1"; + } + } } diff --git a/src/main/java/club/joylink/rtss/controller/OrgController.java b/src/main/java/club/joylink/rtss/controller/OrgController.java index 01dd1864f..5fa772b55 100644 --- a/src/main/java/club/joylink/rtss/controller/OrgController.java +++ b/src/main/java/club/joylink/rtss/controller/OrgController.java @@ -1,6 +1,8 @@ package club.joylink.rtss.controller; +import club.joylink.rtss.constants.RoleEnum; import club.joylink.rtss.controller.advice.AuthenticateInterceptor; +import club.joylink.rtss.controller.advice.Role; import club.joylink.rtss.services.org.IOrgLessonService; import club.joylink.rtss.services.org.IOrgScoringRuleService; import club.joylink.rtss.services.org.IOrgService; @@ -52,9 +54,8 @@ public class OrgController { @ApiOperation(value = "分页获取公司列表") @GetMapping("paging") - public PageVO pagingQueryAll(CompanyQueryVO queryVO) { - PageVO list = iOrgUserService.queryPageOrganizations(queryVO); - return list; + public PageVO pagingQueryAll(OrgQueryVO queryVO) { + return iOrgUserService.queryPageOrganizations(queryVO); } @ApiOperation(value = "删除公司信息") @@ -164,10 +165,10 @@ public class OrgController { iOrgUserService.deleteDepartUserInfo(user, userDepartRelVO); } - @ApiOperation(value = "分页获取单位部门成员信息") - @GetMapping("/dept/{deptId}/departUserInfo") - public PageVO getCompanyUserInfo(@RequestAttribute @ApiIgnore UserVO user, @PathVariable Integer deptId, CompanyUserQueryVO companyUserQueryVO) { - return iOrgUserService.getCompanyDepartUserInfoList(user, deptId, companyUserQueryVO); + @ApiOperation(value = "分页获取班级学生信息") + @GetMapping("/dept/{clsId}/departUserInfo") + public PageVO getCompanyUserInfo(@RequestAttribute @ApiIgnore UserVO user, @PathVariable Integer clsId, CompanyUserQueryVO companyUserQueryVO) { + return iOrgUserService.getCompanyDepartUserInfoList(user, clsId, companyUserQueryVO); } @ApiOperation(value = "导入单位成员信息") @@ -206,28 +207,22 @@ public class OrgController { iOrgService.createCls(createVO, loginInfo); } - @ApiOperation("分页查询所有班级") - @GetMapping("/paged/cls") - public PageVO pagedQueryCls(CompanyQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { - return iOrgService.pagedQueryCls(queryVO, loginInfo, false); - } - @ApiOperation("分页查询个人创建的班级") @GetMapping("/paged/cls/self") - public PageVO pagedQuerySelfCls(CompanyQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { + public PageVO pagedQuerySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { return iOrgService.pagedQueryCls(queryVO, loginInfo, true); } @ApiOperation("查询个人创建的班级") @GetMapping("/list/cls/self") - public List querySelfCls(CompanyQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { + public List querySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { return iOrgService.queryCls(queryVO, loginInfo, true); } @ApiOperation("创建评价规则") @PostMapping("/orgScoringRule") - public void createScoringRule(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute UserVO user) { - iOrgScoringRuleService.createScoringRule(orgScoringRuleVO, user); + public void createScoringRule(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute LoginUserInfoVO loginInfo) { + iOrgScoringRuleService.createScoringRule(orgScoringRuleVO, loginInfo); } @ApiOperation("保存评价规则") @@ -245,8 +240,8 @@ public class OrgController { @ApiOperation("查询自己创建的指定评价规则详细信息") @GetMapping("/orgScoringRule/details/self/{orgId}/{schoolYear}/{term}") public OrgScoringRuleVO queryOrgScoringRuleDetails(@PathVariable Integer orgId, @PathVariable String schoolYear, - @PathVariable Integer term, @RequestAttribute UserVO user) { - return iOrgScoringRuleService.queryOrgScoringRuleDetails(orgId, schoolYear, term, user); + @PathVariable Integer term, @RequestAttribute LoginUserInfoVO loginInfo) { + return iOrgScoringRuleService.queryOrgScoringRuleDetails(orgId, schoolYear, term, loginInfo); } @ApiOperation("查询指定评价规则详细信息") @@ -255,17 +250,11 @@ public class OrgController { return iOrgScoringRuleService.getOrgScoringRuleDetails(ruleId); } - @ApiOperation("使用评价规则评分") - @GetMapping("/orgScoringRule/score") - public List score(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute UserVO user) { - return iOrgScoringRuleService.score(orgScoringRuleVO, user); - } - @ApiOperation("使用评价规则评分") @GetMapping("/orgScoringRule/score/{orgId}/{schoolYear}/{term}") public List score(@PathVariable Integer orgId, @PathVariable String schoolYear, - @PathVariable Integer term, @RequestAttribute UserVO user) { - return iOrgScoringRuleService.score(orgId, schoolYear, term , user); + @PathVariable Integer term, @RequestAttribute LoginUserInfoVO loginInfo) { + return iOrgScoringRuleService.score(orgId, schoolYear, term, loginInfo); } @ApiOperation("删除评分规则") @@ -273,4 +262,23 @@ public class OrgController { public void deleteScoringRule(@PathVariable Long ruleId, @RequestAttribute UserVO user) { iOrgScoringRuleService.deleteRuleOfSelf(ruleId, user.getId()); } + + @ApiOperation("查询规则能够应用到的组织") + @GetMapping("/orgScoringRule/{ruleId}/canApplyTo") + public List queryRuleCanApplyTo(@PathVariable Long ruleId) { + return iOrgScoringRuleService.queryRuleCanApplyTo(ruleId); + } + + @ApiOperation("将评价规则应用到") + @PostMapping("/orgScoringRule/{ruleId}/apply") + public void applyOrgScoringRule(@PathVariable Long ruleId, @RequestBody List orgIds) { + iOrgScoringRuleService.applyOrgScoringRule(ruleId, orgIds); + } + + @Role(RoleEnum.Admin) + @ApiOperation("管理员查看非顶级组织") + @GetMapping("/org/admin/paged") + public PageVO adminPagedQueryOrg(OrgQueryVO queryVO) { + return iOrgService.adminPagedQueryOrg(queryVO); + } } diff --git a/src/main/java/club/joylink/rtss/controller/publish/ExamController.java b/src/main/java/club/joylink/rtss/controller/publish/ExamController.java index 24661b847..571f35656 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/ExamController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/ExamController.java @@ -112,15 +112,21 @@ public class ExamController { this.iExamService.update(id, examDefinitionVO); } - @ApiOperation(value = "分页查询自己创建的试卷") - @GetMapping("/paged/org/self") + @ApiOperation(value = "分页查询当前登录项目下自己创建的试卷") + @GetMapping("/paged/loginProject/self") public PageVO 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 listQueryExamICreated(ExamDefinitionQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { + return this.iExamService.listQueryExamICreated(queryVO, loginInfo); + } + + @ApiOperation(value = "不分页查询组织下自己创建的试卷") @GetMapping("/list/org/self") - public List listQuerySelfExam(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) { - return this.iExamService.listQueryOrgExamOfSelf(clsId, loginInfo); + public List listQueryOrgExamOfSelf(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) { + return this.iExamService.listQueryOrgExamICreated(clsId, loginInfo); } } diff --git a/src/main/java/club/joylink/rtss/controller/publish/LessonController.java b/src/main/java/club/joylink/rtss/controller/publish/LessonController.java index ff453377f..845ba602f 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/LessonController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/LessonController.java @@ -132,10 +132,10 @@ public class LessonController { @ApiOperation(value = "查询用户当前登录的项目下的课程") @GetMapping(path = "/unPaged/self") public List 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") public List queryOrgLessonOfSelf(Integer clsId, @RequestAttribute LoginUserInfoVO loginInfo) { return iLessonService.queryOrgLessonOfSelf(clsId, loginInfo); diff --git a/src/main/java/club/joylink/rtss/dao/OrgScoringRuleRelDAO.java b/src/main/java/club/joylink/rtss/dao/OrgScoringRuleRelDAO.java new file mode 100644 index 000000000..7b250835e --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/OrgScoringRuleRelDAO.java @@ -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 { + void batchInsert(List rels); +} diff --git a/src/main/java/club/joylink/rtss/entity/Org.java b/src/main/java/club/joylink/rtss/entity/Org.java index 304d091b9..9cdd09cb8 100644 --- a/src/main/java/club/joylink/rtss/entity/Org.java +++ b/src/main/java/club/joylink/rtss/entity/Org.java @@ -36,7 +36,7 @@ public class Org implements Serializable { private String code; /** - * 创建时间 + * 创建者 */ private Long creatorId; @@ -55,6 +55,11 @@ public class Org implements Serializable { */ private LocalDateTime updateTime; + /** + * 状态 + */ + private String status; + private static final long serialVersionUID = 1L; public Integer getId() { @@ -137,6 +142,14 @@ public class Org implements Serializable { this.updateTime = updateTime; } + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + @Override public boolean equals(Object 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.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (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 @@ -175,6 +189,7 @@ public class Org implements Serializable { result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateId() == null) ? 0 : getUpdateId().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); return result; } @@ -194,8 +209,9 @@ public class Org implements Serializable { sb.append(", createTime=").append(createTime); sb.append(", updateId=").append(updateId); sb.append(", updateTime=").append(updateTime); + sb.append(", status=").append(status); sb.append(", serialVersionUID=").append(serialVersionUID); sb.append("]"); return sb.toString(); } -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/OrgExample.java b/src/main/java/club/joylink/rtss/entity/OrgExample.java index cf929df97..e609094fc 100644 --- a/src/main/java/club/joylink/rtss/entity/OrgExample.java +++ b/src/main/java/club/joylink/rtss/entity/OrgExample.java @@ -754,6 +754,76 @@ public class OrgExample { addCriterion("update_time not between", value1, value2, "updateTime"); 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 values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List 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); } } -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/OrgScoringRule.java b/src/main/java/club/joylink/rtss/entity/OrgScoringRule.java index 813625167..d8e9bd8eb 100644 --- a/src/main/java/club/joylink/rtss/entity/OrgScoringRule.java +++ b/src/main/java/club/joylink/rtss/entity/OrgScoringRule.java @@ -4,14 +4,19 @@ import java.io.Serializable; import java.time.LocalDateTime; /** - * @author + * @author * 组织评分规则 */ public class OrgScoringRule implements Serializable { private Long id; /** - * 组织(班级)id + * 名称 + */ + private String name; + + /** + * 该规则属于哪个顶级组织 */ private Integer orgId; @@ -55,6 +60,14 @@ public class OrgScoringRule implements Serializable { this.id = id; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public Integer getOrgId() { return orgId; } @@ -124,6 +137,7 @@ public class OrgScoringRule implements Serializable { } OrgScoringRule other = (OrgScoringRule) that; 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.getSchoolYear() == null ? other.getSchoolYear() == null : this.getSchoolYear().equals(other.getSchoolYear())) && (this.getTerm() == null ? other.getTerm() == null : this.getTerm().equals(other.getTerm())) @@ -138,6 +152,7 @@ public class OrgScoringRule implements Serializable { final int prime = 31; int result = 1; 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 + ((getSchoolYear() == null) ? 0 : getSchoolYear().hashCode()); result = prime * result + ((getTerm() == null) ? 0 : getTerm().hashCode()); @@ -155,6 +170,7 @@ public class OrgScoringRule implements Serializable { sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", name=").append(name); sb.append(", orgId=").append(orgId); sb.append(", schoolYear=").append(schoolYear); sb.append(", term=").append(term); diff --git a/src/main/java/club/joylink/rtss/entity/OrgScoringRuleExample.java b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleExample.java index ff3aa8000..10f4fe3a7 100644 --- a/src/main/java/club/joylink/rtss/entity/OrgScoringRuleExample.java +++ b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleExample.java @@ -185,6 +185,76 @@ public class OrgScoringRuleExample { 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 values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List 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() { addCriterion("org_id is null"); return (Criteria) this; diff --git a/src/main/java/club/joylink/rtss/entity/OrgScoringRuleRel.java b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleRel.java new file mode 100644 index 000000000..5896772b8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleRel.java @@ -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(); + } +} diff --git a/src/main/java/club/joylink/rtss/entity/OrgScoringRuleRelExample.java b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleRelExample.java new file mode 100644 index 000000000..f20a0251a --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleRelExample.java @@ -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 oredCriteria; + + private Integer limit; + + private Long offset; + + public OrgScoringRuleRelExample() { + oredCriteria = new ArrayList(); + } + + 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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 values) { + addCriterion("org_id in", values, "orgId"); + return (Criteria) this; + } + + public Criteria andOrgIdNotIn(List 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 values) { + addCriterion("rule_id in", values, "ruleId"); + return (Criteria) this; + } + + public Criteria andRuleIdNotIn(List 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); + } + } +} diff --git a/src/main/java/club/joylink/rtss/entity/OrgScoringRuleWithBLOBs.java b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleWithBLOBs.java index 32a6bb8ef..57ea31570 100644 --- a/src/main/java/club/joylink/rtss/entity/OrgScoringRuleWithBLOBs.java +++ b/src/main/java/club/joylink/rtss/entity/OrgScoringRuleWithBLOBs.java @@ -3,7 +3,7 @@ package club.joylink.rtss.entity; import java.io.Serializable; /** - * @author + * @author * 组织评分规则 */ public class OrgScoringRuleWithBLOBs extends OrgScoringRule implements Serializable { @@ -48,6 +48,7 @@ public class OrgScoringRuleWithBLOBs extends OrgScoringRule implements Serializa } OrgScoringRuleWithBLOBs other = (OrgScoringRuleWithBLOBs) that; 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.getSchoolYear() == null ? other.getSchoolYear() == null : this.getSchoolYear().equals(other.getSchoolYear())) && (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; int result = 1; 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 + ((getSchoolYear() == null) ? 0 : getSchoolYear().hashCode()); result = prime * result + ((getTerm() == null) ? 0 : getTerm().hashCode()); diff --git a/src/main/java/club/joylink/rtss/services/ExamService.java b/src/main/java/club/joylink/rtss/services/ExamService.java index 6461951b7..d76ecefb8 100644 --- a/src/main/java/club/joylink/rtss/services/ExamService.java +++ b/src/main/java/club/joylink/rtss/services/ExamService.java @@ -14,7 +14,6 @@ import club.joylink.rtss.vo.client.*; import club.joylink.rtss.vo.client.org.DepartmentVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -445,6 +444,7 @@ public class ExamService implements IExamService { examDefinitionDAO.deleteByPrimaryKey(Long.parseLong(id)); } + // /** // * 查询章节下允许创建的最多题目数量 // * @@ -465,7 +465,6 @@ public class ExamService implements IExamService { // // return lsRelChapterTrainingList.size(); // } - @Override public Long queryTrainingNum(Long lessonId, String trainingType, String operateType) { // 获取课程数据 @@ -501,6 +500,20 @@ public class ExamService implements IExamService { 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 findEntities(List examIds) { + ExamDefinitionExample example = new ExamDefinitionExample(); + example.createCriteria().andIdIn(examIds); + return examDefinitionDAO.selectByExample(example); + } + private void forceOffline(ExamDefinition exam) { exam.setStatus(BusinessConsts.STATUS_NOT_USE); this.examDefinitionDAO.updateByPrimaryKey(exam); @@ -590,41 +603,79 @@ public class ExamService implements IExamService { } @Override - public PageVO pagedQuerySelfExam4OrgTeacher(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) { - List orgLessons; + public PageVO pagedQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) { + List lessonIds; if (queryVO.getLessonId() != null) { - orgLessons = iOrgLessonService.findEntities(queryVO.getLessonId()); + lessonIds = List.of(queryVO.getLessonId()); } else { - Org topOrg = iOrgService.getEntity(loginInfo.getProject()); - List clsIds = iOrgService.findEntitiesByParentId(topOrg.getId(), null).stream().map(Org::getId).collect(Collectors.toList()); - orgLessons = iOrgLessonService.findEntities(clsIds); + lessonIds = iLessonService.queryLessonICreatedInLoginProject(loginInfo).stream().map(LessonVO::getId).collect(Collectors.toList()); } - - Map> lessonOrgMap = orgLessons.stream().collect(Collectors.groupingBy(OrgLesson::getLessonId)); - List lessonIds = orgLessons.stream().map(OrgLesson::getLessonId).collect(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())); + if (CollectionUtils.isEmpty(lessonIds)) { + return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>()); + } else { + List orgLessons = iOrgLessonService.findEntitiesByLessonIds(lessonIds); + Map> 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())); + } + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + Page page = (Page) examDefinitionDAO.selectByExample(example); + List 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 page = (Page) examDefinitionDAO.selectByExample(example); - List 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 - public List listQueryOrgExamOfSelf(@NonNull Integer clsId, LoginUserInfoVO loginInfo) { - List lessonIds = iOrgLessonService.findEntities(clsId).stream().map(OrgLesson::getLessonId).collect(Collectors.toList()); + public List listQueryOrgExamICreated(Integer clsId, LoginUserInfoVO loginInfo) { + List lessonIds; + if (clsId == null) { + Org topOrg = iOrgService.getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID); + List clsList = iOrgService.findEntitiesByParentId(topOrg.getId(), "id", BusinessConsts.Org.Status.VALID); + List 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() .filter(exam -> loginInfo.getUserVO().getId().equals(exam.getCreatorId())) .map(ExamDefinitionVO::new).collect(Collectors.toList()); } + @Override + public List listQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) { + List 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 orgLessons = iOrgLessonService.findEntitiesByLessonIds(lessonIds); + Map> 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 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 findEntityByLessonIdList(List lessonIdList) { if (CollectionUtils.isEmpty(lessonIdList)) { return new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/services/IExamService.java b/src/main/java/club/joylink/rtss/services/IExamService.java index 20441d019..1bffcf6f6 100644 --- a/src/main/java/club/joylink/rtss/services/IExamService.java +++ b/src/main/java/club/joylink/rtss/services/IExamService.java @@ -49,11 +49,11 @@ public interface IExamService { */ void deleteExam(String id, UserVO userVO); + // /** // * 查询章节下允许创建的最多题目数量 // */ // int queryTrainingNum(String lessonId, String chapterId); - /** * 根据课程和实训类型查询实训数量 */ @@ -84,10 +84,19 @@ public interface IExamService { /** * 分页查询组织老师个人创建的考试 */ - PageVO pagedQuerySelfExam4OrgTeacher(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo); + PageVO pagedQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo); /** * 不分页查询组织老师个人创建的考试 */ - List listQueryOrgExamOfSelf(Integer clsId, LoginUserInfoVO loginInfo); + List listQueryOrgExamICreated(Integer clsId, LoginUserInfoVO loginInfo); + + /** + * 查询当前项目下“我”创建的考试 + */ + List listQueryExamICreated(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo); + + ExamDefinition getEntity(Long examId); + + List findEntities(List examIds); } diff --git a/src/main/java/club/joylink/rtss/services/ILessonService.java b/src/main/java/club/joylink/rtss/services/ILessonService.java index eb3abfb5b..931ed8a6b 100644 --- a/src/main/java/club/joylink/rtss/services/ILessonService.java +++ b/src/main/java/club/joylink/rtss/services/ILessonService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.services; +import club.joylink.rtss.constants.Project; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.*; @@ -153,12 +154,17 @@ public interface ILessonService { PageVO pagedQueryPersonalLesson(LessonQueryVO queryVO, LoginUserInfoVO loginInfo); /** - * 查询用户当前登录的项目下的课程(仅课程的信息) + * 查询自己创建的、当前登录的项目下的课程(仅课程的信息) */ - List queryPersonalLesson(LoginUserInfoVO loginInfo); + List queryLessonICreatedInLoginProject(LoginUserInfoVO loginInfo); /** * 查询自己为指定班级创建的课程 */ List queryOrgLessonOfSelf(Integer clsId, LoginUserInfoVO loginInfo); + + /** + * 查询由该用户创建的、在这个项目下的课程 + */ + List queryLessons(Long userId, Project project); } diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index f29b3a7f0..f4d40ec9a 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -2,6 +2,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.MapStatus; +import club.joylink.rtss.constants.Project; import club.joylink.rtss.dao.*; import club.joylink.rtss.entity.*; import club.joylink.rtss.entity.LsLessonExample.Criteria; @@ -573,20 +574,8 @@ public class LessonService implements ILessonService { } @Override - public List queryPersonalLesson(LoginUserInfoVO loginInfo) { - List maps = iMapService.findOnlineMapByProjectCode(loginInfo.getProject().name()); - if (CollectionUtils.isEmpty(maps)) { - return new ArrayList<>(); - } else { - List mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList()); - LsLessonExample example = new LsLessonExample(); - example.createCriteria() - .andMapIdIn(mapIds) - .andCreatorIdEqualTo(loginInfo.getUserVO().getId()) - .andSysfaultEqualTo(false); - List list = lessonDAO.selectByExample(example); - return LessonVO.convert(list); - } + public List queryLessonICreatedInLoginProject(LoginUserInfoVO loginInfo) { + return queryLessons(loginInfo.getUserVO().getId(), loginInfo.getProject()); } @Override @@ -597,6 +586,23 @@ public class LessonService implements ILessonService { .filter(lesson->loginInfo.getUserVO().getId().equals(lesson.getCreatorId())).map(LessonVO::new).collect(Collectors.toList()); } + @Override + public List queryLessons(Long userId, Project project) { + List maps = iMapService.findOnlineMapByProjectCode(project.name()); + if (CollectionUtils.isEmpty(maps)) { + return new ArrayList<>(); + } else { + List mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList()); + LsLessonExample example = new LsLessonExample(); + example.createCriteria() + .andMapIdIn(mapIds) + .andCreatorIdEqualTo(userId) + .andSysfaultEqualTo(false); + List list = lessonDAO.selectByExample(example); + return LessonVO.convert(list); + } + } + private List findLessonEntities(List lessonIds) { if (CollectionUtils.isEmpty(lessonIds)) { return new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/services/UserExamService.java b/src/main/java/club/joylink/rtss/services/UserExamService.java index ab7cb3c43..56edac650 100644 --- a/src/main/java/club/joylink/rtss/services/UserExamService.java +++ b/src/main/java/club/joylink/rtss/services/UserExamService.java @@ -324,7 +324,7 @@ public class UserExamService implements IUserExamService { .collect(Collectors.toMap(UserExam::getUserId, Function.identity())); Map 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 vos = userIds.stream().map(userId -> { UserExam userExam = userExamMap.get(userId); UserExamVO vo; diff --git a/src/main/java/club/joylink/rtss/services/org/IOrgLessonService.java b/src/main/java/club/joylink/rtss/services/org/IOrgLessonService.java index 9d7128dcf..2e64c3966 100644 --- a/src/main/java/club/joylink/rtss/services/org/IOrgLessonService.java +++ b/src/main/java/club/joylink/rtss/services/org/IOrgLessonService.java @@ -16,7 +16,9 @@ public interface IOrgLessonService { /** * 查询这些组织的课程关联关系 */ - List findEntities(List orgIds); + List findEntitiesByOrgIds(List orgIds); + + List findEntitiesByLessonIds(List lessonIds); List findEntities(Long lessonId); diff --git a/src/main/java/club/joylink/rtss/services/org/IOrgScoringRuleService.java b/src/main/java/club/joylink/rtss/services/org/IOrgScoringRuleService.java index 978bf6669..66ce51cdf 100644 --- a/src/main/java/club/joylink/rtss/services/org/IOrgScoringRuleService.java +++ b/src/main/java/club/joylink/rtss/services/org/IOrgScoringRuleService.java @@ -1,10 +1,13 @@ package club.joylink.rtss.services.org; +import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; 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.OrgScoringRuleQueryVO; import club.joylink.rtss.vo.client.org.OrgScoringRuleVO; +import org.springframework.transaction.annotation.Transactional; 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); - /** - * 使用评分规则评分 - * @return - */ - List 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获取规则详情 @@ -48,5 +45,17 @@ public interface IOrgScoringRuleService { /** * 使用评分规则进行评分 */ - List score(Integer orgId, String schoolYear, Integer term, UserVO user); + List score(Integer orgId, String schoolYear, Integer term, LoginUserInfoVO loginInfo); + + /** + * 将评价规则应用到 + */ + @Transactional + void applyOrgScoringRule(Long ruleId, List orgIds); + + /** + * 查询评价规则能应用到的组织 + * @return + */ + List queryRuleCanApplyTo(Long ruleId); } diff --git a/src/main/java/club/joylink/rtss/services/org/IOrgService.java b/src/main/java/club/joylink/rtss/services/org/IOrgService.java index f6bbf5827..3d6deb24a 100644 --- a/src/main/java/club/joylink/rtss/services/org/IOrgService.java +++ b/src/main/java/club/joylink/rtss/services/org/IOrgService.java @@ -5,10 +5,10 @@ import club.joylink.rtss.entity.Org; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; 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.DepartmentVO; import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO; +import club.joylink.rtss.vo.client.org.OrgQueryVO; import java.util.List; @@ -19,7 +19,7 @@ public interface IOrgService { Org getEntity(Integer orgId); - Org getEntity(Project project); + Org getEntity(Project project, String status); CompanyVO updateOrg(Integer id, CompanyVO companyVO, UserVO user); @@ -28,21 +28,28 @@ public interface IOrgService { */ void deleteNonTopOrg(Integer nonTopOrgId); - List findEntitiesByParentId(Integer parentId, String orderBy); + List findEntitiesByParentId(Integer parentId, String orderBy, String status); /** * 分页查询自己创建的班级 * @param self 是否仅查询自己创建的 */ - PageVO pagedQueryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self); + PageVO pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self); /** * 查询自己创建的班级 */ - List queryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self); + List queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self); /** * 获取该组织所属的顶级组织 */ - Org getTopOrgEntity(Integer orgId); + Org getTopOrgEntity(Integer orgId, String status); + + List findEntities(List orgIds, String status); + + /** + * 管理员分页查询组织 + */ + PageVO adminPagedQueryOrg(OrgQueryVO queryVO); } diff --git a/src/main/java/club/joylink/rtss/services/org/IOrgUserService.java b/src/main/java/club/joylink/rtss/services/org/IOrgUserService.java index d3b753c46..a30f2cdc0 100644 --- a/src/main/java/club/joylink/rtss/services/org/IOrgUserService.java +++ b/src/main/java/club/joylink/rtss/services/org/IOrgUserService.java @@ -23,7 +23,7 @@ public interface IOrgUserService { boolean isExistWithCompanyName(String name); - PageVO queryPageOrganizations(CompanyQueryVO queryVO); + PageVO queryPageOrganizations(OrgQueryVO queryVO); /** * 用户绑定为单位管理员 @@ -96,4 +96,6 @@ public interface IOrgUserService { void createOrgUser(Integer orgId, Long userId, BusinessConsts.OrgRole role); List findEntities(Integer orgId, BusinessConsts.OrgRole role); + + List findEntities(List orgIds, BusinessConsts.OrgRole role); } diff --git a/src/main/java/club/joylink/rtss/services/org/OrgLessonService.java b/src/main/java/club/joylink/rtss/services/org/OrgLessonService.java index 41db78917..7213d8d66 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgLessonService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgLessonService.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.stream.Collectors; @Service -public class OrgLessonService implements IOrgLessonService{ +public class OrgLessonService implements IOrgLessonService { @Autowired private OrgLessonDAO orgLessonDAO; @@ -45,14 +45,14 @@ public class OrgLessonService implements IOrgLessonService{ List orgLessons = findEntitiesByOrgId(orgId); if (CollectionUtils.isEmpty(orgLessons)) { return new ArrayList<>(); - } else{ + } else { List lessonIds = orgLessons.stream().map(OrgLesson::getLessonId).collect(Collectors.toList()); return iLessonService.queryByIds(lessonIds); } } @Override - public List findEntities(List orgIds) { + public List findEntitiesByOrgIds(List orgIds) { if (CollectionUtils.isEmpty(orgIds)) { return new ArrayList<>(); } else { @@ -62,6 +62,17 @@ public class OrgLessonService implements IOrgLessonService{ } } + @Override + public List findEntitiesByLessonIds(List lessonIds) { + if (CollectionUtils.isEmpty(lessonIds)) { + return new ArrayList<>(); + } else { + OrgLessonExample example = new OrgLessonExample(); + example.createCriteria().andLessonIdIn(lessonIds); + return orgLessonDAO.selectByExample(example); + } + } + @Override public List findEntities(Long lessonId) { OrgLessonExample example = new OrgLessonExample(); diff --git a/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java b/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java index 65e2b919f..c78f76aed 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java @@ -1,16 +1,21 @@ package club.joylink.rtss.services.org; import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.dao.OrgDAO; import club.joylink.rtss.dao.OrgScoringRuleDAO; +import club.joylink.rtss.dao.OrgScoringRuleRelDAO; import club.joylink.rtss.entity.*; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.IExamService; import club.joylink.rtss.services.ISysUserService; import club.joylink.rtss.services.IUserExamService; import club.joylink.rtss.services.IUserUsageStatsService; import club.joylink.rtss.services.user.ISysUserLoginService; +import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; 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.OrgScoringRuleQueryVO; import club.joylink.rtss.vo.client.org.OrgScoringRuleVO; @@ -23,10 +28,8 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; @Service @@ -52,12 +55,26 @@ public class OrgScoringRuleService implements IOrgScoringRuleService { @Autowired private ISysUserService iSysUserService; + @Autowired + private IExamService iExamService; + + @Autowired + private OrgScoringRuleRelDAO orgScoringRuleRelDAO; + + @Autowired + private IOrgLessonService iOrgLessonService; + + @Autowired + private OrgDAO orgDAO; + @Override - public void createScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user) { - this.check4Create(orgScoringRuleVO, user.getId()); + public void createScoringRule(OrgScoringRuleVO orgScoringRuleVO, LoginUserInfoVO loginInfo) { + Org topOrg = iOrgService.getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID); + this.check4Create(orgScoringRuleVO, topOrg.getId(), loginInfo.getUserVO().getId()); OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.convert2DB(); - rule.setCreatorId(user.getId()); + rule.setOrgId(topOrg.getId()); + rule.setCreatorId(loginInfo.getUserVO().getId()); rule.setCreateTime(LocalDateTime.now()); orgScoringRuleDAO.insert(rule); } @@ -65,46 +82,27 @@ public class OrgScoringRuleService implements IOrgScoringRuleService { @Override public void updateScoringRule(OrgScoringRuleVO orgScoringRuleVO, UserVO user) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(orgScoringRuleVO.getId(), "id不能为null"); - this.check4Update(orgScoringRuleVO, user.getId()); - OrgScoringRuleWithBLOBs entity = getEntity(orgScoringRuleVO.getId()); + this.check4Update(orgScoringRuleVO); + OrgScoringRuleWithBLOBs entity = getRuleEntity(orgScoringRuleVO.getId()); OrgScoringRuleWithBLOBs rule = orgScoringRuleVO.cover4Update(entity); rule.setUpdateId(user.getId()); rule.setUpdateTime(LocalDateTime.now()); orgScoringRuleDAO.updateByPrimaryKeyWithBLOBs(rule); } - @Override - public List score(@NonNull OrgScoringRuleVO orgScoringRuleVO, @NonNull UserVO user) { - orgScoringRuleVO.check4Use(); - List students = iOrgUserService.findEntities(orgScoringRuleVO.getOrgId(), BusinessConsts.OrgRole.Student); - List userIds = students.stream().map(OrgUser::getUserId).collect(Collectors.toList()); - Org topOrg = iOrgService.getTopOrgEntity(orgScoringRuleVO.getOrgId()); - List projects = List.of(topOrg.getProjectCode().split(",")); - int totalWeight = orgScoringRuleVO.calculateTotalWeight(); - Map usualScoreMap = new HashMap<>(); - if (orgScoringRuleVO.getUsualScoringRule() != null) { - usualScoreMap = this.score(userIds, orgScoringRuleVO.getUsualScoringRule(), totalWeight, projects); - } - Map finalScoreMap = new HashMap<>(); - if (orgScoringRuleVO.getFinalScoringRule() != null) { - finalScoreMap = this.score(userIds, orgScoringRuleVO.getFinalScoringRule(), totalWeight, projects); - } - List list = new ArrayList<>(); - List 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 public PageVO queryBasicInfo(OrgScoringRuleQueryVO queryVO, UserVO user) { + List 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.Criteria criteria = example.createCriteria().andCreatorIdEqualTo(user.getId()); - if (queryVO.getOrgId() != null) { - criteria.andOrgIdEqualTo(queryVO.getOrgId()); + if (!CollectionUtils.isEmpty(ruleIds)) { + criteria.andIdIn(ruleIds); } if (StringUtils.hasText(queryVO.getSchoolYear())) { criteria.andSchoolYearEqualTo(queryVO.getSchoolYear()); @@ -114,21 +112,45 @@ public class OrgScoringRuleService implements IOrgScoringRuleService { } PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); Page page = (Page) orgScoringRuleDAO.selectByExample(example); - List voList = page.stream().map(OrgScoringRuleVO::buildBasicInfo).collect(Collectors.toList()); - return PageVO.convert(page, voList); + if (CollectionUtils.isEmpty(page)) { + return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>()); + } else { + Map> 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 voList = page.stream().map(rule -> OrgScoringRuleVO.buildBasicInfo(rule, rule_org_map.get(rule.getId()))) + .collect(Collectors.toList()); + return PageVO.convert(page, voList); + } } @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(); example.createCriteria() - .andOrgIdEqualTo(orgId) + .andOrgIdEqualTo(topOrg.getId()) + .andCreatorIdEqualTo(loginInfo.getUserVO().getId()) .andSchoolYearEqualTo(schoolYear) - .andTermEqualTo(term) - .andCreatorIdEqualTo(user.getId()); + .andTermEqualTo(term); List rules = orgScoringRuleDAO.selectByExampleWithBLOBs(example); if (!CollectionUtils.isEmpty(rules)) { - return OrgScoringRuleVO.buildDetails(rules.get(0)); + List ruleIds = rules.stream().map(OrgScoringRule::getId).collect(Collectors.toList()); + List 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 orgIds = rels.stream().filter(orgRuleRel -> orgRuleRel.getRuleId().equals(rule.getId())) + .map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList()); + return OrgScoringRuleVO.buildDetails(rule, orgIds); + } + } } else { return null; } @@ -136,13 +158,14 @@ public class OrgScoringRuleService implements IOrgScoringRuleService { @Override public OrgScoringRuleVO getOrgScoringRuleDetails(Long ruleId) { - OrgScoringRuleWithBLOBs rule = orgScoringRuleDAO.selectByPrimaryKey(ruleId); - return OrgScoringRuleVO.buildDetails(rule); + OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId); + List orgIds = findRelEntities(ruleId).stream().map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList()); + return OrgScoringRuleVO.buildDetails(rule, orgIds); } @Override public void deleteRuleOfSelf(@NonNull Long id, @NonNull Long userId) { - OrgScoringRuleWithBLOBs rule = findEntity(id); + OrgScoringRuleWithBLOBs rule = findRuleEntity(id); if (rule != null) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertEquals(rule.getCreatorId(), userId, "非本人创建的评价规则不能删除"); @@ -151,77 +174,247 @@ public class OrgScoringRuleService implements IOrgScoringRuleService { } @Override - public List score(@NonNull Integer orgId, @NonNull String schoolYear, @NonNull Integer term, UserVO user) { - OrgScoringRuleVO ruleVO = queryOrgScoringRuleDetails(orgId, schoolYear, term, user); + public List score(@NonNull Integer orgId, @NonNull String schoolYear, @NonNull Integer term, LoginUserInfoVO loginInfo) { + OrgScoringRuleVO ruleVO = queryOrgScoringRuleDetails(orgId, schoolYear, term, loginInfo); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(ruleVO, "评价规则不存在"); - return score(ruleVO, user); + return score(ruleVO, orgId); } - private Map score(List userIds, @NonNull OrgScoringRuleVO.ScoringRule rule, int totalWeight, List projects) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(userIds); - Map scoreMap = new HashMap<>(); - for (Long userId : userIds) { - int score = 0; + @Override + public void applyOrgScoringRule(Long ruleId, List orgIds) { + //校验 + if (!CollectionUtils.isEmpty(orgIds)) { + 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 otherRules = orgScoringRuleDAO.selectByExample(ruleExample); //与操作的规则同顶级组织、同创建者、同学年、同学期的其它规则 + if (!CollectionUtils.isEmpty(otherRules)) { + List otherRuleIds = otherRules.stream() + .map(OrgScoringRule::getId).collect(Collectors.toList()); + OrgScoringRuleRelExample relExample = new OrgScoringRuleRelExample(); + relExample.createCriteria() + .andRuleIdIn(otherRuleIds) + .andOrgIdIn(orgIds); + List relList = orgScoringRuleRelDAO.selectByExample(relExample); + if (!CollectionUtils.isEmpty(relList)) { + List ruleRelOrgIds = relList.stream().map(OrgScoringRuleRel::getOrgId).collect(Collectors.toList()); + Map orgMap = iOrgService.findEntities(ruleRelOrgIds, BusinessConsts.Org.Status.VALID).stream().collect(Collectors.toMap(Org::getId, Function.identity())); + Map 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 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 queryRuleCanApplyTo(Long ruleId) { + OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId); + OrgScoringRuleVO vo = OrgScoringRuleVO.buildDetails(rule, null); + OrgScoringRuleVO.ScoringRule scoringRule = vo.getScoringRule(); + Set lessonIdSet = new HashSet<>(); + if (!CollectionUtils.isEmpty(scoringRule.getLearningTimeList())) { + scoringRule.getLearningTimeList().forEach(learningTime -> lessonIdSet.addAll(learningTime.getLessonIds())); + } + if (!CollectionUtils.isEmpty(scoringRule.getExams())) { + List examIds = scoringRule.getExams().stream().map(OrgScoringRuleVO.Exam::getExamId).collect(Collectors.toList()); + List 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 orgLessonList = iOrgLessonService.findEntitiesByLessonIds(new ArrayList<>(lessonIdSet)); + if (CollectionUtils.isEmpty(orgLessonList)) { + return new ArrayList<>(); + } else { + Map> org_lessons_map = orgLessonList.stream().collect(Collectors.groupingBy(OrgLesson::getOrgId, + Collectors.mapping(OrgLesson::getLessonId, Collectors.toSet()))); + List 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 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 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 rules = orgScoringRuleDAO.selectByExample(ruleExample); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionEmpty(rules, + "该规则应用到的班级有些已被同学年同学期的其它规则应用到"); + } + } + } + + private List 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 students; + if (clsId == null) { + students = iOrgUserService.findEntities(orgScoringRuleVO.getOrgIds(), BusinessConsts.OrgRole.Student); + } else { + students = iOrgUserService.findEntities(clsId, BusinessConsts.OrgRole.Student); + } + List userIds = students.stream().map(OrgUser::getUserId).collect(Collectors.toList()); + List users = iSysUserService.findEntity(userIds, "id"); + Org topOrg = iOrgService.getTopOrgEntity(orgScoringRuleVO.getOrgIds().get(0), BusinessConsts.Org.Status.VALID); + List 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 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 results, @NonNull OrgScoringRuleVO.ScoringRule rule, List projects) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(results); + Map examScoreMap = new HashMap<>(); //考试及其满分 + for (OrgScoringResultVO result : results) { + Long userId = result.getUserId(); //考勤分 OrgScoringRuleVO.Attendance attendance = rule.getAttendance(); if (attendance != null) { int loginDays = iSysUserLoginService.getLoginDays(userId, attendance.getStartDate(), attendance.getEndDate(), projects); - score += attendance.calculateScore(loginDays, totalWeight); + result.setAttendanceScore(attendance.calculateScore(loginDays)); } //课时分 List learningTimeList = rule.getLearningTimeList(); if (!CollectionUtils.isEmpty(learningTimeList)) { - for (OrgScoringRuleVO.LearningTime learningTime : learningTimeList) { + int score = learningTimeList.stream().mapToInt(learningTime -> { UserRankStatsVO vo = iUserUsageStatsService.statisticsLessonLearningDuration(learningTime.getLessonIds(), userId); - score += learningTime.calculateScore(vo.getDuration(), totalWeight); - } + return learningTime.calculateScore(vo.getDuration()); + }).sum(); + result.setLearningTimeScore(score); } //考试分 List exams = rule.getExams(); if (!CollectionUtils.isEmpty(exams)) { - for (OrgScoringRuleVO.Exam exam : exams) { - Integer examScore = iUserExamService.queryHeightScoreOfUserExam(userId, exam.getExamId()); - score += exam.calculateScore(examScore, totalWeight); - } + int score = exams.stream().mapToInt(exam -> { + Integer userScore = iUserExamService.queryHeightScoreOfUserExam(userId, exam.getExamId()); + 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) { - 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) { + private OrgScoringRuleWithBLOBs getRuleEntity(Long id) { OrgScoringRuleWithBLOBs entity = orgScoringRuleDAO.selectByPrimaryKey(id); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity, String.format("id[%s]的评分规则不存在", id)); return entity; } - private OrgScoringRuleWithBLOBs findEntity(Long id) { + private OrgScoringRuleWithBLOBs findRuleEntity(Long id) { return orgScoringRuleDAO.selectByPrimaryKey(id); } + + private List findBasicRuleEntities(Integer orgId, Long creatorId) { + OrgScoringRuleExample example = new OrgScoringRuleExample(); + example.createCriteria().andOrgIdEqualTo(orgId).andCreatorIdEqualTo(creatorId); + return orgScoringRuleDAO.selectByExample(example); + } + + private List findRelEntities(Integer orgId) { + OrgScoringRuleRelExample example = new OrgScoringRuleRelExample(); + example.createCriteria().andOrgIdEqualTo(orgId); + return orgScoringRuleRelDAO.selectByExample(example); + } + + private List findRelEntities(Long ruleId) { + OrgScoringRuleRelExample example = new OrgScoringRuleRelExample(); + example.createCriteria().andRuleIdEqualTo(ruleId); + return orgScoringRuleRelDAO.selectByExample(example); + } + + private List findRelEntities(List 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); + } } diff --git a/src/main/java/club/joylink/rtss/services/org/OrgService.java b/src/main/java/club/joylink/rtss/services/org/OrgService.java index 0b0cb54cc..7487eeb40 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgService.java @@ -9,10 +9,10 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; 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.DepartmentVO; 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.PageHelper; import lombok.NonNull; @@ -23,11 +23,12 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @Service -public class OrgService implements IOrgService{ +public class OrgService implements IOrgService { @Autowired private OrgDAO orgDAO; @@ -44,7 +45,7 @@ public class OrgService implements IOrgService{ @Override 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(); Long userId = loginInfo.getUserVO().getId(); iOrgUserService.confirmIsTheRoleInThisOrg(userId, topOrgId, BusinessConsts.OrgRole.Admin); @@ -60,9 +61,12 @@ public class OrgService implements IOrgService{ } @Override - public Org getEntity(Project project) { + public Org getEntity(Project project, String status) { 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 orgs = orgDAO.selectByExample(example); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, String.format("关联项目为[%s]的组织不存在", project)); return orgs.get(0); @@ -88,55 +92,98 @@ public class OrgService implements IOrgService{ @Override public void deleteNonTopOrg(Integer nonTopOrgId) { confirmIsNonTopOrg(nonTopOrgId); - orgDAO.deleteByPrimaryKey(nonTopOrgId); + Org org = new Org(); + org.setId(nonTopOrgId); + org.setStatus(BusinessConsts.Org.Status.DELETE); + orgDAO.updateByPrimaryKeySelective(org); } @Override - public List findEntitiesByParentId(Integer parentId, String orderBy) { + public List findEntitiesByParentId(Integer parentId, String orderBy, String status) { OrgExample example = new OrgExample(); if (StringUtils.hasText(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); } @Override - public PageVO pagedQueryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { - OrgExample example = buildQueryClsExample(queryVO, loginInfo, self); + public PageVO pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { + OrgExample example = buildQueryClsExample(queryVO, loginInfo.getUserVO().getId(), loginInfo.getProject(), self); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); Page page = (Page) orgDAO.selectByExample(example); List list = page.getResult().stream().map(entity -> { - DepartmentVO vo = new DepartmentVO(entity); - vo.setNumberOfPeople(iOrgUserService.getQuantities(vo.getId(), BusinessConsts.OrgRole.Student)); - return vo; + int numberOfPeople = iOrgUserService.getQuantities(entity.getId(), BusinessConsts.OrgRole.Student); + return new DepartmentVO(entity, numberOfPeople); }).collect(Collectors.toList()); return PageVO.convert(page, list); } @Override - public List queryCls(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { - OrgExample example = buildQueryClsExample(queryVO, loginInfo, self);; + public List queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { + OrgExample example = buildQueryClsExample(queryVO, loginInfo.getUserVO().getId(), loginInfo.getProject(), self); List clsList = orgDAO.selectByExample(example); return clsList.stream().map(DepartmentVO::new).collect(Collectors.toList()); } @Override - public Org getTopOrgEntity(Integer orgId) { + public Org getTopOrgEntity(Integer orgId, String status) { Org entity = getEntity(orgId); return getEntity(entity.getRootId()); } - private OrgExample buildQueryClsExample(CompanyQueryVO queryVO, LoginUserInfoVO loginInfo, boolean self) { - Org topOrg = getEntity(loginInfo.getProject()); - OrgExample example = new OrgExample(); - OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(topOrg.getId()); - if (self) { - criteria.andCreatorIdEqualTo(loginInfo.getUserVO().getId()); + @Override + public List findEntities(List orgIds, String status) { + if (CollectionUtils.isEmpty(orgIds)) { + return new ArrayList<>(); + } else { + 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 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())); } + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + Page page = (Page) orgDAO.selectByExample(example); + List 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; } @@ -147,7 +194,7 @@ public class OrgService implements IOrgService{ //检查顶级组织 confirmIsTopOrg(rootId); //检查同级同名组织 - List entities = findEntitiesByParentId(parentId, null); + List entities = findEntitiesByParentId(parentId, null, BusinessConsts.Org.Status.VALID); if (!CollectionUtils.isEmpty(entities)) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)), String.format("上级为[%s]的同名组织已存在", parentId)); @@ -185,12 +232,15 @@ public class OrgService implements IOrgService{ String.format("组织[%s]是顶级组织", id)); } - private List findEntitiesByRootId(Integer rootId, String orderBy) { + private List findEntitiesByRootId(Integer rootId, String orderBy, String status) { OrgExample example = new OrgExample(); if (StringUtils.hasText(orderBy)) { example.setOrderByClause(orderBy); } - example.createCriteria().andRootIdEqualTo(rootId); + OrgExample.Criteria criteria = example.createCriteria().andRootIdEqualTo(rootId); + if (StringUtils.hasText(status)) { + criteria.andStatusEqualTo(status); + } List orgs = orgDAO.selectByExample(example); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, String.format("没有顶级组织id为[%s]的组织", rootId)); diff --git a/src/main/java/club/joylink/rtss/services/org/OrgUserService.java b/src/main/java/club/joylink/rtss/services/org/OrgUserService.java index 4a6edc94a..96c230b0b 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgUserService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgUserService.java @@ -66,7 +66,7 @@ public class OrgUserService implements IOrgUserService { @Override - public PageVO queryPageOrganizations(CompanyQueryVO queryVO) { + public PageVO queryPageOrganizations(OrgQueryVO queryVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); OrgExample example = new OrgExample(); OrgExample.Criteria criteria = example.createCriteria(); @@ -569,6 +569,19 @@ public class OrgUserService implements IOrgUserService { return orgUserDAO.selectByExample(example); } + @Override + public List findEntities(List 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() { OrgExample e = new OrgExample(); e.setLimit(1); diff --git a/src/main/java/club/joylink/rtss/vo/client/org/CompanyQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/org/OrgQueryVO.java similarity index 58% rename from src/main/java/club/joylink/rtss/vo/client/org/CompanyQueryVO.java rename to src/main/java/club/joylink/rtss/vo/client/org/OrgQueryVO.java index 1ae6a964c..bf901515c 100644 --- a/src/main/java/club/joylink/rtss/vo/client/org/CompanyQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/org/OrgQueryVO.java @@ -2,14 +2,15 @@ package club.joylink.rtss.vo.client.org; import club.joylink.rtss.vo.client.PageQueryVO; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter -public class CompanyQueryVO extends PageQueryVO { - +@NoArgsConstructor +public class OrgQueryVO extends PageQueryVO { private String name; - + private Integer topOrgId; } diff --git a/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringResultVO.java b/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringResultVO.java index 6d9dc68d9..10d917df3 100644 --- a/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringResultVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringResultVO.java @@ -17,16 +17,24 @@ public class OrgScoringResultVO { 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.account = account; this.username = username; - this.usualScore = usualScore; - this.finalScore = finalScore; + this.attendanceScore = attendanceScore; + this.learningTimeScore = learningTimeScore; + this.examScore = examScore; } + public OrgScoringResultVO(Long userId, String account, String username) { + this.userId = userId; + this.account = account; + this.username = username; + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringRuleVO.java b/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringRuleVO.java index dc100f357..3075fdab4 100644 --- a/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringRuleVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/org/OrgScoringRuleVO.java @@ -14,8 +14,10 @@ import org.springframework.util.StringUtils; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; /** * 评分规则 @@ -27,10 +29,12 @@ public class OrgScoringRuleVO { @JsonSerialize(using = ToStringSerializer.class) private Long id; + private String name; + /** * 组织(班级)id */ - private Integer orgId; + private List orgIds; /** * 学年 @@ -42,15 +46,15 @@ public class OrgScoringRuleVO { */ private Integer term; - /** - * 平时分评价规则 - */ - private ScoringRule usualScoringRule; +// /** +// * 平时分评价规则 +// */ +// private ScoringRule usualScoringRule; /** - * 期末分评价规则 + * 评价规则 */ - private ScoringRule finalScoringRule; + private ScoringRule scoringRule; @JsonSerialize(using = ToStringSerializer.class) private Long creatorId; @@ -65,10 +69,11 @@ public class OrgScoringRuleVO { /** * 构建基础信息 */ - public static OrgScoringRuleVO buildBasicInfo(OrgScoringRule rule) { + public static OrgScoringRuleVO buildBasicInfo(OrgScoringRule rule, List orgIds) { OrgScoringRuleVO vo = new OrgScoringRuleVO(); vo.setId(rule.getId()); - vo.setOrgId(rule.getOrgId()); + vo.setName(rule.getName()); + vo.setOrgIds(Objects.requireNonNullElseGet(orgIds, ArrayList::new)); vo.setSchoolYear(rule.getSchoolYear()); vo.setTerm(rule.getTerm()); vo.setCreatorId(rule.getCreatorId()); @@ -81,13 +86,10 @@ public class OrgScoringRuleVO { /** * 构建详细信息 */ - public static OrgScoringRuleVO buildDetails(OrgScoringRuleWithBLOBs rule) { - OrgScoringRuleVO vo = buildBasicInfo(rule); - if (StringUtils.hasText(rule.getUsualScoringRule())) { - vo.setUsualScoringRule(JsonUtils.read(rule.getUsualScoringRule(), ScoringRule.class)); - } + public static OrgScoringRuleVO buildDetails(OrgScoringRuleWithBLOBs rule, List orgIds) { + OrgScoringRuleVO vo = buildBasicInfo(rule, orgIds); if (StringUtils.hasText(rule.getFinalScoringRule())) { - vo.setFinalScoringRule(JsonUtils.read(rule.getFinalScoringRule(), ScoringRule.class)); + vo.setScoringRule(JsonUtils.read(rule.getFinalScoringRule(), ScoringRule.class)); } return vo; } @@ -96,7 +98,6 @@ public class OrgScoringRuleVO { * 检查以确保评分规则能够保存 */ public void check4Save() { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(orgId, "班级不能不选"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(schoolYear, "学年不能不选"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(term, "学期不能不选"); } @@ -106,45 +107,31 @@ public class OrgScoringRuleVO { */ public void check4Use() { check4Save(); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(usualScoringRule != null || finalScoringRule != null, - "平时分和期末分评价规则至少有一个"); - if (usualScoringRule != null) { - usualScoringRule.check4Use(true); - } - if (finalScoringRule != null) { - finalScoringRule.check4Use(false); - } + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(scoringRule, "评价规则未填写"); + scoringRule.check4Use(); } public OrgScoringRuleWithBLOBs convert2DB() { OrgScoringRuleWithBLOBs rule = new OrgScoringRuleWithBLOBs(); rule.setId(id); - rule.setOrgId(orgId); + rule.setName(name); rule.setSchoolYear(schoolYear); rule.setTerm(term); - rule.setUsualScoringRule(JsonUtils.writeValueAsString(usualScoringRule)); - rule.setFinalScoringRule(JsonUtils.writeValueAsString(finalScoringRule)); + if (scoringRule != null) { + rule.setFinalScoringRule(JsonUtils.writeValueAsString(scoringRule)); + } return rule; } public OrgScoringRuleWithBLOBs cover4Update(OrgScoringRuleWithBLOBs entity) { - entity.setOrgId(orgId); entity.setSchoolYear(schoolYear); entity.setTerm(term); - entity.setUsualScoringRule(JsonUtils.writeValueAsString(usualScoringRule)); - entity.setFinalScoringRule(JsonUtils.writeValueAsString(finalScoringRule)); + entity.setFinalScoringRule(JsonUtils.writeValueAsString(scoringRule)); return entity; } - public int calculateTotalWeight() { - int totalWeight = 0; - if (usualScoringRule != null) { - totalWeight += usualScoringRule.calculateTotalWeight(); - } - if (finalScoringRule != null) { - totalWeight += usualScoringRule.calculateTotalWeight(); - } - return totalWeight; + public int calculateTotalMarks() { + return scoringRule.calculateTotalMarks(); } /** @@ -172,40 +159,33 @@ public class OrgScoringRuleVO { /** * 获取总权重 */ - public int calculateTotalWeight() { + public int calculateTotalMarks() { int weight = 0; if (this.attendance != null) { - weight += this.attendance.getWeight(); + weight += this.attendance.getFullMarks(); } if (!CollectionUtils.isEmpty(learningTimeList)) { for (LearningTime learningTime : learningTimeList) { - weight += learningTime.getWeight(); + weight += learningTime.getFullMarks(); } } if (!CollectionUtils.isEmpty(exams)) { for (Exam exam : exams) { - weight += exam.getWeight(); + weight += exam.getFullMarks(); } } return weight; } - public void check4Use(boolean usual) { - if (usual) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(attendance != null - || !CollectionUtils.isEmpty(learningTimeList) || !CollectionUtils.isEmpty(exams), - "平时成绩评价细则不能为空"); - } else { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(exams, - "期末成绩评价细则不能为空"); + public void check4Use() { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(attendance != null + || !CollectionUtils.isEmpty(learningTimeList) || !CollectionUtils.isEmpty(exams), + "评价规则的细则未填写"); + if (attendance != null) { + attendance.check4Use(); } - if (usual) { - if (attendance != null) { - attendance.check4Use(); - } - if (!CollectionUtils.isEmpty(learningTimeList)) { - learningTimeList.forEach(LearningTime::check4Use); - } + if (!CollectionUtils.isEmpty(learningTimeList)) { + learningTimeList.forEach(LearningTime::check4Use); } if (!CollectionUtils.isEmpty(exams)) { exams.forEach(Exam::check4Use); @@ -243,23 +223,23 @@ public class OrgScoringRuleVO { private Map scoringRules; /** - * 权重(百分数) + * 满分 */ - private Integer weight; + private Integer fullMarks; /** * 根据登录天数计算得分 */ - public int calculateScore(int loginDays, int totalWeight) { - double score = Math.min((double) loginDays / days4FullMarks, 1) * 100; - return (int) (score * weight / totalWeight); + public int calculateScore(int loginDays) { + double percent = Math.min((double) loginDays / days4FullMarks, 1); + return (int) (percent * fullMarks); } public void check4Use() { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(startDate, "考勤评分的开始时间不能为空"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(endDate, "考勤评分的截止时间不能为空"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(days4FullMarks, "满分的考勤次数不能为空"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(weight, "考勤评分的权重不能不填"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(startDate, "考勤评价的开始时间未填写"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(endDate, "考勤评价的截止时间未填写"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(days4FullMarks, "满分的考勤次数未填写"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(fullMarks, "考勤评价的满分未填写"); } } @@ -286,20 +266,20 @@ public class OrgScoringRuleVO { */ private Map scoringRules; - private Integer weight; + private Integer fullMarks; - public int calculateScore(Long durationInSecond, int totalWeight) { + public int calculateScore(Long durationInSecond) { if (durationInSecond == null) { return 0; } - double score = Math.min(1, durationInSecond / (duration4FullMarks * 60d)) * 100; - return (int) (score * weight / totalWeight); + double percent = Math.min(1, durationInSecond / (duration4FullMarks * 60d)); + return (int) (percent * fullMarks); } public void check4Use() { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(lessonIds, "学习时长评分所选课程不能为空"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(duration4FullMarks, "学习时长评分的满分学习时长不能为空"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(weight, "学习时长评分的权重不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(lessonIds, "学习时长评价课程未选择"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(duration4FullMarks, "学习时长评价的满分学习时长未填写"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(fullMarks, "学习时长评价的总分未填写"); } } @@ -310,18 +290,24 @@ public class OrgScoringRuleVO { @JsonSerialize(using = ToStringSerializer.class) 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 (int) (examScore * (double) weight / totalWeight); + double percent = (double) userScore / examFullMarks; + return (int) (percent * fullMarks); } public void check4Use() { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(examId, "考试评份所选的考试不能为空"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(weight, "考试评分的权重不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(examId, "考试评价的考试未选择"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(fullMarks, "考试评价的满分未填写"); } } } diff --git a/src/main/resources/mybatis/mapper/OrgDAO.xml b/src/main/resources/mybatis/mapper/OrgDAO.xml index 83ad335d1..62394c3da 100644 --- a/src/main/resources/mybatis/mapper/OrgDAO.xml +++ b/src/main/resources/mybatis/mapper/OrgDAO.xml @@ -12,6 +12,7 @@ + @@ -72,8 +73,8 @@ - id, `name`, parent_id, root_id, project_code, code, creator_id, create_time, update_id, - update_time + id, `name`, parent_id, root_id, project_code, code, creator_id, create_time, update_id, + update_time, `status` @@ -223,6 +230,9 @@ update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + `status` = #{record.status,jdbcType=VARCHAR}, + @@ -239,7 +249,8 @@ creator_id = #{record.creatorId,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=TIMESTAMP}, update_id = #{record.updateId,jdbcType=BIGINT}, - update_time = #{record.updateTime,jdbcType=TIMESTAMP} + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + `status` = #{record.status,jdbcType=VARCHAR} @@ -274,6 +285,9 @@ update_time = #{updateTime,jdbcType=TIMESTAMP}, + + `status` = #{status,jdbcType=VARCHAR}, + where id = #{id,jdbcType=INTEGER} @@ -287,7 +301,8 @@ creator_id = #{creatorId,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_id = #{updateId,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=TIMESTAMP} + update_time = #{updateTime,jdbcType=TIMESTAMP}, + `status` = #{status,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} - + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/OrgScoringRuleDAO.xml b/src/main/resources/mybatis/mapper/OrgScoringRuleDAO.xml index b4374a0b1..c64a48ec9 100644 --- a/src/main/resources/mybatis/mapper/OrgScoringRuleDAO.xml +++ b/src/main/resources/mybatis/mapper/OrgScoringRuleDAO.xml @@ -3,6 +3,7 @@ + @@ -74,7 +75,7 @@ - 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 usual_scoring_rule, final_scoring_rule @@ -144,18 +145,21 @@ - insert into org_scoring_rule (org_id, school_year, term, - creator_id, create_time, update_id, - update_time, usual_scoring_rule, final_scoring_rule - ) - values (#{orgId,jdbcType=INTEGER}, #{schoolYear,jdbcType=VARCHAR}, #{term,jdbcType=INTEGER}, - #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, - #{updateTime,jdbcType=TIMESTAMP}, #{usualScoringRule,jdbcType=LONGVARCHAR}, #{finalScoringRule,jdbcType=LONGVARCHAR} - ) + insert into org_scoring_rule (`name`, org_id, school_year, + term, creator_id, create_time, + update_id, update_time, usual_scoring_rule, + final_scoring_rule) + values (#{name,jdbcType=VARCHAR}, #{orgId,jdbcType=INTEGER}, #{schoolYear,jdbcType=VARCHAR}, + #{term,jdbcType=INTEGER}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, + #{updateId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{usualScoringRule,jdbcType=LONGVARCHAR}, + #{finalScoringRule,jdbcType=LONGVARCHAR}) insert into org_scoring_rule + + `name`, + org_id, @@ -185,6 +189,9 @@ + + #{name,jdbcType=VARCHAR}, + #{orgId,jdbcType=INTEGER}, @@ -226,6 +233,9 @@ id = #{record.id,jdbcType=BIGINT}, + + `name` = #{record.name,jdbcType=VARCHAR}, + org_id = #{record.orgId,jdbcType=INTEGER}, @@ -261,6 +271,7 @@ update org_scoring_rule set id = #{record.id,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, org_id = #{record.orgId,jdbcType=INTEGER}, school_year = #{record.schoolYear,jdbcType=VARCHAR}, term = #{record.term,jdbcType=INTEGER}, @@ -277,6 +288,7 @@ update org_scoring_rule set id = #{record.id,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, org_id = #{record.orgId,jdbcType=INTEGER}, school_year = #{record.schoolYear,jdbcType=VARCHAR}, term = #{record.term,jdbcType=INTEGER}, @@ -291,6 +303,9 @@ update org_scoring_rule + + `name` = #{name,jdbcType=VARCHAR}, + org_id = #{orgId,jdbcType=INTEGER}, @@ -323,7 +338,8 @@ 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}, term = #{term,jdbcType=INTEGER}, creator_id = #{creatorId,jdbcType=BIGINT}, @@ -336,7 +352,8 @@ 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}, term = #{term,jdbcType=INTEGER}, creator_id = #{creatorId,jdbcType=BIGINT}, diff --git a/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml b/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml new file mode 100644 index 000000000..455a89376 --- /dev/null +++ b/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + org_id, rule_id + + + + delete from org_scoring_rule_rel + + + + + + insert into org_scoring_rule_rel (org_id, rule_id) + values (#{orgId,jdbcType=INTEGER}, #{ruleId,jdbcType=BIGINT}) + + + insert into org_scoring_rule_rel + + + org_id, + + + rule_id, + + + + + #{orgId,jdbcType=INTEGER}, + + + #{ruleId,jdbcType=BIGINT}, + + + + + + update org_scoring_rule_rel + + + org_id = #{record.orgId,jdbcType=INTEGER}, + + + rule_id = #{record.ruleId,jdbcType=BIGINT}, + + + + + + + + update org_scoring_rule_rel + set org_id = #{record.orgId,jdbcType=INTEGER}, + rule_id = #{record.ruleId,jdbcType=BIGINT} + + + + + + + insert into org_scoring_rule_rel (org_id, rule_id) + values + + (#{rel.orgId}, #{rel.ruleId}) + + + From e1dae1fa0256bf831ad3934be8e203545cf473ca Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 23 Mar 2021 16:52:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=BA=BF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BF=85=E7=BB=8F=E5=8C=BA=E6=AE=B5=EF=BC=88=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=8F=AA=E6=98=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/build/InterlockBuilder2.java | 3 ++- .../client/map/newmap/MapDestinationCodeDefinitionVO.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 55cce7703..aa6ad165f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -550,6 +550,7 @@ public class InterlockBuilder2 { Station rightStation = null; Boolean leftFrontTurnBack = null; Boolean rightFrontTurnBack = null; + Route route = null; List
runPath = null; List routes = null; @@ -677,7 +678,7 @@ public class InterlockBuilder2 { break; } 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); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java index f58fd91cc..bb0a1587a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java @@ -65,6 +65,11 @@ public class MapDestinationCodeDefinitionVO { */ private Boolean stationBFrontTurnBack; + /** + * 必选进路 + */ + private String necessaryRouteCode; + /** * 目前仅用来生成目的地码数据 */ @@ -95,6 +100,9 @@ public class MapDestinationCodeDefinitionVO { if (definition.getRightFrontTurnBack() != null) { vo.stationBFrontTurnBack = definition.getRightFrontTurnBack(); } + if (definition.getNecessaryRoute() != null) { + vo.necessaryRouteCode = definition.getNecessaryRoute().getCode(); + } return vo; } From 2eb8cae79a8aaf6b64c7b1238629f1be5b5176aa Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 23 Mar 2021 16:52:41 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=BA=BF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BF=85=E7=BB=8F=E8=BF=9B=E8=B7=AF=EF=BC=88=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=8F=AA=E6=98=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/build/InterlockBuilder2.java | 3 ++- .../client/map/newmap/MapDestinationCodeDefinitionVO.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 55cce7703..aa6ad165f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -550,6 +550,7 @@ public class InterlockBuilder2 { Station rightStation = null; Boolean leftFrontTurnBack = null; Boolean rightFrontTurnBack = null; + Route route = null; List
runPath = null; List routes = null; @@ -677,7 +678,7 @@ public class InterlockBuilder2 { break; } 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); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java index f58fd91cc..bb0a1587a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java @@ -65,6 +65,11 @@ public class MapDestinationCodeDefinitionVO { */ private Boolean stationBFrontTurnBack; + /** + * 必选进路 + */ + private String necessaryRouteCode; + /** * 目前仅用来生成目的地码数据 */ @@ -95,6 +100,9 @@ public class MapDestinationCodeDefinitionVO { if (definition.getRightFrontTurnBack() != null) { vo.stationBFrontTurnBack = definition.getRightFrontTurnBack(); } + if (definition.getNecessaryRoute() != null) { + vo.necessaryRouteCode = definition.getNecessaryRoute().getCode(); + } return vo; }