fit:设备分类接口增加,分类分组

This commit is contained in:
gyb 2026-02-09 13:44:02 +08:00
parent ae6b8bcc93
commit 87d7de414e
7 changed files with 96 additions and 34 deletions

View File

@ -3,6 +3,7 @@ package com.ruoyi.device.controller;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.device.api.domain.AirTypeCategoryGroupVO;
import com.ruoyi.device.api.domain.AirTypeGeneralEnumVO;
import com.ruoyi.device.api.domain.AirTypeVendorGroupVO;
import com.ruoyi.device.controller.convert.DeviceAirTypeGeneralEnumVOConvert;
@ -16,7 +17,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 无人机类型通用枚举Controller
@ -50,7 +53,7 @@ public class DeviceAirTypeGeneralEnumController extends BaseController
}
/**
* 按厂商分组查询无人机类型
* 按厂商分组查询无人机类型厂商 -> 分类 -> 设备类型
*
* @return 按厂商分组的无人机类型列表
*/
@ -63,9 +66,9 @@ public class DeviceAirTypeGeneralEnumController extends BaseController
if (dictResult.getData() != null)
{
// 获取所有无人机类型数据
List<DeviceAirTypeGeneralEnumDTO> allList = airTypeGeneralEnumService.selectAirTypeGeneralEnumList(new DeviceAirTypeGeneralEnumDTO());
List<AirTypeGeneralEnumVO> allVoList = DeviceAirTypeGeneralEnumVOConvert.fromList(allList);
// 获取所有无人机类型数据包括生效和失效的
List<DeviceAirTypeGeneralEnumDTO> allList = airTypeGeneralEnumService.selectAirTypeGeneralEnumList(new DeviceAirTypeGeneralEnumDTO());
List<AirTypeGeneralEnumVO> allVoList = DeviceAirTypeGeneralEnumVOConvert.fromList(allList);
// 为每个字典项创建分组
for (SysDictData dictData : dictResult.getData())
@ -84,12 +87,36 @@ public class DeviceAirTypeGeneralEnumController extends BaseController
}
}
groupVO.setAirTypeList(vendorAirTypes);
// 按分类分组
Map<String, List<AirTypeGeneralEnumVO>> categoryMap = new HashMap<>();
for (AirTypeGeneralEnumVO vo : vendorAirTypes)
{
String category = vo.getCategory();
if (category == null || category.isEmpty()) {
category = "其他";
}
if (!categoryMap.containsKey(category)) {
categoryMap.put(category, new ArrayList<>());
}
categoryMap.get(category).add(vo);
}
// 构建分类分组列表
List<AirTypeCategoryGroupVO> categoryGroups = new ArrayList<>();
for (Map.Entry<String, List<AirTypeGeneralEnumVO>> entry : categoryMap.entrySet()) {
AirTypeCategoryGroupVO categoryGroup = new AirTypeCategoryGroupVO();
categoryGroup.setCategory(entry.getKey());
categoryGroup.setAirTypeList(entry.getValue());
categoryGroups.add(categoryGroup);
}
groupVO.setCategoryGroups(categoryGroups);
vendorGroupList.add(groupVO);
}
}
return R.ok(vendorGroupList);
}
}

View File

@ -55,7 +55,7 @@ public interface IDeviceAirTypeGeneralEnumDomain
* 批量删除无人机类型通用枚举
*
* @param ids 需要删除的主键集合
* @return 结果
* @return 影响行数
*/
int deleteAirTypeGeneralEnumByIds(Long[] ids);
}

View File

@ -41,5 +41,11 @@ public class DeviceAirTypeGeneralEnum extends BaseEntity
/** 图标 */
private String icon;
/** 分类 */
private String category;
/** 是否生效0-失效1-生效 */
private Integer enabled;
}

View File

