Browse Source

审核建群后发送消息

master
wangchao 5 years ago
parent
commit
52a44050e0
  1. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffGridController.java
  2. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java
  3. 27
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java
  4. 38
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetMessageFeignClient.java
  5. 8
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetUserFeignClient.java
  6. 15
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/GovOrgFeignClient.java
  7. 29
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetMessageFeignClientFallback.java
  8. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetUserFeignClientFallback.java
  9. 14
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/GovOrgFeignClientFallBack.java
  10. 82
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  11. 30
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java
  12. 32
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/RolesUsersListFormDTO.java
  13. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
  14. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java
  15. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java
  16. 21
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java
  17. 34
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffGridController.java

@ -26,6 +26,7 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.excel.CustomerStaffGridExcel;
@ -105,4 +106,17 @@ public class CustomerStaffGridController {
ValidatorUtils.validateEntity(latestGridFormDTO);
return customerStaffGridService.getStaffGridOrderByGridName(latestGridFormDTO);
}
/**
* @Description 查询一个网格下的所有工作人员
* @param gridIdFormDTO
* @return Result<List<String>>
* @author wangc
* @date 2020.04.29 22:59
**/
@PostMapping("getgridstaffs")
public Result<List<String>> getGridStaffs(@RequestBody CommonGridIdFormDTO gridIdFormDTO){
ValidatorUtils.validateEntity(gridIdFormDTO);
return customerStaffGridService.getAllGridStaffs(gridIdFormDTO);
}
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.result.CommonStaffInfoResultDTO;
@ -107,4 +108,13 @@ public interface CustomerStaffGridService extends BaseService<CustomerStaffGridE
* @Date 2020.04.23 09:11
**/
Result<CustomerGridByUserIdResultDTO> getStaffGridOrderByGridName(LatestGridFormDTO latestGridFormDTO);
/**
* @Description 查询一个网格下的所有工作人员
* @param gridIdFormDTO
* @return Result<List<String>>
* @author wangc
* @date 2020.04.29 22:59
**/
Result<List<String>> getAllGridStaffs(CommonGridIdFormDTO gridIdFormDTO);
}

27
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java

@ -23,17 +23,14 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.CustomerStaffGridDao;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.result.CommonStaffInfoResultDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.entity.CustomerStaffGridEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.redis.CustomerStaffGridRedis;
import com.epmet.service.CustomerStaffGridService;
import org.apache.commons.lang3.StringUtils;
@ -41,9 +38,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 网格人员关系表
@ -57,8 +56,6 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl<CustomerStaffG
@Autowired
private CustomerStaffGridRedis customerStaffGridRedis;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Override
public PageData<CustomerStaffGridDTO> page(Map<String, Object> params) {
@ -128,4 +125,22 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl<CustomerStaffG
result.setAgencyId(grid.getPid());
return new Result<CustomerGridByUserIdResultDTO>().ok(result);
}
/**
* @Description 查询一个网格下的所有工作人员
* @param gridIdFormDTO
* @return Result<List<String>>
* @author wangc
* @date 2020.04.29 22:59
**/
@Override
public Result<List<String>> getAllGridStaffs(CommonGridIdFormDTO gridIdFormDTO) {
List<CustomerStaffGridDTO> staffs = baseDao.selectByGridId(gridIdFormDTO.getGridId());
return new Result<List<String>>().ok(
new ArrayList<>(
staffs.stream().map(CustomerStaffGridDTO::getUserId).
collect(Collectors.toSet())
)
);
}
}

38
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetMessageFeignClient.java

