Bläddra i källkod

1、修改创建任务之后,下发任务;2、执行任务时,调用执行航线任务接口;

tags/v1.3.1
wanjing 1 år sedan
förälder
incheckning
e4ffb68ccd
8 ändrade filer med 133 tillägg och 35 borttagningar
  1. +60
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java
  2. +12
    -14
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java
  3. +13
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/constant/TZHLConstant.java
  4. +44
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/task/FlightTaskService.java
  5. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml
  6. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml
  7. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml
  8. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml

+ 60
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java Visa fil

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

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.InspectionConverMapper;
import com.tuoheng.admin.entity.*;
@@ -10,6 +11,9 @@ import com.tuoheng.admin.enums.code.inspection.AddInspectionCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspection.AddInspectionRequest;
import com.tuoheng.admin.service.third.pilot.PilotService;
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse;
import com.tuoheng.admin.tzhl.service.airportline.TZHLGetAirportLineListService;
import com.tuoheng.admin.tzhl.service.task.ShelterTaskService;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.utils.GaodeUtil;
import com.tuoheng.common.core.constant.CommonConstants;
@@ -46,6 +50,9 @@ public class AddInspectionService {
@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionHistoryMapper inspectionHistoryMapper;

@Autowired
private TenantMapper tenantMapper;

@@ -55,6 +62,12 @@ public class AddInspectionService {
@Autowired
private DspServiceInstMapper dspServiceInstMapper;

@Autowired
private ShelterTaskService shelterTaskService;

@Autowired
private TZHLGetAirportLineListService tzhlGetAirportLineListService;

/**
* 添加任务
*
@@ -75,11 +88,17 @@ public class AddInspectionService {
Inspection inspection = this.buildInspection(user, tenantId, addInspectionRequest);

// 调用第三方平台
result = this.callThirdPlatform(user, tenantId, inspection);
result = this.callThirdPlatform(user, inspection);
if (0 != result.getCode()) {
log.info("添加任务业务:对接第三方平台失败:{}", result.getMsg());
return result;
}

if (InspectionTypeEnum.AIRPORT.getCode() == inspection.getInspectionType()) {
Long recordId = (Long) result.getData();
inspection.setRecordId(recordId);
}

Integer rowId = inspectionMapper.insert(inspection);
log.info("添加任务, 返回结果: deptId={}", rowId);
if (rowId <= 0) {
@@ -199,25 +218,24 @@ public class AddInspectionService {
}

/**
* 与第三方平台(飞手、高德)对接
* 与第三方平台(天翼、飞手、高德)对接
*
* @param user
* @param tenantId
* @param inspection
* @return
*/
private JsonResult callThirdPlatform(User user, String tenantId, Inspection inspection) {
private JsonResult callThirdPlatform(User user, Inspection inspection) {
// 对接高德地图
JsonResult result = this.callGaode(inspection);
if (0 != result.getCode()) {
return result;
}
if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == inspection.getInspectionType()) {
if (InspectionTypeEnum.AIRPORT.getCode() == inspection.getInspectionType()) {
// 对接天翼平台
return this.callTianYi(inspection);
} else if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == inspection.getInspectionType()) {
// 对接飞手平台
result = pilotService.addTask(user, inspection);
if (0 != result.getCode()) {
return result;
}
return pilotService.addTask(user, inspection);
}
return JsonResult.success();
}
@@ -242,4 +260,37 @@ public class AddInspectionService {
return JsonResult.success();
}

private JsonResult callTianYi(Inspection inspection) {
TZHLAirportLineResponse tzhlAirportLineResponse = tzhlGetAirportLineListService.getAirportLineById(inspection.getInspectionLine());
if (ObjectUtil.isEmpty(tzhlAirportLineResponse)) {
this.insertInspectionHistory(inspection, "创建任务,下发任务,航线不存在");
return JsonResult.error("创建任务,下发任务,航线不存在");
}
Long recordId = shelterTaskService.distributeTask(inspection, tzhlAirportLineResponse);
if (ObjectUtil.isEmpty(recordId)) {
log.info("创建任务,下发任务失败,status={}", inspection.getStatus());

inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());

this.insertInspectionHistory(inspection, "创建任务,下发任务失败");

return JsonResult.error("创建任务,下发任务失败");
}
return JsonResult.success(recordId);
}

/**
* 更新任务失败记录
*
* @param inspection
*/
private void insertInspectionHistory(Inspection inspection, String msg) {
InspectionHistory inspectionHistory = new InspectionHistory();
inspectionHistory.setTenantId(inspection.getTenantId());
inspectionHistory.setInspectionId(inspection.getId());
inspectionHistory.setHistoryName(msg);
inspectionHistory.setCreateUser("");
inspectionHistory.setCreateTime(DateUtils.now());
inspectionHistoryMapper.insert(inspectionHistory);
}
}

