Browse Source

修改租户权限

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
e00517d97b
8 changed files with 68 additions and 106 deletions
  1. +3
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java
  2. +6
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionByIdService.java
  3. +5
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionDetailsByIdService.java
  4. +3
    -30
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java
  5. +0
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/query/QueryReportPageListService.java
  6. +47
    -45
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/structure/StructureServiceImpl.java
  7. +4
    -9
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/StructureMapper.xml
  8. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml

+ 3
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java View File

return JsonResult.error(AddDeptCodeEnum.ADD_DEPT_IS_FAILED.getCode(), AddDeptCodeEnum.ADD_DEPT_IS_FAILED.getMsg()); return JsonResult.error(AddDeptCodeEnum.ADD_DEPT_IS_FAILED.getCode(), AddDeptCodeEnum.ADD_DEPT_IS_FAILED.getMsg());
} }


this.updateSuperAdminUser(userId, dept);
this.updateSuperAdminUser(userId, tenantId, dept);


// 新增公路/路段与部门数据 // 新增公路/路段与部门数据
addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList()); addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList());
/** /**
* 如果创建的是顶级部门,将该部门与超级管理员关联 * 如果创建的是顶级部门,将该部门与超级管理员关联
*/ */
private void updateSuperAdminUser(String userId, Dept dept) {
private void updateSuperAdminUser(String userId, String tenantId, Dept dept) {
if (!SystemConstant.ROOT_DEPT_PID.equals(dept.getPid())) { if (!SystemConstant.ROOT_DEPT_PID.equals(dept.getPid())) {
return; return;
} }
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getRoleId, 1) .eq(User::getRoleId, 1)
.eq(User::getMark, 1)); .eq(User::getMark, 1));
if (CollectionUtils.isEmpty(userList)) { if (CollectionUtils.isEmpty(userList)) {

+ 6
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionByIdService.java View File

import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum;
import com.tuoheng.admin.mapper.InspectionHistoryMapper; import com.tuoheng.admin.mapper.InspectionHistoryMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils; import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Autowired @Autowired
private InspectionMapper inspectionMapper; private InspectionMapper inspectionMapper;


@Autowired
private InspectionHistoryMapper inspectionHistoryMapper;

public JsonResult getInspectionInfo(String id) { public JsonResult getInspectionInfo(String id) {
log.info("进入查询巡检任务信息业务"); log.info("进入查询巡检任务信息业务");
JsonResult result = this.check(id);
String tenantId = CurrentUserUtil.getTenantId();
JsonResult result = this.check(tenantId, id);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("进入查询巡检任务信息业务:校验失败:{}", result.getMsg()); log.info("进入查询巡检任务信息业务:校验失败:{}", result.getMsg());
return result; return result;


/** /**
* 检查参数 * 检查参数
*
* @param id * @param id
* @return * @return
*/ */
private JsonResult check(String id) {
private JsonResult check(String tenantId, String id) {
// 判断任务id是否为空 // 判断任务id是否为空
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
} }

// 判断任务是否存在 // 判断任务是否存在
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getId, id) .eq(Inspection::getId, id)
.eq(Inspection::getMark, 1)); .eq(Inspection::getMark, 1));

if (null == inspection) { if (null == inspection) {
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg()); return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
} }

+ 5
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionDetailsByIdService.java View File

import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnum;
import com.tuoheng.admin.mapper.InspectionHistoryMapper; import com.tuoheng.admin.mapper.InspectionHistoryMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.inspection.InspectionDetailsVo; import com.tuoheng.admin.vo.inspection.InspectionDetailsVo;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils; import com.tuoheng.common.core.utils.StringUtils;


public JsonResult getInspectionDetails(String id) { public JsonResult getInspectionDetails(String id) {
log.info("进入查询巡检任务详情业务"); log.info("进入查询巡检任务详情业务");
JsonResult result = this.check(id);
String tenantId = CurrentUserUtil.getTenantId();
JsonResult result = this.check(tenantId, id);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg()); log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg());
return result; return result;
* @param id * @param id
* @return * @return
*/ */
private JsonResult check(String id) {
private JsonResult check(String tenantId, String id) {
// 判断任务id是否为空 // 判断任务id是否为空
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); return JsonResult.error(QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg());


// 判断任务是否存在 // 判断任务是否存在
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getId, id) .eq(Inspection::getId, id)
.eq(Inspection::getMark, 1)); .eq(Inspection::getMark, 1));



