Bladeren bron

提交预警核实,忽略,上报等代码

tags/v1.2.0^2
wanjing 1 jaar geleden
bovenliggende
commit
5d51332bf8
17 gewijzigde bestanden met toevoegingen van 764 en 17 verwijderingen
  1. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java
  2. +42
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java
  3. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java
  4. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Inspection.java
  5. +21
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AccidentVerifyRequest.java
  6. +41
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/ReportAccidentRequest.java
  7. +20
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/ReportNoAccidentRequest.java
  8. +62
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java
  9. +41
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java
  10. +82
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java
  11. +91
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java
  12. +120
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java
  13. +172
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java
  14. +39
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/DroneControlService.java
  15. +1
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java
  16. +13
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java
  17. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java Bestand weergeven

@@ -49,6 +49,16 @@ public interface SystemConstant {
*/
String API_AIRPORT_GET_WEATHER = "/api/airportInterface/getWeather";

/**
* 机场平台:控制无人机
*/
String API_AIRPORT_DRONE_CONTROL = "/api/airportInterface/droneCommand";

/**
* 机场平台:获取机场状态
*/
String API_AIRPORT_STATUS_BY_AIRPORT_ID = "/api/airportInterface/getAirportStatusByAirportId";

// 飞手平台不同接口url
/**
* 新增任务接口

+ 42
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java Bestand weergeven

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

import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.AccidentVerifyRequest;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.request.accident.ReportAccidentRequest;
import com.tuoheng.admin.request.accident.ReportNoAccidentRequest;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

/**
* 事故前端控制器
@@ -45,17 +45,18 @@ public class AccidentController {
* 告警列表分页
*/
@GetMapping("/index")
public JsonResult queryAccidentPage(AccidentQuery query){
public JsonResult queryAccidentPage(AccidentQuery query) {
return accidentService.index(query);
}

/**
* 事故详情
*
* @param id
* @return
*/
@GetMapping("/details/{id}")
public JsonResult accidentDetails(@PathVariable("id") String id){
public JsonResult accidentDetails(@PathVariable("id") String id) {
return accidentService.accidentDetails(id);
}

@@ -63,7 +64,7 @@ public class AccidentController {
* 告警弹窗通知下发
*/
@GetMapping("/notice")
public JsonResult notice(){
public JsonResult notice() {
return accidentService.notice();
}

@@ -87,5 +88,39 @@ public class AccidentController {
return accidentService.getTimeAxis(accidentId);
}

/**
* 事故核实
* @param request
* @return
*/
@PostMapping("/verify")
public JsonResult verify(AccidentVerifyRequest request) {
return accidentService.verify(request);
}

/**
* 事故上报
*/
@PostMapping("/report/accident")
public JsonResult report(ReportAccidentRequest request) {
return accidentService.report(request);
}

/**
* 无事故
*/
@PostMapping("/report/no/accident")
public JsonResult noAccident(ReportNoAccidentRequest request) {
return accidentService.noAccident(request);
}

/**
* 预警忽略
*
* @return
*/
@PostMapping("/ignore/{id}")
public JsonResult ignore(@PathVariable("id") String id){
return accidentService.ignore(id);
}
}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java Bestand weergeven

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

/**
* 是否有事故:0:无;1:有
*/
private Integer isAccident;

/**
* 是否有伤亡:0:无;1:有
*/

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Inspection.java Bestand weergeven

@@ -49,7 +49,7 @@ public class Inspection extends BaseEntity {
private String name;

/**
* 巡检任务类型 1 临时巡检
* 巡检任务类型 1:临时巡检 2:应急任务
*/
private Integer type;

@@ -275,8 +275,8 @@ public class Inspection extends BaseEntity {
private String patrolLocation;

/**
* 任务类型:0:巡检任务 1:应急任务
* 应急任务关联数据任务ID
*/
private Integer accidentTask;
private String emergencyDataInspectionId;

}

+ 21
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AccidentVerifyRequest.java Bestand weergeven

@@ -0,0 +1,21 @@
package com.tuoheng.admin.request.accident;

import lombok.Data;

/**
* 事故核实请求实体
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Data
public class AccidentVerifyRequest {


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

}

+ 41
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/ReportAccidentRequest.java Bestand weergeven

@@ -0,0 +1,41 @@
package com.tuoheng.admin.request.accident;

import lombok.Data;

/**
* 事故上报请求实体
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Data
public class ReportAccidentRequest {


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

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

/**
* 是否影响驾驶安全:0:无;1:有
*/
private Integer isDrivingSafety;

/**
* 是否有明火:0:无;1:有
*/
private Integer isFire;

/**
* 事故现场描述
*/
private String record;

}

+ 20
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/ReportNoAccidentRequest.java Bestand weergeven

@@ -0,0 +1,20 @@
package com.tuoheng.admin.request.accident;

import lombok.Data;

/**
* 无事故请求实体
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Data
public class ReportNoAccidentRequest {

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

}

+ 62
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java Bestand weergeven

@@ -3,10 +3,17 @@ 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.AccidentVerifyRequest;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.request.accident.ReportAccidentRequest;
import com.tuoheng.admin.request.accident.ReportNoAccidentRequest;
import com.tuoheng.admin.service.accident.ignore.AccidentIgnoreService;
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.admin.service.accident.reoprt.ReportAccidentService;
import com.tuoheng.admin.service.accident.reoprt.ReportNoAccidentService;
import com.tuoheng.admin.service.accident.verify.AccidentVerifyService;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
@@ -39,6 +46,18 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden
@Autowired
private TimeAxisService timeAxisService;

@Autowired
private AccidentVerifyService accidentVerifyService;

@Autowired
private ReportAccidentService reportAccidentService;

@Autowired
private ReportNoAccidentService reportNoAccidentService;

@Autowired
private AccidentIgnoreService accidentIgnoreService;

@Override
public JsonResult getPageList(QueryAccidentPageListRequest request) {
return queryAccidentPageListService.getPageList(request);
@@ -73,4 +92,47 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden
public JsonResult getTimeAxis(String accidentId) {
return timeAxisService.getTimeAxis(accidentId);
}

/**
* 事故核实
*
* @param request
* @return
*/
public JsonResult verify(AccidentVerifyRequest request) {
return accidentVerifyService.verify(request);
}

/**
* 事故上报
*
* @param request
* @return
*/
@Override
public JsonResult report(ReportAccidentRequest request) {
return reportAccidentService.report(request);
}

/**
* 无事故
*
* @param request
* @return
*/
@Override
public JsonResult noAccident(ReportNoAccidentRequest request) {
return reportNoAccidentService.report(request);
}

/**
* 忽略
*
* @param id
* @return
*/
@Override
public JsonResult ignore(String id) {
return accidentIgnoreService.ignore(id);
}
}

+ 41
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java Bestand weergeven

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

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

@@ -30,6 +33,7 @@ public interface IAccidentService extends IBaseService<Accident> {

/**
* 应急列表分页
*
* @param query
* @return
*/
@@ -37,6 +41,7 @@ public interface IAccidentService extends IBaseService<Accident> {

/**
* 事故详情
*
* @param id
* @return
*/
@@ -44,12 +49,14 @@ public interface IAccidentService extends IBaseService<Accident> {

/**
* 告警弹窗通知下发
*
* @return
*/
JsonResult notice();

/**
* 事故告警提示
*
* @param accidentId
* @return
*/
@@ -57,8 +64,42 @@ public interface IAccidentService extends IBaseService<Accident> {

/**
* 事故时间轴
*
* @param accidentId
* @return
*/
JsonResult getTimeAxis(String accidentId);

/**
* 事故核实
*
* @param request
* @return
*/
JsonResult verify(AccidentVerifyRequest request);

/**
* 事故上报
*
* @param request
* @return
*/
JsonResult report(ReportAccidentRequest request);

/**
* 无事故
*
* @param request
* @return
*/
JsonResult noAccident(ReportNoAccidentRequest request);

/**
* 忽略
*
* @param id
* @return
*/
JsonResult ignore(String id);

}

+ 82
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java Bestand weergeven

@@ -0,0 +1,82 @@
package com.tuoheng.admin.service.accident.ignore;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.request.accident.ReportAccidentRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
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.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 忽略事故业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Slf4j
@Service
public class AccidentIgnoreService {

@Autowired
private AccidentMapper accidentMapper;

public JsonResult ignore(String id) {
// log.info("进入忽略事故业务");
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();
JsonResult result = this.check(tenantId, id);
if (0 != result.getCode()) {
log.info("忽略事故业务:校验失败:{}", result.getMsg());
return result;
}

Accident accident = (Accident) result.getData();
Accident accidentUpdate = new Accident();
accidentUpdate.setId(accident.getId());
accidentUpdate.setStatus(AccidentStatusEnum.IGNORED.getCode());
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setCheckUser(userId);
accidentUpdate.setCheckTime(DateUtils.now());
accidentMapper.updateById(accidentUpdate);

return JsonResult.success();
}

/**
* 检查参数
*
* @param tenantId
* @param id
* @return
*/
private JsonResult check(String tenantId, String id) {
if (StringUtils.isEmpty(id)) {
throw new ServiceException("事故ID为空");
}
Accident accident = accidentMapper.selectOne(new LambdaQueryWrapper<Accident>()
.eq(Accident::getTenantId, tenantId)
.eq(Accident::getId, id)
.eq(Accident::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理,不能在忽略");
}
return JsonResult.success(accident);
}

}

+ 91
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java Bestand weergeven

@@ -0,0 +1,91 @@
package com.tuoheng.admin.service.accident.reoprt;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.request.accident.ReportAccidentRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
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.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 无事故上报业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Slf4j
@Service
public class ReportAccidentService {

@Autowired
private AccidentMapper accidentMapper;

public JsonResult report(ReportAccidentRequest request) {
// log.info("进入事故上报业务");
// User user = CurrentUserUtil.getUserInfo();
// String userId = user.getId();
// String tenantId = user.getTenantId();

String userId = "111";
String tenantId = "0";

JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("无事故业务:校验失败:{}", result.getMsg());
return result;
}

Accident accident = (Accident) result.getData();
Accident accidentUpdate = new Accident();
accidentUpdate.setId(accident.getId());
accidentUpdate.setIsAccident(1);
accidentUpdate.setIsCasualties(request.getIsCasualties());
accidentUpdate.setIsDrivingSafety(request.getIsDrivingSafety());
accidentUpdate.setIsFire(request.getIsFire());
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSED.getCode());
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setCheckUser(userId);
accidentUpdate.setCheckTime(DateUtils.now());
accidentUpdate.setRecord(request.getRecord());
accidentMapper.updateById(accidentUpdate);

return JsonResult.success();
}

/**
* 检查参数
*
* @param tenantId
* @param request
* @return
*/
private JsonResult check(String tenantId, ReportAccidentRequest request) {
if (StringUtils.isEmpty(request.getAccidentId())) {
throw new ServiceException("事故ID为空");
}
Accident accident = accidentMapper.selectOne(new LambdaQueryWrapper<Accident>()
.eq(Accident::getTenantId, tenantId)
.eq(Accident::getId, request.getAccidentId())
.eq(Accident::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理");
}
return JsonResult.success(accident);
}

}

+ 120
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java Bestand weergeven

@@ -0,0 +1,120 @@
package com.tuoheng.admin.service.accident.reoprt;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.request.accident.ReportAccidentRequest;
import com.tuoheng.admin.request.accident.ReportNoAccidentRequest;
import com.tuoheng.admin.service.third.airport.DroneControlService;
import com.tuoheng.admin.utils.CurrentUserUtil;
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.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 无事故业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Slf4j
@Service
public class ReportNoAccidentService {

@Autowired
private AccidentMapper accidentMapper;

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private DroneControlService droneControlService;

public JsonResult report(ReportNoAccidentRequest request) {
// log.info("进入事故上报业务");
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();
JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("事故上报业务:校验失败:{}", result.getMsg());
return result;
}

Accident accident = (Accident) result.getData();

Accident accidentUpdate = new Accident();
accidentUpdate.setId(accident.getId());
accidentUpdate.setIsAccident(0);
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSED.getCode());
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setCheckUser(userId);
accidentUpdate.setCheckTime(DateUtils.now());
accidentMapper.updateById(accidentUpdate);



return JsonResult.success();
}

/**
* 检查参数
*
* @param tenantId
* @param request
* @return
*/
private JsonResult check(String tenantId, ReportNoAccidentRequest request) {
if (StringUtils.isEmpty(request.getAccidentId())) {
throw new ServiceException("事故ID为空");
}
Accident accident = accidentMapper.selectOne(new LambdaQueryWrapper<Accident>()
.eq(Accident::getTenantId, tenantId)
.eq(Accident::getId, request.getAccidentId())
.eq(Accident::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理");
}
return JsonResult.success(accident);
}

/**
* 无人机回仓
*
* @param inspectionId
*/
private void droneReturn(String inspectionId) {
// 向机场发送无人机回舱指令
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getId, accident.getInspectionId())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
JSONObject jsonObject = new JSONObject();
jsonObject.put("zhilin", "03");
jsonObject.put("taskId", inspection.getId());
jsonObject.put("airportId", inspection.getAirportId());
jsonObject.put("msg", "回仓");
droneControlService.execute(jsonObject);
}

}

+ 172
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java Bestand weergeven

@@ -0,0 +1,172 @@
package com.tuoheng.admin.service.accident.verify;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.request.accident.AccidentVerifyRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.HttpUtils;
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 org.springframework.transaction.annotation.Transactional;

/**
* 事故核实业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-03-15
*/
@Slf4j
@Service
public class AccidentVerifyService {

@Autowired
private AccidentMapper accidentMapper;

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

/**
*
* 1、向机场起降平台推送指令,无人机前往事故发生地点,即获取拍摄到事故照片时所处的经纬度,并在事故地点上方悬停
* 2、修改该事故状态为处理中
*
* @param request
* @return
*/
@Transactional
public JsonResult verify(AccidentVerifyRequest request) {
// log.info("进入事故核实业务");
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();

JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("事故核实业务:校验失败:{}", result.getMsg());
return result;
}

Accident accident = (Accident) result.getData();

Inspection oldInspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getId, accident.getInspectionId())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));

this.createInspection(user, oldInspection);

// 1、向机场起降平台推送指令,无人机前往事故发生地点,即获取拍摄到事故照片时所处的经纬度,并在事故地点上方悬停
this.callOldAirpor(accident, oldInspection);

Accident accidentUpdate = new Accident();
accidentUpdate.setId(accident.getId());
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSING.getCode());
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.(DateUtils.now());
accidentMapper.updateById(accidentUpdate);

return JsonResult.success();
}

