Просмотр исходного кода

小程序取出航线名称字段,改为自动获取

pull/361/head
wanjing 10 месяцев назад
Родитель
Сommit
6354fa2df7
6 измененных файлов: 200 добавлений и 47 удалений
  1. +0
    -20
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/Inspection.java
  2. +26
    -19
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java
  3. +117
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/third/airport/GetAirLineListService.java
  4. +56
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/AirportLineVo.java
  5. +1
    -3
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionInfoVo.java
  6. +0
    -5
      tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/InspectionMapper.xml

+ 0
- 20
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/Inspection.java Просмотреть файл

@@ -54,21 +54,11 @@ public class Inspection extends BaseEntity {
*/
private String roadId;

/**
* 公路名称
*/
private String roadName;

/**
* 路段id
*/
private String sectionId;

/**
* 路段名称
*/
private String sectionName;

/**
* 巡检方式类型 1 无人机 2机场
*/
@@ -84,21 +74,11 @@ public class Inspection extends BaseEntity {
*/
private Integer droneId;

/**
* 巡检机场名称
*/
private String airportName;

/**
* 巡检线路id
*/
private Integer inspectionLine;

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

/**
* 飞行设备
*/

+ 26
- 19
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java Просмотреть файл

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

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -18,7 +20,9 @@ import com.tuoheng.miniprogram.entity.User;
import com.tuoheng.miniprogram.entity.query.InspectionQuery;
import com.tuoheng.miniprogram.enums.DataPermissionEnum;
import com.tuoheng.miniprogram.service.IInspectionService;
import com.tuoheng.miniprogram.service.third.airport.GetAirLineListService;
import com.tuoheng.miniprogram.utils.CurrentUserUtil;
import com.tuoheng.miniprogram.vo.AirportLineVo;
import com.tuoheng.miniprogram.vo.InspectionInfoVo;
import com.tuoheng.miniprogram.vo.PlayBackInfoVo;
import lombok.extern.slf4j.Slf4j;
@@ -26,10 +30,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
@@ -55,6 +57,9 @@ public class InspectionServiceImpl implements IInspectionService {
@Autowired
private TenantMapper tenantMapper;

@Autowired
private GetAirLineListService getAirLineListService;

/**
* 任务列表(分页)
*
@@ -163,6 +168,15 @@ public class InspectionServiceImpl implements IInspectionService {
}
}
}
Map<Integer, AirportLineVo> airportLineMap = this.getAirportLineMap(inspectionInfoVoList);
for (InspectionInfoVo inspectionInfoVo : inspectionInfoVoList) {
//航线名称
if (CollectionUtil.isNotEmpty(airportLineMap)) {
if (ObjectUtil.isNotNull(airportLineMap.get(inspectionInfoVo.getInspectionLine()))) {
inspectionInfoVo.setInspectionLineName(airportLineMap.get(inspectionInfoVo.getInspectionLine()).getFileName());
}
}
}
pageDataVo.setRecords(inspectionInfoVoList);
return JsonResult.success(pageDataVo);
}
@@ -219,23 +233,16 @@ public class InspectionServiceImpl implements IInspectionService {
if (count <= 0 && num != inspectionFiles.size()) {
return JsonResult.error();
}

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

}

/**
* 递归获取部门的子集
*
* @author zhu_zishuang
* @date 3/13/21
*/
private List<Dept> getChildren(Dept rootDept, List<Dept> list) {
return list.stream().filter(dept ->
dept.getPid().equals(rootDept.getId())
).peek(dept -> {
// 设置子集
dept.setItemList(getChildren(dept, list));
}).sorted(Comparator.comparingInt(dept -> (dept.getSort() == null ? 0 : dept.getSort()))).collect(Collectors.toList());
private Map<Integer, AirportLineVo> getAirportLineMap(List<InspectionInfoVo> inspectionInfoVoList) {
List<Integer> airportLineIdList = inspectionInfoVoList.stream().map(o -> o.getInspectionLine()).collect(Collectors.toList());
List<AirportLineVo> airportLineVoList = getAirLineListService.getList(null, airportLineIdList);
if (CollectionUtil.isEmpty(airportLineVoList)) {
return null;
}
Map<Integer, AirportLineVo> airportLineMap = airportLineVoList.stream().collect(Collectors.toMap(AirportLineVo::getId, Function.identity()));
return airportLineMap;
}
}

+ 117
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/third/airport/GetAirLineListService.java Просмотреть файл

@@ -0,0 +1,117 @@
package com.tuoheng.miniprogram.service.third.airport;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.dao.TenantMapper;
import com.tuoheng.miniprogram.entity.Tenant;
import com.tuoheng.miniprogram.utils.CurrentUserUtil;
import com.tuoheng.miniprogram.vo.AirportLineVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.List;
import java.util.Objects;

@Slf4j
@Service
public class GetAirLineListService {

/**
* 机场平台:获取机场路线列表接口
*/
String API_AIRPORT_LINE_LIST = "/airportInterface/taskByDroneId";

/**
* 机场平台:获取机场路线列表接口
*/
String API_AIRPORT_LINE_FILE_LIST = "/airportInterface/getAirlineFileListForThird";

@Autowired
private TenantMapper tenantMapper;

@Autowired
@Qualifier("restTemplate")
private RestTemplate restTemplate;

public JsonResult getAirLineList(Integer droneId) {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
log.info("租户不存在, tenantId:{}", CurrentUserUtil.getTenantId());
throw new ServiceException("租户不存在");
}
String url = UriComponentsBuilder.fromHttpUrl(CommonConfig.airportURL + API_AIRPORT_LINE_LIST)
.queryParam("page", 1)
.queryParam("limit", 100)
.queryParam("droneId", droneId)
.toUriString();

JsonResult jsonResult;
try {
jsonResult = restTemplate.getForObject(url, JsonResult.class);
} catch (Exception e) {
log.info("获机航线列表接口异常, url:{}", url);
throw new ServiceException("获机航线列表接口异常");
}
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(Objects.requireNonNull(jsonResult).getData()) && jsonResult.getCode() != 0)) {
log.info("获机航线列表接口返回为空");
throw new ServiceException("获机航线列表接口返回为空");
}
return jsonResult;
}

public List<AirportLineVo> getList(String airportId, List<Integer> airportLineIdList) {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
return null;
}
String url = CommonConfig.airportURL + API_AIRPORT_LINE_FILE_LIST;

JSONObject jsonObject = new JSONObject();
jsonObject.put("tenantCode", tenant.getCode());
jsonObject.put("airportId", airportId);
jsonObject.put("airlineFileIds", airportLineIdList);

log.info("调用机场平台,获取航线列表,url:{}", url);
log.info("调用机场平台,获取航线列表,jsonObject:{}", jsonObject);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity httpEntity = new HttpEntity(jsonObject, headers);
ResponseEntity<JsonResult> response;
try {
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
} catch (Exception e) {
log.info("调用机场平台,获取航线列表接口异常,url:{}", url);
log.info("调用机场平台,获取航线列表接口异常,jsonObject:{}", jsonObject);
return null;
}
if (ObjectUtil.isEmpty(response)) {
log.info("调用机场平台,获取航线列表接口返回为空,url:{}", url);
log.info("调用机场平台,获取航线列表接口返回为空,jsonObject:{}", jsonObject);
return null;
}
JsonResult jsonResult = response.getBody();
if (0 != jsonResult.getCode()) {
log.info("调用机场平台,获取航线列表,失败,url:{}", url);
log.info("调用机场平台,获取航线列表,失败,jsonObject:{}", jsonObject);
log.info("调用机场平台,获取航线列表,失败,jsonResult:{}", jsonResult.getMsg());
return null;
}
List<AirportLineVo> airportLineVoList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirportLineVo.class);
if (CollectionUtil.isEmpty(airportLineVoList)) {
log.info("调用机场平台,获取航线列表,数据为空");
}
return airportLineVoList;
}
}

