feat(shop): 添加根据ID获取商店详情的接口

新增获取商店详情的功能,包括领域层服务方法和控制器接口
```

```msg
feat(cabinet): 新增10口机柜模板枚举值

在CabinetTemplateEnum中添加CABINET_10枚举值,用于支持10口机柜配置
```

```msg
feat(cabinet): 拆分智能柜列表接口为分页和非分页版本

将原智能柜列表接口拆分为getSmartCabinetPage和getSmartCabinetList
分别用于分页查询和普通列表查询
```

```msg
refactor(mqtt): 优化MQTT连接日志信息

在MQTT连接和消息发送日志中添加主题信息,便于调试和问题排查
This commit is contained in:
dzq 2025-06-13 11:51:45 +08:00
parent 9cc755f83c
commit ad1d764991
6 changed files with 46 additions and 6 deletions

View File

@ -42,8 +42,15 @@ public class SmartCabinetController extends BaseController {
@Operation(summary = "智能柜列表") @Operation(summary = "智能柜列表")
@GetMapping @GetMapping
public ResponseDTO<PageDTO<SmartCabinetDTO>> list(SearchSmartCabinetQuery<SmartCabinetEntity> query) { public ResponseDTO<PageDTO<SmartCabinetDTO>> page(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
PageDTO<SmartCabinetDTO> page = smartCabinetApplicationService.getSmartCabinetList(query); PageDTO<SmartCabinetDTO> page = smartCabinetApplicationService.getSmartCabinetPage(query);
return ResponseDTO.ok(page);
}
@Operation(summary = "智能柜列表")
@GetMapping("/list")
public ResponseDTO<List<SmartCabinetDTO>> list(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
List<SmartCabinetDTO> page = smartCabinetApplicationService.getSmartCabinetList(query);
return ResponseDTO.ok(page); return ResponseDTO.ok(page);
} }

View File

@ -107,6 +107,13 @@ public class ShopController extends BaseController {
return ResponseDTO.ok(page); return ResponseDTO.ok(page);
} }
@Operation(summary = "获取商店详情")
@GetMapping("/{id}")
public ResponseDTO<ShopDTO> getShopById(@PathVariable Long id) {
ShopDTO shopDTO = shopApplicationService.getShopById(id);
return ResponseDTO.ok(shopDTO);
}
@Operation(summary = "新增商店") @Operation(summary = "新增商店")
@AccessLog(title = "商店管理", businessType = BusinessTypeEnum.ADD) @AccessLog(title = "商店管理", businessType = BusinessTypeEnum.ADD)
@PostMapping @PostMapping

View File

