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.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.ServiceUtil;
|
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import org.locationtech.jts.geom.Geometry;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
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.constant.CacheConstants;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.ServiceUtil;
|
||||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
import com.ruoyi.common.utils.map.GeoUtils;
|
import com.ruoyi.common.utils.map.GeoUtils;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ public class DeviceVO extends Device {
|
||||||
private BigDecimal modelLowVoltage;
|
private BigDecimal modelLowVoltage;
|
||||||
@ApiModelProperty("车型续航")
|
@ApiModelProperty("车型续航")
|
||||||
private BigDecimal modelFullEndurance;
|
private BigDecimal modelFullEndurance;
|
||||||
|
@ApiModelProperty("车型是否允许用户打开坐垫锁")
|
||||||
|
private Boolean modelEnableSeat;
|
||||||
|
|
||||||
// 运营区
|
// 运营区
|
||||||
@ApiModelProperty("运营区名称")
|
@ApiModelProperty("运营区名称")
|
||||||
|
|
|
@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
bm.full_voltage as model_full_voltage,
|
bm.full_voltage as model_full_voltage,
|
||||||
bm.low_voltage as model_low_voltage,
|
bm.low_voltage as model_low_voltage,
|
||||||
bm.full_endurance as model_full_endurance,
|
bm.full_endurance as model_full_endurance,
|
||||||
|
bm.enable_seat as model_enable_seat,
|
||||||
ba.name as area_name,
|
ba.name as area_name,
|
||||||
ba.user_id as area_user_id,
|
ba.user_id as area_user_id,
|
||||||
ba.undercharge as area_undercharge,
|
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.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.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.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 != ''">
|
<if test="query.keyword != null and query.keyword != ''">
|
||||||
and (
|
and (
|
||||||
bd.sn like concat('%', #{query.keyword}, '%')
|
bd.sn like concat('%', #{query.keyword}, '%')
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
@ -78,6 +79,9 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OperLogService operLogService;
|
private OperLogService operLogService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceAssembler deviceAssembler;
|
||||||
|
|
||||||
private final static Integer SUB_FAST = 5; // 上报频率(快)
|
private final static Integer SUB_FAST = 5; // 上报频率(快)
|
||||||
private final static Integer SUB_SLOW = 300; // 上报频率(慢)
|
private final static Integer SUB_SLOW = 300; // 上报频率(慢)
|
||||||
private final static Integer SUB_X_SLOW = 50; // 上报频率(X开头硬件)
|
private final static Integer SUB_X_SLOW = 50; // 上报频率(X开头硬件)
|
||||||
|
@ -280,22 +284,25 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取物联网信息
|
// 获取物联网信息
|
||||||
List<IotDeviceInfo> iotList = iotService.getDeviceInfo(deviceList);
|
// List<IotDeviceInfo> iotList = iotService.getDeviceInfo(deviceList);
|
||||||
if (CollectionUtils.isEmptyElement(iotList)) {
|
// if (CollectionUtils.isEmptyElement(iotList)) {
|
||||||
return;
|
// 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) {
|
deviceAssembler.assembleIot(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 异步发送命令,强制设备上报数据
|
// 异步发送命令,强制设备上报数据
|
||||||
if (onlineType != null) {
|
if (onlineType != null) {
|
||||||
|
@ -432,7 +439,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
||||||
try {
|
try {
|
||||||
// 获取设备最新信息
|
// 获取设备最新信息
|
||||||
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
||||||
this.refresh(device, null);
|
deviceAssembler.assembleIot(device);
|
||||||
this.monitor(device);
|
this.monitor(device);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
||||||
|
@ -472,7 +479,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
||||||
@Override
|
@Override
|
||||||
public void monitor(String mac) {
|
public void monitor(String mac) {
|
||||||
DeviceVO device = deviceService.selectByMac(mac);
|
DeviceVO device = deviceService.selectByMac(mac);
|
||||||
this.refresh(device, null);
|
deviceAssembler.assembleIot(device);
|
||||||
this.monitor(device);
|
this.monitor(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,10 @@ public class DeviceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆是否离线
|
* 判断设备是否离线
|
||||||
|
*
|
||||||
|
* @param device 设备
|
||||||
|
* @return 是否离线
|
||||||
*/
|
*/
|
||||||
public static boolean isOffline(DeviceVO device) {
|
public static boolean isOffline(DeviceVO device) {
|
||||||
return device != null && device.getOnlineStatus() != null && DeviceOnlineStatus.OFFLINE.getStatus().equals(device.getOnlineStatus());
|
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")
|
@Min(value = 0, message = "骑行低电量提醒不能小于0")
|
||||||
private Integer lowBatteryReminder;
|
private Integer lowBatteryReminder;
|
||||||
|
|
||||||
|
@Excel(name = "是否允许用户打开坐垫锁")
|
||||||
|
@ApiModelProperty("是否允许用户打开坐垫锁")
|
||||||
|
private Boolean enableSeat;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object logBizId() {
|
public Object logBizId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
bm.deleted,
|
bm.deleted,
|
||||||
bm.low_battery_reminder_switch,
|
bm.low_battery_reminder_switch,
|
||||||
bm.low_battery_reminder,
|
bm.low_battery_reminder,
|
||||||
|
bm.enable_seat,
|
||||||
su.nick_name as user_name
|
su.nick_name as user_name
|
||||||
from <include refid="searchTables"/>
|
from <include refid="searchTables"/>
|
||||||
</sql>
|
</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.deleted == null "> and bm.deleted = false</if>
|
||||||
<if test="query.lowBatteryReminderSwitch != null "> and bm.low_battery_reminder_switch = #{query.lowBatteryReminderSwitch}</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.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">
|
<if test="query.ids != null">
|
||||||
and bm.id in
|
and bm.id in
|
||||||
<foreach item="item" collection="query.ids" open="(" separator="," close=")">
|
<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="remark != null">remark,</if>
|
||||||
<if test="lowBatteryReminderSwitch != null">low_battery_reminder_switch,</if>
|
<if test="lowBatteryReminderSwitch != null">low_battery_reminder_switch,</if>
|
||||||
<if test="lowBatteryReminder != null">low_battery_reminder,</if>
|
<if test="lowBatteryReminder != null">low_battery_reminder,</if>
|
||||||
|
<if test="enableSeat != null">enable_seat,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="areaId != null">#{areaId},</if>
|
<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="remark != null">#{remark},</if>
|
||||||
<if test="lowBatteryReminderSwitch != null">#{lowBatteryReminderSwitch},</if>
|
<if test="lowBatteryReminderSwitch != null">#{lowBatteryReminderSwitch},</if>
|
||||||
<if test="lowBatteryReminder != null">#{lowBatteryReminder},</if>
|
<if test="lowBatteryReminder != null">#{lowBatteryReminder},</if>
|
||||||
|
<if test="enableSeat != null">#{enableSeat},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</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.remark != null">remark = #{data.remark},</if>
|
||||||
<if test="data.lowBatteryReminderSwitch != null">low_battery_reminder_switch = #{data.lowBatteryReminderSwitch},</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.lowBatteryReminder != null">low_battery_reminder = #{data.lowBatteryReminder},</if>
|
||||||
|
<if test="data.enableSeat != null">enable_seat = #{data.enableSeat},</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<delete id="deleteModelById" parameterType="Long">
|
<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.OrderEndDTO;
|
||||||
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
||||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
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.dto.OrderVerifyDTO;
|
||||||
import com.ruoyi.bst.order.domain.vo.OrderEndVO;
|
import com.ruoyi.bst.order.domain.vo.OrderEndVO;
|
||||||
import com.ruoyi.bst.order.domain.vo.OrderFeeVO;
|
import com.ruoyi.bst.order.domain.vo.OrderFeeVO;
|
||||||
|
@ -211,6 +212,14 @@ public interface OrderService {
|
||||||
*/
|
*/
|
||||||
public int updateDisatance(Long id, BigDecimal distance);
|
public int updateDisatance(Long id, BigDecimal distance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开坐垫锁
|
||||||
|
*
|
||||||
|
* @param dto 参数
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean seat(OrderSeatDTO dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 押金抵扣
|
* 押金抵扣
|
||||||
*
|
*
|
||||||
|
|
|
@ -101,4 +101,9 @@ public interface OrderValidator {
|
||||||
* 是否是用户
|
* 是否是用户
|
||||||
*/
|
*/
|
||||||
boolean isUser(Long orderId, Long userId);
|
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.domain.ChannelVO;
|
||||||
import com.ruoyi.bst.channel.service.ChannelService;
|
import com.ruoyi.bst.channel.service.ChannelService;
|
||||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
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.DeviceIotService;
|
||||||
import com.ruoyi.bst.device.service.DeviceService;
|
import com.ruoyi.bst.device.service.DeviceService;
|
||||||
import com.ruoyi.bst.locationLog.domain.vo.LocationLogPositionVO;
|
import com.ruoyi.bst.locationLog.domain.vo.LocationLogPositionVO;
|
||||||
|
@ -112,6 +113,9 @@ public class OrderConverterImpl implements OrderConverter{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelAssembler modelAssembler;
|
private ModelAssembler modelAssembler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceAssembler deviceAssembler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderPrePriceVO toOrderPrePriceVO(OrderCalcPrePriceDTO dto) {
|
public OrderPrePriceVO toOrderPrePriceVO(OrderCalcPrePriceDTO dto) {
|
||||||
if (dto == null) {
|
if (dto == null) {
|
||||||
|
@ -363,7 +367,7 @@ public class OrderConverterImpl implements OrderConverter{
|
||||||
if (orderDevice != null) {
|
if (orderDevice != null) {
|
||||||
// 获取当前设备信息
|
// 获取当前设备信息
|
||||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||||
deviceIotService.refresh(device, null);
|
deviceAssembler.assembleIot(device);
|
||||||
bo.setDevice(device);
|
bo.setDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +451,7 @@ public class OrderConverterImpl implements OrderConverter{
|
||||||
|
|
||||||
// 查询旧设备
|
// 查询旧设备
|
||||||
DeviceVO oldDevice = deviceService.selectDeviceById(oldOrderDevice.getDeviceId());
|
DeviceVO oldDevice = deviceService.selectDeviceById(oldOrderDevice.getDeviceId());
|
||||||
deviceIotService.refresh(oldDevice, null);
|
deviceAssembler.assembleIot(oldDevice);
|
||||||
ServiceUtil.assertion(oldDevice == null, "ID为%s的旧设备不存在", oldOrderDevice.getDeviceId());
|
ServiceUtil.assertion(oldDevice == null, "ID为%s的旧设备不存在", oldOrderDevice.getDeviceId());
|
||||||
bo.setOldDevice(oldDevice);
|
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.DeviceLocationType;
|
||||||
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
||||||
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
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.DeviceIotService;
|
||||||
import com.ruoyi.bst.device.service.DeviceService;
|
import com.ruoyi.bst.device.service.DeviceService;
|
||||||
import com.ruoyi.bst.device.utils.DeviceUtil;
|
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.OrderEndDTO;
|
||||||
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
||||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
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.dto.OrderVerifyDTO;
|
||||||
import com.ruoyi.bst.order.domain.enums.OrderPayType;
|
import com.ruoyi.bst.order.domain.enums.OrderPayType;
|
||||||
import com.ruoyi.bst.order.domain.enums.OrderReturnType;
|
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.ServiceUtil;
|
||||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
import com.ruoyi.system.user.service.UserService;
|
import com.ruoyi.system.user.service.UserService;
|
||||||
|
|
||||||
|
@ -162,6 +165,9 @@ public class OrderServiceImpl implements OrderService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceAssembler deviceAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
*
|
*
|
||||||
|
@ -482,8 +488,6 @@ public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置日志参数
|
* 设置日志参数
|
||||||
* @param lon 手机定位经度
|
|
||||||
* @param lat 手机定位纬度
|
|
||||||
* @param device 设备信息
|
* @param device 设备信息
|
||||||
*/
|
*/
|
||||||
private void setLogParam(DeviceVO device) {
|
private void setLogParam(DeviceVO device) {
|
||||||
|
@ -500,18 +504,14 @@ public class OrderServiceImpl implements OrderService {
|
||||||
private void handleDeviceLocationAsync(DeviceVO device, BigDecimal lon, BigDecimal lat) {
|
private void handleDeviceLocationAsync(DeviceVO device, BigDecimal lon, BigDecimal lat) {
|
||||||
if (device != null && device.getId() != null && StringUtils.isNotBlank(device.getMac()) && DeviceUtil.validLocation(lon, lat)) {
|
if (device != null && device.getId() != null && StringUtils.isNotBlank(device.getMac()) && DeviceUtil.validLocation(lon, lat)) {
|
||||||
scheduledExecutorService.execute(() -> {
|
scheduledExecutorService.execute(() -> {
|
||||||
device.setLongitude(lon);
|
|
||||||
device.setLatitude(lat);
|
|
||||||
device.setLocationType(DeviceLocationType.PHONE.getCode());
|
|
||||||
device.setLastLocationTime(LocalDateTime.now());
|
|
||||||
|
|
||||||
// 若卫星信号弱或者车辆离线,则更新设备定位
|
// 若卫星信号弱或者离线,则更新设备定位
|
||||||
if (DeviceUtil.isLowSatelliteSignal(device) || DeviceUtil.isOffline(device)) {
|
if (DeviceUtil.isLowSatelliteSignal(device) || DeviceUtil.isOffline(device)) {
|
||||||
Device data = new Device();
|
Device data = new Device();
|
||||||
data.setMac(device.getMac());
|
data.setMac(device.getMac());
|
||||||
data.setLongitude(device.getLongitude());
|
data.setLongitude(lon);
|
||||||
data.setLatitude(device.getLatitude());
|
data.setLatitude(lat);
|
||||||
data.setLocationType(device.getLocationType());
|
data.setLocationType(DeviceLocationType.PHONE.getCode());
|
||||||
data.setLastLocationTime(LocalDateTime.now());
|
data.setLastLocationTime(LocalDateTime.now());
|
||||||
int rows = deviceIotService.updateIot(data);
|
int rows = deviceIotService.updateIot(data);
|
||||||
if (rows != 1) {
|
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) {
|
if (locationLog == null) {
|
||||||
log.error("通过手机定位转换定位日志失败: {}", device.getMac());
|
log.error("通过手机定位转换定位日志失败: {}", device.getMac());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暂存到Redis缓存
|
// 暂存到Redis缓存
|
||||||
redisCache.rightPush(CacheConstants.LOCATION_LOG_QUEUE, locationLog);
|
redisCache.rightPush(CacheConstants.LOCATION_LOG_QUEUE, locationLog);
|
||||||
|
|
||||||
|
@ -652,7 +659,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
// 设备信息
|
// 设备信息
|
||||||
DeviceVO device = deviceService.selectDeviceById(order.getDeviceId());
|
DeviceVO device = deviceService.selectDeviceById(order.getDeviceId());
|
||||||
deviceIotService.refresh(device, null);
|
deviceAssembler.assembleIot(device);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -710,7 +717,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
// 查询设备
|
// 查询设备
|
||||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
||||||
deviceIotService.refresh(device, null);
|
deviceAssembler.assembleIot(device);
|
||||||
// 设置日志参数
|
// 设置日志参数
|
||||||
this.setLogParam(device);
|
this.setLogParam(device);
|
||||||
// 异步使用手机定位更新设备定位
|
// 异步使用手机定位更新设备定位
|
||||||
|
@ -736,7 +743,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
// 查询设备
|
// 查询设备
|
||||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
||||||
deviceIotService.refresh(device, null);
|
deviceAssembler.assembleIot(device);
|
||||||
// 设置日志参数
|
// 设置日志参数
|
||||||
this.setLogParam(device);
|
this.setLogParam(device);
|
||||||
// 异步使用手机定位更新设备定位
|
// 异步使用手机定位更新设备定位
|
||||||
|
@ -885,6 +892,28 @@ public class OrderServiceImpl implements OrderService {
|
||||||
return orderMapper.updateOrder(data);
|
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
|
@Override
|
||||||
public int deduct(OrderDeductDTO dto) {
|
public int deduct(OrderDeductDTO dto) {
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
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.DeviceVO;
|
||||||
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
|
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
|
||||||
import com.ruoyi.bst.device.service.DeviceService;
|
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.model.domain.ModelVO;
|
||||||
import com.ruoyi.bst.order.domain.OrderQuery;
|
import com.ruoyi.bst.order.domain.OrderQuery;
|
||||||
import com.ruoyi.bst.order.domain.OrderVO;
|
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);
|
return order != null && userId != null && Objects.equals(order.getUserId(), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,4 +244,5 @@ public class OrderValidatorImpl implements OrderValidator{
|
||||||
OrderVO order = orderMapper.selectOrderById(orderId);
|
OrderVO order = orderMapper.selectOrderById(orderId);
|
||||||
return isUser(order, userId);
|
return isUser(order, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ public class OrderDeviceVO extends OrderDevice{
|
||||||
// 车型
|
// 车型
|
||||||
@ApiModelProperty("车型")
|
@ApiModelProperty("车型")
|
||||||
private String deviceModelName;
|
private String deviceModelName;
|
||||||
|
@ApiModelProperty("车型是否允许用户打开坐垫锁")
|
||||||
|
private Boolean deviceModelEnableSeat;
|
||||||
|
|
||||||
// 设备剩余续航(公里)
|
// 设备剩余续航(公里)
|
||||||
public BigDecimal getDeviceRemainEndurance() {
|
public BigDecimal getDeviceRemainEndurance() {
|
||||||
|
|
|
@ -44,7 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
bd.latitude as device_latitude,
|
bd.latitude as device_latitude,
|
||||||
su.nick_name as order_user_name,
|
su.nick_name as order_user_name,
|
||||||
mch.nick_name as device_mch_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
|
from bst_order_device bod
|
||||||
left join bst_order bo on bo.id = bod.order_id
|
left join bst_order bo on bo.id = bod.order_id
|
||||||
left join bst_device bd on bd.id = bod.device_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.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.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.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">
|
<if test="query.statusList != null and query.statusList.size() > 0">
|
||||||
and bod.status in
|
and bod.status in
|
||||||
<foreach item="item" collection="query.statusList" separator="," open="(" close=")">
|
<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.OrderCreateDTO;
|
||||||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||||
import com.ruoyi.bst.order.domain.dto.OrderOpenDeviceDTO;
|
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.OrderReturnType;
|
||||||
import com.ruoyi.bst.order.domain.enums.OrderStatus;
|
import com.ruoyi.bst.order.domain.enums.OrderStatus;
|
||||||
import com.ruoyi.bst.order.domain.vo.OrderEndVO;
|
import com.ruoyi.bst.order.domain.vo.OrderEndVO;
|
||||||
|
@ -169,7 +170,7 @@ public class AppOrderController extends BaseController {
|
||||||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||||
ServiceUtil.assertion(order == null, "订单不存在");
|
ServiceUtil.assertion(order == null, "订单不存在");
|
||||||
ServiceUtil.assertion(!orderValidator.canOpenDevice(order, getUserId()), "您无权操作ID为%s的订单设备开启", order.getId());
|
ServiceUtil.assertion(!orderValidator.canOpenDevice(order, getUserId()), "您无权操作ID为%s的订单设备开启", order.getId());
|
||||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
ServiceUtil.assertion(orderValidator.isTimeout(order), "预存款已完用,请还车后再扫码骑行,或联系客服人员处理!");
|
||||||
if (dto.getRequiredIot() == null) {
|
if (dto.getRequiredIot() == null) {
|
||||||
dto.setRequiredIot(true);
|
dto.setRequiredIot(true);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +190,7 @@ public class AppOrderController extends BaseController {
|
||||||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||||
ServiceUtil.assertion(order == null, "订单不存在");
|
ServiceUtil.assertion(order == null, "订单不存在");
|
||||||
ServiceUtil.assertion(!orderValidator.canCloseDevice(order, getUserId()), "您无权操作ID为%s的订单设备关闭", order.getId());
|
ServiceUtil.assertion(!orderValidator.canCloseDevice(order, getUserId()), "您无权操作ID为%s的订单设备关闭", order.getId());
|
||||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
ServiceUtil.assertion(orderValidator.isTimeout(order), "预存款已完用,请还车后再扫码骑行,或联系客服人员处理!");
|
||||||
if (dto.getRequiredIot() == null) {
|
if (dto.getRequiredIot() == null) {
|
||||||
dto.setRequiredIot(true);
|
dto.setRequiredIot(true);
|
||||||
}
|
}
|
||||||
|
@ -208,10 +209,23 @@ public class AppOrderController extends BaseController {
|
||||||
|
|
||||||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||||
ServiceUtil.assertion(!orderValidator.canChangeDevice(order, getUserId()), "您无权操作ID为%s的订单换车", order.getId());
|
ServiceUtil.assertion(!orderValidator.canChangeDevice(order, getUserId()), "您无权操作ID为%s的订单换车", order.getId());
|
||||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
ServiceUtil.assertion(orderValidator.isTimeout(order), "预存款已完用,请还车后再扫码骑行,或联系客服人员处理!");
|
||||||
dto.setUserId(getUserId());
|
dto.setUserId(getUserId());
|
||||||
dto.setUserName(getNickName());
|
dto.setUserName(getNickName());
|
||||||
return toAjax(orderService.changeDevice(dto));
|
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