1.修改服务器状态接口优化。
2.无人机盒子对象增加盒子别名字段。
3.动态修改服务状态。
10 files modified
85 ■■■■■ changed files
ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java 6 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/component/netty/TyTcpClientManager.java 6 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/domain/entity/ArdDroneInfo.java 7 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/domain/entity/ArdServerInfo.java 8 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/mapper/ArdServerInfoMapper.java 3 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java 2 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/service/impl/ArdDroneInfoServiceImpl.java 10 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java 4 ●●●●● patch | view | raw | blame | history
ard-work/src/main/resources/mapper/ArdDroneInfoMapper.xml 33 ●●●●● patch | view | raw | blame | history
ard-work/src/main/resources/mapper/ArdServerInfoMapper.xml 6 ●●●●● patch | view | raw | blame | history
ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java
@@ -112,9 +112,9 @@
    @ApiOperation("修改服务器状态")
    @PreAuthorize("@ss.hasPermi('work:server:updateStatus')")
    @Log(title = "服务器管理", businessType = BusinessType.UPDATE)
    @PutMapping("/{id}")
    public AjaxResult updateServerStatus(@PathVariable("id") String id) {
        return toAjax(ardServerInfoService.updateServerStatus(id));
    @PutMapping("/{id}/{status}")
    public AjaxResult updateServerStatus(@PathVariable("id") String id,@PathVariable("status") String status) {
        return toAjax(ardServerInfoService.updateServerStatus(id,status));
    }
}
ard-work/src/main/java/com/ard/work/component/netty/TyTcpClientManager.java
@@ -81,9 +81,13 @@
                Channel channel = f.channel();
                channel.attr(AttributeKey.valueOf("serverId")).set(serverId);
                TyTcpServerCache.putTcpServerCache(serverId, true);
                // 断开服务器,修改状态为: 0 - 在线
                ardServerService.updateServerStatus(serverId, "1");
            } else {
                log.warn("❌ 服务器 [{}] 连接失败", serverId);
                TyTcpServerCache.putTcpServerCache(serverId, false);
                // 断开服务器,修改状态为: 0 - 离线
                ardServerService.updateServerStatus(serverId, "0");
            }
        });
@@ -107,6 +111,8 @@
        if (session != null && session.getChannelFuture() != null) {
            session.getChannelFuture().channel().close();
            log.info("断开服务器 [{}] 连接", serverId);
            // 断开服务器,修改状态为: 0 - 离线
            ardServerService.updateServerStatus(serverId, "0");
        }
        TyTcpServerCache.removeTcpServerCache(serverId);
    }
ard-work/src/main/java/com/ard/work/domain/entity/ArdDroneInfo.java
@@ -3,7 +3,7 @@
import com.ard.common.annotation.Excel;
import com.ard.common.core.domain.BaseEntity;
import com.ard.work.domain.receiver.BoxInfoReceiver;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import java.util.Date;
@@ -39,6 +39,7 @@
    private String boxVersion;
    /** 启动时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "启动时间")
    private Date startTime;
@@ -70,6 +71,10 @@
    @Excel(name = "服务器管理ID")
    private String serverId;
    /** 盒子别名 */
    @Excel(name = "盒子别名")
    private String boxAliasName;
    /**
     * 服务器实体对象
     */
ard-work/src/main/java/com/ard/work/domain/entity/ArdServerInfo.java
@@ -52,8 +52,12 @@
    /** 部门ID */
    private Long deptId;
    /** 服务器状态 */
    private Long serverStatus;
    /**
     * 服务器状态
     * 0:离线
     * 1:在线
     */
    private String serverStatus;
    private List<ArdDroneInfo> ardDroneInfoList;
