Browse Source

重构代码

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
ddec83b8d4
9 changed files with 28 additions and 37 deletions
  1. +1
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/FlightDataController.java
  2. +1
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/callback/CloudBoxCallbackoxController.java
  3. +12
    -12
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/FlightDataServiceImpl.java
  4. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/IFlightDataService.java
  5. +3
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFindFlightDataByInspectionIdService.java
  6. +4
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFindFlightDataService.java
  7. +1
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFlightDataTrackService.java
  8. +2
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/AsyncServiceImpl.java
  9. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java

+ 1
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/FlightDataController.java View File

@@ -3,8 +3,7 @@ package com.tuoheng.admin.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.query.FlightDataQuery;
import com.tuoheng.admin.service.IFlightDataService;
import com.tuoheng.common.core.common.OperationEnum;
import com.tuoheng.admin.service.flightdata.IFlightDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


+ 1
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/callback/CloudBoxCallbackoxController.java View File

@@ -1,10 +1,9 @@
package com.tuoheng.admin.controller.callback;

import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.service.IFlightDataService;
import com.tuoheng.admin.service.flightdata.IFlightDataService;
import com.tuoheng.common.core.common.OperationEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/FlightDataServiceImpl.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/FlightDataServiceImpl.java View File

@@ -1,4 +1,4 @@
package com.tuoheng.admin.service.impl;
package com.tuoheng.admin.service.flightdata;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -8,7 +8,6 @@ import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.mapper.FlightDataMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.query.FlightDataQuery;
import com.tuoheng.admin.service.IFlightDataService;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
@@ -40,42 +39,43 @@ public class FlightDataServiceImpl extends BaseServiceImpl<FlightDataMapper, Fli

