Ver Fonte

学习中心、课程权限

xiatian há 3 anos atrás
pai
commit
cb837b1c2b
19 ficheiros alterados com 498 adições e 190 exclusões
  1. 35 15
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamAuditController.java
  2. 20 11
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamRecordController.java
  3. 16 16
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamScoreController.java
  4. 68 23
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamStudentController.java
  5. 33 0
      examcloud-core-oe-admin-base/src/main/java/cn/com/qmth/examcloud/core/oe/admin/base/utils/RoleUtil.java
  6. 4 8
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamAuditService.java
  7. 8 7
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamRecordService.java
  8. 4 3
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamScoreService.java
  9. 11 7
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java
  10. 2 0
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExportTaskService.java
  11. 33 0
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/UserDataRules.java
  12. 84 19
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/AsyncExportServiceImpl.java
  13. 16 5
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamAuditServiceImpl.java
  14. 0 4
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordForMarkingServiceImpl.java
  15. 34 18
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordServiceImpl.java
  16. 0 4
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamScoreQueueServiceImpl.java
  17. 33 17
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamScoreServiceImpl.java
  18. 90 33
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java
  19. 7 0
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExportTaskServiceImpl.java

+ 35 - 15
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamAuditController.java

@@ -7,6 +7,23 @@
 
 package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.JsonMapper;
@@ -21,7 +38,12 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.enums.AuditStatus;
 import cn.com.qmth.examcloud.core.oe.admin.dao.enums.SelectType;
 import cn.com.qmth.examcloud.core.oe.admin.service.AsyncExportService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamAuditService;
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.*;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditEntityConvert;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditExcel;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditQuery;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.RedoAuditInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.util.AsyncExportConcurrentUtil;
 import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
