1.车辆开关命令发送
This commit is contained in:
parent
3ce298b53d
commit
56030b9d41
|
@ -208,8 +208,8 @@ lock:
|
|||
|
||||
iot:
|
||||
iotUrl: https://iot-api.heclouds.com/datapoint
|
||||
# 产品id 浇花器
|
||||
productId: 50dd83E8zQ
|
||||
# 产品id 电动车
|
||||
productId: 796mCwPk0F
|
||||
# 版本号 签名算法版本
|
||||
version: 2020-05-29
|
||||
# 用户资源信息 用户id
|
||||
|
|
|
@ -452,7 +452,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
String finalOrderNo = orderNo;
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** 2.发送命令*/
|
||||
// sendCommand(asDevice.getMac(), token,"开锁命令","编号开锁");
|
||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"编号开锁");
|
||||
/** 3.更新车辆状态*/
|
||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
|
||||
|
@ -513,7 +513,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
String token = Token.getToken();
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** 2.发送命令*/
|
||||
// sendCommand(asDevice.getMac(), token,"开锁命令","管理员开锁");
|
||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"管理员开锁");
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if(!execute)throw new ServiceException("管理员开锁失败");
|
||||
|
@ -629,6 +629,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
return integer;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
/** 发送命令*/
|
||||
public void sendCommand(String mac, String token,String command,String type) {
|
||||
|
@ -638,6 +639,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
log.info("【"+type+"】===>IOT请求调用结果:【{}】",result);
|
||||
JSONObject paramsObj = JSON.parseObject(result);
|
||||
String code = paramsObj.getString("code");
|
||||
//记录命令
|
||||
|
||||
if (!HttpStatus.IOT_SUCCESS.equals(code))
|
||||
{
|
||||
throw new ServiceException(code+"-----"+ IotUtil.formatMsg(code));
|
||||
|
@ -658,7 +661,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
String token = Token.getToken();
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** 2.发送命令*/
|
||||
// sendCommand(asDevice.getMac(), token,"响铃命令","响铃寻车");
|
||||
sendCommand(asDevice.getMac(), token,"响铃命令","响铃寻车");
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if(!execute)throw new ServiceException("响铃寻车失败");
|
||||
|
@ -686,7 +689,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** TODO 临时锁车*/
|
||||
/** 2.发送命令*/
|
||||
// sendCommand(asDevice.getMac(), token,"临时锁车命令","临时锁车");
|
||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_CLOSE,"临时锁车");
|
||||
if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户临时锁车
|
||||
/** 改变车辆状态:4-临时锁车 */
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车
|
||||
|
@ -735,7 +738,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** TODO 临时解锁*/
|
||||
/** 2.发送命令*/
|
||||
// sendCommand(asDevice.getMac(), token,"临时解锁命令","临时解锁");
|
||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"临时解锁");
|
||||
if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户骑行中解锁
|
||||
/** 改变车辆状态:3-骑行中 */
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);//骑行中
|
||||
|
@ -822,7 +825,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
if(ObjectUtil.isNotNull(appointmentVo.getRuleId())){
|
||||
//1.发送开锁命令并更新车辆状态
|
||||
String token = Token.getToken();
|
||||
// sendCommand(asDevice.getMac(), token,"开锁命令","取消预约开锁");
|
||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"取消预约开锁");
|
||||
order.setSn("");
|
||||
//TODO 记录行程
|
||||
/** 5.记录行程*/
|
||||
|
@ -908,9 +911,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
order.setReturnType(returnType);
|
||||
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
|
||||
order.setReturnTime(DateUtils.getNowDate());
|
||||
// String token = Token.getToken();
|
||||
String token = Token.getToken();
|
||||
/** 2. 车辆远程关锁*/
|
||||
// sendCommand(order.getSn(), token,"关锁命令","还车关锁");
|
||||
sendCommand(order.getSn(), token,IotConstants.COMMAND_CLOSE,"还车关锁");
|
||||
/** 4. 更新车辆状态*/
|
||||
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
||||
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSON;
|
|||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.IotConstants;
|
||||
import com.ruoyi.common.constant.ServiceConstants;
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
|
@ -15,6 +16,7 @@ import com.ruoyi.common.pay.wx.domain.NotifyEventType;
|
|||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.common.utils.onenet.Token;
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.domain.vo.AttachVo;
|
||||
import com.ruoyi.system.service.*;
|
||||
|
@ -25,6 +27,7 @@ import com.wechat.pay.java.service.payments.model.Transaction;
|
|||
import com.wechat.pay.java.service.refund.model.Refund;
|
||||
import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||
import com.wechat.pay.java.service.refund.model.Status;
|
||||
import lombok.SneakyThrows;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -88,6 +91,7 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
@SneakyThrows
|
||||
public void weChat(HttpServletRequest request) {
|
||||
String body = HttpUtils.getBody(request);
|
||||
logger.info("【微信支付回调】接收对象 : " + JSON.toJSONString(body));
|
||||
|
@ -112,6 +116,7 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
if(StrUtil.isNotBlank(order.getSn())){
|
||||
asDevice = asDeviceService.selectAsDeviceBySn(order.getSn());
|
||||
}
|
||||
String iotToken = Token.getToken();
|
||||
//先判断是骑行订单还是押金,如果是骑行订单
|
||||
// 还要区分是取消预约支付
|
||||
// 如果是,更新订单状态,pay_time、pay_type(默认是wx)、appointment_fee等于total_fee,状态改为4 订单结束
|
||||
|
@ -125,7 +130,7 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
// 1-骑行支付 关锁
|
||||
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
||||
order.setMark("骑行支付");
|
||||
// deviceService.sendCommand(order.getSn(), token,"开锁命令","套餐开锁");
|
||||
asDeviceService.sendCommand(order.getSn(), iotToken, IotConstants.COMMAND_OPEN,"套餐开锁");
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//还车后车辆正常运营
|
||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||
|
||||
|
@ -195,7 +200,7 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
order.setAppointmentStartTime(DateUtils.getNowDate());
|
||||
order.setMark("套餐预约支付");
|
||||
/** 2.发送命令*/
|
||||
// deviceService.sendCommand(order.getSn(), token,"关锁命令","套餐预约");
|
||||
asDeviceService.sendCommand(order.getSn(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约");
|
||||
/** 3.更新车辆状态*/
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);//预约中
|
||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||
|
@ -204,7 +209,7 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
order.setMark("套餐骑行支付");
|
||||
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);//骑行中
|
||||
/** 2.发送命令*/
|
||||
// deviceService.sendCommand(order.getSn(), token,"开锁命令","套餐开锁");
|
||||
asDeviceService.sendCommand(order.getSn(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁");
|
||||
/** 3.更新车辆状态*/
|
||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.IotConstants;
|
||||
import com.ruoyi.common.constant.ServiceConstants;
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
|
@ -392,7 +393,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
//校验 userI,sn,ruleId,type 3 isAppointment
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** 2.发送命令*/
|
||||
// deviceService.sendCommand(order.getSn(), token,"临时锁车命令","套餐预约");
|
||||
deviceService.sendCommand(order.getSn(), token, IotConstants.COMMAND_CLOSE,"套餐预约");
|
||||
/** 3.更新车辆状态*/
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车
|
||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||
|
@ -409,7 +410,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
/** 2.发送命令*/
|
||||
// deviceService.sendCommand(order.getSn(), token,"开锁命令","套餐开锁");
|
||||
deviceService.sendCommand(order.getSn(), token,IotConstants.COMMAND_OPEN,"套餐开锁");
|
||||
/** 3.更新车辆状态*/
|
||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING_STR);
|
||||
|
|
Loading…
Reference in New Issue
Block a user