@ -48,12 +48,24 @@ public class DeviceAirTypeGeneralEnumEntity extends BaseEntity {
*/
private String icon;
/**
* 分类
*/
private String category;
/**
* 是否生效0-失效1-生效
*/
private Integer enabled;
@Override
public String toString() {
return "DeviceAirTypeGeneralEnumEntity{" +
"id=" + id +
", name='" + name + "'" +
", category='" + category + "'" +
", enabled=" + enabled +
", vendorId=" + vendorId +
", domain=" + domain +
", type=" + type +

View File

@ -41,4 +41,10 @@ public class DeviceAirTypeGeneralEnumDTO extends BaseEntity
/** 图标 */
private String icon;
/** 分类 */
private String category;
/** 是否生效0-失效1-生效 */
private Integer enabled;
}

View File

@ -3,6 +3,8 @@
CREATE TABLE IF NOT EXISTS `device_air_type_general_enum` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` VARCHAR(255) DEFAULT NULL COMMENT '名称',
`category` VARCHAR(255) DEFAULT NULL COMMENT '分类',
`enabled` TINYINT DEFAULT 0 COMMENT '是否生效0-失效1-生效',
`vendor_id` BIGINT DEFAULT NULL COMMENT '厂商ID',
`domain` BIGINT DEFAULT NULL COMMENT '领域',
`type` BIGINT DEFAULT NULL COMMENT '主类型',
@ -18,37 +20,37 @@ CREATE TABLE IF NOT EXISTS `device_air_type_general_enum` (
-- Matrice 系列
INSERT INTO device_air_type_general_enum (name, vendor_id, domain, type, sub_type, remark) VALUES
('Matrice 400', 1, 0, 103, 0, '-'),
('Matrice 350 RTK', 1, 0, 89, 0, '-'),
('Matrice 300 RTK', 1, 0, 60, 0, '-'),
('Matrice 30', 1, 0, 67, 0, '-'),
('Matrice 30T', 1, 0, 67, 1, '-'),
('Matrice 3D', 1, 0, 91, 0, '-'),
('Matrice 3TD', 1, 0, 91, 1, '-'),
('Matrice 4D', 1, 0, 100, 0, '-'),
('Matrice 4TD', 1, 0, 100, 1, '-');
INSERT INTO device_air_type_general_enum (name, category, enabled, vendor_id, domain, type, sub_type, remark) VALUES
('Matrice 400', 'Matrice', 1, 1, 0, 103, 0, '-'),
('Matrice 350 RTK', 'Matrice', 1, 1, 0, 89, 0, '-'),
('Matrice 300 RTK', 'Matrice', 1, 1, 0, 60, 0, '-'),
('Matrice 30', 'Matrice', 1, 1, 0, 67, 0, '-'),
('Matrice 30T', 'Matrice', 1, 1, 0, 67, 1, '-'),
('Matrice 3D', 'Matrice', 1, 1, 0, 91, 0, '-'),
('Matrice 3TD', 'Matrice', 1, 1, 0, 91, 1, '-'),
('Matrice 4D', 'Matrice', 1, 1, 0, 100, 0, '-'),
('Matrice 4TD', 'Matrice', 1, 1, 0, 100, 1, '-');
-- Mavic 3 行业系列
INSERT INTO device_air_type_general_enum (name, vendor_id, domain, type, sub_type, remark) VALUES
('Mavic 3 行业系列 (M3E 相机)', 1, 0, 77, 0, '-'),
('Mavic 3 行业系列 (M3T 相机)', 1, 0, 77, 1, '-'),
('Mavic 3 行业系列 (M3TA 相机)', 1, 0, 77, 3, '-');
INSERT INTO device_air_type_general_enum (name, category, enabled, vendor_id, domain, type, sub_type, remark) VALUES
('Mavic 3 行业系列 (M3E 相机)', 'Mavic', 0, 1, 0, 77, 0, '-'),
('Mavic 3 行业系列 (M3T 相机)', 'Mavic', 0, 1, 0, 77, 1, '-'),
('Mavic 3 行业系列 (M3TA 相机)', 'Mavic', 0, 1, 0, 77, 3, '-');
-- DJI Matrice 4 系列
INSERT INTO device_air_type_general_enum (name, vendor_id, domain, type, sub_type, remark) VALUES
('DJI Matrice 4 系列 (M4E 相机)', 1, 0, 99, 0, '-'),
('DJI Matrice 4 系列 (M4T 相机)', 1, 0, 99, 1, '-');
INSERT INTO device_air_type_general_enum (name, category, enabled, vendor_id, domain, type, sub_type, remark) VALUES
('DJI Matrice 4 系列 (M4E 相机)', 'Matrice', 0, 1, 0, 99, 0, '-'),
('DJI Matrice 4 系列 (M4T 相机)', 'Matrice', 0, 1, 0, 99, 1, '-');
-- 遥控器系列
INSERT INTO device_air_type_general_enum (name, vendor_id, domain, type, sub_type, remark) VALUES
('DJI 带屏遥控器行业版', 1, 2, 56, 0, '搭配 Matrice 300 RTK'),
('DJI RC Plus', 1, 2, 119, 0, '搭配 Matrice 350 RTK,Matrice 300 RTK,Matrice 30/30T'),
('DJI RC Plus 2', 1, 2, 174, 0, '搭配 >DJI Matrice 4 系列'),
('DJI RC Pro 行业版', 1, 2, 144, 0, '搭配 Mavic 3 行业系列');
INSERT INTO device_air_type_general_enum (name, category, enabled, vendor_id, domain, type, sub_type, remark) VALUES
('DJI 带屏遥控器行业版', '遥控器', 0, 1, 2, 56, 0, '搭配 Matrice 300 RTK'),
('DJI RC Plus', '遥控器', 0, 1, 2, 119, 0, '搭配 Matrice 350 RTK,Matrice 300 RTK,Matrice 30/30T'),
('DJI RC Plus 2', '遥控器', 0, 1, 2, 174, 0, '搭配 >DJI Matrice 4 系列'),
('DJI RC Pro 行业版', '遥控器', 0, 1, 2, 144, 0, '搭配 Mavic 3 行业系列');
-- 大疆机场系列
INSERT INTO device_air_type_general_enum (name, vendor_id, domain, type, sub_type, remark) VALUES
('大疆机场', 1, 3, 1, 0, '-'),
('大疆机场 2', 1, 3, 2, 0, '-'),
('大疆机场 3', 1, 3, 3, 0, '-');
INSERT INTO device_air_type_general_enum (name, category, enabled, vendor_id, domain, type, sub_type, remark) VALUES
('大疆机场', '机场', 0, 1, 3, 1, 0, '-'),
('大疆机场 2', '机场', 0, 1, 3, 2, 0, '-'),
('大疆机场 3', '机场', 0, 1, 3, 3, 0, '-');

View File

@ -7,6 +7,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.ruoyi.device.mapper.entity.DeviceAirTypeGeneralEnumEntity" id="AirTypeGeneralEnumResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="category" column="category" />
<result property="enabled" column="enabled" />
<result property="vendorId" column="vendor_id" />
<result property="domain" column="domain" />
<result property="type" column="type" />
@ -20,19 +22,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAirTypeGeneralEnumVo">
select id, name, vendor_id, domain, type, sub_type, icon,
select id, name, category, enabled, vendor_id, domain, type, sub_type, icon,
create_by, create_time, update_by, update_time, remark
from device_air_type_general_enum
</sql>
<select id="selectAirTypeGeneralEnumById" parameterType="Long" resultMap="AirTypeGeneralEnumResult">
<include refid="selectAirTypeGeneralEnumVo"/>
where id = #{id}
where id = #{id} and enabled = 1
</select>
<select id="selectAirTypeGeneralEnumList" parameterType="com.ruoyi.device.mapper.entity.DeviceAirTypeGeneralEnumEntity" resultMap="AirTypeGeneralEnumResult">
<include refid="selectAirTypeGeneralEnumVo"/>
<where>
enabled = 1
<if test="name != null and name != ''">
and name like concat('%', #{name}, '%')
</if>
@ -55,6 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into device_air_type_general_enum
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="category != null and category != ''">category,</if>
<if test="enabled != null">enabled,</if>
<if test="vendorId != null">vendor_id,</if>
<if test="domain != null">domain,</if>
<if test="type != null">type,</if>
@ -66,6 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="category != null and category != ''">#{category},</if>
<if test="enabled != null">#{enabled},</if>
<if test="vendorId != null">#{vendorId},</if>
<if test="domain != null">#{domain},</if>
<if test="type != null">#{type},</if>
@ -81,6 +88,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update device_air_type_general_enum
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="category != null and category != ''">category = #{category},</if>
<if test="enabled != null">enabled = #{enabled},</if>
<if test="vendorId != null">vendor_id = #{vendorId},</if>
<if test="domain != null">domain = #{domain},</if>
<if test="type != null">type = #{type},</if>