Browse Source

Merge remote-tracking branch 'origin/dev_v2.2.1' into dev_v2.2.1

wangliang 3 years ago
parent
commit
bf0b17f161

+ 6 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -1182,7 +1182,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         InputStream inputStream = (InputStream) map.get("inputStream");
         List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicCourseImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
             List<ExcelError> excelErrorTemp = new ArrayList<>();
-            Map<String, String> checkMap = new HashMap<>();
+//            Map<String, String> checkMap = new HashMap<>();
             for (int i = 0; i < finalExcelList.size(); i++) {
                 LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
                 List<Object> basicCourseImportDtoList = excelMap.get(i);
@@ -1198,11 +1198,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     String clazz = basicCourseImportDto.getClazz();
 
                     // 检验excel中
-                    if (checkMap.containsKey(courseCode)) {
-                        throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【课程编号】:" + courseCode);
-                    } else {
-                        checkMap.put(courseCode, courseName);
-                    }
+//                    if (checkMap.containsKey(courseCode)) {
+//                        throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【课程编号】:" + courseCode);
+//                    } else {
+//                        checkMap.put(courseCode, courseName);
+//                    }
 
                     excelErrorTemp.addAll(ExcelUtil.checkExcelField(basicCourseImportDto, y, i));
                     if (Objects.isNull(courseCode) || courseCode.length() > 30 || !courseCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {

+ 2 - 1
distributed-print/src/test/java/com/qmth/distributed/print/SyncHelpTest.java

@@ -39,7 +39,8 @@ public class SyncHelpTest {
             }else {
                 userPushParam.setRole(SpecialPrivilegeEnum.SUBJECT_HEADER);
             }
-            stmmsUtils.syncUser(userPushParam,2L);
+            userPushParam.setSchoolId(2L);
+            stmmsUtils.syncUser(userPushParam);
         }
     }
 

+ 13 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/params/UserPushParam.java

@@ -37,6 +37,11 @@ public class UserPushParam {
     @ApiModelProperty(value = "科组长关联科目,科目代码用,分割,例如ASC,WED")
     private String subjectCodes;
 
+    @ApiModelProperty(value = "学校id")
+    @DBVerify(value = "学校id",required = true)
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long schoolId;
+
     public UserPushParam() {
     }
 
@@ -95,4 +100,12 @@ public class UserPushParam {
     public void setSubjectCodes(String subjectCodes) {
         this.subjectCodes = subjectCodes;
     }
+
+    public Long getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Long schoolId) {
+        this.schoolId = schoolId;
+    }
 }

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicStudent.java

@@ -52,11 +52,11 @@ public class BasicStudent extends BaseEntity implements Serializable {
 
     @ApiModelProperty(value = "可操作人机构id")
     @JsonSerialize(using = ToStringSerializer.class)
-    @TableField(value = "org_id", updateStrategy = FieldStrategy.IGNORED)
     private Long orgId;
 
     @ApiModelProperty(value = "所属机构id")
     @JsonSerialize(using = ToStringSerializer.class)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private Long belongOrgId;
 
     @ApiModelProperty(value = "专业id")

+ 1 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/PushUserTrackServiceImpl.java

@@ -163,6 +163,7 @@ public class PushUserTrackServiceImpl extends ServiceImpl<PushUserTrackMapper, P
 
                 UserPushParam cell = new UserPushParam();
                 cell.setUserId(userId);
+                cell.setSchoolId(currentUser.getSchoolId());
                 cell.setName(currentUser.getRealName());
                 cell.setPassword(currentUser.getPassword());
                 cell.setRole(identify);

+ 46 - 49
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java

@@ -131,7 +131,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
     @Transactional
     @Override
-    public boolean saveUser(UserSaveParams userSaveParams) {
+    public boolean saveUser(UserSaveParams userSaveParams) throws IllegalAccessException {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long oldId = userSaveParams.getId();
         Set<Long> dbRoleIdSet = new HashSet<>();
@@ -144,9 +144,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         Long upUserId = saveUserCommon(userSaveParams, null);
         if (SystemConstant.longNotNull(upUserId)) {
             result = true;
-            List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(dbRoleIdSet,currentRoleIdSet,upUserId,this.getById(upUserId).getEnable(),requestUser.getId());
+            List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(dbRoleIdSet, currentRoleIdSet, upUserId, this.getById(upUserId).getEnable(), requestUser.getId());
             List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
-            if (userPushParamList != null && userPushParamList.size() > 0){
+            if (userPushParamList != null && userPushParamList.size() > 0) {
                 this.userPushService(userPushParamList, requestUser.getId());
             }
         }
@@ -166,7 +166,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             commonService.removeUserInfo(user.getId(), true);
         }
         if (success) {
-            this.analyzeUserEnableSpecialPrivilege(user.getId(), user.getEnable(),requestUser.getId());
+            this.analyzeUserEnableSpecialPrivilege(user.getId(), user.getEnable(), requestUser.getId());
         }
         return success;
     }
@@ -664,11 +664,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     /**
      * 过滤拥有审核权限的人
      *
-     * @param schoolId schoolId
-     * @param orgIds orgIds
-     * @param filter filter
+     * @param schoolId    schoolId
+     * @param orgIds      orgIds
+     * @param filter      filter
      * @param approveName approveName
-     * @param realName realName
+     * @param realName    realName
      * @return return
      */
     @Override
@@ -728,9 +728,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 if (SystemConstant.longNotNull(upUserId)) {
 
                     Set<Long> currentRoleIdSet = new HashSet<>(Arrays.asList(userSaveParams.getRoleIds()));
-                    List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(oldRoleIdSet,currentRoleIdSet,upUserId,true,requestUser.getId());
+                    List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(oldRoleIdSet, currentRoleIdSet, upUserId, true, requestUser.getId());
                     List<UserPushParam> userPushParamCell = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
-                    if (userPushParamCell != null && userPushParamCell.size() > 0){
+                    if (userPushParamCell != null && userPushParamCell.size() > 0) {
                         userPushParamList.addAll(userPushParamCell);
                     }
                 }
@@ -769,7 +769,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
      * 获取命题审批人
      *
      * @param courseCode courseCode
-     * @param realName realName
+     * @param realName   realName
      * @return return
      */
     @Override
@@ -792,7 +792,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
      * 获取教研室主任审批人
      *
      * @param courseCode courseCode
-     * @param realName realName
+     * @param realName   realName
      * @return return
      */
     @Override
@@ -821,7 +821,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     /**
      * 获取院长审批人
      *
-     * @param orgIds orgIds
+     * @param orgIds   orgIds
      * @param realName realName
      * @return return
      */
@@ -847,9 +847,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     /**
      * 获取同级别下一级审批人
      *
-     * @param courseCode courseCode
-     * @param orgIds orgIds
-     * @param realName realName
+     * @param courseCode          courseCode
+     * @param orgIds              orgIds
+     * @param realName            realName
      * @param flowApproveNameEnum flowApproveNameEnum
      * @return return
      */
@@ -940,25 +940,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
     @Transactional
     @Override
-    public boolean userPushService(List<UserPushParam> userPushParamList, Long requestUserId) {
+    public boolean userPushService(List<UserPushParam> userPushParamList, Long requestUserId) throws IllegalAccessException {
         SysUser requestUser = this.getById(requestUserId);
-        Long schoolId = requestUser.getSchoolId();
-        if (!SystemConstant.longNotNull(schoolId)){
-            schoolId = SystemConstant.convertIdToLong(String.valueOf(ServletUtil.getRequestHeaderSchoolId()));
-        }
-        if (Objects.isNull(requestUser)){
+        if (Objects.isNull(requestUser)) {
             log.error("未找到请求用户信息 requestUserId = " + requestUserId);
             throw ExceptionResultEnum.ERROR.exception("未找到请求用户信息");
         }
         boolean result = true;
         for (UserPushParam userPushParam : userPushParamList) {
-            boolean syncResult = stmmsUtils.syncUser(userPushParam, schoolId);
+            boolean syncResult = stmmsUtils.syncUser(userPushParam);
             if (!syncResult) {
                 log.warn("-----------------------------用户同步推送失败----------------------------");
                 result = false;
                 PushUserError pushUserError = new PushUserError();
                 pushUserError.setId(SystemConstant.getDbUuid());
-                pushUserError.setSchoolId(requestUser.getSchoolId());
+                pushUserError.setSchoolId(userPushParam.getSchoolId());
                 pushUserError.setUserId(userPushParam.getUserId());
                 pushUserError.setAccount(userPushParam.getAccount());
                 pushUserError.setName(userPushParam.getName());
@@ -976,24 +972,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
     @Transactional
     @Override
-    public void autoPushUserErrorData() {
+    public void autoPushUserErrorData() throws IllegalAccessException {
         List<PushUserError> pushUserErrorList = pushUserErrorService.list();
         Set<Long> userIdSet = pushUserErrorList.stream().map(PushUserError::getUserId).collect(Collectors.toSet());
-        List<SysUser> sysUserList = this.listByIds(userIdSet);
-        // 清空push-user-error表
-        pushUserErrorService.remove(new QueryWrapper<PushUserError>().lambda().in(PushUserError::getUserId, userIdSet));
-        for (SysUser sysUser : sysUserList) {
-            if (!SyncStatusEnum.NEED_PUSH_AGAIN.equals(sysUser.getSyncStatus())) {
-                // 用户同步状态不为需要重新同步的错误数据再同步(防止和需要重新同步类型的数据冲突或因为权限改动导致的反复同步!)
-                Long userId = sysUser.getId();
-                Long schoolId = sysUser.getSchoolId();
-                Set<Long> roleIdSet = sysUserRoleService.listRoleByUserId(userId).stream().map(BaseEntity::getId).collect(Collectors.toSet());
-
-                // TODO: 2021/11/4 系统管理员的id判断
-                Long requestUserId = 1L; // 系统管理员
-                List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null,roleIdSet,userId,sysUser.getEnable(),requestUserId);
-                List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
-                this.userPushService(userPushParamList, requestUserId);
+        if (userIdSet.size() > 0) {
+            List<SysUser> sysUserList = this.listByIds(userIdSet);
+            // 清空push-user-error表
+            pushUserErrorService.remove(new QueryWrapper<PushUserError>().lambda().in(PushUserError::getUserId, userIdSet));
+            for (SysUser sysUser : sysUserList) {
+                if (!SyncStatusEnum.NEED_PUSH_AGAIN.equals(sysUser.getSyncStatus())) {
+                    // 用户同步状态不为需要重新同步的错误数据再同步(防止和需要重新同步类型的数据冲突或因为权限改动导致的反复同步!)
+                    Long userId = sysUser.getId();
+                    Set<Long> roleIdSet = sysUserRoleService.listRoleByUserId(userId).stream().map(BaseEntity::getId).collect(Collectors.toSet());
+
+                    Long requestUserId = 1L; // 系统管理员
+                    List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null, roleIdSet, userId, sysUser.getEnable(), requestUserId);
+                    List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
+                    this.userPushService(userPushParamList, requestUserId);
+                }
             }
         }
     }
@@ -1041,7 +1037,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     public SyncCountResult needPushAgainOperate(SysUser requestUser) throws IllegalAccessException {
         int correctCount = 0;
         int totalCount = 0;
-        if (Objects.isNull(requestUser)){
+        if (Objects.isNull(requestUser)) {
             throw ExceptionResultEnum.ERROR.exception("未找到请求用户");
         }
         Long schoolId = requestUser.getSchoolId();
@@ -1049,8 +1045,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         // 需要同步的用户
         QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(SysUser::getSyncStatus, SyncStatusEnum.NEED_PUSH_AGAIN);
-        if (SystemConstant.longNotNull(schoolId)){
-            queryWrapper.lambda().eq(SysUser::getSchoolId,schoolId);
+        if (SystemConstant.longNotNull(schoolId)) {
+            queryWrapper.lambda().eq(SysUser::getSchoolId, schoolId);
         }
         List<SysUser> sysUserList = sysUserService.list(queryWrapper);
         totalCount = sysUserList.size();
@@ -1193,20 +1189,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
     /**
      * 用户禁用启用特殊权限判断及处理
-     * @param userId 用户id
-     * @param enable 启用/禁用
+     *
+     * @param userId        用户id
+     * @param enable        启用/禁用
      * @param requestUserId 请求人id
      */
-    private void analyzeUserEnableSpecialPrivilege(Long userId, boolean enable,Long requestUserId) {
+    private void analyzeUserEnableSpecialPrivilege(Long userId, boolean enable, Long requestUserId) throws IllegalAccessException {
         SysUser dbUser = sysUserService.getById(userId);
         if (Objects.isNull(dbUser)) {
             throw ExceptionResultEnum.ERROR.exception("未找到系统用户");
         }
         Set<Long> currentRoleIdSet = new HashSet<>(sysRoleService.getUserRoles(userId));
-        List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null,currentRoleIdSet,userId,enable,requestUserId);
+        List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null, currentRoleIdSet, userId, enable, requestUserId);
         List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
-        if (userPushParamList != null && userPushParamList.size() > 0){
-            this.userPushService(userPushParamList,requestUserId);
+        if (userPushParamList != null && userPushParamList.size() > 0) {
+            this.userPushService(userPushParamList, requestUserId);
         }
     }
 }

+ 7 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/StmmsUtils.java

@@ -6,6 +6,7 @@ import com.qmth.teachcloud.common.SignatureEntityTest;
 import com.qmth.teachcloud.common.bean.dto.PaperDTO;
 import com.qmth.teachcloud.common.bean.dto.QuestionDTO;
 import com.qmth.teachcloud.common.bean.params.UserPushParam;
+import com.qmth.teachcloud.common.bean.result.DBVerifyResult;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
@@ -79,12 +80,17 @@ public class StmmsUtils {
         }
     }
 
-    public boolean syncUser(UserPushParam userPushParam, Long schoolId) {
+    public boolean syncUser(UserPushParam userPushParam) throws IllegalAccessException {
+        DBVerifyResult verifyResult = SystemConstant.verifyDBFields(userPushParam,userPushParam.getClass());
+        if (!verifyResult.getStatus()){
+            throw ExceptionResultEnum.ERROR.exception(verifyResult.getMessage());
+        }
         String account = userPushParam.getAccount();
         String name = userPushParam.getName();
         String password = userPushParam.getPassword();
         int roleValue = userPushParam.getRole().getValue();
         Boolean enable = userPushParam.getEnable();
+        Long schoolId = userPushParam.getSchoolId();
 
 
         String hostUrl = dictionaryConfig.syncDataDomain().getHostUrl();

+ 4 - 1
teachcloud-task/src/main/resources/application-task.properties

@@ -128,4 +128,7 @@ spring.quartz.properties.org.quartz.threadPool.threadCount=10
 spring.quartz.properties.org.quartz.threadPool.threadPriority=5
 
 #\u914D\u7F6E\u6587\u4EF6
-#spring.profiles=task
+#spring.profiles=task
+sync.config.hostUrl=http://localhost:8081
+
+sync.config.userSaveUrl=/api/user/external/save