+ 12
- 14
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java Visa fil

@@ -19,6 +19,7 @@ import com.tuoheng.admin.tzhl.response.TZHLShelterTaskResponse;
import com.tuoheng.admin.tzhl.service.airport.TZHLGetAirportListService;
import com.tuoheng.admin.tzhl.service.airportline.TZHLGetAirportLineListService;
import com.tuoheng.admin.tzhl.service.fly.onlineuav.OnlineUavService;
import com.tuoheng.admin.tzhl.service.task.FlightTaskService;
import com.tuoheng.admin.tzhl.service.task.ShelterTaskService;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
@@ -50,34 +51,32 @@ public class ExecuteTaskService {
private TZHLGetAirportLineListService tzhlGetAirportLineListService;

@Autowired
private ShelterTaskService shelterTaskService;
private FlightTaskService flightTaskService;

public JsonResult executeTask(String userId, Inspection inspection) {
log.info("进入泰州海陵区城管,执行任务,inspectionId={}", inspection.getId());

JsonResult result = this.check(inspection);
TZHLAirportLineResponse tzhlAirportLineResponse = tzhlGetAirportLineListService.getAirportLineById(inspection.getInspectionLine());
if (0 != result.getCode()) {
this.insertInspectionHistory(inspection, result.getMsg());
return JsonResult.error(result.getMsg());
}

Long recordId = shelterTaskService.distributeTask(inspection, tzhlAirportLineResponse);
if (ObjectUtil.isEmpty(recordId)) {
log.info("泰州海陵区城管,执行任务,下发任务失败,status={}", inspection.getStatus());

result = flightTaskService.flightTask(inspection);
if (0 != result.getCode()) {
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
this.updateInspection(userId, inspection, recordId);
this.updateInspection(userId, inspection);

log.info("执行任务失败,修改任务状态,status={}", inspection.getStatus());

this.insertInspectionHistory(inspection, "下发任务失败");
this.insertInspectionHistory(inspection, "执行任务失败");

return JsonResult.success("泰州海陵区城管,执行任务,下发任务失败");
return JsonResult.success("执行任务失败");
}

inspection.setStatus(InspectionStatusEnum.PREPARING.getCode());
this.updateInspection(userId, inspection, recordId);
this.updateInspection(userId, inspection);

log.info("任务下发成功,修改任务状态,status={}", inspection.getStatus());
log.info("执行任务成功,修改任务状态,status={}", inspection.getStatus());

return JsonResult.success();
}
@@ -108,12 +107,11 @@ public class ExecuteTaskService {
* @param userId
* @param inspection
*/
private void updateInspection(String userId, Inspection inspection, Long recordId) {
private void updateInspection(String userId, Inspection inspection) {
inspection.setExecutionStatus(2); // 修改任务执行状态,防止手动执行和定时重复
inspection.setStatus(inspection.getStatus());
inspection.setUpdateUser(userId);
inspection.setUpdateTime(DateUtils.now());
inspection.setRecordId(recordId);
inspectionMapper.update(inspection);
}


+ 13
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/constant/TZHLConstant.java Visa fil

@@ -28,42 +28,47 @@ public interface TZHLConstant {
/**
* 天翼星云机场平台:票据登录
*/
String TIAN_YI_API_TICKET_LOGIN = "/prod-api/auth/ticketLogin";
String TIAN_YI_API_TICKET_LOGIN = "/auth/ticketLogin";

/**
* 天翼星云机场平台:获取机场列表
*/
String TIAN_YI_API_AIRPORT_LIST = "/prod-api/ctuav/openapi/ctuav/v4/shelter/list";
String TIAN_YI_API_AIRPORT_LIST = "/ctuav/openapi/ctuav/v4/shelter/list";

/**
* 天翼星云机场平台:航线列表(跟据方舱序列号查询待开发)
*/
String TIAN_YI_API_FLY_LINE_LIST = "/prod-api/ctuav/openapi/ctuav/v4/flyline/list";
String TIAN_YI_API_FLY_LINE_LIST = "/ctuav/openapi/ctuav/v4/flyline/list";

/**
* 天翼星云机场平台:下发任务
*/
String TIAN_YI_API_SHELTER_TASKS = "/prod-api/shelter/task";
String TIAN_YI_API_SHELTER_TASKS = "/shelter/task";

/**
* 天翼星云机场平台:执行航线任务
*/
String TIAN_YI_API_WAYLINE_FLIGHT_TASKS = "/shelter/wayline/v1.4/flight-tasks";

/**
* 天翼星云机场平台:飞行日志回调
*/
String TIAN_YI_API_FLIGHT_LOG = "/prod-api/ctuav/mapper/fly/log/listAll";
String TIAN_YI_API_FLIGHT_LOG = "/ctuav/mapper/fly/log/listAll";

/**
* 天翼星云机场平台:飞行画面
*/
String TIAN_YI_API_FLIGHT_SCREEN = "/prod-api/ctuav/openapi/ctuav/v4/onlineuav/list";
String TIAN_YI_API_FLIGHT_SCREEN = "/ctuav/openapi/ctuav/v4/onlineuav/list";

/**
* 天翼星云机场平台:飞行数据
*/
String TIAN_YI_API_FLIGHT_DATA = "/prod-api/ctuav/openapi/ctuav/v4/flydata/list";
String TIAN_YI_API_FLIGHT_DATA = "/ctuav/openapi/ctuav/v4/flydata/list";

/**
* 天翼星云机场信息:气象数据接口
*/
String TIAN_YI_API_AIRPORT_MSG = "/prod-api/ctuav/openapi/ctuav/v4/shelter/info";
String TIAN_YI_API_AIRPORT_MSG = "/ctuav/openapi/ctuav/v4/shelter/info";


}

+ 44
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/task/FlightTaskService.java Visa fil

@@ -0,0 +1,44 @@
package com.tuoheng.admin.tzhl.service.task;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class FlightTaskService {

@Autowired
@Qualifier("restTemplate")
private RestTemplate restTemplate;

@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

public JsonResult flightTask(Inspection inspection) {
String apiPath = TZHLConstant.TIAN_YI_API_WAYLINE_FLIGHT_TASKS;
JSONObject jsonObject = this.buildJSONObject(inspection);
String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject);
return JsonResult.success(dataJson);
}

private JSONObject buildJSONObject(Inspection inspection) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("method", "flighttask_prepare"); // 默认值 flighttask_prepare
jsonObject.put("sn", inspection.getSn()); // 机库序列号
jsonObject.put("recordId", inspection.getRecordId()); // 飞行计划Id
return jsonObject;
}

}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml Visa fil

@@ -208,5 +208,5 @@ aliyun:

# 泰州海陵区城管
tzhl:
url: http://221.230.150.241:8889
url: http://221.230.150.241:8889/prod-api
ticket: b6hd+ymZb5bY//0wNMJZsA==

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml Visa fil

@@ -204,5 +204,5 @@ aliyun:

# 泰州海陵区城管
tzhl:
url: http://221.230.150.241:8889
url: http://221.230.150.241:8889/prod-api
ticket: b6hd+ymZb5bY//0wNMJZsA==

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml Visa fil

@@ -208,5 +208,5 @@ aliyun:

# 泰州海陵区城管
tzhl:
url: http://221.230.150.241:8889
url: http://221.230.150.241:8889/prod-api
ticket: b6hd+ymZb5bY//0wNMJZsA==

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml Visa fil

@@ -208,5 +208,5 @@ aliyun:

# 泰州海陵区城管
tzhl:
url: http://221.230.150.241:8889
url: http://221.230.150.241:8889/prod-api
ticket: b6hd+ymZb5bY//0wNMJZsA==

Laddar…
Avbryt
Spara