Browse Source

1、提交重新提交任务代码;2、修改新增任务判断业务逻辑;

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
3e5e799919
9 changed files with 437 additions and 21 deletions
  1. +9
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/AddInspectionCodeEnum.java
  3. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/EditInspectionCodeEnum.java
  4. +73
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/ResubmitInspectionCodeEnum.java
  5. +30
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/EditInspectionRequest.java
  6. +8
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java
  7. +15
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java
  8. +11
    -14
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java
  9. +288
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/resubmit/ResubmitInspectionService.java

+ 9
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java View File

@@ -97,4 +97,13 @@ public class InspectionController {
public JsonResult videoById(@PathVariable("id") String id){
return iInspectionService.getVideoById(id);
}

/**
* 删除巡检任务
*/
@PostMapping("/resubmit")
public JsonResult resubmit(@RequestBody EditInspectionRequest editInspectionRequest) {
log.info("进入重新提交任务接口, id={}", editInspectionRequest.getId());
return iInspectionService.resubmit(editInspectionRequest);
}
}

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/AddInspectionCodeEnum.java View File

@@ -11,10 +11,10 @@ package com.tuoheng.admin.enums.code.inspection;
*/
public enum AddInspectionCodeEnum {

ADD_INSPECTION_IS_FAILED(1230100, "添加任务失败"),
ADD_IS_FAILED(1230100, "添加任务失败"),
NAME_IS_NULL(1230101, "任务名为空"),
TYPE_IS_NULL(1230102, "任务类型为空"),
ROAD_IS_NULL(1230103, "任务地点为空"),
ROAD_IS_NULL(1230103, "公路信息为空"),
SECTION_IS_NULL(1230104, "路段信息为空"),
INSPECTION_TYPE_IS_NULL(1230105, "巡检方式为空"),
AIRPORT_IS_NULL(1230106, "巡检机场为空"),

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/EditInspectionCodeEnum.java View File

@@ -11,7 +11,7 @@ package com.tuoheng.admin.enums.code.inspection;
*/
public enum EditInspectionCodeEnum {

ADD_DEPT_IS_FAILED(1230300, "修改任务失败"),
EDIT_IS_FAILED(1230300, "修改任务失败"),
ID_IS_NULL(1230301, "任务ID为空"),
NAME_IS_NULL(1230302, "任务名为空"),
TYPE_IS_NULL(1230303, "任务类型为空"),

+ 73
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/ResubmitInspectionCodeEnum.java View File

@@ -0,0 +1,73 @@
package com.tuoheng.admin.enums.code.inspection;

/**
* 重新提交任务信息返回码
* 模块代码:23(任务管理)
* 接口代码:07 (重新提交任务)
*
* @author wanjing
* @team tuoheng
* @date 2022-12-01
*/
public enum ResubmitInspectionCodeEnum {

RESUBMIT_IS_FAILED(1230700, "重新提交失败"),
ID_IS_NULL(1230701, "任务ID为空"),
NAME_IS_NULL(1230702, "任务名为空"),
TYPE_IS_NULL(1230703, "任务类型为空"),
ROAD_IS_NULL(1230704, "公路信息为空"),
SECTION_IS_NULL(1230705, "路段信息为空"),
INSPECTION_TYPE_IS_NULL(1230706, "巡检方式为空"),
AIRPORT_IS_NULL(1230707, "巡检机场为空"),
INSPECTION_LINE_IS_NULL(1230708, "巡检路线为空"),
LIVE_IS_NULL(1230709, "是否直播为空"),
START_LONGITUDE_IS_NULL(1230710, "起点经度为空"),
START_LATITUDE_IS_NULL(1230711, "起点纬度为空"),
END_LONGITUDE_IS_NULL(1230712, "终点经度为空"),
END_LATITUDE_IS_NULL(1230713, "终点纬度为空"),
INSPECTION_TIME_IS_NULL(1230714, "巡检时间为空"),
INSPECTION_IS_NOT_EXIST(1230715, "任务不存在"),

FAILED_INSPECTION_CANNOT_RESUBMIT(1230716, "非失败的任务不能被重新提交"),
TYPE_IS_NOT_EDIT(1230717, "巡检类型不能被修改"),
INSPECTION_TYPE_IS_NOT_EDIT(1230718, "巡检方式不能被修改"),
ROAD_IS_NOT_EXIST(1230719, "公路不存在"),
SECTION_IS_NOT_EXIST(1230720, "路段不存在"),
USER_IS_NOT_EXIST(1230721, "用户不存在"),
DEPT_IS_NOT_EXIST(1230722, "部门不存在"),
CALL_PILOT_IS_FAILED(1230723, "对接飞手平台失败"),
CALL_DSP_IS_FAILED(1230724, "对接DSP平台失败"),
CALL_AMAP_IS_FAILED(1230725, "对接高德地图平台失败");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

ResubmitInspectionCodeEnum(int code, String msg){
this.code = code;
this.msg = msg;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

}

+ 30
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/EditInspectionRequest.java View File

@@ -32,6 +32,11 @@ public class EditInspectionRequest {
*/
private Integer tenantId;

/**
* 任务编码
*/
private String code;

/**
* 任务名称
*/
@@ -92,6 +97,31 @@ public class EditInspectionRequest {
*/
private String sectionName;

/**
* 是否直播,1:实时 2:离线 默认:null
*/
private Integer isLive;

/**
* 起点经度
*/
private String startLongitude;

/**
* 起点纬度
*/
private String startLatitude;

/**
* 终点经度
*/
private String endLongitude;

/**
* 终点纬度
*/
private String endLatitude;

/**
* 计划巡检日期
*/

+ 8
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java View File

@@ -75,4 +75,12 @@ public interface IInspectionService {

JsonResult getVideoById(String id);

/**
* 重新提交巡检任务
*
* @param editInspectionRequest 修改任务请求参数
* @return 结果
*/
JsonResult resubmit(EditInspectionRequest editInspectionRequest);

}

+ 15
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java View File

@@ -1,12 +1,11 @@
package com.tuoheng.admin.service.inspection;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.request.inspection.AddInspectionRequest;
import com.tuoheng.admin.request.inspection.EditInspectionRequest;
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest;
import com.tuoheng.admin.service.inspection.add.AddInspectionService;
import com.tuoheng.admin.service.inspection.resubmit.ResubmitInspectionService;
import com.tuoheng.admin.service.inspection.delete.DeleteInspectionService;

import com.tuoheng.admin.service.inspection.query.*;
@@ -16,8 +15,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 巡检任务Service业务层处理
*
@@ -56,6 +53,9 @@ public class InspectionServiceImpl implements IInspectionService {
@Autowired
private QueryVideoService queryVideoService;

@Autowired
private ResubmitInspectionService resubmitInspectionService;

/**
* 查询巡检任务分页分页列表
*
@@ -149,4 +149,15 @@ public class InspectionServiceImpl implements IInspectionService {
public JsonResult getVideoById(String id) {
return queryVideoService.getVideoById(id);
}

/**
* 重新提交巡检任务
*
* @param editInspectionRequest 修改任务请求参数
* @return 结果
*/
@Override
public JsonResult resubmit(EditInspectionRequest editInspectionRequest) {
return resubmitInspectionService.resubmit(editInspectionRequest);
}
}

+ 11
- 14
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java View File

@@ -76,7 +76,7 @@ public class AddInspectionService {
log.info("添加任务, 返回结果: deptId={}", rowId);
if (rowId <= 0) {
log.info("添加任务业务:添加任务失败:{}", result.getMsg());
return JsonResult.error(AddInspectionCodeEnum.ADD_INSPECTION_IS_FAILED.getCode(), AddInspectionCodeEnum.ADD_INSPECTION_IS_FAILED.getMsg());
return JsonResult.error(AddInspectionCodeEnum.ADD_IS_FAILED.getCode(), AddInspectionCodeEnum.ADD_IS_FAILED.getMsg());
}
log.info("添加任务业务:添加任务成功:{}", inspection);
return JsonResult.success(inspection);
@@ -100,15 +100,21 @@ public class AddInspectionService {
if (null == addInspectionRequest.getInspectionType()) {
return JsonResult.error(AddInspectionCodeEnum.INSPECTION_TYPE_IS_NULL.getCode(), AddInspectionCodeEnum.INSPECTION_TYPE_IS_NULL.getMsg());
}
if (null == addInspectionRequest.getRoadId() || StringUtils.isEmpty(addInspectionRequest.getRoadName())) {
return JsonResult.error(AddInspectionCodeEnum.ROAD_IS_NULL.getCode(), AddInspectionCodeEnum.ROAD_IS_NULL.getMsg());
}

if (null == addInspectionRequest.getSectionId() || StringUtils.isEmpty(addInspectionRequest.getSectionName())) {
return JsonResult.error(AddInspectionCodeEnum.SECTION_IS_NULL.getCode(), AddInspectionCodeEnum.SECTION_IS_NULL.getMsg());
}
if (InspectionTypeEnum.AIRPORT.getCode() == addInspectionRequest.getInspectionType()) {
// 巡检方式:机场巡逻,可选择巡检机场和巡检路线
if (null == addInspectionRequest.getRoadId() || StringUtils.isEmpty(addInspectionRequest.getRoadName())) {
return JsonResult.error(AddInspectionCodeEnum.ROAD_IS_NULL.getCode(), AddInspectionCodeEnum.ROAD_IS_NULL.getMsg());
if (null == addInspectionRequest.getAirportId() || StringUtils.isEmpty(addInspectionRequest.getAirportName())) {
return JsonResult.error(AddInspectionCodeEnum.AIRPORT_IS_NULL.getCode(), AddInspectionCodeEnum.AIRPORT_IS_NULL.getMsg());
}

if (null == addInspectionRequest.getSectionId() || StringUtils.isEmpty(addInspectionRequest.getSectionName())) {
return JsonResult.error(AddInspectionCodeEnum.SECTION_IS_NULL.getCode(), AddInspectionCodeEnum.SECTION_IS_NULL.getMsg());
if (null == addInspectionRequest.getInspectionLine() || StringUtils.isEmpty(addInspectionRequest.getInspectionLineName())) {
return JsonResult.error(AddInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getCode(), AddInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getMsg());
}
} else if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == addInspectionRequest.getInspectionType()) {
// 巡检方式:飞手值飞,可选择是否直播,起点坐标,终点坐标
@@ -128,15 +134,6 @@ public class AddInspectionService {
return JsonResult.error(AddInspectionCodeEnum.END_LATITUDE_IS_NULL.getCode(), AddInspectionCodeEnum.END_LATITUDE_IS_NULL.getMsg());
}
}

if (null == addInspectionRequest.getAirportId() || StringUtils.isEmpty(addInspectionRequest.getAirportName())) {
return JsonResult.error(AddInspectionCodeEnum.AIRPORT_IS_NULL.getCode(), AddInspectionCodeEnum.AIRPORT_IS_NULL.getMsg());
}

if (null == addInspectionRequest.getInspectionLine() || StringUtils.isEmpty(addInspectionRequest.getInspectionLineName())) {
return JsonResult.error(AddInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getCode(), AddInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getMsg());
}

if (null == addInspectionRequest.getInspectionTime()) {
return JsonResult.error(AddInspectionCodeEnum.INSPECTION_TIME_IS_NULL.getCode(), AddInspectionCodeEnum.INSPECTION_TIME_IS_NULL.getMsg());
}

+ 288
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/resubmit/ResubmitInspectionService.java View File

@@ -0,0 +1,288 @@
package com.tuoheng.admin.service.inspection.resubmit;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.InspectionConverMapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionStatusEnum;
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.utils.ShiroUtils;
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 2022-12-201
*/
@Slf4j
@Service
public class ResubmitInspectionService {

@Autowired
private UserMapper userMapper;

@Autowired
private DeptMapper deptMapper;

@Autowired
private RoadInformationMapper roadInformationMapper;

@Autowired
private SectionMapper sectionMapper;

@Autowired
private InspectionMapper inspectionMapper;

/**
* 重新提交任务
*
* @return
*/
public JsonResult resubmit(EditInspectionRequest request) {
log.info("进入重新提交任务业务");
String userId = ShiroUtils.getUserId();
String tenantId = ShiroUtils.getTenantId();
JsonResult result = this.checkParam(tenantId, request);
if (0 != result.getCode()) {
log.info("重新提交任务业务:校验参数失败:{}", result.getMsg());
return result;
}

// 构造inspection对象
result = this.buildInspection(userId, tenantId, request);
if (0 != result.getCode()) {
log.info("重新提交任务业务:构建inspection对象失败:{}", result.getMsg());
return result;
}
Inspection inspection = (Inspection) result.getData();

// 调用第三方平台
result = this.callThirdPlatform(tenantId, inspection);
if (0 != result.getCode()) {
log.info("重新提交任务业务:对接第三方平台失败:{}", result.getMsg());
return result;
}
Integer rowId = inspectionMapper.insert(inspection);
log.info("重新提交任务, 返回结果: deptId={}", rowId);
if (rowId <= 0) {
log.info("重新提交任务业务:重新提交任务失败:{}", result.getMsg());
return JsonResult.error(ResubmitInspectionCodeEnum.RESUBMIT_IS_FAILED.getCode(), ResubmitInspectionCodeEnum.RESUBMIT_IS_FAILED.getMsg());
}
log.info("重新提交任务业务:重新提交任务成功:{}", inspection);
return JsonResult.success(inspection);
}

/**
* 检查参数
* @param tenantId
* @param request
* @return
*/
private JsonResult checkParam(String tenantId, EditInspectionRequest request) {
if (StringUtils.isEmpty(request.getId())) {
return JsonResult.error(ResubmitInspectionCodeEnum.ID_IS_NULL.getCode(), ResubmitInspectionCodeEnum.ID_IS_NULL.getMsg());
}

if (StringUtils.isEmpty(request.getName())) {
return JsonResult.error(ResubmitInspectionCodeEnum.NAME_IS_NULL.getCode(), ResubmitInspectionCodeEnum.NAME_IS_NULL.getMsg());
}
if (null == request.getType()) {
return JsonResult.error(ResubmitInspectionCodeEnum.TYPE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.TYPE_IS_NULL.getMsg());
}
if (null == request.getInspectionType()) {
return JsonResult.error(ResubmitInspectionCodeEnum.INSPECTION_TYPE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.INSPECTION_TYPE_IS_NULL.getMsg());
}
if (null == request.getRoadId() || StringUtils.isEmpty(request.getRoadName())) {
return JsonResult.error(ResubmitInspectionCodeEnum.ROAD_IS_NULL.getCode(), ResubmitInspectionCodeEnum.ROAD_IS_NULL.getMsg());
}

if (null == request.getSectionId() || StringUtils.isEmpty(request.getSectionName())) {
return JsonResult.error(ResubmitInspectionCodeEnum.SECTION_IS_NULL.getCode(), ResubmitInspectionCodeEnum.SECTION_IS_NULL.getMsg());
}
if (InspectionTypeEnum.AIRPORT.getCode() == request.getInspectionType()) {
// 巡检方式:机场巡逻,可选择巡检机场和巡检路线
if (null == request.getAirportId() || StringUtils.isEmpty(request.getAirportName())) {
return JsonResult.error(ResubmitInspectionCodeEnum.AIRPORT_IS_NULL.getCode(), ResubmitInspectionCodeEnum.AIRPORT_IS_NULL.getMsg());
}
if (null == request.getInspectionLine() || StringUtils.isEmpty(request.getInspectionLineName())) {
return JsonResult.error(ResubmitInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getMsg());
}
} else if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == request.getInspectionType()) {
// 巡检方式:飞手值飞,可选择是否直播,起点坐标,终点坐标
if (null == request.getIsLive()) {
return JsonResult.error(ResubmitInspectionCodeEnum.LIVE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.LIVE_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(request.getStartLongitude())) {
return JsonResult.error(ResubmitInspectionCodeEnum.START_LONGITUDE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.START_LONGITUDE_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(request.getStartLatitude())) {
return JsonResult.error(ResubmitInspectionCodeEnum.START_LATITUDE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.START_LATITUDE_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(request.getEndLongitude())) {
return JsonResult.error(ResubmitInspectionCodeEnum.END_LONGITUDE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.END_LONGITUDE_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(request.getEndLatitude())) {
return JsonResult.error(ResubmitInspectionCodeEnum.END_LATITUDE_IS_NULL.getCode(), ResubmitInspectionCodeEnum.END_LATITUDE_IS_NULL.getMsg());
}
}

if (null == request.getInspectionTime()) {
return JsonResult.error(ResubmitInspectionCodeEnum.INSPECTION_TIME_IS_NULL.getCode(), ResubmitInspectionCodeEnum.INSPECTION_TIME_IS_NULL.getMsg());
}

Inspection inspectionOld = inspectionMapper.selectById(request.getId());
if (null == inspectionOld) {
return JsonResult.error(ResubmitInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}

if (inspectionOld.getStatus() != InspectionStatusEnum.FLIGHT_FAILED.getCode()) {
return JsonResult.error(ResubmitInspectionCodeEnum.FAILED_INSPECTION_CANNOT_RESUBMIT.getCode(), ResubmitInspectionCodeEnum.FAILED_INSPECTION_CANNOT_RESUBMIT.getMsg());
}

if (inspectionOld.getType() != request.getType()) {
return JsonResult.error(ResubmitInspectionCodeEnum.TYPE_IS_NOT_EDIT.getCode(), ResubmitInspectionCodeEnum.TYPE_IS_NOT_EDIT.getMsg());
}

if (inspectionOld.getInspectionType() != request.getInspectionType()) {
return JsonResult.error(ResubmitInspectionCodeEnum.INSPECTION_TYPE_IS_NOT_EDIT.getCode(), ResubmitInspectionCodeEnum.INSPECTION_TYPE_IS_NOT_EDIT.getMsg());
}

Integer roadCount = roadInformationMapper.selectCount(Wrappers.<RoadInformation>lambdaQuery()
.eq(RoadInformation::getTenantId, tenantId)
.eq(RoadInformation::getId, request.getRoadId())
.eq(RoadInformation::getMark, 1));

if (roadCount <= 0) {
return JsonResult.error(ResubmitInspectionCodeEnum.ROAD_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.ROAD_IS_NOT_EXIST.getMsg());
}

Integer sectionCount = sectionMapper.selectCount(Wrappers.<Section>lambdaQuery()
.eq(Section::getTenantId, tenantId)
.eq(Section::getId, request.getSectionId())
.eq(Section::getMark, 1));
if (sectionCount <= 0) {
return JsonResult.error(ResubmitInspectionCodeEnum.SECTION_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.SECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success();
}

/**
*
* 构造Inspection对象
*
* @param userId
* @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());
}
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, user.getDeptId())
.eq(Dept::getMark, 1));
if (null == dept) {
return JsonResult.error(ResubmitInspectionCodeEnum.DEPT_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}
Inspection inspection = InspectionConverMapper.INSTANCE.fromEditInspectionRequestToInspection(request);
inspection.setId("");
inspection.setTenantId(tenantId);
inspection.setDeptId(dept.getId());
inspection.setCreateUser(userId);
inspection.setCreateTime(DateUtils.now());
inspection.setMobile(user.getMobile());
inspection.setStatus(InspectionStatusEnum.WAIT_FLIGHT.getCode()); // 重新提交,状态设置为等待飞行
return JsonResult.success(inspection);
}

/**
* 验证与第三方平台(飞手、dsp、高德)对接
* @param tenantId
* @param inspection
* @return
*/
private JsonResult callThirdPlatform(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());
}
return JsonResult.success();
}

/**
*
* 对接高德地图平台:将经纬度转换成巡逻地点
*
* @return
*/
private JsonResult callGaode(Inspection inspection) {
// 经纬度转换成巡逻地点
// 接口暂未调通,直接返回成功
// String patrolLocation = GaodeUtil.getGaodeAddress(inspection.getStartLongitude(), inspection.getStartLatitude());
// if (StringUtils.isEmpty(patrolLocation)) {
// return JsonResult.error(ResubmitInspectionCodeEnum.CALL_AMAP_IS_FAILED.getCode(), ResubmitInspectionCodeEnum.CALL_AMAP_IS_FAILED.getMsg());
// }
// inspection.setPatrolLocation(patrolLocation);
return JsonResult.success();
}

}

Loading…
Cancel
Save