@ -22,7 +22,9 @@ public enum CabinetTemplateEnum {
/** 120口机柜模板(6X20)6块主板每块主板20个单元格 */ /** 120口机柜模板(6X20)6块主板每块主板20个单元格 */
CABINET_120(8, "cabinet_120.jpg", "120口机柜", 6, 20), CABINET_120(8, "cabinet_120.jpg", "120口机柜", 6, 20),
/** 4口机柜模板1块主板每块主板4个单元格 */ /** 4口机柜模板1块主板每块主板4个单元格 */
CABINET_4(9, "cabinet_4.jpg","4口机柜", 1, 4); CABINET_4(9, "cabinet_4.jpg","4口机柜", 1, 4),
/** 10口机柜模板1块主板每块主板10个单元格 */
CABINET_10(1, "cabinet_16.jpg", "10口机柜", 1, 10);
/** 模板代码 */ /** 模板代码 */
private final int code; private final int code;

View File

@ -45,7 +45,7 @@ public class SmartCabinetApplicationService {
private final CabinetMainboardModelFactory cabinetMainboardModelFactory; private final CabinetMainboardModelFactory cabinetMainboardModelFactory;
private final CabinetCellModelFactory cabinetCellModelFactory; private final CabinetCellModelFactory cabinetCellModelFactory;
public PageDTO<SmartCabinetDTO> getSmartCabinetList(SearchSmartCabinetQuery<SmartCabinetEntity> query) { public PageDTO<SmartCabinetDTO> getSmartCabinetPage(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
List<ShopEntity> shopEntities = shopService.selectAll(); List<ShopEntity> shopEntities = shopService.selectAll();
Page<SmartCabinetEntity> page = smartCabinetService.getCabinetList(query); Page<SmartCabinetEntity> page = smartCabinetService.getCabinetList(query);
@ -64,6 +64,24 @@ public class SmartCabinetApplicationService {
return new PageDTO<>(dtoList, page.getTotal()); return new PageDTO<>(dtoList, page.getTotal());
} }
public List<SmartCabinetDTO> getSmartCabinetList(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
List<ShopEntity> shopEntities = shopService.selectAll();
List<SmartCabinetDTO> dtoList = smartCabinetService.list(query.toQueryWrapper()).stream()
.map(SmartCabinetDTO::new)
.collect(Collectors.toList());
dtoList.forEach(dto ->
dto.setShopName(
shopEntities.stream()
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
.findFirst()
.map(ShopEntity::getShopName)
.orElse(""))
);
return dtoList;
}
public SmartCabinetDTO getSmartCabinetById(Long cabinetId) { public SmartCabinetDTO getSmartCabinetById(Long cabinetId) {
SmartCabinetEntity cabinet = smartCabinetService.getById(cabinetId); SmartCabinetEntity cabinet = smartCabinetService.getById(cabinetId);
SmartCabinetDTO dto = new SmartCabinetDTO(cabinet); SmartCabinetDTO dto = new SmartCabinetDTO(cabinet);

View File

@ -66,7 +66,7 @@ public class MqttService implements MqttCallback {
if (existingConfig != null) { if (existingConfig != null) {
existingConfig.client.subscribe(config.getTopicFilter()); existingConfig.client.subscribe(config.getTopicFilter());
clientConfigs.add(new ClientConfig(existingConfig.client, config)); clientConfigs.add(new ClientConfig(existingConfig.client, config));
log.info("复用已有MQTT连接{} 账号:{}", config.getServerUrl(), config.getUsername()); log.info("复用已有MQTT连接{} 账号:{} 主题:{}", config.getServerUrl(), config.getUsername(), config.getPublishTopic());
continue; continue;
} }
@ -88,7 +88,7 @@ public class MqttService implements MqttCallback {
client.connect(options); client.connect(options);
client.subscribe(config.getTopicFilter()); client.subscribe(config.getTopicFilter());
clientConfigs.add(new ClientConfig(client, config)); clientConfigs.add(new ClientConfig(client, config));
log.info("成功连接MQTT服务器{} 账号:{}", config.getServerUrl(), config.getUsername()); log.info("成功连接MQTT服务器{} 账号:{} 主题:{}", config.getServerUrl(), config.getUsername(), config.getPublishTopic());
} }
} }
@ -104,6 +104,7 @@ public class MqttService implements MqttCallback {
.filter(cc -> cc.config.getMqttServerId().equals(mqttServerId)) .filter(cc -> cc.config.getMqttServerId().equals(mqttServerId))
.forEach(cc -> { .forEach(cc -> {
try { try {
log.info("发送消息到主题:{} 消息:{}", cc.config.getPublishTopic(), data + bcc);
cc.client.publish(cc.config.getPublishTopic(), message); cc.client.publish(cc.config.getPublishTopic(), message);
} catch (MqttException e) { } catch (MqttException e) {
log.error("消息发送失败", e); log.error("消息发送失败", e);

View File

@ -32,6 +32,11 @@ public class ShopApplicationService {
return new PageDTO<>(dtoList, page.getTotal()); return new PageDTO<>(dtoList, page.getTotal());
} }
public ShopDTO getShopById(Long shopId) {
ShopEntity shopEntity = shopService.getById(shopId);
return new ShopDTO(shopEntity);
}
public List<ShopEntity> getShopListByCorpid(String corpid) { public List<ShopEntity> getShopListByCorpid(String corpid) {
return shopService.getShopListByCorpid(corpid); return shopService.getShopListByCorpid(corpid);
} }