|
@@ -31,8 +31,10 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author huangyuan
|
|
@@ -232,22 +234,36 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
);
|
|
|
List<MtCompanyUser> mtCompanyUserList = mtCompanyUserPage.getRecords();
|
|
|
if (mtCompanyUserList != null && mtCompanyUserList.size() > 0) {
|
|
|
-
|
|
|
- /** 用户信息区域 **/
|
|
|
+ //用户信息区域
|
|
|
//获取用户id集合
|
|
|
- List<Long> userIdList = ProjectUtils.getAttrList(mtCompanyUserList, "userId", null);
|
|
|
+ List<Long> userIdList = mtCompanyUserList.stream().map(MtCompanyUser::getUserId).collect(Collectors.toList());
|
|
|
Map<Long, UserResponse> userIdToUserResponse = userService.getUserResponseByUserIdList(userIdList);
|
|
|
|
|
|
- /** 角色信息区域 **/
|
|
|
+ // 角色信息区域
|
|
|
//获取用户角色关联关系
|
|
|
Map<Long, Role> userIdToRole = roleService.getUserIdToRoleByUserIdsAndCompanyId(userIdList, mtCompanyUserRequest.getCompanyId());
|
|
|
|
|
|
- /** 操作证信息区域 **/
|
|
|
+ //操作证信息区域
|
|
|
//获取用户操作证信息
|
|
|
List<LiftCertificate> liftCertificateList = projectService.getLiftCertificateList(new ProjectUser(mtCompanyUserRequest.getCompanyId(), userIdList));
|
|
|
Map<Long, LiftCertificate> userIdToLiftCertificate = ProjectUtils.attrToObjMap(liftCertificateList, "userId", null);
|
|
|
|
|
|
- /** 公司用户信息组装区域 **/
|
|
|
+ //关联项目信息
|
|
|
+ List<ProjectUser> projectUserList = projectService.getProjectUserList(new ProjectUserRequest(
|
|
|
+ mtCompanyUserRequest.getCompanyId(), userIdList));
|
|
|
+ Map<Long, List<ProjectUser>> userIdToProjectUserList = new HashMap<>();
|
|
|
+ if (projectUserList != null && projectUserList.size() > 0) {
|
|
|
+ userIdToProjectUserList = projectUserList.stream().collect(Collectors.groupingBy(ProjectUser::getUserId));
|
|
|
+ }
|
|
|
+ //关联电梯信息
|
|
|
+ List<LiftUser> liftUserList = projectService.getLiftUserList(new ProjectUserRequest(
|
|
|
+ mtCompanyUserRequest.getCompanyId(), userIdList));
|
|
|
+ Map<Long, List<LiftUser>> userIdToLiftUserList = new HashMap<>();
|
|
|
+ if (liftUserList != null && liftUserList.size() > 0) {
|
|
|
+ userIdToLiftUserList = liftUserList.stream().collect(Collectors.groupingBy(LiftUser::getLiftId));
|
|
|
+ }
|
|
|
+
|
|
|
+ //公司用户信息组装区域
|
|
|
//组装公司用户信息
|
|
|
for (MtCompanyUser mtCompanyUser : mtCompanyUserList) {
|
|
|
MtCompanyUserResponse mtCompanyUserResponse = new MtCompanyUserResponse();
|
|
@@ -274,6 +290,24 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
if (liftCertificate != null) {
|
|
|
mtCompanyUserResponse.setCertificateStatus(liftCertificate.getStatus());
|
|
|
}
|
|
|
+ //设置用户关联的项目数
|
|
|
+ if (userIdToProjectUserList.size() > 0) {
|
|
|
+ List<ProjectUser> projectUsers = userIdToProjectUserList.get(mtCompanyUser.getUserId());
|
|
|
+ long projectNum = 0L;
|
|
|
+ if (projectUsers != null) {
|
|
|
+ projectNum = projectUsers.size();
|
|
|
+ }
|
|
|
+ mtCompanyUserResponse.setConnectedProjectNum(projectNum);
|
|
|
+ }
|
|
|
+ //设置用户关联的电梯数量
|
|
|
+ if (userIdToLiftUserList.size() > 0) {
|
|
|
+ List<LiftUser> liftUsers = userIdToLiftUserList.get(mtCompanyUser.getUserId());
|
|
|
+ long liftNum = 0L;
|
|
|
+ if(liftUsers != null) {
|
|
|
+ liftNum = liftUsers.size();
|
|
|
+ }
|
|
|
+ mtCompanyUserResponse.setConnectedProjectNum(liftNum);
|
|
|
+ }
|
|
|
mtCompanyUserResponseList.add(mtCompanyUserResponse);
|
|
|
}
|
|
|
}
|