Browse Source

事故时间轴接口

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
3573c9c7bc
2 changed files with 76 additions and 0 deletions
  1. +66
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java
  2. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentPromptlyLookVo.java

+ 66
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java View File

@@ -1,9 +1,26 @@
package com.tuoheng.admin.service.accident;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
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.AccidentRead;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.AccidentReadMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.vo.accident.AccidentPromptlyLookVo;
import com.tuoheng.admin.vo.accident.AccidentTimeAxisVo;
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.List;

/**
* @Author ChengWang
* @Date 2023/3/15
@@ -12,12 +29,61 @@ import org.springframework.stereotype.Service;
@Service
public class TimeAxisService {

@Autowired
private AccidentMapper accidentMapper;

@Autowired
private AccidentReadMapper accidentReadMapper;

@Autowired
private UserMapper userMapper;

/**
* 事故时间轴
* @param accidentId
* @return
*/
public JsonResult getTimeAxis(String accidentId) {
//校验
if(StringUtils.isEmpty(accidentId)){
return JsonResult.error(AccidentEnum.ACCIDENT_ID_IS_NULL.getCode(),AccidentEnum.ACCIDENT_ID_IS_NULL.getMsg());
}
Accident accident = accidentMapper.selectById(accidentId);
if(ObjectUtils.isEmpty(accident)){
return JsonResult.error(AccidentEnum.ACCIDENT_DATA_IS_NULL.getCode(),AccidentEnum.ACCIDENT_DATA_IS_NULL.getMsg());
}
AccidentTimeAxisVo vo = new AccidentTimeAxisVo();
//发生时间
if(accident.getCreateTime() != null){
vo.setCreateTime(accident.getCreateTime());
}
//立即查看时间 获取应急记录可读表每个用户对应此应急事故已标记可读的时间存list集合
List<AccidentPromptlyLookVo> list = new ArrayList<>();;
List<AccidentRead> accidentReadList = accidentReadMapper.selectList(Wrappers.<AccidentRead>lambdaQuery()
.eq(AccidentRead::getAccidentId, accidentId));
if(CollectionUtils.isEmpty(accidentReadList) || accidentReadList.size() == 0){
list.add(null);
}
//遍历每个用户对应事故的时间
for (AccidentRead accidentRead : accidentReadList) {
AccidentPromptlyLookVo promptlyLookVo = new AccidentPromptlyLookVo();
promptlyLookVo.setLookNowTime(accidentRead.getCreateTime());
User user = userMapper.selectById(accidentRead.getUserId());
if(StringUtils.isNotEmpty(user.getRealname())){
promptlyLookVo.setRealName(user.getRealname());
}
//已读人数
promptlyLookVo.setNumber(accidentReadList.size());
list.add(promptlyLookVo);
}
vo.setLookTimeList(list);
//核实时间






return null;
}
}

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

@@ -13,6 +13,16 @@ import java.util.Date;
@Data
public class AccidentPromptlyLookVo {

/**
* 已读人姓名
*/
private String realName;

/**
* 已读人数
*/
private Integer number;;

/**
* 立即查看
*/

Loading…
Cancel
Save