瀏覽代碼

add: 电动车轨迹
add:周统计

459242451@qq.com 3 年之前
父節點
當前提交
41dcc4c7a9
共有 22 個文件被更改,包括 1416 次插入18 次删除
  1. 11 16
      README.md
  2. 8 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlCommonController.java
  3. 4 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlDocumentController.java
  4. 104 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlElectricDeviceController.java
  5. 93 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlElectricDeviceLocationController.java
  6. 1 0
      ruoyi-admin/src/main/resources/application.yml
  7. 120 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlElectricDevice.java
  8. 132 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlElectricDeviceLocation.java
  9. 55 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlElectricDeviceLocationMapper.java
  10. 61 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlElectricDeviceMapper.java
  11. 1 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionLocationLogMapper.java
  12. 10 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/IQdCommonService.java
  13. 60 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlElectricDeviceLocationService.java
  14. 68 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlElectricDeviceService.java
  15. 2 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionLocationLogService.java
  16. 98 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/QdCommonServiceImpl.java
  17. 90 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlElectricDeviceLocationServiceImpl.java
  18. 131 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlElectricDeviceServiceImpl.java
  19. 37 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionLocationLogServiceImpl.java
  20. 164 0
      ruoyi-system/src/main/resources/mapper/qdtl/TlElectricDeviceLocationMapper.xml
  21. 158 0
      ruoyi-system/src/main/resources/mapper/qdtl/TlElectricDeviceMapper.xml
  22. 8 0
      ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationLogMapper.xml

+ 11 - 16
README.md

@@ -1,7 +1,7 @@
-
 <h4 align="center">启东市铁路沿线监测平台系统</h4>
 
 ## 平台简介
+
 若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
 
 * 前端采用Vue、Element UI。
@@ -16,15 +16,15 @@
 
 ## 内置功能
 
-1.  用户管理:用户是系统操作者,该功能主要完成系统用户配置。
-2.  部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
-3.  岗位管理:配置系统用户所属担任职务。
-4.  菜单管理:配置系统菜单,操作权限,按钮权限标识等。
-5.  角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
-6.  字典管理:对系统中经常使用的一些较为固定的数据进行维护。
-7.  参数管理:对系统动态配置常用参数。
-8.  通知公告:系统通知公告信息发布维护。
-9.  操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
+1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
+2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
+3. 岗位管理:配置系统用户所属担任职务。
+4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
+5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
+6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
+7. 参数管理:对系统动态配置常用参数。
+8. 通知公告:系统通知公告信息发布维护。
+9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
 10. 登录日志:系统登录日志记录查询包含登录异常。
 11. 在线用户:当前系统中活跃用户状态监控。
 12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
@@ -35,10 +35,5 @@
 17. 在线构建器:拖动表单元素生成相应的HTML代码。
 18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
 
->  打包:mvn clean package -DskipTests -DsendCredentialsOverHttp=true
-
-## 需求
-### 区域管理
-> 1.新增页面:区域类型、编号、名称、描述、范围(类型为1,4时显示)、点位(类型为2,3时显示)、备注
+> 打包:mvn clean package -DskipTests -DsendCredentialsOverHttp=true
 
-> 2.列表页面:展示序号、类型、编号、名称、描述、区域设备(类型为1时。数量值,点击可查询该区域的所有关联设备)、区域巡检点(类型为1时。数量值,点击可查询该区域的所有关联巡检点)、备注

+ 8 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlCommonController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.qdtl;
 
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
@@ -164,7 +165,12 @@ public class TlCommonController extends BaseController {
         Map<String, Object> checkPercent = planRecordService.queryCheckPercent(date);
         map.put("areaStatics", checkPercent.get("areaStatics"));
         map.put("totalStatic", checkPercent.get("totalStatic"));
-
+        // 周巡检里程统计
+        DateTime endDate = DateUtil.yesterday();
+        DateTime startDate = DateUtil.offsetDay(endDate, -6);
+        List<JSONObject> locationLogDaysList = tlInspectionLocationLogService.queryDistanceByDateRange(DateUtil.formatDate(startDate), DateUtil.formatDate(endDate));
+        map.put("locationLogDaysList", locationLogDaysList);
+        
         return AjaxResult.success(map);
     }
 
@@ -202,4 +208,5 @@ public class TlCommonController extends BaseController {
         }
         return AjaxResult.success(data);
     }
+
 }

+ 4 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlDocumentController.java

