|
@@ -3,9 +3,13 @@ package cn.com.ty.lift.system.user.service.impl;
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
+import cn.com.ty.lift.common.utils.SendMessageUtil;
|
|
|
import cn.com.ty.lift.system.constants.CommonConstants;
|
|
|
+import cn.com.ty.lift.system.settings.dao.entity.MaintenanceCompany;
|
|
|
+import cn.com.ty.lift.system.settings.service.IMaintenanceCompanyService;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.MtCompanyUser;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.UserApplication;
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.UserInfo;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.UserRole;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.model.*;
|
|
|
import cn.com.ty.lift.system.user.dao.mapper.UserApplicationMapper;
|
|
@@ -17,8 +21,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
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;
|
|
@@ -38,21 +44,34 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
@Resource
|
|
|
private IMtCompanyUserService mtCompanyUserService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IMaintenanceCompanyService maintenanceCompanyService;
|
|
|
+
|
|
|
@Resource
|
|
|
private IUserRoleService userRoleService;
|
|
|
|
|
|
@Resource
|
|
|
private IUserService userService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IUserInfoService userInfoService;
|
|
|
+
|
|
|
@Resource
|
|
|
private IProjectService projectService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private JmsMessagingTemplate jmsMessagingTemplate;
|
|
|
+
|
|
|
@Override
|
|
|
public RestResponse apply(UserApplyRequest userApplyRequest, int applyTypeTeam) {
|
|
|
+ //申请公司id
|
|
|
long companyId = userApplyRequest.getCompanyId();
|
|
|
+ //申请人id
|
|
|
+ long applyUserId = userApplyRequest.getUserId();
|
|
|
//获取用户原有的申请信息
|
|
|
UserApplication userApplication = this.getOne(new QueryWrapper<UserApplication>()
|
|
|
.eq("mt_company_id", companyId)
|
|
|
- .eq("user_id", userApplyRequest.getUserId())
|
|
|
+ .eq("user_id", applyUserId)
|
|
|
//去掉申请未通过的判断
|
|
|
.ne("status", ApiConstants.ApplicationConstants.APPLY_FAIL)
|
|
|
);
|
|
@@ -65,7 +84,7 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
//校验通过设置审核信息
|
|
|
if (userApplication == null) {
|
|
|
userApplication = new UserApplication();
|
|
|
- userApplication.setUserId(userApplyRequest.getUserId());
|
|
|
+ userApplication.setUserId(applyUserId);
|
|
|
userApplication.setMtCompanyId(companyId);
|
|
|
userApplication.setType(applyTypeTeam);
|
|
|
//设置审核描述信息
|
|
@@ -78,17 +97,16 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
//申请加入项目时需要设置的信息
|
|
|
userApplication.setPowerType(userApplyRequest.getPowerType());
|
|
|
boolean result = this.saveOrUpdate(userApplication);
|
|
|
+
|
|
|
if (result) {
|
|
|
//申请操作成功,推送消息
|
|
|
if (ApiConstants.ApplicationConstants.APPLY_TYPE_TEAM == applyTypeTeam) {
|
|
|
- //申请加入团队成功,给公司所有文员推送信息
|
|
|
- //1.获取所有文员信息
|
|
|
- List<Long> clerkIds = userService.getUserIdByCompanyIdAndRoleCode(companyId,
|
|
|
- CommonEnum.DefaultRole.CLERK.getCode());
|
|
|
- if (clerkIds != null && clerkIds.size() > 0) {
|
|
|
-
|
|
|
+ RestResponse pushMessageResponse = applyTeamPushMessage(companyId, applyUserId);
|
|
|
+ if (pushMessageResponse != null) {
|
|
|
+ return pushMessageResponse;
|
|
|
}
|
|
|
} else {
|
|
|
+ //申请加入团队,将消息推送到app端
|
|
|
|
|
|
}
|
|
|
} else {
|
|
@@ -319,4 +337,31 @@ public class UserApplicationService extends ServiceImpl<UserApplicationMapper, U
|
|
|
projectService.saveProjectUser(projectUser);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param companyId 公司id
|
|
|
+ * @param applyUserId 申请人id
|
|
|
+ * @return 推送信息
|
|
|
+ * @description 申请加入团队将消息推送给pc端文员
|
|
|
+ * @date 2020/5/2 4:18 下午
|
|
|
+ */
|
|
|
+ private RestResponse applyTeamPushMessage(long companyId, long applyUserId) {
|
|
|
+ //组合消息内容
|
|
|
+ UserInfo userInfo = userInfoService.getByUserId(applyUserId);
|
|
|
+ if (userInfo == null) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "用户信息不存在,无法申请");
|
|
|
+ }
|
|
|
+ MaintenanceCompany maintenanceCompany = maintenanceCompanyService.getById(companyId);
|
|
|
+ if (maintenanceCompany == null) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "申请加入的团队不存在");
|
|
|
+ }
|
|
|
+ String content = userInfo.getName() + "申请加入" + maintenanceCompany.getName();
|
|
|
+ //申请加入团队成功,给公司所有文员推送信息
|
|
|
+ List<Long> clerkIds = userService.getUserIdByCompanyIdAndRoleCode(companyId,
|
|
|
+ CommonEnum.DefaultRole.CLERK.getCode());
|
|
|
+ SendMessageUtil.sendMessageToPC(jmsMessagingTemplate, clerkIds, content, applyUserId);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|