浏览代码

3.2.7 云阅卷单点登录bug

xiaofei 1 年之前
父节点
当前提交
200292dbb7

+ 35 - 20
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/SsoServiceImpl.java

@@ -51,6 +51,9 @@ public class SsoServiceImpl implements SsoService {
     @Resource
     @Resource
     SysUserRoleService sysUserRoleService;
     SysUserRoleService sysUserRoleService;
 
 
+    @Resource
+    CloudMarkingTaskUtils cloudMarkingTaskUtils;
+
     @Override
     @Override
     public Map<String, Object> markerLoginInfo() {
     public Map<String, Object> markerLoginInfo() {
         try {
         try {
@@ -60,17 +63,23 @@ public class SsoServiceImpl implements SsoService {
                     || SpecialPrivilegeEnum.SUBJECT_HEADER.equals(userSpecialPrivilege)) {
                     || SpecialPrivilegeEnum.SUBJECT_HEADER.equals(userSpecialPrivilege)) {
                 throw ExceptionResultEnum.ERROR.exception("该用户没有评卷员角色,无法登录");
                 throw ExceptionResultEnum.ERROR.exception("该用户没有评卷员角色,无法登录");
             }
             }
-            // 顶级机构
+
-            SysOrg rootOrg = sysOrgService.findRootOrg(sysUser.getSchoolId());
+            String orgCode = null;
-            List<SysOrg> sysOrgList = sysOrgService.findByConnectByParentId(sysUser.getOrgId(), false, false);
+            if (cloudMarkingTaskUtils.isCollegeMode(sysUser.getSchoolId())) {
-            if(sysOrgList.isEmpty()){
+                // 顶级机构
-                throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属机构及上级机构", sysUser.getLoginName()));
+                SysOrg rootOrg = sysOrgService.findRootOrg(sysUser.getSchoolId());
-            }
+                List<SysOrg> sysOrgList = sysOrgService.findByConnectByParentId(sysUser.getOrgId(), false, false);
-            SysOrg collegeOrg = sysOrgList.stream().filter(m->m.getParentId().equals(rootOrg.getId())).findFirst().orElseGet(null);
+                if (sysOrgList.isEmpty()) {
-            if(collegeOrg == null){
+                    throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属机构及上级机构", sysUser.getLoginName()));
-                throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属学院", sysUser.getLoginName()));
+                }
+                Optional<SysOrg> orgOptional = sysOrgList.stream().filter(m -> m.getParentId() != null && m.getParentId().equals(rootOrg.getId())).findFirst();
+                if (!orgOptional.isPresent()) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属学院", sysUser.getLoginName()));
+                }
+                SysOrg collegeOrg = orgOptional.get();
+                orgCode = collegeOrg.getCode();
             }
             }
-            return stmmsUtils.markLogin(sysUser, collegeOrg.getCode());
+            return stmmsUtils.markLogin(sysUser, orgCode);
         } catch (Exception e) {
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
         }
@@ -85,17 +94,23 @@ public class SsoServiceImpl implements SsoService {
                     || SpecialPrivilegeEnum.MARKER.equals(userSpecialPrivilege)) {
                     || SpecialPrivilegeEnum.MARKER.equals(userSpecialPrivilege)) {
                 throw ExceptionResultEnum.ERROR.exception("该用户没有科组长角色,无法登录");
                 throw ExceptionResultEnum.ERROR.exception("该用户没有科组长角色,无法登录");
             }
             }
-            // 顶级机构
+
-            SysOrg rootOrg = sysOrgService.findRootOrg(sysUser.getSchoolId());
+            String orgCode = null;
-            List<SysOrg> sysOrgList = sysOrgService.findByConnectByParentId(sysUser.getOrgId(), false, false);
+            if (cloudMarkingTaskUtils.isCollegeMode(sysUser.getSchoolId())) {
-            if(sysOrgList.isEmpty()){
+                // 顶级机构
-                throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属机构及上级机构", sysUser.getLoginName()));
+                SysOrg rootOrg = sysOrgService.findRootOrg(sysUser.getSchoolId());
-            }
+                List<SysOrg> sysOrgList = sysOrgService.findByConnectByParentId(sysUser.getOrgId(), false, false);
-            SysOrg collegeOrg = sysOrgList.stream().filter(m->m.getParentId().equals(rootOrg.getId())).findFirst().orElseGet(null);
+                if (sysOrgList.isEmpty()) {
-            if(collegeOrg == null){
+                    throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属机构及上级机构", sysUser.getLoginName()));
-                throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属学院", sysUser.getLoginName()));
+                }
+                Optional<SysOrg> orgOptional = sysOrgList.stream().filter(m -> m.getParentId() != null && m.getParentId().equals(rootOrg.getId())).findFirst();
+                if (!orgOptional.isPresent()) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("未找到用户账号[%s]所属学院", sysUser.getLoginName()));
+                }
+                SysOrg collegeOrg = orgOptional.get();
+                orgCode = collegeOrg.getCode();
             }
             }
-            return stmmsUtils.markLeaderLogin(sysUser, collegeOrg.getCode());
+            return stmmsUtils.markLeaderLogin(sysUser, orgCode);
         } catch (Exception e) {
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
         }

+ 3 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysOrgServiceImpl.java

@@ -598,10 +598,11 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         if (sysOrgList.isEmpty()) {
         if (sysOrgList.isEmpty()) {
             throw ExceptionResultEnum.ERROR.exception(String.format("未找到课程[%s(%s)]所属机构及上级机构", basicCourse.getName(), basicCourse.getCode()));
             throw ExceptionResultEnum.ERROR.exception(String.format("未找到课程[%s(%s)]所属机构及上级机构", basicCourse.getName(), basicCourse.getCode()));
         }
         }
-        SysOrg collegeOrg = sysOrgList.stream().filter(m -> m.getParentId().equals(rootOrg.getId())).findFirst().orElseGet(null);
+        Optional<SysOrg> orgOptional = sysOrgList.stream().filter(m -> m.getParentId() != null && m.getParentId().equals(rootOrg.getId())).findFirst();
-        if (collegeOrg == null) {
+        if (!orgOptional.isPresent()) {
             throw ExceptionResultEnum.ERROR.exception(String.format("未找到课程[%s(%s)]所属学院", basicCourse.getName(), basicCourse.getCode()));
             throw ExceptionResultEnum.ERROR.exception(String.format("未找到课程[%s(%s)]所属学院", basicCourse.getName(), basicCourse.getCode()));
         }
         }
+        SysOrg collegeOrg = orgOptional.get();
         return collegeOrg;
         return collegeOrg;
     }
     }