|
|
@@ -2,7 +2,12 @@ package com.tuoheng.admin.service.warning.query; |
|
|
|
|
|
|
|
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.conver.WarningConverMapper; |
|
|
|
import com.tuoheng.admin.entity.domain.Question; |
|
|
|
import com.tuoheng.admin.entity.domain.Warning; |
|
|
|
import com.tuoheng.admin.entity.vo.warning.WarningListVo; |
|
|
|
import com.tuoheng.admin.entity.vo.warning.WarningVo; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.QuestionMapper; |
|
|
|
import com.tuoheng.admin.mapper.WarningMapper; |
|
|
@@ -14,6 +19,9 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据Id查询预警信息业务层处理 |
|
|
|
* |
|
|
@@ -41,7 +49,11 @@ public class QueryWarningByIdService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
Warning warning = (Warning) result.getData(); |
|
|
|
return JsonResult.success(warning); |
|
|
|
|
|
|
|
// 构造返回结果对象 |
|
|
|
WarningVo warningVo = this.buildWarningVo(warning); |
|
|
|
|
|
|
|
return JsonResult.success(warningVo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -53,7 +65,7 @@ public class QueryWarningByIdService { |
|
|
|
*/ |
|
|
|
private JsonResult check(Integer tenantId, Integer id) { |
|
|
|
// 判断预警id是否为空 |
|
|
|
if (ObjectUtil.isNotNull(id)) { |
|
|
|
if (ObjectUtil.isNull(id)) { |
|
|
|
throw new ServiceException("预警ID为空"); |
|
|
|
} |
|
|
|
Warning warning = warningMapper.selectOne(new LambdaQueryWrapper<Warning>() |
|
|
@@ -66,4 +78,27 @@ public class QueryWarningByIdService { |
|
|
|
return JsonResult.success(warning); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param warning |
|
|
|
* @return warningVo |
|
|
|
*/ |
|
|
|
private WarningVo buildWarningVo(Warning warning) { |
|
|
|
WarningVo warningVo = WarningConverMapper.INSTANCE.fromWarningToWarningVo(warning); |
|
|
|
Question question = questionMapper.selectOne(Wrappers.<Question>lambdaQuery() |
|
|
|
.eq(Question::getId, warning.getQuestionId()) |
|
|
|
.eq(Question::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isNull(question)) { |
|
|
|
return warningVo; |
|
|
|
} |
|
|
|
warningVo.setQuestionType(question.getType()); |
|
|
|
warningVo.setQuestionName(question.getQuestionName()); |
|
|
|
warningVo.setQuestionDesc(question.getQuestionDesc()); |
|
|
|
warningVo.setFileCode(question.getFileCode()); |
|
|
|
warningVo.setFileName(question.getFileName()); |
|
|
|
warningVo.setFileOriginalUrl(question.getFileOriginalUrl()); |
|
|
|
warningVo.setFileMarkerUrl(question.getFileMarkerUrl()); |
|
|
|
warningVo.setLng(question.getLng()); |
|
|
|
warningVo.setLat(question.getLat()); |
|
|
|
return warningVo; |
|
|
|
} |
|
|
|
} |