feat(智能柜): 添加主柜ID字段并优化查询逻辑
在智能柜系统中,新增`main_cabinet`字段以标识副柜的归属主柜,并更新相关DTO、Entity和Mapper以支持该字段。同时,优化了查询逻辑,确保查询条件与表别名一致,避免潜在的SQL错误。
This commit is contained in:
parent
71329ffe0a
commit
3fe5778ea0
|
@ -39,6 +39,14 @@ public class SmartCabinetEntity extends BaseEntity<SmartCabinetEntity> {
|
|||
@TableField("cabinet_type")
|
||||
private Integer cabinetType;
|
||||
|
||||
@ApiModelProperty("归属主柜ID")
|
||||
@TableField("main_cabinet")
|
||||
private Long mainCabinet;
|
||||
|
||||
@ApiModelProperty("归属主柜名称")
|
||||
@TableField(exist = false)
|
||||
private String mainCabinetName;
|
||||
|
||||
@ApiModelProperty("MQTT服务ID")
|
||||
@TableField("mqtt_server_id")
|
||||
private Long mqttServerId;
|
||||
|
|
|
@ -17,8 +17,9 @@ import java.util.List;
|
|||
* @since 2025-03-17
|
||||
*/
|
||||
public interface SmartCabinetMapper extends BaseMapper<SmartCabinetEntity> {
|
||||
@Select("SELECT cabinet_id, cabinet_name, cabinet_type, template_no, lock_control_no, location " +
|
||||
"FROM smart_cabinet " +
|
||||
@Select("SELECT sc.*, scl.cabinet_name AS mainCabinetName " +
|
||||
"FROM smart_cabinet sc " +
|
||||
"LEFT JOIN smart_cabinet scl ON scl.cabinet_id = sc.main_cabinet " +
|
||||
"${ew.customSqlSegment}")
|
||||
Page<SmartCabinetEntity> getCabinetList(
|
||||
Page<SmartCabinetEntity> page,
|
||||
|
|
|
@ -20,7 +20,7 @@ public class SmartCabinetServiceImpl extends ServiceImpl<SmartCabinetMapper, Sma
|
|||
|
||||
@Override
|
||||
public Page<SmartCabinetEntity> getCabinetList(AbstractPageQuery<SmartCabinetEntity> query) {
|
||||
return this.page(query.toPage(), query.toQueryWrapper());
|
||||
return baseMapper.getCabinetList(query.toPage(), query.toQueryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,6 +34,12 @@ public class SmartCabinetDTO {
|
|||
@ExcelColumn(name = "柜机类型(0主柜 1副柜)")
|
||||
private Integer cabinetType;
|
||||
|
||||
@ExcelColumn(name = "归属主柜ID")
|
||||
private Long mainCabinet;
|
||||
|
||||
@ExcelColumn(name = "归属主柜名称")
|
||||
private String mainCabinetName;
|
||||
|
||||
@ExcelColumn(name = "MQTT服务ID")
|
||||
private Long mqttServerId;
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@ public class SearchSmartCabinetQuery<T> extends AbstractPageQuery<T> {
|
|||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotEmpty(cabinetName), "cabinet_name", cabinetName)
|
||||
.eq(cabinetType != null, "cabinet_type", cabinetType)
|
||||
.eq(mqttServerId!= null, "mqtt_server_id", mqttServerId)
|
||||
.eq(shopId!= null, "shop_id", shopId)
|
||||
.eq(StrUtil.isNotEmpty(templateNo), "template_no", templateNo)
|
||||
.eq("deleted", false)
|
||||
.between(startTime != null && endTime != null, "create_time", startTime, endTime);
|
||||
.like(StrUtil.isNotEmpty(cabinetName), "sc.cabinet_name", cabinetName)
|
||||
.eq(cabinetType != null, "sc.cabinet_type", cabinetType)
|
||||
.eq(mqttServerId!= null, "sc.mqtt_server_id", mqttServerId)
|
||||
.eq(shopId!= null, "sc.shop_id", shopId)
|
||||
.eq(StrUtil.isNotEmpty(templateNo), "sc.template_no", templateNo)
|
||||
.eq("sc.deleted", false)
|
||||
.between(startTime != null && endTime != null, "sc.create_time", startTime, endTime);
|
||||
|
||||
this.timeRangeColumn = "create_time";
|
||||
|
||||
|
|
|
@ -22,4 +22,9 @@ CREATE TABLE `ab98_user` (
|
|||
KEY `idx_openid` (`openid`),
|
||||
KEY `idx_tel` (`tel`),
|
||||
KEY `idx_name` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='汇邦云用户信息表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='汇邦云用户信息表';
|
||||
|
||||
|
||||
ALTER TABLE `smart_cabinet`
|
||||
ADD COLUMN `main_cabinet` BIGINT NULL COMMENT '归属主柜ID'
|
||||
AFTER `cabinet_type`;
|
Loading…
Reference in New Issue