ard-work/src/main/java/com/ard/work/mapper/ArdServerInfoMapper.java
@@ -1,5 +1,6 @@
package com.ard.work.mapper;
import com.ard.work.domain.entity.ArdServerInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -65,6 +66,6 @@
     * @param id 服务器管理主键
     * @return 结果
     */
    public int updateServerStatus(String id);
    public int updateServerStatus(@Param("id") String id, @Param("status") String status);
}
ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java
@@ -68,6 +68,6 @@
    /**
     * 修改服务器状态
     */
    public int updateServerStatus(String id);
    public int updateServerStatus(String id,String status);
}
ard-work/src/main/java/com/ard/work/service/impl/ArdDroneInfoServiceImpl.java
@@ -138,9 +138,6 @@
            throw new IllegalArgumentException("部门ID不能为空");
        }
        try {
            //utilMethod.authorizationVerification(boxSn.length);
            // 1. 检查已存在的无人机盒子
            List<ArdDroneInfo> existingDrones = getExistingDrones(boxSn);
            // 2. 授权数量验证
@@ -212,6 +209,7 @@
        drone.setId(IdUtils.simpleUUID());
        drone.setBoxSn(box.getBoxSn());
        drone.setBoxName(box.getBoxName());
        drone.setBoxAliasName(box.getBoxName());
        drone.setStartTime(new Date());
        drone.setOnLine(box.getOnLine());
        drone.setVideoServer(box.getVideoServer());
@@ -239,13 +237,9 @@
     */
    private int batchInsertDrones(List<ArdDroneInfo> drones) {
        if (drones.isEmpty()) {
            log.info("没有需要插入的无人机信息");
            return 0;
        }
        int result = ArdDroneInfoMapper.insertArdDroneLs(drones);
        log.info("成功插入 {} 条无人机记录", result);
        return result;
        return ArdDroneInfoMapper.insertArdDroneLs(drones);
    }
    /**
ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java
@@ -144,8 +144,8 @@
     * 修改服务器状态
     */
    @Override
    public int updateServerStatus(String id) {
        return ardServerInfoMapper.updateServerStatus(id);
    public int updateServerStatus(String id,String status) {
        return ardServerInfoMapper.updateServerStatus(id,status);
    }
    private String getEncryptStr(ArdServerInfo serverInfo, long timeStamp) {
ard-work/src/main/resources/mapper/ArdDroneInfoMapper.xml
@@ -16,6 +16,7 @@
        <result property="lastTaskId"    column="last_task_id"    />
        <result property="userId"    column="user_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="boxAliasName"    column="box_alias_name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
@@ -37,24 +38,25 @@
    <sql id="selectArdDroneVo">
        select id,
            box_sn,
            box_name,
            box_version,
            start_time,
            on_line,
            video_server,
            video_port,
            last_task_id,
            server_id,
            user_id,
            dept_id
               box_sn,
               box_name,
               box_version,
               start_time,
               on_line,
               video_server,
               video_port,
               last_task_id,
               server_id,
               user_id,
               dept_id,
               box_alias_name
        from ard_drone_info
    </sql>
    <select id="selectArdDroneList" parameterType="ArdDroneInfo" resultMap="ArdDroneInfoResult">
        <include refid="selectArdDroneVo"/>
        <where>
            <if test="boxSn != null  and boxSn != ''"> and box_sn = #{boxSn}</if>
        <where>
            <if test="boxSn != null  and boxSn != ''"> and box_sn like concat('%', #{boxSn}, '%')</if>
            <if test="boxName != null  and boxName != ''"> and box_name like concat('%', #{boxName}, '%')</if>
            <if test="boxVersion != null  and boxVersion != ''"> and box_version = #{boxVersion}</if>
            <if test="onLine != null "> and onLine = #{onLine}</if>
@@ -87,6 +89,7 @@
            <if test="serverId != null">server_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="boxAliasName != null">box_alias_name,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
@@ -106,6 +109,7 @@
            <if test="serverId != null">#{serverId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="boxAliasName != null">#{boxAliasName},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
@@ -128,6 +132,7 @@
            <if test="serverId != null">server_id = #{serverId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="boxAliasName != null">box_alias_name = #{boxAliasName},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
@@ -162,6 +167,7 @@
            server_id,
            user_id,
            dept_id,
            box_alias_name,
            create_by,
            create_time,
            update_by,
@@ -181,6 +187,7 @@
            #{item.serverId},
            #{item.userId},
            #{item.deptId},
            #{item.boxAliasName},
            #{item.createBy},
            #{item.createTime},
            #{item.updateBy},
ard-work/src/main/resources/mapper/ArdServerInfoMapper.xml
@@ -43,7 +43,7 @@
        <include refid="selectArdServerInfoVo"/>
        <where>
            <if test="id != null and id != ''"> and c.id = #{id}</if>
            <if test="serverName != null and serverName != ''"> and server_name like c.concat('%', #{serverName}, '%')</if>
            <if test="serverName != null and serverName != ''"> and c.server_name like c.concat('%', #{serverName}, '%')</if>
            <if test="accessKeyId != null and accessKeyId != ''"> and c.access_key_id = #{accessKeyId}</if>
            <if test="accessKeySecret != null and accessKeySecret != ''"> and c.access_key_secret = #{accessKeySecret}</if>
            <if test="serverStatus != null and serverStatus != ''"> and c.server_status = #{serverStatus}</if>
@@ -113,10 +113,10 @@
        where id = #{id}
    </update>
    <update id="updateServerStatus" parameterType="String">
    <update id="updateServerStatus">
        update ard_server_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="serverStatus != null">server_status = #{serverStatus},</if>
            <if test="status != null">server_status = #{status},</if>
        </trim>
        where id = #{id}
    </update>