/**
* 检查参数
*
* @param tenantId
* @param request
* @return
*/
private JsonResult check(String tenantId, AccidentVerifyRequest request) {
if (StringUtils.isEmpty(request.getAccidentId())) {
throw new ServiceException("事故ID为空");
}
Accident accident = accidentMapper.selectOne(new LambdaQueryWrapper<Accident>()
.eq(Accident::getTenantId, tenantId)
.eq(Accident::getId, request.getAccidentId())
.eq(Accident::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理,不能在核实");
}
return JsonResult.success(accident);
}

/**
* 创建应急任务
*
* @param user
* @param oldInspection
* @return
*/
private Inspection createInspection(User user, Inspection oldInspection) {
Inspection inspection = new Inspection();
String code = DateUtils.generateCode("XJRW");;
inspection.setCode(code);
inspection.setName("应急任务" + code);
inspection.setTenantId(user.getTenantId());
inspection.setType(2);
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode()); // 设置应急任务状态为飞行中
inspection.setInspectionType(InspectionTypeEnum.AIRPORT.getCode());
inspection.setAirportId(oldInspection.getAirportId());
inspection.setAirportName(oldInspection.getAirportName());
inspection.setInspectionLine(0);
inspection.setInspectionLineName("");
inspection.setExecutionStartTime(DateUtils.now());
inspection.setCreateUser(user.getId());
inspection.setCreateTime(DateUtils.now());
inspection.setEmergencyDataInspectionId(oldInspection.getId());

Integer count = inspectionMapper.insert(inspection);
if (count <= 0) {
log.info("创建应急任务失败");
throw new ServiceException("创建应急任务失败");
} else {
log.info("创建应急任务成功, inspection={}", inspection);
}
return inspection;
}

