吉安感知网项目-后端
linwei
2026-02-02 abc35b38ff9e0e1a4f2979df648d50af24359650
设备同步优化
2 files modified
24 ■■■■■ changed files
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/entity/GdManageDeviceEntity.java 9 ●●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/service/impl/GdManageDeviceServiceImpl.java 15 ●●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/entity/GdManageDeviceEntity.java
@@ -130,8 +130,17 @@
    @ApiModelProperty(value = "设备位置")
    private String location;
    /**
     * 设备高度
     */
    @ApiModelProperty(value = "设备高度")
    private Double height;
    /**
     * 是否在机巢中0:是1否
     */
    @ApiModelProperty(value = "是否在机巢中0:是1否")
    private Integer isWithDock;
}
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/service/impl/GdManageDeviceServiceImpl.java
@@ -19,6 +19,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
@@ -105,10 +106,13 @@
     */
    @Override
    @Scheduled(cron = "0 0 0 * * ?")
    // @Scheduled(cron = "*/10 * * * * ?")
    public int syncXingtuDevice() throws Exception {
        int total = 0;
        total += syncPilotDevices();
        // 2.同步机巢设备
        total += syncAirportDevices();
        // 1.同步无人机设备
        total += syncPilotDevices();
        log.info("更新或新增设备"+total);
        return total;
    }
@@ -171,9 +175,12 @@
        if (StringUtil.isBlank(entity.getAirportId())) {
            return false;
        }
        // 获取设备信息
        GdManageDeviceEntity exist = lambdaQuery()
            .eq(GdManageDeviceEntity::getAirportId, entity.getAirportId())
            .one();
        // 获取父级设备信息
        GdManageDeviceEntity parent = getOne(Wrappers.<GdManageDeviceEntity>lambdaQuery().eq(GdManageDeviceEntity::getChildSn, entity.getDeviceSn()));
        if (exist != null) {
            entity.setId(exist.getId());
            if (entity.getLongitude() == null) {
@@ -184,6 +191,11 @@
            }
            if (entity.getInsureExpiredTime() == null) {
                entity.setInsureExpiredTime(exist.getInsureExpiredTime());
            }
            // 获取父级设备位置信息
            if (parent != null) {
                entity.setLongitude(parent.getLongitude());
                entity.setLatitude(parent.getLatitude());
            }
        }
        return saveOrUpdateDevice(entity);
@@ -211,6 +223,7 @@
        entity.setModeCode(parseModeCode(item.getStatus()));
        entity.setInsureExpiredTime(parseInsuranceDate(item.getInsuranceInfo()));
        entity.setAreaCode(extractAreaCode(item.getRegionCode()));
        entity.setIsWithDock(item.getIsWithDock());
        return entity;
    }