+ 3
- 30
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java View File

@Override @Override
public JsonResult getQuestionList() { public JsonResult getQuestionList() {
//获取当前登录人租户id //获取当前登录人租户id
String username = SecurityUserUtils.username();
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getMark, 1)
.eq(User::getStatus,1)
.eq(User::getUsername, username));
if(ObjectUtil.isNull(user)){
return null;
}
if(StringUtils.isEmpty(user.getTenantId())){
return JsonResult.error(ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getMsg());
}
//租户id
String tenantId = user.getTenantId();
String tenantId = CurrentUserUtil.getTenantId();
//查询区域范范围问题 //查询区域范范围问题
List<InspectionFile> inspectionFileLists = new ArrayList<>(); List<InspectionFile> inspectionFileLists = new ArrayList<>();
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()


@Override @Override
public JsonResult getListByDeptUserType(InspectionFileQuery query) { public JsonResult getListByDeptUserType(InspectionFileQuery query) {
// if(query.getUserId()==null){
// JsonResult.error(ListByDeptUserTypeEnum.QUERY_IS_FAILED.getCode(),ListByDeptUserTypeEnum.QUERY_IS_FAILED.getMsg());
// }
//获取当前登录人信息
String username = SecurityUserUtils.username();
if(StringUtils.isEmpty(username)){
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg());
}
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getMark, 1)
.eq(User::getStatus,1)
.eq(User::getUsername, username));
if(ObjectUtil.isNull(user)){
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg());
}
String tenantId = CurrentUserUtil.getTenantId();
User user = CurrentUserUtil.getUserInfo();
//用户角色判断 1超级管理员 2部门管理员 3普通用户 //用户角色判断 1超级管理员 2部门管理员 3普通用户
if(null == user.getRoleId()){ if(null == user.getRoleId()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
//直接查问题列表 //直接查问题列表
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()
.eq(InspectionFile::getMark, 1) .eq(InspectionFile::getMark, 1)
.eq(InspectionFile::getTenantId, tenantId)
.eq(InspectionFile::getTenantId, user.getTenantId())
.in(InspectionFile::getStatus,20,25)); .in(InspectionFile::getStatus,20,25));
//根据状态类型分类 //根据状态类型分类
if(null == inspectionFileList){ if(null == inspectionFileList){

+ 0
- 10
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/query/QueryReportPageListService.java View File

return result; return result;
} }


User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getId, userId)
.eq(User::getMark, 1));

Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, user.getDeptId())
.eq(Dept::getMark, 1));

// 设置分页参数 // 设置分页参数
IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); IPage<Report> page = new Page<>(request.getPage(), request.getLimit());
// 用户只能查看自己生成的报告 // 用户只能查看自己生成的报告

+ 47
- 45
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/structure/StructureServiceImpl.java View File

import com.tuoheng.admin.enums.StructureEnum; import com.tuoheng.admin.enums.StructureEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.query.StructureQuery; import com.tuoheng.admin.query.StructureQuery;
import com.tuoheng.admin.service.structure.IStructureService;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.StructureInfoVo; import com.tuoheng.admin.vo.StructureInfoVo;
import com.tuoheng.common.core.common.BaseServiceImpl; import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.config.common.CommonConfig; import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.enums.ServiceExceptionEnum; import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.*;
import com.tuoheng.common.core.utils.CommonUtils;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Autowired @Autowired
private SectionDeptMapper sectionDeptMapper; private SectionDeptMapper sectionDeptMapper;



