Explorar o código

3.2.7 云阅卷单点登录bug

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