Parcourir la source

任务状态及机场状态展示首页滚动

tags/V1.0.1^2
chengwang il y a 1 an
Parent
révision
3a6b7e4524
7 fichiers modifiés avec 239 ajouts et 1 suppressions
  1. +8
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +75
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/inspection/InspectionScrollbarVo.java
  3. +6
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java
  4. +12
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java
  5. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java
  6. +110
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionAndAirportStatusService.java
  7. +26
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/InspectionServiceTest.java

+ 8
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java Voir le fichier

@@ -178,5 +178,13 @@ public class InspectionController {
return iInspectionService.updateTaskByCode(request);
}

/**
* 查询任务状态及对应机场信息 页面滑动展示
*/
@GetMapping("/getList")
public JsonResult InspectionStatusGetList(){
return iInspectionService.getList();
}


}

+ 75
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/inspection/InspectionScrollbarVo.java Voir le fichier

@@ -0,0 +1,75 @@
package com.tuoheng.admin.entity.vo.inspection;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2023/5/22
*/
@Data
public class InspectionScrollbarVo {

private static final long serialVersionUID = 1L;

/**
* 任务id
*/
private String id;

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

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

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

/**
* 任务类型
*/
private Integer inspectionType;

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

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

/**
* 机场状态信息
*/
private String airportStatus;;

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

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

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

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


}

+ 6
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java Voir le fichier

@@ -139,4 +139,10 @@ public interface IInspectionService {
*/
JsonResult inspectionList();

/**
* 页面滑动条展示
* @return
*/
JsonResult getList();

}

+ 12
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java Voir le fichier

@@ -88,6 +88,9 @@ public class InspectionServiceImpl implements IInspectionService {
@Autowired
private QueryInspectionDetailsService queryInspectionDetailsService;

@Autowired
private QueryInspectionAndAirportStatusService queryInspectionAndAirportStatusService;

/**
* 查询巡任务
* @return
@@ -282,4 +285,13 @@ public class InspectionServiceImpl implements IInspectionService {
return null;
}

/**
* 页面滑动条展示
* @return
*/
@Override
public JsonResult getList() {
return queryInspectionAndAirportStatusService.getList();
}

}

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

@@ -76,6 +76,7 @@ public class AddInspectionService {
// log.info("添加任务业务:对接第三方平台失败:{}", result.getMsg());
// return result;
// }
//保存任务
Integer rowId = inspectionMapper.insert(inspection);
log.info("添加任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
@@ -84,7 +85,7 @@ public class AddInspectionService {
}
log.info("添加任务业务:添加任务成功:{}", inspection);

//判断是机场巡逻的任务
//判断是机场巡逻的任务,航线数据关联任务id
if(inspection.getInspectionType() == 2){
log.info("查询巡检任务对应新增航线");
Integer inspectionLine = inspection.getInspectionLine();

+ 110
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionAndAirportStatusService.java Voir le fichier

@@ -0,0 +1,110 @@
package com.tuoheng.admin.service.inspection.query;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.domain.Inspection;
import com.tuoheng.admin.entity.domain.User;
import com.tuoheng.admin.entity.vo.airport.AirPortStatusVO;
import com.tuoheng.admin.entity.vo.inspection.InspectionScrollbarVo;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.HttpUtils;
import com.tuoheng.common.core.utils.JacksonUtil;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
* @Author ChengWang
* @Date 2023/5/22
*/
@Slf4j
@Service
public class QueryInspectionAndAirportStatusService {

@Autowired
private InspectionMapper inspectionMapper;


public JsonResult getList() {
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();
JsonResult jsonResult = check(userId,tenantId);
if(0 != jsonResult.getCode()){
log.info("进入查询任务列表及机场状态业务:校验失败:{}",jsonResult.getMsg());
}
//查询当前租户下的任务列表
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getMark, MarkEnum.VALID.getCode())
.in(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode(), InspectionStatusEnum.PREPARING.getCode()));
if(CollectionUtils.isEmpty(inspectionList) || inspectionList.size() == 0){
log.info("任务列表为空");
return JsonResult.success();
}
List<InspectionScrollbarVo> inspectionVoList = new ArrayList<>();
for (Inspection inspection : inspectionList) {
InspectionScrollbarVo vo = new InspectionScrollbarVo();
BeanUtils.copyProperties(inspection,vo);
inspectionVoList.add(vo);
}
//机场状态
Map<Integer, AirPortStatusVO> airPortStatusVOMap = this.getAirPortStatusMap(inspectionList);
AirPortStatusVO airPortStatusVO;
for (InspectionScrollbarVo inspectionScrollbarVo : inspectionVoList) {
if(ObjectUtil.isNotNull(airPortStatusVOMap)){
airPortStatusVO = airPortStatusVOMap.get(inspectionScrollbarVo.getAirportId());
if(ObjectUtil.isNotNull(airPortStatusVO)){
//机场状态
inspectionScrollbarVo.setAirportStatus(airPortStatusVO.getMsg());
}
}
}

return JsonResult.success();
}

private Map<Integer, AirPortStatusVO> getAirPortStatusMap(List<Inspection> inspectionList) {
StringBuffer ids = new StringBuffer();
String airportIds;
Set<Integer> set = new HashSet<>();
for (Inspection inspection : inspectionList) {
if(set.add(inspection.getAirportId())){
ids.append(inspection.getAirportId()).append(",");
}
}
airportIds = ids.substring(0,ids.length() - 1);
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_STATUS_BY_AIRPORT_ID;
String param = "airportIds=" + airportIds;
String airPortStatusStr = HttpUtils.sendGet(url, param);
if(StringUtils.isEmpty(airPortStatusStr)){
log.info("调用机场平台,查询飞行任务:机场接口返回数据为空,查询飞行状态失败");
return null;
}
//String---> JsonResult
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStatusStr, JsonResult.class);
List<AirPortStatusVO> airPortStatusVOList = (List<AirPortStatusVO>) jsonResult.getData();
// List<AirPortStatusVO> airPortStatusVOList = com.alibaba.fastjson.JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirPortStatusVO.class);
Map<Integer,AirPortStatusVO> map = new HashMap<>();
for (AirPortStatusVO airPortStatusVO : airPortStatusVOList) {
map.put(airPortStatusVO.getAirportId(),airPortStatusVO);
}
return map;
}

private JsonResult check(String userId, String tenantId) {
return JsonResult.success();
}
}

+ 26
- 0
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/InspectionServiceTest.java Voir le fichier

@@ -2,7 +2,9 @@ package com.tuoheng.admin.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.domain.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.entity.request.inspection.AddInspectionRequest;
@@ -20,6 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
@@ -115,4 +122,23 @@ public class InspectionServiceTest {
missionStatusRequest.setStatus(2);
updateFlightStatusService.updateFlightStatus(inspection, missionStatusRequest);
}

@Test
public void test33() {

StringBuffer ids = new StringBuffer();
String airportIds;
//查询当前租户下的任务列表
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, "1")
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
Set<Integer> set = new HashSet<>();
for (Inspection inspection : inspectionList) {
if (set.add(inspection.getAirportId())) {
ids.append(inspection.getAirportId()).append(",");
}
}
airportIds = ids.substring(0,ids.length() - 1);
System.out.println(airportIds);
}
}

Chargement…
Annuler
Enregistrer