站控请求云端的mqtt
This commit is contained in:
parent
24f0b6607f
commit
f9d4ee19c9
@ -0,0 +1,58 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.request;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.service.BatteryStationService;
|
||||
import com.evotech.hd.cloud.utils.DateUtils;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStation;
|
||||
import com.evotech.hd.common.core.utils.Collections;
|
||||
import com.evotech.hd.common.core.utils.DataUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 站端状态监控
|
||||
*
|
||||
* @ClassName:MqttRequestPushCarCreateMakeAppointmentExchangeProcessorImpl
|
||||
* @date: 2025年04月30日 15:34
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MqttRequestBatteryStatusExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
BatteryStationService batteryStationService;
|
||||
|
||||
@Override
|
||||
public boolean accept(String functionName) {
|
||||
return RequestFunctionTypesEnum.FUN_BATTERY_STATUS.getFunction().equals(functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
log.info("MqttRequestBatteryStatusExchangeProcessorImpl-->>>>> 请求参数{}", JSONUtil.toJsonStr(dataBody));
|
||||
|
||||
MqttResponse response = null;
|
||||
BatteryStation batteryStation = batteryStationService.getBatteryStationByCode(topic.getStationCode());
|
||||
if(batteryStation != null) {
|
||||
response = new MqttResponse().success(Collections.asMap("status", DataUtils.findDefaultValue(batteryStation.getStop(), false),
|
||||
"stopMinutes", DateUtils.getBetweenMinutes(new Date(),DataUtils.findDefaultValue(batteryStation.getStopTime(), new Date())),
|
||||
"stopTip", batteryStation.getStopTip()));
|
||||
}else{
|
||||
response = new MqttResponse().error("站点信息未找到");
|
||||
}
|
||||
logger.info("\r\n接收站端推送的车牌照, 创建车辆信息和预约单: MqttRequestPushCarInfoExchangeProcessorImpl =====>>>message:{}", response.getMsg());
|
||||
sendAESMessage(topic, header, RequestFunctionTypesEnum.FUN_BATTERY_STATUS, response);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user