Преглед на файлове

根据AI算法识别出应急类型,应急数据入库

tags/v1.2.0^2
chengwang преди 1 година
родител
ревизия
4284a3247b
променени са 12 файла, в които са добавени 257 реда и са изтрити 9 реда
  1. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java
  2. +29
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentStatusEnum.java
  3. +25
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentTaskEnum.java
  4. +25
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/IsCasualtiesEnum.java
  5. +25
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/IsDrivingSafetyEnum.java
  6. +25
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/IsFireEnum.java
  7. +25
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/UavReturnEnum.java
  8. +4
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java
  9. +3
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java
  10. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentDetailsService.java
  11. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java
  12. +88
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java Целия файл

@@ -62,6 +62,11 @@ public class Accident extends BaseEntity {
*/
private String sectionId;

/**
* 路段名称
*/
private String sectionName;

/**
* 问题ID
*/

+ 29
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentStatusEnum.java Целия файл

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

import lombok.Getter;

/**
* @Author ChengWang
* @Date 2023/3/10
*/
public enum AccidentStatusEnum {

UNTREATED(1,"未处理"),

PROCESSING(2,"处理中"),

IGNORED(3,"已忽略"),

PROCESSED(4,"已处理");

AccidentStatusEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 25
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentTaskEnum.java Целия файл

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

import lombok.Getter;

/**
* @Author ChengWang
* @Date 2023/3/10
*/
public enum AccidentTaskEnum {

INSPECTION_ACCIDENT_TASK(1,"应急任务"),

INSPECTION_TASK(0,"巡检任务");

AccidentTaskEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 25
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/IsCasualtiesEnum.java Целия файл

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

import lombok.Getter;

/**
* @Author ChengWang
* @Date 2023/3/10
*/
public enum IsCasualtiesEnum {

CASUALTIES(1,"有"),

IS_NO_CASUALTIES(0,"否");

IsCasualtiesEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 25
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/IsDrivingSafetyEnum.java Целия файл

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

import lombok.Getter;

/**
* @Author ChengWang
* @Date 2023/3/10
*/
public enum IsDrivingSafetyEnum {

DRIVING_SAFETY(1,"有"),

IS_NO_DRIVING_SAFETY(0,"否");

IsDrivingSafetyEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 25
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/IsFireEnum.java Целия файл

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

import lombok.Getter;

/**
* @Author ChengWang
* @Date 2023/3/10
*/
public enum IsFireEnum {

IS_FIRE(1,"有"),

IS_NO_FIRE(0,"否");

IsFireEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 25
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/UavReturnEnum.java Целия файл

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

import lombok.Getter;

/**
* @Author ChengWang
* @Date 2023/3/10
*/
public enum UavReturnEnum {

UAV_RETURN(1,"已回仓"),

UAV_RETURN_IS_NOT(0,"未回仓");

UavReturnEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 4
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java Целия файл

@@ -1,10 +1,13 @@
package com.tuoheng.admin.service.accident;

import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.mapper.AccidentMapper;
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.QueryAccidentDetailsService;
import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -16,7 +19,7 @@ import org.springframework.stereotype.Service;
*/
@Service
@Slf4j
public class AccidentServiceImpl implements IAccidentService {
public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Accident> implements IAccidentService {

@Autowired
private QueryAccidentPageListService queryAccidentPageListService;

+ 3
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java Целия файл

@@ -1,14 +1,16 @@
package com.tuoheng.admin.service.accident;

import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.common.core.common.IBaseService;
import com.tuoheng.common.core.utils.JsonResult;

/**
* @Author ChengWang
* @Date 2022/11/17
*/
public interface IAccidentService {
public interface IAccidentService extends IBaseService<Accident> {

/**
* 查询事故列表(分页)

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentDetailsService.java Целия файл

@@ -109,8 +109,8 @@ public class QueryAccidentDetailsService {
* @param vo
*/
private void getInspectionById(Accident accident, AccidentDetailsVo vo) {
if(StringUtils.isNotEmpty(accident.getAccidentInspectionId())){
Inspection inspection = inspectionMapper.selectById(accident.getAccidentInspectionId());
if(StringUtils.isNotEmpty(accident.getInspectionId())){
Inspection inspection = inspectionMapper.selectById(accident.getInspectionId());
if(inspection.getAirportName() !=null){
vo.setAirPortName(inspection.getAirportName());
}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java Целия файл

@@ -133,7 +133,7 @@ public class QueryAccidentPageListService {
}

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

+ 88
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java Целия файл

@@ -5,17 +5,19 @@ import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.AiAnalyseTypeEnum;
import com.tuoheng.admin.enums.FileTypeEnum;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.SourceEnum;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.third.DspCallbackRequest;
import com.tuoheng.admin.request.third.QuestionFile;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.utils.GaodeUtil;
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.*;
import lombok.extern.slf4j.Slf4j;
@@ -25,7 +27,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
@@ -53,6 +58,12 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
@Autowired
private QuestionTypeMapper questionTypeMapper;

@Autowired
private RoadInformationMapper roadInformationMapper;

@Autowired
private IAccidentService accidentService;

/**
* 保存DSP回调数据
*
@@ -256,10 +267,83 @@ public class DspCallbackServiceImpl implements IDspCallbackService {

log.info("批量插入问题图片数据");
CommonUtils.batchOperate((x) -> inspectionFileMapper.addBatch(x), thirstyQuestionFiles, 1000);

//批量插入问题之后调用saveAccidentData方法保存应急记录数据入库
Boolean flag = this.saveAccidentData(thirstyQuestionFiles);
log.info("预警数据入库结束,{}",flag);

}
return JsonResult.success();
}

/**
* 应急记录数据入库
* @param inspectionFileList
* @return
*/
private Boolean saveAccidentData(List<InspectionFile> inspectionFileList){
log.info("应急数据入库开始....");
//获取当前登录用户
User user = CurrentUserUtil.getUserInfo();
//部门
String deptId = user.getDeptId();
if(StringUtils.isEmpty(deptId)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
List<Accident> accidentList = new ArrayList<>();
List<QuestionType> questionTypeList = questionTypeMapper.selectList(Wrappers.<QuestionType>lambdaQuery()
.eq(QuestionType::getMark, MarkEnum.VALID.getCode()));
Map<String,QuestionType> typeMap = new HashMap<>();
for (QuestionType type : questionTypeList) {
typeMap.put(type.getCode(),type);
}
//调用问题列表接口
for (InspectionFile inspectionFile : inspectionFileList) {
Accident accident = new Accident();
//问题类型为应急类型时添加数据
if(inspectionFile.getQuestionCode().equals(QuestionTypeEnum.PON_DING_NAME.getCode())){
accident.setTenantId(inspectionFile.getTenantId());
accident.setDeptId(deptId);
accident.setInspectionId(inspectionFile.getInspectionId());
accident.setInspectionFileId(inspectionFile.getId());
accident.setAccidentInspectionId(inspectionFile.getInspectionId());
//根据巡检任务查询对应的公路id
Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId());
if(ObjectUtils.isNotEmpty(inspection)){
accident.setRoadId(inspection.getRoadId());
accident.setSectionId(inspection.getSectionId());
accident.setSectionName(inspection.getSectionName());
//根据巡检任务类型判断当前应急事故类型
Integer accidentTaskType = inspection.getAccidentTask();
if(AccidentTaskEnum.INSPECTION_ACCIDENT_TASK.getCode() == accidentTaskType){
accident.setFlag(FlagEnum.ACCIDENT.getCode());
}else {
accident.setFlag(FlagEnum.INSPECTION_ACCIDENT.getCode());
}
}
//公路代号
RoadInformation roadInformation = roadInformationMapper.selectById(inspection.getRoadId());
if(ObjectUtils.isNotEmpty(roadInformation)){
accident.setRoadCode(roadInformation.getCode());
}
accident.setQuestionId(inspectionFile.getQuestionId());
accident.setQuestionCode(inspectionFile.getQuestionCode());
accident.setQuestionName(inspectionFile.getQuestionName());
accident.setIsCasualties(IsCasualtiesEnum.IS_NO_CASUALTIES.getCode());
accident.setIsDrivingSafety(IsDrivingSafetyEnum.IS_NO_DRIVING_SAFETY.getCode());
accident.setIsFire(IsFireEnum.IS_NO_FIRE.getCode());
accident.setLongitude(inspectionFile.getLongitude());
accident.setLatitude(inspectionFile.getLatitude());
accident.setUavReturn(UavReturnEnum.UAV_RETURN_IS_NOT.getCode());
accident.setStatus(AccidentStatusEnum.UNTREATED.getCode());
accident.setCreateUser(user.getUsername());
accident.setCreateTime(inspectionFile.getCreateTime());
accidentList.add(accident);
}
}
return accidentService.saveBatch(accidentList);
}

/**
* 获取飞行坐标
*

Loading…
Отказ
Запис