|
@@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.jms.core.JmsMessagingTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -280,7 +281,7 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
* @description 团队审核通过
|
|
|
* @date 2020-01-05 15:00
|
|
|
*/
|
|
|
- private void teamPass(UserApplyRequest userApplyRequest, UserApplication userApplication) {
|
|
|
+ private RestResponse teamPass(UserApplyRequest userApplyRequest, UserApplication userApplication) {
|
|
|
//更新公司用户信息
|
|
|
Long companyId = userApplication.getMtCompanyId();
|
|
|
Long userId = userApplication.getUserId();
|
|
@@ -289,7 +290,9 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
userRole.setCompanyId(companyId);
|
|
|
userRole.setUserId(userId);
|
|
|
userRole.setRoleId(userApplyRequest.getRoleId());
|
|
|
- userRoleService.save(userRole);
|
|
|
+ if (!userRoleService.save(userRole)) {
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "给用户分配角色失败");
|
|
|
+ }
|
|
|
//获取公司用户信息
|
|
|
MtCompanyUser mtCompanyUser = mtCompanyUserService.getOne(new QueryWrapper<MtCompanyUser>()
|
|
|
.eq("mt_company_id", companyId)
|
|
@@ -307,7 +310,12 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
mtCompanyUser.setUpdateUserId(userId);
|
|
|
//设置用户状态在团队中
|
|
|
mtCompanyUser.setStatus(ApiConstants.ApplicationConstants.APPLY_PASS);
|
|
|
- mtCompanyUserService.saveOrUpdate(mtCompanyUser);
|
|
|
+ if (!mtCompanyUserService.saveOrUpdate(mtCompanyUser)) {
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "关联团队失败");
|
|
|
+ }
|
|
|
+ //加入团队审核通过后进行消息推送
|
|
|
+ teamPassPushMessage(companyId, userId);
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -325,6 +333,17 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
projectUser.setIsMonitor("0");
|
|
|
//保存项目信息
|
|
|
projectService.saveProjectUser(projectUser);
|
|
|
+ //加入项目审核通过,消息推送
|
|
|
+ ProjectInfo projectInfo = projectService.getProjectById(userApplication.getProjectId());
|
|
|
+ if (projectInfo != null) {
|
|
|
+ UserInfo applyUserInfo = userInfoService.getByUserId(userApplication.getUserId());
|
|
|
+ if (applyUserInfo != null) {
|
|
|
+ PushUserInfo regionDirector = pushUserService.getCompanyUserInfoByUserId(userApplication.getMtCompanyId(),
|
|
|
+ projectUser.getUserId());
|
|
|
+ PushMessage.workObtainPermission(applyUserInfo.getName(), projectInfo.getProjectName(),
|
|
|
+ permission.get(userApplication.getPowerType())).sendTokenOnPlatform(jmsMessagingTemplate, regionDirector);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -346,8 +365,8 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
|
|
|
/**
|
|
|
* @param userApplyRequest 申请信息
|
|
|
- * @param companyId 申请的项目所在的公司
|
|
|
- * @param applyName 申请名称
|
|
|
+ * @param companyId 申请的项目所在的公司
|
|
|
+ * @param applyName 申请名称
|
|
|
* @return false 失败 true 成功
|
|
|
* @description 申请加入项目成功后推送消息
|
|
|
* @date 2020/5/2 11:50 下午
|
|
@@ -393,13 +412,45 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
userApplication.setDealUserId(userApplyRequest.getUserId());
|
|
|
if (ApiConstants.ApplicationConstants.APPLY_TYPE_TEAM == userApplication.getType()) {
|
|
|
//团队审核通过
|
|
|
- teamPass(userApplyRequest, userApplication);
|
|
|
+ RestResponse restResponse = teamPass(userApplyRequest, userApplication);
|
|
|
+ if (restResponse != null) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return restResponse;
|
|
|
+ }
|
|
|
} else {
|
|
|
//项目审核通过
|
|
|
projectPass(userApplication);
|
|
|
}
|
|
|
- this.updateById(userApplication);
|
|
|
+ if (this.updateById(userApplication)) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "更新用户申请信息失败");
|
|
|
+ }
|
|
|
return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "操作成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 加入团队审核通过后进行消息推送
|
|
|
+ * @date 2020/5/3 11:05 上午
|
|
|
+ */
|
|
|
+ private void teamPassPushMessage(Long companyId, Long userId) {
|
|
|
+ //推送消息
|
|
|
+ //获取区域主管信息
|
|
|
+ List<PushUserInfo> pushUserInfoList = pushUserService.getUserInfoByRoleCode(
|
|
|
+ CommonEnum.DefaultRole.REGION_DIRECTOR.getCode());
|
|
|
+ if (pushUserInfoList != null && pushUserInfoList.size() > 0) {
|
|
|
+ //申请人
|
|
|
+ PushUserInfo applyUserInfo = pushUserService.getUserInfoByUserId(userId);
|
|
|
+ if (applyUserInfo != null) {
|
|
|
+ MaintenanceCompany maintenanceCompany = maintenanceCompanyService.getById(companyId);
|
|
|
+ pushUserInfoList.add(applyUserInfo);
|
|
|
+ if (maintenanceCompany != null) {
|
|
|
+ PushMessage.teamJoin(applyUserInfo.getUserName(), maintenanceCompany.getName())
|
|
|
+ .sendTokenOnPlatform(jmsMessagingTemplate, pushUserInfoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|