Bläddra i källkod

宁乡大屏 测试流速分页查询

airCurrent20210430
chenlu 6 månader sedan
förälder
incheckning
d314dcb2d0
20 ändrade filer med 1196 tillägg och 144 borttagningar
  1. +5
    -0
      pom.xml
  2. +4
    -0
      src/main/java/com/tuoheng/airportGzdp/common/BaseController.java
  3. +62
    -0
      src/main/java/com/tuoheng/airportGzdp/common/BaseEntity.java
  4. +19
    -0
      src/main/java/com/tuoheng/airportGzdp/common/BaseQuery.java
  5. +38
    -0
      src/main/java/com/tuoheng/airportGzdp/common/BaseResponse.java
  6. +187
    -0
      src/main/java/com/tuoheng/airportGzdp/common/BaseServiceImpl.java
  7. +99
    -0
      src/main/java/com/tuoheng/airportGzdp/common/IBaseService.java
  8. +49
    -0
      src/main/java/com/tuoheng/airportGzdp/constant/Constant.java
  9. +10
    -5
      src/main/java/com/tuoheng/airportGzdp/controller/AirCurrentController.java
  10. +46
    -42
      src/main/java/com/tuoheng/airportGzdp/entity/AirCurrent.java
  11. +131
    -0
      src/main/java/com/tuoheng/airportGzdp/entity/InspectionRecord.java
  12. +4
    -0
      src/main/java/com/tuoheng/airportGzdp/mapper/AirCurrentMapper.java
  13. +16
    -0
      src/main/java/com/tuoheng/airportGzdp/mapper/InspectionRecordMapper.java
  14. +6
    -0
      src/main/java/com/tuoheng/airportGzdp/service/AirCurrentService.java
  15. +21
    -0
      src/main/java/com/tuoheng/airportGzdp/service/IInspectionRecordService.java
  16. +138
    -9
      src/main/java/com/tuoheng/airportGzdp/service/impl/AirCurrentServiceImpl.java
  17. +51
    -0
      src/main/java/com/tuoheng/airportGzdp/service/impl/InspectionRecordServiceImpl.java
  18. +299
    -0
      src/main/java/com/tuoheng/airportGzdp/until/DateUtils.java
  19. +3
    -12
      src/main/java/com/tuoheng/airportGzdp/vo/AirCurrentDto.java
  20. +8
    -76
      src/main/java/com/tuoheng/airportGzdp/vo/AirCurrentVo.java

+ 5
- 0
pom.xml Visa fil

@@ -66,6 +66,11 @@
<artifactId>hutool-log</artifactId>
<version>5.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<!-- Redis 起始依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>

+ 4
- 0
src/main/java/com/tuoheng/airportGzdp/common/BaseController.java Visa fil

@@ -0,0 +1,4 @@
package com.tuoheng.airportGzdp.common;

public class BaseController {
}

+ 62
- 0
src/main/java/com/tuoheng/airportGzdp/common/BaseEntity.java Visa fil

@@ -0,0 +1,62 @@
package com.tuoheng.airportGzdp.common;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
* 基类实体对象
*
* @author 牧羊人
* @date 2019/11/28
*/
@Data
public class BaseEntity implements Serializable {

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
// @TableField(fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
// @TableField(fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;
/**
* 租户id
*/
private Integer tenantId;

}

+ 19
- 0
src/main/java/com/tuoheng/airportGzdp/common/BaseQuery.java Visa fil

@@ -0,0 +1,19 @@
package com.tuoheng.airportGzdp.common;

import lombok.Data;

/**
* 查询对象基类
*/
@Data
public class BaseQuery {
/**
* 页码
*/
private Integer page;

/**
* 每页数
*/
private Integer limit;
}

+ 38
- 0
src/main/java/com/tuoheng/airportGzdp/common/BaseResponse.java Visa fil

@@ -0,0 +1,38 @@
package com.tuoheng.airportGzdp.common;


import com.tuoheng.airportGzdp.constant.Constant;
import lombok.Data;
import lombok.experimental.Accessors;

/**
* 结果集
*
* @author zhu_zishuang
* @date 2021-03-12
*/
@Data
@Accessors(chain = true)
public class BaseResponse<T> {

/**
* success:成功,fail:业务返回的失败,error:非业务异常失败
*/
private String status = Constant.SUCCESS;

/**
* 状态码
**/
private Integer code;

/**
* 结果描述
**/
private String message;

/**
* 结果数据
**/
private T data;
}


+ 187
- 0
src/main/java/com/tuoheng/airportGzdp/common/BaseServiceImpl.java Visa fil

@@ -0,0 +1,187 @@
package com.tuoheng.airportGzdp.common;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.airportGzdp.until.DateUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.List;

