From 4d4eb6e9addc4ce148e05f470beb016e507975ba Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期一, 27 四月 2026 17:21:06 +0800
Subject: [PATCH] 小程序二维码 支持改价 自主行程查询
---
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineSiteServiceImpl.java | 147 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 147 insertions(+), 0 deletions(-)
diff --git a/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineSiteServiceImpl.java b/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineSiteServiceImpl.java
index b8307d4..74b172d 100644
--- a/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineSiteServiceImpl.java
+++ b/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineSiteServiceImpl.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.crossCity.server.impl;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
@@ -9,12 +10,14 @@
import com.stylefeng.guns.modular.crossCity.model.*;
import com.stylefeng.guns.modular.crossCity.server.ILineSiteService;
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
+import com.stylefeng.guns.modular.crossCity.warpper.LocationWarpper;
import com.stylefeng.guns.modular.crossCity.warpper.SiteWarpper;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.util.DateUtil;
import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil;
import com.stylefeng.guns.modular.system.util.GDMapGeocodingUtil;
+import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.SystemException;
import com.stylefeng.guns.modular.system.util.model.GeoFencingPolygon;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
@@ -50,6 +53,9 @@
@Resource
private LocationMapper locationMapper;
+
+ @Resource
+ private DriverSelfTripMapper driverSelfTripMapper;
@Autowired
private DateUtil dateUtil;
@@ -287,6 +293,147 @@
return locationMapper.queryLocation(siteId);
}
+ @Override
+ public ResultUtil<List<LocationWarpper>> querySelfLocation(Integer driverId, Integer lineShiftDriverId, Integer type) throws Exception {
+ if (driverId == null) {
+ return ResultUtil.tokenErr();
+ }
+ if (lineShiftDriverId == null || type == null) {
+ return ResultUtil.paranErr();
+ }
+ if (type != 1 && type != 2) {
+ return ResultUtil.error("type参数错误");
+ }
+ LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(lineShiftDriverId);
+ if (lineShiftDriver == null) {
+ return ResultUtil.error("班次信息不存在");
+ }
+ if (!driverId.equals(lineShiftDriver.getDriverId())) {
+ return ResultUtil.error("无权操作此班次");
+ }
+ if (lineShiftDriver.getCustomerId() == null) {
+ return ResultUtil.error("自主行程信息不存在");
+ }
+ DriverSelfTrip selfTrip = driverSelfTripMapper.selectById(lineShiftDriver.getCustomerId());
+ if (selfTrip == null || selfTrip.getState() == null || selfTrip.getState() != 1) {
+ return ResultUtil.error("自主行程信息不存在");
+ }
+
+ List<LocationWarpper> data = new ArrayList<>();
+ if (type == 1) {
+ if (selfTrip.getStartLon() == null || selfTrip.getStartLat() == null) {
+ return ResultUtil.error("上车点坐标不存在");
+ }
+ data.add(buildCircleLocation(selfTrip.getStartLon(), selfTrip.getStartLat()));
+ return ResultUtil.success(data);
+ }
+
+ if (ToolUtil.isEmpty(selfTrip.getDestJson())) {
+ return ResultUtil.success(data);
+ }
+ JSONArray array = JSON.parseArray(selfTrip.getDestJson());
+ if (array == null) {
+ return ResultUtil.success(data);
+ }
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject item = array.getJSONObject(i);
+ if (item == null) {
+ continue;
+ }
+ Double endLon = item.getDouble("endLon");
+ Double endLat = item.getDouble("endLat");
+ if (endLon == null || endLat == null) {
+ continue;
+ }
+ data.add(buildCircleLocation(endLon, endLat));
+ }
+ return ResultUtil.success(data);
+ }
+
+ private LocationWarpper buildCircleLocation(Double lon, Double lat) {
+ LocationWarpper locationWarpper = new LocationWarpper();
+ locationWarpper.setType(2);
+ locationWarpper.setCoordinate(lon + "," + lat + ";3000");
+ locationWarpper.setProvince("");
+ locationWarpper.setProvinceCode("");
+ locationWarpper.setCity("");
+ locationWarpper.setCityCode("");
+ locationWarpper.setDistrict("");
+ locationWarpper.setDistrictCode("");
+ return locationWarpper;
+ }
+
+ @Override
+ public boolean selfAreaMonitoring(Integer driverId, Integer lineShiftDriverId, Integer type, String lonLat) throws Exception {
+ if (driverId == null || lineShiftDriverId == null || type == null || ToolUtil.isEmpty(lonLat)) {
+ return false;
+ }
+ if (type != 1 && type != 2) {
+ return false;
+ }
+ String[] pointArr = lonLat.split(",");
+ if (pointArr.length != 2) {
+ return false;
+ }
+ Double pointLon;
+ Double pointLat;
+ try {
+ pointLon = Double.valueOf(pointArr[0]);
+ pointLat = Double.valueOf(pointArr[1]);
+ } catch (Exception e) {
+ return false;
+ }
+
+ LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(lineShiftDriverId);
+ if (lineShiftDriver == null || !driverId.equals(lineShiftDriver.getDriverId()) || lineShiftDriver.getCustomerId() == null) {
+ return false;
+ }
+ DriverSelfTrip selfTrip = driverSelfTripMapper.selectById(lineShiftDriver.getCustomerId());
+ if (selfTrip == null || selfTrip.getState() == null || selfTrip.getState() != 1) {
+ return false;
+ }
+
+ if (type == 1) {
+ return isWithinCircle(selfTrip.getStartLon(), selfTrip.getStartLat(), pointLon, pointLat, 3000D);
+ }
+
+ if (ToolUtil.isEmpty(selfTrip.getDestJson())) {
+ return false;
+ }
+ JSONArray array = JSON.parseArray(selfTrip.getDestJson());
+ if (array == null || array.isEmpty()) {
+ return false;
+ }
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject item = array.getJSONObject(i);
+ if (item == null) {
+ continue;
+ }
+ Double endLon = item.getDouble("endLon");
+ Double endLat = item.getDouble("endLat");
+ if (isWithinCircle(endLon, endLat, pointLon, pointLat, 3000D)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isWithinCircle(Double centerLon, Double centerLat, Double pointLon, Double pointLat, Double radiusMeter) {
+ if (centerLon == null || centerLat == null || pointLon == null || pointLat == null || radiusMeter == null) {
+ return false;
+ }
+ double earthRadius = 6371000D;
+ double lat1 = Math.toRadians(centerLat);
+ double lat2 = Math.toRadians(pointLat);
+ double deltaLat = lat2 - lat1;
+ double deltaLon = Math.toRadians(pointLon - centerLon);
+ double a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2)
+ + Math.cos(lat1) * Math.cos(lat2) * Math.sin(deltaLon / 2) * Math.sin(deltaLon / 2);
+ double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+ double distance = earthRadius * c;
+ return distance <= radiusMeter;
+ }
+
/**
--
Gitblit v1.7.1