Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/v1.1.0^2
chengwang 1 year ago
parent
commit
9ace6249c9
3 changed files with 73 additions and 0 deletions
  1. +9
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/SectionController.java
  2. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/ISectionService.java
  3. +61
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/SectionServiceImpl.java

+ 9
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/SectionController.java View File

@@ -38,6 +38,15 @@ public class SectionController {
return sectionService.getListInfo(query);
}

/**
* 部门管理员或普通用户获取所属部门监管范围路段之和
* @return
*/
@GetMapping("/listByUserType")
public JsonResult getListByUserType(){
return sectionService.getSectionList();
}

/**
* 根据部门id获取该部门下路段信息列表
* @param deptId

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/ISectionService.java View File

@@ -23,4 +23,7 @@ public interface ISectionService extends IBaseService<Section> {
JsonResult editInfo(Section entity);

JsonResult getSectionInfo(String sectionId);

JsonResult getSectionList();

}

+ 61
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/SectionServiceImpl.java View File

@@ -1,15 +1,18 @@
package com.tuoheng.admin.service.section;


import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.RoadInformation;
import com.tuoheng.admin.entity.Section;
import com.tuoheng.admin.entity.SectionDept;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.SectionEnum;
import com.tuoheng.admin.mapper.DeptMapper;
@@ -275,6 +278,64 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section>
return JsonResult.success(sectionInfoVo);
}

@Override
public JsonResult getSectionList() {
//获取当前登录人信息 登录用户名
User user = CurrentUserUtil.getUserInfo();
if(ObjectUtils.isEmpty(user)) {
return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode());
}
String tenantId = CurrentUserUtil.getTenantId();
//超级管理员获取当前租户下全部公路,部门管理员和普通用户显示用户所属部门监管范围路段之和
if(null == user.getRoleId()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//登录用户若为部门管理员或普通用户需要查询所在部门
String deptId = user.getDeptId();
List<Section> list = new ArrayList<>();
List<RoadInformation> roadInformationList = new ArrayList<>();

//超级管理员
if(RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()){
roadInformationList = this.getAllRoadInformationList(tenantId);
return JsonResult.success(roadInformationList);
}

//部门管理员和普通用户
if(RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()){
//对应部门下的路段列表
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>()
.eq(SectionDept::getDeptId, deptId).eq(SectionDept::getTenantId, tenantId));
//获取对应的公路列表
List<String> sectionList = sectionDeptList.stream().map(t -> t.getSectionId()).collect(Collectors.toList());
//获取当前租户当前部门下的路段列表
list = sectionMapper.selectList(Wrappers.<Section>lambdaQuery()
.eq(Section::getTenantId, tenantId)
.eq(Section::getMark, MarkEnum.VALID.getCode())
.in(Section::getId, sectionList));
return JsonResult.success(list);
}

return JsonResult.error(SectionEnum.QUERY_IS_FAILED.getCode());
}


/**
* 如果是顶级部门,则查询所有公路列表
*
* @param tenantId
* @return
*/
private List<RoadInformation> getAllRoadInformationList(String tenantId) {
List<RoadInformation> roadInformationList = roadInformationMapper.selectList(new LambdaQueryWrapper<RoadInformation>()
.eq(RoadInformation::getTenantId, tenantId)
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()));
if (CollectionUtil.isEmpty(roadInformationList)) {
return null;
}
return roadInformationList;
}


private void SectionRelation(Section section) {
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery()

Loading…
Cancel
Save