import com.tuoheng.admin.entity.QuestionType; | import com.tuoheng.admin.entity.QuestionType; | ||||
import com.tuoheng.admin.entity.User; | import com.tuoheng.admin.entity.User; | ||||
import com.tuoheng.admin.enums.DataPermissionEnum; | 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.inspectionfile.ListByDeptUserTypeEnum; | ||||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | ||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListService; | import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListService; | ||||
import com.tuoheng.admin.service.inspectionfile.update.UpdateInspectionFileQuestionTypeService; | import com.tuoheng.admin.service.inspectionfile.update.UpdateInspectionFileQuestionTypeService; | ||||
import com.tuoheng.admin.utils.CurrentUserUtil; | import com.tuoheng.admin.utils.CurrentUserUtil; | ||||
import com.tuoheng.admin.vo.inspection.InspectionFileVo; | |||||
import com.tuoheng.admin.vo.ListByDeptUserTypeVo; | 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.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 org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
String tenantId = CurrentUserUtil.getTenantId(); | String tenantId = CurrentUserUtil.getTenantId(); | ||||
//获取当前登录人信息 | //获取当前登录人信息 | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
//获取用户角色 | |||||
Integer roleId = user.getDataPermission(); | |||||
if(roleId ==null){ | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
//查询区域范范围问题 | //查询区域范范围问题 | ||||
List<InspectionFile> inspectionFileLists = new ArrayList<>(); | List<InspectionFile> inspectionFileLists = new ArrayList<>(); | ||||
//超级管理员 | //超级管理员 | ||||
if(DataPermissionEnum.ALL.getCode()==roleId){ | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
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, tenantId)); | ||||
for (InspectionFile inspectionFile : inspectionFileList) { | for (InspectionFile inspectionFile : inspectionFileList) { | ||||
//任务状态判断 | //任务状态判断 | ||||
if(20 == inspectionFile.getStatus()){ | |||||
if (20 == inspectionFile.getStatus()) { | |||||
//任务状态判断,已生成工单,问题未解决 | //任务状态判断,已生成工单,问题未解决 | ||||
Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId()); | Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId()); | ||||
if (ObjectUtil.isNull(inspection)) { | if (ObjectUtil.isNull(inspection)) { | ||||
} | } | ||||
} | } | ||||
//部门管理员及普通用户 本部门的问题 | //部门管理员及普通用户 本部门的问题 | ||||
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 | //根据用户查询对应的巡检任务id | ||||
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>() | List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>() | ||||
.eq(Inspection::getTenantId, tenantId) | .eq(Inspection::getTenantId, tenantId) | ||||
.eq(Inspection::getMark, 1) | .eq(Inspection::getMark, 1) | ||||
.eq(Inspection::getDeptId, user.getDeptId())); | |||||
.in(Inspection::getDeptId, deptList)); | |||||
//查询对应的问题 | //查询对应的问题 | ||||
for (Inspection inspection : inspectionList) { | for (Inspection inspection : inspectionList) { | ||||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | ||||
.eq(InspectionFile::getInspectionId, inspection.getId())); | .eq(InspectionFile::getInspectionId, inspection.getId())); | ||||
for (InspectionFile inspectionFile : inspectionFileList) { | for (InspectionFile inspectionFile : inspectionFileList) { | ||||
//任务状态判断 | //任务状态判断 | ||||
if(20 == inspectionFile.getStatus()){ | |||||
if (20 == inspectionFile.getStatus()) { | |||||
//任务状态判断,已生成工单,问题未解决 | //任务状态判断,已生成工单,问题未解决 | ||||
Inspection inspections = inspectionMapper.selectById(inspectionFile.getInspectionId()); | Inspection inspections = inspectionMapper.selectById(inspectionFile.getInspectionId()); | ||||
if (ObjectUtil.isNull(inspections)) { | if (ObjectUtil.isNull(inspections)) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
List<InspectionFileVo> list = inspectionFileLists.stream().map(x -> { | List<InspectionFileVo> list = inspectionFileLists.stream().map(x -> { | ||||
InspectionFileVo vo = new InspectionFileVo(); | InspectionFileVo vo = new InspectionFileVo(); | ||||
BeanUtils.copyProperties(x, vo); | BeanUtils.copyProperties(x, vo); | ||||
//标记图片 | //标记图片 | ||||
vo.setFileImage(CommonConfig.imageURL+x.getFileImage()); | |||||
vo.setFileImage(CommonConfig.imageURL + x.getFileImage()); | |||||
//任务名称 | //任务名称 | ||||
if (StringUtils.isNotEmpty(x.getInspectionId())) { | if (StringUtils.isNotEmpty(x.getInspectionId())) { | ||||
Inspection inspection = inspectionMapper.selectById(x.getInspectionId()); | Inspection inspection = inspectionMapper.selectById(x.getInspectionId()); | ||||
//问题类型 | //问题类型 | ||||
if (StringUtils.isNotEmpty(x.getQuestionCode())) { | if (StringUtils.isNotEmpty(x.getQuestionCode())) { | ||||
QuestionType questionType = questionTypeMapper.selectOne(new LambdaQueryWrapper<QuestionType>() | 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) { | if (null != questionType) { | ||||
vo.setCode(questionType.getCode()); | vo.setCode(questionType.getCode()); | ||||
vo.setContent(questionType.getContent()); | vo.setContent(questionType.getContent()); | ||||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | public JsonResult getListByDeptUserType(InspectionFileQuery query) { | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | //用户角色判断 1超级管理员 2部门管理员 3普通用户 | ||||
if(null == user.getDataPermission()){ | |||||
if (null == user.getDataPermission()) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
List<ListByDeptUserTypeVo> list = new ArrayList<>(); | List<ListByDeptUserTypeVo> list = new ArrayList<>(); | ||||
//5块状裂纹 | //5块状裂纹 | ||||
Integer massiveCrack = 0; | Integer massiveCrack = 0; | ||||
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 | //若角色为超级管理员,查看状态为已生成工单和和问题已处理 | ||||
if(DataPermissionEnum.ALL.getCode()==user.getDataPermission()){ | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
//直接查问题列表 | //直接查问题列表 | ||||
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, user.getTenantId()) | .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) { | 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() | QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | ||||
.eq(QuestionType::getMark, 1) | .eq(QuestionType::getMark, 1) | ||||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | .eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | ||||
if(ObjectUtil.isNull(questionType)){ | |||||
if (ObjectUtil.isNull(questionType)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
Integer name = questionType.getName(); | Integer name = questionType.getName(); | ||||
if(name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||||
//1横向裂缝 | //1横向裂缝 | ||||
abeamCrackNum+=1; | |||||
}else if(name==QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()){ | |||||
abeamCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||||
//3网状裂纹 | //3网状裂纹 | ||||
reticularCrackNum+=1; | |||||
}else if(name==QuestionTypeEnum.PIT_GROOVE_NAME.getCode()){ | |||||
reticularCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||||
//4坑槽 | //4坑槽 | ||||
pitGrooveNum+=1; | |||||
}else if(name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()){ | |||||
pitGrooveNum += 1; | |||||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||||
//5块状裂纹 | //5块状裂纹 | ||||
massiveCrack+=1; | |||||
}else if(name == QuestionTypeEnum.PON_DING_NAME.getCode()){ | |||||
massiveCrack += 1; | |||||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||||
//6积水 | //6积水 | ||||
ponDingNum+=1; | |||||
}else if(name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()){ | |||||
ponDingNum += 1; | |||||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||||
//0纵向裂缝 | //0纵向裂缝 | ||||
longitudinalCrackNum+=1; | |||||
longitudinalCrackNum += 1; | |||||
} | } | ||||
} | } | ||||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | ||||
vo4.setNum(ponDingNum); | vo4.setNum(ponDingNum); | ||||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | ||||
vo5.setNum(longitudinalCrackNum); | 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(); | 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列表 | //根据部门id获取部门id列表 | ||||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | ||||
if(CollectionUtil.isEmpty(deptIdList)){ | |||||
if (CollectionUtil.isEmpty(deptIdList)) { | |||||
return null; | return null; | ||||
} | } | ||||
//根据部门id列表查多条任务 | //根据部门id列表查多条任务 | ||||
List<Inspection> inspectionList = inspectionMapper.selectListByDeptIdList(deptIdList); | 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()); | List<String> inspectionIdList = inspectionList.stream().map(o -> o.getId()).collect(Collectors.toList()); | ||||
//根据任务id列表查找多条问题 | //根据任务id列表查找多条问题 | ||||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectListByInspectIdList(inspectionIdList); | 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) { | 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() | QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | ||||
.eq(QuestionType::getMark, 1) | .eq(QuestionType::getMark, 1) | ||||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | .eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | ||||
if(ObjectUtil.isNull(questionType)){ | |||||
if (ObjectUtil.isNull(questionType)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
Integer name = questionType.getName(); | Integer name = questionType.getName(); | ||||
if(name==QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||||
//1横向裂缝 | //1横向裂缝 | ||||
abeamCrackNum+=1; | |||||
}else if(name==QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()){ | |||||
abeamCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||||
//3网状裂纹 | //3网状裂纹 | ||||
reticularCrackNum+=1; | |||||
}else if(name==QuestionTypeEnum.PIT_GROOVE_NAME.getCode()){ | |||||
reticularCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||||
//4坑槽 | //4坑槽 | ||||
pitGrooveNum+=1; | |||||
}else if(name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()){ | |||||
pitGrooveNum += 1; | |||||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||||
//5块状裂纹 | //5块状裂纹 | ||||
massiveCrack+=1; | |||||
}else if(name == QuestionTypeEnum.PON_DING_NAME.getCode()){ | |||||
massiveCrack += 1; | |||||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||||
//6积水 | //6积水 | ||||
ponDingNum+=1; | |||||
}else if(name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()){ | |||||
ponDingNum += 1; | |||||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||||
//0纵向裂缝 | //0纵向裂缝 | ||||
longitudinalCrackNum+=1; | |||||
longitudinalCrackNum += 1; | |||||
} | } | ||||
} | } | ||||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | ||||
vo4.setNum(ponDingNum); | vo4.setNum(ponDingNum); | ||||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | ||||
vo5.setNum(longitudinalCrackNum); | vo5.setNum(longitudinalCrackNum); | ||||
Collections.addAll(list,vo,vo1,vo2,vo3,vo4,vo5); | |||||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||||
} | } | ||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
public JsonResult getPageListByInspectionId(QueryInspectionFilePageListByInspectionIdRequest request){ | |||||
public JsonResult getPageListByInspectionId(QueryInspectionFilePageListByInspectionIdRequest request) { | |||||
return queryInspectionFilePageListByInspectionIdService.getPageListByInspectionId(request); | return queryInspectionFilePageListByInspectionIdService.getPageListByInspectionId(request); | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 查询任务问题分页列表 | * 查询任务问题分页列表 | ||||
* | * | ||||
* @param request | * @param request | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 确认 | * 确认 | ||||
* | * | ||||
* @param idList | * @param idList | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 忽略 | * 忽略 | ||||
* | * | ||||
* @param idList | * @param idList | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 获取任务问题处理结果 | * 获取任务问题处理结果 | ||||
* | * | ||||
* @param id | * @param id | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 查询任务问题分布列表 | * 查询任务问题分布列表 | ||||
* | * | ||||
* @param request | * @param request | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 根据工单ID查询工单问题列表 | * 根据工单ID查询工单问题列表 | ||||
* | * | ||||
* @param request | * @param request | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 处理任务问题 | * 处理任务问题 | ||||
* | * | ||||
* @param request | * @param request | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* 修改巡检任务问题类型 | * 修改巡检任务问题类型 | ||||
* | * | ||||
* @param id | * @param id | ||||
* @param questionCode | * @param questionCode | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override |
package com.tuoheng.admin.service.road; | package com.tuoheng.admin.service.road; | ||||
import cn.hutool.core.collection.CollectionUtil; | 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.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 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.DataPermissionEnum; | ||||
import com.tuoheng.admin.enums.MarkEnum; | |||||
import com.tuoheng.admin.enums.SectionEnum; | |||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import com.tuoheng.admin.query.RoadInformationQuery; | import com.tuoheng.admin.query.RoadInformationQuery; | ||||
import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService; | import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService; | ||||
import com.tuoheng.common.core.common.BaseServiceImpl; | import com.tuoheng.common.core.common.BaseServiceImpl; | ||||
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.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.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
return JsonResult.error(ServiceExceptionEnum.PARAMETER_IS_NULL); | 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); | 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> 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> records = pageData.getRecords(); | ||||
List<RoadInformation> list = new ArrayList<>(); | List<RoadInformation> list = new ArrayList<>(); | ||||
for (RoadInformation record : records) { | for (RoadInformation record : records) { | ||||
public JsonResult getListInfo(RoadInformationQuery query) { | public JsonResult getListInfo(RoadInformationQuery query) { | ||||
//获取超级管理员登录信息 | //获取超级管理员登录信息 | ||||
String tenantId = CurrentUserUtil.getTenantId(); | String tenantId = CurrentUserUtil.getTenantId(); | ||||
if(StringUtils.isEmpty(tenantId)){ | |||||
if (StringUtils.isEmpty(tenantId)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//当前租户下所有公路信息 | //当前租户下所有公路信息 | ||||
/** | /** | ||||
* 根据部门id获取该部门下公路列表 | * 根据部门id获取该部门下公路列表 | ||||
* | |||||
* @param deptId | * @param deptId | ||||
* @return | * @return | ||||
*/ | */ | ||||
public JsonResult editInfo(RoadInformation entity) { | public JsonResult editInfo(RoadInformation entity) { | ||||
//获取当前超级管理员用户信息 | //获取当前超级管理员用户信息 | ||||
String userId = CurrentUserUtil.getUserId(); | String userId = CurrentUserUtil.getUserId(); | ||||
if(StringUtils.isEmpty(userId)){ | |||||
if (StringUtils.isEmpty(userId)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
if(StringUtils.isEmpty(CurrentUserUtil.getTenantId())){ | |||||
if (StringUtils.isEmpty(CurrentUserUtil.getTenantId())) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
if (StringUtils.isEmpty(entity.getId())) { | if (StringUtils.isEmpty(entity.getId())) { | ||||
RoadInformation roadInformation = this.getOne(Wrappers.<RoadInformation>lambdaQuery().eq(RoadInformation::getId, entity.getId())); | RoadInformation roadInformation = this.getOne(Wrappers.<RoadInformation>lambdaQuery().eq(RoadInformation::getId, entity.getId())); | ||||
String code = entity.getCode(); | String code = entity.getCode(); | ||||
//当前公路的code是否重复判断 | //当前公路的code是否重复判断 | ||||
if(!code.equals(roadInformation.getCode())){ | |||||
if (!code.equals(roadInformation.getCode())) { | |||||
//code如果不存在则查询数据库中公路列表是否有重复的code | //code如果不存在则查询数据库中公路列表是否有重复的code | ||||
if (this.getInformationListByCode(entity)) return JsonResult.error("公路已存在"); | if (this.getInformationListByCode(entity)) return JsonResult.error("公路已存在"); | ||||
} | } | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
//查询数据库中当前租户对应的公路列表 | //查询数据库中当前租户对应的公路列表 | ||||
private boolean getInformationListByCode(RoadInformation entity) { | private boolean getInformationListByCode(RoadInformation entity) { | ||||
List<RoadInformation> roadInformationList = roadInformationMapper.selectList(new LambdaQueryWrapper<RoadInformation>() | List<RoadInformation> roadInformationList = roadInformationMapper.selectList(new LambdaQueryWrapper<RoadInformation>() | ||||
.eq(RoadInformation::getTenantId, CurrentUserUtil.getTenantId()) | .eq(RoadInformation::getTenantId, CurrentUserUtil.getTenantId()) | ||||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode()) | .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) { | for (RoadInformation roadInformation : roadInformationList) { | ||||
if(entity.getCode().equals(roadInformation.getCode())){ | |||||
if (entity.getCode().equals(roadInformation.getCode())) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 根据登录人角色获取该部门下公路信息列表 | * 根据登录人角色获取该部门下公路信息列表 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
//获取租户id | //获取租户id | ||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
//用户类型角色判断 1超级管理员 2 部门管理员 3普通用户 | //用户类型角色判断 1超级管理员 2 部门管理员 3普通用户 | ||||
if(null == user.getDataPermission()){ | |||||
if (null == user.getDataPermission()) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//登录用户若为部门管理员或普通用户需要查询所在部门 | //登录用户若为部门管理员或普通用户需要查询所在部门 | ||||
//获取公路列表 | //获取公路列表 | ||||
List<RoadInformation> roadInformationList = new ArrayList<>(); | List<RoadInformation> roadInformationList = new ArrayList<>(); | ||||
//超级管理员 | //超级管理员 | ||||
if(DataPermissionEnum.ALL.getCode()== user.getDataPermission()){ | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
roadInformationList = this.getAllRoadInformationList(tenantId); | roadInformationList = this.getAllRoadInformationList(tenantId); | ||||
} | } | ||||
//部门管理员 | //部门管理员 | ||||
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()){ | |||||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
//根据当前用户对应的部门id获取该部门及子部门的id集合 | //根据当前用户对应的部门id获取该部门及子部门的id集合 | ||||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | ||||
if(CollectionUtil.isEmpty(deptIdList)){ | |||||
if (CollectionUtil.isEmpty(deptIdList)) { | |||||
return null; | return null; | ||||
} | } | ||||
List<RoadDept> list = roadDeptMapper.selectListByDeptIdList(deptIdList); | List<RoadDept> list = roadDeptMapper.selectListByDeptIdList(deptIdList); | ||||
roadInformationList = this.getRoadInformationList(tenantId, list); | 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>() | List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>() | ||||
.eq(RoadDept::getTenantId, tenantId) | .eq(RoadDept::getTenantId, tenantId) | ||||
.eq(RoadDept::getDeptId, deptId)); | .eq(RoadDept::getDeptId, deptId)); | ||||
if (CollectionUtil.isEmpty(roadDeptList)) { | if (CollectionUtil.isEmpty(roadDeptList)) { | ||||
return null; | return null; | ||||
} | } | ||||
roadInformationList =this.getRoadInformationList(tenantId,roadDeptList); | |||||
roadInformationList = this.getRoadInformationList(tenantId, roadDeptList); | |||||
} | } | ||||
return JsonResult.success(roadInformationList); | return JsonResult.success(roadInformationList); | ||||
} | } | ||||
/** | /** | ||||
* 根据租户id获取公路列表 | * 根据租户id获取公路列表 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
public JsonResult getListByTenantId() { | public JsonResult getListByTenantId() { | ||||
//获取当前租户下id | //获取当前租户下id | ||||
String tenantId = CurrentUserUtil.getTenantId(); | String tenantId = CurrentUserUtil.getTenantId(); | ||||
if(StringUtils.isEmpty(tenantId)){ | |||||
if (StringUtils.isEmpty(tenantId)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//查询公路列表 | //查询公路列表 | ||||
/** | /** | ||||
* 根据部门列表获取公路列表 | * 根据部门列表获取公路列表 | ||||
* | |||||
* @param tenantId | * @param tenantId | ||||
* @param list | * @param list | ||||
* @return | * @return | ||||
Map<String, Object> map = new HashMap<>(); | Map<String, Object> map = new HashMap<>(); | ||||
map.put("tenantId", tenantId); | map.put("tenantId", tenantId); | ||||
map.put("roadIdList", roadIdList); | map.put("roadIdList", roadIdList); | ||||
map.put("mark",MarkEnum.VALID.getCode()); | |||||
map.put("mark", MarkEnum.VALID.getCode()); | |||||
roadInformationList = roadInformationMapper.getListByMap(map); | roadInformationList = roadInformationMapper.getListByMap(map); | ||||
return roadInformationList; | return roadInformationList; | ||||
} | } |
import com.tuoheng.admin.entity.Section; | import com.tuoheng.admin.entity.Section; | ||||
import com.tuoheng.admin.entity.SectionDept; | import com.tuoheng.admin.entity.SectionDept; | ||||
import com.tuoheng.admin.entity.User; | import com.tuoheng.admin.entity.User; | ||||
import com.tuoheng.admin.enums.MarkEnum; | |||||
import com.tuoheng.admin.enums.DataPermissionEnum; | import com.tuoheng.admin.enums.DataPermissionEnum; | ||||
import com.tuoheng.admin.enums.MarkEnum; | |||||
import com.tuoheng.admin.enums.SectionEnum; | import com.tuoheng.admin.enums.SectionEnum; | ||||
import com.tuoheng.admin.mapper.DeptMapper; | import com.tuoheng.admin.mapper.DeptMapper; | ||||
import com.tuoheng.admin.mapper.RoadInformationMapper; | import com.tuoheng.admin.mapper.RoadInformationMapper; | ||||
return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode(), SectionEnum.USER_IS_NOT_EXIST.getMsg()); | return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode(), SectionEnum.USER_IS_NOT_EXIST.getMsg()); | ||||
} | } | ||||
String tenantId = user.getTenantId(); | 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()) { | if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | ||||
//获取分页数据 | //获取分页数据 | ||||
IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); | |||||
pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery() | pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery() | ||||
.eq(Section::getMark, 1) | .eq(Section::getMark, 1) | ||||
.eq(Section::getTenantId, tenantId) | .eq(Section::getTenantId, tenantId) | ||||
} | } | ||||
pageData.setRecords(list); | 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(); | String deptId = user.getDeptId(); | ||||
if (StringUtils.isEmpty(deptId)) { | if (StringUtils.isEmpty(deptId)) { | ||||
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); | 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() | 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()).collect(Collectors.toList()); | List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).collect(Collectors.toList()); | ||||
if (StringUtils.isEmpty(sectionIdList)) { | if (StringUtils.isEmpty(sectionIdList)) { | ||||
return JsonResult.error(SectionEnum.SECTION_ID_IS_NULL.getCode(), SectionEnum.SECTION_ID_IS_NULL.getMsg()); | return JsonResult.error(SectionEnum.SECTION_ID_IS_NULL.getCode(), SectionEnum.SECTION_ID_IS_NULL.getMsg()); | ||||
} | } | ||||
//根据路段id列表获取对应的路段信息 | //根据路段id列表获取对应的路段信息 | ||||
List<Section> sectionList = sectionMapper.selectList(new LambdaQueryWrapper<Section>() | |||||
pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery() | |||||
.eq(Section::getMark, 1) | .eq(Section::getMark, 1) | ||||
.eq(Section::getTenantId, tenantId) | .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<>(); | List<Section> list = new ArrayList<>(); | ||||
for (Section section : sectionList) { | |||||
for (Section record : records) { | |||||
//获取每条路段对应的公路id | //获取每条路段对应的公路id | ||||
RoadInformation roadInformation = roadInformationMapper.selectOne(Wrappers.<RoadInformation>lambdaQuery() | RoadInformation roadInformation = roadInformationMapper.selectOne(Wrappers.<RoadInformation>lambdaQuery() | ||||
.eq(RoadInformation::getId, section.getRoadId()) | |||||
.eq(RoadInformation::getId, record.getRoadId()) | |||||
.eq(RoadInformation::getMark, 1)); | .eq(RoadInformation::getMark, 1)); | ||||
if (ObjectUtil.isNotNull(roadInformation)) { | |||||
if (StringUtils.isNotNull(roadInformation)) { | |||||
if (StringUtils.isNotEmpty(roadInformation.getCode())) { | 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); | pageData.setRecords(list); | ||||
} | } | ||||
//路段范围属性 | //路段范围属性 | ||||
String sectionRange = record.getSectionRange(); | String sectionRange = record.getSectionRange(); | ||||
String[] sectionRanges = sectionRange.split(","); | 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; | return sectionRange; | ||||
} | } | ||||
//超级管理员可以进行新增和编辑,普通用户不能进行此操作,部门管理员可以进行修改经纬度 | //超级管理员可以进行新增和编辑,普通用户不能进行此操作,部门管理员可以进行修改经纬度 | ||||
String userId = CurrentUserUtil.getUserId(); | String userId = CurrentUserUtil.getUserId(); | ||||
String tenantId = CurrentUserUtil.getTenantId(); | String tenantId = CurrentUserUtil.getTenantId(); | ||||
if(StringUtils.isEmpty(tenantId)){ | |||||
if (StringUtils.isEmpty(tenantId)) { | |||||
return JsonResult.error("租户id为空"); | return JsonResult.error("租户id为空"); | ||||
} | } | ||||
if (StringUtils.isEmpty(entity.getId())) { | if (StringUtils.isEmpty(entity.getId())) { | ||||
public JsonResult getSectionList() { | public JsonResult getSectionList() { | ||||
//获取当前登录人信息 登录用户名 | //获取当前登录人信息 登录用户名 | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
if(ObjectUtils.isEmpty(user)) { | |||||
if (ObjectUtils.isEmpty(user)) { | |||||
return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode()); | return JsonResult.error(SectionEnum.USER_IS_NOT_EXIST.getCode()); | ||||
} | } | ||||
String tenantId = CurrentUserUtil.getTenantId(); | String tenantId = CurrentUserUtil.getTenantId(); | ||||
//超级管理员获取当前租户下全部公路,部门管理员和普通用户显示用户所属部门监管范围路段之和 | //超级管理员获取当前租户下全部公路,部门管理员和普通用户显示用户所属部门监管范围路段之和 | ||||
if(null == user.getDataPermission()){ | |||||
if (null == user.getDataPermission()) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//登录用户若为部门管理员或普通用户需要查询所在部门 | //登录用户若为部门管理员或普通用户需要查询所在部门 | ||||
List<RoadInformation> roadInformationList = new ArrayList<>(); | List<RoadInformation> roadInformationList = new ArrayList<>(); | ||||
//超级管理员 | //超级管理员 | ||||
if(DataPermissionEnum.ALL.getCode() == user.getDataPermission()){ | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
roadInformationList = this.getAllRoadInformationList(tenantId); | roadInformationList = this.getAllRoadInformationList(tenantId); | ||||
return JsonResult.success(roadInformationList); | 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>() | List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>() | ||||
.eq(SectionDept::getDeptId, deptId).eq(SectionDept::getTenantId, tenantId)); | .eq(SectionDept::getDeptId, deptId).eq(SectionDept::getTenantId, tenantId)); | ||||
.eq(RoadInformation::getTenantId, tenantId) | .eq(RoadInformation::getTenantId, tenantId) | ||||
.eq(RoadInformation::getId, roadId) | .eq(RoadInformation::getId, roadId) | ||||
.eq(RoadInformation::getMark, MarkEnum.VALID.getCode())); | .eq(RoadInformation::getMark, MarkEnum.VALID.getCode())); | ||||
if(roadInformation !=null){ | |||||
if (roadInformation != null) { | |||||
section.setCode(roadInformation.getCode()); | section.setCode(roadInformation.getCode()); | ||||
} | } | ||||
sections.add(section); | sections.add(section); |
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
query.setTenantId(tenantId); | query.setTenantId(tenantId); | ||||
//获取用户角色 | |||||
Integer roleId = user.getDataPermission(); | |||||
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit()); | |||||
IPage<StructureInfoVo> pageData = null; | 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); | pageData = structureMapper.queryPage(page, query); | ||||
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { | List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { | ||||
return structureInfoVo; | return structureInfoVo; | ||||
}).collect(Collectors.toList()); | }).collect(Collectors.toList()); | ||||
pageData.setRecords(list); | 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(); | String deptId = user.getDeptId(); | ||||
if (StringUtils.isEmpty(deptId)) { | 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) { | if (StringUtils.isEmpty(deptList) && deptList.size() <= 0) { | ||||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | ||||
} | } | ||||
} | } | ||||
pageData.setRecords(list); | pageData.setRecords(list); | ||||
} | } | ||||
return JsonResult.success(pageData); | return JsonResult.success(pageData); | ||||
} | } | ||||
@Override | @Override | ||||
public JsonResult getSectionInfo() { | 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)) { | if (StringUtils.isEmpty(tenantId)) { | ||||
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(), StructureEnum.TENANT_ID_IS_NULL.getMsg()); | 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) { | if (null == structures) { | ||||
return JsonResult.error(); | return JsonResult.error(); | ||||
} | } |