Browse Source

任务列表接口功能

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
496c6ce9cb
11 changed files with 490 additions and 23 deletions
  1. +34
    -4
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/InspectionController.java
  2. +19
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/TenantController.java
  3. +11
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/TenantMapper.java
  4. +136
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/Tenant.java
  5. +8
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IInspectionService.java
  6. +11
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/ITenantService.java
  7. +17
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/ITenantServiceImpl.java
  8. +91
    -19
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java
  9. +109
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/AirPortVO.java
  10. +47
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/PlayBackInfoVo.java
  11. +7
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/TenantMapper.xml

+ 34
- 4
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/InspectionController.java View File

@@ -4,12 +4,11 @@ import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.entity.query.InspectionQuery;
import com.tuoheng.miniprogram.service.IInspectionService;
import com.tuoheng.miniprogram.vo.AirLineVO;
import com.tuoheng.miniprogram.vo.AirPortVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@@ -49,6 +48,37 @@ public class InspectionController {
return iInspectionService.airLine(droneId);
}

/**
* 获取巡检机场
*/
@GetMapping("/airport")
public List<AirPortVO> airport() {
return iInspectionService.airport();
}

/**
* 回放
* @param id
* @return
*/
@GetMapping("/playback/{id}")
public JsonResult playback(@PathVariable("id") String id){
return iInspectionService.playback(id);
}

/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/delete/{id}")
public JsonResult deleteById(@PathVariable("id") String id){
return iInspectionService.deleteById(id);
}








+ 19
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/TenantController.java View File

@@ -0,0 +1,19 @@
package com.tuoheng.miniprogram.controller;

import com.tuoheng.miniprogram.service.ITenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
@RestController
@RequestMapping("/tenant")
public class TenantController {

@Autowired
private ITenantService iTenantService;

}

+ 11
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/TenantMapper.java View File

@@ -0,0 +1,11 @@
package com.tuoheng.miniprogram.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.miniprogram.entity.Tenant;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
public interface TenantMapper extends BaseMapper<Tenant> {
}

+ 136
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/Tenant.java View File

@@ -0,0 +1,136 @@
package com.tuoheng.miniprogram.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.core.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
* <p>
* 企业管理表
* </p>
*
* @author 拓恒
* @since 2022-07-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("th_tenant")
public class Tenant extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 租户名称
*/
private String name;

/**
* 租户编号
*/
private String code;

/**
* 租户账号
*/
private String username;

/**
* 租户LOGO
*/
private String logo;

/**
* 上级ID
*/
private Integer pid;

/**
* 租户类型:1政府 2企业 3组织
*/
private Integer type;

/**
* 租户电话
*/
private String phone;

/**
* 租户邮箱
*/
private String email;

/**
* 省份编号
*/
private String provinceCode;

/**
* 省份名称
*/
private String provinceName;

/**
* 市区编号
*/
private String cityCode;

/**
* 市区名称
*/
private String cityName;

/**
* 区县编号
*/
private String districtCode;

/**
* 区县名称
*/
private String districtName;

/**
* 平台名称
*/
private String platformName;

/**
* 机场平台url
*/
private String airportUrl;

/**
* 详细地址
*/
private String address;

/**
* 租户简介
*/
private String intro;

/**
* 状态:1正常 2禁用
*/
private Integer status;

/**
* 备注
*/
private String note;

/**
* 排序号
*/
private Integer sort;
/**
* 租户头像url
*/
private String portraitUrl;

}

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

@@ -3,6 +3,7 @@ package com.tuoheng.miniprogram.service;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.entity.query.InspectionQuery;
import com.tuoheng.miniprogram.vo.AirLineVO;
import com.tuoheng.miniprogram.vo.AirPortVO;

import java.util.List;

@@ -14,4 +15,11 @@ public interface IInspectionService {
JsonResult index(InspectionQuery query);

List<AirLineVO> airLine(Integer droneId);

List<AirPortVO> airport();

JsonResult playback(String id);


JsonResult deleteById(String id);
}

+ 11
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/ITenantService.java View File

@@ -0,0 +1,11 @@
package com.tuoheng.miniprogram.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.tuoheng.miniprogram.entity.Tenant;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
public interface ITenantService extends IService<Tenant> {
}

+ 17
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/ITenantServiceImpl.java View File

@@ -0,0 +1,17 @@
package com.tuoheng.miniprogram.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.miniprogram.dao.TenantMapper;
import com.tuoheng.miniprogram.entity.Tenant;
import com.tuoheng.miniprogram.service.ITenantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
@Service
@Slf4j
public class ITenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> implements ITenantService {
}

+ 91
- 19
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java View File

@@ -1,38 +1,33 @@
package com.tuoheng.miniprogram.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.SecurityUserUtils;
import com.tuoheng.common.core.utils.StringUtils;
import com.tuoheng.miniprogram.dao.DeptMapper;
import com.tuoheng.miniprogram.dao.InspectionFileMapper;
import com.tuoheng.miniprogram.dao.InspectionMapper;
import com.tuoheng.miniprogram.dao.UserMapper;
import com.tuoheng.miniprogram.entity.Dept;
import com.tuoheng.miniprogram.entity.Inspection;
import com.tuoheng.miniprogram.entity.InspectionFile;
import com.tuoheng.miniprogram.entity.User;
import com.tuoheng.common.core.utils.*;
import com.tuoheng.miniprogram.dao.*;
import com.tuoheng.miniprogram.entity.*;
import com.tuoheng.miniprogram.entity.query.InspectionQuery;
import com.tuoheng.miniprogram.service.IInspectionService;
import com.tuoheng.miniprogram.utils.ShiroUtils;
import com.tuoheng.miniprogram.vo.AirLineVO;
import com.tuoheng.miniprogram.vo.AirPortVO;
import com.tuoheng.miniprogram.vo.InspectionInfoVo;
import com.tuoheng.miniprogram.vo.PlayBackInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

