|
|
@@ -5,11 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
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.Structure; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.entity.*; |
|
|
|
import com.tuoheng.admin.enums.RoleEnum; |
|
|
|
import com.tuoheng.admin.enums.SectionEnum; |
|
|
|
import com.tuoheng.admin.enums.StructureEnum; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.query.StructureQuery; |
|
|
|
import com.tuoheng.admin.service.IStructureService; |
|
|
@@ -51,6 +50,9 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
@Autowired |
|
|
|
private DeptMapper deptMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SectionDeptMapper sectionDeptMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public JsonResult queryPage(StructureQuery query) { |
|
|
@@ -62,13 +64,15 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
if(ObjectUtil.isNull(user)){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//租户id |
|
|
|
String tenantId = user.getTenantId(); |
|
|
|
//获取用户角色 |
|
|
|
Integer roleId = user.getRoleId(); |
|
|
|
IPage<Structure> page = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
IPage<StructureInfoVo> pageData = null; |
|
|
|
//如果是超级管理员,查看所有构造物 |
|
|
|
if(RoleEnum.SUPER_ADMIN.getCode() == roleId){ |
|
|
|
//数据分页 |
|
|
|
IPage<Structure> page = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
pageData = structureMapper.queryPage(page,query); |
|
|
|
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { |
|
|
|
StructureInfoVo structureInfoVo = new StructureInfoVo(); |
|
|
@@ -96,11 +100,44 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
} |
|
|
|
//如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物 |
|
|
|
if(RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId){ |
|
|
|
|
|
|
|
String deptId = user.getDeptId(); |
|
|
|
if (StringUtils.isEmpty(deptId)){ |
|
|
|
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(),StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
//获取当前登录用户对应的部门及子部门 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> deptList = deptMapper.selectAllChildListById(deptId); |
|
|
|
//根据部门列表查对应的部门路段数据列表 |
|
|
|
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() |
|
|
|
.eq(SectionDept::getTenantId, tenantId) |
|
|
|
.in(SectionDept::getDeptId, deptList)); |
|
|
|
//查询对应的路段列表 |
|
|
|
List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).collect(Collectors.toList()); |
|
|
|
if (StringUtils.isEmpty(sectionIdList)) { |
|
|
|
JsonResult.error(SectionEnum.SECTION_ID_IS_NULL.getCode(), SectionEnum.SECTION_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
List<StructureInfoVo> list = new ArrayList<>(); |
|
|
|
//根据路段id查询对应的构造物列表 |
|
|
|
for (String sectionId : sectionIdList) { |
|
|
|
query.setSectionId(sectionId); |
|
|
|
pageData = structureMapper.queryPageBySectionId(page,query); |
|
|
|
List<StructureInfoVo> records = pageData.getRecords(); |
|
|
|
for (StructureInfoVo record : records) { |
|
|
|
//获取构造物图片,对图片进行处理 |
|
|
|
if(StringUtils.isNotEmpty(record.getImageUrl())){ |
|
|
|
String[] imageUrls = record.getImageUrl().split(","); |
|
|
|
if(StringUtils.isNotEmpty(imageUrls)){ |
|
|
|
for (int i = 0; i < imageUrls.length; i++) { |
|
|
|
if(StringUtils.isNotEmpty(imageUrls[i])){ |
|
|
|
imageUrls[i]= CommonConfig.imageURL+imageUrls[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
record.setImageUrl(StringUtils.join(imageUrls,",")); |
|
|
|
} |
|
|
|
list.add(record); |
|
|
|
} |
|
|
|
} |
|
|
|
pageData.setRecords(list); |
|
|
|
} |
|
|
|
|
|
|
|
|