1.修改服务器状态接口优化。
2.无人机盒子对象增加盒子别名字段。
3.动态修改服务状态。
| | |
| | | @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)); |
| | | } |
| | | |
| | | } |
| | |
| | | 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"); |
| | | } |
| | | }); |
| | | |
| | |
| | | if (session != null && session.getChannelFuture() != null) { |
| | | session.getChannelFuture().channel().close(); |
| | | log.info("断开服务器 [{}] 连接", serverId); |
| | | // 断开服务器,修改状态为: 0 - 离线 |
| | | ardServerService.updateServerStatus(serverId, "0"); |
| | | } |
| | | TyTcpServerCache.removeTcpServerCache(serverId); |
| | | } |
| | |
| | | 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; |
| | |
| | | private String boxVersion; |
| | | |
| | | /** 启动时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "启动时间") |
| | | private Date startTime; |
| | | |
| | |
| | | @Excel(name = "服务器管理ID") |
| | | private String serverId; |
| | | |
| | | /** 盒子别名 */ |
| | | @Excel(name = "盒子别名") |
| | | private String boxAliasName; |
| | | |
| | | /** |
| | | * 服务器实体对象 |
| | | */ |
| | |
| | | /** 部门ID */ |
| | | private Long deptId; |
| | | |
| | | /** 服务器状态 */ |
| | | private Long serverStatus; |
| | | /** |
| | | * 服务器状态 |
| | | * 0:离线 |
| | | * 1:在线 |
| | | */ |
| | | private String serverStatus; |
| | | |
| | | private List<ArdDroneInfo> ardDroneInfoList; |
| | | |
| | |
| | | package com.ard.work.mapper; |
| | | import com.ard.work.domain.entity.ArdServerInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @param id 服务器管理主键 |
| | | * @return 结果 |
| | | */ |
| | | public int updateServerStatus(String id); |
| | | public int updateServerStatus(@Param("id") String id, @Param("status") String status); |
| | | |
| | | } |
| | |
| | | /** |
| | | * 修改服务器状态 |
| | | */ |
| | | public int updateServerStatus(String id); |
| | | public int updateServerStatus(String id,String status); |
| | | |
| | | } |
| | |
| | | throw new IllegalArgumentException("部门ID不能为空"); |
| | | } |
| | | try { |
| | | |
| | | //utilMethod.authorizationVerification(boxSn.length); |
| | | |
| | | // 1. 检查已存在的无人机盒子 |
| | | List<ArdDroneInfo> existingDrones = getExistingDrones(boxSn); |
| | | // 2. 授权数量验证 |
| | |
| | | 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()); |
| | |
| | | */ |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 修改服务器状态 |
| | | */ |
| | | @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) { |
| | |
| | | <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" /> |
| | |
| | | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | server_id, |
| | | user_id, |
| | | dept_id, |
| | | box_alias_name, |
| | | create_by, |
| | | create_time, |
| | | update_by, |
| | |
| | | #{item.serverId}, |
| | | #{item.userId}, |
| | | #{item.deptId}, |
| | | #{item.boxAliasName}, |
| | | #{item.createBy}, |
| | | #{item.createTime}, |
| | | #{item.updateBy}, |
| | |
| | | <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> |
| | |
| | | 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> |