import java.util.*;
import java.util.stream.Collectors;

/**
@@ -55,6 +50,9 @@ public class InspectionServiceImpl implements IInspectionService {
@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private TenantMapper tenantMapper;

/**
* 任务列表(分页)
* @param query
@@ -98,6 +96,9 @@ public class InspectionServiceImpl implements IInspectionService {
query.setEndTimeDate(endTime);
// 根据部门id获取此部门id和所有下级部门id封装list集合
List<String> deptLists = deptMapper.selectAllChildListById(query.getDeptId());
if (StringUtils.isEmpty(deptLists)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}

List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>();

@@ -143,11 +144,82 @@ public class InspectionServiceImpl implements IInspectionService {

@Override
public List<AirLineVO> airLine(Integer droneId) {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(ShiroUtils.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
throw new ServiceException(ServiceExceptionEnum.GET_NO_TENANT);
}
if (StringUtils.isEmpty(tenant.getAirportUrl())) {
throw new ServiceException(ServiceExceptionEnum.GET_NO_TENANT);
}
String url = tenant.getAirportUrl() + "/api/airportInterface/taskByDroneId";
String param = "page=1&limit=100&droneId=" + droneId;
String airPortStr = HttpUtils.sendGet(url, param);
JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(Objects.requireNonNull(jsonResult).getData()) && jsonResult.getCode() != 0)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取航线信息失败,请重试");
}
return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirLineVO.class);

}

@Override
public List<AirPortVO> airport() {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(ShiroUtils.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
throw new ServiceException(ServiceExceptionEnum.GET_NO_TENANT);
}
if (StringUtils.isEmpty(tenant.getAirportUrl())) {
throw new ServiceException(ServiceExceptionEnum.GET_NO_TENANT);
}
String url = tenant.getAirportUrl() + "/api/airportInterface/airportList";
String param = "page=1&limit=10";
String airPortStr = HttpUtils.sendGet(url, param);
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取机场信息失败,请重试");
}
return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirPortVO.class);
}

@Override
public JsonResult playback(String id) {
//参数校验
if(StringUtils.isEmpty(id)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//根据任务id获取任务
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, 0)
.eq(Inspection::getMark, 1)
.eq(Inspection::getId, id));
PlayBackInfoVo vo = new PlayBackInfoVo();
BeanUtils.copyProperties(inspection,vo);
//对视频地址进行处理
if(StringUtils.isNotEmpty(inspection.getVideoUrl())){
vo.setVideoUrl(CommonConfig.videoURL+inspection.getVideoUrl());
}

return JsonResult.success(vo);
}

@Override
public JsonResult deleteById(String id) {
if (id == null || StringUtils.isEmpty(id)) {
return JsonResult.error("记录ID不能为空");
}
// 设置Mark=0
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, id));
inspection.setMark(0);
int count = inspectionMapper.updateById(inspection);
if(count<=0){
return JsonResult.error();
}

return JsonResult.success("删除成功");

return null;
}



+ 109
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/AirPortVO.java View File

@@ -0,0 +1,109 @@
package com.tuoheng.miniprogram.vo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* @User qiujinyang
* @Description
* @Date Created by 2022/7/28 13:31
*/
@NoArgsConstructor
@Data
public class AirPortVO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 机场id
*/
private Integer id;

/**
* 机场代码
*/
private String code;

/**
* 机场名称
*/
private String name;

/**
* 机场图片
*/
private String image;

/**
* 机场外部监控地址
*/
private String externalMonitorUrl;

/**
* 机场外部监控FLV地址
*/
private String flvExternalMonitorUrl;

/**
* 机场内部监控地址
*/
private String internalMonitorUrl;

/**
* 覆盖范围(km)
*/
private String coverage;

/**
* 排序
*/
private Integer sort;

/**
* 经度
*/
private String longitude;

/**
* 纬度
*/
private String latitude;

/**
* 无人机id
*/
private Integer droneId;

/**
* 无人机名称
*/
private String droneName;

/**
* 设备id
*/
private String edgeId;

/**
* 创建人
*/
private Integer createUser;

/**
* 创建时间
*/
private String createTime;

/**
* 修改人
*/
private Integer updateUser;

/**
* 修改时间
*/
private String updateTime;

}

+ 47
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/PlayBackInfoVo.java View File

@@ -0,0 +1,47 @@
package com.tuoheng.miniprogram.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
@Data
public class PlayBackInfoVo {

/**
* 任务执行时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date executionStartTime;

/**
* 任务名称
*/
private String name;

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

/**
* 巡检任务类型 1 临时巡检
*/
private Integer type;

/**
* 巡检路线名称
*/
private String inspectionLineName;

/**
* 原视频地址
*/
private String videoUrl;
}

+ 7
- 0
tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/TenantMapper.xml View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.miniprogram.dao.TenantMapper">

</mapper>

Loading…
Cancel
Save