@@ -33,6 +33,11 @@ public class CommonConfig { | |||
*/ | |||
public static String channelUrl; | |||
/** | |||
* 飞手平台URL | |||
*/ | |||
public static String pilotURL; | |||
/** | |||
* 图片域名赋值 | |||
* | |||
@@ -82,4 +87,14 @@ public class CommonConfig { | |||
public void setChannelUrl(String url) { | |||
channelUrl = url; | |||
} | |||
/** | |||
* 飞手平台 | |||
* @param url 不同环境对应不同的url | |||
*/ | |||
@Value("${tuoheng.pilot-url}") | |||
public void setPilotURL(String url) { | |||
pilotURL = url; | |||
} | |||
} |
@@ -12,4 +12,25 @@ public interface SystemConstant { | |||
*/ | |||
String GAO_DE_URL = "https://restapi.amap.com/v3/geocode/regeo"; | |||
/** | |||
* 机场平台:获取机场列表接口 | |||
*/ | |||
String API_AIRPORT_LIST = "/api/airportInterface/airportList"; | |||
/** | |||
* 机场平台:获取机场路线列表接口 | |||
*/ | |||
String API_AIRPORT_LINE_LIST = "/api/airportInterface/taskByDroneId"; | |||
/** | |||
* 机场平台:执行接口 | |||
*/ | |||
String API_AIRPORT_EXECUTE_TASK = "/api/airportInterface/executeTask"; | |||
// 飞手平台不同接口url | |||
/** | |||
* 新增任务接口 | |||
*/ | |||
String ADD_PILOTTASK = "apiTask/add"; | |||
} |
@@ -1,7 +1,5 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
@@ -16,8 +14,8 @@ import java.util.Date; | |||
/** | |||
* 巡检任务对象 th_inspection | |||
* | |||
* @team tuoheng | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-16 | |||
*/ | |||
@Data | |||
@@ -84,11 +82,13 @@ public class Inspection extends BaseEntity { | |||
private Integer airportId; | |||
/** | |||
* 巡检机场名称 */ | |||
* 巡检机场名称 | |||
*/ | |||
private String airportName; | |||
/** | |||
* 巡检线路id */ | |||
* 巡检线路id | |||
*/ | |||
private Integer inspectionLine; | |||
/** | |||
@@ -117,19 +117,23 @@ public class Inspection extends BaseEntity { | |||
private String equipmentMountName; | |||
/** | |||
* 5G云盒ID */ | |||
* 5G云盒ID | |||
*/ | |||
private String cloudBoxId; | |||
/** | |||
* 云盒名称 */ | |||
* 云盒名称 | |||
*/ | |||
private String cloudBoxName; | |||
/** | |||
* 云盒SN号 */ | |||
* 云盒SN号 | |||
*/ | |||
private String boxSn; | |||
/** | |||
* 飞手(多选逗号","分隔) */ | |||
* 飞手(多选逗号","分隔) | |||
*/ | |||
private String flightHand; | |||
/** | |||
@@ -204,7 +208,6 @@ public class Inspection extends BaseEntity { | |||
private Integer analyseStatus; | |||
/** | |||
* | |||
* ai任务分析进度 | |||
*/ | |||
private BigDecimal progressbar; | |||
@@ -237,7 +240,7 @@ public class Inspection extends BaseEntity { | |||
/** | |||
* 定时任务的执行状态。1:未执行,2:已执行 | |||
*/ | |||
private Long executionStatus; | |||
private Integer executionStatus; | |||
/** | |||
* 起点经度 |
@@ -14,9 +14,10 @@ public enum ExecuteInspectionCodeEnum { | |||
Execute_IS_FAILED(1230800, "重新提交失败"), | |||
ID_IS_NULL(1230801, "任务ID为空"), | |||
INSPECTION_IS_NOT_EXIST(1230802, "任务不存在"), | |||
TENANT_IS_NOT_EXIST(1230803, "租户不存在"), | |||
AIRPORT_URL_IS_NULL(1230804, "机场平台URL为空"), | |||
AIRPORT_RETURN_DATA_IS_NULL(1230804, "机场接口返回数据为空"); | |||
USER_ONLY_EXECUTE_DEPARTMENT_TASK(1230803, "用户只能执行本部门任务"), | |||
TENANT_IS_NOT_EXIST(1230804, "租户不存在"), | |||
AIRPORT_URL_IS_NULL(1230805, "机场平台URL为空"), | |||
AIRPORT_RETURN_DATA_IS_NULL(1230806, "机场接口返回数据为空"); | |||
/** | |||
* 错误码 |
@@ -0,0 +1,91 @@ | |||
package com.tuoheng.admin.request.third; | |||
import lombok.Data; | |||
import java.util.Date; | |||
/** | |||
* 新增部门请求参数 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-02 | |||
*/ | |||
@Data | |||
public class PilotTaskRequest { | |||
/** | |||
* 任务编码 | |||
*/ | |||
private String taskCode; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String taskName; | |||
/** | |||
* 租户名称 | |||
*/ | |||
private String tenantName; | |||
/** | |||
* 巡逻地点 | |||
*/ | |||
private String patrolLocation; | |||
/** | |||
* 平台编码 | |||
*/ | |||
private String platformCode; | |||
/** | |||
* 发起人名称 | |||
*/ | |||
private String sponsorName; | |||
/** | |||
* 发起人手机号 | |||
*/ | |||
private String sponsorPhone; | |||
/** | |||
* 任务执行时间(期望巡检时间) | |||
*/ | |||
private Date taskStartTime; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remark; | |||
/** | |||
* 是否直播 0否,1是 | |||
*/ | |||
private Integer isLive; | |||
/** | |||
* 起点纬度 | |||
*/ | |||
private String startLatitude; | |||
/** | |||
* 起点经度 | |||
*/ | |||
private String startLongitude; | |||
/** | |||
*终点经度 | |||
*/ | |||
private String endLongitude; | |||
/** | |||
* 终点纬度 | |||
*/ | |||
private String endLatitude; | |||
/** | |||
* 巡检类型 1.自营飞行计划 | |||
*/ | |||
private Integer inspectionType; | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.tuoheng.admin.service.airport; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.enums.code.AriportCodeEnum; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
@@ -18,9 +19,6 @@ import java.util.Objects; | |||
@Service | |||
public class AirportServiceImpl implements AirportService { | |||
private final static String API_AIRPORT_LIST = "/api/airportInterface/airportList"; | |||
private final static String API_AIRPORT_LINE_LIST = "/api/airportInterface/taskByDroneId"; | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@@ -37,7 +35,7 @@ public class AirportServiceImpl implements AirportService { | |||
return JsonResult.error(AriportCodeEnum.GET_NO_TENANT.getCode(), AriportCodeEnum.GET_NO_TENANT.getMsg()); | |||
} | |||
String url = tenant.getAirportUrl() + API_AIRPORT_LIST; | |||
String url = tenant.getAirportUrl() + SystemConstant.API_AIRPORT_LIST; | |||
String param = "page=1&limit=10"; | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
@@ -60,7 +58,7 @@ public class AirportServiceImpl implements AirportService { | |||
return JsonResult.error(AriportCodeEnum.GET_NO_TENANT.getCode(), AriportCodeEnum.GET_NO_TENANT.getMsg()); | |||
} | |||
String url = tenant.getAirportUrl() + API_AIRPORT_LINE_LIST; | |||
String url = tenant.getAirportUrl() + SystemConstant.API_AIRPORT_LINE_LIST; | |||
String param = "page=1&limit=100&droneId=" + droneId; | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); |
@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.inspection.add; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.conver.InspectionConverMapper; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
@@ -9,12 +10,19 @@ import com.tuoheng.admin.enums.InspectionTypeEnum; | |||
import com.tuoheng.admin.enums.code.inspection.AddInspectionCodeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.request.inspection.AddInspectionRequest; | |||
import com.tuoheng.admin.request.third.PilotTaskRequest; | |||
import com.tuoheng.admin.service.third.pilot.PilotService; | |||
import com.tuoheng.admin.utils.ShiroUtils; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
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.http.HttpEntity; | |||
import org.springframework.http.HttpMethod; | |||
import org.springframework.http.HttpStatus; | |||
import org.springframework.http.ResponseEntity; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
@@ -43,6 +51,12 @@ public class AddInspectionService { | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Autowired | |||
private PilotService pilotService; | |||
/** | |||
* 添加任务 | |||
* | |||
@@ -58,8 +72,16 @@ public class AddInspectionService { | |||
return result; | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
if (null == user) { | |||
return JsonResult.error(AddInspectionCodeEnum.USER_IS_NOT_EXIST.getCode(), AddInspectionCodeEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
// 构造inspection对象 | |||
result = this.buildInspection(userId, tenantId, addInspectionRequest); | |||
result = this.buildInspection(user, tenantId, addInspectionRequest); | |||
if (0 != result.getCode()) { | |||
log.info("添加任务业务:构建inspection对象失败:{}", result.getMsg()); | |||
return result; | |||
@@ -67,7 +89,7 @@ public class AddInspectionService { | |||
Inspection inspection = (Inspection) result.getData(); | |||
// 调用第三方平台 | |||
result = this.callThirdPlatform(tenantId, inspection); | |||
result = this.callThirdPlatform(user, tenantId, inspection); | |||
if (0 != result.getCode()) { | |||
log.info("添加任务业务:对接第三方平台失败:{}", result.getMsg()); | |||
return result; | |||
@@ -161,19 +183,12 @@ public class AddInspectionService { | |||
* | |||
* 构造Inspection对象 | |||
* | |||
* @param userId | |||
* @param user | |||
* @param tenantId | |||
* @param addInspectionRequest | |||
* @return | |||
*/ | |||
private JsonResult buildInspection(String userId, String tenantId, AddInspectionRequest addInspectionRequest) { | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
if (null == user) { | |||
return JsonResult.error(AddInspectionCodeEnum.USER_IS_NOT_EXIST.getCode(), AddInspectionCodeEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
private JsonResult buildInspection(User user, String tenantId, AddInspectionRequest addInspectionRequest) { | |||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||
.eq(Dept::getTenantId, tenantId) | |||
.eq(Dept::getId, user.getDeptId()) | |||
@@ -186,7 +201,7 @@ public class AddInspectionService { | |||
inspection.setCode(code); | |||
inspection.setTenantId(tenantId); | |||
inspection.setDeptId(dept.getId()); | |||
inspection.setCreateUser(userId); | |||
inspection.setCreateUser(user.getId()); | |||
inspection.setCreateTime(DateUtils.now()); | |||
inspection.setMobile(user.getMobile()); | |||
inspection.setStatus(InspectionStatusEnum.WAIT_FLIGHT.getCode()); | |||
@@ -194,58 +209,26 @@ public class AddInspectionService { | |||
} | |||
/** | |||
* 验证与第三方平台(飞手、dsp、高德)对接 | |||
* 与第三方平台(飞手、高德)对接 | |||
* | |||
* @param user | |||
* @param tenantId | |||
* @param inspection | |||
* @return | |||
*/ | |||
private JsonResult callThirdPlatform(String tenantId, Inspection inspection) { | |||
private JsonResult callThirdPlatform(User user, String tenantId, Inspection inspection) { | |||
// 对接高德地图 | |||
JsonResult result = this.callGaode(inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
// 对接飞手平台 | |||
result = this.callPilot(inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
// 对接DSP平台 | |||
result = this.callDSP(inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* | |||
* 对接飞手平台 | |||
* | |||
* @return | |||
*/ | |||
private JsonResult callPilot(Inspection inspection) { | |||
// TODO | |||
// 具体业务逻辑待实现,以下写法只是为了体现调用飞手平台成功或失败场景 | |||
if (StringUtils.isEmpty(inspection.getName())) { | |||
return JsonResult.error(AddInspectionCodeEnum.CALL_PILOT_IS_FAILED.getCode(), AddInspectionCodeEnum.CALL_PILOT_IS_FAILED.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* | |||
* 对接DSP平台 | |||
* | |||
* @return | |||
*/ | |||
private JsonResult callDSP(Inspection inspection) { | |||
// TODO | |||
// 具体业务逻辑待实现,以下写法只是为了体现调用DSP平台成功或失败场景 | |||
if (StringUtils.isEmpty(inspection.getName())) { | |||
return JsonResult.error(AddInspectionCodeEnum.CALL_DSP_IS_FAILED.getCode(), AddInspectionCodeEnum.CALL_DSP_IS_FAILED.getMsg()); | |||
if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == inspection.getInspectionType()) { | |||
// 对接飞手平台 | |||
result = pilotService.addTask(user, inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
} | |||
return JsonResult.success(); | |||
} |
@@ -2,13 +2,17 @@ package com.tuoheng.admin.service.inspection.execute; | |||
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.Inspection; | |||
import com.tuoheng.admin.entity.InspectionHistory; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.code.inspection.ExecuteInspectionCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionHistoryMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.utils.ShiroUtils; | |||
import com.tuoheng.common.core.utils.*; | |||
import lombok.Data; | |||
@@ -27,6 +31,9 @@ import org.springframework.stereotype.Service; | |||
@Service | |||
public class ExecuteInspectionService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@@ -46,7 +53,7 @@ public class ExecuteInspectionService { | |||
String userId = ShiroUtils.getUserId(); | |||
String tenantId = ShiroUtils.getTenantId(); | |||
JsonResult result = this.check(id); | |||
JsonResult result = this.check(userId, tenantId, id); | |||
if (0 != result.getCode()) { | |||
log.info("立即执行任务业务:校验参数失败:{}", result.getMsg()); | |||
return result; | |||
@@ -54,6 +61,8 @@ public class ExecuteInspectionService { | |||
Inspection inspection = (Inspection) result.getData(); | |||
// 立即执行任务 | |||
this.executeTask(userId, tenantId, inspection); | |||
log.info("立即执行任务业务:重新提交任务成功:{}", inspection); | |||
return JsonResult.success(inspection); | |||
@@ -61,11 +70,12 @@ public class ExecuteInspectionService { | |||
/** | |||
* 检查参数 | |||
* | |||
* 注意:1)、超级管理员不能执行任务 | |||
* 2)、管理员和普通用户只能执行本部门任务,不能执行子部门任务 | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
private JsonResult check(String userId, String tenantId, String id) { | |||
if (StringUtils.isEmpty(id)) { | |||
return JsonResult.error(ExecuteInspectionCodeEnum.ID_IS_NULL.getCode(), ExecuteInspectionCodeEnum.ID_IS_NULL.getMsg()); | |||
} | |||
@@ -73,6 +83,15 @@ public class ExecuteInspectionService { | |||
if (null == inspection) { | |||
return JsonResult.error(ExecuteInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), ExecuteInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg()); | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
if (!user.getDeptId().equals(inspection.getDeptId())) { | |||
return JsonResult.error(ExecuteInspectionCodeEnum.USER_ONLY_EXECUTE_DEPARTMENT_TASK.getCode(), ExecuteInspectionCodeEnum.USER_ONLY_EXECUTE_DEPARTMENT_TASK.getMsg()); | |||
} | |||
return JsonResult.success(inspection); | |||
} | |||
@@ -83,7 +102,7 @@ public class ExecuteInspectionService { | |||
* @param inspection | |||
* @return | |||
*/ | |||
public JsonResult executeTask(String tenantId, Inspection inspection) { | |||
public JsonResult executeTask(String userId, String tenantId, Inspection inspection) { | |||
//读取不同租户的机场平台url | |||
Tenant tenant = tenantMapper.selectById(inspection.getTenantId()); | |||
if (ObjectUtil.isEmpty(tenant)) { | |||
@@ -94,10 +113,10 @@ public class ExecuteInspectionService { | |||
return JsonResult.error(ExecuteInspectionCodeEnum.AIRPORT_URL_IS_NULL.getCode(), ExecuteInspectionCodeEnum.AIRPORT_URL_IS_NULL.getMsg()); | |||
} | |||
String url = tenant.getAirportUrl() + "/api/airportInterface/executeTask"; | |||
String url = tenant.getAirportUrl() + SystemConstant.API_AIRPORT_EXECUTE_TASK; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("taskId", inspection.getInspectionLine()); | |||
jsonObject.put("requestId", String.valueOf(inspection.getId())); | |||
jsonObject.put("requestId", inspection.getId()); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
@@ -106,10 +125,12 @@ public class ExecuteInspectionService { | |||
return JsonResult.error(ExecuteInspectionCodeEnum.AIRPORT_RETURN_DATA_IS_NULL.getCode(), ExecuteInspectionCodeEnum.AIRPORT_RETURN_DATA_IS_NULL.getMsg()); | |||
} | |||
this.updateInspection(userId, inspection); | |||
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
if (jsonResult.getCode() != 0) { | |||
log.info("立即执行任务业务:机场接口返回结果:失败:{}", jsonResult.getMsg()); | |||
this.insertInspectionHistory(userId, tenantId, inspection, jsonResult.getMsg()); | |||
return JsonResult.error(jsonResult.getMsg()); | |||
} else { | |||
return JsonResult.success(); | |||
@@ -119,10 +140,10 @@ public class ExecuteInspectionService { | |||
/** | |||
* 修改任务执行状态 | |||
* | |||
* @param tenantId | |||
* @param userId | |||
* @param inspection | |||
*/ | |||
private void updateInspection(String userId, String tenantId, Inspection inspection, String msg) { | |||
private void updateInspection(String userId, Inspection inspection) { | |||
inspection.setExecutionStatus(2); | |||
inspection.setUpdateUser(userId); | |||
inspection.setUpdateTime(DateUtils.now()); | |||
@@ -142,7 +163,6 @@ public class ExecuteInspectionService { | |||
inspectionHistory.setHistoryName(msg); | |||
inspectionHistory.setCreateUser(userId); | |||
inspectionHistory.setCreateTime(DateUtils.now()); | |||
inspectionHistoryMapper.insert(inspectionHistory); | |||
} | |||
@@ -9,6 +9,7 @@ import com.tuoheng.admin.enums.InspectionTypeEnum; | |||
import com.tuoheng.admin.enums.code.inspection.ResubmitInspectionCodeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.request.inspection.EditInspectionRequest; | |||
import com.tuoheng.admin.service.third.pilot.PilotService; | |||
import com.tuoheng.admin.utils.ShiroUtils; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -43,6 +44,9 @@ public class ResubmitInspectionService { | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private PilotService pilotService; | |||
/** | |||
* 重新提交任务 | |||
* | |||
@@ -57,9 +61,15 @@ public class ResubmitInspectionService { | |||
log.info("重新提交任务业务:校验参数失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
if (null == user) { | |||
return JsonResult.error(ResubmitInspectionCodeEnum.USER_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
// 构造inspection对象 | |||
result = this.buildInspection(userId, tenantId, request); | |||
result = this.buildInspection(user, tenantId, request); | |||
if (0 != result.getCode()) { | |||
log.info("重新提交任务业务:构建inspection对象失败:{}", result.getMsg()); | |||
return result; | |||
@@ -67,7 +77,7 @@ public class ResubmitInspectionService { | |||
Inspection inspection = (Inspection) result.getData(); | |||
// 调用第三方平台 | |||
result = this.callThirdPlatform(tenantId, inspection); | |||
result = this.callThirdPlatform(user, tenantId, inspection); | |||
if (0 != result.getCode()) { | |||
log.info("重新提交任务业务:对接第三方平台失败:{}", result.getMsg()); | |||
return result; | |||
@@ -180,19 +190,12 @@ public class ResubmitInspectionService { | |||
* | |||
* 构造Inspection对象 | |||
* | |||
* @param userId | |||
* @param user | |||
* @param tenantId | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult buildInspection(String userId, String tenantId, EditInspectionRequest request) { | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
if (null == user) { | |||
return JsonResult.error(ResubmitInspectionCodeEnum.USER_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
private JsonResult buildInspection(User user, String tenantId, EditInspectionRequest request) { | |||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||
.eq(Dept::getTenantId, tenantId) | |||
.eq(Dept::getId, user.getDeptId()) | |||
@@ -201,10 +204,12 @@ public class ResubmitInspectionService { | |||
return JsonResult.error(ResubmitInspectionCodeEnum.DEPT_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
Inspection inspection = InspectionConverMapper.INSTANCE.fromEditInspectionRequestToInspection(request); | |||
String code = DateUtils.generateCode("XJRW"); | |||
inspection.setCode(code); | |||
inspection.setId(""); | |||
inspection.setTenantId(tenantId); | |||
inspection.setDeptId(dept.getId()); | |||
inspection.setCreateUser(userId); | |||
inspection.setCreateUser(user.getId()); | |||
inspection.setCreateTime(DateUtils.now()); | |||
inspection.setMobile(user.getMobile()); | |||
inspection.setStatus(InspectionStatusEnum.WAIT_FLIGHT.getCode()); // 重新提交,状态设置为等待飞行 | |||
@@ -212,58 +217,26 @@ public class ResubmitInspectionService { | |||
} | |||
/** | |||
* 验证与第三方平台(飞手、dsp、高德)对接 | |||
* 与第三方平台(飞手、高德)对接 | |||
* | |||
* @param user | |||
* @param tenantId | |||
* @param inspection | |||
* @return | |||
*/ | |||
private JsonResult callThirdPlatform(String tenantId, Inspection inspection) { | |||
private JsonResult callThirdPlatform(User user, String tenantId, Inspection inspection) { | |||
// 对接高德地图 | |||
JsonResult result = this.callGaode(inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
// 对接飞手平台 | |||
result = this.callPilot(inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
// 对接DSP平台 | |||
result = this.callDSP(inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* | |||
* 对接飞手平台 | |||
* | |||
* @return | |||
*/ | |||
private JsonResult callPilot(Inspection inspection) { | |||
// TODO | |||
// 具体业务逻辑待实现,以下写法只是为了体现调用飞手平台成功或失败场景 | |||
if (StringUtils.isEmpty(inspection.getName())) { | |||
return JsonResult.error(ResubmitInspectionCodeEnum.CALL_PILOT_IS_FAILED.getCode(), ResubmitInspectionCodeEnum.CALL_PILOT_IS_FAILED.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* | |||
* 对接DSP平台 | |||
* | |||
* @return | |||
*/ | |||
private JsonResult callDSP(Inspection inspection) { | |||
// TODO | |||
// 具体业务逻辑待实现,以下写法只是为了体现调用DSP平台成功或失败场景 | |||
if (StringUtils.isEmpty(inspection.getName())) { | |||
return JsonResult.error(ResubmitInspectionCodeEnum.CALL_DSP_IS_FAILED.getCode(), ResubmitInspectionCodeEnum.CALL_DSP_IS_FAILED.getMsg()); | |||
if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == inspection.getInspectionType()) { | |||
// 对接飞手平台 | |||
result = pilotService.addTask(user, inspection); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
} | |||
return JsonResult.success(); | |||
} |
@@ -0,0 +1,78 @@ | |||
package com.tuoheng.admin.service.third.pilot; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.request.third.PilotTaskRequest; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
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.http.HttpEntity; | |||
import org.springframework.http.HttpMethod; | |||
import org.springframework.http.HttpStatus; | |||
import org.springframework.http.ResponseEntity; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.client.RestTemplate; | |||
@Slf4j | |||
@Service | |||
public class AddPilotTskService { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Autowired | |||
@Qualifier("restTemplate") | |||
private RestTemplate restTemplate; | |||
public JsonResult addTask(User user, Inspection inspection) { | |||
Tenant tenant = tenantMapper.selectById(inspection.getTenantId()); | |||
//第三方请求体需要 | |||
PilotTaskRequest pilotTaskRequest = new PilotTaskRequest(); | |||
pilotTaskRequest.setTaskCode(inspection.getCode()); | |||
pilotTaskRequest.setTaskName(inspection.getName()); | |||
pilotTaskRequest.setTenantName(tenant.getName()); | |||
pilotTaskRequest.setPatrolLocation(inspection.getPatrolLocation()); | |||
pilotTaskRequest.setPlatformCode("hhz"); | |||
pilotTaskRequest.setSponsorName(user.getRealname()); | |||
pilotTaskRequest.setSponsorPhone(inspection.getMobile()); | |||
pilotTaskRequest.setTaskStartTime(inspection.getInspectionTime()); | |||
pilotTaskRequest.setRemark(inspection.getNote()); | |||
//直播 | |||
pilotTaskRequest.setIsLive(inspection.getIsLive()); | |||
//经纬度 | |||
pilotTaskRequest.setStartLatitude(inspection.getStartLatitude()); | |||
pilotTaskRequest.setStartLongitude(inspection.getStartLongitude()); | |||
pilotTaskRequest.setEndLongitude(inspection.getEndLongitude()); | |||
pilotTaskRequest.setEndLatitude(inspection.getEndLatitude()); | |||
//第三方 | |||
pilotTaskRequest.setInspectionType(0); | |||
HttpEntity httpEntity = new HttpEntity(pilotTaskRequest); | |||
//设置地址(飞手平台) | |||
String url = CommonConfig.pilotURL + SystemConstant.ADD_PILOTTASK; | |||
//String url ="http://localhost:9115/apiTask/add"; | |||
ResponseEntity<JsonResult> response = null; | |||
try { | |||
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); | |||
} catch (Exception e) { | |||
log.error("请求第三方响应失败,异常!"); | |||
return JsonResult.error("请求第三方响应失败"); | |||
} | |||
if (null == response || !response.hasBody() || response.getBody().getCode() != JsonResult.SUCCESS) { | |||
log.error("请求第三方响应失败!"); | |||
return JsonResult.error("请求第三方响应失败,返回空"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.tuoheng.admin.service.third.pilot; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
public interface PilotService { | |||
JsonResult addTask(User user, Inspection inspection); | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.tuoheng.admin.service.third.pilot; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Service("pilotService") | |||
public class PilotServiceImpl implements PilotService { | |||
@Autowired | |||
private AddPilotTskService addPilotTskService; | |||
@Override | |||
public JsonResult addTask(User user, Inspection inspection) { | |||
return addPilotTskService.addTask(user, inspection); | |||
} | |||
} |
@@ -122,11 +122,17 @@ tuoheng: | |||
# OSS域名 | |||
oss-url: https://ta-tech-image.oss-cn-shanghai.aliyuncs.com | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com | |||
# 通道地址 | |||
live-channel-domain-url: http://47.96.182.154:9024/ | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: c01a978a4a24759282f6e3a9b9a0974d | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: https://dsp.t-aaron.com/ | |||
# DSP回调地址 | |||
dsp-callback-url: https://192.168.11.11:9055/api/dsp/{requestId}/callback | |||
#飞手平台地址 | |||
pilot-url: http://192.168.11.11:7011/pilot/web/ | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 |
@@ -123,15 +123,21 @@ spring: | |||
tuoheng: | |||
oidc-url: http://192.168.11.11:7011 | |||
# 图片域名 | |||
image-url: https://image.t-aaron.com | |||
image-url: http://localhost:9055/api | |||
# OSS域名 | |||
oss-url: https://ta-tech-image.oss-cn-shanghai.aliyuncs.com | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com | |||
# 通道地址 | |||
live-channel-domain-url: http://47.96.182.154:9024/ | |||
video-url: http://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: c01a978a4a24759282f6e3a9b9a0974d | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: http://192.168.11.241:7011/ | |||
# DSP回调地址 | |||
dsp-callback-url: https://127.0.0.1:9055/api/dsp/{requestId}/callback | |||
#飞手平台地址 | |||
pilot-url: http://192.168.11.241:7011/pilot/web/ | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 |
@@ -122,11 +122,17 @@ tuoheng: | |||
# OSS域名 | |||
oss-url: https://ta-tech-image.oss-cn-shanghai.aliyuncs.com | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com | |||
# 通道地址 | |||
live-channel-domain-url: http://47.96.182.154:9024/ | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: c01a978a4a24759282f6e3a9b9a0974d | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: https://dsp-portal.t-aaron.com/ | |||
# DSP回调地址 | |||
dsp-callback-url: https://hhz.t-aaron.com/api/dsp/{requestId}/callback | |||
#飞手平台地址 | |||
pilot-url: https://pilot.t-aaron.com/pilot/web/ | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 |
@@ -123,11 +123,17 @@ tuoheng: | |||
# OSS域名 | |||
oss-url: https://ta-tech-image.oss-cn-shanghai.aliyuncs.com | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com | |||
# 通道地址 | |||
live-channel-domain-url: http://47.96.182.154:9024/ | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: c01a978a4a24759282f6e3a9b9a0974d | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: http://192.168.11.241:7011/ | |||
# DSP回调地址 | |||
dsp-callback-url: http://192.168.11.241:9055/api/dsp/{requestId}/callback | |||
#飞手平台地址 | |||
pilot-url: http://192.168.11.241:7011/pilot/web/ | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 |