Parcourir la source

添加是否通过硬件获取数据

tags/v1.1.0
qiujinyang il y a 2 ans
Parent
révision
4f357e18f9
11 fichiers modifiés avec 127 ajouts et 28 suppressions
  1. +3
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +36
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ParamController.java
  3. +4
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/CallbackRequest.java
  4. +4
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/MissionQuery.java
  5. +3
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/MissionRequest.java
  6. +3
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/MissionStatusRequest.java
  7. +26
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/PushAndPullURLRequest.java
  8. +5
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/TenantQuery.java
  9. +2
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IThInspectionService.java
  10. +0
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java
  11. +41
    -17
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java

+ 3
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java Voir le fichier

@@ -5,6 +5,7 @@ import com.tuoheng.admin.entity.domain.ThInspection;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.InspectionRequest;
import com.tuoheng.admin.entity.request.MissionStatusRequest;
import com.tuoheng.admin.entity.request.PushAndPullURLRequest;
import com.tuoheng.admin.entity.vo.InspectionVO;
import com.tuoheng.admin.service.IMissionService;
import com.tuoheng.admin.service.IThInspectionService;
@@ -83,8 +84,8 @@ public class InspectionController {
@PutMapping("/mission/{id}")
@ApiOperation(value = "立即执行", notes = "立即执行")
@ApiImplicitParam(name="id",value = "巡检的Id,飞行任务里面的id")
public JsonResult executeTask(@PathVariable("id") String id) {
return inspectionService.executeTask(id);
public JsonResult executeTask(@PathVariable("id") String id,@RequestBody PushAndPullURLRequest pushAndPull) {
return inspectionService.executeTask(id,pushAndPull);
}

/**

+ 36
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ParamController.java Voir le fichier

@@ -0,0 +1,36 @@
package com.tuoheng.admin.controller;

import cn.hutool.core.util.ObjectUtil;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.RedisUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/common")
@ApiOperation(value = "系统参数")
public class ParamController {


@Autowired
private RedisUtils redisUtils;


@PutMapping("/status")
@ApiOperation(value = "修改参数是否从硬件读取", notes = "修改参数是否从硬件读取")
public JsonResult<Boolean> commonParam() {
if(ObjectUtil.isEmpty(redisUtils.get("status"))){
redisUtils.set("status",1);
}else{
int status=(Integer) redisUtils.get("status");
status = status == 1 ? 2 : 1;
redisUtils.set("status",status);
}
boolean status = (Integer) redisUtils.get("status")==1?true:false;
return JsonResult.success(status);
}

}

+ 4
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/CallbackRequest.java Voir le fichier

@@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@@ -22,7 +23,9 @@ import java.util.List;
*/
@Data
@Accessors(chain = true)
public class CallbackRequest {
public class CallbackRequest implements Serializable {

private static final long serialVersionUID = 1L;
/**
* 分析状态
*/

+ 4
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/MissionQuery.java Voir le fichier

@@ -8,6 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
@@ -15,7 +16,9 @@ import java.util.Date;
* @author: qiujinyang
*/
@Data
public class MissionQuery extends BaseQuery {
public class MissionQuery extends BaseQuery implements Serializable {

private static final long serialVersionUID = 1L;

private Integer id;


+ 3
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/MissionRequest.java Voir le fichier

@@ -8,6 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
@@ -16,7 +17,8 @@ import java.util.Date;
* @date: 2021/9/7
*/
@Data
public class MissionRequest {
public class MissionRequest implements Serializable {

private static final long serialVersionUID = 1L;

private Integer id;

+ 3
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/MissionStatusRequest.java Voir le fichier

@@ -6,6 +6,7 @@ import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
@@ -14,7 +15,8 @@ import java.util.Date;
* @date: 2021/9/7
*/
@Data
public class MissionStatusRequest {
public class MissionStatusRequest implements Serializable {

private static final long serialVersionUID = 1L;

@NotNull(message = "巡检任务ID不能为空!")

+ 26
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/PushAndPullURLRequest.java Voir le fichier

@@ -0,0 +1,26 @@
package com.tuoheng.admin.entity.request;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
* 巡检任务 新增或修改请求参数
* @author: qiujinyang
* @date: 2021/9/7
*/
@Data
public class PushAndPullURLRequest implements Serializable {

private static final long serialVersionUID = 1L;

//@NotNull(message = "视频推流地址不能为空!")
@ApiModelProperty(value = "视频推流地址")
private String pushUrl;

//@NotNull(message = "视频拉流地址不能为空!")
@ApiModelProperty(value = "视频拉流地址")
private String pullUrl;
}

+ 5
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/TenantQuery.java Voir le fichier

@@ -3,11 +3,15 @@ package com.tuoheng.admin.entity.request;
import com.tuoheng.common.common.BaseQuery;
import lombok.Data;

import java.io.Serializable;

/**
* 租户查询条件
*/
@Data
public class TenantQuery extends BaseQuery {
public class TenantQuery extends BaseQuery implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 租户名称

+ 2
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IThInspectionService.java Voir le fichier

@@ -3,6 +3,7 @@ package com.tuoheng.admin.service;
import com.tuoheng.admin.entity.domain.ThInspection;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.InspectionRequest;
import com.tuoheng.admin.entity.request.PushAndPullURLRequest;
import com.tuoheng.admin.entity.vo.*;
import com.tuoheng.common.common.IBaseService;
import com.tuoheng.common.exception.ServiceException;
@@ -28,7 +29,7 @@ public interface IThInspectionService extends IBaseService<ThInspection> {

AirWeatherVO getWeather(Integer airportId);

JsonResult executeTask(String taskId) throws ServiceException;
JsonResult executeTask(String taskId,PushAndPullURLRequest pushAndPull) throws ServiceException;

JsonResult lineTrack(Integer missionId);
}

+ 0
- 3
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java Voir le fichier

@@ -63,9 +63,6 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
@Autowired
private ReportMapper reportMapper;

@Autowired
private RedisUtils redisUtils;

@Autowired
private IDspService dspService;


+ 41
- 17
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java Voir le fichier

@@ -8,12 +8,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.domain.ThInspection;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.InspectionRequest;
import com.tuoheng.admin.entity.request.MissionStatusRequest;
import com.tuoheng.admin.entity.request.PushAndPullURLRequest;
import com.tuoheng.admin.entity.vo.*;
import com.tuoheng.admin.enums.MarkTypeEnum;
import com.tuoheng.admin.enums.TaskStatusEnum;
import com.tuoheng.admin.enums.UpdateOrCreateEnum;
import com.tuoheng.admin.mapper.ThInspectionMapper;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.service.IMissionService;
import com.tuoheng.admin.service.IThInspectionService;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.config.CommonConfig;
@@ -21,6 +24,7 @@ import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.HttpUtils;
import com.tuoheng.common.utils.JacksonUtil;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.RedisUtils;
import com.tuoheng.system.utils.ShiroUtils;
import groovy.util.logging.Slf4j;
import org.apache.poi.ss.formula.functions.T;
@@ -51,6 +55,12 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
@Autowired
private ThMissionMapper missionMapper;

@Autowired
private RedisUtils redisUtils;

@Autowired
private IMissionService missionService;

@Override
public List<InspectionVO> track(Integer id) {

@@ -116,29 +126,43 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
}

@Override
public JsonResult executeTask(String taskId) throws ServiceException{
public JsonResult executeTask(String taskId,PushAndPullURLRequest pushAndPull) throws ServiceException{

ThMission thMission = missionMapper.selectById(taskId);
Assert.notNull(thMission,"任务不能为空!");
taskId=thMission.getInspectionLine().toString();
//这边需要配置到yml文件里面
String url = CommonConfig.airportUrl + "/api/airportInterface/executeTask";
JSONObject jsonObject=new JSONObject();
jsonObject.put("taskId",taskId);

String airPortStr = HttpUtils.doSend(url,jsonObject, null,"POST");
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if(ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(Objects.requireNonNull(jsonResult).getData()) && jsonResult.getCode() != 0)) {
assert jsonResult != null;
return JsonResult.error(JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("data").toString(), AirExecuteTaskVO.class),"执行任务失败!");
}else if(ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0){
return JsonResult.error(jsonResult.getMsg());
int status = (Integer)redisUtils.get("status");
//1:开,2:关
if(status==1) {
//这边需要配置到yml文件里面
String url = CommonConfig.airportUrl + "/api/airportInterface/executeTask";
JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", taskId);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(Objects.requireNonNull(jsonResult).getData()) && jsonResult.getCode() != 0)) {
assert jsonResult != null;
return JsonResult.error(JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("data").toString(), AirExecuteTaskVO.class), "执行任务失败!");
} else if (ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0) {
return JsonResult.error(jsonResult.getMsg());
} else {
//修改执行时间为当前
thMission.setExecutionStartTime(new Date());
missionMapper.updateById(thMission);
//返回执行结果
return JsonResult.success(jsonResult.getMsg());
}
}else{
//修改执行时间为当前
thMission.setExecutionStartTime(new Date());
missionMapper.updateById(thMission);
//返回执行结果
return JsonResult.success(jsonResult.getMsg());
MissionStatusRequest missionStatusRequest=new MissionStatusRequest();
missionStatusRequest.setId(thMission.getInspectionLine());
missionStatusRequest.setPushUrl(pushAndPull.getPushUrl());
missionStatusRequest.setPullUrl(pushAndPull.getPullUrl());
missionStatusRequest.setStatus(1);
//修改任务状态,任务开始飞行
boolean b = missionService.updateStatus(missionStatusRequest);
return JsonResult.success(thMission.getInspectionLine());
}
}


Chargement…
Annuler
Enregistrer