+ 56
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/AirportLineVo.java Просмотреть файл

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

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* 机场线路视图Vo
*
* @author wanjing
* @team tuoheng
* @date 2022-11-23
*/
@Data
@NoArgsConstructor
public class AirportLineVo implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 航线id
*/
private Integer id;

/**
* 航线名称
*/
private String fileName;

/**
* 航线地址
*/
private String fileUrl;

/**
* 机场ID
*/
private String airportId;

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

/**
* 航线类型:1,航点航线;2,指点航线;3,指面航线
*/
private String type;

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

}

+ 1
- 3
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionInfoVo.java Просмотреть файл

@@ -34,7 +34,7 @@ public class InspectionInfoVo {
private Integer type;

/**
*任务状态 5任务待飞行 7飞行失败 10任务飞行中 15任务飞行完成
* 任务状态 5任务待飞行 7飞行失败 10任务飞行中 15任务飞行完成
*/
private Integer status;

@@ -85,6 +85,4 @@ public class InspectionInfoVo {
*/
private String aiVideoUrl;



}

+ 0
- 5
tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/InspectionMapper.xml Просмотреть файл

@@ -11,14 +11,10 @@
<result property="name" column="name" />
<result property="type" column="type" />
<result property="roadId" column="road_id" />
<result property="roadName" column="road_name" />
<result property="sectionId" column="section_id" />
<result property="sectionName" column="section_name" />
<result property="inspectionType" column="inspection_type" />
<result property="airportId" column="airport_id" />
<result property="airportName" column="airport_name" />
<result property="inspectionLine" column="inspection_line" />
<result property="inspectionLineName" column="inspection_line_name" />
<result property="equipmentId" column="equipment_id" />
<result property="equipmentName" column="equipment_name" />
<result property="equipmentMountId" column="equipment_mount_id" />
@@ -71,7 +67,6 @@
ti.status,
ti.inspection_type as inspectionType,
ti.inspection_line as inspectionLine,
ti.inspection_line_name as inspectionLineName,
ti.create_user as createUser,
ti.execution_start_time as executionStartTime,
ti.ai_video_url as aiVideoUrl

Загрузка…
Отмена
Сохранить