@ -0,0 +1,38 @@
package com.epmet.modules.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.modules.feign.fallback.EpmetMessageFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @Description epmet-message服务转发
* @author wangc
* @date 2020.04.29 23:52
**/
@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageFeignClientFallback.class)
public interface EpmetMessageFeignClient {
/**
* @param formDto
* @return com.epmet.commons.tools.utils.Result
* @Author sun
* @Description 新增未读消息
**/
@PostMapping(value = "message/usermessage/saveusermessage", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result saveUserMessage(UserMessageFormDTO formDto);
/**
* @param msgList
* @return com.epmet.commons.tools.utils.Result
* @Author sun
* @Description 热心居民申请给网格长们发送消息
**/
@PostMapping(value = "message/usermessage/saveusermessagelist", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result saveUserMessageList(List<UserMessageFormDTO> msgList);
}

8
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetUserFeignClient.java

@ -2,10 +2,7 @@ package com.epmet.modules.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserInvitationFormDTO;
import com.epmet.dto.form.UserResiInfoFormDTO;
import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.form.UserRoleFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.modules.feign.fallback.EpmetUserFeignClientFallback;
@ -63,4 +60,7 @@ public interface EpmetUserFeignClient {
**/
@PostMapping(value = "epmetuser/userinvitation/saveuserinvitation", consumes = MediaType.APPLICATION_JSON_VALUE)
Result saveUserInvitation(@RequestBody UserInvitationFormDTO userInvitationFormDTO);
@PostMapping(value = "epmetuser/staffrole/specificrolesstaffs", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<String>> specificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO);
}

15
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/GovOrgFeignClient.java

@ -4,9 +4,14 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerDepartmentDTO;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.modules.feign.fallback.GovOrgFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @Description gov-org服务feginClient 服务间调用
@ -34,4 +39,14 @@ public interface GovOrgFeignClient {
*/
@GetMapping("/gov/org/customerdepartment/{id}")
Result<CustomerDepartmentDTO> getDept(String id);
/**
* @Description 查询一个网格下的所有工作人员
* @param gridIdFormDTO
* @return Result<List<String>>
* @author wangc
* @date 2020.04.29 22:59
**/
@PostMapping("/gov/org/customerstaffgrid/getgridstaffs")
Result<List<String>> getGridStaffs(@RequestBody CommonGridIdFormDTO gridIdFormDTO);
}

29
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetMessageFeignClientFallback.java

@ -0,0 +1,29 @@
package com.epmet.modules.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.modules.feign.EpmetMessageFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description
* @ClassName EpmetMessageFeignClientFallback
* @Auth wangc
* @Date 2020-04-29 23:53
*/
@Component
public class EpmetMessageFeignClientFallback implements EpmetMessageFeignClient {
@Override
public Result saveUserMessage(UserMessageFormDTO formDto) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "saveUserMessage", formDto);
}
@Override
public Result saveUserMessageList(List<UserMessageFormDTO> msgList) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "saveUserMessageList", msgList);
}
}

10
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetUserFeignClientFallback.java

@ -3,10 +3,7 @@ package com.epmet.modules.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserInvitationFormDTO;
import com.epmet.dto.form.UserResiInfoFormDTO;
import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.form.UserRoleFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.modules.feign.EpmetUserFeignClient;
@ -41,4 +38,9 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
public Result saveUserInvitation(UserInvitationFormDTO userInvitationFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveUserInvitation", userInvitationFormDTO);
}
@Override
public Result<List<String>> specificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "specificRolesStaffs", rolesUsersListFormDTO);
}
}

14
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/GovOrgFeignClientFallBack.java

