Browse Source

Merge remote-tracking branch 'origin/dev_grid_patrol' into develop

master
zxc 4 years ago
parent
commit
455c4beb19
  1. 4
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerAgencyUserRoleFormDTO.java
  2. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  3. 4
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  4. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
  5. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java
  6. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java
  7. 54
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java
  8. 8
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

4
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerAgencyUserRoleFormDTO.java

@ -25,6 +25,6 @@ public class CustomerAgencyUserRoleFormDTO implements Serializable {
/**
* 工作人员IDs
*/
@NotNull(message = "工作人员IDS不能为空",groups = CustomerAgencyUserRoleForm.class)
private List<String> staffIds;
@NotBlank(message = "工作人员ID不能为空",groups = CustomerAgencyUserRoleForm.class)
private String staffId;
}

2
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -594,5 +594,5 @@ public interface EpmetUserOpenFeignClient {
* @date 2021/6/15 3:03 下午
*/
@PostMapping("/epmetuser/staffrole/getroles")
Result<List<CustomerAgencyUserRoleDTO>> getRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO);
Result<CustomerAgencyUserRoleDTO> getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO);
}

4
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -405,8 +405,8 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
}
@Override
public Result<List<CustomerAgencyUserRoleDTO>> getRoles(CustomerAgencyUserRoleFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRoles", formDTO);
public Result<CustomerAgencyUserRoleDTO> getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoles", formDTO);
}
}

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

@ -210,8 +210,8 @@ public class StaffRoleController {
* @date 2021/6/15 3:03 下午
*/
@PostMapping("getroles")
public Result<List<CustomerAgencyUserRoleDTO>> getRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO){
public Result<CustomerAgencyUserRoleDTO> getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, CustomerAgencyUserRoleFormDTO.CustomerAgencyUserRoleForm.class);
return new Result<List<CustomerAgencyUserRoleDTO>>().ok(staffRoleService.getRoles(formDTO));
return new Result<CustomerAgencyUserRoleDTO>().ok(staffRoleService.getUserRoles(formDTO));
}
}

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

@ -143,5 +143,5 @@ public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
* @author zxc
* @date 2021/6/15 3:51 下午
*/
List<RoleKeyValueResultDTO> getRolesByDB(@Param("userIds")List<String> userIds);
List<RoleKeyValueResultDTO> getRolesByDB(@Param("userId")String userId);
}

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

@ -173,5 +173,5 @@ public interface StaffRoleService extends BaseService<StaffRoleEntity> {
* @author zxc
* @date 2021/6/15 3:03 下午
*/
List<CustomerAgencyUserRoleDTO> getRoles(CustomerAgencyUserRoleFormDTO formDTO);
CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO);
}

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

@ -211,41 +211,29 @@ public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRol
* @date 2021/6/15 3:03 下午
*/
@Override
public List<CustomerAgencyUserRoleDTO> getRoles(CustomerAgencyUserRoleFormDTO formDTO) {
List<CustomerAgencyUserRoleDTO> result = new ArrayList<>();
List<String> disUserIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(formDTO.getStaffIds())){
List<String> staffIds = formDTO.getStaffIds();
String customerId = formDTO.getCustomerId();
staffIds.forEach(userId -> {
CustomerAgencyUserRoleDTO role = staffRoleRedis.getRole(customerId, userId);
if (null != role){
result.add(role);
}else {
disUserIds.add(userId);
}
});
if (!CollectionUtils.isEmpty(disUserIds)){
List<RoleKeyValueResultDTO> rolesByDB = baseDao.getRolesByDB(disUserIds);
if (!CollectionUtils.isEmpty(rolesByDB)){
Map<String, List<RoleKeyValueResultDTO>> groupByUserId = rolesByDB.stream().collect(Collectors.groupingBy(RoleKeyValueResultDTO::getStaffId));
groupByUserId.forEach((userId,list) -> {
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
dto.setStaffId(list.get(NumConstant.ZERO).getStaffId());
dto.setCustomerId(customerId);
dto.setAgencyId(list.get(NumConstant.ZERO).getOrgId());
Map map = new HashMap(16);
list.forEach(l -> {
map.put(l.getRoleKey(),l.getRoleName());
});
dto.setRoles(map.toString());
staffRoleRedis.setRole(customerId,userId,dto);
result.add(dto);
});
}
public CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) {
String staffId = formDTO.getStaffId();
String customerId = formDTO.getCustomerId();
CustomerAgencyUserRoleDTO role = staffRoleRedis.getRole(customerId, staffId);
if (null != role){
return role;
}else {
List<RoleKeyValueResultDTO> rolesByDB = baseDao.getRolesByDB(staffId);
if (!CollectionUtils.isEmpty(rolesByDB)) {
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
dto.setStaffId(rolesByDB.get(NumConstant.ZERO).getStaffId());
dto.setCustomerId(customerId);
dto.setAgencyId(rolesByDB.get(NumConstant.ZERO).getOrgId());
Map map = new HashMap(16);
rolesByDB.forEach(l -> {
map.put(l.getRoleKey(), l.getRoleName());
});
dto.setRoles(map.toString());
staffRoleRedis.setRole(customerId, staffId, dto);
return dto;
}
}
return result;
return null;
}
}

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

@ -216,12 +216,8 @@
gsr.ROLE_NAME,
sr.STAFF_ID
FROM staff_role sr
LEFT JOIN gov_staff_role gsr ON gsr.ID = sr.ROLE_ID AND gsr.DEL_FLAG = 0
LEFT JOIN gov_staff_role gsr ON gsr.ID = sr.ROLE_ID AND gsr.DEL_FLAG = 0
WHERE sr.DEL_FLAG = 0
AND (
<foreach collection="userIds" item="userId" separator=" OR ">
sr.STAFF_ID = #{userId}
</foreach>
)
AND sr.STAFF_ID = #{userId}
</select>
</mapper>

Loading…
Cancel
Save