From 55a9d49a3414a9f48beac520c850f6eb65afe687 Mon Sep 17 00:00:00 2001
From: Gjm <你的邮箱>
Date: Wed, 8 Apr 2026 15:27:29 +0800
Subject: [PATCH] =?UTF-8?q?feat(iot):=20=E6=89=A9=E5=B1=95=E4=BA=A7?=
=?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E5=92=8C=E8=AE=BE=E5=A4=87=E5=88=86?=
=?UTF-8?q?=E7=BB=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在Category实体类中添加parentId和industryCode字段并集成lombok@Data注解
- 在Group实体类中添加parentId和industryCode字段并集成lombok@Data注解
- 更新Category和Group的数据映射文件以支持新字段的数据库操作
- 修改Product查询逻辑以通过左连接获取正确的分类名称
- 在产品创建服务中添加分类名称的自动设置功能
Signed-off-by: Gjm <你的邮箱>
---
.../java/iot/lidee/iot/domain/Category.java | 131 +++++++++++-------
.../main/java/iot/lidee/iot/domain/Group.java | 7 +
.../iot/service/impl/ProductServiceImpl.java | 9 +-
.../resources/mapper/iot/CategoryMapper.xml | 13 +-
.../main/resources/mapper/iot/GroupMapper.xml | 10 +-
.../resources/mapper/iot/ProductMapper.xml | 11 +-
6 files changed, 119 insertions(+), 62 deletions(-)
diff --git a/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Category.java b/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Category.java
index 88219e3..38d4a60 100644
--- a/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Category.java
+++ b/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Category.java
@@ -3,6 +3,7 @@ package iot.lidee.iot.domain;
import iot.lidee.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import iot.lidee.common.annotation.Excel;
@@ -14,40 +15,53 @@ import iot.lidee.common.annotation.Excel;
* @date 2021-12-16
*/
@ApiModel(value = "Category", description = "产品分类对象 iot_category")
-public class Category extends BaseEntity
-{
+public class Category extends BaseEntity {
private static final long serialVersionUID = 1L;
- /** 产品分类ID */
+ /**
+ * 产品分类ID
+ */
@ApiModelProperty("产品分类ID")
private Long categoryId;
- /** 产品分类名称 */
+ /**
+ * 产品分类名称
+ */
@ApiModelProperty("产品分类名称")
@Excel(name = "产品分类名称")
private String categoryName;
- /** 租户ID */
+ /**
+ * 租户ID
+ */
@ApiModelProperty("租户ID")
@Excel(name = "租户ID")
private Long tenantId;
- /** 租户名称 */
+ /**
+ * 租户名称
+ */
@ApiModelProperty("租户名称")
@Excel(name = "租户名称")
private String tenantName;
- /** 是否系统通用(0-否,1-是) */
+ /**
+ * 是否系统通用(0-否,1-是)
+ */
@ApiModelProperty("是否系统通用(0-否,1-是)")
@Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是")
private Integer isSys;
- /** 显示顺序 */
+ /**
+ * 显示顺序
+ */
@ApiModelProperty("显示顺序")
@Excel(name = "显示顺序")
private Integer orderNum;
- /** 删除标志(0代表存在 2代表删除) */
+ /**
+ * 删除标志(0代表存在 2代表删除)
+ */
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
private String delFlag;
@@ -60,6 +74,10 @@ public class Category extends BaseEntity
@ApiModelProperty("机构ID")
private Long deptId;
+ private Long parentId;
+
+ private String industryCode;
+
public Boolean getShowSenior() {
return showSenior;
}
@@ -84,84 +102,95 @@ public class Category extends BaseEntity
isAdmin = admin;
}
- public void setCategoryId(Long categoryId)
- {
+ public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
- public Long getCategoryId()
- {
+ public Long getCategoryId() {
return categoryId;
}
- public void setCategoryName(String categoryName)
- {
+
+ public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
- public String getCategoryName()
- {
+ public String getCategoryName() {
return categoryName;
}
- public void setTenantId(Long tenantId)
- {
+
+ public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
- public Long getTenantId()
- {
+ public Long getTenantId() {
return tenantId;
}
- public void setTenantName(String tenantName)
- {
+
+ public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
- public String getTenantName()
- {
+ public String getTenantName() {
return tenantName;
}
- public void setIsSys(Integer isSys)
- {
+
+ public void setIsSys(Integer isSys) {
this.isSys = isSys;
}
- public Integer getIsSys()
- {
+
+ public Integer getIsSys() {
return isSys;
}
- public void setOrderNum(Integer orderNum)
- {
+ public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
- public Integer getOrderNum()
- {
+
+ public Integer getOrderNum() {
return orderNum;
}
- public void setDelFlag(String delFlag)
- {
+
+ public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
- public String getDelFlag()
- {
+ public String getDelFlag() {
return delFlag;
}
+ public Long getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(Long parentId) {
+ this.parentId = parentId;
+ }
+
+ public String getIndustryCode() {
+ return industryCode;
+ }
+
+ public void setIndustryCode(String industryCode) {
+ this.industryCode = industryCode;
+ }
+
@Override
public String toString() {
- return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
- .append("categoryId", getCategoryId())
- .append("categoryName", getCategoryName())
- .append("tenantId", getTenantId())
- .append("tenantName", getTenantName())
- .append("isSys", getIsSys())
- .append("orderNum", getOrderNum())
- .append("delFlag", getDelFlag())
- .append("createBy", getCreateBy())
- .append("createTime", getCreateTime())
- .append("updateBy", getUpdateBy())
- .append("updateTime", getUpdateTime())
- .append("remark", getRemark())
- .toString();
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+ .append("categoryId", getCategoryId())
+ .append("categoryName", getCategoryName())
+ .append("tenantId", getTenantId())
+ .append("tenantName", getTenantName())
+ .append("isSys", getIsSys())
+ .append("orderNum", getOrderNum())
+ .append("delFlag", getDelFlag())
+ .append("createBy", getCreateBy())
+ .append("createTime", getCreateTime())
+ .append("updateBy", getUpdateBy())
+ .append("updateTime", getUpdateTime())
+ .append("remark", getRemark())
+ .append("parentId", getParentId())
+ .append("industryCode", getIndustryCode())
+ .toString();
}
}
diff --git a/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Group.java b/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Group.java
index 949eff4..10786bb 100644
--- a/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Group.java
+++ b/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/domain/Group.java
@@ -2,6 +2,7 @@ package iot.lidee.iot.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import iot.lidee.common.annotation.Excel;
@@ -14,6 +15,7 @@ import iot.lidee.common.core.domain.BaseEntity;
* @date 2021-12-16
*/
@ApiModel(value = "Group", description = "设备分组对象 iot_group")
+@Data
public class Group extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -46,6 +48,11 @@ public class Group extends BaseEntity
@ApiModelProperty("删除标志")
private String delFlag;
+
+ private Long parentId;
+
+ private String industryCode;
+
public void setGroupId(Long groupId)
{
this.groupId = groupId;
diff --git a/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/service/impl/ProductServiceImpl.java b/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/service/impl/ProductServiceImpl.java
index 63a5caf..3f06ed3 100644
--- a/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/service/impl/ProductServiceImpl.java
+++ b/lidee-service/lidee-iot-service/src/main/java/iot/lidee/iot/service/impl/ProductServiceImpl.java
@@ -7,10 +7,7 @@ import iot.lidee.common.core.redis.RedisKeyBuilder;
import iot.lidee.common.utils.DateUtils;
import iot.lidee.common.utils.StringUtils;
import iot.lidee.iot.cache.ITSLCache;
-import iot.lidee.iot.domain.Device;
-import iot.lidee.iot.domain.Product;
-import iot.lidee.iot.domain.ProductModbusJob;
-import iot.lidee.iot.domain.ProductSubGateway;
+import iot.lidee.iot.domain.*;
import iot.lidee.iot.mapper.*;
import iot.lidee.iot.mapper.*;
import iot.lidee.iot.model.ChangeProductStatusModel;
@@ -60,6 +57,8 @@ public class ProductServiceImpl implements IProductService {
private ProductSubGatewayMapper productSubGatewayMapper;
@Resource
private ProductModbusJobMapper productModbusJobMapper;
+ @Resource
+ private CategoryMapper categoryMapper;
// select cache
@@ -253,6 +252,8 @@ public class ProductServiceImpl implements IProductService {
}
product.setStatus(product.getStatus() == null ? 1 : product.getStatus());
product.setCreateTime(DateUtils.getNowDate());
+ Category category = categoryMapper.selectCategoryByCategoryId(product.getCategoryId());
+ product.setCategoryName(category.getCategoryName());
productMapper.insertProduct(product);
return product;
}
diff --git a/lidee-service/lidee-iot-service/src/main/resources/mapper/iot/CategoryMapper.xml b/lidee-service/lidee-iot-service/src/main/resources/mapper/iot/CategoryMapper.xml
index 41fbbc9..fa5a56d 100644
--- a/lidee-service/lidee-iot-service/src/main/resources/mapper/iot/CategoryMapper.xml
+++ b/lidee-service/lidee-iot-service/src/main/resources/mapper/iot/CategoryMapper.xml
@@ -14,6 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
@@ -22,12 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category
+ select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark, parent_id, industry_code from iot_category