@@ -73,7 +73,7 @@ public class TlDocumentController extends BaseController {
      * 导出公文管理列表
      */
     @Log(title = "公文管理", businessType = BusinessType.EXPORT)
-    @GetMapping("/export")
+    @RequestMapping(value = "/export", method = {RequestMethod.GET, RequestMethod.POST})
     public void export(@RequestParam Long id, HttpServletResponse response) {
         // 查询公文明细
         TlDocument tlDocument = tlDocumentService.selectTlDocumentById(id);
@@ -172,6 +172,9 @@ public class TlDocumentController extends BaseController {
     @Log(title = "公文管理", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TlDocument tlDocument) {
+        tlDocument.setBasicExample(JSONUtil.toJsonStr(tlDocument.getBasicExample()));
+        tlDocument.setQuestion(JSONUtil.toJsonStr(tlDocument.getQuestion()));
+        tlDocument.setAdvice(JSONUtil.toJsonStr(tlDocument.getAdvice()));
         return toAjax(tlDocumentService.updateTlDocument(tlDocument));
     }
 

+ 104 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlElectricDeviceController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.web.controller.qdtl;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.qdtl.domain.TlElectricDevice;
+import com.ruoyi.qdtl.service.ITlElectricDeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 电动车定位设备Controller
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@RestController
+@RequestMapping("/qdtl/electricDevice")
+public class TlElectricDeviceController extends BaseController {
+    @Autowired
+    private ITlElectricDeviceService tlElectricDeviceService;
+
+    /**
+     * 查询电动车定位设备列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(TlElectricDevice tlElectricDevice) {
+        startPage();
+        List<TlElectricDevice> list = tlElectricDeviceService.selectTlElectricDeviceList(tlElectricDevice);
+        return getDataTable(list);
+    }
+
+    /**
+     * 同步第三方的设备数据到本地
+     *
+     * @return
+     */
+    @PostMapping("/syncDevice")
+    public AjaxResult syncDevice() {
+        return AjaxResult.success(tlElectricDeviceService.syncDevice());
+    }
+
+    /**
+     * 导出电动车定位设备列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:device:export')")
+    @Log(title = "电动车定位设备", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TlElectricDevice tlElectricDevice) {
+        List<TlElectricDevice> list = tlElectricDeviceService.selectTlElectricDeviceList(tlElectricDevice);
+        ExcelUtil<TlElectricDevice> util = new ExcelUtil<TlElectricDevice>(TlElectricDevice.class);
+        util.exportExcel(response, list, "电动车定位设备数据");
+    }
+
+    /**
+     * 获取电动车定位设备详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:device:query')")
+    @GetMapping(value = "/{imei}")
+    public AjaxResult getInfo(@PathVariable("imei") String imei) {
+        return AjaxResult.success(tlElectricDeviceService.selectTlElectricDeviceByImei(imei));
+    }
+
+    /**
+     * 新增电动车定位设备
+     *//*
+    @PreAuthorize("@ss.hasPermi('qdtl:device:add')")
+    @Log(title = "电动车定位设备", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TlElectricDevice tlElectricDevice) {
+        return toAjax(tlElectricDeviceService.insertTlElectricDevice(tlElectricDevice));
+    }
+
+    *//**
+     * 修改电动车定位设备
+     *//*
+    @PreAuthorize("@ss.hasPermi('qdtl:device:edit')")
+    @Log(title = "电动车定位设备", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TlElectricDevice tlElectricDevice) {
+        return toAjax(tlElectricDeviceService.updateTlElectricDevice(tlElectricDevice));
+    }
+
+    *//**
+     * 删除电动车定位设备
+     *//*
+    @PreAuthorize("@ss.hasPermi('qdtl:device:remove')")
+    @Log(title = "电动车定位设备", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{imeis}")
+    public AjaxResult remove(@PathVariable String[] imeis) {
+        return toAjax(tlElectricDeviceService.deleteTlElectricDeviceByImeis(imeis));
+    }*/
+}

+ 93 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlElectricDeviceLocationController.java

@@ -0,0 +1,93 @@
+package com.ruoyi.web.controller.qdtl;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
+import com.ruoyi.qdtl.service.ITlElectricDeviceLocationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 电动车定位设备轨迹Controller
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@RestController
+@RequestMapping("/qdtl/electricLocation")
+public class TlElectricDeviceLocationController extends BaseController {
+    @Autowired
+    private ITlElectricDeviceLocationService tlElectricDeviceLocationService;
+
+    /**
+     * 查询电动车定位设备轨迹列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:location:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TlElectricDeviceLocation tlElectricDeviceLocation) {
+        startPage();
+        List<TlElectricDeviceLocation> list = tlElectricDeviceLocationService.selectTlElectricDeviceLocationList(tlElectricDeviceLocation);
+        return getDataTable(list);
+    }
+
+    @PostMapping("/syncDeviceLocation")
+    public AjaxResult syncDeviceLocation() {
+        tlElectricDeviceLocationService.syncDeviceLocation();
+        return AjaxResult.success();
+    }
+
+    /**
+     * 导出电动车定位设备轨迹列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:location:export')")
+    @Log(title = "电动车定位设备轨迹", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TlElectricDeviceLocation tlElectricDeviceLocation) {
+        List<TlElectricDeviceLocation> list = tlElectricDeviceLocationService.selectTlElectricDeviceLocationList(tlElectricDeviceLocation);
+        ExcelUtil<TlElectricDeviceLocation> util = new ExcelUtil<TlElectricDeviceLocation>(TlElectricDeviceLocation.class);
+        util.exportExcel(response, list, "电动车定位设备轨迹数据");
+    }
+
+    /**
+     * 获取电动车定位设备轨迹详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:location:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return AjaxResult.success(tlElectricDeviceLocationService.selectTlElectricDeviceLocationById(id));
+    }
+
+    /**
+     * 新增电动车定位设备轨迹
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:location:add')")
+    @Log(title = "电动车定位设备轨迹", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TlElectricDeviceLocation tlElectricDeviceLocation) {
+        return toAjax(tlElectricDeviceLocationService.insertTlElectricDeviceLocation(tlElectricDeviceLocation));
+    }
+
+    /**
+     * 删除电动车定位设备轨迹
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:location:remove')")
+    @Log(title = "电动车定位设备轨迹", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(tlElectricDeviceLocationService.deleteTlElectricDeviceLocationByIds(ids));
+    }
+}

+ 1 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -130,6 +130,7 @@ third:
   xuncheckpoint: https://api.5ixun.com/api/v1/checkpoint # 巡检点
   xunpatrolman: https://api.5ixun.com/api/v1/patrolman # 巡检员
   xuntrail: https://api.5ixun.com/api/v1/trail # 设备轨迹
+  electricCarsOpenApi: http://open.aichezaixian.com/route/rest # 涂强开放api(电动车)
 
 hls:
   path: C:/qdtl/ckplayer/

+ 120 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlElectricDevice.java

@@ -0,0 +1,120 @@
+package com.ruoyi.qdtl.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 电动车定位设备对象 tl_electric_device
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class TlElectricDevice extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 设备IMEI
+     */
+    private String imei;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /**
+     * 设备型号
+     */
+    @Excel(name = "设备型号")
+    private String mcType;
+
+    /**
+     * 机型使用范围(aotomobile:汽车 electromobile:电动车 personal:个人 pet:宠物 plane:飞机 others:其他)
+     */
+    @Excel(name = "机型使用范围(aotomobile:汽车 electromobile:电动车 personal:个人 pet:宠物 plane:飞机 others:其他)")
+    private String mcTypeUseScope;
+
+    /**
+     * 设备类型(WIRED:有线 WIRELESS:无线)
+     */
+    @Excel(name = "设备类型", readConverterExp = "W=IRED:有线,W=IRELESS:无线")
+    private String equipType;
+
+    /**
+     * Sim卡号
+     */
+    @Excel(name = "Sim卡号")
+    private String sim;
+
+    /**
+     * 到期时间,格式yyyy-MM-dd HH:mm:ss
+     */
+    @Excel(name = "到期时间,格式yyyy-MM-dd HH:mm:ss")
+    private String expiration;
+
+    /**
+     * 激活时间,格式yyyy-MM-dd HH:mm:ss
+     */
+    @Excel(name = "激活时间,格式yyyy-MM-dd HH:mm:ss")
+    private String activationTime;
+
+    /**
+     * 车辆名称
+     */
+    @Excel(name = "车辆名称")
+    private String vehicleName;
+
+    /**
+     * 车辆图标
+     */
+    @Excel(name = "车辆图标")
+    private String vehicleIcon;
+
+    /**
+     * 车牌号
+     */
+    @Excel(name = "车牌号")
+    private String vehicleNumber;
+
+    /**
+     * 车辆品牌
+     */
+    @Excel(name = "车辆品牌")
+    private String vehicleModels;
+
+    /**
+     * 车架号
+     */
+    @Excel(name = "车架号")
+    private String carFrame;
+
+    /**
+     * 司机名称
+     */
+    @Excel(name = "司机名称")
+    private String driverName;
+
+    /**
+     * 司机电话
+     */
+    @Excel(name = "司机电话")
+    private String driverPhone;
+
+    /**
+     * 是否启用(0:不启用;1:启用)
+     */
+    @Excel(name = "是否启用", readConverterExp = "0=:不启用;1:启用")
+    private Integer enabledFlag;
+
+    /**
+     * 电机发动机号
+     */
+    @Excel(name = "电机发动机号")
+    private String engineNumber;
+
+}

+ 132 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlElectricDeviceLocation.java

@@ -0,0 +1,132 @@
+package com.ruoyi.qdtl.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 电动车定位设备轨迹对象 tl_electric_device_location
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class TlElectricDeviceLocation extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * 设备IMEI
+     */
+    @Excel(name = "设备IMEI")
+    private String imei;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /**
+     * 车辆图标
+     */
+    @Excel(name = "车辆图标")
+    private String icon;
+
+    /**
+     * 设备状态 0,离线; 1,在线
+     */
+    @Excel(name = "设备状态 0,离线; 1,在线")
+    private String status;
+
+    /**
+     * 经度 (如果设备过期,值为0)
+     */
+    @Excel(name = "经度 (如果设备过期,值为0)")
+    private String lng;
+
+    /**
+     * 纬度 (如果设备过期,值为0)
+     */
+    @Excel(name = "纬度 (如果设备过期,值为0)")
+    private String lat;
+
+    /**
+     * 是否过期1-未过期 0-过期
+     */
+    @Excel(name = "是否过期1-未过期 0-过期")
+    private String expireFlag;
+
+    /**
+     * 是否激活1-激活 0-未激活
+     */
+    @Excel(name = "是否激活1-激活 0-未激活")
+    private String activationFlag;
+
+    /**
+     * 卫星定位-GPS, 基站定位-LBS, WIFI定位-WIFI, 蓝牙定位-BEACON
+     */
+    @Excel(name = "卫星定位-GPS, 基站定位-LBS, WIFI定位-WIFI, 蓝牙定位-BEACON")
+    private String posType;
+
+    /**
+     * GPS定位时间
+     */
+    @Excel(name = "GPS定位时间")
+    private String gpsTime;
+
+    /**
+     * 心跳时间
+     */
+    @Excel(name = "心跳时间")
+    private String hbTime;
+
+    /**
+     * 速度 (单位:km/h)
+     */
+    @Excel(name = "速度 (单位:km/h)")
+    private String speed;
+
+    /**
+     * Acc状态 0:关闭 1:打开
+     */
+    @Excel(name = "Acc状态 0:关闭 1:打开")
+    private String accStatus;
+
+    /**
+     * 设备电量(0-100),部分设备型号不支持
+     */
+    @Excel(name = "设备电量", readConverterExp = "0=-100")
+    private String electQuantity;
+
+    /**
+     * 外电电压(0-100),部分设备支持
+     */
+    @Excel(name = "外电电压", readConverterExp = "0=-100")
+    private String powerValue;
+
+    /**
+     * 参与定位卫星数
+     */
+    @Excel(name = "参与定位卫星数")
+    private String gpsNum;
+
+    /**
+     * 移动的方向角度0~360
+     */
+    @Excel(name = "移动的方向角度0~360")
+    private String direction;
+
+    /**
+     * 里程统计
+     */
+    @Excel(name = "里程统计")
+    private String mileage;
+
+}

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

@@ -0,0 +1,55 @@
+package com.ruoyi.qdtl.mapper;
+
+import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
+
+import java.util.List;
+
+/**
+ * 电动车定位设备轨迹Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+public interface TlElectricDeviceLocationMapper {
+    /**
+     * 查询电动车定位设备轨迹
+     *
+     * @param id 电动车定位设备轨迹主键
+     * @return 电动车定位设备轨迹
+     */
+    public TlElectricDeviceLocation selectTlElectricDeviceLocationById(Long id);
+
+    /**
+     * 查询电动车定位设备轨迹列表
+     *
+     * @param tlElectricDeviceLocation 电动车定位设备轨迹
+     * @return 电动车定位设备轨迹集合
+     */
+    public List<TlElectricDeviceLocation> selectTlElectricDeviceLocationList(TlElectricDeviceLocation tlElectricDeviceLocation);
+
+    /**
+     * 新增电动车定位设备轨迹
+     *
+     * @param tlElectricDeviceLocation 电动车定位设备轨迹
+     * @return 结果
+     */
+    public int insertTlElectricDeviceLocation(TlElectricDeviceLocation tlElectricDeviceLocation);
+
+    /**
+     * 删除电动车定位设备轨迹
+     *
+     * @param id 电动车定位设备轨迹主键
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceLocationById(Long id);
+
+    /**
+     * 批量删除电动车定位设备轨迹
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceLocationByIds(Long[] ids);
+
+    void saveBatch(List<TlElectricDeviceLocation> electricCarsDeviceLocationList);
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlElectricDeviceMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.qdtl.mapper;
+
+import java.util.List;
+import com.ruoyi.qdtl.domain.TlElectricDevice;
+
+/**
+ * 电动车定位设备Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+public interface TlElectricDeviceMapper 
+{
+    /**
+     * 查询电动车定位设备
+     * 
+     * @param imei 电动车定位设备主键
+     * @return 电动车定位设备
+     */
+    public TlElectricDevice selectTlElectricDeviceByImei(String imei);
+
+    /**
+     * 查询电动车定位设备列表
+     * 
+     * @param tlElectricDevice 电动车定位设备
+     * @return 电动车定位设备集合
+     */
+    public List<TlElectricDevice> selectTlElectricDeviceList(TlElectricDevice tlElectricDevice);
+
+    /**
+     * 新增电动车定位设备
+     * 
+     * @param tlElectricDevice 电动车定位设备
+     * @return 结果
+     */
+    public int insertTlElectricDevice(TlElectricDevice tlElectricDevice);
+
+    /**
+     * 修改电动车定位设备
+     * 
+     * @param tlElectricDevice 电动车定位设备
+     * @return 结果
+     */
+    public int updateTlElectricDevice(TlElectricDevice tlElectricDevice);
+
+    /**
+     * 删除电动车定位设备
+     * 
+     * @param imei 电动车定位设备主键
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceByImei(String imei);
+
+    /**
+     * 批量删除电动车定位设备
+     * 
+     * @param imeis 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceByImeis(String[] imeis);
+}

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionLocationLogMapper.java

@@ -72,4 +72,5 @@ public interface TlInspectionLocationLogMapper {
 
     List<TlInspectionLocationLog> selectListByDate(@Param("date") String date);
 
+    List<TlInspectionLocationLog> queryDistanceByDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate);
 }

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/IQdCommonService.java

@@ -1,6 +1,10 @@
 package com.ruoyi.qdtl.service;
 
 import cn.hutool.json.JSONArray;
+import com.ruoyi.qdtl.domain.TlElectricDevice;
+import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
+
+import java.util.List;
 
 /**
  * @Description: TODO
@@ -23,4 +27,10 @@ public interface IQdCommonService {
     JSONArray getTrail(long startTime, long endTime, String deviceId);
 
     int getVersion(String key);
+
+    String getElectricCarsToken();
+
+    List<TlElectricDevice> getElectricCarsDeviceList();
+
+    List<TlElectricDeviceLocation> getElectricCarsDeviceLocationList();
 }

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

@@ -0,0 +1,60 @@
+package com.ruoyi.qdtl.service;
+
+import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
+
+import java.util.List;
+
+/**
+ * 电动车定位设备轨迹Service接口
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+public interface ITlElectricDeviceLocationService {
+    /**
+     * 查询电动车定位设备轨迹
+     *
+     * @param id 电动车定位设备轨迹主键
+     * @return 电动车定位设备轨迹
+     */
+    public TlElectricDeviceLocation selectTlElectricDeviceLocationById(Long id);
+
+    /**
+     * 查询电动车定位设备轨迹列表
+     *
+     * @param tlElectricDeviceLocation 电动车定位设备轨迹
+     * @return 电动车定位设备轨迹集合
+     */
+    public List<TlElectricDeviceLocation> selectTlElectricDeviceLocationList(TlElectricDeviceLocation tlElectricDeviceLocation);
+
+    /**
+     * 新增电动车定位设备轨迹
+     *
+     * @param tlElectricDeviceLocation 电动车定位设备轨迹
+     * @return 结果
+     */
+    public int insertTlElectricDeviceLocation(TlElectricDeviceLocation tlElectricDeviceLocation);
+
+    /**
+     * 批量删除电动车定位设备轨迹
+     *
+     * @param ids 需要删除的电动车定位设备轨迹主键集合
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceLocationByIds(Long[] ids);
+
+    /**
+     * 删除电动车定位设备轨迹信息
+     *
+     * @param id 电动车定位设备轨迹主键
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceLocationById(Long id);
+
+    /**
+     * 同步设备最新位置数据
+     *
+     * @return
+     */
+    void syncDeviceLocation();
+}

+ 68 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlElectricDeviceService.java

@@ -0,0 +1,68 @@
+package com.ruoyi.qdtl.service;
+
+import com.ruoyi.qdtl.domain.TlElectricDevice;
+
+import java.util.List;
+
+/**
+ * 电动车定位设备Service接口
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+public interface ITlElectricDeviceService {
+    /**
+     * 查询电动车定位设备
+     *
+     * @param imei 电动车定位设备主键
+     * @return 电动车定位设备
+     */
+    public TlElectricDevice selectTlElectricDeviceByImei(String imei);
+
+    /**
+     * 查询电动车定位设备列表
+     *
+     * @param tlElectricDevice 电动车定位设备
+     * @return 电动车定位设备集合
+     */
+    public List<TlElectricDevice> selectTlElectricDeviceList(TlElectricDevice tlElectricDevice);
+
+    /**
+     * 新增电动车定位设备
+     *
+     * @param tlElectricDevice 电动车定位设备
+     * @return 结果
+     */
+    public int insertTlElectricDevice(TlElectricDevice tlElectricDevice);
+
+    /**
+     * 修改电动车定位设备
+     *
+     * @param tlElectricDevice 电动车定位设备
+     * @return 结果
+     */
+    public int updateTlElectricDevice(TlElectricDevice tlElectricDevice);
+
+    /**
+     * 批量删除电动车定位设备
+     *
+     * @param imeis 需要删除的电动车定位设备主键集合
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceByImeis(String[] imeis);
+
+    /**
+     * 删除电动车定位设备信息
+     *
+     * @param imei 电动车定位设备主键
+     * @return 结果
+     */
+    public int deleteTlElectricDeviceByImei(String imei);
+
+    /**
+     * 同步第三方设备数据到本地
+     *
+     * @return
+     */
+    String syncDevice();
+}

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionLocationLogService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.qdtl.service;
 
+import cn.hutool.json.JSONObject;
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
 import com.ruoyi.qdtl.domain.UserCheckPoint;
 
@@ -80,4 +81,5 @@ public interface ITlInspectionLocationLogService {
      */
     double queryDistance(String date, String deviceId);
 
+    List<JSONObject> queryDistanceByDateRange(String startDate, String endDate);
 }

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

@@ -11,6 +11,8 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.qdtl.domain.TlElectricDevice;
+import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
 import com.ruoyi.qdtl.service.IQdCommonService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
@@ -47,6 +50,8 @@ public class QdCommonServiceImpl implements IQdCommonService {
     private String xunpatrolmanUrl;
     @Value("${third.xuntrail}")
     private String xuntrailUrl;
+    @Value("${third.electricCarsOpenApi}")
+    private String electricCarsOpenApiUrl;
 
     @Autowired
     private RedisCache redisCache;
@@ -201,4 +206,97 @@ public class QdCommonServiceImpl implements IQdCommonService {
         }
         return Convert.toInt(redisCache.incr(key, 1));
     }
+
+    /**
+     * 获取电动车定位平台token
+     *
+     * @return
+     */
+    @Override
+    public String getElectricCarsToken() {
+        String token = redisCache.getCacheObject("electric:token");
+        if (StrUtil.isBlank(token)) {
+            Map<String, Object> paramMap = new HashMap<>();
+            // 公共参数
+            paramMap.put("app_key", "8FB345B8693CCD006879C3CE09549C82");
+            paramMap.put("v", "0.9");
+            paramMap.put("timestamp", DateUtil.now());
+            paramMap.put("sign_method", "md5");
+            paramMap.put("format", "json");
+            paramMap.put("method", "jimi.oauth.token.get");
+            // 私有参数
+            paramMap.put("user_id", "启东市铁路巡逻电瓶车");
+            paramMap.put("user_pwd_md5", "62ea9d1a6f6cfe766c69656c4869a819");
+            paramMap.put("expires_in", "7200");
+            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);
+            } else {
+                log.error("获取电动车定位平台接口的token失败:{}", postJson);
+                throw new ServiceException("获取电动车定位平台接口的token失败");
+            }
+        }
+        return token;
+    }
+
+    /**
+     * 获取设备列表
+     *
+     * @return
+     */
+    @Override
+    public List<TlElectricDevice> getElectricCarsDeviceList() {
+        Map<String, Object> paramMap = new HashMap<>();
+        // 公共参数
+        paramMap.put("app_key", "8FB345B8693CCD006879C3CE09549C82");
+        paramMap.put("v", "0.9");
+        paramMap.put("timestamp", DateUtil.now());
+        paramMap.put("sign_method", "md5");
+        paramMap.put("format", "json");
+        paramMap.put("method", "jimi.user.device.list");
+        // 私有参数
+        paramMap.put("target", "启东市铁路巡逻电瓶车");
+        paramMap.put("access_token", this.getElectricCarsToken());
+        String post = HttpUtil.post(electricCarsOpenApiUrl, paramMap);
+        JSONObject postJson = JSONUtil.parseObj(post);
+        if (0 == postJson.getInt("code")) {
+            return JSONUtil.toList(postJson.getJSONArray("result"), TlElectricDevice.class);
+        } else {
+            log.error("获取电动车定位平台接口的设备列表失败:{}", postJson);
+            throw new ServiceException("获取电动车定位平台接口的设备列表失败");
+        }
+    }
+
+    /**
+     * 获取设备定位最新数据
+     *
+     * @return
+     */
+    @Override
+    public List<TlElectricDeviceLocation> getElectricCarsDeviceLocationList() {
+        Map<String, Object> paramMap = new HashMap<>();
+        // 公共参数
+        paramMap.put("app_key", "8FB345B8693CCD006879C3CE09549C82");
+        paramMap.put("v", "0.9");
+        paramMap.put("timestamp", DateUtil.now());
+        paramMap.put("sign_method", "md5");
+        paramMap.put("format", "json");
+        paramMap.put("method", "jimi.user.device.location.list");
+        // 私有参数
+        paramMap.put("target", "启东市铁路巡逻电瓶车");
+        paramMap.put("access_token", this.getElectricCarsToken());
+        String post = HttpUtil.post(electricCarsOpenApiUrl, paramMap);
+        JSONObject postJson = JSONUtil.parseObj(post);
+        if (0 == postJson.getInt("code")) {
+            return JSONUtil.toList(postJson.getJSONArray("result"), TlElectricDeviceLocation.class);
+        } else {
+            log.error("获取电动车定位平台接口的设备最新位置失败:{}", postJson);
+            throw new ServiceException("获取电动车定位平台接口的设备最新位置失败");
+        }
+    }
+
+
 }

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

@@ -0,0 +1,90 @@
+package com.ruoyi.qdtl.service.impl;
+
+import com.ruoyi.qdtl.domain.TlElectricDeviceLocation;
+import com.ruoyi.qdtl.mapper.TlElectricDeviceLocationMapper;
+import com.ruoyi.qdtl.service.IQdCommonService;
+import com.ruoyi.qdtl.service.ITlElectricDeviceLocationService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 电动车定位设备轨迹Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@Service
+@Slf4j
+public class TlElectricDeviceLocationServiceImpl implements ITlElectricDeviceLocationService {
+    @Autowired
+    private TlElectricDeviceLocationMapper tlElectricDeviceLocationMapper;
+    @Autowired
+    private IQdCommonService qdCommonService;
+
+    /**
+     * 查询电动车定位设备轨迹
+     *
+     * @param id 电动车定位设备轨迹主键
+     * @return 电动车定位设备轨迹
+     */
+    @Override
+    public TlElectricDeviceLocation selectTlElectricDeviceLocationById(Long id) {
+        return tlElectricDeviceLocationMapper.selectTlElectricDeviceLocationById(id);
+    }
+
+    /**
+     * 查询电动车定位设备轨迹列表
+     *
+     * @param tlElectricDeviceLocation 电动车定位设备轨迹
+     * @return 电动车定位设备轨迹
+     */
+    @Override
+    public List<TlElectricDeviceLocation> selectTlElectricDeviceLocationList(TlElectricDeviceLocation tlElectricDeviceLocation) {
+        return tlElectricDeviceLocationMapper.selectTlElectricDeviceLocationList(tlElectricDeviceLocation);
+    }
+
+    /**
+     * 新增电动车定位设备轨迹
+     *
+     * @param tlElectricDeviceLocation 电动车定位设备轨迹
+     * @return 结果
+     */
+    @Override
+    public int insertTlElectricDeviceLocation(TlElectricDeviceLocation tlElectricDeviceLocation) {
+        return tlElectricDeviceLocationMapper.insertTlElectricDeviceLocation(tlElectricDeviceLocation);
+    }
+
+    /**
+     * 批量删除电动车定位设备轨迹
+     *
+     * @param ids 需要删除的电动车定位设备轨迹主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlElectricDeviceLocationByIds(Long[] ids) {
+        return tlElectricDeviceLocationMapper.deleteTlElectricDeviceLocationByIds(ids);
+    }
+
+    /**
+     * 删除电动车定位设备轨迹信息
+     *
+     * @param id 电动车定位设备轨迹主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlElectricDeviceLocationById(Long id) {
+        return tlElectricDeviceLocationMapper.deleteTlElectricDeviceLocationById(id);
+    }
+
+    @Override
+    public void syncDeviceLocation() {
+        List<TlElectricDeviceLocation> electricCarsDeviceLocationList = qdCommonService.getElectricCarsDeviceLocationList();
+        if (electricCarsDeviceLocationList != null && electricCarsDeviceLocationList.size() > 0) {
+            tlElectricDeviceLocationMapper.saveBatch(electricCarsDeviceLocationList);
+        }
+        log.info("同步最新的定位数据量:{}条", electricCarsDeviceLocationList.size());
+    }
+}

+ 131 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlElectricDeviceServiceImpl.java

@@ -0,0 +1,131 @@
+package com.ruoyi.qdtl.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.StrUtil;
+import com.ruoyi.qdtl.domain.TlElectricDevice;
+import com.ruoyi.qdtl.mapper.TlElectricDeviceMapper;
+import com.ruoyi.qdtl.service.IQdCommonService;
+import com.ruoyi.qdtl.service.ITlElectricDeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 电动车定位设备Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-06-03
+ */
+@Service
+public class TlElectricDeviceServiceImpl implements ITlElectricDeviceService {
+    @Autowired
+    private TlElectricDeviceMapper tlElectricDeviceMapper;
+    @Autowired
+    private IQdCommonService qdCommonService;
+
+    /**
+     * 查询电动车定位设备
+     *
+     * @param imei 电动车定位设备主键
+     * @return 电动车定位设备
+     */
+    @Override
+    public TlElectricDevice selectTlElectricDeviceByImei(String imei) {
+        return tlElectricDeviceMapper.selectTlElectricDeviceByImei(imei);
+    }
+
+    /**
+     * 查询电动车定位设备列表
+     *
+     * @param tlElectricDevice 电动车定位设备
+     * @return 电动车定位设备
+     */
+    @Override
+    public List<TlElectricDevice> selectTlElectricDeviceList(TlElectricDevice tlElectricDevice) {
+        return tlElectricDeviceMapper.selectTlElectricDeviceList(tlElectricDevice);
+    }
+
+    /**
+     * 新增电动车定位设备
+     *
+     * @param tlElectricDevice 电动车定位设备
+     * @return 结果
+     */
+    @Override
+    public int insertTlElectricDevice(TlElectricDevice tlElectricDevice) {
+        return tlElectricDeviceMapper.insertTlElectricDevice(tlElectricDevice);
+    }
+
+    /**
+     * 修改电动车定位设备
+     *
+     * @param tlElectricDevice 电动车定位设备
+     * @return 结果
+     */
+    @Override
+    public int updateTlElectricDevice(TlElectricDevice tlElectricDevice) {
+        return tlElectricDeviceMapper.updateTlElectricDevice(tlElectricDevice);
+    }
+
+    /**
+     * 批量删除电动车定位设备
+     *
+     * @param imeis 需要删除的电动车定位设备主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlElectricDeviceByImeis(String[] imeis) {
+        return tlElectricDeviceMapper.deleteTlElectricDeviceByImeis(imeis);
+    }
+
+    /**
+     * 删除电动车定位设备信息
+     *
+     * @param imei 电动车定位设备主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlElectricDeviceByImei(String imei) {
+        return tlElectricDeviceMapper.deleteTlElectricDeviceByImei(imei);
+    }
+
+    @Override
+    @Transactional
+    public String syncDevice() {
+        int delSum = 0, addSum = 0, updateSum = 0;
+        List<TlElectricDevice> remoteList = qdCommonService.getElectricCarsDeviceList();
+        List<String> remoteImei = remoteList.stream().map(TlElectricDevice::getImei).collect(Collectors.toList());
+        // 查询本地的数据,若存在差集则删除
+        List<TlElectricDevice> localList = this.selectTlElectricDeviceList(new TlElectricDevice());
+        List<String> localImei = localList.stream().map(TlElectricDevice::getImei).collect(Collectors.toList());
+        // 待删除的数据
+        List<String> removeImei = CollUtil.subtractToList(localImei, remoteImei);
+        // 待新增的数据
+        List<String> saveImei = CollUtil.subtractToList(remoteImei, localImei);
+        // 待更新的数据
+        Collection<String> intersection = CollUtil.intersection(localImei, remoteImei);
+
+        // 删除
+        if (removeImei.size() > 0) {
+            deleteTlElectricDeviceByImeis(Convert.toStrArray(removeImei));
+            delSum = removeImei.size();
+        }
+        for (TlElectricDevice tlElectricDevice : remoteList) {
+            if (saveImei.contains(tlElectricDevice.getImei())) {
+                insertTlElectricDevice(tlElectricDevice);
+                addSum++;
+            } else if (intersection.contains(tlElectricDevice.getImei())) {
+                updateTlElectricDevice(tlElectricDevice);
+                updateSum++;
+            }
+        }
+        return StrUtil.concat(true, "此次同步共删除数量", Convert.toStr(delSum),
+                "条;共新增数量", Convert.toStr(addSum),
+                "条;共更新数量", Convert.toStr(updateSum), "条。");
+    }
+}

+ 37 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionLocationLogServiceImpl.java

@@ -2,8 +2,10 @@ package com.ruoyi.qdtl.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONObject;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
 import com.ruoyi.qdtl.domain.UserCheckPoint;
@@ -15,6 +17,7 @@ import org.gavaghan.geodesy.GlobalCoordinates;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -164,4 +167,38 @@ public class TlInspectionLocationLogServiceImpl implements ITlInspectionLocation
         }
         return NumberUtil.div(distance, 1000, 3);
     }
+
+    @Override
+    public List<JSONObject> queryDistanceByDateRange(String startDate, String endDate) {
+        List<TlInspectionLocationLog> locationLogList = tlInspectionLocationLogMapper.queryDistanceByDateRange(startDate, endDate);
+        // 解析根据日期分组
+        Map<String, List<TlInspectionLocationLog>> collect = locationLogList.stream().collect(Collectors.groupingBy(a -> DateUtil.formatDate(a.getCreateTime())));
+        List<JSONObject> result = new ArrayList<>();
+        for (Map.Entry<String, List<TlInspectionLocationLog>> stringListEntry : collect.entrySet()) {
+            double distance = 0;
+            List<TlInspectionLocationLog> origin = stringListEntry.getValue();
+            if (origin.size() < 2) {
+                continue;
+            }
+            // 对原始list分成2组list,一个去掉头节点,一个去掉尾节点
+            List<TlInspectionLocationLog> subPre = CollUtil.sub(origin, 0, origin.size() - 1);
+            List<TlInspectionLocationLog> subAfter = CollUtil.sub(origin, 1, origin.size());
+            for (int i = 0; i < subPre.size(); i++) {
+                String fencePre = subPre.get(i).getFence();
+                String fenceAfter = subAfter.get(i).getFence();
+                // 计算2点之间距离
+                GlobalCoordinates source = new GlobalCoordinates(Convert.toDouble(fencePre.split(",")[1]), Convert.toDouble(fencePre.split(",")[0]));
+                GlobalCoordinates target = new GlobalCoordinates(Convert.toDouble(fenceAfter.split(",")[1]), Convert.toDouble(fenceAfter.split(",")[0]));
+                // 创建GeodeticCalculator,调用计算方法
+                double ellipsoidalDistance = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, source, target).getEllipsoidalDistance();
+                distance = NumberUtil.add(distance, ellipsoidalDistance);
+            }
+            JSONObject jb = new JSONObject();
+            jb.set("date", stringListEntry.getKey());
+            jb.set("week", DateUtil.dayOfWeekEnum(DateUtil.parseDate(stringListEntry.getKey())).toChinese("周"));
+            jb.set("distance", NumberUtil.div(distance, 1000, 3));
+            result.add(jb);
+        }
+        return CollUtil.sortByProperty(result, "date");
+    }
 }

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

@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.qdtl.mapper.TlElectricDeviceLocationMapper">
+
+    <resultMap type="TlElectricDeviceLocation" id="TlElectricDeviceLocationResult">
+        <result property="id" column="id"/>
+        <result property="imei" column="imei"/>
+        <result property="deviceName" column="device_name"/>
+        <result property="icon" column="icon"/>
+        <result property="status" column="status"/>
+        <result property="lng" column="lng"/>
+        <result property="lat" column="lat"/>
+        <result property="expireFlag" column="expire_flag"/>
+        <result property="activationFlag" column="activation_flag"/>
+        <result property="posType" column="pos_type"/>
+        <result property="gpsTime" column="gps_time"/>
+        <result property="hbTime" column="hb_time"/>
+        <result property="speed" column="speed"/>
+        <result property="accStatus" column="acc_status"/>
+        <result property="electQuantity" column="elect_quantity"/>
+        <result property="powerValue" column="power_value"/>
+        <result property="gpsNum" column="gps_num"/>
+        <result property="direction" column="direction"/>
+        <result property="mileage" column="mileage"/>
+    </resultMap>
+
+    <sql id="selectTlElectricDeviceLocationVo">
+        select id,
+               imei,
+               device_name,
+               icon,
+               status,
+               lng,
+               lat,
+               expire_flag,
+               activation_flag,
+               pos_type,
+               gps_time,
+               hb_time,
+               speed,
+               acc_status,
+               elect_quantity,
+               power_value,
+               gps_num,
+               direction,
+               mileage
+        from tl_electric_device_location
+    </sql>
+
+    <select id="selectTlElectricDeviceLocationList" parameterType="TlElectricDeviceLocation" resultMap="TlElectricDeviceLocationResult">
+        <include refid="selectTlElectricDeviceLocationVo"/>
+        <where>
+            <if test="imei != null  and imei != ''">and imei = #{imei}</if>
+            <if test="deviceName != null  and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
+            <if test="icon != null  and icon != ''">and icon = #{icon}</if>
+            <if test="status != null  and status != ''">and status = #{status}</if>
+            <if test="lng != null  and lng != ''">and lng = #{lng}</if>
+            <if test="lat != null  and lat != ''">and lat = #{lat}</if>
+            <if test="expireFlag != null  and expireFlag != ''">and expire_flag = #{expireFlag}</if>
+            <if test="activationFlag != null  and activationFlag != ''">and activation_flag = #{activationFlag}</if>
+            <if test="posType != null  and posType != ''">and pos_type = #{posType}</if>
+            <if test="gpsTime != null  and gpsTime != ''">and gps_time = #{gpsTime}</if>
+            <if test="hbTime != null  and hbTime != ''">and hb_time = #{hbTime}</if>
+            <if test="speed != null  and speed != ''">and speed = #{speed}</if>
+            <if test="accStatus != null  and accStatus != ''">and acc_status = #{accStatus}</if>
+            <if test="electQuantity != null  and electQuantity != ''">and elect_quantity = #{electQuantity}</if>
+            <if test="powerValue != null  and powerValue != ''">and power_value = #{powerValue}</if>
+            <if test="gpsNum != null  and gpsNum != ''">and gps_num = #{gpsNum}</if>
+            <if test="direction != null  and direction != ''">and direction = #{direction}</if>
+            <if test="mileage != null  and mileage != ''">and mileage = #{mileage}</if>
+        </where>
+    </select>
+
+    <select id="selectTlElectricDeviceLocationById" parameterType="Long" resultMap="TlElectricDeviceLocationResult">
+        <include refid="selectTlElectricDeviceLocationVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertTlElectricDeviceLocation" parameterType="TlElectricDeviceLocation" useGeneratedKeys="true" keyProperty="id">
+        insert into tl_electric_device_location
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="imei != null">imei,</if>
+            <if test="deviceName != null">device_name,</if>
+            <if test="icon != null">icon,</if>
+            <if test="status != null">status,</if>
+            <if test="lng != null">lng,</if>
+            <if test="lat != null">lat,</if>
+            <if test="expireFlag != null">expire_flag,</if>
+            <if test="activationFlag != null">activation_flag,</if>
+            <if test="posType != null">pos_type,</if>
+            <if test="gpsTime != null">gps_time,</if>
+            <if test="hbTime != null">hb_time,</if>
+            <if test="speed != null">speed,</if>
+            <if test="accStatus != null">acc_status,</if>
+            <if test="electQuantity != null">elect_quantity,</if>
+            <if test="powerValue != null">power_value,</if>
+            <if test="gpsNum != null">gps_num,</if>
+            <if test="direction != null">direction,</if>
+            <if test="mileage != null">mileage,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="imei != null">#{imei},</if>
+            <if test="deviceName != null">#{deviceName},</if>
+            <if test="icon != null">#{icon},</if>
+            <if test="status != null">#{status},</if>
+            <if test="lng != null">#{lng},</if>
+            <if test="lat != null">#{lat},</if>
+            <if test="expireFlag != null">#{expireFlag},</if>
+            <if test="activationFlag != null">#{activationFlag},</if>
+            <if test="posType != null">#{posType},</if>
+            <if test="gpsTime != null">#{gpsTime},</if>
+            <if test="hbTime != null">#{hbTime},</if>
+            <if test="speed != null">#{speed},</if>
+            <if test="accStatus != null">#{accStatus},</if>
+            <if test="electQuantity != null">#{electQuantity},</if>
+            <if test="powerValue != null">#{powerValue},</if>
+            <if test="gpsNum != null">#{gpsNum},</if>
+            <if test="direction != null">#{direction},</if>
+            <if test="mileage != null">#{mileage},</if>
+        </trim>
+    </insert>
+
+    <insert id="saveBatch">
+        insert into tl_electric_device_location(
+        imei,
+        device_name,
+        icon,
+        status,
+        lng,
+        lat,
+        expire_flag,
+        activation_flag,
+        pos_type,
+        gps_time,
+        hb_time,
+        speed,
+        acc_status,
+        elect_quantity,
+        power_value,
+        gps_num,
+        direction,
+        mileage) values
+        <foreach item="item" index="index" collection="list" separator=",">
+            (#{item.imei},#{item.deviceName},#{item.icon},#{item.status},#{item.lng},
+            #{item.lat},#{item.expireFlag},#{item.activationFlag},#{item.posType},#{item.gpsTime},#{item.hbTime},#{item.speed},
+            #{item.accStatus},#{item.electQuantity},#{item.powerValue},#{item.gpsNum},#{item.direction},#{item.mileage})
+        </foreach>
+    </insert>
+
+    <delete id="deleteTlElectricDeviceLocationById" parameterType="Long">
+        delete
+        from tl_electric_device_location
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteTlElectricDeviceLocationByIds" parameterType="String">
+        delete from tl_electric_device_location where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 158 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlElectricDeviceMapper.xml

@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.qdtl.mapper.TlElectricDeviceMapper">
+
+    <resultMap type="TlElectricDevice" id="TlElectricDeviceResult">
+        <result property="imei" column="imei"/>
+        <result property="deviceName" column="device_name"/>
+        <result property="mcType" column="mc_type"/>
+        <result property="mcTypeUseScope" column="mc_type_use_scope"/>
+        <result property="equipType" column="equip_type"/>
+        <result property="sim" column="sim"/>
+        <result property="expiration" column="expiration"/>
+        <result property="activationTime" column="activation_time"/>
+        <result property="remark" column="re_mark"/>
+        <result property="vehicleName" column="vehicle_name"/>
+        <result property="vehicleIcon" column="vehicle_icon"/>
+        <result property="vehicleNumber" column="vehicle_number"/>
+        <result property="vehicleModels" column="vehicle_models"/>
+        <result property="carFrame" column="car_frame"/>
+        <result property="driverName" column="driver_name"/>
+        <result property="driverPhone" column="driver_phone"/>
+        <result property="enabledFlag" column="enabled_flag"/>
+        <result property="engineNumber" column="engine_number"/>
+    </resultMap>
+
+    <sql id="selectTlElectricDeviceVo">
+        select imei,
+               device_name,
+               mc_type,
+               mc_type_use_scope,
+               equip_type,
+               sim,
+               expiration,
+               activation_time,
+               re_mark,
+               vehicle_name,
+               vehicle_icon,
+               vehicle_number,
+               vehicle_models,
+               car_frame,
+               driver_name,
+               driver_phone,
+               enabled_flag,
+               engine_number
+        from tl_electric_device
+    </sql>
+
+    <select id="selectTlElectricDeviceList" parameterType="TlElectricDevice" resultMap="TlElectricDeviceResult">
+        <include refid="selectTlElectricDeviceVo"/>
+        <where>
+            <if test="deviceName != null  and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
+            <if test="mcType != null  and mcType != ''">and mc_type = #{mcType}</if>
+            <if test="mcTypeUseScope != null  and mcTypeUseScope != ''">and mc_type_use_scope = #{mcTypeUseScope}</if>
+            <if test="equipType != null  and equipType != ''">and equip_type = #{equipType}</if>
+            <if test="sim != null  and sim != ''">and sim = #{sim}</if>
+            <if test="expiration != null  and expiration != ''">and expiration = #{expiration}</if>
+            <if test="activationTime != null  and activationTime != ''">and activation_time = #{activationTime}</if>
+            <if test="remark != null  and remark != ''">and re_mark = #{remark}</if>
+            <if test="vehicleName != null  and vehicleName != ''">and vehicle_name like concat('%', #{vehicleName}, '%')</if>
+            <if test="vehicleIcon != null  and vehicleIcon != ''">and vehicle_icon = #{vehicleIcon}</if>
+            <if test="vehicleNumber != null  and vehicleNumber != ''">and vehicle_number = #{vehicleNumber}</if>
+            <if test="vehicleModels != null  and vehicleModels != ''">and vehicle_models = #{vehicleModels}</if>
+            <if test="carFrame != null  and carFrame != ''">and car_frame = #{carFrame}</if>
+            <if test="driverName != null  and driverName != ''">and driver_name like concat('%', #{driverName}, '%')</if>
+            <if test="driverPhone != null  and driverPhone != ''">and driver_phone = #{driverPhone}</if>
+            <if test="enabledFlag != null ">and enabled_flag = #{enabledFlag}</if>
+            <if test="engineNumber != null  and engineNumber != ''">and engine_number = #{engineNumber}</if>
+        </where>
+    </select>
+
+    <select id="selectTlElectricDeviceByImei" parameterType="String" resultMap="TlElectricDeviceResult">
+        <include refid="selectTlElectricDeviceVo"/>
+        where imei = #{imei}
+    </select>
+
+    <insert id="insertTlElectricDevice" parameterType="TlElectricDevice">
+        insert into tl_electric_device
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="imei != null">imei,</if>
+            <if test="deviceName != null">device_name ,</if>
+            <if test="mcType != null">mc_type ,</if>
+            <if test="mcTypeUseScope != null">mc_type_use_scope,</if>
+            <if test="equipType != null">equip_type ,</if>
+            <if test="sim != null">sim ,</if>
+            <if test="expiration != null">expiration ,</if>
+            <if test="activationTime != null">activation_time,</if>
+            <if test="remark != null">re_mark ,</if>
+            <if test="vehicleName != null">vehicle_name ,</if>
+            <if test="vehicleIcon != null">vehicle_icon ,</if>
+            <if test="vehicleNumber != null">vehicle_number ,</if>
+            <if test="vehicleModels != null">vehicle_models ,</if>
+            <if test="carFrame != null">car_frame ,</if>
+            <if test="driverName != null">driver_name ,</if>
+            <if test="driverPhone != null">driver_phone ,</if>
+            <if test="enabledFlag != null">enabled_flag ,</if>
+            <if test="engineNumber != null">engine_number ,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="imei != null">#{imei},</if>
+            <if test="deviceName != null">#{deviceName},</if>
+            <if test="mcType != null">#{mcType},</if>
+            <if test="mcTypeUseScope != null">#{mcTypeUseScope},</if>
+            <if test="equipType != null">#{equipType},</if>
+            <if test="sim != null">#{sim},</if>
+            <if test="expiration != null">#{expiration},</if>
+            <if test="activationTime != null">#{activationTime},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="vehicleName != null">#{vehicleName},</if>
+            <if test="vehicleIcon != null">#{vehicleIcon},</if>
+            <if test="vehicleNumber != null">#{vehicleNumber},</if>
+            <if test="vehicleModels != null">#{vehicleModels},</if>
+            <if test="carFrame != null">#{carFrame},</if>
+            <if test="driverName != null">#{driverName},</if>
+            <if test="driverPhone != null">#{driverPhone},</if>
+            <if test="enabledFlag != null">#{enabledFlag},</if>
+            <if test="engineNumber != null">#{engineNumber},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTlElectricDevice" parameterType="TlElectricDevice">
+        update tl_electric_device
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="deviceName != null">device_name = #{deviceName},</if>
+            <if test="mcType != null">mc_type = #{mcType},</if>
+            <if test="mcTypeUseScope != null">mc_type_use_scope = #{mcTypeUseScope},</if>
+            <if test="equipType != null">equip_type = #{equipType},</if>
+            <if test="sim != null">sim = #{sim},</if>
+            <if test="expiration != null">expiration = #{expiration},</if>
+            <if test="activationTime != null">activation_time = #{activationTime},</if>
+            <if test="remark != null">re_mark = #{remark},</if>
+            <if test="vehicleName != null">vehicle_name = #{vehicleName},</if>
+            <if test="vehicleIcon != null">vehicle_icon = #{vehicleIcon},</if>
+            <if test="vehicleNumber != null">vehicle_number = #{vehicleNumber},</if>
+            <if test="vehicleModels != null">vehicle_models = #{vehicleModels},</if>
+            <if test="carFrame != null">car_frame = #{carFrame},</if>
+            <if test="driverName != null">driver_name = #{driverName},</if>
+            <if test="driverPhone != null">driver_phone = #{driverPhone},</if>
+            <if test="enabledFlag != null">enabled_flag = #{enabledFlag},</if>
+            <if test="engineNumber != null">engine_number = #{engineNumber},</if>
+        </trim>
+        where imei = #{imei}
+    </update>
+
+    <delete id="deleteTlElectricDeviceByImei" parameterType="String">
+        delete
+        from tl_electric_device
+        where imei = #{imei}
+    </delete>
+
+    <delete id="deleteTlElectricDeviceByImeis" parameterType="String">
+        delete from tl_electric_device where imei in
+        <foreach item="imei" collection="array" open="(" separator="," close=")">
+            #{imei}
+        </foreach>
+    </delete>
+</mapper>

+ 8 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationLogMapper.xml

@@ -111,6 +111,14 @@
         order by create_time asc
     </select>
 
+    <select id="queryDistanceByDateRange" resultMap="TlInspectionLocationLogResult">
+        <include refid="selectTlInspectionLocationLogVo"/>
+        where date_format(create_time,'%Y-%m-%d') &gt;= #{startDate}
+        and date_format(create_time,'%Y-%m-%d') &lt;= #{endDate}
+        and fence != ''
+        order by create_time asc
+    </select>
+
     <select id="selectTlInspectionLocationLogTrailList" parameterType="TlInspectionLocationLog" resultMap="TlInspectionLocationLogResult">
         <include refid="selectTlInspectionLocationLogVo"/>
         <where>