Commit a29fffcf authored by maoying's avatar maoying

风险点关联巡检点部门,责任人,电话显示修改

parent fa4e9e03
...@@ -4,6 +4,7 @@ package com.yeejoin.amos.fas.business.feign; ...@@ -4,6 +4,7 @@ package com.yeejoin.amos.fas.business.feign;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.vo.Toke; import com.yeejoin.amos.fas.business.vo.Toke;
...@@ -14,11 +15,15 @@ import com.yeejoin.amos.feign.systemctl.Systemctl; ...@@ -14,11 +15,15 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Service("remoteSecurityService") @Service("remoteSecurityService")
public class RemoteSecurityService { public class RemoteSecurityService {
...@@ -214,6 +219,61 @@ public class RemoteSecurityService { ...@@ -214,6 +219,61 @@ public class RemoteSecurityService {
} }
return agencyUserModel; return agencyUserModel;
} }
/**
* 根据用户ids获取用户实体列表
* @param toke
* @param product
* @param appKey
* @param userIds
* @return
*/
public Map<String,AgencyUserModel> getUsersMap(String toke,String product,String appKey,Set<Object> userIds){
List<AgencyUserModel> users = listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, AgencyUserModel> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,v->v, (v1, v2) -> v1));
}
return userMap;
}
/**
* 根据用户ids获取用户名称列表
* @param toke
* @param product
* @param appKey
* @param userIds
* @return
*/
public Map<String,String> getUserRealName(String toke,String product,String appKey,Set<Object> userIds){
List<AgencyUserModel> users = listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, String> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
}
return userMap;
}
/**
* 根据部门ids获取部门名称
* @param toke
* @param product
* @param appKey
* @param depIds
* @return
*/
public Map<Long,String> getDepName(String toke,String product,String appKey,Set<Object> depIds){
List<DepartmentModel> depts = new ArrayList<>();
if(!CollectionUtils.isEmpty(depIds)){
depts = this.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(depIds));
}
Map<Long, String> deptMap = new HashMap<>();
if(depts!=null){
deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
}
return deptMap;
}
//用户id获取用户信息 //用户id获取用户信息
public AgencyUserModel getUserById(String toke,String product,String appKey,String userId) { public AgencyUserModel getUserById(String toke,String product,String appKey,String userId) {
if (userId == null || userId.equals("")) { if (userId == null || userId.equals("")) {
......
...@@ -543,33 +543,25 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -543,33 +543,25 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if(!CollectionUtils.isEmpty(content)){ if(!CollectionUtils.isEmpty(content)){
Set<Object> userIds = content.stream().filter(x -> !StringUtils.isEmpty(x.get("userId"))).map(arg0 -> arg0.get("userId")).collect(Collectors.toSet()); Set<Object> userIds = content.stream().filter(x -> !StringUtils.isEmpty(x.get("userId"))).map(arg0 -> arg0.get("userId")).collect(Collectors.toSet());
Set<Object> deptIds = content.stream().filter(x -> !StringUtils.isEmpty(x.get("deptId"))).map(arg0 -> arg0.get("deptId")).collect(Collectors.toSet()); Set<Object> deptIds = content.stream().filter(x -> !StringUtils.isEmpty(x.get("deptId"))).map(arg0 -> arg0.get("deptId")).collect(Collectors.toSet());
List<AgencyUserModel> users = new ArrayList<>(); Map<String,AgencyUserModel> userMap = new HashMap<>();
if(!CollectionUtils.isEmpty(userIds)){ if(!CollectionUtils.isEmpty(userIds)){
users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds)); userMap = remoteSecurityService.getUsersMap(toke, product, appKey, userIds);
} }
// Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
Map<String, String> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
}
List<DepartmentModel> depts = new ArrayList<>();
if(!CollectionUtils.isEmpty(deptIds)){
depts = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIds));
}
// Map<Long, String > deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
Map<Long, String> deptMap = new HashMap<>(); Map<Long, String> deptMap = new HashMap<>();
if(depts!=null){ if(!CollectionUtils.isEmpty(deptIds)){
deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName)); deptMap = remoteSecurityService.getDepName(toke, product, appKey, deptIds);
} }
// content.forEach(e -> {
// e.put("userName",userMap.get(e.get("userId")));
// e.put("deptName",deptMap.get(e.get("deptId")));
// e.put("tel",userMap.get(String.valueOf(e.get("deptId")+"tel")));
// });
for(int i=0;i<content.size();i++){ for(int i=0;i<content.size();i++){
content.get(i).put("userName",userMap.get(content.get(i).get("userId"))); if(content.get(i).get("userId") !=null && userMap.containsKey(content.get(i).get("userId"))){
content.get(i).put("deptName",deptMap.get(content.get(i).get("deptId"))); AgencyUserModel user = userMap.get(content.get(i).get("userId"));
content.get(i).put("tel",userMap.get(String.valueOf(content.get(i).get("deptId")+"tel"))); content.get(i).put("userName", user.getRealName());
content.get(i).put("tel", user.getMobile());
}
if(content.get(i).get("deptId") !=null && deptMap.containsKey(Long.valueOf(content.get(i).get("deptId").toString()))){
content.get(i).put("deptName", deptMap.get(Long.valueOf(content.get(i).get("deptId").toString())));
}
} }
} }
return new PageImpl<>(content, pageable, total); return new PageImpl<>(content, pageable, total);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment