Commit 914a1e04 by 刘鑫

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

2 parents eb7f533c db6db1ee
......@@ -2,6 +2,7 @@ package com.dituhui.pea.enums;
/**
* 错误码枚举类
*
* @author zl
*/
......@@ -38,39 +39,39 @@ public enum StatusCodeEnum {
/**
* 文件不存在
*/
FILE_NOT_EXIST("005", "文件不存在",false),
FILE_NOT_EXIST("005", "文件不存在", false),
/**
* 系统异常
*/
SYSTEM_UNKNOWN_ERROR("006", "系统繁忙,请稍后再试....",false),
SYSTEM_UNKNOWN_ERROR("006", "系统繁忙,请稍后再试....", false),
REQUEST_LIMIT_ERROR("0429","请求超限!", false),
REQUEST_LIMIT_ERROR("0429", "请求超限!", false),
/**
* 没有查询到对应的数据
*/
NO_DATA("007", "没有查询到对应的数据",false),
NO_DATA("007", "没有查询到对应的数据", false),
/**
* 用户不存在
*/
USER_DOES_NOT_EXIST("008","用户不存在", false),
USER_DOES_NOT_EXIST("008", "用户不存在", false),
/**
* 团队不存在
*/
TEAM_DOES_NOT_EXIST("009","团队不存在", false),
TEAM_DOES_NOT_EXIST("009", "团队不存在", false),
/**
* 手机号码已存在
*/
MOBILE_NUMBER_EXISTS("010","手机号码已存在", false),
MOBILE_NUMBER_EXISTS("010", "手机号码已存在", false),
/**
* 账号已存在
*/
ACCOUNT_EXISTS("011", "账号已存在",false),
ACCOUNT_EXISTS("011", "账号已存在", false),
/**
* 邮箱已存在
......@@ -80,17 +81,17 @@ public enum StatusCodeEnum {
/**
* 用户已存在团队中,不能重复添加
*/
USER_ALREADY_EXISTS_TEAM("013","用户已存在团队中,不能重复添加",false),
USER_ALREADY_EXISTS_TEAM("013", "用户已存在团队中,不能重复添加", false),
/**
* 角色不存在
*/
ROLE_DOES_NOT_EXIST("014","角色不存在", false),
ROLE_DOES_NOT_EXIST("014", "角色不存在", false),
/**
* 角色资源为空
*/
ROLE_RESOURCE_EMPTY("015","角色资源为空!", false),
ROLE_RESOURCE_EMPTY("015", "角色资源为空!", false),
/**
* 权限资源不存在
......@@ -100,12 +101,12 @@ public enum StatusCodeEnum {
/**
* 角色中已存在该资源,不能重复添加
*/
RESOURCE_ALREADY_EXISTS_ROLE("017","角色中已存在该资源,不能重复添加", false),
RESOURCE_ALREADY_EXISTS_ROLE("017", "角色中已存在该资源,不能重复添加", false),
/**
* 用户状态异常或已被禁用
*/
USER_ISBAN_OR_ERROR("018","用户状态异常或已被禁用", false),
USER_ISBAN_OR_ERROR("018", "用户状态异常或已被禁用", false),
GIS_EXISTS("001", "已存在", false),
......@@ -117,8 +118,13 @@ public enum StatusCodeEnum {
GIS_AREA_SMALL("005", "对象操作后面积过小", false),
GIS_AREA_TOPOLOGY("006", "拓扑处理出错", false)
;
GIS_AREA_TOPOLOGY("006", "拓扑处理出错", false),
USER_PHONE_ERROR("019", "手机号格式有误", false),
USER_EMAIL_ERROR("020", "邮箱格式有误", false),
USER_ORG_NULL_ERROR("021", "组织结构异常或为空", false);
/**
* 状态码
......
......@@ -16,4 +16,9 @@ public class OrgInfo implements Serializable {
* 机构名称
*/
private String name;
/**
* 组织级别 0:大区 1:分部 2:站点
*/
private Integer orgLevel;
}
......@@ -20,6 +20,28 @@ public class OrderServiceDetailResp {
private OrderDetail reschedulingParams;
private List<KV> items;
/**
* 是否重物搬运(双人上门) 0:否 1:是 默认0
*/
private Integer isMultiple;
/**
* 是否指定某个工程师/是否排除某个工程师 0:否 1:指定 2:排除 默认0
*/
private Integer isAppointEngineer;
/**
* 指定某个工程师/排除某个工程师 codes 多个,分割
*/
private String appointEngineerCodes;
/**
* bean优先级,例如:紧急、正常
*/
private String beanPriority;;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class OrderDetail{
......
......@@ -37,5 +37,21 @@ public class OrderServiceList {
*/
private String beanPriority;
/**
* 是否重物搬运(双人上门) 0:否 1:是 默认0
*/
private Integer isMultiple;
/**
* 是否指定某个工程师/是否排除某个工程师 0:否 1:指定 2:排除 默认0
*/
private Integer isAppointEngineer;
/**
* 指定某个工程师/排除某个工程师 codes 多个,分割
*/
private String appointEngineerCodes;
}
......@@ -59,4 +59,20 @@ public class OrderInfo {
private String description;
private Timestamp createTime;
private Timestamp updateTime;
/**
* 是否重物搬运(双人上门) 0:否 1:是 默认0
*/
private Integer isMultiple;
/**
* 是否指定某个工程师/是否排除某个工程师 0:否 1:指定 2:排除 默认0
*/
private Integer isAppointEngineer;
/**
* 指定某个工程师/排除某个工程师 codes 多个,分割
*/
private String appointEngineerCodes;
}
\ No newline at end of file
......@@ -44,10 +44,10 @@ public class OrderInfoEntity {
private String address;
@Column(name = "x", nullable = false, length = 20)
private String x="0";
private String x = "0";
@Column(name = "y", nullable = false, length = 20)
private String y="0";
private String y = "0";
@Column(name = "bean_brand", nullable = false, length = 20)
private String beanBrand;
......@@ -176,4 +176,25 @@ public class OrderInfoEntity {
private LocalDateTime updateTime = LocalDateTime.now();
// Getters and setters (omitted for brevity)
/**
* 是否重物搬运(双人上门) 0:否 1:是 默认0
*/
@Column(name = "is_multiple")
private Integer isMultiple = 0;
/**
* 是否指定某个工程师/是否排除某个工程师 0:否 1:指定 2:排除 默认0
*/
@Column(name = "is_appoint_engineer")
private Integer isAppointEngineer = 0;
/**
* 指定某个工程师/排除某个工程师 codes 多个,分割
*/
@Column(name = "appoint_engineer_codes")
private String appointEngineerCodes;
}
......@@ -7,6 +7,11 @@ package com.dituhui.pea.order.enums;
public enum OrganizationType {
/**
* 超管
*/
admin("admin"),
/**
* 大区
*/
cluster("cluster"),
......
......@@ -185,7 +185,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
btime = getHourMinute(order.getPlanStartTime(), -order.getArriveElapsed());
etime = getHourMinute(order.getPlanStartTime());
}
tips.add(new LabelValueDTO().setLabel("在途路程").setValue(String.format("%s", order.getArriveDistance())));
tips.add(new LabelValueDTO().setLabel("在途路程").setValue(String.format("%s公里(千米)", order.getArriveDistance())));
tips.add(new LabelValueDTO().setLabel("在途时间").setValue(String.format("%s-%s", btime, etime)));
tips.add(new LabelValueDTO().setLabel("在途耗时").setValue(String.format("%s分钟", order.getArriveElapsed())));
return tips;
......
......@@ -68,6 +68,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setReschedulingParams(detail);
res.setItems(items);
res.setIsMultiple(order.getIsMultiple());
res.setIsAppointEngineer(order.getIsAppointEngineer());
res.setAppointEngineerCodes(order.getAppointEngineerCodes());
res.setBeanPriority(order.getBeanPriority());
return Result.success(res);
}
......@@ -125,12 +130,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>();
for (OrderInfoEntity o : results) {
EngineerInfoEntity eg = egInfo.getOrDefault(o.getEngineerCode(), null);
if(eg == null) {
if (eg == null) {
log.warn("未获得工程师{}基础信息, 订单:{}", o.getEngineerCode(), o.getOrderId());
continue;
}
String skill = egSkill.getOrDefault(o.getEngineerCode(), null);
if(skill == null) {
if (skill == null) {
log.warn("未获得工程师{}基础技能, 订单:{}", o.getEngineerCode(), o.getOrderId());
}
......@@ -192,7 +197,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
if (egCodes.isEmpty()) {
return map;
}
List<EngineerInfoEntity> rows = engineerInfoDao.findByEngineerCodeIn(egCodes);;
List<EngineerInfoEntity> rows = engineerInfoDao.findByEngineerCodeIn(egCodes);
;
for (EngineerInfoEntity row : rows) {
map.put(row.getEngineerCode(), row);
}
......
......@@ -140,6 +140,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
record.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime()));
record.setBeanPriority(o.getBeanPriority());
record.setIsMultiple(o.getIsMultiple());
record.setIsAppointEngineer(o.getIsAppointEngineer());
record.setAppointEngineerCodes(o.getAppointEngineerCodes());
content.add(record);
}
......
......@@ -235,6 +235,18 @@ public class OrganizationServiceImpl implements OrganizationService {
}).collect(Collectors.toList());
}
break;
case admin:
List<OrgClusterEntity> adminCluster = orgClusterDao.findAll();
if (CollectionUtils.isNotEmpty(adminCluster)) {
return adminCluster.stream().map(c -> {
OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setId(c.getClusterId());
organizationDTO.setName(c.getName());
organizationDTO.setType(OrganizationType.cluster.getValue());
return organizationDTO;
}).collect(Collectors.toList());
}
break;
default:
break;
}
......
......@@ -4,9 +4,11 @@ import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import com.dituhui.pea.user.entity.UserEntity;
import org.springframework.data.repository.query.Param;
/**
* 用户表(User)表数据库访问层
......@@ -80,4 +82,14 @@ public interface UserDao extends JpaRepository<UserEntity, String>, JpaSpecifica
*/
List<UserEntity> findByIdIn(List<String> userIds);
/**
* 登录验证
* @param loginname 登录名(手机号、邮箱、用户名)
* @param password 密码
* @return
*/
@Query("select t from UserEntity t where (t.account=:loginname or t.email=:loginname or t.phone=:loginname) and t.password=:password")
public UserEntity findByLoginnameAndPass(@Param("loginname")String loginname, @Param("password")String password);
}
......@@ -21,5 +21,13 @@ public interface UserOrgDao extends JpaRepository<UserOrgEntity, String>, JpaSpe
*/
List<UserOrgEntity> findByUserId(String userId);
/**
* 根据用户id查询
*
* @param orgId
* @return
*/
List<UserOrgEntity> findByOrgId(String orgId);
void deleteByUserId(String userId);
}
......@@ -34,6 +34,14 @@ public interface UserRoleDao extends JpaRepository<UserRoleEntity, String>,
List<UserRoleEntity> findByUserId(String userId);
/**
* 根据用户ID查询
*
* @param userId 用户ID
* @return
*/
List<UserRoleEntity> findByUserIdIn(List<String> userId);
/**
* 根据角色ID和用户ID删除
*
* @param roleId 角色ID
......
......@@ -16,6 +16,7 @@ import com.dituhui.pea.pojo.*;
import com.dituhui.pea.pojo.user.OrgInfo;
import com.dituhui.pea.user.dao.*;
import com.dituhui.pea.user.entity.*;
import com.dituhui.pea.user.utils.LevelUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
......@@ -100,7 +101,7 @@ public class UserService {
UserOrgDao userOrgDao;
public Result<UserLoginDTO> userLogin(String account, String password) {
UserEntity user = userDao.findByAccountAndPassword(account, SecureUtil.md5(password));
UserEntity user = userDao.findByLoginnameAndPass(account, SecureUtil.md5(password));
log.info("{}/{} login", account, password);
if (null == user) {
return Result.failure("鉴权失败");
......@@ -122,10 +123,14 @@ public class UserService {
UserLoginDTO userDTO = BeanUtil.copyProperties(user, UserLoginDTO.class);
// 获取角色
List<UserRoleEntity> userRoles = userRoleDao.findByUserId(user.getId());
if (CollectionUtils.isNotEmpty(userRoles)) {
if (CollectionUtils.isEmpty(userRoles)) {
return userDTO;
}
List<String> ids = userRoles.stream().map(r -> r.getRoleId()).collect(Collectors.toList());
List<RoleEntity> roles = roleDao.findAllById(ids);
if (CollectionUtils.isNotEmpty(roles)) {
if (CollectionUtils.isEmpty(roles)) {
return userDTO;
}
userDTO.setRoles(roles.stream().map(r -> BeanUtil.copyProperties(r, RoleInfo.class))
.collect(Collectors.toList()));
......@@ -139,45 +144,63 @@ public class UserService {
List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids);
log.info("role : {} roleResources:{}", ids, CollectionUtils.isNotEmpty(roleResources));
if (CollectionUtils.isNotEmpty(roleResources)) {
List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId())
.collect(Collectors.toList());
List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId()).collect(Collectors.toList());
resources = resourceDao.findAllById(resourceIds);
}
}
if (CollectionUtils.isNotEmpty(resources)) {
if (CollectionUtils.isEmpty(resources)) {
return userDTO;
}
// 菜单嵌套处理+菜单排序
final Set<String> resourceIds = resources.stream().map(r -> r.getId()).collect(Collectors.toSet());
// 查出一级菜单
List<ResourceInfo> levelOne = resources.stream()
.filter(r -> StringUtils.isEmpty(r.getParentId()) && r.getType() == 1)
.map(r -> BeanUtil.copyProperties(r, ResourceInfo.class)).collect(Collectors.toList());
// 过滤二,三级菜单
for (ResourceInfo resourceInfo : levelOne) {
splitMenuExtra(resourceInfo);
List<ResourceEntity> levelTow = resourceDao.findByParentId(resourceInfo.getId());
List<ResourceInfo> levelTowResourceInfo = levelTow.stream()
// 过滤未配置二级菜单
.filter(r -> resourceIds.contains(r.getId())).map(r -> {
ResourceInfo res = BeanUtil.copyProperties(r, ResourceInfo.class);
splitMenuExtra(res);
return res;
}).collect(Collectors.toList());
resourceInfo.setChildren(levelTowResourceInfo);
// List<ResourceEntity> levelTow = resourceDao.findByParentId(resourceInfo.getId());
List<ResourceEntity> levelTow = resources.stream().filter(e -> StringUtils.isNotBlank(e.getParentId()) && e.getParentId().equals(resourceInfo.getId()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(levelTow)) {
continue;
}
List<ResourceInfo> levelTowConvert = levelTow.stream().map(e -> BeanUtil.copyProperties(e, ResourceInfo.class)).collect(Collectors.toList());
for (ResourceInfo resourceThree : levelTowConvert) {
List<ResourceEntity> levelThree = resources.stream().filter(e -> StringUtils.isNotBlank(e.getParentId()) && e.getParentId().equals(resourceThree.getId())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(levelThree)) {
continue;
}
resourceThree.setChildren(levelThree.stream().map(e -> BeanUtil.copyProperties(e, ResourceInfo.class)).collect(Collectors.toList()));
}
resourceInfo.setChildren(levelTowConvert);
}
levelOne = levelOne.stream().sorted(Comparator.comparing(ResourceInfo::getOrder))
.collect(Collectors.toList());
userDTO.setMenus(levelOne);
// 获取组织架构资源
List<OrganizationDTO> allOrgs = resources.stream().filter(r -> r.getType() == 3).map(r -> {
List<OrganizationDTO> orgs = Lists.newArrayList();
String[] temp = r.getExtra().split("\\|");
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations(temp[0],
Arrays.asList(temp[1].split(",")));
//用户组织机构从关联表获取
List<OrganizationDTO> allOrgs = new ArrayList<>();
// 超管处理,不用配置资源自动拥有所有权限
if (ids.contains(Globals.SUPER_ADMIN_ID)) {
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations("admin", Arrays.asList("admin"));
if (StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) {
orgs = result.getResult();
allOrgs = result.getResult();
}
} else {
List<UserOrgEntity> byUserId = userOrgDao.findByUserId(userDTO.getId());
if (CollectionUtils.isNotEmpty(byUserId)) {
List<String> collect = byUserId.stream().map(UserOrgEntity::getOrgId).collect(Collectors.toList());
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations(LevelUtils.convertOrgLevel(byUserId.get(0).getOrgLevel()), collect);
if (StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) {
allOrgs = result.getResult();
}
}
}
return orgs;
}).flatMap(a -> a.stream()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(allOrgs)) {
// 设置第一个为当前权限等级
for (int i = 0; i < allOrgs.size(); i++) {
......@@ -189,9 +212,6 @@ public class UserService {
}
}
userDTO.setAuths(allOrgs);
}
}
}
return userDTO;
}
......@@ -554,7 +574,7 @@ public class UserService {
if (StringUtils.isNotBlank(userInfo.getPhone())) {
// 校验手机格式是否正确
if (!Validator.isMobile(userInfo.getPhone())) {
return Result.failed(StatusCodeEnum.COMMON_PARAM_ERROR, null);
return Result.failed(StatusCodeEnum.USER_PHONE_ERROR, null);
// throw new BusinessException(StatusCodeEnum.COMMON_PARAM_ERROR);
}
if (checkPhone(userInfo.getPhone(), userInfo.getId())) {
......@@ -566,7 +586,7 @@ public class UserService {
if (StringUtils.isNotBlank(userInfo.getEmail())) {
// 校验邮箱格式是否正确
if (!Validator.isEmail(userInfo.getEmail())) {
return Result.failed(StatusCodeEnum.COMMON_PARAM_ERROR, null);
return Result.failed(StatusCodeEnum.USER_EMAIL_ERROR, null);
// throw new BusinessException(StatusCodeEnum.COMMON_PARAM_ERROR);
}
if (checkEmail(userInfo.getEmail(), userInfo.getId())) {
......@@ -721,20 +741,38 @@ public class UserService {
entityManager.clear();
PageResult<UserInfoSearch> pageResult = new PageResult<>();
String count = "select count(*) ";
String select = "SELECT su.*,sr.name roleName ,sr.id roleId ";
String select = "SELECT su.* ";
String limit = " ORDER BY su.CREATED_TIME DESC limit " + (search.getPage() - 1) * search.getSize() + "," + search.getSize();
StringBuffer querySql = new StringBuffer("from sys_user su left join sys_user_role sur on su.id =sur.user_id left JOIN sys_role sr on sr.id =sur.role_id left join sys_user_org suo on su.id=suo.user_id where 1=1 ");
// StringBuffer querySql = new StringBuffer("from sys_user su left join sys_user_role sur on su.id =sur.user_id left JOIN sys_role sr on sr.id =sur.role_id left join sys_user_org suo on su.id=suo.user_id where 1=1 ");
StringBuffer querySql = new StringBuffer("from sys_user su where 1=1 ");
RoleEntity roleEntity = null;
List<UserRoleEntity> byRoleId = null;
if (StringUtils.isNotBlank(search.getRoleId())) {
querySql.append("and sr.id ='" + search.getRoleId() + "'");
roleEntity = roleDao.findById(search.getRoleId()).orElse(null);
if (ObjectUtil.isNull(roleEntity)) {
return pageResult;
}
byRoleId = userRoleDao.findByRoleId(search.getRoleId());
if (CollectionUtils.isEmpty(byRoleId)) {
return pageResult;
}
List<String> collect = byRoleId.stream().map(UserRoleEntity::getUserId).collect(Collectors.toList());
querySql.append(" and su.id in ('" + String.join("','", collect) + "') ");
}
if (null != search.getSource()) {
querySql.append("and su.source =" + search.getSource() + " ");
querySql.append(" and su.source =" + search.getSource() + " ");
}
if (null != search.getOrgId()) {
querySql.append("and suo.org_id ='" + search.getOrgId() + "'");
// querySql.append("and suo.org_id ='" + search.getOrgId() + "'");
List<UserOrgEntity> byOrgId = userOrgDao.findByOrgId(search.getOrgId());
if (CollectionUtils.isEmpty(byOrgId)) {
return pageResult;
}
List<String> collect = byOrgId.stream().map(UserOrgEntity::getUserId).collect(Collectors.toList());
querySql.append(" and su.id in ('" + String.join("','", collect) + "')");
}
if (null != search.getQueryString()) {
querySql.append("and (su.engineer_code LIKE '%" + search.getQueryString() + "%' or su.nickname like '%" + search.getQueryString() + "%' or su.phone like '%" + search.getQueryString() + "%' or su.email like '%" + search.getQueryString() + "%' )");
querySql.append(" and (su.engineer_code LIKE '%" + search.getQueryString() + "%' or su.nickname like '%" + search.getQueryString() + "%' or su.phone like '%" + search.getQueryString() + "%' or su.email like '%" + search.getQueryString() + "%' )");
}
log.info("countSql:" + (count + querySql.toString()));
BigInteger countNum = (BigInteger) entityManager.createNativeQuery(count + querySql.toString()).getSingleResult();
......@@ -744,13 +782,35 @@ public class UserService {
log.info("selectSql:" + (select + querySql.toString() + limit));
Query query = entityManager.createNativeQuery(select + querySql.toString() + limit);
List<Map<String, Object>> resultList1 = query.getResultList();
// List<Map<String, Object>> resultList1 = query.getResultList();
// log.info("resultList1:" + JSONObject.toJSONString(resultList1));
//将结果转换为Map,返回后的map中的key是数据库表字段,如果用实体接收,使用@JsonAlias设置一下在反序列化时进行映射
query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<Map<String, Object>> resultList = query.getResultList();
// log.info("resultList:" + JSONObject.toJSONString(resultList));
List<UserInfoSearch> list = resultList.stream().map(a -> mapConvertToObject(a)).collect(Collectors.toList());
RoleEntity finalRoleEntity = roleEntity;
List<UserInfoSearch> list = resultList.stream().map(a -> mapConvertToObject(a, finalRoleEntity)).collect(Collectors.toList());
//组装角色信息
if (CollectionUtils.isNotEmpty(list) && CollectionUtils.isEmpty(byRoleId) && StringUtils.isBlank(search.getRoleId())) {
List<String> collect = list.stream().map(UserInfoSearch::getId).collect(Collectors.toList());
List<UserRoleEntity> byUserIdIn = userRoleDao.findByUserIdIn(collect);
if (CollectionUtils.isNotEmpty(byUserIdIn)) {
List<RoleEntity> allById = roleDao.findAllById(byUserIdIn.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toList()));
if (CollectionUtils.isNotEmpty(allById)) {
Map<String, String> roleMap = allById.stream().collect(Collectors.toMap(RoleEntity::getId, RoleEntity::getName));
Map<String, String> userRoleMap = byUserIdIn.stream().collect(Collectors.toMap(UserRoleEntity::getUserId, UserRoleEntity::getRoleId));
for (UserInfoSearch infoSearch : list) {
if (userRoleMap.containsKey(infoSearch.getId())) {
if (roleMap.containsKey(userRoleMap.get(infoSearch.getId()))) {
infoSearch.setRoleId(userRoleMap.get(infoSearch.getId()));
infoSearch.setRoleName(roleMap.get(userRoleMap.get(infoSearch.getId())));
}
}
}
}
}
}
Integer pageInt = countNum.intValue() / search.getSize();
pageResult.setDataList(list);
pageResult.setCurrPage(search.getPage());
......@@ -766,7 +826,7 @@ public class UserService {
* @param map map
* @return r
*/
public static UserInfoSearch mapConvertToObject(Map<String, Object> map) {
public static UserInfoSearch mapConvertToObject(Map<String, Object> map, RoleEntity roleEntity) {
UserInfoSearch search = new UserInfoSearch();
search.setId(map.containsKey("id") && ObjectUtil.isNotEmpty(map.get("id")) ? map.get("id").toString() : null);
search.setAccount(map.containsKey("account") && ObjectUtil.isNotEmpty(map.get("account")) ? map.get("account").toString() : null);
......@@ -777,8 +837,6 @@ public class UserService {
search.setEmail(map.containsKey("email") && ObjectUtil.isNotEmpty(map.get("email")) ? map.get("email").toString() : null);
search.setPhone(map.containsKey("phone") && ObjectUtil.isNotEmpty(map.get("phone")) ? map.get("phone").toString() : null);
search.setEngineerCode(map.containsKey("engineer_code") && ObjectUtil.isNotEmpty(map.get("engineer_code")) ? map.get("engineer_code").toString() : null);
search.setRoleName(map.containsKey("roleName") && ObjectUtil.isNotEmpty(map.get("roleName")) ? map.get("roleName").toString() : null);
search.setRoleId(map.containsKey("roleId") && ObjectUtil.isNotEmpty(map.get("roleId")) ? map.get("roleId").toString() : null);
search.setBan(map.containsKey("ban") && ObjectUtil.isNotEmpty(map.get("ban")) ? Integer.parseInt(map.get("ban").toString()) : null);
search.setCreatedBy(map.containsKey("CREATED_BY") && ObjectUtil.isNotEmpty(map.get("CREATED_BY")) ? map.get("CREATED_BY").toString() : null);
search.setUpdatedBy(map.containsKey("UPDATED_BY") && ObjectUtil.isNotEmpty(map.get("UPDATED_BY")) ? map.get("UPDATED_BY").toString() : null);
......@@ -786,6 +844,10 @@ public class UserService {
search.setCreatedTime(map.containsKey("CREATED_TIME") && ObjectUtil.isNotEmpty(map.get("CREATED_TIME")) ? formatter.format(map.get("CREATED_TIME")) : null);
search.setUpdatedTime(map.containsKey("UPDATED_TIME") && ObjectUtil.isNotEmpty(map.get("UPDATED_TIME")) ? formatter.format(map.get("UPDATED_TIME")) : null);
search.setLastLoginTime(map.containsKey("LAST_LOGIN_TIME") && ObjectUtil.isNotEmpty(map.get("LAST_LOGIN_TIME")) ? formatter.format(map.get("LAST_LOGIN_TIME")) : null);
if (ObjectUtil.isNotNull(roleEntity)) {
search.setRoleName(roleEntity.getName());
search.setRoleId(roleEntity.getId());
}
return search;
}
......@@ -809,9 +871,18 @@ public class UserService {
if (CollectionUtils.isEmpty(byUserId)) {
return orgInfos;
}
byUserId.forEach(e -> {
List<String> collect = byUserId.stream().map(UserOrgEntity::getOrgId).collect(Collectors.toList());
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations(LevelUtils.convertOrgLevel(byUserId.get(0).getOrgLevel()), collect);
if (!StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) {
throw new BusinessException(StatusCodeEnum.USER_ORG_NULL_ERROR);
}
result.getResult().forEach(e -> {
OrgInfo orgInfo = new OrgInfo();
orgInfo.setId(e.getOrgId());
orgInfo.setId(e.getId());
orgInfo.setName(e.getName());
orgInfo.setOrgLevel(byUserId.get(0).getOrgLevel());
orgInfos.add(orgInfo);
});
return orgInfos;
......
package com.dituhui.pea.user.utils;
import cn.hutool.core.util.ObjectUtil;
public class LevelUtils {
/**
* 组织级别转换
*
* @param orgLevel
* @return
*/
public static String convertOrgLevel(Integer orgLevel) {
if (ObjectUtil.isNull(orgLevel)) {
return null;
}
String level = null;
switch (orgLevel) {
case 0:
return level = "cluster";
case 1:
return level = "branch";
case 2:
return level = "group";
}
return level;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!