public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> extends ServiceImpl<M, T> implements IBaseService<T> {

/**
* 根据查询条件获取数据列表
*
* @param query 查询条件
* @return
*/
@Override
public JsonResult getList(BaseQuery query) {
return null;
}

/**
* 根据ID获取记录信息
*
* @param id 记录ID
* @return
*/
@Override
public JsonResult info(Integer id) {
if (id == null && id <= 0) {
return JsonResult.error("记录ID不能为空");
}
Object result = this.getInfo(id);
return JsonResult.success(result);
}

/**
* 根据ID获取记录信息
*
* @param id 记录ID
* @return
*/
@Override
public Object getInfo(Serializable id) {
T entity = this.getById(id);
return entity;
}

/**
* 传入实体对象添加记录
*
* @param entity 实体对象
* @return
*/
@Override
public JsonResult add(T entity) {
entity.setCreateTime(DateUtils.now());
entity.setMark(1);
boolean result = this.save(entity);
if (!result) {
return JsonResult.error();
}
return JsonResult.success();
}

/**
* 传入实体对象更新记录
*
* @param entity 实体对象
* @return
*/
@Override
public JsonResult update(T entity) {
entity.setUpdateTime(DateUtils.now());
boolean result = this.updateById(entity);
if (!result) {
return JsonResult.error();
}
return JsonResult.success();
}

/**
* 根据实体对象添加、编辑记录
*
* @param entity 实体对象
* @return
*/
@Override
public JsonResult edit(T entity) {
if (entity == null) {
return JsonResult.error("实体对象不存在");
}
if (entity.getId() != null && entity.getId() > 0) {
// 修改记录
return this.update(entity);
} else {
// 新增记录
return this.add(entity);
}
}

/**
* 删除记录
*
* @param entity 实体对象
* @return
*/
@Override
public JsonResult delete(T entity) {
entity.setUpdateTime(DateUtils.now());
entity.setMark(0);
boolean result = this.updateById(entity);
if (!result) {
return JsonResult.error();
}
return JsonResult.success("删除成功");
}

/**
* 根据ID删除记录
*
* @param id 记录ID
* @return
*/
@Override
public JsonResult deleteById(Integer id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error("记录ID不能为空");
}
// 设置Mark=0
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.set("mark", 0);
updateWrapper.eq("id", id);
boolean result = update(updateWrapper);
if (!result) {
return JsonResult.error();
}
return JsonResult.success("删除成功");
}

/**
* 根据ID删除记录
*
* @param ids 记录ID
* @return
*/
@Override
public JsonResult deleteByIds(Integer[] ids) {
if (StringUtils.isEmpty(ids)) {
return JsonResult.error("记录ID不能为空");
}
// String[] item = ids.split(",");
// 设置Mark=0
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.set("mark", 0);
updateWrapper.in("id", ids);
boolean result = update(updateWrapper);
if (!result) {
return JsonResult.error();
}
return JsonResult.success();
}

/**
* 设置状态
*
* @param entity 实体对象
* @return
*/
@Override
public JsonResult setStatus(T entity) {
return this.update(entity);
}

/**
* 导出Excel
*
* @return
*/
@Override
public List<T> exportExcel() {
return null;
}
}

+ 99
- 0
src/main/java/com/tuoheng/airportGzdp/common/IBaseService.java Visa fil

@@ -0,0 +1,99 @@
package com.tuoheng.airportGzdp.common;

import com.baomidou.mybatisplus.extension.service.IService;

import java.io.Serializable;
import java.util.List;


public interface IBaseService<T> extends IService<T> {

/**
* 根据查询条件获取数据列表
*
* @param query 查询条件
* @return
*/
JsonResult getList(BaseQuery query);

/**
* 根据ID获取记录信息
*
* @param id 记录ID
* @return
*/
JsonResult info(Integer id);

/**
* 根据ID获取记录信息
*
* @param id 记录ID
* @return
*/

Object getInfo(Serializable id);

/**
* 根据实体对象添加记录
*
* @param entity 实体对象
* @return
*/
JsonResult add(T entity);

/**
* 根据实体对象更新记录
*
* @param entity 实体对象
* @return
*/
JsonResult update(T entity);

/**
* 根据实体对象添加、编辑记录
*
* @param entity 实体对象
* @return
*/
JsonResult edit(T entity);

/**
* 删除记录
*
* @param entity 实体对象
* @return
*/
JsonResult delete(T entity);

/**
* 根据ID删除记录
*
* @param id 记录ID
* @return
*/
JsonResult deleteById(Integer id);

/**
* 根据ID删除记录
*
* @param ids 记录ID
* @return
*/
JsonResult deleteByIds(Integer[] ids);

/**
* 设置状态
*
* @param entity 实体对象
* @return
*/
JsonResult setStatus(T entity);

/**
* 导出Excel
*
* @return
*/
List<T> exportExcel();

}