@Override @Override
public JsonResult queryPage(StructureQuery query) { public JsonResult queryPage(StructureQuery query) {
if(null==(query.getPage()) && null == query.getLimit()){
if (null == (query.getPage()) && null == query.getLimit()) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//获取登录信息 //获取登录信息
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
if(ObjectUtil.isNull(user)){
if (ObjectUtil.isNull(user)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//租户id //租户id
String tenantId = user.getTenantId(); String tenantId = user.getTenantId();
query.setTenantId(tenantId); query.setTenantId(tenantId);

//获取用户角色 //获取用户角色
Integer roleId = user.getRoleId(); Integer roleId = user.getRoleId();
IPage<Structure> page = new Page<>(query.getPage(),query.getLimit());
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit());
IPage<StructureInfoVo> pageData = null; IPage<StructureInfoVo> pageData = null;
//如果是超级管理员,查看所有构造物 //如果是超级管理员,查看所有构造物
if(RoleEnum.SUPER_ADMIN.getCode() == roleId){
//query.setTenantId(tenantId);
if (RoleEnum.SUPER_ADMIN.getCode() == roleId) {
//数据分页 //数据分页
pageData = structureMapper.queryPage(page,query);
pageData = structureMapper.queryPage(page, query);
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> {
StructureInfoVo structureInfoVo = new StructureInfoVo(); StructureInfoVo structureInfoVo = new StructureInfoVo();
BeanUtils.copyProperties(item, structureInfoVo); BeanUtils.copyProperties(item, structureInfoVo);
//获取构造物图片,对图片进行处理 //获取构造物图片,对图片进行处理
if(StringUtils.isNotEmpty(item.getImageUrl())){
if (StringUtils.isNotEmpty(item.getImageUrl())) {
String[] imageUrls = item.getImageUrl().split(","); String[] imageUrls = item.getImageUrl().split(",");
if(StringUtils.isNotEmpty(imageUrls)){
if (StringUtils.isNotEmpty(imageUrls)) {
for (int i = 0; i < imageUrls.length; i++) { for (int i = 0; i < imageUrls.length; i++) {
if(StringUtils.isNotEmpty(imageUrls[i])){
imageUrls[i]= CommonConfig.imageURL+imageUrls[i];
if (StringUtils.isNotEmpty(imageUrls[i])) {
imageUrls[i] = CommonConfig.imageURL + imageUrls[i];
} }
} }
} }
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,","));
structureInfoVo.setImageUrl(StringUtils.join(imageUrls, ","));
} }
// if (StringUtils.isNotEmpty(item.getImageUrl())) { // if (StringUtils.isNotEmpty(item.getImageUrl())) {
// String imageUrl = getMultipleUrl(item.getImageUrl()); // String imageUrl = getMultipleUrl(item.getImageUrl());


} }
//如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物 //如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物
if(RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId){
if (RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId) {
String deptId = user.getDeptId(); String deptId = user.getDeptId();
if (StringUtils.isEmpty(deptId)){
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(),StructureEnum.DEPT_IS_NOT_EXIST.getMsg());
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<String> deptList = deptMapper.selectAllChildListById(deptId);
if(StringUtils.isEmpty(deptList) && deptList.size()<=0){
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(),SectionEnum.DEPT_ID_IS_NULL.getMsg());
if (StringUtils.isEmpty(deptList) && deptList.size() <= 0) {
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg());
} }
//根据部门列表查对应的部门路段数据列表 //根据部门列表查对应的部门路段数据列表
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery()
.eq(SectionDept::getTenantId, tenantId) .eq(SectionDept::getTenantId, tenantId)
.in(SectionDept::getDeptId, deptList)); .in(SectionDept::getDeptId, deptList));
if(StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size()<=0){
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(),SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg());
if (StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size() <= 0) {
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg());
} }
//查询对应的路段列表 //查询对应的路段列表
List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).distinct().collect(Collectors.toList()); List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).distinct().collect(Collectors.toList());
//根据路段id查询对应的构造物列表 //根据路段id查询对应的构造物列表
for (String sectionId : sectionIdList) { for (String sectionId : sectionIdList) {
query.setSectionId(sectionId); query.setSectionId(sectionId);
pageData = structureMapper.queryPageBySectionId(page,query);
pageData = structureMapper.queryPageBySectionId(page, query);
List<StructureInfoVo> records = pageData.getRecords(); List<StructureInfoVo> records = pageData.getRecords();
for (StructureInfoVo record : records) { for (StructureInfoVo record : records) {
//获取构造物图片,对图片进行处理 //获取构造物图片,对图片进行处理
if(StringUtils.isNotEmpty(record.getImageUrl())){
if (StringUtils.isNotEmpty(record.getImageUrl())) {
String[] imageUrls = record.getImageUrl().split(","); String[] imageUrls = record.getImageUrl().split(",");
if(StringUtils.isNotEmpty(imageUrls)){
if (StringUtils.isNotEmpty(imageUrls)) {
for (int i = 0; i < imageUrls.length; i++) { for (int i = 0; i < imageUrls.length; i++) {
if(StringUtils.isNotEmpty(imageUrls[i])){
imageUrls[i]= CommonConfig.imageURL+imageUrls[i];
if (StringUtils.isNotEmpty(imageUrls[i])) {
imageUrls[i] = CommonConfig.imageURL + imageUrls[i];
} }
} }
} }
record.setImageUrl(StringUtils.join(imageUrls,","));
record.setImageUrl(StringUtils.join(imageUrls, ","));
} }
list.add(record); list.add(record);
} }
public JsonResult editInfo(Structure entity) { public JsonResult editInfo(Structure entity) {
//获取登录信息 //获取登录信息
String userId = CurrentUserUtil.getUserId(); String userId = CurrentUserUtil.getUserId();
if(StringUtils.isEmpty(userId)){
JsonResult.error(StructureEnum.USER_ID_IS_NULL.getCode(),StructureEnum.USER_ID_IS_NULL.getMsg());
if (StringUtils.isEmpty(userId)) {
JsonResult.error(StructureEnum.USER_ID_IS_NULL.getCode(), StructureEnum.USER_ID_IS_NULL.getMsg());
} }


//校验 //校验
if(StringUtils.isEmpty(entity.getRoadId()) && StringUtils.isEmpty(entity.getSectionId())){
if (StringUtils.isEmpty(entity.getRoadId()) && StringUtils.isEmpty(entity.getSectionId())) {
return JsonResult.error("公路和路段为空"); return JsonResult.error("公路和路段为空");
} }
//获取租户id //获取租户id
String tenantId = CurrentUserUtil.getTenantId(); String tenantId = CurrentUserUtil.getTenantId();
//查询用户信息 //查询用户信息
if(StringUtils.isEmpty(entity.getId())){
if (StringUtils.isEmpty(entity.getId())) {
//新增 //新增
entity.setCreateTime(DateUtils.now()); entity.setCreateTime(DateUtils.now());
entity.setCreateUser(userId); entity.setCreateUser(userId);
entity.setTenantId(tenantId); entity.setTenantId(tenantId);
}else {
} else {
//更新 //更新
entity.setUpdateTime(DateUtils.now()); entity.setUpdateTime(DateUtils.now());
entity.setUpdateUser(userId); entity.setUpdateUser(userId);


/** /**
* 当前登录人对应的公路所属的构造物 * 当前登录人对应的公路所属的构造物
*
* @return * @return
*/ */
@Override @Override
public JsonResult getSectionInfo() { public JsonResult getSectionInfo() {
//获取登录信息 //获取登录信息
String tenantId = CurrentUserUtil.getTenantId(); String tenantId = CurrentUserUtil.getTenantId();
if(StringUtils.isEmpty(tenantId)){
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(),StructureEnum.TENANT_ID_IS_NULL.getMsg());
if (StringUtils.isEmpty(tenantId)) {
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(), StructureEnum.TENANT_ID_IS_NULL.getMsg());
} }
List<Structure> structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) List<Structure> structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1)
.eq(Structure::getTenantId, tenantId)); .eq(Structure::getTenantId, tenantId));
if(null == structures){
if (null == structures) {
return JsonResult.error(); return JsonResult.error();
} }
List<StructureInfoVo> list = new ArrayList<>(); List<StructureInfoVo> list = new ArrayList<>();
for (Structure structure : structures) { for (Structure structure : structures) {
StructureInfoVo structureInfoVo = new StructureInfoVo(); StructureInfoVo structureInfoVo = new StructureInfoVo();
BeanUtils.copyProperties(structure,structureInfoVo);
BeanUtils.copyProperties(structure, structureInfoVo);
//设置图片 //设置图片
if(StringUtils.isNotEmpty(structure.getImageUrl())){
if (StringUtils.isNotEmpty(structure.getImageUrl())) {
String[] imageUrls = structure.getImageUrl().split(","); String[] imageUrls = structure.getImageUrl().split(",");
if(StringUtils.isNotEmpty(imageUrls)){
if (StringUtils.isNotEmpty(imageUrls)) {
for (int i = 0; i < imageUrls.length; i++) { for (int i = 0; i < imageUrls.length; i++) {
if(StringUtils.isNotEmpty(imageUrls[i])){
imageUrls[i]=CommonConfig.imageURL+imageUrls[i];
if (StringUtils.isNotEmpty(imageUrls[i])) {
imageUrls[i] = CommonConfig.imageURL + imageUrls[i];
} }
} }
} }
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,","));
structureInfoVo.setImageUrl(StringUtils.join(imageUrls, ","));
} }
//根据公路id获取公路code //根据公路id获取公路code
if(StringUtils.isEmpty(structure.getRoadId())){
if (StringUtils.isEmpty(structure.getRoadId())) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
RoadInformation roadInformation = roadInformationMapper.selectById(structure.getRoadId()); RoadInformation roadInformation = roadInformationMapper.selectById(structure.getRoadId());
if(ObjectUtil.isNotNull(roadInformation)){
if (ObjectUtil.isNotNull(roadInformation)) {
structureInfoVo.setCode(roadInformation.getCode()); structureInfoVo.setCode(roadInformation.getCode());
} }
//根据路段id获取路段范围 //根据路段id获取路段范围
if(StringUtils.isEmpty(structure.getSectionId())){
if (StringUtils.isEmpty(structure.getSectionId())) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
Section section = sectionMapper.selectById(structure.getSectionId()); Section section = sectionMapper.selectById(structure.getSectionId());
if(ObjectUtil.isNotNull(section)){
if (ObjectUtil.isNotNull(section)) {
structureInfoVo.setSectionRange(section.getSectionRange()); structureInfoVo.setSectionRange(section.getSectionRange());
} }
list.add(structureInfoVo); list.add(structureInfoVo);

+ 4
- 9
tuoheng-service/tuoheng-admin/src/main/resources/mapper/StructureMapper.xml View File

left JOIN th_section se ON sr.section_id=se.id left JOIN th_section se ON sr.section_id=se.id
left JOIN th_road rd ON sr.road_id=rd.id left JOIN th_road rd ON sr.road_id=rd.id
where sr.mark=1 and se.mark=1 and rd.mark=1 where sr.mark=1 and se.mark=1 and rd.mark=1
<if test="request.structureName !=null and request.structureName !=''">
AND sr.`structure_name` like concat('%',#{request.structureName},'%')
</if>
<if test="request.structureType !=null">
AND sr.structure_type = #{request.structureType}
</if>
<if test="request.roadId !=null">
AND sr.road_id = #{request.roadId}
</if>
<if test="request.structureName !=null and request.structureName !=''"> and sr.`structure_name` like concat('%',#{request.structureName},'%') </if>
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>
<if test="request.structureType !=null"> and sr.structure_type = #{request.structureType} </if>
<if test="request.roadId !=null"> and sr.road_id = #{request.roadId} </if>
ORDER BY ORDER BY
sr.create_time DESC sr.create_time DESC
</select> </select>

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml View File

<select id="selectPageList" parameterType="com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest" resultMap="WorkOrderResult"> <select id="selectPageList" parameterType="com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest" resultMap="WorkOrderResult">
<include refid="selectThWorkOrderVo"/> <include refid="selectThWorkOrderVo"/>
<where> <where>
<if test="1 == 1"> and mark = 1 </if> <if test="1 == 1"> and mark = 1 </if>
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> <if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>
<if test="request.code != null and request.code != 0"> and code = #{request.code} </if> <if test="request.code != null and request.code != 0"> and code = #{request.code} </if>

Loading…
Cancel
Save