@@ -29,19 +51,10 @@ import cn.com.qmth.examcloud.support.enums.ExamProperties;
 import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+import cn.com.qmth.examcloud.web.security.DataRule;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.web.support.Naked;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
 
 /**
  * 考试记录审核相关接口
@@ -66,12 +79,15 @@ public class ExamAuditController extends ControllerSupport {
     @Autowired
     private AsyncExportService asyncExportService;
 
+    
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/list")
     @ApiOperation(value = "查询“监考已审”列表(分页)")
     public Page<ExamAuditInfo> getExamAuditList(@RequestBody ExamAuditQuery query) {
         User user = getAccessUser();
         query.setRootOrgId(user.getRootOrgId());
-        Page<ExamAuditInfo> examAuditList = examAuditService.getExamAuditList(query);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamAuditInfo> examAuditList = examAuditService.getExamAuditList(uds,query);
 
         examAuditList.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(user.getRootOrgId(), p.getIdentityNumber()));
@@ -79,6 +95,7 @@ public class ExamAuditController extends ControllerSupport {
         return examAuditList;
     }
 
+
     @GetMapping("export/async")
     @ApiOperation(value = "导出“监考已审”(异步)")
     public void exportExamAuditList(@RequestParam String query) {
@@ -88,13 +105,15 @@ public class ExamAuditController extends ControllerSupport {
         ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(), "监考已审-导出", "导出条件:" + query));
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/discipline/list")
     @ApiOperation(value = "查询“违纪名单”列表(分页)")
     public Page<ExamAuditInfo> getExamAuditUnPassList(@RequestBody ExamAuditQuery query) {
         query.setStatus(AuditStatus.UN_PASS.name());
         User user = getAccessUser();
         query.setRootOrgId(user.getRootOrgId());
-        Page<ExamAuditInfo> examAuditList = examAuditService.getExamAuditList(query);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamAuditInfo> examAuditList = examAuditService.getExamAuditList(uds,query);
 
         examAuditList.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(user.getRootOrgId(), p.getIdentityNumber()));
@@ -102,7 +121,7 @@ public class ExamAuditController extends ControllerSupport {
         return examAuditList;
     }
 
-    @Naked
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @GetMapping("/discipline/list/export")
     @ApiOperation(value = "导出“违纪名单”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
     public void exportExamAuditUnPassList(@RequestParam String query, HttpServletResponse response) throws Exception {
@@ -112,7 +131,8 @@ public class ExamAuditController extends ControllerSupport {
 
         newQuery.setStatus(AuditStatus.UN_PASS.name());
         newQuery.setSelectType(SelectType.EXPORT);
-        Page<ExamAuditInfo> page = examAuditService.getExamAuditList(newQuery);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamAuditInfo> page = examAuditService.getExamAuditList(uds,newQuery);
         List<ExamAuditExcel> list = ExamAuditEntityConvert.ofExcel(page);
         ExportUtils.exportEXCEL("违纪名单列表", ExamAuditExcel.class, list, response);
     }

+ 20 - 11
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamRecordController.java

@@ -7,6 +7,7 @@
 
 package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
@@ -19,6 +20,7 @@ import cn.com.qmth.examcloud.core.oe.admin.service.AsyncExportService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamCaptureService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamProcessRecordService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordFileAnswerInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordQuery;
@@ -28,8 +30,8 @@ import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
 import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
+import cn.com.qmth.examcloud.web.security.DataRule;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.web.support.Naked;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -74,11 +76,12 @@ public class ExamRecordController extends ControllerSupport {
     
     
 
-
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/waiting/audit/list")
     @ApiOperation(value = "查询“监考待审”列表(分页)")
     public Page<ExamRecordInfo> getExamRecordWaitingAuditList(@RequestBody ExamRecordQuery query) {
-        Page<ExamRecordInfo> examRecordWaitingAuditList = examRecordService.getExamRecordWaitingAuditList(query);
+    	UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamRecordInfo> examRecordWaitingAuditList = examRecordService.getExamRecordWaitingAuditList(uds,query);
         examRecordWaitingAuditList.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(p.getRootOrgId(), p.getIdentityNumber()));
         });
@@ -97,23 +100,29 @@ public class ExamRecordController extends ControllerSupport {
         return examRecordWaitingAuditList;
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/waiting/audit/next")
     @ApiOperation(value = "查询“监考待审”下一条记录")
     public Long getExamRecordWaitingAuditNextId(@RequestBody ExamRecordQuery query,
                                                 @RequestParam Long examRecordDataId, String next) {
-        return examRecordService.getExamRecordWaitingAuditNextId(query, examRecordDataId, next);
+    	UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        return examRecordService.getExamRecordWaitingAuditNextId(uds,query, examRecordDataId, next);
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/detail/check")
     @ApiOperation(value = "查询“考试明细” 是否存在待审数据")
     public Long existsWarnExamRecordDetail(@RequestBody ExamRecordQuery query) {
-        return examRecordService.existsWarnExamRecordDetail(query);
+    	UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        return examRecordService.existsWarnExamRecordDetail(uds,query);
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/detail/list")
     @ApiOperation(value = "查询“考试明细”列表(分页)")
     public Page<ExamRecordInfo> getExamRecordDetailList(@RequestBody ExamRecordQuery query) {
-        Page<ExamRecordInfo> examRecordInfoPage = examRecordService.getExamRecordDetailListForPage(query);
+    	UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamRecordInfo> examRecordInfoPage = examRecordService.getExamRecordDetailListForPage(uds,query);
         List<ExamRecordInfo> examRecordInfoList = examRecordInfoPage.getContent();
         if (examRecordInfoList != null && examRecordInfoList.size() > 0) {
             String examType = examRecordInfoList.get(0).getExamType();
@@ -157,10 +166,10 @@ public class ExamRecordController extends ControllerSupport {
         return resultList;
     }
 
-    @Naked
-    @GetMapping("/detail/list/export")
-    @ApiOperation(value = "导出“考试明细”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
-    public void exportExamRecordDetailList(@RequestParam String query, HttpServletResponse response) throws Exception {
+//    @Naked
+//    @GetMapping("/detail/list/export")
+//    @ApiOperation(value = "导出“考试明细”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
+//    public void exportExamRecordDetailList(@RequestParam String query, HttpServletResponse response) throws Exception {
 //        ExamRecordQuery newQuery = new JsonMapper().parseJson(query, ExamRecordQuery.class);
 //        Check.isNull(newQuery, "请求参数不能为空!");
 //        Check.isNull(newQuery.getExamId(), "请先选择考试批次!");
@@ -177,7 +186,7 @@ public class ExamRecordController extends ControllerSupport {
 //        }
 //
 //        ExportUtils.exportEXCEL("考试明细列表", ExamRecordInfo.class, examRecordInfoList, response);
-    }
+//    }
 
     @GetMapping("/detail/list/export/async")
     @ApiOperation(value = "导出“考试明细”列表(异步)", notes = "参数示例:query={\"rootOrgId\":0,\"examId\":1}")

+ 16 - 16
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamScoreController.java

@@ -1,11 +1,10 @@
 package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
-import cn.com.qmth.examcloud.commons.util.JsonMapper;
-import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
-import cn.com.qmth.examcloud.core.oe.admin.base.utils.excel.ExportUtils;
 import cn.com.qmth.examcloud.core.oe.admin.service.AsyncExportService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreQuery;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ObjectiveScoreInfo;
@@ -13,15 +12,14 @@ import cn.com.qmth.examcloud.core.oe.admin.service.util.AsyncExportConcurrentUti
 import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
+import cn.com.qmth.examcloud.web.security.DataRule;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.web.support.Naked;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -41,10 +39,12 @@ public class ExamScoreController extends ControllerSupport {
     @Autowired
     private ExamScoreService examScoreService;
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/statistic/list")
     @ApiOperation(value = "查询“成绩统计”列表(分页)")
     public Page<ExamScoreInfo> getExamAuditList(@RequestBody ExamScoreQuery query) {
-        Page<ExamScoreInfo> examScoreList = examScoreService.getExamScoreList(query);
+    	UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamScoreInfo> examScoreList = examScoreService.getExamScoreList(uds,query);
 
         examScoreList.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(getRootOrgId(), p.getIdentityNumber()));
@@ -52,16 +52,16 @@ public class ExamScoreController extends ControllerSupport {
         return examScoreList;
     }
 
-    @Naked
-    @GetMapping("/statistic/list/export")
-    @ApiOperation(value = "导出“成绩统计”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
-    public void exportExamRecordDetailList(@RequestParam String query, HttpServletResponse response) throws Exception {
-        ExamScoreQuery newQuery = new JsonMapper().parseJson(query, ExamScoreQuery.class);
-        Check.isNull(newQuery, "请求参数不能为空!");
-        Check.isNull(newQuery.getExamId(), "请先选择考试批次!");
-        List<ExamScoreInfo> examScoreList = examScoreService.exportExamScoreList(newQuery);
-        ExportUtils.exportEXCEL("成绩统计列表", ExamScoreInfo.class, examScoreList, response);
-    }
+//    @Naked
+//    @GetMapping("/statistic/list/export")
+//    @ApiOperation(value = "导出“成绩统计”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
+//    public void exportExamRecordDetailList(@RequestParam String query, HttpServletResponse response) throws Exception {
+//        ExamScoreQuery newQuery = new JsonMapper().parseJson(query, ExamScoreQuery.class);
+//        Check.isNull(newQuery, "请求参数不能为空!");
+//        Check.isNull(newQuery.getExamId(), "请先选择考试批次!");
+//        List<ExamScoreInfo> examScoreList = examScoreService.exportExamScoreList(newQuery);
+//        ExportUtils.exportEXCEL("成绩统计列表", ExamScoreInfo.class, examScoreList, response);
+//    }
 
     @GetMapping("/statistic/list/export/async")
     @ApiOperation(value = "导出“成绩统计”列表(异步)",

+ 68 - 23
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamStudentController.java

@@ -7,7 +7,28 @@
 
 package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
 import cn.com.qmth.examcloud.commons.util.JsonMapper;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
@@ -16,25 +37,27 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.IllegallyTypeRepo;
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.IllegallyTypeEntity;
 import cn.com.qmth.examcloud.core.oe.admin.service.AsyncExportService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.*;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.CourseCompleteProgressExcel;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.CourseProgressInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentEntityConvert;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentExcel;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentFinishedStatistic;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentOrgStatistic;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentQuery;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentUnFinishedExcel;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.OrgCompleteProgressExcel;
 import cn.com.qmth.examcloud.core.oe.admin.service.util.AsyncExportConcurrentUtil;
 import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
 import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
+import cn.com.qmth.examcloud.web.security.DataRule;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.web.support.Naked;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * 考生信息接口
@@ -83,12 +106,14 @@ public class ExamStudentController extends ControllerSupport {
         timer.schedule(new CleanCourseBeanCacheTask(), delay, period);
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/examScheduling/list")
     @ApiOperation(value = "查询“考试进度详情”列表(分页)")
     public Page<ExamStudentInfo> getExamScheduling(@RequestBody ExamStudentQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "考试批次不能为空!");
-        Page<ExamStudentInfo> examStudentListPage = examStudentService.getExamStudentListPage(query);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamStudentInfo> examStudentListPage = examStudentService.getExamStudentListPage(uds,query);
 
         examStudentListPage.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(p.getRootOrgId(), p.getIdentityNumber()));
@@ -96,13 +121,15 @@ public class ExamStudentController extends ControllerSupport {
         return examStudentListPage;
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @GetMapping("/examScheduling/list/export")
     @ApiOperation(value = "导出“考试进度详情”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
     public void exportExamStudentList(@RequestParam String query, HttpServletResponse response) throws Exception {
         ExamStudentQuery newQuery = new JsonMapper().parseJson(query, ExamStudentQuery.class);
         Check.isNull(newQuery, "请求参数不能为空!");
         Check.isNull(newQuery.getExamId(), "请先选择考试批次!");
-        List<ExamStudentInfo> examStudentInfoList = examStudentService.getExamStudentInfoList(newQuery);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        List<ExamStudentInfo> examStudentInfoList = examStudentService.getExamStudentInfoList(uds,newQuery);
         List<ExamStudentExcel> list = ExamStudentEntityConvert.ofExcel(examStudentInfoList);
         ExportUtils.exportEXCEL("考试详情列表", ExamStudentExcel.class, list, response);
         //        ExcelExportUtil.exportExcel("考试详情列表", ExamStudentExcel.class, list, response);
@@ -117,38 +144,43 @@ public class ExamStudentController extends ControllerSupport {
         ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(), "考试进度详情-导出", "导出条件:" + query));
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/unfinished/list")
     @ApiOperation(value = "查询“缺考登记”列表(分页)")
     public Page<ExamStudentInfo> getExamStudentUnFinishedList(@RequestBody ExamStudentQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "考试批次不能为空!");
         query.setFinished(0);
-        Page<ExamStudentInfo> examStudentListPage = examStudentService.getExamStudentListPage(query);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamStudentInfo> examStudentListPage = examStudentService.getExamStudentListPage(uds,query);
         examStudentListPage.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(p.getRootOrgId(), p.getIdentityNumber()));
         });
         return examStudentListPage;
     }
 
-    @Naked
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @GetMapping("/unfinished/list/export")
     @ApiOperation(value = "导出“缺考登记”列表(Excel)", notes = "参数示例:query={\"pageNo\":1,\"pageSize\":10,\"examId\":123, ...}")
     public void exportExamStudentUnFinishedList(@RequestParam String query, HttpServletResponse response) throws Exception {
-        ExamStudentQuery newQuery = new JsonMapper().parseJson(query, ExamStudentQuery.class);
+    	ExamStudentQuery newQuery = new JsonMapper().parseJson(query, ExamStudentQuery.class);
         Check.isNull(newQuery, "请求参数不能为空!");
         Check.isNull(newQuery.getExamId(), "请先选择考试批次!");
         newQuery.setFinished(0);//未完成
-        List<ExamStudentInfo> examStudentInfos = examStudentService.getExamStudentInfoList(newQuery);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        List<ExamStudentInfo> examStudentInfos = examStudentService.getExamStudentInfoList(uds,newQuery);
         List<ExamStudentUnFinishedExcel> list = ExamStudentEntityConvert.ofUnFinishedExcel(examStudentInfos);
         ExportUtils.exportEXCEL("缺考登记列表", ExamStudentUnFinishedExcel.class, list, response);
     }
 
+    @DataRule(type = {DataRuleType.COURSE,DataRuleType.ORG})
     @PostMapping("/reexamine/list")
     @ApiOperation(value = "查询重考考生列表(分页)")
     public Page<ExamStudentInfo> getReExamineStudentList(@RequestBody ExamStudentQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "考试批次不能为空!");
-        Page<ExamStudentInfo> reExamineStudentList = examStudentService.getReExamineStudentList(query);
+        UserDataRules uds=new UserDataRules(getUserDataRule(DataRuleType.ORG), getUserDataRule(DataRuleType.COURSE));
+        Page<ExamStudentInfo> reExamineStudentList = examStudentService.getReExamineStudentList(uds,query);
         reExamineStudentList.getContent().forEach(p -> {
             p.setIdentityNumber(IdentityNumberHelper.conceal(p.getRootOrgId(), p.getIdentityNumber()));
         });
@@ -189,6 +221,7 @@ public class ExamStudentController extends ControllerSupport {
         return examStudentService.getExamStudentStatisticByFinished(examId, examStageId);
     }
 
+    @DataRule(type = {DataRuleType.ORG})
     @PostMapping("/statistic/by/org")
     @ApiOperation(value = "考试概况-按学习中心统计")
     public List<ExamStudentOrgStatistic> getExamStudentStatisticByOrg(@RequestParam Long examId,
@@ -197,9 +230,10 @@ public class ExamStudentController extends ControllerSupport {
         if (examId == null) {
             return null;
         }
-        return examStudentService.getExamStudentStatisticByOrg(examId, examStageId, orgId);
+        return examStudentService.getExamStudentStatisticByOrg(getUserDataRule(DataRuleType.ORG),examId, examStageId, orgId);
     }
 
+    @DataRule(type = {DataRuleType.ORG})
     @GetMapping("/statistic/by/org/export")
     @ApiOperation(value = "导出“考试概况-按学习中心统计”列表(Excel)")
     public void exportExamStudentStatisticByOrg(@RequestParam Long examId,
@@ -208,7 +242,7 @@ public class ExamStudentController extends ControllerSupport {
                                                 HttpServletResponse response) throws Exception {
         Check.isNull(examId, "请选择考试批次!");
         List<ExamStudentOrgStatistic> examStudentStatisticByOrgList =
-                examStudentService.getExamStudentStatisticByOrg(examId, examStageId, orgId);
+                examStudentService.getExamStudentStatisticByOrg(getUserDataRule(DataRuleType.ORG),examId, examStageId, orgId);
         List<OrgCompleteProgressExcel> resultList =
                 ExamStudentEntityConvert.copyFromExamStudentOrgStatistic(examStudentStatisticByOrgList);
         ExportUtils.exportEXCEL("学习中心完成进度", OrgCompleteProgressExcel.class, resultList, response);
@@ -221,6 +255,7 @@ public class ExamStudentController extends ControllerSupport {
      * @param orgId
      * @return
      */