@ -1,12 +1,17 @@
package com.epmet.modules.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerDepartmentDTO;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.modules.feign.GovOrgFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class GovOrgFeignClientFallBack implements GovOrgFeignClient {
@ -14,11 +19,16 @@ public class GovOrgFeignClientFallBack implements GovOrgFeignClient {
@Override
public Result<CustomerGridDTO> getGrid(String id) {
return null;
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGrid", id);
}
@Override
public Result<CustomerDepartmentDTO> getDept(String id) {
return null;
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getDept", id);
}
@Override
public Result<List<String>> getGridStaffs(CommonGridIdFormDTO gridIdFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridStaffs", gridIdFormDTO);
}
}

82
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

@ -29,12 +29,13 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserResiInfoFormDTO;
import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.form.UserRoleFormDTO;
import com.epmet.constant.ReadFlagConstant;
import com.epmet.dto.form.*;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.modules.feign.EpmetMessageFeignClient;
import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.feign.GovOrgFeignClient;
import com.epmet.modules.group.dao.ResiGroupDao;
import com.epmet.modules.group.dao.ResiGroupOperationDao;
import com.epmet.modules.group.entity.ResiGroupEntity;
@ -66,6 +67,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sun.security.pkcs11.Secmod;
import java.text.SimpleDateFormat;
import java.util.*;
@ -110,6 +112,11 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
@Autowired
private ResiGroupMemberRedis resiGroupMemberRedis;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private EpmetMessageFeignClient epmetMessageFeignClient;
@Override
@ -383,6 +390,8 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
resiGroupStatisticalDTO.setTotalEarnestMemebers(NumConstant.ZERO);
}
resiGroupStatisticalService.save(resiGroupStatisticalDTO);
//发送消息:创建小组
sendMsgResi2Gov(ModuleConstant.CREATE_GROUP_APPLYING_MSG_TITLE,msg,applyCreateGroupFormDTO.getGridId(),applyCreateGroupFormDTO.getUserId(),applyCreateGroupFormDTO.getCustomerId());
return new Result();
}
@ -533,7 +542,16 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
*/
logger.warn(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO);
}
//发送消息
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO();
userMessageFormDTO.setUserId(resiGroupDTO.getCreatedBy());
userMessageFormDTO.setTitle(ModuleConstant.AUDITED_GROUP_APPLYING_TITLE);
userMessageFormDTO.setReadFlag(ModuleConstant.UNREAD);
userMessageFormDTO.setApp(ModuleConstant.APP_RESI);
userMessageFormDTO.setGridId(resiGroupDTO.getGridId());
userMessageFormDTO.setCustomerId(resiGroupDTO.getCustomerId());
userMessageFormDTO.setMessageContent(ModuleConstant.AGREE_CREATING_GROUP_MSG);
epmetMessageFeignClient.saveUserMessage(userMessageFormDTO);
return new Result();
}
@ -567,6 +585,15 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
groupMemeberOperationDTO.setOperateUserId(disAgreeApplyGroupFormDTO.getUserId());
groupMemeberOperationService.update(groupMemeberOperationDTO);
//5、给用户发送消息???待定
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO();
userMessageFormDTO.setUserId(resiGroupDTO.getCreatedBy());
userMessageFormDTO.setTitle(ModuleConstant.AUDITED_GROUP_APPLYING_TITLE);
userMessageFormDTO.setReadFlag(ModuleConstant.UNREAD);
userMessageFormDTO.setApp(ModuleConstant.APP_RESI);
userMessageFormDTO.setGridId(resiGroupDTO.getGridId());
userMessageFormDTO.setCustomerId(resiGroupDTO.getCustomerId());
userMessageFormDTO.setMessageContent(String.format(ModuleConstant.DISAGREE_CREATING_GROUP_MSG,resiGroupDTO.getGroupName(),disAgreeApplyGroupFormDTO.getRejectReason()));
epmetMessageFeignClient.saveUserMessage(userMessageFormDTO);
return new Result();
}
@ -752,5 +779,52 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
return new Result<ApplyingGroupDetailResultDTO>().ok(detail);
}
/**
* @Description 给加入此网格的管理员发送消息
* @param msg
* @param gridId
* @param userId
* @author wangc
* @date 2020.04.29 22:49
**/
private void sendMsgResi2Gov(String title,String msg,String gridId,String userId,String customerId){
//1.查询加入当前网格下的人员 customer_staff_grid
CommonGridIdFormDTO commonGridIdFormDTO = new CommonGridIdFormDTO();
commonGridIdFormDTO.setGridId(gridId);
commonGridIdFormDTO.setUserId(userId);
Result<List<String>> gridstaffs =
govOrgFeignClient.getGridStaffs(commonGridIdFormDTO);
//2.查询这些人是否有管理员身份且未被禁用 staff_role customer_staff
if(gridstaffs.success() && null != gridstaffs.getData() && gridstaffs.getData().size() > 0){
RolesUsersListFormDTO rolesUsersListFormDTO = new RolesUsersListFormDTO();
rolesUsersListFormDTO.setCustomerId(customerId);
List<String> roleKeys = new ArrayList<String>();
roleKeys.add(ModuleConstant.STAFF_ROLE_MANAGER);
rolesUsersListFormDTO.setRoleKeys(roleKeys);
rolesUsersListFormDTO.setUserIds(gridstaffs.getData());
Result<List<String>> staffRoles =
epmetUserFeignClient.specificRolesStaffs(rolesUsersListFormDTO);
//3.发送消息
if(staffRoles.success() && null != staffRoles.getData() && staffRoles.getData().size() > 0){
List<UserMessageFormDTO> msgList = new ArrayList<>();
for(String to : staffRoles.getData()){
UserMessageFormDTO msgObj = new UserMessageFormDTO();
msgObj.setApp(ModuleConstant.APP_RESI);
msgObj.setCustomerId(customerId);
msgObj.setGridId(gridId);
msgObj.setMessageContent(msg);
msgObj.setReadFlag(ReadFlagConstant.UN_READ);
msgObj.setTitle(title);
msgObj.setUserId(to);
msgList.add(msgObj);
}
Result result = epmetMessageFeignClient.saveUserMessageList(msgList);
if(!result.success()){
logger.warn(String.format(ModuleConstant.FAILED_SEND_MESSAGE,msg));
}
}
}
}
}