+ 49
- 0
src/main/java/com/tuoheng/airportGzdp/constant/Constant.java Visa fil

@@ -0,0 +1,49 @@
package com.tuoheng.airportGzdp.constant;

/**
* 常量类
*
* @author: zhu_zishuang
* @date: 2020-04-22 14:22
*/
public final class Constant {
/**
* 构造器私有化
*/
private Constant() {
// 可抛出异常,防止通过反射实例化对象
}

/**
* 返回结果 success:成功,fail:业务返回的失败,error:非业务异常失败
*/
public static final String SUCCESS = "success";
public static final String FAIL = "fail";
public static final String ERROR = "error";

/**
* 常用数值
*/
public static final Integer ONE = 1;
public static final Long MAX_PAGE_SIZE = 100_000L;


/**
* 常用字符
*/
public static final String SPLIT_CLASS = " ";
public static final String LOG_INFO_PREFIX = "登录异常,异常信息:{}";

/**
* 是否
*/
public static final Byte YES = 1;
public static final Byte NO = 0;
public static final Integer YES_INT = 1;


/**
* 平台管理员
*/
public static final String ADMIN = "admin";
}

+ 10
- 5
src/main/java/com/tuoheng/airportGzdp/controller/AirCurrentController.java Visa fil

@@ -4,15 +4,14 @@ package com.tuoheng.airportGzdp.controller;
import com.tuoheng.airportGzdp.common.JsonResult;
import com.tuoheng.airportGzdp.service.AirCurrentService;
import com.tuoheng.airportGzdp.vo.AirCurrentDto;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tuoheng.airportGzdp.vo.AirCurrentVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/airCurrent")
@RequestMapping("/data")
public class AirCurrentController {

@Resource
@@ -28,4 +27,10 @@ public class AirCurrentController {
return airCurrentService.getAirCurrentPage(dto);
}

@PostMapping("/upload")
public Map getAirCurrent(@RequestBody String json){
return airCurrentService.getAirCurrent(json);
}


}

+ 46
- 42
src/main/java/com/tuoheng/airportGzdp/entity/AirCurrent.java Visa fil

