diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/DataPushApi.java b/ruoyi-admin/src/main/java/com/ruoyi/api/DataPushApi.java index 24ebcf6..7977428 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/DataPushApi.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/DataPushApi.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.orders.domain.ZcOrderSub; import com.ruoyi.orders.dto.PushItemRequest; import com.ruoyi.orders.dto.RefundRequest; +import com.ruoyi.orders.dto.TrajectoryPoint; +import com.ruoyi.orders.util.OrderTrajectoryResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -13,6 +15,8 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; import java.util.Map; @Service @@ -36,6 +40,10 @@ public class DataPushApi { @Value(value = "${dataPush.sendAddUserUrl}") private String sendAddUserUrl; + + @Value(value = "${dataPush.orderTrajectoryUrl}") + private String orderTrajectoryUrl; + /** * 发送添加运营商信息 * @param companyId @@ -219,4 +227,66 @@ public class DataPushApi { } } + + + /** + * 获取订单轨迹 + * @param clientId + * @param startTm + * @param endTm + * @return + */ + public List fetchOrderTrajectory(String clientId, String startTm, String endTm) { + try { + // 准备请求参数 + Map requestBody = new HashMap<>(); + requestBody.put("clientId", clientId); + requestBody.put("startTm", startTm); + requestBody.put("endTm", endTm); + + // 打印请求参数便于调试 + String jsonParams = objectMapper.writeValueAsString(requestBody); + logger.info("订单轨迹请求参数: {}", jsonParams); + + // 发送HTTP POST请求调用订单轨迹接口 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity response = restTemplate.postForEntity(orderTrajectoryUrl, requestEntity, String.class); + + // 处理订单轨迹接口响应 + if (response.getStatusCode() == HttpStatus.OK) { + String responseBody = response.getBody(); + if (responseBody != null) { + try { + // 使用ObjectMapper解析JSON响应 + OrderTrajectoryResponse result = objectMapper.readValue(responseBody, OrderTrajectoryResponse.class); + if (result.getCode() != null && result.getCode() == 200) { + logger.info("获取订单轨迹成功,客户端ID: {},轨迹点数量: {}", clientId, + result.getData() != null ? result.getData().size() : 0); + return result.getData(); + } else { + logger.error("获取订单轨迹失败,客户端ID: {},响应: {}", clientId, responseBody); + return null; + } + } catch (Exception jsonEx) { + logger.error("解析订单轨迹接口响应异常,客户端ID: {},响应: {}", clientId, responseBody, jsonEx); + return null; + } + } else { + logger.error("订单轨迹接口返回空响应,客户端ID: {}", clientId); + return null; + } + } else { + logger.error("获取订单轨迹失败,客户端ID: {},响应: {}", clientId, response.getBody()); + return null; + } + } catch (Exception e) { + logger.error("调用订单轨迹接口异常,客户端ID: " + clientId, e); + return null; + } + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/orders/controller/ZcOrderMainController.java b/ruoyi-admin/src/main/java/com/ruoyi/orders/controller/ZcOrderMainController.java index 5895966..6413d04 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/orders/controller/ZcOrderMainController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/orders/controller/ZcOrderMainController.java @@ -4,16 +4,19 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import com.ruoyi.api.DataPushApi; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.operation.domain.Company; import com.ruoyi.operation.service.ICompanyService; import com.ruoyi.orders.domain.ZcOrderCarChange; import com.ruoyi.orders.dto.StatisticsHomeOrder; +import com.ruoyi.orders.dto.TrajectoryPoint; import com.ruoyi.orders.service.IZcOrderCarChangeService; import com.ruoyi.orders.util.OrderStatusEnum; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; @@ -48,6 +51,9 @@ public class ZcOrderMainController extends BaseController private IZcOrderCarChangeService zcOrderCarChangeService; @Autowired private ICompanyService companyService; + @Autowired + private DataPushApi dataPushApi; + @RequiresPermissions("orders:order:view") @GetMapping() @@ -166,6 +172,57 @@ public class ZcOrderMainController extends BaseController return toAjax(flag); } + /** + * 租车订单轨迹 + */ + @GetMapping("/orderTrajectory/{id}") + public String orderTrajectory(@PathVariable("id") Long id, ModelMap mmap) + { + // 调用 + List trajectoryPoints = dataPushApi.fetchOrderTrajectory("15135683068", "2025-10-10 08:08:80", "2025-10-10 16:80:00"); + + +// List trajectoryPoints = new ArrayList<>(); +// double[][] testData = { +// {112.925285, 27.900163}, {112.925285, 27.900163}, {112.925285, 27.900163}, +// {112.925285, 27.900163}, {112.925285, 27.900163}, {112.925285, 27.900163}, +// {112.925285, 27.900163}, {112.925285, 27.900163}, {112.925285, 27.900163}, +// {112.925285, 27.900163}, {112.925285, 27.900163}, {112.925285, 27.900163}, +// {112.925285, 27.900163}, {112.925285, 27.900163}, {112.925285, 27.900163}, +// {112.925285, 27.900163}, {112.925285, 27.900163}, {112.925855, 27.898977}, +// {112.925745, 27.898878}, {112.9261, 27.898802}, {112.926718, 27.898633}, +// {112.927295, 27.898673}, {112.92779, 27.898652}, {112.928342, 27.898685}, +// {112.928483, 27.89868}, {112.929135, 27.898667}, {112.9299, 27.898445}, +// {112.930225, 27.898263}, {112.93024, 27.898233}, {112.930213, 27.898052}, +// {112.929905, 27.897193}, {112.929437, 27.895972}, {112.929417, 27.895775}, +// {112.929483, 27.895702}, {112.929832, 27.895443}, {112.929875, 27.89528}, +// {112.930153, 27.894773}, {112.930123, 27.894712}, {112.929758, 27.894537}, +// {112.929558, 27.894395}, {112.929668, 27.894208}, {112.929712, 27.89416}, +// {112.930053, 27.893827}, {112.930018, 27.89383}, {112.930027, 27.893798}, +// {112.930027, 27.893798}, {112.930027, 27.893798}, {112.93002, 27.893797}, +// {112.93002, 27.893797}, {112.93002, 27.893797}, {112.929775, 27.89305}, +// {112.929775, 27.89305}, {112.92978, 27.893495}, {112.92978, 27.893495} +// }; +// // 创建轨迹点列表 +// for (int i = 0; i < testData.length; i++) { +// TrajectoryPoint point = new TrajectoryPoint(); +// point.setLng(testData[i][0]); // 经度 +// point.setLat(testData[i][1]); // 纬度 +// // 时间戳可以按需添加 +// // point.setTs("2025-10-17 14:" + String.format("%02d", (39 + i)) + ":36.0"); +// trajectoryPoints.add(point); +// } + + // 设置中心点和轨迹点列表 + if (!trajectoryPoints.isEmpty()) { + mmap.put("centerPoint", trajectoryPoints.get(0)); + mmap.put("orderTrajectoryPointList", trajectoryPoints); + mmap.put("orderTrajectoryPointLen", trajectoryPoints.size()-1); + } + return prefix + "/orderTrajectory"; + } + + @PostMapping("/statisticsHomeOrder") @ResponseBody public AjaxResult statisticsHomeOrder(String type) { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/orders/dto/TrajectoryPoint.java b/ruoyi-admin/src/main/java/com/ruoyi/orders/dto/TrajectoryPoint.java new file mode 100644 index 0000000..3cc6c03 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/orders/dto/TrajectoryPoint.java @@ -0,0 +1,18 @@ +package com.ruoyi.orders.dto; + +public class TrajectoryPoint { + + private Double lng; // 经度 + private Double lat; // 纬度 + private String ts; // 时间戳 + + // getter和setter方法 + public Double getLng() { return lng; } + public void setLng(Double lng) { this.lng = lng; } + + public Double getLat() { return lat; } + public void setLat(Double lat) { this.lat = lat; } + + public String getTs() { return ts; } + public void setTs(String ts) { this.ts = ts; } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/orders/util/OrderTrajectoryResponse.java b/ruoyi-admin/src/main/java/com/ruoyi/orders/util/OrderTrajectoryResponse.java new file mode 100644 index 0000000..77bfad9 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/orders/util/OrderTrajectoryResponse.java @@ -0,0 +1,22 @@ +package com.ruoyi.orders.util; + +import com.ruoyi.orders.dto.TrajectoryPoint; + +import java.util.List; + +public class OrderTrajectoryResponse { + + private Integer code; + private List data; + + // getter和setter方法 + public Integer getCode() { return code; } + public void setCode(Integer code) { this.code = code; } + + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } +} diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 3b72e11..35a615f 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -87,7 +87,10 @@ dataPush: refundUrl: http://115.190.8.52:8019/api/payment/refund alirefundUrl: http://115.190.8.52:8019/api/alipay/refund pushItemUrl: http://115.190.8.52:8019/item/sync/item + # 轨迹接口地址 + orderTrajectoryUrl: http://106.14.7.172:8100/device/getHistoryDeviceInfo sendAddCompanyUrl: http://sczx-sync-container:8016/send/companyinfo/ sendAddStoreUrl: http://sczx-sync-container:8016/send/storeinfo/ sendAddUserUrl: http://sczx-sync-container:8016/send/userinfo/ + diff --git a/ruoyi-admin/src/main/resources/static/img/model_taxi.png b/ruoyi-admin/src/main/resources/static/img/model_taxi.png new file mode 100644 index 0000000..55488d9 Binary files /dev/null and b/ruoyi-admin/src/main/resources/static/img/model_taxi.png differ diff --git a/ruoyi-admin/src/main/resources/templates/orders/order/order.html b/ruoyi-admin/src/main/resources/templates/orders/order/order.html index 433c6ea..1ce8d3b 100644 --- a/ruoyi-admin/src/main/resources/templates/orders/order/order.html +++ b/ruoyi-admin/src/main/resources/templates/orders/order/order.html @@ -263,11 +263,41 @@ field: 'startRentTime', title: '开始计费时间', width: '160px' + }, + { + title: '操作', + align: 'center', + width: '100px', + formatter: function(value, row, index) { + var actions = []; + actions.push('轨迹 '); + return actions.join(''); + } }] }; $.table.init(options); }); + function orderTrajectory(id){ + var url = prefix + "/orderTrajectory/" + id; + top.layer.open({ + type: 2, + area: ['1400px', '800px'], + fix: false, + //不固定 + maxmin: true, + shade: 0.3, + title: "订单轨迹回放", + content: url, + btn: ['关闭'], + // 弹层外区域关闭 + shadeClose: true, + cancel: function(index) { + return true; + } + }); + //$.modal.open("订单轨迹", prefix + "/orderTrajectory/" + id, '1400', '800', false); + } function manualClose(id){ var index = layer.open({ type: 2, // iframe模式 diff --git a/ruoyi-admin/src/main/resources/templates/orders/order/orderTrajectory.html b/ruoyi-admin/src/main/resources/templates/orders/order/orderTrajectory.html new file mode 100644 index 0000000..a627bc6 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/orders/order/orderTrajectory.html @@ -0,0 +1,334 @@ + + + + + + + marker轨迹回放-跟随模式 + + + + + + +
+ + + + + +
+

+

+

当前小车行驶距离:0米

+

+
+
+
+ + +