30
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java

@ -229,4 +229,34 @@ public interface ModuleConstant extends Constant {
* 申请组时的消息模板
*/
String CREATION_OF_GROUP_MESSAGE_TEMPLATE = "%s%s申请创建小组【%s】,请审核。";
/**
* 工作人员角色key管理员
* */
String STAFF_ROLE_MANAGER = "manager";
/**
* 消息发送失败
*/
String FAILED_SEND_MESSAGE = "消息发送失败,消息内容:【%s】";
/**
* 申请建组消息名称
* */
String CREATE_GROUP_APPLYING_MSG_TITLE = "您有一条建组申请消息";
/**
* 建组审核驳回时消息模板
* */
String DISAGREE_CREATING_GROUP_MSG = "您好,您申请的%s小组,由于不符合%s条件的原因,已被驳回。";
/**
* 建组审核同意时消息模板
* */
String AGREE_CREATING_GROUP_MSG = "您好,您申请的%s小组已通过。";
/**
* 审核建组申请消息名称
* */
String AUDITED_GROUP_APPLYING_TITLE = "您有一条建组审核消息";
}

32
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/RolesUsersListFormDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 特定的角色 特定的员工
* @ClassName RolesUsersListFormDTO
* @Auth wangc
* @Date 2020-04-29 23:40
*/
@Data
public class RolesUsersListFormDTO implements Serializable {
private static final long serialVersionUID = -7375096282690016010L;
/**
* 客户Id
* */
private String CustomerId;
/**
* 角色列表
* */
private List<String> roleKeys;
/**
* 人员Id列表
*/
private List<String> userIds;
}

12
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java

@ -7,6 +7,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.RolesUsersListFormDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.StaffRolesResultDTO;
@ -88,4 +89,15 @@ public class StaffRoleController {
ValidatorUtils.validateEntity(commonUserFormDTO);
return staffRoleService.getStaffRoles(commonUserFormDTO);
}
/**
* @Description 查找具有特定角色的人员Id(可用)
* @param rolesUsersListFormDTO
* @author wangc
* @date 2020.04.29 23:49
**/
@PostMapping("specificrolesstaffs")
public Result<List<String>> specificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO){
return staffRoleService.getSpecificRolesStaffs(rolesUsersListFormDTO);
}
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java

