Просмотр исходного кода

修改预警核实,忽略,上报,无事故等代码

tags/v1.2.0^2
wanjing 1 год назад
Родитель
Сommit
5b2ec3913a
7 измененных файлов: 108 добавлений и 59 удалений
  1. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java
  2. +21
    -11
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java
  3. +30
    -19
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java
  4. +12
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java
  5. +9
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyCompletedService.java
  6. +26
    -15
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java
  7. +10
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/DroneControlService.java

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

@@ -105,7 +105,6 @@ public class AccidentController {
return accidentService.verifyCompleted(request);
}


/**
* 事故上报
*/

+ 21
- 11
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java Просмотреть файл

@@ -41,16 +41,9 @@ public class AccidentIgnoreService {
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);

this.updateAccident(userId, accident);

return JsonResult.success();
}
@@ -73,10 +66,27 @@ public class AccidentIgnoreService {
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理,不能在忽略");
if (AccidentStatusEnum.UNTREATED.getCode() != accident.getStatus()) {
throw new ServiceException("未处理的事故才能忽略");
}
return JsonResult.success(accident);
}

/**
* 修改预警记录信息
*
* @param userId
* @param userId
*/
private void updateAccident(String userId, Accident accident) {
Accident accidentUpdate = new Accident();
accidentUpdate.setId(accident.getId());
accidentUpdate.setStatus(AccidentStatusEnum.IGNORED.getCode());
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
Integer count = accidentMapper.updateById(accidentUpdate);
if (count <= 0) {
log.info("事故忽略,修改预警信息失败");
}
}
}

+ 30
- 19
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java Просмотреть файл

@@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 事故上报业务层处理
* 事故上报业务层处理
*
* @author wanjing
* @team tuoheng
@@ -41,23 +41,8 @@ public class ReportAccidentService {
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());
accidentUpdate.setReportTime(DateUtils.now());
accidentMapper.updateById(accidentUpdate);

this.updateAccident(userId, request, accident);
return JsonResult.success();
}

@@ -79,10 +64,36 @@ public class ReportAccidentService {
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理");
if (AccidentStatusEnum.PROCESSING.getCode() != accident.getStatus()) {
throw new ServiceException("处理中的事故才能上报");
}
return JsonResult.success(accident);
}

/**
* 修改预警记录信息
*
* @param userId
* @param request
* @param accident
*/
private void updateAccident(String userId, ReportAccidentRequest request, Accident accident) {
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());
accidentUpdate.setReportTime(DateUtils.now());
Integer count = accidentMapper.updateById(accidentUpdate);
if (count <= 0) {
log.info("事故上报,修改预警信息失败");
}
}
}

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

@@ -59,11 +59,11 @@ public class ReportNoAccidentService {
}
Accident accident = (Accident) result.getData();

this.updateAccident(accident.getId(), userId);

// 无人机回仓
this.droneReturn(accident.getInspectionId());

this.updateAccident(accident.getId(), userId);

return JsonResult.success();
}