/**
* 获取巡检任务飞行轨迹坐标列表
*
* @param flightDataQuery
* @return
*/
@Override
public IPage<FlightData> getFlightDataList(FlightDataQuery flightDataQuery) {
if(StringUtils.isEmpty(flightDataQuery.getInspectionId())){
if (StringUtils.isEmpty(flightDataQuery.getInspectionId())) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
QueryWrapper<FlightData> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("inspection_id",flightDataQuery.getInspectionId());
queryWrapper.eq("mark",1);
queryWrapper.eq("inspection_id", flightDataQuery.getInspectionId());
queryWrapper.eq("mark", 1);
//飞机坐标不关联租户id
//queryWrapper.eq("tenant_id", ShiroUtils.getTenantId())
queryWrapper.orderByDesc("id");
//查询分页数据
IPage<FlightData> page = new Page<>(flightDataQuery.getPage(),flightDataQuery.getLimit());
IPage<FlightData> pageData = flightDataMapper.selectPage(page,queryWrapper);
IPage<FlightData> page = new Page<>(flightDataQuery.getPage(), flightDataQuery.getLimit());
IPage<FlightData> pageData = flightDataMapper.selectPage(page, queryWrapper);

return pageData;
}

@Override
public void addCallback(FlightData entity) {
if(entity !=null && StringUtils.isNotEmpty(entity.getBoxSn())){
log.info("addCallback接口入参:"+entity);
if (entity != null && StringUtils.isNotEmpty(entity.getBoxSn())) {
log.info("addCallback接口入参:" + entity);
//查询正在执行的云盒所对应的任务
List<Inspection> inspectionList = inspectionMapper.getListByBox(entity.getBoxSn());
if(StringUtils.isNotEmpty(inspectionList)){
if (StringUtils.isNotEmpty(inspectionList)) {
entity.setTenantId(inspectionList.get(0).getTenantId());
entity.setInspectionId(inspectionList.get(0).getId());
//将最新一条数据存放入缓存,并设置过期时间
redisUtils.set(inspectionList.get(0).getId(),entity,10);
redisUtils.set(inspectionList.get(0).getId(), entity, 10);
}
entity.setCreateTime(DateUtils.now());
flightDataMapper.insert(entity);
log.info("addCallback接口入库成功:"+entity.getId());
log.info("addCallback接口入库成功:" + entity.getId());
}
}
}

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/IFlightDataService.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/IFlightDataService.java View File

@@ -1,4 +1,4 @@
package com.tuoheng.admin.service;
package com.tuoheng.admin.service.flightdata;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.FlightData;

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryFindFlightDataByInspectionIdService.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFindFlightDataByInspectionIdService.java View File

@@ -1,7 +1,6 @@
package com.tuoheng.admin.service.inspection.query;
package com.tuoheng.admin.service.flightdata.query;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.mapper.FlightDataMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
@@ -31,7 +30,6 @@ public class QueryFindFlightDataByInspectionIdService {
@Autowired
private RedisUtils redisUtils;


public FlightData getFlightData(String inspectionId) {
//拉取最新一条经纬度信息
// FlightData flightData = flightDataMapper.selectOne(Wrappers.<FlightData>lambdaQuery()
@@ -41,9 +39,9 @@ public class QueryFindFlightDataByInspectionIdService {
//从缓存中拿出遥测数据
Object obj = redisUtils.get(inspectionId);
FlightData flightData = null;
if(ObjectUtil.isNull(obj)){
if (ObjectUtil.isNull(obj)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}else {
} else {
flightData = (FlightData) obj;
}
return flightData;

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryFindFlightDataService.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFindFlightDataService.java View File

@@ -1,9 +1,8 @@
package com.tuoheng.admin.service.inspection.query;
package com.tuoheng.admin.service.flightdata.query;

import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum;
import com.tuoheng.admin.mapper.FlightDataMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
@@ -22,17 +21,12 @@ import java.util.List;
@Slf4j
public class QueryFindFlightDataService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private FlightDataMapper flightDataMapper;



public JsonResult findFlightData(String id) {
if(StringUtils.isEmpty(id)){
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(),QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
public JsonResult findFlightData(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
}
//根据任务id查询对应的云盒遥测数据
List<FlightData> listData = flightDataMapper.selectListByInspectionId(id);

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryFlightDataTrackService.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFlightDataTrackService.java View File

@@ -1,4 +1,4 @@
package com.tuoheng.admin.service.inspection.query;
package com.tuoheng.admin.service.flightdata.query;

import cn.hutool.core.util.ObjectUtil;
import com.tuoheng.admin.entity.FlightData;
@@ -32,7 +32,6 @@ public class QueryFlightDataTrackService {
@Autowired
private InspectionMapper inspectionMapper;


public OperationEnum track(InspectionRequest inspectionRequest) {
Inspection inspection = inspectionMapper.selectById(inspectionRequest.getRequestId());
if (ObjectUtil.isEmpty(inspection)) {

+ 2
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/AsyncServiceImpl.java View File

@@ -1,7 +1,7 @@
package com.tuoheng.admin.service.impl;

import com.tuoheng.admin.service.AsyncService;
import com.tuoheng.admin.service.IFlightDataService;
import com.tuoheng.admin.service.flightdata.IFlightDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
@@ -9,7 +9,6 @@ import org.springframework.stereotype.Service;

import java.util.List;


/**
* 异步任务接口实现
*/
@@ -21,7 +20,7 @@ public class AsyncServiceImpl implements AsyncService {
private IFlightDataService flightDataService;

@Async("asyncServiceExecutor")
public void flightDataSaveBatch(List list){
public void flightDataSaveBatch(List list) {
log.info("线程-" + Thread.currentThread().getId() + "在执行写入");
flightDataService.saveBatch(list);
}

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java View File

@@ -4,6 +4,9 @@ import com.tuoheng.admin.dto.InspectionDto;
import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.request.inspection.*;
import com.tuoheng.admin.service.flightdata.query.QueryFindFlightDataByInspectionIdService;
import com.tuoheng.admin.service.flightdata.query.QueryFindFlightDataService;
import com.tuoheng.admin.service.flightdata.query.QueryFlightDataTrackService;
import com.tuoheng.admin.service.inspection.add.AddInspectionService;
import com.tuoheng.admin.service.inspection.execute.ExecuteInspectionService;
import com.tuoheng.admin.service.inspection.resubmit.ResubmitInspectionService;

Loading…
Cancel
Save