@ -66,4 +66,14 @@ public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
//@DataFilter(tableAliases = { "role" })
StaffRolesResultDTO getStaffRoles(CommonUserFormDTO commonUserFormDTO);
/**
* @Description 查询特定身份的员工Id
* @param roleKeys
* @param userIds
* @param customerId
* @author wangc
* @date 2020.04.29 23:38
**/
List<String> selectSpecificRolesStaffs(@Param("roleKeys")List<String> roleKeys,@Param("userIds")List<String> userIds,@Param("customerId")String customerId);
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java

@ -23,6 +23,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.RolesUsersListFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.StaffRolesResultDTO;
import com.epmet.entity.StaffRoleEntity;
@ -120,4 +121,13 @@ public interface StaffRoleService extends BaseService<StaffRoleEntity> {
* @Date 2020.04.26 10:59
**/
Result<StaffRolesResultDTO> getStaffRoles(CommonUserFormDTO userParam);
/**
* @Description 查找具有特定角色的人员Id(可用)
* @param rolesUsersListFormDTO
* @return Result<String>
* @author wangc
* @date 2020.04.29 23:44
**/
Result<List<String>> getSpecificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO);
}

21
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.annotation.DataFilter;
import com.epmet.commons.mybatis.entity.DataScope;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
@ -29,6 +30,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.StaffRoleDao;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.RolesUsersListFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.StaffRolesResultDTO;
import com.epmet.entity.StaffRoleEntity;
@ -39,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -136,4 +139,22 @@ public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRol
return new Result<StaffRolesResultDTO>().ok(baseDao.getStaffRoles(userParam));
}
/**
* @Description 查找具有特定角色的人员Id(可用)
* @param rolesUsersListFormDTO
* @return Result<String>
* @author wangc
* @date 2020.04.29 23:44
**/
@Override
public Result<List<String>> getSpecificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO) {
if(null != rolesUsersListFormDTO.getRoleKeys() && null != rolesUsersListFormDTO.getUserIds()
&& rolesUsersListFormDTO.getRoleKeys().size() > NumConstant.ZERO
&& rolesUsersListFormDTO.getUserIds().size() > NumConstant.ZERO){
return new Result<List<String>>().ok(
baseDao.selectSpecificRolesStaffs(rolesUsersListFormDTO.getRoleKeys(),rolesUsersListFormDTO.getUserIds(),rolesUsersListFormDTO.getCustomerId()));
}
return new Result<List<String>>().ok(new ArrayList<>());
}
}

34
epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

@ -68,4 +68,38 @@
AND staff.USER_ID = #{userId}
AND staff.CUSTOMER_ID = #{customerId}
</select>
<!-- 查询具有特定角色的工作人员Id -->
<select id="selectSpecificRolesStaffs" resultType="string">
SELECT
staffrole.STAFF_ID
FROM
`staff_role` staffrole
LEFT JOIN `customer_staff` staff ON staffrole.STAFF_ID = staff.USER_ID
LEFT JOIN `gov_staff_role` role ON staffrole.ROLE_ID = ROLE.ID
<where>
staffrole.DEL_FLAG = '0'
AND staff.DEL_FLAG = '0'
AND role.DEL_FLAG = '0'
AND staff.ENABLE_FLAG = 'enable'
AND staffrole.ROLE_ID IN (
SELECT
ID
FROM
GOV_STAFF_ROLE
WHERE
ROLE_KEY IN
<foreach item="roleKey" collection="rolekeys" open="(" separator="," close=")">
#{rolekey}
</foreach>
AND DEL_FLAG = '0' )
AND staffrole.STAFF_ID IN
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
<if test='null != customerId and "" != customerId'>
AND staff.CUSTOMER_ID = #{customerId}
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save