Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2560660e72
|
@ -188,6 +188,10 @@ public class Area extends BaseEntity implements LogBizParam
|
|||
@ApiModelProperty("响铃寻车是否必须在范围内")
|
||||
private Boolean requiredRingRadius;
|
||||
|
||||
@Excel(name = "超时是否自动断电")
|
||||
@ApiModelProperty("超时是否自动断电")
|
||||
private Boolean timeoutLock;
|
||||
|
||||
@Override
|
||||
public Object logBizId() {
|
||||
return id;
|
||||
|
|
|
@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ba.outage_distance,
|
||||
ba.ring_radius,
|
||||
ba.required_ring_radius,
|
||||
ba.timeout_lock,
|
||||
su.nick_name as user_name,
|
||||
su.agent_id as agent_id,
|
||||
su.user_name as user_phone,
|
||||
|
@ -85,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.userName != null and query.userName != ''"> and su.nick_name like concat('%', #{query.userName}, '%')</if>
|
||||
<if test="query.createName != null and query.createName != ''"> and suc.nick_name like concat('%', #{query.createName}, '%')</if>
|
||||
<if test="query.userPhone != null and query.userPhone != ''"> and su.user_name like concat('%', #{query.userPhone}, '%')</if>
|
||||
<if test="query.timeoutLock != null "> and ba.timeout_lock = #{query.timeoutLock}</if>
|
||||
<if test="query.ids != null and query.ids.size() > 0">
|
||||
and ba.id in
|
||||
<foreach collection="query.ids" item="item" open="(" separator="," close=")">
|
||||
|
@ -166,6 +168,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="outageDistance != null">outage_distance,</if>
|
||||
<if test="ringRadius != null">ring_radius,</if>
|
||||
<if test="requiredRingRadius != null">required_ring_radius,</if>
|
||||
<if test="timeoutLock != null">timeout_lock,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
|
@ -204,6 +207,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="outageDistance != null">#{outageDistance},</if>
|
||||
<if test="ringRadius != null">#{ringRadius},</if>
|
||||
<if test="requiredRingRadius != null">#{requiredRingRadius},</if>
|
||||
<if test="timeoutLock != null">#{timeoutLock},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -252,6 +256,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.outageDistance != null">outage_distance = #{data.outageDistance},</if>
|
||||
<if test="data.ringRadius != null">ring_radius = #{data.ringRadius},</if>
|
||||
<if test="data.requiredRingRadius != null">required_ring_radius = #{data.requiredRingRadius},</if>
|
||||
<if test="data.timeoutLock != null">timeout_lock = #{data.timeoutLock},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteAreaById" parameterType="Long">
|
||||
|
|
|
@ -32,6 +32,7 @@ public class AreaConverterImpl implements AreaConverter {
|
|||
po.setAreaOutOutage(data.getAreaOutOutage());
|
||||
po.setBoundaryDistance(data.getBoundaryDistance());
|
||||
po.setOutageDistance(data.getOutageDistance());
|
||||
po.setTimeoutLock(data.getTimeoutLock());
|
||||
|
||||
// 还车设置
|
||||
po.setError(data.getError());
|
||||
|
@ -74,7 +75,8 @@ public class AreaConverterImpl implements AreaConverter {
|
|||
po.setAreaOutOutage(data.getAreaOutOutage());
|
||||
po.setBoundaryDistance(data.getBoundaryDistance());
|
||||
po.setOutageDistance(data.getOutageDistance());
|
||||
|
||||
po.setTimeoutLock(data.getTimeoutLock());
|
||||
|
||||
// 还车设置
|
||||
po.setError(data.getError());
|
||||
po.setReturnVerify(data.getReturnVerify());
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import com.ruoyi.bst.areaSub.domain.AreaSubVO;
|
||||
import com.ruoyi.bst.areaSub.domain.enums.AreaSubStatus;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.common.utils.map.GeoUtils;
|
||||
|
||||
|
@ -35,6 +36,9 @@ public class AreaSubUtil {
|
|||
if (geometry == null) {
|
||||
continue;
|
||||
}
|
||||
if (AreaSubStatus.DISABLED.getCode().equals(area.getStatus())) {
|
||||
continue;
|
||||
}
|
||||
if(area.getError() != null ){
|
||||
tolerance = area.getError();
|
||||
}
|
||||
|
@ -67,6 +71,9 @@ public class AreaSubUtil {
|
|||
if (geometry == null) {
|
||||
continue;
|
||||
}
|
||||
if (AreaSubStatus.DISABLED.getCode().equals(area.getStatus())) {
|
||||
continue;
|
||||
}
|
||||
if (area.getError() != null) {
|
||||
tolerance = area.getError();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.bst.device.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
@ -67,7 +68,7 @@ public class DeviceVO extends Device {
|
|||
@ApiModelProperty("是否必须停车点还车")
|
||||
private Boolean areaParkingReturn;
|
||||
|
||||
// 订单
|
||||
// 订单设备
|
||||
@ApiModelProperty("当前订单ID")
|
||||
private Long orderId;
|
||||
@ApiModelProperty("当前订单状态")
|
||||
|
@ -76,8 +77,18 @@ public class DeviceVO extends Device {
|
|||
private String orderNo;
|
||||
@ApiModelProperty("当前订单设备状态")
|
||||
private String orderDeviceStatus;
|
||||
@ApiModelProperty("当前订单设备开始时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime orderDeviceStartTime;
|
||||
@ApiModelProperty("当前订单设备结束时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime orderDeviceEndTime;
|
||||
@ApiModelProperty("当前订单用户ID")
|
||||
private Long orderUserId;
|
||||
@ApiModelProperty("当前订单用户名称")
|
||||
private String orderUserName;
|
||||
@ApiModelProperty("当前订单用户手机号")
|
||||
private String orderUserPhone;
|
||||
|
||||
// 硬件版本
|
||||
@ApiModelProperty("硬件版本")
|
||||
|
|
|
@ -44,7 +44,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bd.last_online_time,
|
||||
bd.order_device_id,
|
||||
bd.software_version,
|
||||
bd.last_user_id,
|
||||
mch.nick_name as mch_name,
|
||||
mch.point as mch_point,
|
||||
bm.name as model_name,
|
||||
|
@ -73,10 +72,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bo.user_id as order_user_id,
|
||||
bod.status as order_device_status,
|
||||
bod.order_id as order_id,
|
||||
bod.start_time as order_device_start_time,
|
||||
bod.end_time as order_device_end_time,
|
||||
bhv.version as hardware_version,
|
||||
bhv.instructions as hardware_version_instructions,
|
||||
bul.nick_name as last_user_name,
|
||||
bul.user_name as last_user_phone
|
||||
suo.nick_name as order_user_name,
|
||||
suo.user_name as order_user_phone
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
|
@ -84,13 +85,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bst_device bd
|
||||
left join sys_user mch on bd.mch_id = mch.user_id
|
||||
left join bst_model bm on bd.model_id = bm.id
|
||||
left join bst_hardware_version bhv on bhv.id = bd.hardware_version_id
|
||||
left join bst_area ba on bd.area_id = ba.id
|
||||
left join sys_user basu on basu.user_id = ba.user_id
|
||||
left join sys_user basua on basua.user_id = basu.agent_id
|
||||
left join sys_user bul on bul.user_id = bd.last_user_id
|
||||
left join bst_order_device bod on bod.id = bd.order_device_id
|
||||
left join bst_order bo on bo.id = bod.order_id
|
||||
left join bst_hardware_version bhv on bhv.id = bd.hardware_version_id
|
||||
left join sys_user suo on suo.user_id = bo.user_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
|
@ -122,11 +123,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.areaAgentName != null and query.areaAgentName != ''"> and basua.nick_name like concat('%', #{query.areaAgentName}, '%')</if>
|
||||
<if test="query.orderNo != null and query.orderNo != ''"> and bo.no like concat('%', #{query.orderNo}, '%')</if>
|
||||
<if test="query.excludeId != null">and bd.id != #{query.excludeId}</if>
|
||||
<if test="query.lastUserId != null">and bd.last_user_id = #{query.lastUserId}</if>
|
||||
<if test="query.lastUserName != null and query.lastUserName != ''">and bul.nick_name like concat('%', #{query.lastUserName}, '%')</if>
|
||||
<if test="query.lastUserPhone != null and query.lastUserPhone != ''">and bul.user_name like concat('%', #{query.lastUserPhone}, '%')</if>
|
||||
<if test="query.mchName != null and query.mchName != ''">and mch.nick_name like concat('%', #{query.mchName}, '%')</if>
|
||||
<if test="query.modelName != null and query.modelName != ''">and bm.name like concat('%', #{query.modelName}, '%')</if>
|
||||
<if test="query.orderUserName != null and query.orderUserName != ''">and suo.nick_name like concat('%', #{query.orderUserName}, '%')</if>
|
||||
<if test="query.orderUserPhone != null and query.orderUserPhone != ''">and suo.user_name like concat('%', #{query.orderUserPhone}, '%')</if>
|
||||
<if test="query.lastTimeEnd != null">and bd.last_location_time <= #{query.lastTimeEnd}</if>
|
||||
<if test="query.lastTimeStart != null">and bd.last_location_time >= #{query.lastTimeStart}</if>
|
||||
<if test="query.keyword != null and query.keyword != ''">
|
||||
|
@ -230,7 +230,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="lastOnlineTime != null">last_online_time,</if>
|
||||
<if test="orderDeviceId != null">order_device_id,</if>
|
||||
<if test="softwareVersion != null">software_version,</if>
|
||||
<if test="lastUserId != null">last_user_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="modelId != null">#{modelId},</if>
|
||||
|
@ -265,7 +264,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="lastOnlineTime != null">#{lastOnlineTime},</if>
|
||||
<if test="orderDeviceId != null">#{orderDeviceId},</if>
|
||||
<if test="softwareVersion != null">#{softwareVersion},</if>
|
||||
<if test="lastUserId != null">#{lastUserId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -310,7 +308,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.lastOnlineTime != null">bd.last_online_time = #{data.lastOnlineTime},</if>
|
||||
<if test="data.orderDeviceId != null">bd.order_device_id = #{data.orderDeviceId},</if>
|
||||
<if test="data.softwareVersion != null">bd.software_version = #{data.softwareVersion},</if>
|
||||
<if test="data.lastUserId != null">bd.last_user_id = #{data.lastUserId},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteDeviceById" parameterType="Long">
|
||||
|
@ -373,8 +370,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bd.longitude,
|
||||
bd.latitude,
|
||||
bod.status as order_device_status,
|
||||
bod.order_id
|
||||
bod.order_id,
|
||||
bm.full_voltage as model_full_voltage,
|
||||
bm.low_voltage as model_low_voltage,
|
||||
bm.full_endurance as model_full_endurance
|
||||
from bst_device bd
|
||||
left join bst_model bm on bm.id = bd.model_id
|
||||
left join bst_order_device bod on bod.id = bd.order_device_id
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
|
|
|
@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderQuery extends OrderVO {
|
||||
public class OrderQuery extends OrderVO {
|
||||
|
||||
@ApiModelProperty("id列表")
|
||||
private List<Long> ids;
|
||||
|
|
|
@ -5,12 +5,13 @@ import java.time.LocalDateTime;
|
|||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.orderDevice.domain.OrderDeviceVO;
|
||||
import com.ruoyi.iot.interfaces.IotDevice;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderVO extends Order {
|
||||
public class OrderVO extends Order implements IotDevice {
|
||||
|
||||
// 订单设备
|
||||
@ApiModelProperty("当前设备ID")
|
||||
|
@ -33,6 +34,10 @@ public class OrderVO extends Order {
|
|||
private BigDecimal returnLon;
|
||||
@ApiModelProperty("还车纬度")
|
||||
private BigDecimal returnLat;
|
||||
@ApiModelProperty("当前经度")
|
||||
private BigDecimal currentLon;
|
||||
@ApiModelProperty("当前纬度")
|
||||
private BigDecimal currentLat;
|
||||
@ApiModelProperty("订单设备列表")
|
||||
private List<OrderDeviceVO> orderDeviceList;
|
||||
|
||||
|
@ -65,4 +70,18 @@ public class OrderVO extends Order {
|
|||
private BigDecimal payAdminRefund;
|
||||
|
||||
|
||||
@Override
|
||||
public String mac() {
|
||||
return this.deviceMac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal longitude() {
|
||||
return this.currentLon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal latitude() {
|
||||
return this.currentLat;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class OrderInParkingVO {
|
||||
|
||||
@ApiModelProperty("停车区数量")
|
||||
private Integer parkingCount;
|
||||
|
||||
@ApiModelProperty("手机定位所在停车区")
|
||||
private AreaSubVO mobileAreaSub;
|
||||
|
|
|
@ -72,7 +72,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bod.end_area_sub_name,
|
||||
bod.return_mode,
|
||||
bod.return_lon,
|
||||
bod.return_lat
|
||||
bod.return_lat,
|
||||
bd.longitude as current_lon,
|
||||
bd.latitude as current_lat
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
|
@ -82,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join sys_user su on bo.user_id = su.user_id
|
||||
left join bst_pay bp on bo.pay_id = bp.id
|
||||
left join bst_order_device bod on bod.id = bo.order_device_id
|
||||
left join bst_device bd on bod.device_id = bd.id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
|
|
|
@ -90,4 +90,15 @@ public interface OrderValidator {
|
|||
*/
|
||||
boolean canOperate(Long orderId);
|
||||
|
||||
/**
|
||||
* 校验订单是否超时
|
||||
* @param order 订单
|
||||
* @return 是否超时
|
||||
*/
|
||||
boolean isTimeout(OrderVO order);
|
||||
|
||||
/**
|
||||
* 是否是用户
|
||||
*/
|
||||
boolean isUser(Long orderId, Long userId);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.bst.order.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -165,6 +166,12 @@ public class OrderValidatorImpl implements OrderValidator{
|
|||
public void checkInParking(AreaVO area, OrderInParkingVO inParkingVO) {
|
||||
log.info("【还车定位校验】运营区:{},定位数据:{}", area.getName(), inParkingVO);
|
||||
ServiceUtil.assertion(inParkingVO == null, "参数错误,停车点信息不存在");
|
||||
ServiceUtil.assertion(area == null, "参数错误,运营区信息不存在");
|
||||
|
||||
if (inParkingVO.getParkingCount() != null && inParkingVO.getParkingCount() == 0) {
|
||||
log.warn("运营区{}的停车区数量为0,无需校验停车区", area.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
boolean mustInParking = area.getParkingReturn() != null && area.getParkingReturn();
|
||||
boolean inParking = inParkingVO.getInParking() != null && inParkingVO.getInParking();
|
||||
|
@ -224,4 +231,15 @@ public class OrderValidatorImpl implements OrderValidator{
|
|||
List<Long> list = orderMapper.selectIdByQuery(query);
|
||||
return new HashSet<>(list).containsAll(orderIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTimeout(OrderVO order) {
|
||||
return order != null && order.getMaxTime() != null && order.getMaxTime().isBefore(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUser(Long orderId, Long userId) {
|
||||
OrderVO order = orderMapper.selectOrderById(orderId);
|
||||
return isUser(order, userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,10 @@ public class OrderUtil {
|
|||
BigDecimal deviceLon = device.getLongitude();
|
||||
BigDecimal deviceLat = device.getLatitude();
|
||||
|
||||
// 停车区数量
|
||||
int parkingCount = parkingList == null ? 0 : parkingList.size();
|
||||
vo.setParkingCount(parkingCount);
|
||||
|
||||
// 通过设备定位获取所在停车点
|
||||
AreaSubVO deviceAreaSub = AreaSubUtil.getInAreaSub(parkingList, deviceLon, deviceLat, areaError);
|
||||
vo.setDeviceAreaSub(deviceAreaSub);
|
||||
|
|
|
@ -182,11 +182,11 @@ public class OrderDeviceServiceImpl implements OrderDeviceService
|
|||
query.setStatusList(OrderDeviceStatus.canStart());
|
||||
int rows = orderDeviceMapper.updateByQuery(data, query);
|
||||
|
||||
if (rows > 0 ) {
|
||||
// 更新设备最后一次使用的用户ID
|
||||
int update = deviceService.updateLastUserId(orderDevice.getDeviceId(), orderDevice.getOrderUserId());
|
||||
ServiceUtil.assertion(update != 1, "更新设备最后一次使用的用户ID失败");
|
||||
}
|
||||
// if (rows > 0 ) {
|
||||
// // 更新设备最后一次使用的用户ID
|
||||
// int update = deviceService.updateLastUserId(orderDevice.getDeviceId(), orderDevice.getOrderUserId());
|
||||
// ServiceUtil.assertion(update != 1, "更新设备最后一次使用的用户ID失败");
|
||||
// }
|
||||
|
||||
return rows;
|
||||
});
|
||||
|
@ -236,8 +236,8 @@ public class OrderDeviceServiceImpl implements OrderDeviceService
|
|||
int rows = orderDeviceMapper.updateByQuery(data, query);
|
||||
|
||||
// 清除设备当前订单设备ID
|
||||
int clear = deviceService.clearCurrentOrderDevice(orderDevice.getDeviceId(), orderDevice.getId());
|
||||
ServiceUtil.assertion(clear != 1, "清除设备当前订单ID失败");
|
||||
// int clear = deviceService.clearCurrentOrderDevice(orderDevice.getDeviceId(), orderDevice.getId());
|
||||
// ServiceUtil.assertion(clear != 1, "清除设备当前订单ID失败");
|
||||
|
||||
return rows;
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ public class RefundConverterImpl implements RefundConverter{
|
|||
refund.setReason(dto.getRefundReason());
|
||||
refund.setUserId(dto.getUserId());
|
||||
refund.setUserName(dto.getUserName());
|
||||
refund.setType(dto.getType());
|
||||
return refund;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,18 +9,19 @@ import org.springframework.boot.ApplicationArguments;
|
|||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||
import com.ruoyi.bst.locationLog.domain.vo.LocationLogPositionVO;
|
||||
import com.ruoyi.bst.locationLog.service.LocationLogService;
|
||||
import com.ruoyi.bst.locationLog.utils.LocationLogUtil;
|
||||
import com.ruoyi.bst.order.domain.OrderQuery;
|
||||
import com.ruoyi.bst.order.domain.OrderVO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderReturnType;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderStatus;
|
||||
import com.ruoyi.bst.order.mapper.OrderMapper;
|
||||
import com.ruoyi.bst.order.service.OrderService;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.iot.constants.IotConstants;
|
||||
import com.ruoyi.iot.service.IotService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -37,6 +38,11 @@ public class OrderTask implements ApplicationRunner {
|
|||
@Autowired
|
||||
private LocationLogService locationLogService;
|
||||
|
||||
@Autowired
|
||||
private DeviceIotService deviceIotService;
|
||||
|
||||
@Autowired
|
||||
private IotService iotService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
|
@ -55,9 +61,9 @@ public class OrderTask implements ApplicationRunner {
|
|||
}
|
||||
|
||||
/**
|
||||
* 关闭超过最大可用时间的订单
|
||||
* 处理超过最大可用时间的订单
|
||||
*/
|
||||
public void closeExpireMaxTimeOrder() {
|
||||
public void handleExpireMaxTimeOrder() {
|
||||
// 查询超过最大可用时间的订单
|
||||
OrderQuery query = new OrderQuery();
|
||||
query.setStatusList(OrderStatus.inUse());
|
||||
|
@ -71,11 +77,12 @@ public class OrderTask implements ApplicationRunner {
|
|||
|
||||
for (OrderVO order : orderList) {
|
||||
try {
|
||||
OrderEndDTO dto = new OrderEndDTO();
|
||||
dto.setReturnType(OrderReturnType.SYSTEM.getCode());
|
||||
dto.setOrderId(order.getId());
|
||||
dto.setEndReason("超时系统自动结束");
|
||||
orderService.endOrder(dto);
|
||||
// OrderEndDTO dto = new OrderEndDTO();
|
||||
// dto.setReturnType(OrderReturnType.SYSTEM.getCode());
|
||||
// dto.setOrderId(order.getId());
|
||||
// dto.setEndReason("超时系统自动结束");
|
||||
// orderService.endOrder(dto);
|
||||
iotService.play(order, IotConstants.PLAY_END, "超时系统警告");
|
||||
} catch (Exception e) {
|
||||
log.error("结束订单失败,订单ID:{}", order.getId(), e);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class AppDeviceIotController extends BaseController {
|
|||
ServiceUtil.assertion(device == null, "当前车辆不存在,无法响铃寻车");
|
||||
|
||||
if (device.getAreaRequiredRingRadius() != null && device.getAreaRequiredRingRadius()) {
|
||||
ServiceUtil.assertion(lon == null || lat == null, "请开启定位后重试");
|
||||
BigDecimal distance = GeoUtils.calculateDistance(device.getLatitude(), device.getLongitude(), lat, lon);
|
||||
ServiceUtil.assertion(MathUtils.biggerThan(distance, device.getAreaRingRadius()),
|
||||
"您当前距离车辆%s米,无法响铃寻车。请距离车辆%s米以内再试", distance, device.getAreaRingRadius());
|
||||
|
|
|
@ -1,12 +1,51 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.bst.locationLog.domain.LocationLogQuery;
|
||||
import com.ruoyi.bst.locationLog.domain.LocationLogVO;
|
||||
import com.ruoyi.bst.locationLog.service.LocationLogService;
|
||||
import com.ruoyi.bst.order.service.OrderValidator;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/locationLog")
|
||||
public class AppLocationLogController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private LocationLogService locationLogService;
|
||||
|
||||
@Autowired
|
||||
private OrderValidator orderValidator;
|
||||
|
||||
private boolean canView(Long orderId) {
|
||||
return orderValidator.isUser(orderId, getUserId());
|
||||
}
|
||||
|
||||
@ApiOperation("根据订单ID查询定位日志")
|
||||
@GetMapping("/allByOrder")
|
||||
public AjaxResult getAllByOrder(Long orderId) {
|
||||
if (orderId == null) {
|
||||
return error("订单ID不允许为空");
|
||||
}
|
||||
if (!canView(orderId)) {
|
||||
return error("您无权查看ID为" + orderId + "的订单轨迹");
|
||||
}
|
||||
|
||||
LocationLogQuery query = new LocationLogQuery();
|
||||
query.setOrderId(orderId);
|
||||
List<LocationLogVO> list = locationLogService.selectLocationLogList(query);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ public class AppOrderController extends BaseController {
|
|||
OrderVO order = orderService.selectOrderById(orderId);
|
||||
ServiceUtil.assertion(order == null, "订单不存在");
|
||||
ServiceUtil.assertion(!orderValidator.canOpenDevice(order, getUserId()), "您无权操作ID为%s的订单设备开启", order.getId());
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
||||
return success(orderService.openDevice(order, true));
|
||||
}
|
||||
|
||||
|
@ -139,6 +140,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), "当前订单已超时,请在安全的区域还车");
|
||||
dto.setRequiredIot(true);
|
||||
return success(orderService.closeDevice(dto));
|
||||
}
|
||||
|
@ -149,6 +151,7 @@ public class AppOrderController extends BaseController {
|
|||
public AjaxResult changeDevice(@RequestBody @Validated OrderChangeDeviceDTO dto) {
|
||||
OrderVO order = orderService.selectOrderById(dto.getOrderId());
|
||||
ServiceUtil.assertion(!orderValidator.canChangeDevice(order, getUserId()), "您无权操作ID为%s的订单换车", order.getId());
|
||||
ServiceUtil.assertion(orderValidator.isTimeout(order), "当前订单已超时,请在安全的区域还车");
|
||||
dto.setUserId(getUserId());
|
||||
dto.setUserName(getNickName());
|
||||
return toAjax(orderService.changeDevice(dto));
|
||||
|
|
Loading…
Reference in New Issue
Block a user