云平台接口调整
This commit is contained in:
parent
90d74beb03
commit
9b6485db8d
@ -1,5 +1,6 @@
|
||||
package com.evotech.hd.common.core.entity.order;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
@ -74,4 +75,6 @@ public class Order extends BaseOrder{
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
@TableField(exist = false)
|
||||
private OrderDetail orderDetail;
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ package com.evotech.hd.cloud.open.processor;
|
||||
*/
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.evotech.hd.cloud.entity.MessageMqtt;
|
||||
import com.evotech.hd.cloud.service.MessageMqttService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
@ -31,6 +33,8 @@ public class StrategyFactory implements InitializingBean, ApplicationContextAwar
|
||||
|
||||
private static final Map<String, StationMessageStrategyExchangeProcessor> CONTEXT = new HashMap<>();
|
||||
|
||||
private static MessageMqttService messageMqttService;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
@ -42,11 +46,13 @@ public class StrategyFactory implements InitializingBean, ApplicationContextAwar
|
||||
applicationContext.getBeansOfType(StationMessageStrategyExchangeProcessor.class)
|
||||
.values()
|
||||
.forEach(exchange -> CONTEXT.putIfAbsent(exchange.getClass().getSimpleName().toLowerCase(), exchange));
|
||||
messageMqttService = applicationContext.getBean(MessageMqttService.class);
|
||||
}
|
||||
|
||||
public Result exchange(JSONObject json) {
|
||||
try {
|
||||
StationMessageStrategyExchangeProcessor processor = CONTEXT.get(json.getString("class").toLowerCase());
|
||||
log(json);
|
||||
if (ObjectUtils.isEmpty(processor)){
|
||||
return Result.getInstance().error("当前接口不存在");
|
||||
}
|
||||
@ -64,4 +70,16 @@ public class StrategyFactory implements InitializingBean, ApplicationContextAwar
|
||||
return Result.getInstance().error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void log(JSONObject json){
|
||||
MessageMqtt messageMqtt = new MessageMqtt();
|
||||
messageMqtt.setStationCode(json.getString("stationCode"));
|
||||
messageMqtt.setDirection("M2S");
|
||||
messageMqtt.setType("状态信息类");
|
||||
messageMqtt.setMessageFunction(json.getString("method"));
|
||||
messageMqtt.setTopic(json.getString("class"));
|
||||
messageMqtt.setContent(json.toJSONString());
|
||||
messageMqttService.add(messageMqtt);
|
||||
}
|
||||
// public void
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatusData;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.confirm.MqttConfirmSwapCompleteExchangeProcessorImpl;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.state.MqttStateSwapStepDataExchangeProcessor;
|
||||
import com.evotech.hd.cloud.open.processor.StationMessageStrategyExchangeProcessor;
|
||||
import com.evotech.hd.cloud.service.OrderDetailService;
|
||||
import com.evotech.hd.cloud.service.OrderService;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryPreService;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryStepService;
|
||||
@ -41,6 +42,8 @@ public class OrderSwapProcessor implements StationMessageStrategyExchangeProcess
|
||||
@Resource
|
||||
OrderService orderService;
|
||||
@Resource
|
||||
OrderDetailService orderDetailService;
|
||||
@Resource
|
||||
private OrderSwapBatteryStepService orderSwapBatteryStepService;
|
||||
@Resource
|
||||
private MqttStateSwapStepDataExchangeProcessor mqttStateSwapStepDataExchangeProcessor;
|
||||
@ -115,6 +118,7 @@ public class OrderSwapProcessor implements StationMessageStrategyExchangeProcess
|
||||
orderService.handleOrderStatus(orderStatus, statusData);
|
||||
//再次查询数据信息
|
||||
order = orderService.getById(json.getInteger("pkId"));
|
||||
order.setOrderDetail(orderDetailService.getOrderDetailByOrder(order.getPkId()));
|
||||
return Result.getInstance().build(JSONObject.class).success((JSONObject)JSONObject.toJSON(order));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -16,4 +16,6 @@ public interface OrderDetailService extends IService<OrderDetail> {
|
||||
|
||||
|
||||
public OrderDetail addOrderDetailByOrder(Integer orderId);
|
||||
|
||||
public OrderDetail getOrderDetailByOrder(Integer orderId);
|
||||
}
|
||||
|
||||
@ -36,6 +36,11 @@ public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailDao, OrderDet
|
||||
}
|
||||
return orderDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderDetail getOrderDetailByOrder(Integer orderId) {
|
||||
return getOne(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getOrderId, orderId), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -149,8 +149,10 @@ public class OrderSwapBatteryPreServiceImpl extends ServiceImpl<OrderSwapBattery
|
||||
RedisServiceUtils.set(redisKey, expireTime);
|
||||
// 发送服务号消息,没有消息队列,先用接口吧
|
||||
CloudTemplateMessageUtils.sendPreOrderMessage(orderSwapBatteryPre);
|
||||
//同步下发到站控
|
||||
pushStationControl(orderSwapBatteryPre);
|
||||
//数据来源不是站端的时候, 同步下发到站控
|
||||
if(!Integer.valueOf(3).equals(orderSwapBatteryPre.getSource())){
|
||||
pushStationControl(orderSwapBatteryPre);
|
||||
}
|
||||
return new Result<Boolean>().success(true);
|
||||
}
|
||||
return new Result<Boolean>().error("添加预约换电订单出错!", false);
|
||||
|
||||
@ -43,7 +43,7 @@ public class SendGzhController {
|
||||
return gzhMessageTemplateService.sendOrderToBeSettled(order);
|
||||
}
|
||||
|
||||
@Operation(summary = "推送公众号待结算订单消息")
|
||||
@Operation(summary = "推送站端报警消息")
|
||||
@PostMapping("/alarm/message")
|
||||
@ApiOperationSupport(order = 2)
|
||||
public Result<String> sendAlarmToMessage(@RequestBody AlarmTemplate alarmTemplate) {
|
||||
|
||||
@ -126,6 +126,8 @@ public class GZHMessageTemplateService {
|
||||
* @return
|
||||
*/
|
||||
public com.evotech.hd.common.core.Dto.Result<String> sendAlarmToMessage(AlarmTemplate alarmTemplate){
|
||||
|
||||
log.info("接收到的站端异常报警====>>>>>"+ com.alibaba.fastjson.JSONObject.toJSONString(alarmTemplate));
|
||||
if(alarmTemplate.getMessage().length() > 20){
|
||||
alarmTemplate.setMessage(alarmTemplate.getMessage().substring(0,19));
|
||||
}
|
||||
@ -140,7 +142,9 @@ public class GZHMessageTemplateService {
|
||||
return Result.getInstance().build(String.class).error("当前错误接口没有绑定微信通知人");
|
||||
}
|
||||
for (WechatUser wechatUser : wechatUsers){
|
||||
result.put(wechatUser.getName(), sendTemplateMessage(wechatUser.getGzhOpenid(), gzhProperties.getDeviceAlarmTemplateId(),JSONUtil.parseObj(alarmData), false).getData());
|
||||
String resultMessage = sendTemplateMessage(wechatUser.getGzhOpenid(), gzhProperties.getDeviceAlarmTemplateId(),JSONUtil.parseObj(alarmData), false).getData();
|
||||
log.info("接收到的站端异常报警====>>>>> 通知人:{}---->>>> 通知结果:{}", wechatUser.getName(), resultMessage);
|
||||
result.put(wechatUser.getName(), resultMessage);
|
||||
}
|
||||
}
|
||||
return Result.getInstance().build(String.class).success(com.alibaba.fastjson.JSONObject.toJSONString(result));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user