private void callOldAirpor(Accident accident, Inspection inspection) {
InspectionFile inspectionFile = inspectionFileMapper.selectOne(new LambdaQueryWrapper<InspectionFile>()
.eq(InspectionFile::getId, accident.getInspectionFileId())
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode()));

String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL;
JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", inspection.getId());
jsonObject.put("airportId", inspection.getAirportId());
jsonObject.put("zalt", "");
jsonObject.put("zlon", inspectionFile.getLongitude());
jsonObject.put("zlat", inspectionFile.getLatitude());

log.info("调用机场平台,原无人机执行定点飞行: url:{}", url);
log.info("调用机场平台,原无人机执行定点飞行: jsonObject:{}", jsonObject);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
if (StringUtils.isEmpty(airPortStr)) {
log.info("原无人机执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject);
throw new ServiceException("机场接口返回数据为空,飞行失败");
}
}
}

+ 39
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/DroneControlService.java Bestand weergeven

@@ -0,0 +1,39 @@
package com.tuoheng.admin.service.third.airport;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.HttpUtils;
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;

@Slf4j
@Service
public class DroneControlService {

@Autowired
private TenantMapper tenantMapper;

public JsonResult execute(JSONObject jsonObject) {
log.info("进入调用机场平台,操作无人机");
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL;

log.info("调用机场平台,操作无人机: url:{}", url);
log.info("调用机场平台,操作无人机: jsonObject:{}", jsonObject);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
log.info("调用机场平台,操作无人机: airPortStr:{}", airPortStr);
if (StringUtils.isEmpty(airPortStr)) {
log.info("执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject);
return JsonResult.error(-1, "机场接口返回数据为空");
}

log.info("调用机场平台方法: 操作无人机结束");
return JsonResult.success();
}

}

+ 1
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java Bestand weergeven

@@ -118,7 +118,7 @@ public class PointFlightService {
String code = DateUtils.generateCode("XJRW");
inspection.setCode(code);
inspection.setName("应急任务"+code);
inspection.setType(1);
inspection.setType(2);
inspection.setStatus(TaskStatusEnum.INFLIGHT.getCode());
inspection.setRoadId("");
inspection.setSectionId("");
@@ -127,7 +127,6 @@ public class PointFlightService {
inspection.setAirportName(request.getAirportName());
inspection.setInspectionLine(0);
inspection.setInspectionLineName("");
inspection.setAccidentTask(1);
inspection.setExecutionStartTime(DateUtils.now());
inspection.setCreateUser(user.getId());
inspection.setCreateTime(DateUtils.now());

+ 13
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java Bestand weergeven

@@ -313,14 +313,23 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
accident.setRoadId(inspection.getRoadId());
accident.setSectionId(inspection.getSectionId());
accident.setSectionName(inspection.getSectionName());

//根据巡检任务类型判断当前应急事故类型
Integer accidentTaskType = inspection.getAccidentTask();
if(AccidentTaskEnum.INSPECTION_ACCIDENT_TASK.getCode() == accidentTaskType){
if (AccidentTaskEnum.INSPECTION_ACCIDENT_TASK.getCode() == inspection.getType()) {
accident.setFlag(FlagEnum.ACCIDENT.getCode());
}else {
accident.setFlag(FlagEnum.INSPECTION_ACCIDENT.getCode());
} else {
// 该巡检任务存在应急任务,将后面发现的预警直接设置为不展示
Inspection emergencyInspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getEmergencyDataInspectionId, inspectionFile.getInspectionId())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtils.isNotEmpty(emergencyInspection)) {
accident.setFlag(FlagEnum.ACCIDENT.getCode());
} else {
accident.setFlag(FlagEnum.INSPECTION_ACCIDENT.getCode());
}
}
}

//公路代号
RoadInformation roadInformation = roadInformationMapper.selectById(inspection.getRoadId());
if(ObjectUtils.isNotEmpty(roadInformation)){

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml Bestand weergeven

@@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="accidentTask" column="accident_task" />
<result property="emergencyDataMissionId" column="emergency_data_inspection_id" />
<result property="mark" column="mark" />
</resultMap>


Laden…
Annuleren
Opslaan