Browse Source

工作台中数据根据数据数据权限展示。

tags/V1.3.3^2
keido 1 year ago
parent
commit
5f79f408f2
1 changed files with 74 additions and 71 deletions
  1. +74
    -71
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java

+ 74
- 71
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java View File

@@ -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

Loading…
Cancel
Save