@@ -2,15 +2,13 @@ package com.tuoheng.airportGzdp.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.airportGzdp.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* <p>
@@ -24,14 +22,14 @@ import java.util.Map;
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("th_airCurrent")
public class AirCurrent {
public class AirCurrent extends BaseEntity {

private static final long serialVersionUID = 1L;

/**
* 测流数据表 主键id
*/
private int id;
// /**
// * 测流数据表 主键id
// */
// private int id;

/**
* 飞行任务记录id
@@ -48,6 +46,12 @@ public class AirCurrent {
*/
private Integer airlineFileId;

/**
* 航线文件id 名称
*/
@TableField(exist = false)
private String airlineFileName;

/**
* 数据采集时间
*/
@@ -66,7 +70,7 @@ public class AirCurrent {
/**
* 数据包流水号
*/
private String serial;
private Integer serial;

/**
* 总瞬时流量
@@ -88,39 +92,39 @@ public class AirCurrent {
*/
private String vvx;

/**
* 添加人
*/
private Integer createUser;
/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* 更新人
*/
private Integer updateUser;
/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
/**
* 有效标识
*/
private Integer mark;
/**
* 航线文件id
*/
private Integer tenantId;
// /**
// * 添加人
// */
// private Integer createUser;
//
// /**
// * 创建时间
// */
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
// private Date createTime;
//
// /**
// * 更新人
// */
// private Integer updateUser;
//
// /**
// * 更新时间
// */
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
// private Date updateTime;
//
// /**
// * 有效标识
// */
// private Integer mark;
//
// /**
// * 航线文件id
// */
// private Integer tenantId;


/**

+ 131
- 0
src/main/java/com/tuoheng/airportGzdp/entity/InspectionRecord.java Visa fil

@@ -0,0 +1,131 @@
package com.tuoheng.airportGzdp.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 lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* <p>
* 飞行任务记录表
* </p>
*
* @author 拓恒
* @since 2021-10-15
*/
@Data
@Accessors(chain = true)
@TableName("th_inspection_record")
public class InspectionRecord {

private static final long serialVersionUID = 1L;

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

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

/**
* 执飞无人机ID
*/
private Integer droneId;

/**
* 航线文件ID
*/
private Integer airlineFileId;


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

/**
* 任务状态:1待执行 2执行中
*/
private Integer status;

//任务来源
private String taskSource;
//任务类型
private int type;

//任务来源名称
private String taskSourceName;

//所属任务id
private int taskId;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;

private int aid;

private String aname;
/**
* 飞行距离
*/
private Double distance;

/**
* 飞行时长min
*/
private String flytime;

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
// @TableField(fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
// @TableField(fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;
/**
* 租户id
*/
private Integer tenantId;
}

+ 4
- 0
src/main/java/com/tuoheng/airportGzdp/mapper/AirCurrentMapper.java Visa fil

@@ -3,6 +3,9 @@ package com.tuoheng.airportGzdp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.airportGzdp.entity.AirCurrent;
import com.tuoheng.airportGzdp.vo.AirCurrentDto;

import java.util.List;

/**
* <p>
@@ -14,4 +17,5 @@ import com.tuoheng.airportGzdp.entity.AirCurrent;
*/
public interface AirCurrentMapper extends BaseMapper<AirCurrent> {

List page(AirCurrentDto dto);
}

+ 16
- 0
src/main/java/com/tuoheng/airportGzdp/mapper/InspectionRecordMapper.java Visa fil

@@ -0,0 +1,16 @@
package com.tuoheng.airportGzdp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.airportGzdp.entity.InspectionRecord;

/**
* <p>
* 飞行任务记录表 Mapper 接口
* </p>
*
* @author 拓恒
* @since 2023-4-15
*/
public interface InspectionRecordMapper extends BaseMapper<InspectionRecord> {

}

+ 6
- 0
src/main/java/com/tuoheng/airportGzdp/service/AirCurrentService.java Visa fil

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.tuoheng.airportGzdp.common.JsonResult;
import com.tuoheng.airportGzdp.entity.AirCurrent;
import com.tuoheng.airportGzdp.vo.AirCurrentDto;
import com.tuoheng.airportGzdp.vo.AirCurrentVo;

import java.util.Map;

public interface AirCurrentService extends IService<AirCurrent> {

@@ -13,4 +16,7 @@ public interface AirCurrentService extends IService<AirCurrent> {
* @return
*/
JsonResult getAirCurrentPage(AirCurrentDto dto);


Map getAirCurrent(String json);
}

+ 21
- 0
src/main/java/com/tuoheng/airportGzdp/service/IInspectionRecordService.java Visa fil

@@ -0,0 +1,21 @@
package com.tuoheng.airportGzdp.service;


import com.tuoheng.airportGzdp.entity.InspectionRecord;

import java.util.List;

/**
* <p>
* 飞行任务记录表 服务类
* </p>
*
* @author 拓恒
* @since 2023-4-15
*/
public interface IInspectionRecordService {

//查询最近一条的数据
List<InspectionRecord> getFirstRecord();

}

+ 138
- 9
src/main/java/com/tuoheng/airportGzdp/service/impl/AirCurrentServiceImpl.java Visa fil

@@ -4,21 +4,26 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tuoheng.airportGzdp.common.BaseServiceImpl;
import com.tuoheng.airportGzdp.common.JsonResult;
import com.tuoheng.airportGzdp.entity.AirCurrent;
import com.tuoheng.airportGzdp.entity.AirlineData;
import com.tuoheng.airportGzdp.entity.AirlineFile;
import com.tuoheng.airportGzdp.entity.InspectionRecord;
import com.tuoheng.airportGzdp.mapper.AirCurrentMapper;
import com.tuoheng.airportGzdp.service.AirCurrentService;
import com.tuoheng.airportGzdp.vo.AirCurrentDto;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import javax.management.Query;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;


/**
@@ -31,11 +36,17 @@ import java.util.*;
*/
@Service
@Slf4j
public class AirCurrentServiceImpl extends ServiceImpl<AirCurrentMapper, AirCurrent> implements AirCurrentService {
public class AirCurrentServiceImpl extends BaseServiceImpl<AirCurrentMapper, AirCurrent> implements AirCurrentService {

@Resource
private AirCurrentMapper airCurrentMapper;

@Resource
private AirlineFileServiceImpl airlineFileServiceImpl;

@Resource
private InspectionRecordServiceImpl iInspectionRecordService;

/**
* 查询 流量测速 分页数据
* @param dto
@@ -48,16 +59,36 @@ public class AirCurrentServiceImpl extends ServiceImpl<AirCurrentMapper, AirCurr
return JsonResult.error("开始日期和节数日期为必填项!");
}
//查询数据
//条件查询总数
Integer sumNum = dto.getLimit();
//计算从N开始
Integer pageIndex = (dto.getPage() - 1) * dto.getLimit();
QueryWrapper<AirCurrent> queryWrapper = new QueryWrapper<>();
queryWrapper.ge("air_fly_time", dto.getStartTime());
queryWrapper.le("air_fly_time", dto.getEndTime());
queryWrapper.eq("mark", 1);
queryWrapper.last("LIMIT " + pageIndex + "," + dto.getLimit());
IPage<AirCurrent> page = new Page<>(dto.getPage(), dto.getLimit());
LambdaQueryWrapper<AirCurrent> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ge(AirCurrent::getAirFlyTime, dto.getStartTime());
queryWrapper.le(AirCurrent::getAirFlyTime, dto.getEndTime());
queryWrapper.eq(AirCurrent::getMark, 1);
IPage<AirCurrent> airCurrentIPage = airCurrentMapper.selectPage(page, queryWrapper);
IPage<AirCurrent> airCurrentIPage = page(page, queryWrapper);
//处理流速度的数据
if (!CollectionUtils.isEmpty(airCurrentIPage.getRecords())){
List<AirCurrent> records = airCurrentIPage.getRecords();
airCurrentIPage.setTotal(records.size());
//查询航线名称
Map<Integer, AirlineFile> lineIdMap = new HashMap<>();
List<Integer> airlineFileIdList =
records.stream().map(o -> o.getAirlineFileId()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(airlineFileIdList)){
LambdaQueryWrapper<AirlineFile> airlineFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
airlineFileLambdaQueryWrapper.in(AirlineFile:: getId ,airlineFileIdList);
List<AirlineFile> list = airlineFileServiceImpl.list(airlineFileLambdaQueryWrapper);
lineIdMap = list.stream().collect(Collectors.toMap(AirlineFile::getId, a -> a));
}
Map<Integer, AirlineFile> finalLineIdMap = lineIdMap;
records.forEach(item->{
if (Objects.nonNull(finalLineIdMap) & Objects.nonNull(finalLineIdMap.get(item.getAirlineFileId()))){
item.setAirlineFileName( finalLineIdMap.get(item.getAirlineFileId()).getFileName() );
}
String vvx = item.getVvx();
String[] split = vvx.split(",");
LinkedHashMap<String,String> map = new LinkedHashMap<>();
@@ -72,4 +103,102 @@ public class AirCurrentServiceImpl extends ServiceImpl<AirCurrentMapper, AirCurr
}
return JsonResult.success(airCurrentIPage);
}


/**
* 硬件回传数据
* @param json
* @return
*/
@Override
public Map getAirCurrent(String json){
//Gson gson = new Gson();
if (Objects.isNull(json)){
String msg = "传输的json数据为空:" + json;
log.info(msg);
}
//json转化为 对象
AirCurrent airCurrent = new AirCurrent();
//处理 每个时间段的数据
VVX(json, airCurrent);
//去查询最近的一条任务记录 取任务id 机场id 航线id
List<InspectionRecord> inspectionRecordList = iInspectionRecordService.getFirstRecord();
if (!CollectionUtils.isEmpty(inspectionRecordList)){
InspectionRecord inspectionRecord = inspectionRecordList.get(0);
//飞行记录id
airCurrent.setInspectionRecordId(inspectionRecord.getId());
//机场id
airCurrent.setAirportId(inspectionRecord.getAid());
//航线id
airCurrent.setAirlineFileId(inspectionRecord.getAirlineFileId());
}
int insert = airCurrentMapper.insert(airCurrent);

//返回第三方平台 数据已接受
Map<String, Object> map = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = sdf.format(new Date());
map.put("TM", format);
map.put("ST", airCurrent.getSt());
map.put("ST", airCurrent.getSt());
map.put("MARK", 1);
map.put("SERIAL", airCurrent.getSerial());
return map;
}


@SneakyThrows
private void VVX(String json,AirCurrent airCurrent) {
//处理各个时间段的 流速
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(json);
//数据采集时间
String airFlyTimeString = jsonNode.get("TT").asText();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
airCurrent.setAirFlyTime( dateFormat.parse(airFlyTimeString) );
} catch (ParseException e) {
log.info("时间类型转化异常:" + airFlyTimeString);
throw new RuntimeException(e);
}
//测站唯一编码 用于区分不同测站
String st = Objects.isNull(jsonNode.get("ST")) ? null : jsonNode.get("ST").asText();
airCurrent.setSt(st);
//测站类型
String type = Objects.isNull(jsonNode.get("TYPE")) ? null : jsonNode.get("TYPE").asText();
airCurrent.setType(type);
//数据包流水号
Integer serial = Objects.isNull(jsonNode.get("SERIAL")) ? null : jsonNode.get("SERIAL").asInt();
airCurrent.setSerial(serial);
//总瞬时流量
Double q1 = Objects.isNull(jsonNode.get("Q1")) ? null : jsonNode.get("Q1").asDouble();
airCurrent.setQ1(q1);
//断面平均流速
Double v1 = Objects.isNull(jsonNode.get("V1")) ? null : jsonNode.get("V1").asDouble();
airCurrent.setV1(v1);
//垂线数量
Integer VCNT = Objects.isNull(jsonNode.get("VCNT")) ? null : jsonNode.get("VCNT").asInt();
airCurrent.setVcnt(VCNT);
if(null == VCNT || VCNT <= 0){
String msg = "传输的垂线数量 数据为空:" + VCNT;
log.info(msg);
}else {
//处理流速的数据 硬件给过来的格式是 VV01~VV20
for (int i = 1; i <= VCNT; i++) {
String num = "VV" + String.valueOf(i);
if (i<10){
num = "VV" + "0" + i;
}
//判空 空说声
String aDouble = Objects.isNull(jsonNode.get(num)) ? null : jsonNode.get(num).asText();
if (Objects.isNull(airCurrent.getVvx())){
airCurrent.setVvx(num + ":" + aDouble + ",");
}else {
airCurrent.setVvx(airCurrent.getVvx() + num + ":" + aDouble + ",");
}
}
}
}


}

+ 51
- 0
src/main/java/com/tuoheng/airportGzdp/service/impl/InspectionRecordServiceImpl.java Visa fil

@@ -0,0 +1,51 @@
package com.tuoheng.airportGzdp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.airportGzdp.entity.InspectionRecord;
import com.tuoheng.airportGzdp.mapper.InspectionRecordMapper;
import com.tuoheng.airportGzdp.service.IInspectionRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.index.PathBasedRedisIndexDefinition;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;


/**
* <p>
* 飞行任务表 服务实现类
* </p>
*
* @author 拓恒
* @since 2021-10-15
*/
@Service
@Slf4j
public class InspectionRecordServiceImpl implements IInspectionRecordService {


@Resource
private InspectionRecordMapper inspectionRecordMapper;

/**
*
* @return
*/
@Override
public List<InspectionRecord> getFirstRecord() {
//查询最新一条的数据 且不是任务失败的
QueryWrapper<InspectionRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mark", 1);
queryWrapper.orderByDesc("create_time");
queryWrapper.last("limit 1");
// 分页查询
IPage<InspectionRecord> page = new Page<>(1, 1);
IPage<InspectionRecord> pageData = inspectionRecordMapper.selectPage(page, queryWrapper);
return pageData.getRecords();
}


}

+ 299
- 0
src/main/java/com/tuoheng/airportGzdp/until/DateUtils.java Visa fil

@@ -0,0 +1,299 @@
package com.tuoheng.airportGzdp.until;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
* 时间工具类
*/
public final class DateUtils extends org.apache.commons.lang3.time.DateUtils {

public static String YYYY = "yyyy";

public static String YYYY_MM = "yyyy-MM";

public static String YYYY_MM_DD = "yyyy-MM-dd";

public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

public static String HHMMSS = "HH:mm:ss";

public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};


/**
* 获取当前时间
*
* @return
*/
public static Date now() {
return new Date();
}

/**
* 获取当前日期, 默认格式为yyyy-MM-dd
*
* @return String
*/
public static String getDate() {
return dateTimeNow(YYYY_MM_DD);
}

public static final String getTime() {
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
}

public static final String dateTimeNow() {
return dateTimeNow(YYYYMMDDHHMMSS);
}

public static final String dateTimeNow(final String format) {
return parseDateToStr(format, new Date());
}

public static final String dateTime(final Date date) {
return parseDateToStr(YYYY_MM_DD, date);
}

public static final String parseDateToStr(final String format, final Date date) {
return new SimpleDateFormat(format).format(date);
}

public static final Date dateTime(final String format, final String ts) {
try {
return new SimpleDateFormat(format).parse(ts);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}

/**
* 日期路径 即年/月/日 如2018/08/08
*/
public static final String datePath() {
Date now = new Date();
return DateFormatUtils.format(now, "yyyy/MM/dd");
}

/**
* 日期路径 即年/月/日 如20180808
*/
public static final String dateTime() {
Date now = new Date();
return DateFormatUtils.format(now, "yyyyMMdd");
}

/**
* 日期型字符串转化为日期 格式
*/
public static Date parseDate(Object str) {
if (str == null) {
return null;
}
try {
return parseDate(str.toString(), parsePatterns);
} catch (ParseException e) {
return null;
}
}

/**
* 获取服务器启动时间
*/
public static Date getServerStartDate() {
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
return new Date(time);
}

/**
* 计算两个时间差
*/
public static String getDatePoor(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟";
}

/**
* 返回java.util.Date
* <p>
* 给原本的时间originDate加上自定义的时间
*
* @param originDate 原本的时间
* @param day 要加的天数
* @param hour 要加的小时数
* @param minute 要加的分钟数
* @param second 要加的秒数
* @return 返回加完时间后的时间goalDate
*/
public static Date addDateTimeToDate(Date originDate, int day, int hour, int minute, int second) {
Calendar cal = Calendar.getInstance();
cal.setTime(originDate);
cal.add(Calendar.DATE, day);// 24小时制,加天
cal.add(Calendar.HOUR, hour);// 24小时制 ,加小时
cal.add(Calendar.MINUTE, minute);// 24小时制,加分钟
cal.add(Calendar.SECOND, second);// 24小时制,加秒

Date goalDate = cal.getTime();
return goalDate;
}

/**
* 计算下一个循环周期
*
* @param beginDate 开始日期:格式yyyy-MM-dd HH:mm:ss
* @param cycleType 周期类型0-每周 1-每月
* @param cycleDate 循环日期:如果周期类型是每周,那么循环日期日期值范围为:1-7,如果周期类型为每月,那么周期日期值范围为:1-31
* @return
* @throws ParseException
*/
public static String getNextCycleDay(String beginDate, String cycleType, String cycleDate) throws ParseException {
if (StringUtils.isNotEmpty(cycleType) && "0".equals(cycleType)) {
if (StringUtils.isNotEmpty(cycleDate) && (Integer.valueOf(cycleDate) < 0 || Integer.valueOf(cycleDate) > 7)) {
throw new RuntimeException("循环周期类型为周,循环日期只能再1~7范围内!");
}
} else if (StringUtils.isNotEmpty(cycleType) && "1".equals(cycleType)) {
if (StringUtils.isNotEmpty(cycleDate) && (Integer.valueOf(cycleDate) < 0 || Integer.valueOf(cycleDate) > 31)) {
throw new RuntimeException("循环周期类型为月,循环日期只能再1~31范围内!");
}
}

Date dateBegin = DateUtils.parseDate(beginDate, YYYY_MM_DD_HH_MM_SS);
String beginDateTime = DateUtils.parseDateToStr(HHMMSS, dateBegin);//开始时间点
String nowDateTime = DateUtils.parseDateToStr(HHMMSS, DateUtils.now());//现在时间点
String nextDate = "";//下一个日期
Date date = null;

String today = DateUtils.getDate();//获取今天的日期
//开始日期大于当前,取开始日期进行比较,否则取当天进行比较
if (beginDate.compareTo(today) > 0) {
date = DateUtils.parseDate(beginDate, YYYY_MM_DD_HH_MM_SS);
} else {
date = new Date();
}
if ("0".equals(cycleType)) {
//每周
//如果指定周几大于今天所属的周几,则取本周的周几
//如果指定周几小于今天所属的周几,则取下个周的周几
Calendar cal = Calendar.getInstance(Locale.CHINA);
cal.setTime(date);
cal.setFirstDayOfWeek(Calendar.MONDAY);//将每周第一天设为星期一,默认是星期天
int week = cal.get(Calendar.DAY_OF_WEEK) - 1;//获取指定日期的周几
if (week == 0) week = 7;
if (Integer.valueOf(cycleDate) > week) {//如果指定的周几大于等于当前周几,取本周的周几
cal.set(Calendar.DAY_OF_WEEK, Integer.valueOf(cycleDate) + 1);//星期
//如果指定的周几等于当前周几且时间点也大于当前时间点,取本周的周几
}else if (Integer.valueOf(cycleDate) == week && DateUtils.parseDate(beginDateTime, HHMMSS).after(DateUtils.parseDate(nowDateTime, HHMMSS))) {
cal.set(Calendar.DAY_OF_WEEK, Integer.valueOf(cycleDate) + 1);//星期
}else {
cal.add(Calendar.WEEK_OF_MONTH, 1);//周数加1,即下周
cal.set(Calendar.DAY_OF_WEEK, Integer.valueOf(cycleDate) + 1);//星期
}
nextDate = DateUtils.parseDateToStr(YYYY_MM_DD, cal.getTime());
} else if ("1".equals(cycleType)) {
//每月
if (cycleDate.length() == 1) {
cycleDate = "0" + cycleDate;
}
//如果指定每月几号大于今天所属几号,则取本月的几号
if (Integer.valueOf(cycleDate) > Integer.valueOf(DateUtils.parseDateToStr("dd", date))) {
while (true) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
//如果当月最大天数小于指定的每月几号,则取下一个月的几号,直到找到对应月数有对应的几号为止
if (cal.getActualMaximum(Calendar.DATE) < Integer.valueOf(cycleDate)) {
date = DateUtils.getLastMonthDate(DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, date), 1);
} else {
break;
}
}
nextDate = DateUtils.parseDateToStr("yyyy-MM", date) + "-" + cycleDate;
//如果指定每月几号等于今天所属几号且时间点也大于当前时间点,则取本月的几号
} else if (Integer.valueOf(cycleDate) == Integer.valueOf(DateUtils.parseDateToStr("dd", date)) &&
DateUtils.parseDate(beginDateTime, HHMMSS).after(DateUtils.parseDate(nowDateTime, HHMMSS))) {
while (true) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
//如果当月最大天数小于指定的每月几号,则取下一个月的几号,直到找到对应月数有对应的几号为止
if (cal.getActualMaximum(Calendar.DATE) < Integer.valueOf(cycleDate)) {
date = DateUtils.getLastMonthDate(DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, date), 1);
} else {
break;
}
}
nextDate = DateUtils.parseDateToStr("yyyy-MM", date) + "-" + cycleDate;

}else {//如果指定每月几号小于今天所属几号,则取下个月的几号
Date lastMonthDate = DateUtils.getLastMonthDate(DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, date), 1);
nextDate = DateUtils.parseDateToStr("yyyy-MM", lastMonthDate) + "-" + cycleDate;
}
}

return nextDate + " " + beginDateTime;
}