@@ -85,8 +85,8 @@ public class ReportNoAccidentService {
if (ObjectUtil.isNull(accident)) {
throw new ServiceException("事故不存在");
}
if (AccidentStatusEnum.UNTREATED.getCode() == accident.getStatus()) {
throw new ServiceException("该事故已处理");
if (AccidentStatusEnum.PROCESSING.getCode() != accident.getStatus()) {
throw new ServiceException("处理中的事故才能上报为无事故");
}
return JsonResult.success(accident);
}
@@ -106,7 +106,10 @@ public class ReportNoAccidentService {
jsonObject.put("taskId", inspection.getId());
jsonObject.put("airportId", inspection.getAirportId());
jsonObject.put("msg", "回仓");
droneControlService.execute(jsonObject);
JsonResult jsonResult = droneControlService.execute(jsonObject);
if (0 != jsonResult.getCode()) {
log.info("机场平台返回,返回无人机回仓失败");
}
}

/**
@@ -123,7 +126,10 @@ public class ReportNoAccidentService {
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setNoAccidentTime(DateUtils.now());
accidentMapper.updateById(accidentUpdate);
Integer count = accidentMapper.updateById(accidentUpdate);
if (count <= 0) {
log.info("无事故,修改预警信息失败");
}
}

}

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

@@ -61,7 +61,6 @@ public class AccidentVerifyCompletedService {
* @param request
* @return
*/
@Transactional
public JsonResult verifyCompleted(AccidentVerifyCompletedRequest request) {
// log.info("进入事故核实完成业务");
User user = CurrentUserUtil.getUserInfo();
@@ -122,7 +121,11 @@ public class AccidentVerifyCompletedService {
jsonObject.put("taskId", inspection.getId());
jsonObject.put("airportId", inspection.getAirportId());
jsonObject.put("msg", "回仓");
droneControlService.execute(jsonObject);

JsonResult jsonResult = droneControlService.execute(jsonObject);
if (0 != jsonResult.getCode()) {
throw new ServiceException("机场平台返回,返回无人机回仓失败");
}
}

/**
@@ -138,6 +141,9 @@ public class AccidentVerifyCompletedService {
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setEndTime(DateUtils.now());
accidentMapper.updateById(accidentUpdate);
Integer count = accidentMapper.updateById(accidentUpdate);
if (count <= 0) {
log.info("事故核实完成,修改预警信息失败");
}
}
}

+ 26
- 15
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java Просмотреть файл

@@ -16,10 +16,7 @@ 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 com.tuoheng.common.core.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -59,7 +56,6 @@ public class AccidentVerifyService {
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());
@@ -69,12 +65,12 @@ public class AccidentVerifyService {
Inspection oldInspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getId, accident.getInspectionId())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
// 创建应急任务
this.createInspection(user, oldInspection);

// 无人机前往事故发生地点,事故地点上方悬停
this.callAirpor(accident, oldInspection);

// 创建应急任务
this.createInspection(userId, oldInspection);

this.updateAccident(accident.getId(), userId);

return JsonResult.success();
@@ -107,16 +103,17 @@ public class AccidentVerifyService {
/**
* 创建应急任务
*
* @param user
* @param userid
* @param oldInspection
* @return
*/
private Inspection createInspection(User user, Inspection oldInspection) {
private Inspection createInspection(String userid, Inspection oldInspection) {
Inspection inspection = new Inspection();
String code = DateUtils.generateCode("XJRW");;
inspection.setCode(code);
inspection.setName("应急任务" + code);
inspection.setTenantId(user.getTenantId());
inspection.setDeptId(oldInspection.getDeptId());
inspection.setTenantId(oldInspection.getTenantId());
inspection.setType(2);
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode()); // 设置应急任务状态为飞行中
inspection.setInspectionType(InspectionTypeEnum.AIRPORT.getCode());
@@ -125,10 +122,15 @@ public class AccidentVerifyService {
inspection.setInspectionLine(0);
inspection.setInspectionLineName("");
inspection.setExecutionStartTime(DateUtils.now());
inspection.setCreateUser(user.getId());
inspection.setCreateUser(userid);
inspection.setCreateTime(DateUtils.now());
inspection.setEmergencyDataInspectionId(oldInspection.getId());

inspection.setRoadId("");
inspection.setRoadName("");
inspection.setSectionId("");
inspection.setSectionName("");

Integer count = inspectionMapper.insert(inspection);
if (count <= 0) {
log.info("创建应急任务失败");
@@ -159,8 +161,14 @@ public class AccidentVerifyService {

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

JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (0 != jsonResult.getCode()) {
log.info("调用机场平台,无人机执行定点飞行:飞行失败,jsonResult:{}", jsonResult.getMsg());
throw new ServiceException("机场平台返回,飞行失败");
}
}

@@ -177,6 +185,9 @@ public class AccidentVerifyService {
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setVerificationTime(DateUtils.now());
accidentMapper.updateById(accidentUpdate);
Integer count = accidentMapper.updateById(accidentUpdate);
if (count <= 0) {
log.info("事故核实,修改预警信息失败");
}
}
}

+ 10
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/DroneControlService.java Просмотреть файл

@@ -4,7 +4,9 @@ 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.exception.ServiceException;
import com.tuoheng.common.core.utils.HttpUtils;
import com.tuoheng.common.core.utils.JacksonUtil;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
@@ -19,7 +21,7 @@ public class DroneControlService {
private TenantMapper tenantMapper;

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

log.info("调用机场平台,操作无人机: url:{}", url);
@@ -28,10 +30,14 @@ public class DroneControlService {
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.error(-1, "机场平台返回数据为空");
}
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (0 != jsonResult.getCode()) {
log.info("调用机场平台,操作无人机:返回失败,jsonResult:{}", jsonResult.getMsg());
return JsonResult.error(-1, "机场平台返回失败");
}

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

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