|
@@ -1,8 +1,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.model.PushMessage;
|
|
|
+import cn.com.ty.lift.common.model.PushUserInfo;
|
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
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.Role;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.UserInfo;
|
|
@@ -18,6 +23,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
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;
|
|
@@ -50,6 +56,15 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
@Resource
|
|
|
private IUserService userService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PushUserService pushUserService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IMaintenanceCompanyService maintenanceCompanyService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private JmsMessagingTemplate jmsMessagingTemplate;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public RestResponse assignRole(MtCompanyUserRequest mtCompanyUserRequest) {
|
|
@@ -113,7 +128,7 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
);
|
|
|
//获取角色关联的用户信息
|
|
|
List<Long> userIdList = ProjectUtils.getAttrList(userRoleList, "userId", null);
|
|
|
- if(userIdList.size() > 0){
|
|
|
+ if (userIdList.size() > 0) {
|
|
|
List<MtCompanyUser> mtCompanyUserList = this.list(new QueryWrapper<MtCompanyUser>()
|
|
|
.in(userIdList != null && userIdList.size() > 0, "user_id", userIdList)
|
|
|
.eq("mt_company_id", mtCompanyUserRequest.getCompanyId())
|
|
@@ -168,6 +183,8 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
);
|
|
|
if (deleteUserRoleFlag) {
|
|
|
if (this.updateById(mtCompanyUser)) {
|
|
|
+ //踢出成功推送消息
|
|
|
+ kickOutPushMessage(mtCompanyUser);
|
|
|
return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "踢出用户成功");
|
|
|
} else {
|
|
|
//如果删除不成功,强制事务回滚
|
|
@@ -322,9 +339,36 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<MtCompanyUser> listByMtCompany(Long mtCompanyId){
|
|
|
+ public List<MtCompanyUser> listByMtCompany(Long mtCompanyId) {
|
|
|
LambdaQueryWrapper<MtCompanyUser> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
lambdaQueryWrapper.eq(MtCompanyUser::getMtCompanyId, mtCompanyId);
|
|
|
return list(lambdaQueryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 踢出成功 推送消息
|
|
|
+ * @date 2020/5/3 4:43 下午
|
|
|
+ */
|
|
|
+ private void kickOutPushMessage(MtCompanyUser mtCompanyUser) {
|
|
|
+ //踢出用户成功,进行消息推送
|
|
|
+ //当前公司下的区域主管
|
|
|
+ List<PushUserInfo> pushUserInfoList = pushUserService.getUserInfoByRoleCode(
|
|
|
+ CommonEnum.DefaultRole.REGION_DIRECTOR.getCode());
|
|
|
+ if (pushUserInfoList != null && pushUserInfoList.size() > 0) {
|
|
|
+ //被踢出的人
|
|
|
+ PushUserInfo kickOutUserInfo = pushUserService.getUserInfoByUserId(mtCompanyUser.getUserId());
|
|
|
+ if (kickOutUserInfo != null) {
|
|
|
+ MaintenanceCompany maintenanceCompany = maintenanceCompanyService.getById(
|
|
|
+ mtCompanyUser.getMtCompanyId());
|
|
|
+ if (maintenanceCompany != null) {
|
|
|
+ pushUserInfoList.add(kickOutUserInfo);
|
|
|
+ PushMessage.teamKickOut(kickOutUserInfo.getUserName(), maintenanceCompany.getName())
|
|
|
+ .sendTokenOnPlatform(jmsMessagingTemplate, pushUserInfoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|