/**
* 指定日期字符串加/减指定月数
* @param dataTime
* @param months
* @return
* @throws ParseException
*/
public static Date getLastMonthDate(String dataTime,int months) throws ParseException {
//时间字符串转 LocalDate 类型
LocalDate today = LocalDate.parse(dataTime, DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS));
//当前月份+(-1)
today = today.plusMonths(months);
Instant instant = today.atTime(LocalTime.MIDNIGHT).atZone(ZoneId.systemDefault()).toInstant();
Date date = Date.from(instant);
return date;

}

/**
* 获取日期列表中离当前日期最近的一个日期
* @param dateList
* @return
*/
public static String getLatstDate(List<Date> dateList){

final long now = System.currentTimeMillis();
// Get date closest to "now"
Date closest = Collections.min(dateList, new Comparator<Date>() {
public int compare(Date d1, Date d2) {
long diff1 = Math.abs(d1.getTime() - now);
long diff2 = Math.abs(d2.getTime() - now);
return Long.compare(diff1, diff2);
}
});
return DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, closest);
}

}

+ 3
- 12
src/main/java/com/tuoheng/airportGzdp/vo/AirCurrentDto.java Visa fil

@@ -3,6 +3,7 @@ package com.tuoheng.airportGzdp.vo;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.airportGzdp.common.BaseQuery;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

