优化日志

This commit is contained in:
磷叶 2025-06-13 10:02:18 +08:00
parent 16b78a9dbb
commit 6000048a05
3 changed files with 22 additions and 31 deletions

View File

@ -24,7 +24,6 @@ import com.ruoyi.bst.bonus.service.BonusService;
import com.ruoyi.bst.channel.service.ChannelService;
import com.ruoyi.bst.device.domain.Device;
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;
@ -37,7 +36,6 @@ import com.ruoyi.bst.fault.service.FaultService;
import com.ruoyi.bst.feeLog.domain.FeeLog;
import com.ruoyi.bst.feeLog.service.FeeLogConverter;
import com.ruoyi.bst.feeLog.service.FeeLogService;
import com.ruoyi.bst.locationLog.domain.LocationLog;
import com.ruoyi.bst.locationLog.service.LocationLogConverter;
import com.ruoyi.bst.locationLog.utils.LocationLogUtil;
import com.ruoyi.bst.order.constants.OrderConstants;
@ -94,7 +92,6 @@ import com.ruoyi.bst.sms.service.SmsService;
import com.ruoyi.bst.vipUser.domain.VipUserVO;
import com.ruoyi.bst.vipUser.service.VipUserService;
import com.ruoyi.bst.vipUser.utils.VipUserUtil;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey;
@ -104,7 +101,6 @@ 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;
@ -537,14 +533,12 @@ public class OrderServiceImpl implements OrderService {
private void setLogParam(DeviceVO device) {
if (device != null) {
LogParamHolder.set(LogParamHolder.DEVICE_ID, device.getId());
if (DeviceLocationType.DEVICE.getCode().equals(device.getLocationType())) {
LogParamHolder.set(LogParamHolder.DEVICE_LON, device.getLongitude());
LogParamHolder.set(LogParamHolder.DEVICE_LAT, device.getLatitude());
}
LogParamHolder.set(LogParamHolder.DEVICE_LON, device.getLongitude());
LogParamHolder.set(LogParamHolder.DEVICE_LAT, device.getLatitude());
}
}
// 异步使用手机定位更新设备定位
// 设置手机定位
private void handleDeviceLocationAsync(DeviceVO device, BigDecimal lon, BigDecimal lat) {
if (device != null && device.getId() != null && StringUtils.isNotBlank(device.getMac()) && DeviceUtil.validMobileLocation(lon, lat)) {
// 更新设备手机定位
@ -555,7 +549,7 @@ public class OrderServiceImpl implements OrderService {
data.setMobileLocationTime(LocalDateTime.now());
int rows = deviceIotService.updateIot(data);
if (rows != 1) {
log.error("通过手机定位修改设备定位失败deviceMac={}", device.getMac());
log.error("更新手机定位失败,deviceMac={}", device.getMac());
}
}
}
@ -658,21 +652,12 @@ public class OrderServiceImpl implements OrderService {
public OrderFeeVO calcFee(OrderCalcFeeDTO dto) {
// 查询订单
OrderVO order = this.selectOrderById(dto.getOrderId());
if (order == null) {
return null;
}
// 查询当前设备
OrderDeviceVO orderDevice = orderDeviceService.selectOrderDeviceById(order.getOrderDeviceId());
if (orderDevice == null) {
return null;
}
ServiceUtil.assertion(order == null, "ID为%s的订单不存在", dto.getOrderId());
// 设备信息
DeviceVO device = deviceService.selectDeviceById(order.getDeviceId());
if (device == null) {
return null;
}
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", order.getDeviceId());
// 设置日志参数
this.setLogParam(device);
// 处理设备位置
@ -680,9 +665,7 @@ public class OrderServiceImpl implements OrderService {
// 查询运营区
AreaVO area = areaService.selectAreaById(order.getAreaId());
if (area == null) {
return null;
}
ServiceUtil.assertion(area == null, "ID为%s的运营区不存在", order.getAreaId());
// 查询还车点
List<AreaSubVO> parkingList = areaSubService.selectParkingAreaByAreaId(area.getId());

View File

@ -184,7 +184,6 @@ public class OrderValidatorImpl implements OrderValidator{
@Override
public void checkInParking(AreaVO area, OrderInParkingVO inParkingVO) {
log.info("【还车定位校验】运营区:{},定位数据:{}", area.getName(), inParkingVO);
ServiceUtil.assertion(inParkingVO == null, "参数错误,停车点信息不存在");
ServiceUtil.assertion(area == null, "参数错误,运营区信息不存在");
@ -195,14 +194,23 @@ public class OrderValidatorImpl implements OrderValidator{
boolean mustInParking = area.getParkingReturn() != null && area.getParkingReturn();
boolean inParking = inParkingVO.getInParking() != null && inParkingVO.getInParking();
ServiceUtil.assertion(mustInParking && !inParking, "请将车辆停放在停车点内", ServiceCode.RETURN_MUST_IN_PARKING);
if (mustInParking && !inParking) {
log.error("请将车辆停放在停车点内,运营区:{},定位数据:{}", area, inParkingVO);
ServiceUtil.assertion(true, "请将车辆停放在停车点内", ServiceCode.RETURN_MUST_IN_PARKING);
}
boolean isInNoParking = inParkingVO.getInNoParking() != null && inParkingVO.getInNoParking();
ServiceUtil.assertion(isInNoParking, "请勿将车辆停放在禁停区内", ServiceCode.RETURN_IN_NO_PARKING);
if (isInNoParking) {
log.error("请勿将车辆停放在禁停区内,运营区:{},定位数据:{}", area, inParkingVO);
ServiceUtil.assertion(true, "请勿将车辆停放在禁停区内", ServiceCode.RETURN_IN_NO_PARKING);
}
boolean mustInArea = area.getAreaOutReturn() != null && !area.getAreaOutReturn();
boolean inArea = inParkingVO.getInArea() != null && inParkingVO.getInArea();
ServiceUtil.assertion(mustInArea && !inArea, "请将车辆停放在运营区内", ServiceCode.RETURN_MUST_IN_AREA);
if (mustInArea && !inArea) {
log.error("请将车辆停放在运营区内,运营区:{},定位数据:{}", area, inParkingVO);
ServiceUtil.assertion(true, "请将车辆停放在运营区内", ServiceCode.RETURN_MUST_IN_AREA);
}
}
@Override

View File

@ -154,9 +154,9 @@ public class AppOrderController extends BaseController {
return error("关闭订单失败");
}
@ApiOperation("计算订单费用")
@ApiOperation("计算订单费用(校验还车位置)")
@PostMapping("/calcFee")
@Log(title = "计算订单费用", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.ORDER)
@Log(title = "计算订单费用(校验还车位置)", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.ORDER)
public AjaxResult calcFee(@RequestBody @Validated OrderCalcFeeDTO dto) {
// 设置日志参数
LogParamHolder.set(LogParamHolder.PARAM_LON, dto.getLon());