|
|
@@ -1,17 +1,27 @@ |
|
|
|
package com.tuoheng.admin.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
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.UserTypeEnum; |
|
|
|
import com.tuoheng.admin.enums.code.inspectionFile.ListByDeptUserTypeEnum; |
|
|
|
import com.tuoheng.admin.mapper.InspectionFileMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.mapper.QuestionTypeMapper; |
|
|
|
import com.tuoheng.admin.mapper.UserMapper; |
|
|
|
import com.tuoheng.admin.query.InspectionFileQuery; |
|
|
|
import com.tuoheng.admin.service.IInspectionFileService; |
|
|
|
import com.tuoheng.admin.utils.ShiroUtils; |
|
|
|
import com.tuoheng.admin.vo.InspectionFileVo; |
|
|
|
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.SecurityUserUtils; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
@@ -42,6 +52,10 @@ public class InspectionFileServiceImpl implements IInspectionFileService { |
|
|
|
@Autowired |
|
|
|
private QuestionTypeMapper questionTypeMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 问题类型和任务名称 |
|
|
@@ -95,5 +109,78 @@ public class InspectionFileServiceImpl implements IInspectionFileService { |
|
|
|
return JsonResult.success(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JsonResult getListByDeptUserType(InspectionFileQuery query) { |
|
|
|
if(query.getUserId()==null){ |
|
|
|
JsonResult.error(ListByDeptUserTypeEnum.QUERY_IS_FAILED.getCode(),ListByDeptUserTypeEnum.QUERY_IS_FAILED.getMsg()); |
|
|
|
} |
|
|
|
//获取当前登录人信息 |
|
|
|
String username = SecurityUserUtils.username(); |
|
|
|
if(StringUtils.isEmpty(username)){ |
|
|
|
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() |
|
|
|
.eq(User::getMark, 1).eq(User::getUsername, username)); |
|
|
|
if(ObjectUtil.isNull(user)){ |
|
|
|
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
String tenantId = ShiroUtils.getTenantId(); |
|
|
|
//用户角色判断 1超级管理员 2部门管理员 3普通用户 |
|
|
|
if(null == user.getType()){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
List<ListByDeptUserTypeVo> list = new ArrayList<>(); |
|
|
|
ListByDeptUserTypeVo vo = new ListByDeptUserTypeVo(); |
|
|
|
//问题数量 |
|
|
|
Long count = 0l; |
|
|
|
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 |
|
|
|
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType()){ |
|
|
|
//直接查问题列表 |
|
|
|
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() |
|
|
|
.eq(InspectionFile::getMark, 1) |
|
|
|
.eq(InspectionFile::getTenantId, tenantId) |
|
|
|
.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.getQuestionId())){ |
|
|
|
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::getId, inspectionFile.getQuestionId())); |
|
|
|
if(ObjectUtil.isNull(questionType)){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
Integer name = questionType.getName(); |
|
|
|
//1坑槽 |
|
|
|
if(name==1) { |
|
|
|
count+=1; |
|
|
|
vo.setType(1); |
|
|
|
vo.setNum(count); |
|
|
|
list.add(vo); |
|
|
|
} |
|
|
|
// |
|
|
|
if(name==2){ |
|
|
|
|
|
|
|
} |
|
|
|
// |
|
|
|
if(name==3){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |