@@ -13,7 +13,8 @@ public enum ListByDeptUserTypeEnum { | |||
INSPECTION_LIST_IS_NULL(1100304, "任务列表为空"), | |||
DEPT_ID_IS_NULL(1100305, "部门id为空"), | |||
QUESTION_ID_IS_NULL(1100306, "问题列表为空"), | |||
TENANT_ID_IS_NULL(1100307, "租户id为空"); | |||
TENANT_ID_IS_NULL(1100307, "租户id为空"), | |||
DEPT_LIST_IS_NULL(1100308, "部门列表为空"); | |||
/** | |||
* 错误码 |
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -51,14 +52,18 @@ public class QueryAccidentCardListService { | |||
public JsonResult getList(QueryAccidentCardListRequest request) { | |||
// log.info("进入查询事件列表业务"); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
request.setTenantId(tenantId); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
String tenantId = user.getTenantId(); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询事故卡片列表业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
List<String> deptIdList = this.getDeptIdList(user); | |||
request.setDeptIdList(deptIdList); | |||
request.setTenantId(tenantId); | |||
List<Accident> accidentList = accidentMapper.selectAccidentCardList(request); | |||
// 构造返回结果对象 | |||
@@ -78,6 +83,24 @@ public class QueryAccidentCardListService { | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 根据用户自己的数据权限,查询对应部门的数据 | |||
* | |||
* @param user | |||
* @return | |||
*/ | |||
private List<String> getDeptIdList(User user) { | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
return null; | |||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList.add(user.getDeptId()); | |||
} | |||
return deptIdList; | |||
} | |||
/** | |||
* @param accidentList | |||
* @return |
@@ -1,6 +1,5 @@ | |||
package com.tuoheng.admin.service.inspectionfile; | |||
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.toolkit.Wrappers; | |||
@@ -10,8 +9,6 @@ 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.*; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
import com.tuoheng.admin.request.inspectionfile.*; | |||
@@ -19,17 +16,11 @@ import com.tuoheng.admin.service.inspectionfile.confirm.InspectionFileConfirmSer | |||
import com.tuoheng.admin.service.inspectionfile.handle.QueryInspectionFileHandleByInspectionFileIdService; | |||
import com.tuoheng.admin.service.inspectionfile.ignore.InspectionFileIgnoreService; | |||
import com.tuoheng.admin.service.inspectionfile.processing.InspectionFileProcessingService; | |||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFileDistributionListService; | |||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListByInspectionIdService; | |||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListByWorkOrderIdService; | |||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListService; | |||
import com.tuoheng.admin.service.inspectionfile.query.*; | |||
import com.tuoheng.admin.service.inspectionfile.update.UpdateInspectionFileQuestionTypeService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
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; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -38,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
@@ -94,6 +84,9 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
@Autowired | |||
private UpdateInspectionFileQuestionTypeService updateInspectionFileQuestionTypeService; | |||
@Autowired | |||
private QueryInspectionFileListByDeptUserTypeService queryInspectionFileListByDeptUserTypeService; | |||
/** | |||
* 问题类型和任务名称 | |||
* | |||
@@ -201,161 +194,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
@Override | |||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||
if (null == user.getDataPermission()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
List<ListByDeptUserTypeVo> list = new ArrayList<>(); | |||
ListByDeptUserTypeVo vo = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo1 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo2 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo3 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo4 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo5 = new ListByDeptUserTypeVo(); | |||
//坑槽 积水 裂缝 | |||
//0纵向裂缝 | |||
Integer longitudinalCrackNum = 0; | |||
//4坑槽 | |||
Integer pitGrooveNum = 0; | |||
//6积水 | |||
Integer ponDingNum = 0; | |||
//1横向裂缝 | |||
Integer abeamCrackNum = 0; | |||
//3网状裂纹 | |||
Integer reticularCrackNum = 0; | |||
//5块状裂纹 | |||
Integer massiveCrack = 0; | |||
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 | |||
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)); | |||
//根据状态类型分类 | |||
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()); | |||
} | |||
//查找问题类型 | |||
QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | |||
.eq(QuestionType::getMark, 1) | |||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | |||
if (ObjectUtil.isNull(questionType)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Integer name = questionType.getName(); | |||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
//1横向裂缝 | |||
abeamCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||
//3网状裂纹 | |||
reticularCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||
//4坑槽 | |||
pitGrooveNum += 1; | |||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||
//5块状裂纹 | |||
massiveCrack += 1; | |||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||
//6积水 | |||
ponDingNum += 1; | |||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||
//0纵向裂缝 | |||
longitudinalCrackNum += 1; | |||
} | |||
} | |||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||
vo.setNum(abeamCrackNum); | |||
vo1.setType(QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()); | |||
vo1.setNum(reticularCrackNum); | |||
vo2.setType(QuestionTypeEnum.PIT_GROOVE_NAME.getCode()); | |||
vo2.setNum(pitGrooveNum); | |||
vo3.setType(QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()); | |||
vo3.setNum(massiveCrack); | |||
vo4.setType(QuestionTypeEnum.PON_DING_NAME.getCode()); | |||
vo4.setNum(ponDingNum); | |||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||
vo5.setNum(longitudinalCrackNum); | |||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||
} | |||
//若角色为部门管理员或普通用户 | |||
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()); | |||
} | |||
//根据部门id获取部门id列表 | |||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||
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()); | |||
} | |||
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()); | |||
} | |||
for (InspectionFile inspectionFile : inspectionFileList) { | |||
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)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Integer name = questionType.getName(); | |||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
//1横向裂缝 | |||
abeamCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||
//3网状裂纹 | |||
reticularCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||
//4坑槽 | |||
pitGrooveNum += 1; | |||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||
//5块状裂纹 | |||
massiveCrack += 1; | |||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||
//6积水 | |||
ponDingNum += 1; | |||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||
//0纵向裂缝 | |||
longitudinalCrackNum += 1; | |||
} | |||
} | |||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||
vo.setNum(abeamCrackNum); | |||
vo1.setType(QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()); | |||
vo1.setNum(reticularCrackNum); | |||
vo2.setType(QuestionTypeEnum.PIT_GROOVE_NAME.getCode()); | |||
vo2.setNum(pitGrooveNum); | |||
vo3.setType(QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()); | |||
vo3.setNum(massiveCrack); | |||
vo4.setType(QuestionTypeEnum.PON_DING_NAME.getCode()); | |||
vo4.setNum(ponDingNum); | |||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||
vo5.setNum(longitudinalCrackNum); | |||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||
} | |||
return JsonResult.success(list); | |||
return queryInspectionFileListByDeptUserTypeService.getListByDeptUserType(query); | |||
} | |||
/** |
@@ -0,0 +1,231 @@ | |||
package com.tuoheng.admin.service.inspectionfile.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.entity.Inspection; | |||
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.code.inspectionfile.ListByDeptUserTypeEnum; | |||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.InspectionFileMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.mapper.QuestionTypeMapper; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.ListByDeptUserTypeVo; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 根据任务ID查询巡检任务问题分页列表业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-05 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryInspectionFileListByDeptUserTypeService { | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private InspectionFileMapper inspectionFileMapper; | |||
@Autowired | |||
private QuestionTypeMapper questionTypeMapper; | |||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||
if (null == user.getDataPermission()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
List<ListByDeptUserTypeVo> list = new ArrayList<>(); | |||
ListByDeptUserTypeVo vo = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo1 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo2 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo3 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo4 = new ListByDeptUserTypeVo(); | |||
ListByDeptUserTypeVo vo5 = new ListByDeptUserTypeVo(); | |||
//坑槽 积水 裂缝 | |||
//0纵向裂缝 | |||
Integer longitudinalCrackNum = 0; | |||
//4坑槽 | |||
Integer pitGrooveNum = 0; | |||
//6积水 | |||
Integer ponDingNum = 0; | |||
//1横向裂缝 | |||
Integer abeamCrackNum = 0; | |||
//3网状裂纹 | |||
Integer reticularCrackNum = 0; | |||
//5块状裂纹 | |||
Integer massiveCrack = 0; | |||
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 | |||
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)); | |||
//根据状态类型分类 | |||
if (null == inspectionFileList) { | |||
return 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())) { | |||
return 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)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Integer name = questionType.getName(); | |||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
//1横向裂缝 | |||
abeamCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||
//3网状裂纹 | |||
reticularCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||
//4坑槽 | |||
pitGrooveNum += 1; | |||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||
//5块状裂纹 | |||
massiveCrack += 1; | |||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||
//6积水 | |||
ponDingNum += 1; | |||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||
//0纵向裂缝 | |||
longitudinalCrackNum += 1; | |||
} | |||
} | |||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||
vo.setNum(abeamCrackNum); | |||
vo1.setType(QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()); | |||
vo1.setNum(reticularCrackNum); | |||
vo2.setType(QuestionTypeEnum.PIT_GROOVE_NAME.getCode()); | |||
vo2.setNum(pitGrooveNum); | |||
vo3.setType(QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()); | |||
vo3.setNum(massiveCrack); | |||
vo4.setType(QuestionTypeEnum.PON_DING_NAME.getCode()); | |||
vo4.setNum(ponDingNum); | |||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||
vo5.setNum(longitudinalCrackNum); | |||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||
} | |||
//若角色为部门管理员或普通用户 | |||
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(ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
//根据部门id获取部门id列表 | |||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||
if (CollectionUtil.isEmpty(deptIdList)) { | |||
return JsonResult.error(ListByDeptUserTypeEnum.DEPT_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.DEPT_LIST_IS_NULL.getMsg()); | |||
} | |||
//根据部门id列表查多条任务 | |||
List<Inspection> inspectionList = inspectionMapper.selectListByDeptIdList(deptIdList); | |||
if (CollectionUtil.isEmpty(inspectionList)) { | |||
return 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) { | |||
return 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())) { | |||
return 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)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Integer name = questionType.getName(); | |||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||
//1横向裂缝 | |||
abeamCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||
//3网状裂纹 | |||
reticularCrackNum += 1; | |||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||
//4坑槽 | |||
pitGrooveNum += 1; | |||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||
//5块状裂纹 | |||
massiveCrack += 1; | |||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||
//6积水 | |||
ponDingNum += 1; | |||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||
//0纵向裂缝 | |||
longitudinalCrackNum += 1; | |||
} | |||
} | |||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||
vo.setNum(abeamCrackNum); | |||
vo1.setType(QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()); | |||
vo1.setNum(reticularCrackNum); | |||
vo2.setType(QuestionTypeEnum.PIT_GROOVE_NAME.getCode()); | |||
vo2.setNum(pitGrooveNum); | |||
vo3.setType(QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()); | |||
vo3.setNum(massiveCrack); | |||
vo4.setType(QuestionTypeEnum.PON_DING_NAME.getCode()); | |||
vo4.setNum(ponDingNum); | |||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||
vo5.setNum(longitudinalCrackNum); | |||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||
} | |||
return JsonResult.success(list); | |||
} | |||
/** | |||
* 根据用户自己的数据权限,查询对应部门的数据 | |||
* | |||
* @param user | |||
* @return | |||
*/ | |||
private List<String> getDeptIdList(User user) { | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
return null; | |||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList.add(user.getDeptId()); | |||
} | |||
return deptIdList; | |||
} | |||
} |