Merge remote-tracking branch 'origin/master' into wjh
# Conflicts: # ruoyi-service/src/main/java/com/ruoyi/bst/device/utils/DeviceUtil.java # ruoyi-service/src/main/java/com/ruoyi/bst/order/service/OrderService.java # ruoyi-service/src/main/java/com/ruoyi/bst/order/service/impl/OrderServiceImpl.java
This commit is contained in:
commit
08c4ddecdc
|
@ -3,7 +3,6 @@ package com.ruoyi.bst.areaSub.service.impl;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -19,6 +18,7 @@ import com.ruoyi.bst.areaSub.service.AreaSubService;
|
|||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.common.utils.map.GeoUtils;
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ public class DeviceVO extends Device {
|
|||
private BigDecimal modelLowVoltage;
|
||||
@ApiModelProperty("车型续航")
|
||||
private BigDecimal modelFullEndurance;
|
||||
@ApiModelProperty("车型是否允许用户打开坐垫锁")
|
||||
private Boolean modelEnableSeat;
|
||||
|
||||
// 运营区
|
||||
@ApiModelProperty("运营区名称")
|
||||
|
|
|
@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bm.full_voltage as model_full_voltage,
|
||||
bm.low_voltage as model_low_voltage,
|
||||
bm.full_endurance as model_full_endurance,
|
||||
bm.enable_seat as model_enable_seat,
|
||||
ba.name as area_name,
|
||||
ba.user_id as area_user_id,
|
||||
ba.undercharge as area_undercharge,
|
||||
|
@ -132,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.lastTimeStart != null">and bd.last_time >= #{query.lastTimeStart}</if>
|
||||
<if test="query.locationType != null and query.locationType != ''">and bd.location_type = #{query.locationType}</if>
|
||||
<if test="query.orderDeviceId != null">and bd.order_device_id = #{query.orderDeviceId}</if>
|
||||
<if test="query.modelEnableSeat != null">and bm.enable_seat = #{query.modelEnableSeat}</if>
|
||||
<if test="query.keyword != null and query.keyword != ''">
|
||||
and (
|
||||
bd.sn like concat('%', #{query.keyword}, '%')
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
@ -78,6 +79,9 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
@Autowired
|
||||
private OperLogService operLogService;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
private final static Integer SUB_FAST = 5; // 上报频率(快)
|
||||
private final static Integer SUB_SLOW = 300; // 上报频率(慢)
|
||||
private final static Integer SUB_X_SLOW = 50; // 上报频率(X开头硬件)
|
||||
|
@ -280,22 +284,25 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
}
|
||||
|
||||
// 获取物联网信息
|
||||
List<IotDeviceInfo> iotList = iotService.getDeviceInfo(deviceList);
|
||||
if (CollectionUtils.isEmptyElement(iotList)) {
|
||||
return;
|
||||
}
|
||||
// List<IotDeviceInfo> iotList = iotService.getDeviceInfo(deviceList);
|
||||
// if (CollectionUtils.isEmptyElement(iotList)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 更新设备信息
|
||||
// for (DeviceVO device : deviceList) {
|
||||
// if (device == null || StringUtils.isBlank(device.getMac())) {
|
||||
// continue;
|
||||
// }
|
||||
// IotDeviceInfo iot = iotList.stream()
|
||||
// .filter(item -> Objects.equals(item.getMac(), device.getMac()))
|
||||
// .findFirst().orElse(null);
|
||||
// DeviceUtil.setIotInfo(device, iot);
|
||||
// this.updateIot(device);
|
||||
// }
|
||||
|
||||
// 更新设备信息
|
||||
for (DeviceVO device : deviceList) {
|
||||
if (device == null || StringUtils.isBlank(device.getMac())) {
|
||||
continue;
|
||||
}
|
||||
IotDeviceInfo iot = iotList.stream()
|
||||
.filter(item -> Objects.equals(item.getMac(), device.getMac()))
|
||||
.findFirst().orElse(null);
|
||||
DeviceUtil.setIotInfo(device, iot);
|
||||
this.updateIot(device);
|
||||
}
|
||||
// 拼接物联网信息
|
||||
deviceAssembler.assembleIot(deviceList);
|
||||
|
||||
// 异步发送命令,强制设备上报数据
|
||||
if (onlineType != null) {
|
||||
|
@ -432,7 +439,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
try {
|
||||
// 获取设备最新信息
|
||||
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
||||
this.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
this.monitor(device);
|
||||
} catch (Exception e) {
|
||||
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
||||
|
@ -472,7 +479,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
@Override
|
||||
public void monitor(String mac) {
|
||||
DeviceVO device = deviceService.selectByMac(mac);
|
||||
this.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
this.monitor(device);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ public class DeviceUtil {
|
|||
|
||||
/**
|
||||
* 根据推送设置设备信息
|
||||
*
|
||||
*
|
||||
* @param device 设备
|
||||
* @param sys sys信息
|
||||
* @param at 时间
|
||||
|
@ -201,15 +201,18 @@ public class DeviceUtil {
|
|||
*/
|
||||
public static void setIotSysInfoByReceive(DeviceVO device, IotDeviceSysInfo sys, LocalDateTime at, boolean setNull) {
|
||||
setIotSysInfo(device, sys, at, setNull);
|
||||
|
||||
|
||||
device.setOnlineStatus(DeviceOnlineStatus.ONLINE.getStatus());
|
||||
device.setLastOnlineTime(at);
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆是否离线
|
||||
* 判断设备是否离线
|
||||
*
|
||||
* @param device 设备
|
||||
* @return 是否离线
|
||||
*/
|
||||
public static boolean isOffline(DeviceVO device) {
|
||||
return device != null && device.getOnlineStatus() != null && DeviceOnlineStatus.OFFLINE.getStatus().equals(device.getOnlineStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,10 @@ public class Model extends BaseEntity implements LogBizParam
|
|||
@Min(value = 0, message = "骑行低电量提醒不能小于0")
|
||||
private Integer lowBatteryReminder;
|
||||
|
||||
@Excel(name = "是否允许用户打开坐垫锁")
|
||||
@ApiModelProperty("是否允许用户打开坐垫锁")
|
||||
private Boolean enableSeat;
|
||||
|
||||
@Override
|
||||
public Object logBizId() {
|
||||
return id;
|
||||
|
|
|
@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bm.deleted,
|
||||
bm.low_battery_reminder_switch,
|
||||
bm.low_battery_reminder,
|
||||
bm.enable_seat,
|
||||
su.nick_name as user_name
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
@ -36,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.deleted == null "> and bm.deleted = false</if>
|
||||
<if test="query.lowBatteryReminderSwitch != null "> and bm.low_battery_reminder_switch = #{query.lowBatteryReminderSwitch}</if>
|
||||
<if test="query.userName != null and query.userName != ''"> and su.nick_name like concat('%', #{query.userName}, '%')</if>
|
||||
<if test="query.enableSeat != null "> and bm.enable_seat = #{query.enableSeat}</if>
|
||||
<if test="query.ids != null">
|
||||
and bm.id in
|
||||
<foreach item="item" collection="query.ids" open="(" separator="," close=")">
|
||||
|
@ -86,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="remark != null">remark,</if>
|
||||
<if test="lowBatteryReminderSwitch != null">low_battery_reminder_switch,</if>
|
||||
<if test="lowBatteryReminder != null">low_battery_reminder,</if>
|
||||
<if test="enableSeat != null">enable_seat,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="areaId != null">#{areaId},</if>
|
||||
|
@ -98,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="remark != null">#{remark},</if>
|
||||
<if test="lowBatteryReminderSwitch != null">#{lowBatteryReminderSwitch},</if>
|
||||
<if test="lowBatteryReminder != null">#{lowBatteryReminder},</if>
|
||||
<if test="enableSeat != null">#{enableSeat},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -119,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.remark != null">remark = #{data.remark},</if>
|
||||
<if test="data.lowBatteryReminderSwitch != null">low_battery_reminder_switch = #{data.lowBatteryReminderSwitch},</if>
|
||||
<if test="data.lowBatteryReminder != null">low_battery_reminder = #{data.lowBatteryReminder},</if>
|
||||
<if test="data.enableSeat != null">enable_seat = #{data.enableSeat},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteModelById" parameterType="Long">
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.bst.order.domain.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderSeatDTO {
|
||||
|
||||
@ApiModelProperty("订单ID")
|
||||
@NotNull(message = "订单ID不能为空")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("手机经度")
|
||||
private BigDecimal lon;
|
||||
|
||||
@ApiModelProperty("手机纬度")
|
||||
private BigDecimal lat;
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import com.ruoyi.bst.order.domain.dto.OrderDeductDTO;
|
|||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderSeatDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderVerifyDTO;
|
||||
import com.ruoyi.bst.order.domain.vo.OrderEndVO;
|
||||
import com.ruoyi.bst.order.domain.vo.OrderFeeVO;
|
||||
|
@ -81,7 +82,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 查询单个订单
|
||||
*
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 订单
|
||||
*/
|
||||
|
@ -89,7 +90,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
*
|
||||
* @param dto 创建订单DTO
|
||||
* @return 订单
|
||||
*/
|
||||
|
@ -97,7 +98,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
*
|
||||
* @param no 订单编号
|
||||
* @param scope 是否数据隔离
|
||||
* @return 订单
|
||||
|
@ -106,7 +107,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
*
|
||||
* @param no 订单编号
|
||||
* @return 订单
|
||||
*/
|
||||
|
@ -116,7 +117,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 取消订单
|
||||
*
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -124,7 +125,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 取消过期订单
|
||||
*
|
||||
*
|
||||
* @param order 订单
|
||||
*/
|
||||
public void cancelWhenExpired(Order order);
|
||||
|
@ -139,7 +140,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 计算订单金额
|
||||
*
|
||||
*
|
||||
* @param dto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -147,7 +148,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 退款
|
||||
*
|
||||
*
|
||||
* @param dto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -173,7 +174,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 更新订单设备ID
|
||||
*
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @param orderDeviceId 订单设备ID
|
||||
* @return 结果
|
||||
|
@ -182,7 +183,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 换车
|
||||
*
|
||||
*
|
||||
* @param dto 换车DTO
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -190,7 +191,7 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 还车审核
|
||||
*
|
||||
*
|
||||
* @param dto 审核DTO
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -198,25 +199,33 @@ public interface OrderService {
|
|||
|
||||
/**
|
||||
* 查询ID列表
|
||||
*
|
||||
*
|
||||
* @param query
|
||||
*/
|
||||
public List<Long> selectIdList(OrderQuery query);
|
||||
|
||||
/**
|
||||
* 更新订单距离
|
||||
*
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @param distance 距离
|
||||
*/
|
||||
public int updateDisatance(Long id, BigDecimal distance);
|
||||
|
||||
/**
|
||||
* 打开坐垫锁
|
||||
*
|
||||
* @param dto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean seat(OrderSeatDTO dto);
|
||||
|
||||
/**
|
||||
* 押金抵扣
|
||||
*
|
||||
*
|
||||
* @param dto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public int deduct(OrderDeductDTO dto);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -101,4 +101,9 @@ public interface OrderValidator {
|
|||
* 是否是用户
|
||||
*/
|
||||
boolean isUser(Long orderId, Long userId);
|
||||
|
||||
/**
|
||||
* 是否是用户
|
||||
*/
|
||||
boolean isUser(OrderVO order, Long userId);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.ruoyi.bst.areaSub.service.AreaSubService;
|
|||
import com.ruoyi.bst.channel.domain.ChannelVO;
|
||||
import com.ruoyi.bst.channel.service.ChannelService;
|
||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||
import com.ruoyi.bst.device.service.DeviceService;
|
||||
import com.ruoyi.bst.locationLog.domain.vo.LocationLogPositionVO;
|
||||
|
@ -112,6 +113,9 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
@Autowired
|
||||
private ModelAssembler modelAssembler;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
@Override
|
||||
public OrderPrePriceVO toOrderPrePriceVO(OrderCalcPrePriceDTO dto) {
|
||||
if (dto == null) {
|
||||
|
@ -363,7 +367,7 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
if (orderDevice != null) {
|
||||
// 获取当前设备信息
|
||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
bo.setDevice(device);
|
||||
}
|
||||
|
||||
|
@ -447,7 +451,7 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
|
||||
// 查询旧设备
|
||||
DeviceVO oldDevice = deviceService.selectDeviceById(oldOrderDevice.getDeviceId());
|
||||
deviceIotService.refresh(oldDevice, null);
|
||||
deviceAssembler.assembleIot(oldDevice);
|
||||
ServiceUtil.assertion(oldDevice == null, "ID为%s的旧设备不存在", oldOrderDevice.getDeviceId());
|
||||
bo.setOldDevice(oldDevice);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.ruoyi.bst.device.domain.DeviceVO;
|
|||
import com.ruoyi.bst.device.domain.enums.DeviceLocationType;
|
||||
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
||||
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
||||
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||
import com.ruoyi.bst.device.service.DeviceService;
|
||||
import com.ruoyi.bst.device.utils.DeviceUtil;
|
||||
|
@ -50,6 +51,7 @@ import com.ruoyi.bst.order.domain.dto.OrderDeductDTO;
|
|||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderSeatDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderVerifyDTO;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderPayType;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderReturnType;
|
||||
|
@ -85,6 +87,7 @@ import com.ruoyi.common.utils.MathUtils;
|
|||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.system.user.service.UserService;
|
||||
|
||||
|
@ -162,6 +165,9 @@ public class OrderServiceImpl implements OrderService {
|
|||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
|
@ -432,7 +438,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
order.setEndReason(dto.getEndReason());
|
||||
order.setReturnType(returnType);
|
||||
order.setStatus(OrderStatus.RIDE_WAIT_PAY.getCode());
|
||||
|
||||
|
||||
// 订单费用
|
||||
boolean needDispatchFee = dto.getNeedDispatchFee() != null && dto.getNeedDispatchFee();
|
||||
this.setOrderFee(order, area, inParkingVO, needDispatchFee);
|
||||
|
@ -482,8 +488,6 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
/**
|
||||
* 设置日志参数
|
||||
* @param lon 手机定位经度
|
||||
* @param lat 手机定位纬度
|
||||
* @param device 设备信息
|
||||
*/
|
||||
private void setLogParam(DeviceVO device) {
|
||||
|
@ -500,18 +504,14 @@ public class OrderServiceImpl implements OrderService {
|
|||
private void handleDeviceLocationAsync(DeviceVO device, BigDecimal lon, BigDecimal lat) {
|
||||
if (device != null && device.getId() != null && StringUtils.isNotBlank(device.getMac()) && DeviceUtil.validLocation(lon, lat)) {
|
||||
scheduledExecutorService.execute(() -> {
|
||||
device.setLongitude(lon);
|
||||
device.setLatitude(lat);
|
||||
device.setLocationType(DeviceLocationType.PHONE.getCode());
|
||||
device.setLastLocationTime(LocalDateTime.now());
|
||||
|
||||
// 若卫星信号弱或者车辆离线,则更新设备定位
|
||||
// 若卫星信号弱或者离线,则更新设备定位
|
||||
if (DeviceUtil.isLowSatelliteSignal(device) || DeviceUtil.isOffline(device)) {
|
||||
Device data = new Device();
|
||||
data.setMac(device.getMac());
|
||||
data.setLongitude(device.getLongitude());
|
||||
data.setLatitude(device.getLatitude());
|
||||
data.setLocationType(device.getLocationType());
|
||||
data.setLongitude(lon);
|
||||
data.setLatitude(lat);
|
||||
data.setLocationType(DeviceLocationType.PHONE.getCode());
|
||||
data.setLastLocationTime(LocalDateTime.now());
|
||||
int rows = deviceIotService.updateIot(data);
|
||||
if (rows != 1) {
|
||||
|
@ -519,12 +519,19 @@ public class OrderServiceImpl implements OrderService {
|
|||
}
|
||||
}
|
||||
|
||||
// 直接保存定位日志
|
||||
LocationLog locationLog = locationLogConverter.toPo(device);
|
||||
// 直接保存手机定位日志
|
||||
DeviceVO vo = new DeviceVO();
|
||||
BeanUtils.copyProperties(device, vo);
|
||||
vo.setLongitude(lon);
|
||||
vo.setLatitude(lat);
|
||||
vo.setLocationType(DeviceLocationType.PHONE.getCode());
|
||||
vo.setLastLocationTime(LocalDateTime.now());
|
||||
LocationLog locationLog = locationLogConverter.toPo(vo);
|
||||
if (locationLog == null) {
|
||||
log.error("通过手机定位转换定位日志失败: {}", device.getMac());
|
||||
return;
|
||||
}
|
||||
|
||||
// 暂存到Redis缓存
|
||||
redisCache.rightPush(CacheConstants.LOCATION_LOG_QUEUE, locationLog);
|
||||
|
||||
|
@ -652,7 +659,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
// 设备信息
|
||||
DeviceVO device = deviceService.selectDeviceById(order.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -710,7 +717,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
// 查询设备
|
||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
// 设置日志参数
|
||||
this.setLogParam(device);
|
||||
// 异步使用手机定位更新设备定位
|
||||
|
@ -736,7 +743,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
// 查询设备
|
||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
// 设置日志参数
|
||||
this.setLogParam(device);
|
||||
// 异步使用手机定位更新设备定位
|
||||
|
@ -885,13 +892,35 @@ public class OrderServiceImpl implements OrderService {
|
|||
return orderMapper.updateOrder(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean seat(OrderSeatDTO dto) {
|
||||
OrderVO order = this.selectOrderById(dto.getOrderId());
|
||||
ServiceUtil.assertion(order == null, "ID为%s的订单不存在", dto.getOrderId());
|
||||
ServiceUtil.assertion(!OrderStatus.inUse().contains(order.getStatus()), "ID为%s的订单当前状态不允许打开坐垫锁", dto.getOrderId());
|
||||
|
||||
// 查询设备
|
||||
DeviceVO device = deviceService.selectDeviceById(order.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", order.getDeviceId());
|
||||
boolean enableSeat = device.getModelEnableSeat() != null && device.getModelEnableSeat();
|
||||
ServiceUtil.assertion(!enableSeat, "ID为%s的设备不允许用户打开坐垫锁", order.getDeviceId());
|
||||
deviceAssembler.assembleIot(device);
|
||||
|
||||
// 设置日志参数
|
||||
this.setLogParam(device);
|
||||
|
||||
// 异步使用手机定位更新设备定位
|
||||
this.handleDeviceLocationAsync(device, dto.getLon(), dto.getLat());
|
||||
|
||||
return deviceIotService.unlockSeat(device, "订单打开坐垫锁:" + order.getNo(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deduct(OrderDeductDTO dto) {
|
||||
|
||||
// 查询订单
|
||||
OrderVO order = this.selectOrderById(dto.getId());
|
||||
ServiceUtil.assertion(order == null, "ID为%s的订单不存在", dto.getId());
|
||||
|
||||
|
||||
// 判断是否可以抵扣
|
||||
ServiceUtil.assertion(!OrderStatus.canDeduct().contains(order.getStatus()), "ID为%s的订单当前状态不允许抵扣", dto.getId());
|
||||
BigDecimal canDeductAmount = OrderUtil.calcRemainCanDeductDeposit(order);
|
||||
|
@ -910,19 +939,19 @@ public class OrderServiceImpl implements OrderService {
|
|||
// 关闭订单的支付ID
|
||||
boolean closePay = payService.closeByBstId(PayBstType.ORDER_RIDE.getType(), order.getId());
|
||||
ServiceUtil.assertion(!closePay, "ID为%s的订单骑行费支付关闭失败", dto.getId());
|
||||
|
||||
|
||||
// 更新订单数据
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 押金抵扣
|
||||
int deduct = orderMapper.deductDeposit(order.getId(), deductAmount);
|
||||
ServiceUtil.assertion(deduct != 1, "ID为%s的订单押金抵扣失败,剩余可抵扣押金不足", dto.getId());
|
||||
|
||||
|
||||
OrderRidePaySuccessBO bo = new OrderRidePaySuccessBO();
|
||||
bo.setOrder(order);
|
||||
bo.setPayType(OrderPayType.DEPOSIT_DEDUCTION);
|
||||
bo.setPayAmount(deductAmount);
|
||||
bo.setNeedVerify(dto.getNeedVerify());
|
||||
return this.handleRidePaySuccess(bo);
|
||||
return this.handleRidePaySuccess(bo);
|
||||
|
||||
});
|
||||
|
||||
|
@ -966,7 +995,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
return rows;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
return result == null ? 0 : result;
|
||||
|
|
|
@ -7,8 +7,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ruoyi.bst.device.utils.DeviceUtil;
|
||||
import com.ruoyi.bst.orderDevice.domain.enums.OrderDeviceStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -21,6 +19,7 @@ import com.ruoyi.bst.device.domain.DeviceQuery;
|
|||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
|
||||
import com.ruoyi.bst.device.service.DeviceService;
|
||||
import com.ruoyi.bst.device.utils.DeviceUtil;
|
||||
import com.ruoyi.bst.model.domain.ModelVO;
|
||||
import com.ruoyi.bst.order.domain.OrderQuery;
|
||||
import com.ruoyi.bst.order.domain.OrderVO;
|
||||
|
@ -121,7 +120,8 @@ public class OrderValidatorImpl implements OrderValidator{
|
|||
}
|
||||
|
||||
// 是否是下单用户
|
||||
private boolean isUser(OrderVO order, Long userId) {
|
||||
@Override
|
||||
public boolean isUser(OrderVO order, Long userId) {
|
||||
return order != null && userId != null && Objects.equals(order.getUserId(), userId);
|
||||
}
|
||||
|
||||
|
@ -244,4 +244,5 @@ public class OrderValidatorImpl implements OrderValidator{
|
|||
OrderVO order = orderMapper.selectOrderById(orderId);
|
||||
return isUser(order, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class OrderUtil {
|
|||
vo.setMobileAreaSub(mobileAreaSub);
|
||||
// 是否在停车点
|
||||
boolean inParking = deviceAreaSub != null || mobileAreaSub != null;
|
||||
vo.setInParking(inParking);
|
||||
vo.setInParking(inParking);
|
||||
|
||||
// 实际停车点
|
||||
if (deviceAreaSub != null) {
|
||||
|
|
|
@ -46,6 +46,8 @@ public class OrderDeviceVO extends OrderDevice{
|
|||
// 车型
|
||||
@ApiModelProperty("车型")
|
||||
private String deviceModelName;
|
||||
@ApiModelProperty("车型是否允许用户打开坐垫锁")
|
||||
private Boolean deviceModelEnableSeat;
|
||||
|
||||
// 设备剩余续航(公里)
|
||||
public BigDecimal getDeviceRemainEndurance() {
|
||||
|
|
|
@ -44,7 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bd.latitude as device_latitude,
|
||||
su.nick_name as order_user_name,
|
||||
mch.nick_name as device_mch_name,
|
||||
bm.name as device_model_name
|
||||
bm.name as device_model_name,
|
||||
bm.enable_seat as device_model_eanble_seat
|
||||
from bst_order_device bod
|
||||
left join bst_order bo on bo.id = bod.order_id
|
||||
left join bst_device bd on bd.id = bod.device_id
|
||||
|
@ -75,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.endAreaSubName != null and query.endAreaSubName != ''"> and bod.end_area_sub_name like concat('%', #{query.endAreaSubName}, '%')</if>
|
||||
<if test="query.returnMode != null and query.returnMode != ''"> and bod.return_mode = #{query.returnMode}</if>
|
||||
<if test="query.deviceModelName != null and query.deviceModelName != ''"> and bm.name like concat('%', #{query.deviceModelName}, '%')</if>
|
||||
<if test="query.deviceModelEnableSeat != null"> and bm.enable_seat = #{query.deviceModelEnableSeat}</if>
|
||||
<if test="query.statusList != null and query.statusList.size() > 0">
|
||||
and bod.status in
|
||||
<foreach item="item" collection="query.statusList" separator="," open="(" close=")">
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.ruoyi.bst.order.domain.dto.OrderCloseDeviceDTO;
|
|||
import com.ruoyi.bst.order.domain.dto.OrderCreateDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderSeatDTO;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderReturnType;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderStatus;
|
||||
import com.ruoyi.bst.order.domain.vo.OrderEndVO;
|
||||
|
@ -169,7 +170,7 @@ public class AppOrderController extends BaseController {
|
|||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||
ServiceUtil.assertion(order == null, "订单不存在");
|
||||
ServiceUtil.assertion(!orderValidator.canOpenDevice(order, getUserId()), "您无权操作ID为%s的订单设备开启", order.getId());
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "预存款已完用,请还车后再扫码骑行,或联系客服人员处理!");
|
||||
if (dto.getRequiredIot() == null) {
|
||||
dto.setRequiredIot(true);
|
||||
}
|
||||
|
@ -189,7 +190,7 @@ public class AppOrderController extends BaseController {
|
|||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||
ServiceUtil.assertion(order == null, "订单不存在");
|
||||
ServiceUtil.assertion(!orderValidator.canCloseDevice(order, getUserId()), "您无权操作ID为%s的订单设备关闭", order.getId());
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "预存款已完用,请还车后再扫码骑行,或联系客服人员处理!");
|
||||
if (dto.getRequiredIot() == null) {
|
||||
dto.setRequiredIot(true);
|
||||
}
|
||||
|
@ -208,10 +209,23 @@ public class AppOrderController extends BaseController {
|
|||
|
||||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||
ServiceUtil.assertion(!orderValidator.canChangeDevice(order, getUserId()), "您无权操作ID为%s的订单换车", order.getId());
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "预存款已完用,请还车后再扫码骑行,或联系客服人员处理!");
|
||||
dto.setUserId(getUserId());
|
||||
dto.setUserName(getNickName());
|
||||
return toAjax(orderService.changeDevice(dto));
|
||||
}
|
||||
|
||||
@ApiOperation("打开坐垫锁")
|
||||
@PutMapping("/seat")
|
||||
@Log(title = "打开坐垫锁", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.ORDER)
|
||||
public AjaxResult seat(@RequestBody @Validated OrderSeatDTO dto) {
|
||||
// 设置日志参数
|
||||
LogParamHolder.set(LogParamHolder.PARAM_LON, dto.getLon());
|
||||
LogParamHolder.set(LogParamHolder.PARAM_LAT, dto.getLat());
|
||||
|
||||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||
ServiceUtil.assertion(!orderValidator.isUser(order, getUserId()), "您无权操作ID为%s的订单打开坐垫锁", order.getId());
|
||||
return success(orderService.seat(dto));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user