@@ -17,7 +18,7 @@ import java.util.Date;
* @since 2021-09-26
*/
@Data
public class AirCurrentDto {
public class AirCurrentDto extends BaseQuery {

private static final long serialVersionUID = 1L;

@@ -59,7 +60,7 @@ public class AirCurrentDto {
/**
* 数据包流水号
*/
private String serial;
private Integer serial;

/**
* 总瞬时流量
@@ -126,14 +127,4 @@ public class AirCurrentDto {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime;

/**
* 页码
*/
private Integer page;

/**
* 每页数
*/
private Integer limit;

}

+ 8
- 76
src/main/java/com/tuoheng/airportGzdp/vo/AirCurrentVo.java Visa fil

@@ -1,6 +1,8 @@
package com.tuoheng.airportGzdp.vo;

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

import java.util.Date;

@@ -15,96 +17,26 @@ import java.util.Date;
@Data
public class AirCurrentVo {

private static final long serialVersionUID = 1L;

/**
* 测流数据表 主键id
*/
private Integer id;

/**
* 飞行任务记录id
*/
private Integer inspectionRecordId;

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

/**
* 航线文件id
*/
private Integer airlineFileId;

/**
* 数据采集时间
*/
private Date airFlyTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date TM;

/**
* 测站唯一编码 用于区分不同测站
*/
private String st;

/**
* 测站类型
*/
private String type;
private String ST;

/**
* 数据包流水号
*/
private String serial;

/**
* 总瞬时流量
*/
private Double q1;

/**
* 断面平均流速
*/
private Double v1;

/**
* 垂线数量
*/
private Integer vcnt;

/**
* 所有时间平均流速 记录vv01 - vvx所有的数据
*/
private String vvx;

/**
* 添加人
*/
private Integer createUser;

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

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
private Date updateTime;
private Integer SERIAL;

/**
* 有效标识
*/
private Integer mark;

/**
* 航线文件id
*/
private Integer tenantId;
private Integer MARK;

}

Laddar…
Avbryt
Spara