+    @DataRule(type = DataRuleType.COURSE)
     @GetMapping("/findCoursesByExamIdAndOrgId")
     @ApiOperation(value = "查询课程")
     public List<CourseCacheBean> findCoursesByExamIdAndOrgId(@RequestParam Long examId,
@@ -230,10 +265,16 @@ public class ExamStudentController extends ControllerSupport {
             return null;
         }
         List<Long> courseIdList = examStudentService.findCoursesFromExamStudent(examId, examStageId, orgId);
+        UserDataRule ud=getUserDataRule(DataRuleType.COURSE);
         List<CourseCacheBean> courseBeanList = new ArrayList<CourseCacheBean>();
+        if(ud.assertEmptyQueryResult()) {
+        	return courseBeanList;
+        }
         for (Long courseId : courseIdList) {
-            CourseCacheBean courseBean = ExamCacheTransferHelper.getCachedCourse(courseId);
-            courseBeanList.add(courseBean);
+        	if(!ud.assertNeedQueryRefIds()||ud.getRefIds().contains(courseId)) {
+	            CourseCacheBean courseBean = ExamCacheTransferHelper.getCachedCourse(courseId);
+	            courseBeanList.add(courseBean);
+        	}
         }
         return courseBeanList;
     }
@@ -245,6 +286,7 @@ public class ExamStudentController extends ControllerSupport {
      * @param courseId
      * @return
      */
+    @DataRule(type = DataRuleType.COURSE)
     @GetMapping("/courseProgress/list")
     @ApiOperation(value = "课程完成进度")
     public List<CourseProgressInfo> queryCourseProgressInfos(@RequestParam Long examId,
@@ -254,8 +296,9 @@ public class ExamStudentController extends ControllerSupport {
         if (examId == null) {
             return null;
         }
+        UserDataRule ud=getUserDataRule(DataRuleType.COURSE);
         List<CourseProgressInfo> courseProgressInfoList =
-                examStudentService.queryCourseProgressInfos(examId, examStageId, courseId, orderColumn);
+                examStudentService.queryCourseProgressInfos(ud,examId, examStageId, courseId, orderColumn);
         if (courseProgressInfoList != null && courseProgressInfoList.size() > 0) {
             for (CourseProgressInfo courseProgressInfo : courseProgressInfoList) {
                 long key = courseProgressInfo.getCourseId();
@@ -267,6 +310,7 @@ public class ExamStudentController extends ControllerSupport {
         return courseProgressInfoList;
     }
 
+    @DataRule(type = DataRuleType.COURSE)
     @GetMapping("/courseProgress/list/export")
     @ApiOperation(value = "导出“课程完成进度”列表(Excel)")
     public void exportCourseProgressInfos(@RequestParam Long examId,
@@ -275,8 +319,9 @@ public class ExamStudentController extends ControllerSupport {
                                           @RequestParam(required = false) String orderColumn,
                                           HttpServletResponse response) throws Exception {
         Check.isNull(examId, "请选择考试批次!");
+        UserDataRule ud=getUserDataRule(DataRuleType.COURSE);
         List<CourseProgressInfo> courseProgressInfoList =
-                examStudentService.queryCourseProgressInfos(examId, examStageId, courseId, orderColumn);
+                examStudentService.queryCourseProgressInfos(ud,examId, examStageId, courseId, orderColumn);
         if (courseProgressInfoList != null && courseProgressInfoList.size() > 0) {
             for (CourseProgressInfo courseProgressInfo : courseProgressInfoList) {
                 long key = courseProgressInfo.getCourseId();

+ 33 - 0
examcloud-core-oe-admin-base/src/main/java/cn/com/qmth/examcloud/core/oe/admin/base/utils/RoleUtil.java

@@ -0,0 +1,33 @@
+package cn.com.qmth.examcloud.core.oe.admin.base.utils;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
+import cn.com.qmth.examcloud.core.basic.api.bean.RoleBean;
+import cn.com.qmth.examcloud.core.basic.api.bean.UserBean;
+
+
+public class RoleUtil {
+
+	public static boolean hasAnyRoles(UserBean accessUser, RoleMeta... roles) {
+		List<RoleBean> roleList = accessUser.getRoleList();
+		if (CollectionUtils.isEmpty(roleList)) {
+			return false;
+		}
+
+		Set<String> roleCodes = roleList.stream().map(e -> e.getRoleCode()).collect(Collectors.toSet());
+		for (RoleMeta role : roles) {
+			if (roleCodes.contains(role.name())) {
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+
+}

+ 4 - 8
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamAuditService.java

@@ -9,6 +9,7 @@ package cn.com.qmth.examcloud.core.oe.admin.service;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamAuditEntity;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditQuery;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.RedoAuditInfo;
@@ -30,15 +31,8 @@ public interface ExamAuditService {
      * @param query
      * @return
      */
-    Page<ExamAuditInfo> getExamAuditList(ExamAuditQuery query);
+    Page<ExamAuditInfo> getExamAuditList(UserDataRules uds,ExamAuditQuery query);
 
-    /**
-     * 查询监考已审列表
-     *
-     * @param query
-     * @return
-     */
-    List<ExamAuditInfo> getExamAudit(ExamAuditQuery query);
 
 
     /**
@@ -98,4 +92,6 @@ public interface ExamAuditService {
 
 	void saveExceedMaxSwitchScreenCount(Long realExamRecordDataId);
 
+	List<ExamAuditInfo> getExamAudit(UserDataRules uds, ExamAuditQuery query);
+
 }

+ 8 - 7
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamRecordService.java

@@ -9,6 +9,7 @@ package cn.com.qmth.examcloud.core.oe.admin.service;
 
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.ExamStudentEffectiveScoreInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordQuery;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamStudentQuestionScoreInfo;
@@ -30,7 +31,7 @@ public interface ExamRecordService {
      * @param query
      * @return
      */
-    Page<ExamRecordInfo> getExamRecordList(ExamRecordQuery query);
+    Page<ExamRecordInfo> getExamRecordList(UserDataRules uds,ExamRecordQuery query);
 
     /**
      * 查询“考试明细”列表(分页)
@@ -38,7 +39,7 @@ public interface ExamRecordService {
      * @param query
      * @return
      */
-    Page<ExamRecordInfo> getExamRecordDetailListForPage(ExamRecordQuery query);
+    Page<ExamRecordInfo> getExamRecordDetailListForPage(UserDataRules uds,ExamRecordQuery query);
 
     /**
      * 查询“监考待审”列表(分页)
@@ -46,7 +47,7 @@ public interface ExamRecordService {
      * @param query
      * @return
      */
-    Page<ExamRecordInfo> getExamRecordWaitingAuditList(ExamRecordQuery query);
+    Page<ExamRecordInfo> getExamRecordWaitingAuditList(UserDataRules uds,ExamRecordQuery query);
 
 //    /**
 //     * 查询“监考待审”列表(分页)
@@ -64,7 +65,7 @@ public interface ExamRecordService {
      * @param next
      * @return java.lang.Long
      */
-    Long getExamRecordWaitingAuditNextId(ExamRecordQuery query, Long examRecordDataId, String next);
+    Long getExamRecordWaitingAuditNextId(UserDataRules uds,ExamRecordQuery query, Long examRecordDataId, String next);
 
     /**
      * 获取正在考试的考生ID列表
@@ -88,7 +89,7 @@ public interface ExamRecordService {
      * @param query
      * @return
      */
-    Long existsWarnExamRecordDetail(ExamRecordQuery query);
+    Long existsWarnExamRecordDetail(UserDataRules uds,ExamRecordQuery query);
 
 //    /**
 //     * 根据条件查询 “考试明细”
@@ -116,8 +117,8 @@ public interface ExamRecordService {
      */
     List<ExamStudentEffectiveScoreInfo> getExamStudentEffectiveScoreList(String markingType, List<Long> examStudentIdList);
 
-    List<ExamRecordInfo> getExamRecordDetailListForAsync(ExamRecordQuery query);
-
     void refreshCaptureStatistic(Long examId);
 
+	List<ExamRecordInfo> getExamRecordDetailListForAsync(UserDataRules uds, ExamRecordQuery query);
+
 }

+ 4 - 3
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamScoreService.java

@@ -8,6 +8,7 @@
 package cn.com.qmth.examcloud.core.oe.admin.service;
 
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreEntity;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreQuery;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ObjectiveScoreInfo;
@@ -23,9 +24,9 @@ import java.util.List;
  */
 public interface ExamScoreService {
 
-    Page<ExamScoreInfo> getExamScoreList(ExamScoreQuery query);
+    Page<ExamScoreInfo> getExamScoreList(UserDataRules uds,ExamScoreQuery query);
 
-    List<ExamScoreInfo> exportExamScoreList(ExamScoreQuery query);
+//    List<ExamScoreInfo> exportExamScoreList(ExamScoreQuery query);
 
     /**
      * 获取所有的考试分数集合
@@ -54,6 +55,6 @@ public interface ExamScoreService {
      */
     public List<ObjectiveScoreInfo> queryObjectiveScoreList(Long examStudentId);
 
-    List<ExamScoreInfo> exportExamScoreListForAsync(ExamScoreQuery query);
+    List<ExamScoreInfo> exportExamScoreListForAsync(UserDataRules uds,ExamScoreQuery query);
 
 }

+ 11 - 7
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java

@@ -8,7 +8,9 @@
 package cn.com.qmth.examcloud.core.oe.admin.service;
 
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.*;
 import org.springframework.data.domain.Page;
 
@@ -48,22 +50,21 @@ public interface ExamStudentService {
 
     /**
      * 查询考生列表(分页)
+     * @param uds 
      *
      * @param query
      * @return
      */
-    Page<ExamStudentInfo> getExamStudentListPage(ExamStudentQuery query);
+    Page<ExamStudentInfo> getExamStudentListPage(UserDataRules uds, ExamStudentQuery query);
 
 
-    public List<ExamStudentInfo> getExamStudentInfoList(ExamStudentQuery query);
-
     /**
      * 查询重考考生列表(分页)
      *
      * @param query
      * @return
      */
-    Page<ExamStudentInfo> getReExamineStudentList(ExamStudentQuery query);
+    Page<ExamStudentInfo> getReExamineStudentList(UserDataRules uds,ExamStudentQuery query);
 
     /**
      * 考试概况-按考试完成进度统计
@@ -81,7 +82,7 @@ public interface ExamStudentService {
      * @param examStageId
      * @return
      */
-    List<ExamStudentOrgStatistic> getExamStudentStatisticByOrg(Long examId, Long examStageId, Long orgId);
+    List<ExamStudentOrgStatistic> getExamStudentStatisticByOrg(UserDataRule ud,Long examId, Long examStageId, Long orgId);
 
     /**
      * 获取考生信息
@@ -123,7 +124,7 @@ public interface ExamStudentService {
      * @param examId
      * @param courseId
      */
-    public List<CourseProgressInfo> queryCourseProgressInfos(Long examId, Long examStageId, Long courseId, String orderColumn);
+    public List<CourseProgressInfo> queryCourseProgressInfos(UserDataRule ud,Long examId, Long examStageId, Long courseId, String orderColumn);
 
     /**
      * @return java.util.List<cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentInfo>
@@ -143,8 +144,11 @@ public interface ExamStudentService {
      */
     public List<OnHandExamInfo> queryOnlineExamList(Long studentId, ExamType examType);
 
-    List<ExamStudentInfo> getExamStudentInfoListForAsync(ExamStudentQuery query);
 
     List<OnHandExamInfo> queryOnlineExamEndList(Long userId, ExamType online);
 
+	List<ExamStudentInfo> getExamStudentInfoList(UserDataRules uds, ExamStudentQuery query);
+
+	List<ExamStudentInfo> getExamStudentInfoListForAsync(UserDataRules uds, ExamStudentQuery query);
+
 }

+ 2 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExportTaskService.java

@@ -37,5 +37,7 @@ public interface ExportTaskService {
     void startExportTask(Long taskId);
 
     void endExportTask(Long taskId);
+    
+    ExportTaskEntity findById(Long taskId);
 
 }

+ 33 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/UserDataRules.java

@@ -0,0 +1,33 @@
+package cn.com.qmth.examcloud.core.oe.admin.service.bean;
+
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
+
+public class UserDataRules {
+	
+	private UserDataRule orgRule;
+	
+	private UserDataRule courseRule;
+	
+	
+	public UserDataRules() {
+		super();
+	}
+	public UserDataRules(UserDataRule orgRule, UserDataRule courseRule) {
+		super();
+		this.orgRule = orgRule;
+		this.courseRule = courseRule;
+	}
+	public UserDataRule getOrgRule() {
+		return orgRule;
+	}
+	public void setOrgRule(UserDataRule orgRule) {
+		this.orgRule = orgRule;
+	}
+	public UserDataRule getCourseRule() {
+		return courseRule;
+	}
+	public void setCourseRule(UserDataRule courseRule) {
+		this.courseRule = courseRule;
+	}
+
+}

+ 84 - 19
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/AsyncExportServiceImpl.java

@@ -5,14 +5,45 @@
 
 package cn.com.qmth.examcloud.core.oe.admin.service.impl;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
+import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.DateUtil;
 import cn.com.qmth.examcloud.commons.util.JsonMapper;
+import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
+import cn.com.qmth.examcloud.core.basic.api.bean.UserBean;
+import cn.com.qmth.examcloud.core.basic.api.request.GetUserReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetUserResp;
 import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
+import cn.com.qmth.examcloud.core.oe.admin.base.utils.RoleUtil;
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExportTaskEntity;
 import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExportTaskStatus;
 import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExportTaskType;
-import cn.com.qmth.examcloud.core.oe.admin.service.*;
+import cn.com.qmth.examcloud.core.oe.admin.service.AsyncExportService;
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamAuditService;
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreService;
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
+import cn.com.qmth.examcloud.core.oe.admin.service.ExportTaskService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditQuery;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordInfo;
@@ -30,23 +61,11 @@ import cn.com.qmth.examcloud.support.cache.bean.ExamStageCacheBean;
 import cn.com.qmth.examcloud.support.excel.ExcelExportUtil;
 import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
 import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
+import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.config.SystemProperties;
 import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
 import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import cn.com.qmth.examcloud.web.security.ResourceManager;
 
 /**
  * 异步导出相关接口
@@ -75,6 +94,12 @@ public class AsyncExportServiceImpl implements AsyncExportService {
 
     @Autowired
     private ExamAuditService examAuditService;
+    
+    @Autowired
+    private  UserCloudService userCloudService;
+    
+    @Autowired
+    private ResourceManager resourceManager;
 
     @Override
     public void exportExamScheduling(String jsonParams, User user) {
@@ -99,7 +124,9 @@ public class AsyncExportServiceImpl implements AsyncExportService {
         List<ExamStudentExcel> examRecords;
         List<ExamStudentInfo> examStudentInfoList;
         try {
-            examStudentInfoList = examStudentService.getExamStudentInfoListForAsync(req);
+        	ExportTaskEntity task=exportTaskService.findById(taskId);
+        	UserDataRules uds=new UserDataRules(getUserDataRule(task.getCreator(),DataRuleType.ORG), getUserDataRule(task.getCreator(),DataRuleType.COURSE));
+            examStudentInfoList = examStudentService.getExamStudentInfoListForAsync(uds,req);
             if (CollectionUtils.isEmpty(examStudentInfoList)) {
                 exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "当前条件暂无数据,任务终止");
                 return;
@@ -194,7 +221,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
     public void asyncExportExamRecordDetails(Long taskId, ExamRecordQuery req) {
         List<ExamRecordInfo> examRecords;
         try {
-            examRecords = examRecordService.getExamRecordDetailListForAsync(req);
+        	ExportTaskEntity task=exportTaskService.findById(taskId);
+        	UserDataRules uds=new UserDataRules(getUserDataRule(task.getCreator(),DataRuleType.ORG), getUserDataRule(task.getCreator(),DataRuleType.COURSE));
+            
+            examRecords = examRecordService.getExamRecordDetailListForAsync(uds,req);
 
             if (CollectionUtils.isEmpty(examRecords)) {
                 exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "当前条件暂无数据,任务终止");
@@ -269,7 +299,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
     public void asyncExportExamScoreStatistics(Long taskId, ExamScoreQuery req) {
         List<ExamScoreInfo> examScores;
         try {
-            examScores = examScoreService.exportExamScoreListForAsync(req);
+        	ExportTaskEntity task=exportTaskService.findById(taskId);
+        	UserDataRules uds=new UserDataRules(getUserDataRule(task.getCreator(),DataRuleType.ORG), getUserDataRule(task.getCreator(),DataRuleType.COURSE));
+            
+            examScores = examScoreService.exportExamScoreListForAsync(uds,req);
             if (CollectionUtils.isEmpty(examScores)) {
                 exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "当前条件暂无数据,任务终止");
                 return;
@@ -321,7 +354,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
     public void asyncExportExamAuditList(Long taskId, ExamAuditQuery req) {
         List<ExamAuditInfo> auditInfos;
         try {
-            auditInfos = examAuditService.getExamAudit(req);
+        	ExportTaskEntity task=exportTaskService.findById(taskId);
+        	UserDataRules uds=new UserDataRules(getUserDataRule(task.getCreator(),DataRuleType.ORG), getUserDataRule(task.getCreator(),DataRuleType.COURSE));
+            
+            auditInfos = examAuditService.getExamAudit(uds,req);
 
             if (CollectionUtils.isEmpty(auditInfos)) {
                 exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "当前条件暂无数据,任务终止");
@@ -402,5 +438,34 @@ public class AsyncExportServiceImpl implements AsyncExportService {
         final String pattern = "yyyyMM";
         return new SimpleDateFormat(pattern).format(new Date());
     }
+    
+    private UserDataRule getUserDataRule(Long userId,DataRuleType dataRuleType) {
+    	UserDataRule userDataRule= new UserDataRule();
+        userDataRule.setGlobalStatus(true);
+        userDataRule.setRefIds(new HashSet<>());
+    	boolean isEnable = PropertyHolder.getBoolean("examcloud.data.rule.enable", false);
+        if (!isEnable) {
+            // 未启用数据权限
+            return userDataRule;
+        }
+
+        GetUserReq getUserReq = new GetUserReq();
+        getUserReq.setUserId(userId);
+        GetUserResp getUserResp = userCloudService.getUser(getUserReq);
+        UserBean userBean = getUserResp.getUserBean();
+        if (userBean == null) {
+            throw new StatusException("未找到用户");
+        }
+
+        boolean isAdmimUser = RoleUtil.hasAnyRoles(userBean, RoleMeta.SUPER_ADMIN, RoleMeta.ORG_ADMIN);
+
+        if (isAdmimUser) {
+            // “超管、机构管理员、学生” 暂例外
+        	return userDataRule;
+        } else {
+            userDataRule = resourceManager.loadUserDataRule(userId, dataRuleType);
+        }
+        return userDataRule;
+    }
 
 }

+ 16 - 5
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamAuditServiceImpl.java

@@ -71,6 +71,7 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamScorePushQueueService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentFinalScoreService;
 import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.admin.service.IllegallyTypeService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditEntityConvert;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditMapper;
@@ -164,14 +165,17 @@ public class ExamAuditServiceImpl implements ExamAuditService {
     private static final String AUDIT_USER_NAME = "SYSTEM";
 
     @Override
-    public Page<ExamAuditInfo> getExamAuditList(ExamAuditQuery query) {
+    public Page<ExamAuditInfo> getExamAuditList(UserDataRules uds,ExamAuditQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return Page.empty();
+    	}
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
         //封装查询条件
         Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize());
 
         final String columns = ExamAuditMapper.defaultColumns();
-        SqlWrapper wrapper = getSqlWrapper(query);
+        SqlWrapper wrapper = getSqlWrapper(uds,query);
 
         long totalSize = 0;
         //查询总记录数
@@ -232,11 +236,11 @@ public class ExamAuditServiceImpl implements ExamAuditService {
     }
 
     @Override
-    public List<ExamAuditInfo> getExamAudit(ExamAuditQuery query) {
+    public List<ExamAuditInfo> getExamAudit(UserDataRules uds,ExamAuditQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
 
-        SqlWrapper wrapper = getSqlWrapper(query);
+        SqlWrapper wrapper = getSqlWrapper(uds,query);
 
         wrapper.groupBy("record.id ");
         //查询分页记录
@@ -294,7 +298,7 @@ public class ExamAuditServiceImpl implements ExamAuditService {
     }
 
 
-    private SqlWrapper getSqlWrapper(ExamAuditQuery query) {
+    private SqlWrapper getSqlWrapper(UserDataRules uds,ExamAuditQuery query) {
         final String columns = ExamAuditMapper.defaultColumns();
         SqlWrapper wrapper = new SqlWrapper()
                 .select(columns).from("ec_oe_exam_audit").as("audit")
@@ -360,6 +364,13 @@ public class ExamAuditServiceImpl implements ExamAuditService {
             wrapper.and().gte("audit.update_time", query.getAuditStartTime());
             wrapper.and().lte("audit.update_time", query.getAuditEndTime());
         }
+        
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+        	wrapper.and().in("record.org_id", uds.getOrgRule().getRefIds());
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+        	wrapper.and().in("record.course_id", uds.getCourseRule().getRefIds());
+        }
         return wrapper;
     }
 

+ 0 - 4
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordForMarkingServiceImpl.java

@@ -9,7 +9,6 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.enums.MarkingType;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordQuestionsService;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordDataBean;
-import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.support.enums.ExamProperties;
 import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
@@ -37,9 +36,6 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
     @Autowired
     private ExamRecordForMarkingRepo examRecordForMarkingRepo;
 
-    @Autowired
-    private ExamCloudService examCloudService;
-
     @Autowired
     private ExamRecordDataRepo examRecordDataRepo;
 

+ 34 - 18
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordServiceImpl.java

@@ -30,6 +30,7 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.ExamStudentEffectiveScoreInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordEntityConvert;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordQuery;
@@ -232,23 +233,23 @@ public class ExamRecordServiceImpl implements ExamRecordService {
     private ExamRecordQuestionsRepo examRecordQuestionsRepo;
 
     @Override
-    public Page<ExamRecordInfo> getExamRecordDetailListForPage(ExamRecordQuery query) {
+    public Page<ExamRecordInfo> getExamRecordDetailListForPage(UserDataRules uds,ExamRecordQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
         query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
         query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
-        return this.loadData(_getExamRecordDetailListForPage(query), query.getExamId());
+        return this.loadData(_getExamRecordDetailListForPage(uds,query), query.getExamId());
     }
 
     @Override
-    public Page<ExamRecordInfo> getExamRecordWaitingAuditList(ExamRecordQuery query) {
+    public Page<ExamRecordInfo> getExamRecordWaitingAuditList(UserDataRules uds,ExamRecordQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
         //默认条件
         query.setIsAudit(false);
         query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
         query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
-        return this.getExamRecordList(query);
+        return this.getExamRecordList(uds,query);
     }
 
 //    @Override
@@ -285,8 +286,11 @@ public class ExamRecordServiceImpl implements ExamRecordService {
 //    }
 
     @Override
-    public Long getExamRecordWaitingAuditNextId(ExamRecordQuery query, Long examRecordDataId, String next) {
-        Check.isNull(query, "查询参数不能为空!");
+    public Long getExamRecordWaitingAuditNextId(UserDataRules uds,ExamRecordQuery query, Long examRecordDataId, String next) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return null;
+    	}
+    	Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
         //默认条件
         query.setIsWarn(true);
@@ -296,7 +300,7 @@ public class ExamRecordServiceImpl implements ExamRecordService {
         //查询条件
         StringBuilder sqlBuilder = new StringBuilder();
         sqlBuilder.append("select record_data.id from ec_oe_exam_record_data record_data where 1 = 1 ");
-        sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
+        sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
         if (query.getIsWarn() != null) {
             //只查有异常未审核
             if (query.getIsWarn()) {
@@ -341,13 +345,13 @@ public class ExamRecordServiceImpl implements ExamRecordService {
      * @param query
      * @return
      */
-    private Page<ExamRecordInfo> _getExamRecordDetailListForPage(ExamRecordQuery query) {
+    private Page<ExamRecordInfo> _getExamRecordDetailListForPage(UserDataRules uds,ExamRecordQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
         //查询条件
         StringBuilder sqlBuilder = new StringBuilder();
         sqlBuilder.append(EXAM_RECORD_FROM_SQL);
-        sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
+        sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
         sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn  = 1 and record_data.is_audit = 1))");
         sqlBuilder.append(" group by record_data.id ");
         //分页条件
@@ -434,7 +438,7 @@ public class ExamRecordServiceImpl implements ExamRecordService {
      * @param query
      * @return
      */
-    private StringBuilder buildExamRecordCommonSelectCondition(ExamRecordQuery query) {
+    private StringBuilder buildExamRecordCommonSelectCondition(UserDataRules uds,ExamRecordQuery query) {
         StringBuilder sql = new StringBuilder();
         if (query.getSwitchScreenCountStart() != null) {
         	sql.append(" and record_data.switch_screen_count >= " +query.getSwitchScreenCountStart());
@@ -544,6 +548,12 @@ public class ExamRecordServiceImpl implements ExamRecordService {
         if (StringUtils.isNotBlank(query.getIp())) {
         	sql.append(" and process.source_ip='"+query.getIp()+"' ");
         }
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+            sql.append(" and record_data.org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+            sql.append(" and record_data.course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
+        }
         return sql;
     }
 
@@ -552,13 +562,16 @@ public class ExamRecordServiceImpl implements ExamRecordService {
      * 查询无异常的数据和有异常未审核的数据
      */
     @Override
-    public Page<ExamRecordInfo> getExamRecordList(ExamRecordQuery query) {
+    public Page<ExamRecordInfo> getExamRecordList(UserDataRules uds,ExamRecordQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return Page.empty();
+    	}
         Check.isNull(query, "查询参数不能为空!");
         //查询条件
         StringBuilder sqlBuilder = new StringBuilder();
         //待审核(按原先的sql,多了一个ip字段)
         sqlBuilder.append(EXAM_RECORD_FROM_SQL);
-        sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
+        sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
         if (query.getIsWarn() != null) {
             //只查有异常未审核
             if (query.getIsWarn()) {
@@ -708,17 +721,20 @@ public class ExamRecordServiceImpl implements ExamRecordService {
     }
 
     @Override
-    public Long existsWarnExamRecordDetail(ExamRecordQuery query) {
+    public Long existsWarnExamRecordDetail(UserDataRules uds,ExamRecordQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return 0L;
+    	}
         StringBuilder sqlBuilder = new StringBuilder();
         sqlBuilder.append("select count(record_data.id) from ec_oe_exam_record_data record_data "
                 + " where 1=1 ");
-        sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
+        sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
         sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0");
         return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
     }
 
     @Override
-    public List<ExamRecordInfo> getExamRecordDetailListForAsync(ExamRecordQuery query) {
+    public List<ExamRecordInfo> getExamRecordDetailListForAsync(UserDataRules uds,ExamRecordQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
         query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
@@ -726,7 +742,7 @@ public class ExamRecordServiceImpl implements ExamRecordService {
         List<ExamRecordInfo> examRecordDataList = new ArrayList<ExamRecordInfo>();
         Long startId = 0L;
         for (; ; ) {
-            List<ExamRecordInfo> tem = getExamRecordDetailPageForExport(query, startId);
+            List<ExamRecordInfo> tem = getExamRecordDetailPageForExport(uds,query, startId);
             if (tem == null || tem.size() == 0) {
                 break;
             } else {
@@ -939,10 +955,10 @@ public class ExamRecordServiceImpl implements ExamRecordService {
 
     }
 
-    private List<ExamRecordInfo> getExamRecordDetailPageForExport(ExamRecordQuery query, Long startId) {
+    private List<ExamRecordInfo> getExamRecordDetailPageForExport(UserDataRules uds,ExamRecordQuery query, Long startId) {
         StringBuilder sqlBuilder = new StringBuilder();
         sqlBuilder.append(EXAM_RECORD_EXPORT_SQL);
-        sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
+        sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
         sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn  = 1 and record_data.is_audit = 1))");
         sqlBuilder.append(" and record_data.id >" + startId);
         sqlBuilder.append(" group by record_data.id ");

+ 0 - 4
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamScoreQueueServiceImpl.java

@@ -5,7 +5,6 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScorePushQueue;
 import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExamScoreQueueStatus;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamScorePushService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreQueueService;
-import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
 import cn.com.qmth.examcloud.web.support.SpringContextHolder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -26,9 +25,6 @@ public class ExamScoreQueueServiceImpl implements ExamScoreQueueService {
     @Autowired
     private ExamScorePushQueueRepo examScorePushQueueRepo;
 
-    @Autowired
-    private GainBaseDataService gainBaseDataService;
-
     @Override
     public void disposeScoreQueue() {
         List<ExamScorePushQueue> examScorePushQueues = examScorePushQueueRepo.findExamScorePushQueue();

+ 33 - 17
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamScoreServiceImpl.java

@@ -44,6 +44,7 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentFinalScoreService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreEntityConvert;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreQuery;
@@ -95,7 +96,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     private ExamStudentFinalScoreService examStudentFinalScoreService;
 
     @Override
-    public Page<ExamScoreInfo> getExamScoreList(ExamScoreQuery query) {
+    public Page<ExamScoreInfo> getExamScoreList(UserDataRules uds,ExamScoreQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
         Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize());
@@ -106,7 +107,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 getDefaultCachedExamProperty(query.getExamId(), ExamProperties.MARKING_TYPE.name()).getValue();
 
         //获取考生列表
-        Page<ExamStudentInfo> page = examStudentService.getExamStudentListPage(ExamScoreEntityConvert.of(query));
+        Page<ExamStudentInfo> page = examStudentService.getExamStudentListPage(uds,ExamScoreEntityConvert.of(query));
         List<ExamStudentInfo> examStudentList = page.getContent();
         if (examStudentList == null || examStudentList.size() == 0) {
             return new PageImpl<ExamScoreInfo>(Lists.newArrayList(), pageable, page.getTotalElements());
@@ -176,7 +177,10 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     }
 
     @Override
-    public List<ExamScoreInfo> exportExamScoreListForAsync(ExamScoreQuery query) {
+    public List<ExamScoreInfo> exportExamScoreListForAsync(UserDataRules uds,ExamScoreQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return Lists.newArrayList();
+    	}
         Check.isNull(query, "查询参数不能为空!");
         Check.isNull(query.getExamId(), "请先选择考试批次!");
 
@@ -184,12 +188,12 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         String markingType = ExamCacheTransferHelper.
                 getDefaultCachedExamProperty(query.getExamId(), ExamProperties.MARKING_TYPE.name()).getValue();
         if (query.getStartLimit() != null && query.getEndLimit() != null) {
-            return getExamStudentInfoListOfScoreExport(query, markingType);
+            return getExamStudentInfoListOfScoreExport(uds,query, markingType);
         } else {
             List<ExamStudentEntity> examStudentList = new ArrayList<ExamStudentEntity>();
             Long startId = 0L;
             for (; ; ) {
-                List<ExamStudentEntity> tem = getExamStudentInfoListOfScoreExportByPage(query, markingType, startId);
+                List<ExamStudentEntity> tem = getExamStudentInfoListOfScoreExportByPage(uds,query, markingType, startId);
                 if (tem == null || tem.size() == 0) {
                     break;
                 } else {
@@ -214,7 +218,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         }
     }
 
-    private List<ExamStudentEntity> getExamStudentInfoListOfScoreExportByPage(ExamScoreQuery query, String markingType, Long startId) {
+    private List<ExamStudentEntity> getExamStudentInfoListOfScoreExportByPage(UserDataRules uds,ExamScoreQuery query, String markingType, Long startId) {
         //查询条件
         StringBuffer sql = new StringBuffer();
         sql.append("select id,exam_student_id,exam_id,course_id,course_code,course_level,finished,student_id,student_code,student_name,identity_number"
@@ -247,6 +251,12 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         if (query.getFinished() != null) {
             sql.append(" and finished= " + query.getFinished());
         }
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+        	sql.append(" and org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+        	sql.append(" and course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
+        }
         sql.append(" and id >" + startId);
         sql.append(" order by id limit 500 ");
 
@@ -260,16 +270,16 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         return examStudentList;
     }
 
-    @Override
-    public List<ExamScoreInfo> exportExamScoreList(ExamScoreQuery query) {
-        Check.isNull(query, "查询参数不能为空!");
-        Check.isNull(query.getExamId(), "请先选择考试批次!");
-
-        //阅卷方式
-        String markingType = ExamCacheTransferHelper.
-                getDefaultCachedExamProperty(query.getExamId(), ExamProperties.MARKING_TYPE.name()).getValue();
-        return getExamStudentInfoListOfScoreExport(query, markingType);
-    }
+//    @Override
+//    public List<ExamScoreInfo> exportExamScoreList(ExamScoreQuery query) {
+//        Check.isNull(query, "查询参数不能为空!");
+//        Check.isNull(query.getExamId(), "请先选择考试批次!");
+//
+//        //阅卷方式
+//        String markingType = ExamCacheTransferHelper.
+//                getDefaultCachedExamProperty(query.getExamId(), ExamProperties.MARKING_TYPE.name()).getValue();
+//        return getExamStudentInfoListOfScoreExport(query, markingType);
+//    }
 
     @Override
     public List<ExamScoreEntity> getAllExamScoreList(Long examId, String identityNumber, Long courseId) {
@@ -283,7 +293,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         return examScoreRepo.findByExamRecordDataIdIn(examRecordDataIds);
     }
 
-    private List<ExamScoreInfo> getExamStudentInfoListOfScoreExport(ExamScoreQuery query, String markingType) {
+    private List<ExamScoreInfo> getExamStudentInfoListOfScoreExport(UserDataRules uds,ExamScoreQuery query, String markingType) {
         Check.isNull(query, "查询参数不能为空!");
         //查询条件
         StringBuffer sql = new StringBuffer();
@@ -317,6 +327,12 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         if (query.getFinished() != null) {
             sql.append(" and finished= " + query.getFinished());
         }
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+        	sql.append(" and org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+        	sql.append(" and course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
+        }
         sql.append(" order by update_time desc");
 
         if (query.getStartLimit() != null && query.getEndLimit() != null) {

+ 90 - 33
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java

@@ -47,6 +47,7 @@ import com.google.common.collect.Lists;
 
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.StringUtil;
 import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
@@ -74,6 +75,7 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.admin.service.LocalCacheService;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordFileAnswerInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.CourseProgressInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentEntityConvert;
@@ -86,10 +88,7 @@ import cn.com.qmth.examcloud.core.oe.admin.service.cache.ExamStudentCache;
 import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamSpecialSettingsBean;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
-import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetOngoingExamListReq;
-import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetOngoingExamListResp;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
@@ -255,7 +254,10 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     }
 
     @Override
-    public Page<ExamStudentInfo> getExamStudentListPage(ExamStudentQuery query) {
+    public Page<ExamStudentInfo> getExamStudentListPage(UserDataRules uds,ExamStudentQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return Page.empty();
+    	}
         Check.isNull(query, "查询参数不能为空!");
 
         ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(query.getExamId());
@@ -272,7 +274,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         sql.append(",student_id,student_code,student_name,identity_number"
                 + ",info_collector,root_org_id,org_id,paper_type,used_num,extra_num"
                 + ",specialty_code,specialty_name,grade,t1.exam_stage_id from ec_oe_exam_student t1 where 1=1 ");
-        sql.append(selectExamStudentConfitionSql(query, examBean.getExamType()));
+        sql.append(selectExamStudentConfitionSql(uds,query, examBean.getExamType()));
         sql.append(" order by id desc");
         int currentNum = (query.getPageNo() - 1) * query.getPageSize();
         sql.append(" limit " + currentNum + "," + query.getPageSize());
@@ -305,7 +307,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         }
         cahcheMap.clear();
         Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize());
-        long totalSize = countExamStudent(query, examBean.getExamType());
+        long totalSize = countExamStudent(uds,query, examBean.getExamType());
         fillStage(examStudentInfoList);
         return new PageImpl<>(examStudentInfoList, pageable, totalSize);
     }
@@ -324,16 +326,16 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     	}
     }
 
-    private long countExamStudent(ExamStudentQuery query, String examType) {
+    private long countExamStudent(UserDataRules uds,ExamStudentQuery query, String examType) {
         //查询条件
         StringBuffer sql = new StringBuffer();
         sql.append("select count(t1.id) from ec_oe_exam_student t1 where 1=1 ");
-        sql.append(selectExamStudentConfitionSql(query, examType));
+        sql.append(selectExamStudentConfitionSql(uds,query, examType));
         return jdbcTemplate.queryForObject(sql.toString(), Long.class);
     }
 
     @Override
-    public List<ExamStudentInfo> getExamStudentInfoListForAsync(ExamStudentQuery query) {
+    public List<ExamStudentInfo> getExamStudentInfoListForAsync(UserDataRules uds,ExamStudentQuery query) {
         Check.isNull(query, "查询参数不能为空!");
         ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(query.getExamId());
 
@@ -341,7 +343,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         int pageNo = 1;
         int pageSize = 500;
         for (; ; ) {
-            List<ExamStudentEntity> tem = getExamStudentInfoListByPage(query, examBean, pageNo, pageSize);
+            List<ExamStudentEntity> tem = getExamStudentInfoListByPage(uds,query, examBean, pageNo, pageSize);
             if (tem == null || tem.size() == 0) {
                 break;
             } else {
@@ -426,7 +428,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         tool.setDataForBatch(dataList, 100);
     }
 
-    private List<ExamStudentEntity> getExamStudentInfoListByPage(ExamStudentQuery query, ExamSettingsCacheBean examBean, int pageNo, int pageSize) {
+    private List<ExamStudentEntity> getExamStudentInfoListByPage(UserDataRules uds,ExamStudentQuery query, ExamSettingsCacheBean examBean, int pageNo, int pageSize) {
         //查询条件
         StringBuffer sql = new StringBuffer();
         sql.append("select id,exam_student_id,exam_id,course_id,course_code,course_level");
@@ -439,7 +441,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         sql.append(",student_id,student_code,student_name,identity_number"
                 + ",info_collector,root_org_id,org_id,paper_type,used_num,extra_num"
                 + ",specialty_code,specialty_name,grade,exam_stage_id from ec_oe_exam_student t1 where 1=1 ");
-        sql.append(selectExamStudentConfitionSql(query, examBean.getExamType()));
+        sql.append(selectExamStudentConfitionSql(uds,query, examBean.getExamType()));
         int currentNum = (pageNo - 1) * pageSize;
         sql.append(" order by id limit " + currentNum + "," + pageSize);
 
@@ -454,7 +456,10 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     }
 
     @Override
-    public List<ExamStudentInfo> getExamStudentInfoList(ExamStudentQuery query) {
+    public List<ExamStudentInfo> getExamStudentInfoList(UserDataRules uds,ExamStudentQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return Lists.newArrayList();
+    	}
         Check.isNull(query, "查询参数不能为空!");
         ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(query.getExamId());
 
@@ -470,7 +475,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         sql.append(",student_id,student_code,student_name,identity_number"
                 + ",info_collector,root_org_id,org_id,paper_type,used_num,extra_num"
                 + ",specialty_code,specialty_name,grade,t1.exam_stage_id from ec_oe_exam_student t1 where 1=1 ");
-        sql.append(selectExamStudentConfitionSql(query, examBean.getExamType()));
+        sql.append(selectExamStudentConfitionSql(uds,query, examBean.getExamType()));
         sql.append(" order by id desc");
 
         List<ExamStudentEntity> examStudentList = jdbcTemplate.query(sql.toString(), new RowMapper<ExamStudentEntity>() {
@@ -504,7 +509,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         return examStudentInfoList;
     }
 
-    private StringBuffer selectExamStudentConfitionSql(ExamStudentQuery query, String examType) {
+    private StringBuffer selectExamStudentConfitionSql(UserDataRules uds,ExamStudentQuery query, String examType) {
         StringBuffer sql = new StringBuffer();
         if (query.getOrgId() != null) {
             sql.append(" and org_id=" + query.getOrgId());
@@ -558,6 +563,12 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
             }
         }
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+            sql.append(" and org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+            sql.append(" and course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
+        }
         return sql;
     }
 
@@ -667,7 +678,10 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     }
 
     @Override
-    public Page<ExamStudentInfo> getReExamineStudentList(ExamStudentQuery query) {
+    public Page<ExamStudentInfo> getReExamineStudentList(UserDataRules uds,ExamStudentQuery query) {
+    	if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
+    		return Page.empty();
+    	}
         //获取考试的默认次数
         ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(query.getExamId());
 
@@ -727,6 +741,12 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         if (StringUtils.isNotBlank(query.getCourseLevel())) {
             sql.append(" and t.course_level= '" + query.getCourseLevel() + "'");
         }
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+        	sql.append(" and t.org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+        	sql.append(" and t.course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
+        }
         int currentNum = (query.getPageNo() - 1) * query.getPageSize();
         sql.append(" limit " + currentNum + "," + query.getPageSize());
 
@@ -754,7 +774,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
                 return examStudentEntity;
             }
         });
-        long totalSize = countReExamine(query, examBean);
+        long totalSize = countReExamine(uds,query, examBean);
         List<ExamStudentInfo> list = new ArrayList<ExamStudentInfo>();
         for (ExamStudentEntity examStudentEntity : examStudentList) {
             ExamStudentInfo examStudentInfo = ExamStudentEntityConvert.of(examStudentEntity);
@@ -768,7 +788,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         return new PageImpl<>(list, pageable, totalSize);
     }
 
-    private Long countReExamine(ExamStudentQuery query, ExamSettingsCacheBean examBean) {
+    private Long countReExamine(UserDataRules uds,ExamStudentQuery query, ExamSettingsCacheBean examBean) {
         StringBuffer sql = new StringBuffer();
         sql.append("SELECT count(*)" +
                 " FROM " +
@@ -800,6 +820,12 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         if (StringUtils.isNotBlank(query.getCourseLevel())) {
             sql.append(" and student.course_level= '" + query.getCourseLevel() + "'");
         }
+        if(uds.getOrgRule().assertNeedQueryRefIds()) {
+        	sql.append(" and student.org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
+        }
+        if(uds.getCourseRule().assertNeedQueryRefIds()) {
+        	sql.append(" and student.course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
+        }
         return jdbcTemplate.queryForObject(sql.toString(), Long.class);
     }
 
@@ -858,8 +884,11 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     }
 
     @Override
-    public List<ExamStudentOrgStatistic> getExamStudentStatisticByOrg(Long examId, Long examStageId, Long orgId) {
-        ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
+    public List<ExamStudentOrgStatistic> getExamStudentStatisticByOrg(UserDataRule ud,Long examId, Long examStageId, Long orgId) {
+    	if(ud.assertEmptyQueryResult()) {
+    		return Lists.newArrayList();
+    	}
+    	ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
         if (ExamType.ONLINE.name().equals(examBean.getExamType()) ||
                 ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) {
             StringBuffer totalsql = new StringBuffer();
@@ -903,7 +932,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
                     statistic.setFinishedPercent(new DecimalFormat("#.00").format(percent * 100));
                 }
             }
-            return totalList;
+            List<ExamStudentOrgStatistic> ret=Lists.newArrayList();
+            for (ExamStudentOrgStatistic statistic : totalList) {
+            	if(!ud.assertNeedQueryRefIds()||ud.getRefIds().contains(statistic.getOrgId())) {
+            		ret.add(statistic);
+            	}
+            }
+            return ret;
         } else {
             SqlWrapper wrapper = new SqlWrapper()
                     .select(statisticOrgColumns())
@@ -926,7 +961,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
                 statistic.setOrgCode(orgBean.getCode());
                 statistic.setOrgName(orgBean.getName());
             }
-            return examStudentOrgStatisticList;
+            List<ExamStudentOrgStatistic> ret=Lists.newArrayList();
+            for (ExamStudentOrgStatistic statistic : examStudentOrgStatisticList) {
+            	if(!ud.assertNeedQueryRefIds()||ud.getRefIds().contains(statistic.getOrgId())) {
+            		ret.add(statistic);
+            	}
+            }
+            return ret;
         }
     }
 
@@ -1001,8 +1042,11 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     }
 
     @Override
-    public List<CourseProgressInfo> queryCourseProgressInfos(Long examId, Long examStageId,
+    public List<CourseProgressInfo> queryCourseProgressInfos(UserDataRule ud,Long examId, Long examStageId,
                                                              Long courseId, String orderColumn) {
+    	if(ud.assertEmptyQueryResult()) {
+    		return Lists.newArrayList();
+    	}
         if (examId == null) {
             return null;
         }
@@ -1051,7 +1095,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
                     statistic.setCompletedProportion(Double.valueOf(new DecimalFormat("#.00").format(percent * 100)));
                 }
             }
-            return totalList;
+            List<CourseProgressInfo> ret=Lists.newArrayList();
+            for (CourseProgressInfo statistic : totalList) {
+            	if(!ud.assertNeedQueryRefIds()||ud.getRefIds().contains(statistic.getCourseId())) {
+            		ret.add(statistic);
+            	}
+            }
+            return ret;
         } else {
             if (StringUtils.isBlank(orderColumn)) {
                 orderColumn = "all_num";
@@ -1073,7 +1123,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
             }
             sql += " group by course_id ) tb ORDER BY " + orderColumn + " desc";
 
-            return jdbcTemplate.query(sql, new RowMapper<CourseProgressInfo>() {
+            List<CourseProgressInfo> totalList= jdbcTemplate.query(sql, new RowMapper<CourseProgressInfo>() {
                 @Override
                 public CourseProgressInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
                     CourseProgressInfo courseProgressInfo = new CourseProgressInfo();
@@ -1085,6 +1135,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
                     return courseProgressInfo;
                 }
             });
+            List<CourseProgressInfo> ret=Lists.newArrayList();
+            for (CourseProgressInfo statistic : totalList) {
+            	if(!ud.assertNeedQueryRefIds()||ud.getRefIds().contains(statistic.getCourseId())) {
+            		ret.add(statistic);
+            	}
+            }
+            return ret;
         }
     }
 
@@ -1325,13 +1382,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         examStudentInfo.setUsedNum(ret);
     }
 
-    //获取考试的考生信息
-    private ExamStudentBean getRemoteExamStudent(Long rootOrgId, Long examStudentId) {
-        GetExamStudentReq req = new GetExamStudentReq();
-        req.setExamStudentId(examStudentId);
-        req.setRootOrgId(rootOrgId);
-        GetExamStudentResp resp = examStudentCloudService.getExamStudent(req);
-        return resp.getExamStudentBean();
-    }
+//    //获取考试的考生信息
+//    private ExamStudentBean getRemoteExamStudent(Long rootOrgId, Long examStudentId) {
+//        GetExamStudentReq req = new GetExamStudentReq();
+//        req.setExamStudentId(examStudentId);
+//        req.setRootOrgId(rootOrgId);
+//        GetExamStudentResp resp = examStudentCloudService.getExamStudent(req);
+//        return resp.getExamStudentBean();
+//    }
 
 }

+ 7 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExportTaskServiceImpl.java

@@ -23,6 +23,8 @@ import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamMapsReq;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamMapsResp;
 import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
@@ -256,4 +258,9 @@ public class ExportTaskServiceImpl implements ExportTaskService {
         return info;
     }
 
+	@Override
+	public ExportTaskEntity findById(Long taskId) {
+		return GlobalHelper.getEntity(exportTaskRepo, taskId, ExportTaskEntity.class);
+	}
+
 }