|
|
@@ -0,0 +1,122 @@ |
|
|
|
package com.tuoheng.admin.service.inspectionfile.handle; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.conver.InspectionFileHandleConverMapper; |
|
|
|
import com.tuoheng.admin.entity.InspectionFile; |
|
|
|
import com.tuoheng.admin.entity.InspectionFileHandle; |
|
|
|
import com.tuoheng.admin.entity.QuestionType; |
|
|
|
import com.tuoheng.admin.enums.code.inspectionfile.QueryInspectionFilePageListByInspectionIdCodeEnum; |
|
|
|
import com.tuoheng.admin.enums.code.inspectionfilehandle.QueryInspectionFileHandleByInspectionFileIdCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.InspectionFileHandleMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionFileMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.mapper.QuestionTypeMapper; |
|
|
|
import com.tuoheng.admin.vo.InspectionFileHandleVo; |
|
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
|
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.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据任务问题ID查询任务问题处理业务层处理 |
|
|
|
* |
|
|
|
* @author wanjing |
|
|
|
* @team tuoheng |
|
|
|
* @date 2022-12-06 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class QueryInspectionFileHandleByInspectionFileIdService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InspectionFileMapper inspectionFileMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InspectionFileHandleMapper inspectionFileHandleMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QuestionTypeMapper questionTypeMapper; |
|
|
|
|
|
|
|
public JsonResult handle(String id) { |
|
|
|
log.info("进入根据任务问题ID查询任务问题处理业务, id:{}", id); |
|
|
|
JsonResult result = this.check(id); |
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("进入根据任务ID查询巡检任务问题分页列表业务:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
InspectionFile inspectionFile = (InspectionFile) result.getData(); |
|
|
|
|
|
|
|
InspectionFileHandle inspectionFileHandle = inspectionFileHandleMapper.selectOne(new LambdaQueryWrapper<InspectionFileHandle>() |
|
|
|
.eq(InspectionFileHandle::getInspectionFileId, id) |
|
|
|
.eq(InspectionFileHandle::getMark, 1)); |
|
|
|
|
|
|
|
|
|
|
|
InspectionFileHandleVo inspectionFileHandleVo = buildInspectionFileHandleVo(inspectionFile, inspectionFileHandle); |
|
|
|
|
|
|
|
return JsonResult.success(inspectionFileHandleVo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查参数 |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult check(String id) { |
|
|
|
// 判断任务问题id是否为空 |
|
|
|
if (StringUtils.isEmpty(id)) { |
|
|
|
return JsonResult.error(QueryInspectionFileHandleByInspectionFileIdCodeEnum.INSPECTION_FILE_ID_IS_NULL.getCode(), QueryInspectionFileHandleByInspectionFileIdCodeEnum.INSPECTION_FILE_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
// 判断任务是否存在 |
|
|
|
InspectionFile inspectionFile = inspectionFileMapper.selectOne(new LambdaQueryWrapper<InspectionFile>() |
|
|
|
.eq(InspectionFile::getId, id) |
|
|
|
.eq(InspectionFile::getMark, 1)); |
|
|
|
|
|
|
|
if (null == inspectionFile) { |
|
|
|
return JsonResult.error(QueryInspectionFileHandleByInspectionFileIdCodeEnum.INSPECTION_FILE_IS_NOT_EXIST.getCode(), QueryInspectionFileHandleByInspectionFileIdCodeEnum.INSPECTION_FILE_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
return JsonResult.success(inspectionFile); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理字段 |
|
|
|
*/ |
|
|
|
private InspectionFileHandleVo buildInspectionFileHandleVo(InspectionFile inspectionFile, InspectionFileHandle inspectionFileHandle) { |
|
|
|
InspectionFileHandleVo inspectionFileHandleVo = InspectionFileHandleConverMapper.INSTANCE.fromInspectionFileHandleToInspectionFileHandleVo(inspectionFileHandle); |
|
|
|
List<String> handlerImageList = null; |
|
|
|
if (!StringUtils.isEmpty(inspectionFileHandle.getHandlerImage())) { |
|
|
|
handlerImageList = new ArrayList<>(); |
|
|
|
String[] arr = inspectionFileHandle.getHandlerImage().split(","); |
|
|
|
List<String> list = Arrays.stream(arr).map(String::toString).collect(Collectors.toList()); |
|
|
|
for (String str : list) { |
|
|
|
handlerImageList.add(CommonConfig.imageURL + str); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
QuestionType questionType = questionTypeMapper.selectOne(new LambdaQueryWrapper<QuestionType>() |
|
|
|
.eq(QuestionType::getId, inspectionFile.getQuestionId()) |
|
|
|
.eq(QuestionType::getMark, 1)); |
|
|
|
if (null != questionType) { |
|
|
|
inspectionFileHandleVo.setQuestionName(questionType.getName()); |
|
|
|
inspectionFileHandleVo.setQuestionContent(questionType.getContent()); |
|
|
|
} |
|
|
|
inspectionFileHandleVo.setQuestionId(inspectionFile.getQuestionId()); |
|
|
|
inspectionFileHandleVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); |
|
|
|
inspectionFileHandleVo.setHandlerImageList(handlerImageList); |
|
|
|
return inspectionFileHandleVo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |