459242451@qq.com 3 years ago
parent
commit
95b56067a8

+ 25 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlElectricDeviceLocationController.java

@@ -13,6 +13,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
@@ -33,7 +34,6 @@ public class TlElectricDeviceLocationController extends BaseController {
     /**
      * 查询电动车定位设备轨迹列表
      */
-    @PreAuthorize("@ss.hasPermi('qdtl:location:list')")
     @GetMapping("/list")
     public TableDataInfo list(TlElectricDeviceLocation tlElectricDeviceLocation) {
         startPage();
@@ -41,6 +41,16 @@ public class TlElectricDeviceLocationController extends BaseController {
         return getDataTable(list);
     }
 
+    @GetMapping("/queryLocationRecord")
+    public AjaxResult queryLocationRecord(@RequestParam String startDate,
+                                          @RequestParam String endDate,
+                                          @RequestParam(required = false) String areaName,
+                                          @RequestParam(required = false) String imei) {
+        startDate = startDate + " 00:00:00";
+        endDate = endDate + "23:59:59";
+        return AjaxResult.success(tlElectricDeviceLocationService.queryLocationRecord(startDate, endDate, areaName, imei));
+    }
+
     @PostMapping("/syncDeviceLocation")
     public AjaxResult syncDeviceLocation() {
         tlElectricDeviceLocationService.syncDeviceLocation();
@@ -53,6 +63,20 @@ public class TlElectricDeviceLocationController extends BaseController {
     }
 
     /**
+     * 获取单个设备轨迹
+     *
+     * @return
+     */
+    @GetMapping("/getSingleElectricLocation")
+    public AjaxResult getSingleElectricLocation(@RequestParam String startDate,
+                                                @RequestParam String endDate,
+                                                @RequestParam String imei) {
+        startDate = startDate + " 00:00:00";
+        endDate = endDate + "23:59:59";
+        return AjaxResult.success(tlElectricDeviceLocationService.getSingleElectricLocation(startDate, endDate, imei));
+    }
+
+    /**
      * 导出电动车定位设备轨迹列表
      */
     @PreAuthorize("@ss.hasPermi('qdtl:location:export')")

+ 5 - 6
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java

@@ -3,20 +3,19 @@ package com.ruoyi.quartz.config;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+
 import javax.sql.DataSource;
 import java.util.Properties;
 
 /**
  * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class ScheduleConfig
-{
+public class ScheduleConfig {
     @Bean
-    public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
-    {
+    public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
         SchedulerFactoryBean factory = new SchedulerFactoryBean();
         factory.setDataSource(dataSource);
 
@@ -26,7 +25,7 @@ public class ScheduleConfig
         prop.put("org.quartz.scheduler.instanceId", "AUTO");
         // 线程池配置
         prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
-        prop.put("org.quartz.threadPool.threadCount", "20");
+        prop.put("org.quartz.threadPool.threadCount", "100");
         prop.put("org.quartz.threadPool.threadPriority", "5");
         // JobStore配置
         prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");

+ 53 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/ElectricDeviceLocationRecord.java

@@ -0,0 +1,53 @@
+package com.ruoyi.qdtl.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 电动车定位设备轨迹对象 tl_electric_device_location
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@Data
+public class ElectricDeviceLocationRecord {
+
+    /**
+     * 设备IMEI
+     */
+    @Excel(name = "设备IMEI")
+    private String imei;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /**
+     * 经度 (如果设备过期,值为0)
+     */
+    @Excel(name = "经度 (如果设备过期,值为0)")
+    private String lng;
+
+    /**
+     * 纬度 (如果设备过期,值为0)
+     */
+    @Excel(name = "纬度 (如果设备过期,值为0)")
+    private String lat;
+
+    /**
+     * GPS定位时间
+     */
+    @Excel(name = "GPS定位时间")
+    private String gpsTime;
+
+    /**
+     * 里程统计
+     */
+    @Excel(name = "里程统计")
+    private String mileage;
+
+    private String dayMileage;
+
+}

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlElectricDeviceLocationMapper.java

@@ -1,5 +1,6 @@
 package com.ruoyi.qdtl.mapper;
 
+import com.ruoyi.qdtl.domain.ElectricDeviceLocationRecord;
 import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
 import org.apache.ibatis.annotations.Param;
 
@@ -57,4 +58,8 @@ public interface TlElectricDeviceLocationMapper {
     List<TlElectricDeviceLocation> queryListByDate(@Param("today") String today);
 
     List<TlElectricDeviceLocation> queryMaxNewDevice();
+
+    List<ElectricDeviceLocationRecord> queryLocationRecord(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("areaName") String areaName, @Param("imei") String imei);
+
+    List<TlElectricDeviceLocation> getSingleElectricLocation(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("imei") String imei);
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlElectricDeviceLocationService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.qdtl.service;
 
+import com.ruoyi.qdtl.domain.ElectricDeviceLocationRecord;
 import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
 
 import java.util.List;
@@ -62,4 +63,8 @@ public interface ITlElectricDeviceLocationService {
     List<TlElectricDeviceLocation> queryListByDate(String today);
 
     Map<String, Object> getAllElectricDetail();
+
+    List<ElectricDeviceLocationRecord> queryLocationRecord(String startDate, String endDate, String areaName, String imei);
+
+    List<TlElectricDeviceLocation> getSingleElectricLocation(String startDate, String endDate, String imei);
 }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/QdCommonServiceImpl.java

@@ -255,13 +255,13 @@ public class QdCommonServiceImpl implements IQdCommonService {
             // 私有参数
             paramMap.put("user_id", "启东市铁路巡逻电瓶车");
             paramMap.put("user_pwd_md5", "62ea9d1a6f6cfe766c69656c4869a819");
-            paramMap.put("expires_in", "7200");
+            paramMap.put("expires_in", "600");
             String post = HttpUtil.post(electricCarsOpenApiUrl, paramMap);
             JSONObject postJson = JSONUtil.parseObj(post);
             if (0 == postJson.getInt("code")) {
                 token = postJson.getJSONObject("result").getStr("accessToken");
                 // 存入缓存
-                redisCache.setCacheObject("electric:token", token, 7000, TimeUnit.SECONDS);
+                redisCache.setCacheObject("electric:token", token, 600, TimeUnit.SECONDS);
             } else {
                 log.error("获取电动车定位平台接口的token失败:{}", postJson);
                 throw new ServiceException("获取电动车定位平台接口的token失败");

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlElectricDeviceLocationServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.qdtl.service.impl;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
+import com.ruoyi.qdtl.domain.ElectricDeviceLocationRecord;
 import com.ruoyi.qdtl.domain.TlElectricCarMileage;
 import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
 import com.ruoyi.qdtl.mapper.TlElectricDeviceLocationMapper;
@@ -126,4 +127,16 @@ public class TlElectricDeviceLocationServiceImpl implements ITlElectricDeviceLoc
         result.put("detail", list);
         return result;
     }
+
+    @Override
+    public List<ElectricDeviceLocationRecord> queryLocationRecord(String startDate, String endDate, String areaName, String imei) {
+        List<ElectricDeviceLocationRecord> list = tlElectricDeviceLocationMapper.queryLocationRecord(startDate, endDate, areaName, imei);
+        return list;
+    }
+
+    @Override
+    public List<TlElectricDeviceLocation> getSingleElectricLocation(String startDate, String endDate, String imei) {
+        List<TlElectricDeviceLocation> list = tlElectricDeviceLocationMapper.getSingleElectricLocation(startDate, endDate, imei);
+        return list;
+    }
 }

+ 32 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlElectricDeviceLocationMapper.xml

@@ -92,6 +92,38 @@
                  left join tl_electric_device_location r on t.imei = r.imei and t.id = r.id
     </select>
 
+    <select id="queryLocationRecord" resultType="com.ruoyi.qdtl.domain.ElectricDeviceLocationRecord">
+        select
+        r.imei,
+        device_name deviceName,
+        lng,
+        lat,
+        date_format(gps_time, '%Y-%m-%d') as gpsTime,
+        mileage
+        from (
+        select imei, max(id) id
+        from tl_electric_device_location
+        where gps_time &gt;= #{startDate}
+        and gps_time &lt;= #{endDate}
+        <if test="imei != null and imei != ''">
+            and imei = #{imei}
+        </if>
+        <if test="areaName != null and areaName != ''">
+            and left(device_name, 3) = #{areaName}
+        </if>
+        group by imei, date_format(gps_time, '%Y-%m-%d')
+        ) t
+        left join tl_electric_device_location r on t.imei = r.imei and t.id = r.id
+    </select>
+
+    <select id="getSingleElectricLocation" resultMap="TlElectricDeviceLocationResult">
+        <include refid="selectTlElectricDeviceLocationVo"/>
+        where gps_time &gt;= #{startDate}
+        and gps_time &lt;= #{endDate}
+        and imei = #{imei}
+        order by gps_time desc
+    </select>
+
     <insert id="insertTlElectricDeviceLocation" parameterType="TlElectricDeviceLocation" useGeneratedKeys="true" keyProperty="id">
         insert into tl_electric_device_location
         <trim prefix="(" suffix=")" suffixOverrides=",">