Browse Source

事故告警提示接口

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
25b370705d
2 changed files with 116 additions and 3 deletions
  1. +63
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/AccidentTipsService.java
  2. +53
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentTipsVo.java

+ 63
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/AccidentTipsService.java View File

@@ -1,8 +1,24 @@
package com.tuoheng.admin.service;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.Section;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.SectionMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.vo.accident.AccidentTipsVo;
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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -17,15 +33,59 @@ public class AccidentTipsService {
@Autowired
private AccidentMapper accidentMapper;

@Autowired
private SectionMapper sectionMapper;

@Autowired
private DeptMapper deptMapper;

@Autowired
private UserMapper userMapper;

/**
* 事故告警提示
*
* @param accidentId
* @return
*/
public JsonResult getTips(String accidentId) {

//校验
if (StringUtils.isEmpty(accidentId)) {
return JsonResult.error(AccidentEnum.ACCIDENT_ID_IS_NULL.getCode(), AccidentEnum.ACCIDENT_ID_IS_NULL.getMsg());
}
//根据事故id查询相应属性值
Accident accident = accidentMapper.selectById(accidentId);
if (ObjectUtils.isEmpty(accident)) {
return JsonResult.error(AccidentEnum.DATA_IS_NULL.getCode(), AccidentEnum.DATA_IS_NULL.getMsg());
}
AccidentTipsVo accidentTipsVo = new AccidentTipsVo();
BeanUtils.copyProperties(accident, accidentTipsVo);
//路段范围
if (StringUtils.isNotEmpty(accident.getSectionId())) {
Section section = sectionMapper.selectById(accident.getSectionId());
if (StringUtils.isNotEmpty(section.getSectionRange())) {
accidentTipsVo.setSectionRange(section.getSectionRange());
}
}
//监管部门 部门管理员
if (StringUtils.isEmpty(accident.getDeptId())) {
throw new ServiceException("事故对应的监管部门id为空");
}
Dept dept = deptMapper.selectById(accident.getDeptId());
if (StringUtils.isNotEmpty(dept.getName())) {
accidentTipsVo.setDeptName(dept.getName());
}
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getDeptId, accident.getDeptId())
.eq(User::getRoleId, RoleEnum.ADMIN.getCode())
.eq(User::getMark, MarkEnum.VALID.getCode()));
if(ObjectUtils.isEmpty(user)){
throw new ServiceException("登录用户对应的部门没有管理员账户");
}
if(StringUtils.isNotEmpty(user.getRealname())){
accidentTipsVo.setRealName(user.getRealname());
}

return null;
return JsonResult.success(accidentTipsVo);
}
}

+ 53
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentTipsVo.java View File

@@ -0,0 +1,53 @@
package com.tuoheng.admin.vo.accident;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* @Author ChengWang
* @Date 2023/3/15
*/
@Data
public class AccidentTipsVo {

/**
* 事故id
*/
private String id;

/**
* 事故发生时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
*公路代号
*/
private String roadCode;

/**
* 路段范围
*/
private String sectionRange;

/**
* 监管部门
*/
private String deptName;

/**
* 部门管理员
*/
private String realName;

/**
* 事故状态
*/
private Integer status;

}

Loading…
Cancel
Save