wanjing 1 год назад
Родитель
Сommit
69a66be20f
7 измененных файлов: 182 добавлений и 2 удалений
  1. +12
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java
  2. +47
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentEnum.java
  3. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/AccidentQuery.java
  4. +6
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java
  5. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java
  6. +66
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java
  7. +46
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/QueryAccidentPageVO.java

+ 12
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.common.core.utils.JsonResult;
@@ -40,4 +41,15 @@ public class AccidentController {
return accidentService.getAccidentInfo(id);
}

/**
* 告警列表分页
*/
@GetMapping("/index")
public JsonResult queryAccidentPage(AccidentQuery query){
return accidentService.index(query);
}




}

+ 47
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentEnum.java Просмотреть файл

@@ -0,0 +1,47 @@
package com.tuoheng.admin.enums;

/**
* @Author ChengWang
* @Date 2023/3/8
*/
public enum AccidentEnum {

DATA_IS_NULL(1210101, "数据为空"),
USER_IS_NOT_EXIST(1210102, "用户为空"),
TENANT_ID_IS_NULL(1210103,"租户id为空"),
ACCIDENT_DATA_IS_NULL(1210104,"应急数据不存在");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

AccidentEnum(int code, String msg){
this.code = code;
this.msg = msg;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}



}

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/AccidentQuery.java Просмотреть файл

@@ -23,9 +23,9 @@ public class AccidentQuery extends BaseQuery {
private String code;

/**
* 部门名称
* 部门ID
*/
private String name;
private String deptId;

/**
*起始日期

+ 6
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.tuoheng.admin.service.accident;

import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.service.accident.query.QueryAccidentByIdService;
import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService;
@@ -31,4 +32,9 @@ public class AccidentServiceImpl implements IAccidentService {
public JsonResult getAccidentInfo(String id) {
return queryAccidentByIdService.getInfoById(id);
}

@Override
public JsonResult index(AccidentQuery query) {
return queryAccidentPageListService.index(query);
}
}

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java Просмотреть файл

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

import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Section;
import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.query.SectionQuery;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest;
@@ -30,4 +31,6 @@ public interface IAccidentService {
*/
JsonResult getAccidentInfo(String id);

JsonResult index(AccidentQuery query);

}

+ 66
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java Просмотреть файл

@@ -12,27 +12,36 @@ import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.Inspection;
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.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest;
import com.tuoheng.admin.service.inspection.query.handle.GenerateInspectionFieldHander;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.accident.AccidentVo;
import com.tuoheng.admin.vo.accident.QueryAccidentPageVO;
import com.tuoheng.admin.vo.inspection.InspectionVo;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
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.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -137,4 +146,61 @@ public class QueryAccidentPageListService {
return map;
}

public JsonResult index(AccidentQuery query) {
//校验
if(query.getLimit() == null && query.getPage() == null){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}

//当前租户下
String tenantId = CurrentUserUtil.getTenantId();
if(tenantId == null){
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(),AccidentEnum.TENANT_ID_IS_NULL.getMsg());
}
query.setTenantId(tenantId);
IPage<Accident> page = new Page<>(query.getPage(),query.getLimit());
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(),query.getLimit());
//搜索时间
Date startTime = null;
Date endTime = null;
if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getStartTime()+" 00:00:00");
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getEndTime()+" 23:59:59");
}
query.setAccidentStartTime(startTime);
query.setAccidentEndTime(endTime);
//获取分页数据
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery()
.eq(null != query.getCode(),Accident::getRoadCode,query.getCode())
.eq(null != query.getDeptId(),Accident::getDeptId,query.getDeptId())
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(),
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime())
.eq(Accident::getMark, MarkEnum.VALID.getCode())
.orderByDesc(Accident::getCreateTime));
//属性复制
List<QueryAccidentPageVO> result = accidentPageData.getRecords().stream().map(x -> {
QueryAccidentPageVO vo = new QueryAccidentPageVO();
BeanUtils.copyProperties(x, vo);
//公路代号
if (StringUtils.isNotEmpty(x.getRoadCode())) {
vo.setCode(x.getRoadCode());
}
//监管部门
if (StringUtils.isNotEmpty(x.getDeptId())) {
//根据当前部门id查询对应的部门名称
Dept dept = deptMapper.selectById(x.getDeptId());
vo.setName(dept.getName() !=null?dept.getName():"");
}

return vo;
}).collect(Collectors.toList());
pageData.setPages(accidentPageData.getPages());
pageData.setRecords(result);
pageData.setTotal(accidentPageData.getTotal());
pageData.setCurrent(accidentPageData.getCurrent());

return JsonResult.success(pageData);


}
}

+ 46
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/QueryAccidentPageVO.java Просмотреть файл

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

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;

/**
* @Author ChengWang
* @Date 2023/3/7
*/
@Data
public class QueryAccidentPageVO {

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

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

/**
*是否有伤亡:0:否;1:是
*/
private Integer isCasualties;

/**
* 事故类型
*/
private String questionName;

/**
* 事故状态:1未处理 2处理中 3已忽略 4已处理
*/
private Integer status;

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

}

Загрузка…
Отмена
Сохранить