feat(device): 新增机器人配置管理功能

新增机器人配置实体类、Mapper、Service及Controller,实现机器人配置的增删改查功能,
支持树形结构配置管理,包含配置ID、类型、父节点ID及节点名称等字段。
This commit is contained in:
lixiaolong 2025-09-22 10:58:45 +08:00
parent 22a58227e0
commit b8336ec766
6 changed files with 469 additions and 0 deletions

View File

@ -0,0 +1,105 @@
package com.cmvr.web.controller.device;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.cmvr.common.annotation.Log;
import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.common.enums.BusinessType;
import com.cmvr.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cmvr.device.domain.DeRobotConfig;
import com.cmvr.device.service.IDeRobotConfigService;
import static com.cmvr.common.core.domain.AjaxResult.success;
/**
* 机器人配置Controller
*
* @author cmvr-iot
* @date 2025-09-09
*/
@RestController
@RequestMapping("/device/robot")
public class DeRobotConfigController extends BaseController
{
@Autowired
private IDeRobotConfigService deRobotConfigService;
/**
* 查询机器人配置列表
*/
@PreAuthorize("@ss.hasPermi('device:robot:list')")
@GetMapping("/list")
public AjaxResult list(DeRobotConfig deRobotConfig)
{
List<DeRobotConfig> list = deRobotConfigService.selectDeRobotConfigList(deRobotConfig);
return success(list);
}
/**
* 导出机器人配置列表
*/
@PreAuthorize("@ss.hasPermi('device:robot:export')")
@Log(title = "机器人配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DeRobotConfig deRobotConfig)
{
List<DeRobotConfig> list = deRobotConfigService.selectDeRobotConfigList(deRobotConfig);
ExcelUtil<DeRobotConfig> util = new ExcelUtil<DeRobotConfig>(DeRobotConfig.class);
util.exportExcel(response, list, "机器人配置数据");
}
/**
* 获取机器人配置详细信息
*/
@PreAuthorize("@ss.hasPermi('device:robot:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(deRobotConfigService.selectDeRobotConfigById(id));
}
/**
* 新增机器人配置
*/
@PreAuthorize("@ss.hasPermi('device:robot:add')")
@Log(title = "机器人配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DeRobotConfig deRobotConfig)
{
return toAjax(deRobotConfigService.insertDeRobotConfig(deRobotConfig));
}
/**
* 修改机器人配置
*/
@PreAuthorize("@ss.hasPermi('device:robot:edit')")
@Log(title = "机器人配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DeRobotConfig deRobotConfig)
{
return toAjax(deRobotConfigService.updateDeRobotConfig(deRobotConfig));
}
/**
* 删除机器人配置
*/
@PreAuthorize("@ss.hasPermi('device:robot:remove')")
@Log(title = "机器人配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(deRobotConfigService.deleteDeRobotConfigByIds(ids));
}
}

View File

@ -0,0 +1,52 @@
package com.cmvr.device.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.cmvr.common.annotation.Excel;
import com.cmvr.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 机器人配置对象 de_robot_config
*
* @author cmvr-iot
* @date 2025-09-09
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("机器人配置对象")
public class DeRobotConfig extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
@ApiModelProperty("id")
@TableId(value = "id" , type = IdType.ASSIGN_UUID)
private String id;
/** 配置ID32位的UUID可以是设备ID或终端ID。 */
@Excel(name = "配置ID32位的UUID可以是设备ID或终端ID。")
@ApiModelProperty("配置ID32位的UUID可以是设备ID或终端ID。")
private String configId;
/** 配置类型,区分是设备还是终端 */
@Excel(name = "配置类型,区分是设备还是终端")
@ApiModelProperty(name = "配置类型,区分是设备还是终端")
private String configType;
/** 父配置ID用于构成树形结构。终端节点为root设备节点指向其父终端的id */
@Excel(name = "父配置ID用于构成树形结构。终端节点为root设备节点指向其父终端的id")
@ApiModelProperty(name = "父配置ID用于构成树形结构。终端节点为root设备节点指向其父终端的id")
private String pid;
/** 节点名称,名称可以随意取,不强制唯一 */
@Excel(name = "节点名称,名称可以随意取,不强制唯一")
@ApiModelProperty(name = "节点名称,名称可以随意取,不强制唯一")
private String nodeName;
}

View File

@ -0,0 +1,61 @@
package com.cmvr.device.mapper;
import java.util.List;
import com.cmvr.device.domain.DeRobotConfig;
/**
* 机器人配置Mapper接口
*
* @author cmvr-iot
* @date 2025-09-09
*/
public interface DeRobotConfigMapper
{
/**
* 查询机器人配置
*
* @param id 机器人配置主键
* @return 机器人配置
*/
public DeRobotConfig selectDeRobotConfigById(String id);
/**
* 查询机器人配置列表
*
* @param deRobotConfig 机器人配置
* @return 机器人配置集合
*/
public List<DeRobotConfig> selectDeRobotConfigList(DeRobotConfig deRobotConfig);
/**
* 新增机器人配置
*
* @param deRobotConfig 机器人配置
* @return 结果
*/
public int insertDeRobotConfig(DeRobotConfig deRobotConfig);
/**
* 修改机器人配置
*
* @param deRobotConfig 机器人配置
* @return 结果
*/
public int updateDeRobotConfig(DeRobotConfig deRobotConfig);
/**
* 删除机器人配置
*
* @param id 机器人配置主键
* @return 结果
*/
public int deleteDeRobotConfigById(String id);
/**
* 批量删除机器人配置
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDeRobotConfigByIds(String[] ids);
}

View File

@ -0,0 +1,61 @@
package com.cmvr.device.service;
import java.util.List;
import com.cmvr.device.domain.DeRobotConfig;
/**
* 机器人配置Service接口
*
* @author cmvr-iot
* @date 2025-09-09
*/
public interface IDeRobotConfigService
{
/**
* 查询机器人配置
*
* @param id 机器人配置主键
* @return 机器人配置
*/
public DeRobotConfig selectDeRobotConfigById(String id);
/**
* 查询机器人配置列表
*
* @param deRobotConfig 机器人配置
* @return 机器人配置集合
*/
public List<DeRobotConfig> selectDeRobotConfigList(DeRobotConfig deRobotConfig);
/**
* 新增机器人配置
*
* @param deRobotConfig 机器人配置
* @return 结果
*/
public int insertDeRobotConfig(DeRobotConfig deRobotConfig);
/**
* 修改机器人配置
*
* @param deRobotConfig 机器人配置
* @return 结果
*/
public int updateDeRobotConfig(DeRobotConfig deRobotConfig);
/**
* 批量删除机器人配置
*
* @param ids 需要删除的机器人配置主键集合
* @return 结果
*/
public int deleteDeRobotConfigByIds(String[] ids);
/**
* 删除机器人配置信息
*
* @param id 机器人配置主键
* @return 结果
*/
public int deleteDeRobotConfigById(String id);
}

View File

@ -0,0 +1,97 @@
package com.cmvr.device.service.impl;
import java.util.List;
import com.cmvr.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cmvr.device.mapper.DeRobotConfigMapper;
import com.cmvr.device.domain.DeRobotConfig;
import com.cmvr.device.service.IDeRobotConfigService;
/**
* 机器人配置Service业务层处理
*
* @author cmvr-iot
* @date 2025-09-09
*/
@Service
public class DeRobotConfigServiceImpl implements IDeRobotConfigService
{
@Autowired
private DeRobotConfigMapper deRobotConfigMapper;
/**
* 查询机器人配置
*
* @param id 机器人配置主键
* @return 机器人配置
*/
@Override
public DeRobotConfig selectDeRobotConfigById(String id)
{
return deRobotConfigMapper.selectDeRobotConfigById(id);
}
/**
* 查询机器人配置列表
*
* @param deRobotConfig 机器人配置
* @return 机器人配置
*/
@Override
public List<DeRobotConfig> selectDeRobotConfigList(DeRobotConfig deRobotConfig)
{
return deRobotConfigMapper.selectDeRobotConfigList(deRobotConfig);
}
/**
* 新增机器人配置
*
* @param deRobotConfig 机器人配置
* @return 结果
*/
@Override
public int insertDeRobotConfig(DeRobotConfig deRobotConfig)
{
deRobotConfig.setCreateTime(DateUtils.getNowDate());
return deRobotConfigMapper.insertDeRobotConfig(deRobotConfig);
}
/**
* 修改机器人配置
*
* @param deRobotConfig 机器人配置
* @return 结果
*/
@Override
public int updateDeRobotConfig(DeRobotConfig deRobotConfig)
{
deRobotConfig.setUpdateTime(DateUtils.getNowDate());
return deRobotConfigMapper.updateDeRobotConfig(deRobotConfig);
}
/**
* 批量删除机器人配置
*
* @param ids 需要删除的机器人配置主键
* @return 结果
*/
@Override
public int deleteDeRobotConfigByIds(String[] ids)
{
return deRobotConfigMapper.deleteDeRobotConfigByIds(ids);
}
/**
* 删除机器人配置信息
*
* @param id 机器人配置主键
* @return 结果
*/
@Override
public int deleteDeRobotConfigById(String id)
{
return deRobotConfigMapper.deleteDeRobotConfigById(id);
}
}

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cmvr.device.mapper.DeRobotConfigMapper">
<resultMap type="DeRobotConfig" id="DeRobotConfigResult">
<result property="id" column="id" />
<result property="configId" column="config_id" />
<result property="configType" column="config_type" />
<result property="pid" column="pid" />
<result property="nodeName" column="node_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDeRobotConfigVo">
select id, config_id, config_type, pid, node_name, create_by, create_time, update_by, update_time, remark from de_robot_config
</sql>
<select id="selectDeRobotConfigList" parameterType="DeRobotConfig" resultMap="DeRobotConfigResult">
<include refid="selectDeRobotConfigVo"/>
<where>
<if test="configId != null and configId != ''"> and config_id = #{configId}</if>
<if test="configType != null and configType != ''"> and config_type = #{configType}</if>
<if test="pid != null and pid != ''"> and pid = #{pid}</if>
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
</where>
</select>
<select id="selectDeRobotConfigById" parameterType="String" resultMap="DeRobotConfigResult">
<include refid="selectDeRobotConfigVo"/>
where id = #{id}
</select>
<insert id="insertDeRobotConfig" parameterType="DeRobotConfig">
insert into de_robot_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="configId != null">config_id,</if>
<if test="configType != null">config_type,</if>
<if test="pid != null">pid,</if>
<if test="nodeName != null">node_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="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="configId != null">#{configId},</if>
<if test="configType != null">#{configType},</if>
<if test="pid != null">#{pid},</if>
<if test="nodeName != null">#{nodeName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDeRobotConfig" parameterType="DeRobotConfig">
update de_robot_config
<trim prefix="SET" suffixOverrides=",">
<if test="configId != null">config_id = #{configId},</if>
<if test="configType != null">config_type = #{configType},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="nodeName != null">node_name = #{nodeName},</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>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDeRobotConfigById" parameterType="String">
delete from de_robot_config where id = #{id}
</delete>
<delete id="deleteDeRobotConfigByIds" parameterType="String">
delete from de_robot_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>