haungfuli преди 2 години
родител
ревизия
5b5b8dfd34

+ 2 - 7
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/HyOrderTravelPathController.java

@@ -1,14 +1,9 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.openapi.sdk.service.DataExchangeService;
-import com.yh.saas.common.support.util.IdGenerator;
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.HyOrderTravelPath;
-import com.yh.saas.plugin.yiliangyiyun.entity.HyToken;
-import com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo;
 import com.yh.saas.plugin.yiliangyiyun.service.IHyOrderTravelPathService;
-import com.yh.saas.plugin.yiliangyiyun.service.IHyTokenService;
 import com.yh.saas.plugin.yiliangyiyun.util.Log;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -49,7 +44,7 @@ public class HyOrderTravelPathController {
      */
     @Log(title = "查看轨迹")
     @GetMapping("/getInfo")
-    public HyOrderTravelPath getInfo(HyOrderTravelPath hyOrderTravelPath){
+    public Page<HyOrderTravelPath> getInfo(HyOrderTravelPath hyOrderTravelPath){
         return hyOrderTravelPathService.getInfo(hyOrderTravelPath);
     }
 

+ 18 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/HyOrderTravelPathMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.HyOrderTravelPath;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录订单行程轨迹信息 Mapper 接口
@@ -13,4 +16,19 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  */
 public interface HyOrderTravelPathMapper extends BaseMapper<HyOrderTravelPath> {
 
+    /**
+     * 总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<HyOrderTravelPath> getListByCondition(Map<String, Object> pageView);
 }

+ 2 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IHyOrderTravelPathService.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.HyOrderTravelPath;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -27,7 +28,7 @@ public interface IHyOrderTravelPathService extends IService<HyOrderTravelPath> {
      * @param hyOrderTravelPath
      * @return
      */
-    HyOrderTravelPath getInfo(HyOrderTravelPath hyOrderTravelPath);
+    Page<HyOrderTravelPath> getInfo(HyOrderTravelPath hyOrderTravelPath);
 
     HyOrderTravelPath orderPath(HyOrderTravelPath hyOrderTravelPath)throws Exception;
 }

+ 38 - 22
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/HyOrderTravelPathServiceImpl.java

@@ -3,7 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.openapi.sdk.service.DataExchangeService;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.yiliangyiyun.entity.*;
@@ -11,6 +13,7 @@ import com.yh.saas.plugin.yiliangyiyun.entity.view.GpsView;
 import com.yh.saas.plugin.yiliangyiyun.mapper.HyOrderTravelPathMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.*;
 import com.yh.saas.plugin.yiliangyiyun.util.PositionUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -51,23 +54,23 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String addInfo(HyOrderTravelPath hyOrderTravelPath) {
-        HyOrderTravelPath hyOrderTravelPath1 = this.selectOne(new EntityWrapper<HyOrderTravelPath>()
-                .eq("order_id", hyOrderTravelPath.getOrderId()).eq("delete_flag", "0"));
-        if (hyOrderTravelPath1 == null) {
-            hyOrderTravelPath.setId(IdGenerator.generateUUID());
-            hyOrderTravelPath.setType("1");
-            hyOrderTravelPath.setOrderId(hyOrderTravelPath.getOrderId());
-            hyOrderTravelPath.setLongitudeLatitude(hyOrderTravelPath.getLongitudeLatitude());
-            hyOrderTravelPath.setStartDate(new Date());
-            this.insert(hyOrderTravelPath);
-        } else {
-            hyOrderTravelPath1.setLongitudeLatitude(hyOrderTravelPath1.getLongitudeLatitude()
-                    .substring(0, hyOrderTravelPath1.getLongitudeLatitude().length() - 1) + ","
-                    + hyOrderTravelPath.getLongitudeLatitude()
-                    .substring(1));
-            hyOrderTravelPath1.setEndDate(new Date());
-            this.updateById(hyOrderTravelPath1);
-        }
+//        HyOrderTravelPath hyOrderTravelPath1 = this.selectOne(new EntityWrapper<HyOrderTravelPath>()
+//                .eq("order_id", hyOrderTravelPath.getOrderId()).eq("delete_flag", "0"));
+//        if (hyOrderTravelPath1 == null) {
+        hyOrderTravelPath.setId(IdGenerator.generateUUID());
+        hyOrderTravelPath.setType("1");
+        hyOrderTravelPath.setOrderId(hyOrderTravelPath.getOrderId());
+        hyOrderTravelPath.setLongitudeLatitude(hyOrderTravelPath.getLongitudeLatitude());
+        hyOrderTravelPath.setStartDate(new Date());
+        this.insert(hyOrderTravelPath);
+//        } else {
+//            hyOrderTravelPath1.setLongitudeLatitude(hyOrderTravelPath1.getLongitudeLatitude()
+//                    .substring(0, hyOrderTravelPath1.getLongitudeLatitude().length() - 1) + ","
+//                    + hyOrderTravelPath.getLongitudeLatitude()
+//                    .substring(1));
+//            hyOrderTravelPath1.setEndDate(new Date());
+//            this.updateById(hyOrderTravelPath1);
+//        }
         return "ok";
     }
 
@@ -79,10 +82,23 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public HyOrderTravelPath getInfo(HyOrderTravelPath hyOrderTravelPath) {
-        HyOrderTravelPath hyOrderTravelPath1 = this.selectOne(new EntityWrapper<HyOrderTravelPath>()
-                .eq("order_id", hyOrderTravelPath.getOrderId()).eq("delete_flag", "0").eq("type", "1"));
-        return hyOrderTravelPath1;
+    public Page<HyOrderTravelPath> getInfo(HyOrderTravelPath hyOrderTravelPath) {
+        Map<String, Object> pageView = new HashMap<>(7);
+        pageView.put("startRecord", (hyOrderTravelPath.getCurrentPage() - 1)
+                * hyOrderTravelPath.getPageSize());
+        //订单id
+        pageView.put("orderId", hyOrderTravelPath.getOrderId());
+        pageView.put("pageSize", hyOrderTravelPath.getPageSize());
+        pageView.put("currentPage", hyOrderTravelPath.getCurrentPage());
+        // 查询总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<HyOrderTravelPath> dataList = baseMapper.getListByCondition(pageView);
+        Page<HyOrderTravelPath> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(hyOrderTravelPath.getCurrentPage());
+        page.setSize(hyOrderTravelPath.getPageSize());
+        return page;
     }
 
 
@@ -215,7 +231,7 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
 //                login();
 //                orderPath(hyOrderTravelPath);
 //            }
-        }else {
+        } else {
             //获取当前年月日
             String date = f.format(new Date(System.currentTimeMillis()));
             map.put("qryEtm", date);

+ 31 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/HyOrderTravelPathMapper.xml

@@ -2,4 +2,35 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yh.saas.plugin.yiliangyiyun.mapper.HyOrderTravelPathMapper">
 
+    <!-- 获得轨迹总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM hy_order_travel_path
+        WHERE delete_flag = '0'
+        AND type = '1'
+        AND order_id = #{orderId}
+    </select>
+
+
+    <!-- 获得轨迹列表 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.HyOrderTravelPath">
+        SELECT
+        id,
+        order_id as orderId,
+        longitude_latitude as longitudeLatitude,
+        start_date as startDate,
+        end_date as endDate,
+        create_date as createDate,
+        update_date as updateDate
+        FROM hy_order_travel_path
+        WHERE delete_flag = '0'
+        AND type = '1'
+        AND order_id = #{orderId}
+        ORDER BY create_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>