Browse Source

重构根据ID获取预警信息代码

tags/v1.2.0^2
wanjing 1 year ago
parent
commit
43c9116c1d
3 changed files with 166 additions and 3 deletions
  1. +2
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/conver/WarningConverMapper.java
  2. +127
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/warning/WarningVo.java
  3. +37
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/query/QueryWarningByIdService.java

+ 2
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/conver/WarningConverMapper.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.admin.conver;

import com.tuoheng.admin.entity.domain.Warning;
import com.tuoheng.admin.entity.vo.warning.WarningListVo;
import com.tuoheng.admin.entity.vo.warning.WarningVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@@ -14,5 +15,5 @@ public interface WarningConverMapper {

List<WarningListVo> fromWarningListToWarningListVoList(List<Warning> warningList);

WarningVo fromWarningToWarningVo(Warning warning);
}

+ 127
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/warning/WarningVo.java View File

@@ -0,0 +1,127 @@
package com.tuoheng.admin.entity.vo.warning;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.common.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
* 预警对象 th_warning
*
* @author wanjing
* @team tuoheng
* @date 2023-02-06
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class WarningVo extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 租户ID
*/
private Integer tenantId;

/**
* 任务ID
*/
private Integer missionId;

/**
* 发现方式 1监控摄像 2无人机巡检 3人工巡检
*/
private Integer discoveryWay;

/**
* 火灾位置名称
*/
private String location;

/**
* 预警状态 1待确认 2确认 3忽略
*/
private Integer status;

/**
* 问题ID
*/
private Integer questionId;

/**
* 处理人
*/
private Integer checkUser;

/**
* 处理时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date checkTime;

/**
* 处理结果
*/
private String checkResult;

/**
* 消息读取标识 0:未读 1已读
*/
private Integer messageRead;


/**
* 问题类型
*/
private String questionType;


/**
* 问题类型名称
*/
private String questionName;

/**
* 问题描述
*/
private String questionDesc;

/**
* 文件编码
*/
private String fileCode;

/**
* 文件名称
*/
private String fileName;

/**
* 原图片位置
*/
private String fileOriginalUrl;

/**
* 分析后的图片位置
*/
private String fileMarkerUrl;

/**
* 经度
*/
private String lng;

/**
* 纬度
*/
private String lat;

}

+ 37
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/query/QueryWarningByIdService.java View File

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

Loading…
Cancel
Save