@@ -9,6 +9,7 @@ import com.tuoheng.admin.entity.InspectionFile; | |||
import com.tuoheng.admin.entity.QuestionType; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.SectionEnum; | |||
import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum; | |||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
@@ -24,8 +25,8 @@ import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageLis | |||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListService; | |||
import com.tuoheng.admin.service.inspectionfile.update.UpdateInspectionFileQuestionTypeService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.inspection.InspectionFileVo; | |||
import com.tuoheng.admin.vo.ListByDeptUserTypeVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionFileVo; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
@@ -36,7 +37,6 @@ import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
@@ -105,21 +105,16 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
//获取当前登录人信息 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//获取用户角色 | |||
Integer roleId = user.getDataPermission(); | |||
if(roleId ==null){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//查询区域范范围问题 | |||
List<InspectionFile> inspectionFileLists = new ArrayList<>(); | |||
//超级管理员 | |||
if(DataPermissionEnum.ALL.getCode()==roleId){ | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||
.eq(InspectionFile::getMark, 1) | |||
.eq(InspectionFile::getTenantId, tenantId)); | |||
for (InspectionFile inspectionFile : inspectionFileList) { | |||
//任务状态判断 | |||
if(20 == inspectionFile.getStatus()){ | |||
if (20 == inspectionFile.getStatus()) { | |||
//任务状态判断,已生成工单,问题未解决 | |||
Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId()); | |||
if (ObjectUtil.isNull(inspection)) { | |||
@@ -130,12 +125,30 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
} | |||
//部门管理员及普通用户 本部门的问题 | |||
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()== user.getDataPermission() || DataPermissionEnum.DEPT.getCode()== user.getDataPermission()){ | |||
else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() | |||
|| DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
String deptId = user.getDeptId(); | |||
if (StringUtils.isEmpty(deptId)) { | |||
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
List<String> deptList = new ArrayList<>(); | |||
// 本部门及子部门权限 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
List<String> deptAndSubList = deptMapper.selectAllChildListById(deptId); | |||
if (StringUtils.isEmpty(deptAndSubList) && deptAndSubList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
deptList.addAll(deptAndSubList); | |||
} | |||
// 本部门权限 | |||
else { | |||
deptList.add(deptId); | |||
} | |||
//根据用户查询对应的巡检任务id | |||
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getTenantId, tenantId) | |||
.eq(Inspection::getMark, 1) | |||
.eq(Inspection::getDeptId, user.getDeptId())); | |||
.in(Inspection::getDeptId, deptList)); | |||
//查询对应的问题 | |||
for (Inspection inspection : inspectionList) { | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||
@@ -144,7 +157,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
.eq(InspectionFile::getInspectionId, inspection.getId())); | |||
for (InspectionFile inspectionFile : inspectionFileList) { | |||
//任务状态判断 | |||
if(20 == inspectionFile.getStatus()){ | |||
if (20 == inspectionFile.getStatus()) { | |||
//任务状态判断,已生成工单,问题未解决 | |||
Inspection inspections = inspectionMapper.selectById(inspectionFile.getInspectionId()); | |||
if (ObjectUtil.isNull(inspections)) { | |||
@@ -154,14 +167,13 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
} | |||
} | |||
} | |||
List<InspectionFileVo> list = inspectionFileLists.stream().map(x -> { | |||
InspectionFileVo vo = new InspectionFileVo(); | |||
BeanUtils.copyProperties(x, vo); | |||
//标记图片 | |||
vo.setFileImage(CommonConfig.imageURL+x.getFileImage()); | |||
vo.setFileImage(CommonConfig.imageURL + x.getFileImage()); | |||
//任务名称 | |||
if (StringUtils.isNotEmpty(x.getInspectionId())) { | |||
Inspection inspection = inspectionMapper.selectById(x.getInspectionId()); | |||
@@ -172,8 +184,8 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
//问题类型 | |||
if (StringUtils.isNotEmpty(x.getQuestionCode())) { | |||
QuestionType questionType = questionTypeMapper.selectOne(new LambdaQueryWrapper<QuestionType>() | |||
.eq(QuestionType::getMark, 1) | |||
.eq(QuestionType::getCode, x.getQuestionCode())); | |||
.eq(QuestionType::getMark, 1) | |||
.eq(QuestionType::getCode, x.getQuestionCode())); | |||
if (null != questionType) { | |||
vo.setCode(questionType.getCode()); | |||
vo.setContent(questionType.getContent()); | |||
@@ -191,7 +203,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||
if(null == user.getDataPermission()){ | |||
if (null == user.getDataPermission()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
List<ListByDeptUserTypeVo> list = new ArrayList<>(); | |||
@@ -215,46 +227,46 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
//5块状裂纹 | |||
Integer massiveCrack = 0; | |||
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 | |||
if(DataPermissionEnum.ALL.getCode()==user.getDataPermission()){ | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
//直接查问题列表 | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||
.eq(InspectionFile::getMark, 1) | |||
.eq(InspectionFile::getTenantId, user.getTenantId()) | |||
.in(InspectionFile::getStatus,20,25)); | |||
.in(InspectionFile::getStatus, 20, 25)); | |||
//根据状态类型分类 | |||
if(null == inspectionFileList){ | |||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getCode(),ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getMsg()); | |||
if (null == inspectionFileList) { | |||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getMsg()); | |||
} | |||
for (InspectionFile inspectionFile : inspectionFileList) { | |||
if(StringUtils.isEmpty(inspectionFile.getQuestionCode())){ | |||
JsonResult.error(ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getMsg()); | |||
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) { | |||
JsonResult.error(ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getMsg()); | |||
} | |||
//查找问题类型 | |||
QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | |||
.eq(QuestionType::getMark, 1) | |||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | |||
if(ObjectUtil.isNull(questionType)){ | |||
if (ObjectUtil.isNull(questionType)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Integer name = questionType.getName(); | |||
if(name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
//1横向裂缝 | |||
abeamCrackNum+=1; | |||
}else if(name==QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()){ | |||
abeamCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||
//3网状裂纹 | |||
reticularCrackNum+=1; | |||
}else if(name==QuestionTypeEnum.PIT_GROOVE_NAME.getCode()){ | |||
reticularCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||
//4坑槽 | |||
pitGrooveNum+=1; | |||
}else if(name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()){ | |||
pitGrooveNum += 1; | |||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||
//5块状裂纹 | |||
massiveCrack+=1; | |||
}else if(name == QuestionTypeEnum.PON_DING_NAME.getCode()){ | |||
massiveCrack += 1; | |||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||
//6积水 | |||
ponDingNum+=1; | |||
}else if(name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()){ | |||
ponDingNum += 1; | |||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||
//0纵向裂缝 | |||
longitudinalCrackNum+=1; | |||
longitudinalCrackNum += 1; | |||
} | |||
} | |||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||
@@ -269,62 +281,62 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
vo4.setNum(ponDingNum); | |||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||
vo5.setNum(longitudinalCrackNum); | |||
Collections.addAll(list,vo,vo1,vo2,vo3,vo4,vo5); | |||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||
} | |||
//若角色为部门管理员或普通用户 | |||
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()== user.getDataPermission() || DataPermissionEnum.DEPT.getCode()== user.getDataPermission()){ | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
//获取用户对应的部门 | |||
String deptId = user.getDeptId(); | |||
if(StringUtils.isEmpty(deptId)){ | |||
JsonResult.error(ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getMsg()); | |||
if (StringUtils.isEmpty(deptId)) { | |||
JsonResult.error(ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
//根据部门id获取部门id列表 | |||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||
if(CollectionUtil.isEmpty(deptIdList)){ | |||
if (CollectionUtil.isEmpty(deptIdList)) { | |||
return null; | |||
} | |||
//根据部门id列表查多条任务 | |||
List<Inspection> inspectionList = inspectionMapper.selectListByDeptIdList(deptIdList); | |||
if(null == inspectionList){ | |||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_LIST_IS_NULL.getCode(),ListByDeptUserTypeEnum.INSPECTION_LIST_IS_NULL.getMsg()); | |||
if (null == inspectionList) { | |||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.INSPECTION_LIST_IS_NULL.getMsg()); | |||
} | |||
List<String> inspectionIdList = inspectionList.stream().map(o -> o.getId()).collect(Collectors.toList()); | |||
//根据任务id列表查找多条问题 | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectListByInspectIdList(inspectionIdList); | |||
//根据状态类型分类 | |||
if(null == inspectionFileList){ | |||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getCode(),ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getMsg()); | |||
if (null == inspectionFileList) { | |||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getMsg()); | |||
} | |||
for (InspectionFile inspectionFile : inspectionFileList) { | |||
if(StringUtils.isEmpty(inspectionFile.getQuestionCode())){ | |||
JsonResult.error(ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getMsg()); | |||
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) { | |||
JsonResult.error(ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getMsg()); | |||
} | |||
//查找问题类型 | |||
QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | |||
.eq(QuestionType::getMark, 1) | |||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | |||
if(ObjectUtil.isNull(questionType)){ | |||
if (ObjectUtil.isNull(questionType)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Integer name = questionType.getName(); | |||
if(name==QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
//1横向裂缝 | |||
abeamCrackNum+=1; | |||
}else if(name==QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()){ | |||
abeamCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||
//3网状裂纹 | |||
reticularCrackNum+=1; | |||
}else if(name==QuestionTypeEnum.PIT_GROOVE_NAME.getCode()){ | |||
reticularCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||
//4坑槽 | |||
pitGrooveNum+=1; | |||
}else if(name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()){ | |||
pitGrooveNum += 1; | |||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||
//5块状裂纹 | |||
massiveCrack+=1; | |||
}else if(name == QuestionTypeEnum.PON_DING_NAME.getCode()){ | |||
massiveCrack += 1; | |||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||
//6积水 | |||
ponDingNum+=1; | |||
}else if(name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()){ | |||
ponDingNum += 1; | |||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||
//0纵向裂缝 | |||
longitudinalCrackNum+=1; | |||
longitudinalCrackNum += 1; | |||
} | |||
} | |||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||
@@ -339,7 +351,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
vo4.setNum(ponDingNum); | |||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||
vo5.setNum(longitudinalCrackNum); | |||
Collections.addAll(list,vo,vo1,vo2,vo3,vo4,vo5); | |||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||
} | |||
@@ -352,12 +364,11 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getPageListByInspectionId(QueryInspectionFilePageListByInspectionIdRequest request){ | |||
public JsonResult getPageListByInspectionId(QueryInspectionFilePageListByInspectionIdRequest request) { | |||
return queryInspectionFilePageListByInspectionIdService.getPageListByInspectionId(request); | |||
} | |||
/** | |||
* | |||
* 查询任务问题分页列表 | |||
* | |||
* @param request | |||
@@ -369,7 +380,6 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 确认 | |||
* | |||
* @param idList | |||
@@ -381,7 +391,6 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 忽略 | |||
* | |||
* @param idList | |||
@@ -393,7 +402,6 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 获取任务问题处理结果 | |||
* | |||
* @param id | |||
@@ -405,7 +413,6 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 查询任务问题分布列表 | |||
* | |||
* @param request | |||
@@ -417,7 +424,6 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 根据工单ID查询工单问题列表 | |||
* | |||
* @param request | |||
@@ -429,7 +435,6 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 处理任务问题 | |||
* | |||
* @param request | |||
@@ -441,12 +446,10 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
} | |||
/** | |||
* | |||
* 修改巡检任务问题类型 | |||
* | |||
* @param id | |||
* @param questionCode | |||
* | |||
* @return | |||
*/ | |||
@Override |
@@ -1,13 +1,18 @@ | |||
package com.tuoheng.admin.service.road; | |||
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.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.entity.RoadDept; | |||
import com.tuoheng.admin.entity.RoadInformation; | |||
import com.tuoheng.admin.entity.Section; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.SectionEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.query.RoadInformationQuery; | |||
import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService; | |||
@@ -15,7 +20,9 @@ import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.*; | |||
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.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -56,16 +63,58 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
return JsonResult.error(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//获取超级管理员登录信息 | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
if(StringUtils.isEmpty(tenantId)){ | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if (ObjectUtil.isNull(user)) { | |||
return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode(), SectionEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
String tenantId = user.getTenantId(); // CurrentUserUtil.getTenantId(); | |||
if (StringUtils.isEmpty(tenantId)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
String deptId = user.getDeptId(); | |||
if (StringUtils.isEmpty(deptId)) { | |||
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
//获取分页数据 | |||
IPage<RoadInformation> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<RoadInformation> pageData = roadInformationMapper.selectPage(page, Wrappers.<RoadInformation>lambdaQuery() | |||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()) | |||
.eq(RoadInformation::getTenantId, tenantId) | |||
.orderByDesc(RoadInformation::getCreateTime)); | |||
IPage<RoadInformation> pageData = null; | |||
// 按拥有部门数据权限过滤公路数据 | |||
// 所有部门权限 | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
pageData = roadInformationMapper.selectPage(page, Wrappers.<RoadInformation>lambdaQuery() | |||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()) | |||
.eq(RoadInformation::getTenantId, tenantId) | |||
.orderByDesc(RoadInformation::getCreateTime)); | |||
} | |||
// 本部门及下属部门权限 | |||
else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
List<String> deptAndSubList = deptMapper.selectAllChildListById(deptId); | |||
if (StringUtils.isEmpty(deptAndSubList) && deptAndSubList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
List<RoadDept> roadDeptList = roadDeptMapper.selectList(Wrappers.<RoadDept>lambdaQuery() | |||
.eq(RoadDept::getTenantId, tenantId) | |||
.in(RoadDept::getDeptId, deptAndSubList)); | |||
List<String> roadIdList = roadDeptList.stream().map(t -> t.getRoadId()).collect(Collectors.toList()); | |||
pageData = roadInformationMapper.selectPage(page, Wrappers.<RoadInformation>lambdaQuery() | |||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()) | |||
.eq(RoadInformation::getTenantId, tenantId) | |||
.in(RoadInformation::getId, roadIdList) | |||
.orderByDesc(RoadInformation::getCreateTime)); | |||
} | |||
// 本部门权限 | |||
else { | |||
List<RoadDept> roadDeptList = roadDeptMapper.selectList(Wrappers.<RoadDept>lambdaQuery() | |||
.eq(RoadDept::getTenantId, tenantId) | |||
.in(RoadDept::getDeptId, deptId)); | |||
List<String> roadIdList = roadDeptList.stream().map(t -> t.getRoadId()).collect(Collectors.toList()); | |||
pageData = roadInformationMapper.selectPage(page, Wrappers.<RoadInformation>lambdaQuery() | |||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()) | |||
.eq(RoadInformation::getTenantId, tenantId) | |||
.in(RoadInformation::getId, roadIdList) | |||
.orderByDesc(RoadInformation::getCreateTime)); | |||
} | |||
List<RoadInformation> records = pageData.getRecords(); | |||
List<RoadInformation> list = new ArrayList<>(); | |||
for (RoadInformation record : records) { | |||
@@ -82,7 +131,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
public JsonResult getListInfo(RoadInformationQuery query) { | |||
//获取超级管理员登录信息 | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
if(StringUtils.isEmpty(tenantId)){ | |||
if (StringUtils.isEmpty(tenantId)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//当前租户下所有公路信息 | |||
@@ -100,6 +149,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
/** | |||
* 根据部门id获取该部门下公路列表 | |||
* | |||
* @param deptId | |||
* @return | |||
*/ | |||
@@ -112,10 +162,10 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
public JsonResult editInfo(RoadInformation entity) { | |||
//获取当前超级管理员用户信息 | |||
String userId = CurrentUserUtil.getUserId(); | |||
if(StringUtils.isEmpty(userId)){ | |||
if (StringUtils.isEmpty(userId)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
if(StringUtils.isEmpty(CurrentUserUtil.getTenantId())){ | |||
if (StringUtils.isEmpty(CurrentUserUtil.getTenantId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
if (StringUtils.isEmpty(entity.getId())) { | |||
@@ -129,7 +179,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
RoadInformation roadInformation = this.getOne(Wrappers.<RoadInformation>lambdaQuery().eq(RoadInformation::getId, entity.getId())); | |||
String code = entity.getCode(); | |||
//当前公路的code是否重复判断 | |||
if(!code.equals(roadInformation.getCode())){ | |||
if (!code.equals(roadInformation.getCode())) { | |||
//code如果不存在则查询数据库中公路列表是否有重复的code | |||
if (this.getInformationListByCode(entity)) return JsonResult.error("公路已存在"); | |||
} | |||
@@ -141,15 +191,16 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
return JsonResult.success(); | |||
} | |||
//查询数据库中当前租户对应的公路列表 | |||
private boolean getInformationListByCode(RoadInformation entity) { | |||
List<RoadInformation> roadInformationList = roadInformationMapper.selectList(new LambdaQueryWrapper<RoadInformation>() | |||
.eq(RoadInformation::getTenantId, CurrentUserUtil.getTenantId()) | |||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()) | |||
.eq(RoadInformation::getCode,entity.getCode())); | |||
if(CollectionUtil.isNotEmpty(roadInformationList)){ | |||
.eq(RoadInformation::getCode, entity.getCode())); | |||
if (CollectionUtil.isNotEmpty(roadInformationList)) { | |||
for (RoadInformation roadInformation : roadInformationList) { | |||
if(entity.getCode().equals(roadInformation.getCode())){ | |||
if (entity.getCode().equals(roadInformation.getCode())) { | |||
return true; | |||
} | |||
} | |||
@@ -159,6 +210,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
/** | |||
* 根据登录人角色获取该部门下公路信息列表 | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
@@ -168,7 +220,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
//获取租户id | |||
String tenantId = user.getTenantId(); | |||
//用户类型角色判断 1超级管理员 2 部门管理员 3普通用户 | |||
if(null == user.getDataPermission()){ | |||
if (null == user.getDataPermission()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//登录用户若为部门管理员或普通用户需要查询所在部门 | |||
@@ -176,41 +228,42 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
//获取公路列表 | |||
List<RoadInformation> roadInformationList = new ArrayList<>(); | |||
//超级管理员 | |||
if(DataPermissionEnum.ALL.getCode()== user.getDataPermission()){ | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
roadInformationList = this.getAllRoadInformationList(tenantId); | |||
} | |||
//部门管理员 | |||
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()){ | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
//根据当前用户对应的部门id获取该部门及子部门的id集合 | |||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||
if(CollectionUtil.isEmpty(deptIdList)){ | |||
if (CollectionUtil.isEmpty(deptIdList)) { | |||
return null; | |||
} | |||
List<RoadDept> list = roadDeptMapper.selectListByDeptIdList(deptIdList); | |||
roadInformationList = this.getRoadInformationList(tenantId, list); | |||
} | |||
//普通用户 | |||
if(DataPermissionEnum.DEPT.getCode() == user.getDataPermission()){ | |||
if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>() | |||
.eq(RoadDept::getTenantId, tenantId) | |||
.eq(RoadDept::getDeptId, deptId)); | |||
if (CollectionUtil.isEmpty(roadDeptList)) { | |||
return null; | |||
} | |||
roadInformationList =this.getRoadInformationList(tenantId,roadDeptList); | |||
roadInformationList = this.getRoadInformationList(tenantId, roadDeptList); | |||
} | |||
return JsonResult.success(roadInformationList); | |||
} | |||
/** | |||
* 根据租户id获取公路列表 | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getListByTenantId() { | |||
//获取当前租户下id | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
if(StringUtils.isEmpty(tenantId)){ | |||
if (StringUtils.isEmpty(tenantId)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//查询公路列表 | |||
@@ -223,6 +276,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
/** | |||
* 根据部门列表获取公路列表 | |||
* | |||
* @param tenantId | |||
* @param list | |||
* @return | |||
@@ -233,7 +287,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
Map<String, Object> map = new HashMap<>(); | |||
map.put("tenantId", tenantId); | |||
map.put("roadIdList", roadIdList); | |||
map.put("mark",MarkEnum.VALID.getCode()); | |||
map.put("mark", MarkEnum.VALID.getCode()); | |||
roadInformationList = roadInformationMapper.getListByMap(map); | |||
return roadInformationList; | |||
} |
@@ -12,8 +12,8 @@ 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.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.SectionEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.RoadInformationMapper; | |||
@@ -86,11 +86,11 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode(), SectionEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
String tenantId = user.getTenantId(); | |||
IPage<Section> pageData = new Page<>(query.getPage(), query.getLimit()); | |||
//数据权限 超级管理员可以查看全部路段 | |||
IPage<Section> pageData = null; // new Page<>(query.getPage(), query.getLimit()); | |||
IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); | |||
// 所有部门权限 | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
//获取分页数据 | |||
IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); | |||
pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery() | |||
.eq(Section::getMark, 1) | |||
.eq(Section::getTenantId, tenantId) | |||
@@ -113,53 +113,63 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
} | |||
pageData.setRecords(list); | |||
} | |||
//部门管理员和普通用户 查看本部门及下属部门 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
// 查看本部门及下属部门 | |||
else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() | |||
|| DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
//获取分页数据 | |||
IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); | |||
// IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); | |||
//获取当前部门及其子部门列表 | |||
String deptId = user.getDeptId(); | |||
if (StringUtils.isEmpty(deptId)) { | |||
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
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()); | |||
List<String> deptList = new ArrayList<>(); | |||
// 本部门及子部门权限 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
List<String> deptAndSubList = deptMapper.selectAllChildListById(deptId); | |||
if (StringUtils.isEmpty(deptAndSubList) && deptAndSubList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
deptList.addAll(deptAndSubList); | |||
} | |||
// 本部门权限 | |||
else { | |||
deptList.add(deptId); | |||
} | |||
//根据部门列表查对应的部门路段数据列表 | |||
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() | |||
.eq(SectionDept::getTenantId, tenantId) | |||
.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()).collect(Collectors.toList()); | |||
if (StringUtils.isEmpty(sectionIdList)) { | |||
return JsonResult.error(SectionEnum.SECTION_ID_IS_NULL.getCode(), SectionEnum.SECTION_ID_IS_NULL.getMsg()); | |||
} | |||
//根据路段id列表获取对应的路段信息 | |||
List<Section> sectionList = sectionMapper.selectList(new LambdaQueryWrapper<Section>() | |||
pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery() | |||
.eq(Section::getMark, 1) | |||
.eq(Section::getTenantId, tenantId) | |||
.in(Section::getId, sectionIdList)); | |||
if (StringUtils.isEmpty(sectionList)) { | |||
return JsonResult.error(SectionEnum.SECTION_LIST_IS_NULL.getCode(), SectionEnum.SECTION_LIST_IS_NULL.getMsg()); | |||
} | |||
.in(Section::getId, sectionIdList) | |||
.orderByDesc(Section::getCreateTime)); | |||
List<Section> records = pageData.getRecords(); | |||
List<Section> list = new ArrayList<>(); | |||
for (Section section : sectionList) { | |||
for (Section record : records) { | |||
//获取每条路段对应的公路id | |||
RoadInformation roadInformation = roadInformationMapper.selectOne(Wrappers.<RoadInformation>lambdaQuery() | |||
.eq(RoadInformation::getId, section.getRoadId()) | |||
.eq(RoadInformation::getId, record.getRoadId()) | |||
.eq(RoadInformation::getMark, 1)); | |||
if (ObjectUtil.isNotNull(roadInformation)) { | |||
if (StringUtils.isNotNull(roadInformation)) { | |||
if (StringUtils.isNotEmpty(roadInformation.getCode())) { | |||
section.setCode(roadInformation.getCode()); | |||
record.setCode(roadInformation.getCode()); | |||
} | |||
} | |||
//判断路段是否关联部门 | |||
SectionRelation(section); | |||
list.add(section); | |||
SectionRelation(record); | |||
list.add(record); | |||
} | |||
pageData.setRecords(list); | |||
} | |||
@@ -171,7 +181,7 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
//路段范围属性 | |||
String sectionRange = record.getSectionRange(); | |||
String[] sectionRanges = sectionRange.split(","); | |||
sectionRange ="K"+sectionRanges[0]+"+"+sectionRanges[1]+"~"+"K"+sectionRanges[2]+"+"+sectionRanges[3]; | |||
sectionRange = "K" + sectionRanges[0] + "+" + sectionRanges[1] + "~" + "K" + sectionRanges[2] + "+" + sectionRanges[3]; | |||
return sectionRange; | |||
} | |||
@@ -228,7 +238,7 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
//超级管理员可以进行新增和编辑,普通用户不能进行此操作,部门管理员可以进行修改经纬度 | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
if(StringUtils.isEmpty(tenantId)){ | |||
if (StringUtils.isEmpty(tenantId)) { | |||
return JsonResult.error("租户id为空"); | |||
} | |||
if (StringUtils.isEmpty(entity.getId())) { | |||
@@ -282,12 +292,12 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
public JsonResult getSectionList() { | |||
//获取当前登录人信息 登录用户名 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if(ObjectUtils.isEmpty(user)) { | |||
if (ObjectUtils.isEmpty(user)) { | |||
return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode()); | |||
} | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
//超级管理员获取当前租户下全部公路,部门管理员和普通用户显示用户所属部门监管范围路段之和 | |||
if(null == user.getDataPermission()){ | |||
if (null == user.getDataPermission()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//登录用户若为部门管理员或普通用户需要查询所在部门 | |||
@@ -296,13 +306,13 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
List<RoadInformation> roadInformationList = new ArrayList<>(); | |||
//超级管理员 | |||
if(DataPermissionEnum.ALL.getCode() == user.getDataPermission()){ | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
roadInformationList = this.getAllRoadInformationList(tenantId); | |||
return JsonResult.success(roadInformationList); | |||
} | |||
//部门管理员和普通用户 | |||
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()){ | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
//对应部门下的路段列表 | |||
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>() | |||
.eq(SectionDept::getDeptId, deptId).eq(SectionDept::getTenantId, tenantId)); | |||
@@ -321,7 +331,7 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section> | |||
.eq(RoadInformation::getTenantId, tenantId) | |||
.eq(RoadInformation::getId, roadId) | |||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode())); | |||
if(roadInformation !=null){ | |||
if (roadInformation != null) { | |||
section.setCode(roadInformation.getCode()); | |||
} | |||
sections.add(section); |
@@ -69,12 +69,10 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
String tenantId = user.getTenantId(); | |||
query.setTenantId(tenantId); | |||
//获取用户角色 | |||
Integer roleId = user.getDataPermission(); | |||
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<StructureInfoVo> pageData = null; | |||
//如果是超级管理员,查看所有构造物 | |||
if (DataPermissionEnum.ALL.getCode() == roleId) { | |||
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit()); | |||
// 所有部门权限 | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
//数据分页 | |||
pageData = structureMapper.queryPage(page, query); | |||
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { | |||
@@ -99,16 +97,29 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
return structureInfoVo; | |||
}).collect(Collectors.toList()); | |||
pageData.setRecords(list); | |||
} | |||
//如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == roleId || DataPermissionEnum.DEPT.getCode() == roleId) { | |||
// 本部门及下属部门、本部门 | |||
else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() | |||
|| DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
// 所在部门 | |||
String deptId = user.getDeptId(); | |||
if (StringUtils.isEmpty(deptId)) { | |||
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(), StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
List<String> deptList = new ArrayList<>(); | |||
// 本部门及子部门权限 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
List<String> deptAndSubList = deptMapper.selectAllChildListById(deptId); | |||
if (StringUtils.isEmpty(deptAndSubList) && deptAndSubList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
deptList.addAll(deptAndSubList); | |||
} | |||
// 本部门权限 | |||
else { | |||
deptList.add(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()); | |||
} | |||
@@ -148,8 +159,6 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
} | |||
pageData.setRecords(list); | |||
} | |||
return JsonResult.success(pageData); | |||
} | |||
@@ -201,12 +210,61 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
@Override | |||
public JsonResult getSectionInfo() { | |||
//获取登录信息 | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if (ObjectUtil.isNull(user)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
user.setDataPermission(3); | |||
//获取登录信息 | |||
String tenantId = user.getTenantId(); | |||
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) | |||
.eq(Structure::getTenantId, tenantId)); | |||
List<Structure> structures = null; | |||
// 所有部门权限 | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) | |||
.eq(Structure::getTenantId, tenantId)); | |||
} | |||
// 本部门及下属部门、本部门 | |||
else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() | |||
|| DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
String deptId = user.getDeptId(); | |||
if (StringUtils.isEmpty(deptId)) { | |||
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
List<String> deptIdList = new ArrayList<>(); | |||
// 本部门及下属部门 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
List<String> deptAndSubList = deptMapper.selectAllChildListById(deptId); | |||
if (StringUtils.isEmpty(deptAndSubList) && deptAndSubList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
deptIdList.addAll(deptAndSubList); | |||
} | |||
// 本部门 | |||
else { | |||
deptIdList.add(deptId); | |||
} | |||
// 相关路段 | |||
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() | |||
.eq(SectionDept::getTenantId, tenantId) | |||
.in(SectionDept::getDeptId, deptIdList)); | |||
if (StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg()); | |||
} | |||
//查询对应的路段ID | |||
List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).distinct().collect(Collectors.toList()); | |||
if (StringUtils.isEmpty(sectionIdList)) { | |||
return JsonResult.error(SectionEnum.SECTION_ID_IS_NULL.getCode(), SectionEnum.SECTION_ID_IS_NULL.getMsg()); | |||
} | |||
structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery() | |||
.eq(Structure::getMark, 1) | |||
.eq(Structure::getTenantId, tenantId) | |||
.in(Structure::getSectionId, sectionIdList) | |||
); | |||
} | |||
if (null == structures) { | |||
return JsonResult.error(); | |||
} |