@@ -1,10 +1,7 @@ | |||
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.request.accident.*; | |||
import com.tuoheng.admin.service.accident.IAccidentService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -98,6 +95,17 @@ public class AccidentController { | |||
return accidentService.verify(request); | |||
} | |||
/** | |||
* 事故核实完成 | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/verify/completed") | |||
public JsonResult verifyCompleted(AccidentVerifyCompletedRequest request) { | |||
return accidentService.verifyCompleted(request); | |||
} | |||
/** | |||
* 事故上报 | |||
*/ |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.admin.request.accident; | |||
import lombok.Data; | |||
/** | |||
* 事故核实完成请求实体 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-03-15 | |||
*/ | |||
@Data | |||
public class AccidentVerifyCompletedRequest { | |||
/** | |||
* 事故id | |||
*/ | |||
private String accidentId; | |||
} |
@@ -3,16 +3,14 @@ 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.request.accident.*; | |||
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.AccidentVerifyCompletedService; | |||
import com.tuoheng.admin.service.accident.verify.AccidentVerifyService; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -49,6 +47,9 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden | |||
@Autowired | |||
private AccidentVerifyService accidentVerifyService; | |||
@Autowired | |||
private AccidentVerifyCompletedService accidentVerifyCompletedService; | |||
@Autowired | |||
private ReportAccidentService reportAccidentService; | |||
@@ -99,10 +100,22 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden | |||
* @param request | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult verify(AccidentVerifyRequest request) { | |||
return accidentVerifyService.verify(request); | |||
} | |||
/** | |||
* 事故核实完成 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult verifyCompleted(AccidentVerifyCompletedRequest request) { | |||
return accidentVerifyCompletedService.verifyCompleted(request); | |||
} | |||
/** | |||
* 事故上报 | |||
* |
@@ -2,10 +2,7 @@ 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.admin.request.accident.*; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -78,6 +75,14 @@ public interface IAccidentService extends IBaseService<Accident> { | |||
*/ | |||
JsonResult verify(AccidentVerifyRequest request); | |||
/** | |||
* 事故核实完成 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
JsonResult verifyCompleted(AccidentVerifyCompletedRequest request); | |||
/** | |||
* 事故上报 | |||
* |
@@ -33,13 +33,9 @@ public class ReportAccidentService { | |||
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"; | |||
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()); |
@@ -48,28 +48,21 @@ public class ReportNoAccidentService { | |||
private DroneControlService droneControlService; | |||
public JsonResult report(ReportNoAccidentRequest request) { | |||
// log.info("进入事故上报业务"); | |||
// 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()); | |||
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()); | |||
// 无人机回仓 | |||
this.droneReturn(accident.getInspectionId()); | |||
accidentMapper.updateById(accidentUpdate); | |||
this.updateAccident(accident.getId(), userId); | |||
return JsonResult.success(); | |||
} | |||
@@ -104,7 +97,7 @@ public class ReportNoAccidentService { | |||
* @param inspectionId | |||
*/ | |||
private void droneReturn(String inspectionId) { | |||
// 向机场发送无人机回舱指令 | |||
log.info("事故确认是无事故,无人机回仓"); | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getId, inspectionId) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode())); | |||
@@ -116,4 +109,21 @@ public class ReportNoAccidentService { | |||
droneControlService.execute(jsonObject); | |||
} | |||
/** | |||
* 修改预警记录信息 | |||
* | |||
* @param id | |||
* @param userId | |||
*/ | |||
private void updateAccident(String id, String userId) { | |||
Accident accidentUpdate = new Accident(); | |||
accidentUpdate.setId(id); | |||
accidentUpdate.setIsAccident(0); | |||
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSED.getCode()); | |||
accidentUpdate.setUpdateUser(userId); | |||
accidentUpdate.setUpdateTime(DateUtils.now()); | |||
accidentUpdate.setNoAccidentTime(DateUtils.now()); | |||
accidentMapper.updateById(accidentUpdate); | |||
} | |||
} |
@@ -0,0 +1,143 @@ | |||
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.AccidentStatusEnum; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.InspectionTypeEnum; | |||
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.AccidentVerifyCompletedRequest; | |||
import com.tuoheng.admin.request.accident.AccidentVerifyRequest; | |||
import com.tuoheng.admin.service.third.airport.DroneControlService; | |||
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 AccidentVerifyCompletedService { | |||
@Autowired | |||
private AccidentMapper accidentMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private InspectionFileMapper inspectionFileMapper; | |||
@Autowired | |||
private DroneControlService droneControlService; | |||
/** | |||
* | |||
* 1、向机场推送返舱指令,无人机返回机场 | |||
* 2、修改该事故状态为完成 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@Transactional | |||
public JsonResult verifyCompleted(AccidentVerifyCompletedRequest 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(); | |||
// 无人机回仓 | |||
this.droneReturn(accident.getInspectionId()); | |||
this.updateAccident(accident.getId(), userId); | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param tenantId | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult check(String tenantId, AccidentVerifyCompletedRequest 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) { | |||
log.info("事故核实完成,无人机回仓"); | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getId, inspectionId) | |||
.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); | |||
} | |||
/** | |||
* 修改预警记录信息 | |||
* | |||
* @param id | |||
* @param userId | |||
*/ | |||
private void updateAccident(String id, String userId) { | |||
Accident accidentUpdate = new Accident(); | |||
accidentUpdate.setId(id); | |||
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSED.getCode()); | |||
accidentUpdate.setUpdateUser(userId); | |||
accidentUpdate.setUpdateTime(DateUtils.now()); | |||
accidentUpdate.setEndTime(DateUtils.now()); | |||
accidentMapper.updateById(accidentUpdate); | |||
} | |||
} |
@@ -65,25 +65,17 @@ public class AccidentVerifyService { | |||
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); | |||
// 无人机前往事故发生地点,事故地点上方悬停 | |||
this.callAirpor(accident, oldInspection); | |||
Accident accidentUpdate = new Accident(); | |||
accidentUpdate.setId(accident.getId()); | |||
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSING.getCode()); | |||
accidentUpdate.setUpdateUser(userId); | |||
accidentUpdate.setUpdateTime(DateUtils.now()); | |||
accidentUpdate.setVerificationTime(DateUtils.now()); | |||
accidentMapper.updateById(accidentUpdate); | |||
this.updateAccident(accident.getId(), userId); | |||
return JsonResult.success(); | |||
} | |||
@@ -141,17 +133,19 @@ public class AccidentVerifyService { | |||
if (count <= 0) { | |||
log.info("创建应急任务失败"); | |||
throw new ServiceException("创建应急任务失败"); | |||
} else { | |||
log.info("创建应急任务成功, inspection={}", inspection); | |||
} | |||
return inspection; | |||
} | |||
private void callOldAirpor(Accident accident, Inspection inspection) { | |||
/** | |||
* 调用机场平台,执行指点飞行 | |||
* @param accident | |||
* @param inspection | |||
*/ | |||
private void callAirpor(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()); | |||
@@ -160,13 +154,29 @@ public class AccidentVerifyService { | |||
jsonObject.put("zlon", inspectionFile.getLongitude()); | |||
jsonObject.put("zlat", inspectionFile.getLatitude()); | |||
log.info("调用机场平台,原无人机执行定点飞行: url:{}", url); | |||
log.info("调用机场平台,原无人机执行定点飞行: jsonObject:{}", jsonObject); | |||
log.info("调用机场平台,无人机执行定点飞行: url:{}", url); | |||
log.info("调用机场平台,无人机执行定点飞行: jsonObject:{}", jsonObject); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("原无人机执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject); | |||
log.info("无人机执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject); | |||
throw new ServiceException("机场接口返回数据为空,飞行失败"); | |||
} | |||
} | |||
/** | |||
* 修改预警记录信息 | |||
* | |||
* @param id | |||
* @param userId | |||
*/ | |||
private void updateAccident(String id, String userId) { | |||
Accident accidentUpdate = new Accident(); | |||
accidentUpdate.setId(id); | |||
accidentUpdate.setStatus(AccidentStatusEnum.PROCESSING.getCode()); | |||
accidentUpdate.setUpdateUser(userId); | |||
accidentUpdate.setUpdateTime(DateUtils.now()); | |||
accidentUpdate.setVerificationTime(DateUtils.now()); | |||
accidentMapper.updateById(accidentUpdate); | |||
} | |||
} |