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:
parent
9cc755f83c
commit
ad1d764991
|
@ -42,8 +42,15 @@ public class SmartCabinetController extends BaseController {
|
|||
|
||||
@Operation(summary = "智能柜列表")
|
||||
@GetMapping
|
||||
public ResponseDTO<PageDTO<SmartCabinetDTO>> list(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
|
||||
PageDTO<SmartCabinetDTO> page = smartCabinetApplicationService.getSmartCabinetList(query);
|
||||
public ResponseDTO<PageDTO<SmartCabinetDTO>> page(SearchSmartCabinetQuery<SmartCabinetEntity> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,13 @@ public class ShopController extends BaseController {
|
|||
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 = "新增商店")
|
||||
@AccessLog(title = "商店管理", businessType = BusinessTypeEnum.ADD)
|
||||
@PostMapping
|
||||
|
|
|
@ -22,7 +22,9 @@ public enum CabinetTemplateEnum {
|
|||
/** 120口机柜模板(6X20),6块主板,每块主板20个单元格 */
|
||||
CABINET_120(8, "cabinet_120.jpg", "120口机柜", 6, 20),
|
||||
/** 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;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SmartCabinetApplicationService {
|
|||
private final CabinetMainboardModelFactory cabinetMainboardModelFactory;
|
||||
private final CabinetCellModelFactory cabinetCellModelFactory;
|
||||
|
||||
public PageDTO<SmartCabinetDTO> getSmartCabinetList(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
|
||||
public PageDTO<SmartCabinetDTO> getSmartCabinetPage(SearchSmartCabinetQuery<SmartCabinetEntity> query) {
|
||||
List<ShopEntity> shopEntities = shopService.selectAll();
|
||||
|
||||
Page<SmartCabinetEntity> page = smartCabinetService.getCabinetList(query);
|
||||
|
@ -64,6 +64,24 @@ public class SmartCabinetApplicationService {
|
|||
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) {
|
||||
SmartCabinetEntity cabinet = smartCabinetService.getById(cabinetId);
|
||||
SmartCabinetDTO dto = new SmartCabinetDTO(cabinet);
|
||||
|
|
|
@ -66,7 +66,7 @@ public class MqttService implements MqttCallback {
|
|||
if (existingConfig != null) {
|
||||
existingConfig.client.subscribe(config.getTopicFilter());
|
||||
clientConfigs.add(new ClientConfig(existingConfig.client, config));
|
||||
log.info("复用已有MQTT连接:{} 账号:{}", config.getServerUrl(), config.getUsername());
|
||||
log.info("复用已有MQTT连接:{} 账号:{} 主题:{}", config.getServerUrl(), config.getUsername(), config.getPublishTopic());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class MqttService implements MqttCallback {
|
|||
client.connect(options);
|
||||
client.subscribe(config.getTopicFilter());
|
||||
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))
|
||||
.forEach(cc -> {
|
||||
try {
|
||||
log.info("发送消息到主题:{} 消息:{}", cc.config.getPublishTopic(), data + bcc);
|
||||
cc.client.publish(cc.config.getPublishTopic(), message);
|
||||
} catch (MqttException e) {
|
||||
log.error("消息发送失败", e);
|
||||
|
|
|
@ -32,6 +32,11 @@ public class ShopApplicationService {
|
|||
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) {
|
||||
return shopService.getShopListByCorpid(corpid);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue