浏览代码

同步记录数据

459242451@qq.com 3 年之前
父节点
当前提交
332450b9c5

+ 98 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionLocationLogController.java

@@ -0,0 +1,98 @@
+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.TlInspectionLocationLog;
+import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
+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.PutMapping;
+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-03-10
+ */
+@RestController
+@RequestMapping("/qdtl/log")
+public class TlInspectionLocationLogController extends BaseController {
+    @Autowired
+    private ITlInspectionLocationLogService tlInspectionLocationLogService;
+
+    /**
+     * 查询巡检记录管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:log:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TlInspectionLocationLog tlInspectionLocationLog) {
+        startPage();
+        List<TlInspectionLocationLog> list = tlInspectionLocationLogService.selectTlInspectionLocationLogList(tlInspectionLocationLog);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出巡检记录管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:log:export')")
+    @Log(title = "巡检记录管理", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TlInspectionLocationLog tlInspectionLocationLog) {
+        List<TlInspectionLocationLog> list = tlInspectionLocationLogService.selectTlInspectionLocationLogList(tlInspectionLocationLog);
+        ExcelUtil<TlInspectionLocationLog> util = new ExcelUtil<TlInspectionLocationLog>(TlInspectionLocationLog.class);
+        util.exportExcel(response, list, "巡检记录管理数据");
+    }
+
+    /**
+     * 获取巡检记录管理详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:log:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return AjaxResult.success(tlInspectionLocationLogService.selectTlInspectionLocationLogById(id));
+    }
+
+    /**
+     * 新增巡检记录管理
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:log:add')")
+    @Log(title = "巡检记录管理", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TlInspectionLocationLog tlInspectionLocationLog) {
+        return toAjax(tlInspectionLocationLogService.insertTlInspectionLocationLog(tlInspectionLocationLog));
+    }
+
+    /**
+     * 修改巡检记录管理
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:log:edit')")
+    @Log(title = "巡检记录管理", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TlInspectionLocationLog tlInspectionLocationLog) {
+        return toAjax(tlInspectionLocationLogService.updateTlInspectionLocationLog(tlInspectionLocationLog));
+    }
+
+    /**
+     * 删除巡检记录管理
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:log:remove')")
+    @Log(title = "巡检记录管理", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(tlInspectionLocationLogService.deleteTlInspectionLocationLogByIds(ids));
+    }
+}

+ 31 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/XunTask.java

@@ -1,17 +1,22 @@
 package com.ruoyi.web.controller.task;
 
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.qdtl.domain.TlInspectionDevice;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
+import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
 import com.ruoyi.qdtl.service.IQdCommonService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
+import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+
 /**
  * @Description: TODO
  * @Author: huangcheng
@@ -28,7 +33,7 @@ public class XunTask {
     @Autowired
     private ITlInspectionLocationService tlInspectionLocationService;
     @Autowired
-    private RedisCache redisCache;
+    private ITlInspectionLocationLogService tlInspectionLocationLogService;
 
     /**
      * 同步设备列表
@@ -36,6 +41,8 @@ public class XunTask {
     public void syncDevice() {
         JSONArray deviceList = qdCommonService.getDevice();
         if (deviceList != null && deviceList.size() > 0) {
+            // 获取当前需要更新的版本号
+            int version = qdCommonService.getVersion("tl:version:devicce");
             for (Object o : deviceList) {
                 JSONObject jsonObject = JSONUtil.parseObj(o);
                 String thirdId = jsonObject.getStr("id");
@@ -46,15 +53,19 @@ public class XunTask {
                 if (tlInspectionDevice != null) {
                     tlInspectionDevice.setDeviceCode(code);
                     tlInspectionDevice.setDeviceName(name);
+                    tlInspectionDevice.setVersion(version);
                     tlInspectionDeviceService.updateTlInspectionDevice(tlInspectionDevice);
                 } else {
                     tlInspectionDevice = new TlInspectionDevice();
                     tlInspectionDevice.setDeviceCode(code);
                     tlInspectionDevice.setDeviceName(name);
+                    tlInspectionDevice.setVersion(version);
                     tlInspectionDevice.setThirdId(thirdId);
                     tlInspectionDeviceService.insertTlInspectionDevice(tlInspectionDevice);
                 }
             }
+            // 删除非此版本号的数据
+            tlInspectionDeviceService.deleteLocationByVersion(version);
         }
     }
 
@@ -96,13 +107,29 @@ public class XunTask {
      * 同步巡检记录
      */
     public void syncCheckpointLog() {
-
+        // 获取目前数据库中最后的记录事件
+        Date maxDate = tlInspectionLocationLogService.queryMaxDate();
+        long startTime;
+        long endTime = DateUtil.current();
+        if (maxDate == null) {
+            startTime = DateUtil.offsetDay(new Date(), -20).getTime();
+        } else {
+            startTime = DateUtil.offsetSecond(maxDate, 1).getTime();
+        }
+        JSONArray checkpointLogs = qdCommonService.getCheckpointLog(startTime, endTime);
+        if (checkpointLogs != null && checkpointLogs.size() > 0) {
+            for (Object checkpointLog : checkpointLogs) {
+                TlInspectionLocationLog convert = Convert.convert(TlInspectionLocationLog.class, checkpointLog);
+                tlInspectionLocationLogService.insertTlInspectionLocationLog(convert);
+            }
+        }
     }
 
     /**
      * 同步巡检轨迹
      */
     public void syncTrail() {
-
+        // 暂无
     }
+
 }

+ 69 - 54
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionDevice.java

@@ -1,128 +1,135 @@
 package com.ruoyi.qdtl.domain;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 巡检设备管理对象 tl_inspection_device
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
-public class TlInspectionDevice extends BaseEntity
-{
+public class TlInspectionDevice extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** id */
+    /**
+     * id
+     */
     private Long id;
 
-    /** 设备编号 */
+    /**
+     * 设备编号
+     */
     @Excel(name = "设备编号")
     private String deviceCode;
 
-    /** 设备名称 */
+    /**
+     * 设备名称
+     */
     @Excel(name = "设备名称")
     private String deviceName;
 
-    /** 设备类型 */
+    /**
+     * 设备类型
+     */
     @Excel(name = "设备类型")
     private String deviceType;
 
-    /** 经纬度 */
+    /**
+     * 经纬度
+     */
     @Excel(name = "经纬度")
     private String lnglat;
 
-    /** 所属区域 */
+    /**
+     * 所属区域
+     */
     @Excel(name = "所属区域")
     private Long areaId;
 
-    /** 删除标志(0代表存在 2代表删除) */
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
     private String delFlag;
 
     private String thirdId;
 
-    public void setId(Long id) 
-    {
+    private Integer version;
+
+    public void setId(Long id) {
         this.id = id;
     }
 
-    public Long getId() 
-    {
+    public Long getId() {
         return id;
     }
-    public void setDeviceCode(String deviceCode) 
-    {
+
+    public void setDeviceCode(String deviceCode) {
         this.deviceCode = deviceCode;
     }
 
-    public String getDeviceCode() 
-    {
+    public String getDeviceCode() {
         return deviceCode;
     }
-    public void setDeviceName(String deviceName) 
-    {
+
+    public void setDeviceName(String deviceName) {
         this.deviceName = deviceName;
     }
 
-    public String getDeviceName() 
-    {
+    public String getDeviceName() {
         return deviceName;
     }
-    public void setDeviceType(String deviceType) 
-    {
+
+    public void setDeviceType(String deviceType) {
         this.deviceType = deviceType;
     }
 
-    public String getDeviceType() 
-    {
+    public String getDeviceType() {
         return deviceType;
     }
-    public void setLnglat(String lnglat) 
-    {
+
+    public void setLnglat(String lnglat) {
         this.lnglat = lnglat;
     }
 
-    public String getLnglat() 
-    {
+    public String getLnglat() {
         return lnglat;
     }
-    public void setAreaId(Long areaId) 
-    {
+
+    public void setAreaId(Long areaId) {
         this.areaId = areaId;
     }
 
-    public Long getAreaId() 
-    {
+    public Long getAreaId() {
         return areaId;
     }
-    public void setDelFlag(String delFlag) 
-    {
+
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public String getDelFlag() 
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("deviceCode", getDeviceCode())
-            .append("deviceName", getDeviceName())
-            .append("deviceType", getDeviceType())
-            .append("lnglat", getLnglat())
-            .append("areaId", getAreaId())
-            .append("remark", getRemark())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("deviceCode", getDeviceCode())
+                .append("deviceName", getDeviceName())
+                .append("deviceType", getDeviceType())
+                .append("lnglat", getLnglat())
+                .append("areaId", getAreaId())
+                .append("remark", getRemark())
+                .append("delFlag", getDelFlag())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .toString();
     }
 
     public String getThirdId() {
@@ -132,4 +139,12 @@ public class TlInspectionDevice extends BaseEntity
     public void setThirdId(String thirdId) {
         this.thirdId = thirdId;
     }
+
+    public Integer getVersion() {
+        return version;
+    }
+
+    public void setVersion(Integer version) {
+        this.version = version;
+    }
 }

+ 192 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionLocationLog.java

@@ -0,0 +1,192 @@
+package com.ruoyi.qdtl.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 巡检记录管理对象 tl_inspection_location_log
+ * 
+ * @author ruoyi
+ * @date 2022-03-10
+ */
+public class TlInspectionLocationLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private Long id;
+
+    /** 巡检点id */
+    @Excel(name = "巡检点id")
+    private String checkpointId;
+
+    /** 巡检点名称 */
+    @Excel(name = "巡检点名称")
+    private String checkpointName;
+
+    /** 巡检点卡号 */
+    @Excel(name = "巡检点卡号")
+    private String checkpointCard;
+
+    /** 巡检员ID */
+    @Excel(name = "巡检员ID")
+    private String patrolmanId;
+
+    /** 巡检员名称 */
+    @Excel(name = "巡检员名称")
+    private String patrolmanName;
+
+    /** 巡检员卡号 */
+    @Excel(name = "巡检员卡号")
+    private String patrolmanCard;
+
+    /** 巡检器id */
+    @Excel(name = "巡检器id")
+    private String deviceId;
+
+    /** 巡检器名称 */
+    @Excel(name = "巡检器名称")
+    private String deviceName;
+
+    /** 巡检器卡号 */
+    @Excel(name = "巡检器卡号")
+    private String deviceCode;
+
+    /** 组织ID(与巡检点所在的组织一致) */
+    @Excel(name = "组织ID(与巡检点所在的组织一致)")
+    private String areaId;
+
+    /** 组织名称 */
+    @Excel(name = "组织名称")
+    private String areaName;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setCheckpointId(String checkpointId) 
+    {
+        this.checkpointId = checkpointId;
+    }
+
+    public String getCheckpointId() 
+    {
+        return checkpointId;
+    }
+    public void setCheckpointName(String checkpointName) 
+    {
+        this.checkpointName = checkpointName;
+    }
+
+    public String getCheckpointName() 
+    {
+        return checkpointName;
+    }
+    public void setCheckpointCard(String checkpointCard) 
+    {
+        this.checkpointCard = checkpointCard;
+    }
+
+    public String getCheckpointCard() 
+    {
+        return checkpointCard;
+    }
+    public void setPatrolmanId(String patrolmanId) 
+    {
+        this.patrolmanId = patrolmanId;
+    }
+
+    public String getPatrolmanId() 
+    {
+        return patrolmanId;
+    }
+    public void setPatrolmanName(String patrolmanName) 
+    {
+        this.patrolmanName = patrolmanName;
+    }
+
+    public String getPatrolmanName() 
+    {
+        return patrolmanName;
+    }
+    public void setPatrolmanCard(String patrolmanCard) 
+    {
+        this.patrolmanCard = patrolmanCard;
+    }
+
+    public String getPatrolmanCard() 
+    {
+        return patrolmanCard;
+    }
+    public void setDeviceId(String deviceId) 
+    {
+        this.deviceId = deviceId;
+    }
+
+    public String getDeviceId() 
+    {
+        return deviceId;
+    }
+    public void setDeviceName(String deviceName) 
+    {
+        this.deviceName = deviceName;
+    }
+
+    public String getDeviceName() 
+    {
+        return deviceName;
+    }
+    public void setDeviceCode(String deviceCode) 
+    {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getDeviceCode() 
+    {
+        return deviceCode;
+    }
+    public void setAreaId(String areaId) 
+    {
+        this.areaId = areaId;
+    }
+
+    public String getAreaId() 
+    {
+        return areaId;
+    }
+    public void setAreaName(String areaName) 
+    {
+        this.areaName = areaName;
+    }
+
+    public String getAreaName() 
+    {
+        return areaName;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("checkpointId", getCheckpointId())
+            .append("checkpointName", getCheckpointName())
+            .append("checkpointCard", getCheckpointCard())
+            .append("patrolmanId", getPatrolmanId())
+            .append("patrolmanName", getPatrolmanName())
+            .append("patrolmanCard", getPatrolmanCard())
+            .append("createTime", getCreateTime())
+            .append("deviceId", getDeviceId())
+            .append("deviceName", getDeviceName())
+            .append("deviceCode", getDeviceCode())
+            .append("areaId", getAreaId())
+            .append("areaName", getAreaName())
+            .toString();
+    }
+}

+ 12 - 13
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionDeviceMapper.java

@@ -1,24 +1,21 @@
 package com.ruoyi.qdtl.mapper;
 
-import java.util.List;
-import java.util.Map;
-
 import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.qdtl.domain.TlInspectionDevice;
-import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 巡检设备管理Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
-public interface TlInspectionDeviceMapper 
-{
+public interface TlInspectionDeviceMapper {
     /**
      * 查询巡检设备管理
-     * 
+     *
      * @param id 巡检设备管理主键
      * @return 巡检设备管理
      */
@@ -26,7 +23,7 @@ public interface TlInspectionDeviceMapper
 
     /**
      * 查询巡检设备管理列表
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 巡检设备管理集合
      */
@@ -34,7 +31,7 @@ public interface TlInspectionDeviceMapper
 
     /**
      * 新增巡检设备管理
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 结果
      */
@@ -42,7 +39,7 @@ public interface TlInspectionDeviceMapper
 
     /**
      * 修改巡检设备管理
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 结果
      */
@@ -50,7 +47,7 @@ public interface TlInspectionDeviceMapper
 
     /**
      * 删除巡检设备管理
-     * 
+     *
      * @param id 巡检设备管理主键
      * @return 结果
      */
@@ -58,7 +55,7 @@ public interface TlInspectionDeviceMapper
 
     /**
      * 批量删除巡检设备管理
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
@@ -69,4 +66,6 @@ public interface TlInspectionDeviceMapper
     List<JSONObject> queryDeviceByArea();
 
     TlInspectionDevice queryByThirdId(@Param("thirdId") String thirdId);
+
+    void deleteLocationByVersion(@Param("version") int version);
 }

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

@@ -0,0 +1,64 @@
+package com.ruoyi.qdtl.mapper;
+
+import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 巡检记录管理Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-03-10
+ */
+public interface TlInspectionLocationLogMapper {
+    /**
+     * 查询巡检记录管理
+     *
+     * @param id 巡检记录管理主键
+     * @return 巡检记录管理
+     */
+    public TlInspectionLocationLog selectTlInspectionLocationLogById(Long id);
+
+    /**
+     * 查询巡检记录管理列表
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 巡检记录管理集合
+     */
+    public List<TlInspectionLocationLog> selectTlInspectionLocationLogList(TlInspectionLocationLog tlInspectionLocationLog);
+
+    /**
+     * 新增巡检记录管理
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 结果
+     */
+    public int insertTlInspectionLocationLog(TlInspectionLocationLog tlInspectionLocationLog);
+
+    /**
+     * 修改巡检记录管理
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 结果
+     */
+    public int updateTlInspectionLocationLog(TlInspectionLocationLog tlInspectionLocationLog);
+
+    /**
+     * 删除巡检记录管理
+     *
+     * @param id 巡检记录管理主键
+     * @return 结果
+     */
+    public int deleteTlInspectionLocationLogById(Long id);
+
+    /**
+     * 批量删除巡检记录管理
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTlInspectionLocationLogByIds(Long[] ids);
+
+    Date queryMaxDate();
+}

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

@@ -14,11 +14,11 @@ public interface IQdCommonService {
 
     JSONArray getDevice();
 
-    JSONArray getCheckpointLog(String startTime, String endTime);
+    JSONArray getCheckpointLog(long startTime, long endTime);
 
     JSONArray getCheckpoint();
 
-    JSONArray getTrail(String startTime, String endTime, String deviceId);
+    JSONArray getTrail(long startTime, long endTime, String deviceId);
 
     int getVersion(String key);
 }

+ 13 - 13
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionDeviceService.java

@@ -1,22 +1,20 @@
 package com.ruoyi.qdtl.service;
 
+import com.ruoyi.qdtl.domain.TlInspectionDevice;
+
 import java.util.List;
 import java.util.Map;
 
-import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.qdtl.domain.TlInspectionDevice;
-
 /**
  * 巡检设备管理Service接口
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
-public interface ITlInspectionDeviceService 
-{
+public interface ITlInspectionDeviceService {
     /**
      * 查询巡检设备管理
-     * 
+     *
      * @param id 巡检设备管理主键
      * @return 巡检设备管理
      */
@@ -24,7 +22,7 @@ public interface ITlInspectionDeviceService
 
     /**
      * 查询巡检设备管理列表
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 巡检设备管理集合
      */
@@ -32,7 +30,7 @@ public interface ITlInspectionDeviceService
 
     /**
      * 新增巡检设备管理
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 结果
      */
@@ -40,7 +38,7 @@ public interface ITlInspectionDeviceService
 
     /**
      * 修改巡检设备管理
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 结果
      */
@@ -48,7 +46,7 @@ public interface ITlInspectionDeviceService
 
     /**
      * 批量删除巡检设备管理
-     * 
+     *
      * @param ids 需要删除的巡检设备管理主键集合
      * @return 结果
      */
@@ -56,13 +54,15 @@ public interface ITlInspectionDeviceService
 
     /**
      * 删除巡检设备管理信息
-     * 
+     *
      * @param id 巡检设备管理主键
      * @return 结果
      */
     public int deleteTlInspectionDeviceById(Long id);
 
-    Map<String,Integer> queryDeviceByArea();
+    Map<String, Integer> queryDeviceByArea();
 
     TlInspectionDevice queryByThirdId(String thirdId);
+
+    void deleteLocationByVersion(int version);
 }

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

@@ -0,0 +1,64 @@
+package com.ruoyi.qdtl.service;
+
+import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 巡检记录管理Service接口
+ *
+ * @author ruoyi
+ * @date 2022-03-10
+ */
+public interface ITlInspectionLocationLogService {
+    /**
+     * 查询巡检记录管理
+     *
+     * @param id 巡检记录管理主键
+     * @return 巡检记录管理
+     */
+    public TlInspectionLocationLog selectTlInspectionLocationLogById(Long id);
+
+    /**
+     * 查询巡检记录管理列表
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 巡检记录管理集合
+     */
+    public List<TlInspectionLocationLog> selectTlInspectionLocationLogList(TlInspectionLocationLog tlInspectionLocationLog);
+
+    /**
+     * 新增巡检记录管理
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 结果
+     */
+    public int insertTlInspectionLocationLog(TlInspectionLocationLog tlInspectionLocationLog);
+
+    /**
+     * 修改巡检记录管理
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 结果
+     */
+    public int updateTlInspectionLocationLog(TlInspectionLocationLog tlInspectionLocationLog);
+
+    /**
+     * 批量删除巡检记录管理
+     *
+     * @param ids 需要删除的巡检记录管理主键集合
+     * @return 结果
+     */
+    public int deleteTlInspectionLocationLogByIds(Long[] ids);
+
+    /**
+     * 删除巡检记录管理信息
+     *
+     * @param id 巡检记录管理主键
+     * @return 结果
+     */
+    public int deleteTlInspectionLocationLogById(Long id);
+
+    Date queryMaxDate();
+}

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

@@ -1,6 +1,8 @@
 package com.ruoyi.qdtl.service.impl;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
@@ -99,10 +101,14 @@ public class QdCommonServiceImpl implements IQdCommonService {
      */
     @Override
     @SneakyThrows
-    public JSONArray getCheckpointLog(String startTime, String endTime) {
+    public JSONArray getCheckpointLog(long startTime, long endTime) {
+        if (ObjectUtil.isNull(endTime)) {
+            endTime = DateUtil.current();
+        }
         Map<String, Object> paramMap = new HashMap<>();
         paramMap.put("startTime", startTime);
         paramMap.put("endTime", endTime);
+        paramMap.put("pageSize", 5000);
         String get = HttpRequest.get(xuncheckpointLogUrl).form(paramMap).header("Authorization", this.getXunToken()).execute().body();
         JSONObject getJson = JSONUtil.parseObj(get);
         if (200 == getJson.getInt("code")) {
@@ -122,7 +128,7 @@ public class QdCommonServiceImpl implements IQdCommonService {
     @Override
     public JSONArray getCheckpoint() {
         Map<String, Object> paramMap = new HashMap<>();
-        paramMap.put("pageSize", 3000);
+        paramMap.put("pageSize", 5000);
         String get = HttpRequest.get(xuncheckpointUrl).form(paramMap).header("Authorization", this.getXunToken()).execute().body();
         JSONObject getJson = JSONUtil.parseObj(get);
         if (200 == getJson.getInt("code")) {
@@ -143,7 +149,10 @@ public class QdCommonServiceImpl implements IQdCommonService {
      * @return
      */
     @Override
-    public JSONArray getTrail(String startTime, String endTime, String deviceId) {
+    public JSONArray getTrail(long startTime, long endTime, String deviceId) {
+        if (ObjectUtil.isNull(endTime)) {
+            endTime = DateUtil.current();
+        }
         Map<String, Object> paramMap = new HashMap<>();
         paramMap.put("startTime", startTime);
         paramMap.put("endTime", endTime);

+ 12 - 10
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionDeviceServiceImpl.java

@@ -1,21 +1,18 @@
 package com.ruoyi.qdtl.service.impl;
 
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import cn.hutool.core.convert.Convert;
 import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.qdtl.domain.TlArea;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-import com.ruoyi.qdtl.mapper.TlInspectionDeviceMapper;
 import com.ruoyi.qdtl.domain.TlInspectionDevice;
+import com.ruoyi.qdtl.mapper.TlInspectionDeviceMapper;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 巡检设备管理Service业务层处理
@@ -144,4 +141,9 @@ public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
     public TlInspectionDevice queryByThirdId(String thirdId) {
         return tlInspectionDeviceMapper.queryByThirdId(thirdId);
     }
+
+    @Override
+    public void deleteLocationByVersion(int version) {
+        tlInspectionDeviceMapper.deleteLocationByVersion(version);
+    }
 }

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

@@ -0,0 +1,95 @@
+package com.ruoyi.qdtl.service.impl;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+import com.ruoyi.qdtl.mapper.TlInspectionLocationLogMapper;
+import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 巡检记录管理Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-03-10
+ */
+@Service
+public class TlInspectionLocationLogServiceImpl implements ITlInspectionLocationLogService {
+    @Autowired
+    private TlInspectionLocationLogMapper tlInspectionLocationLogMapper;
+
+    /**
+     * 查询巡检记录管理
+     *
+     * @param id 巡检记录管理主键
+     * @return 巡检记录管理
+     */
+    @Override
+    public TlInspectionLocationLog selectTlInspectionLocationLogById(Long id) {
+        return tlInspectionLocationLogMapper.selectTlInspectionLocationLogById(id);
+    }
+
+    /**
+     * 查询巡检记录管理列表
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 巡检记录管理
+     */
+    @Override
+    public List<TlInspectionLocationLog> selectTlInspectionLocationLogList(TlInspectionLocationLog tlInspectionLocationLog) {
+        return tlInspectionLocationLogMapper.selectTlInspectionLocationLogList(tlInspectionLocationLog);
+    }
+
+    /**
+     * 新增巡检记录管理
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 结果
+     */
+    @Override
+    public int insertTlInspectionLocationLog(TlInspectionLocationLog tlInspectionLocationLog) {
+        tlInspectionLocationLog.setCreateTime(DateUtils.getNowDate());
+        return tlInspectionLocationLogMapper.insertTlInspectionLocationLog(tlInspectionLocationLog);
+    }
+
+    /**
+     * 修改巡检记录管理
+     *
+     * @param tlInspectionLocationLog 巡检记录管理
+     * @return 结果
+     */
+    @Override
+    public int updateTlInspectionLocationLog(TlInspectionLocationLog tlInspectionLocationLog) {
+        return tlInspectionLocationLogMapper.updateTlInspectionLocationLog(tlInspectionLocationLog);
+    }
+
+    /**
+     * 批量删除巡检记录管理
+     *
+     * @param ids 需要删除的巡检记录管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlInspectionLocationLogByIds(Long[] ids) {
+        return tlInspectionLocationLogMapper.deleteTlInspectionLocationLogByIds(ids);
+    }
+
+    /**
+     * 删除巡检记录管理信息
+     *
+     * @param id 巡检记录管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlInspectionLocationLogById(Long id) {
+        return tlInspectionLocationLogMapper.deleteTlInspectionLocationLogById(id);
+    }
+
+    @Override
+    public Date queryMaxDate() {
+        return tlInspectionLocationLogMapper.queryMaxDate();
+    }
+}

+ 12 - 1
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionDeviceMapper.xml

@@ -18,6 +18,7 @@
         <result property="updateBy" column="update_by"/>
         <result property="updateTime" column="update_time"/>
         <result property="thirdId" column="third_id"/>
+        <result property="version" column="version"/>
     </resultMap>
 
     <sql id="selectTlInspectionDeviceVo">
@@ -33,7 +34,8 @@
                create_time,
                update_by,
                update_time,
-               third_id
+               third_id,
+               version
         from tl_inspection_device
     </sql>
 
@@ -91,6 +93,7 @@
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="thirdId != null">third_id,</if>
+            <if test="version != null">version,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
@@ -105,6 +108,7 @@
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="thirdId != null">#{thirdId},</if>
+            <if test="version != null">#{version},</if>
         </trim>
     </insert>
 
@@ -123,6 +127,7 @@
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="thirdId != null">third_id = #{thirdId},</if>
+            <if test="version != null">version = #{version},</if>
         </trim>
         where id = #{id}
     </update>
@@ -139,4 +144,10 @@
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteLocationByVersion">
+        update tl_inspection_device
+        set del_flag = '2'
+        where version != #{version}
+    </delete>
 </mapper>

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

@@ -0,0 +1,130 @@
+<?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.TlInspectionLocationLogMapper">
+
+    <resultMap type="TlInspectionLocationLog" id="TlInspectionLocationLogResult">
+        <result property="id" column="id"/>
+        <result property="checkpointId" column="checkpoint_id"/>
+        <result property="checkpointName" column="checkpoint_name"/>
+        <result property="checkpointCard" column="checkpoint_card"/>
+        <result property="patrolmanId" column="patrolman_id"/>
+        <result property="patrolmanName" column="patrolman_name"/>
+        <result property="patrolmanCard" column="patrolman_card"/>
+        <result property="createTime" column="create_time"/>
+        <result property="deviceId" column="device_id"/>
+        <result property="deviceName" column="device_name"/>
+        <result property="deviceCode" column="device_code"/>
+        <result property="areaId" column="area_id"/>
+        <result property="areaName" column="area_name"/>
+    </resultMap>
+
+    <sql id="selectTlInspectionLocationLogVo">
+        select id,
+               checkpoint_id,
+               checkpoint_name,
+               checkpoint_card,
+               patrolman_id,
+               patrolman_name,
+               patrolman_card,
+               create_time,
+               device_id,
+               device_name,
+               device_code,
+               area_id,
+               area_name
+        from tl_inspection_location_log
+    </sql>
+
+    <select id="selectTlInspectionLocationLogList" parameterType="TlInspectionLocationLog" resultMap="TlInspectionLocationLogResult">
+        <include refid="selectTlInspectionLocationLogVo"/>
+        <where>
+            <if test="checkpointId != null  and checkpointId != ''">and checkpoint_id = #{checkpointId}</if>
+            <if test="checkpointName != null  and checkpointName != ''">and checkpoint_name like concat('%', #{checkpointName}, '%')</if>
+            <if test="checkpointCard != null  and checkpointCard != ''">and checkpoint_card = #{checkpointCard}</if>
+            <if test="patrolmanId != null  and patrolmanId != ''">and patrolman_id = #{patrolmanId}</if>
+            <if test="patrolmanName != null  and patrolmanName != ''">and patrolman_name like concat('%', #{patrolmanName}, '%')</if>
+            <if test="patrolmanCard != null  and patrolmanCard != ''">and patrolman_card = #{patrolmanCard}</if>
+            <if test="deviceId != null  and deviceId != ''">and device_id = #{deviceId}</if>
+            <if test="deviceName != null  and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
+            <if test="deviceCode != null  and deviceCode != ''">and device_code = #{deviceCode}</if>
+            <if test="areaId != null  and areaId != ''">and area_id = #{areaId}</if>
+            <if test="areaName != null  and areaName != ''">and area_name like concat('%', #{areaName}, '%')</if>
+        </where>
+    </select>
+
+    <select id="selectTlInspectionLocationLogById" parameterType="Long" resultMap="TlInspectionLocationLogResult">
+        <include refid="selectTlInspectionLocationLogVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="queryMaxDate" resultType="java.util.Date">
+        select max(create_time)
+        from tl_inspection_location_log
+    </select>
+
+    <insert id="insertTlInspectionLocationLog" parameterType="TlInspectionLocationLog" useGeneratedKeys="true" keyProperty="id">
+        insert into tl_inspection_location_log
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="checkpointId != null">checkpoint_id,</if>
+            <if test="checkpointName != null">checkpoint_name,</if>
+            <if test="checkpointCard != null">checkpoint_card,</if>
+            <if test="patrolmanId != null">patrolman_id,</if>
+            <if test="patrolmanName != null">patrolman_name,</if>
+            <if test="patrolmanCard != null">patrolman_card,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="deviceId != null">device_id,</if>
+            <if test="deviceName != null">device_name,</if>
+            <if test="deviceCode != null">device_code,</if>
+            <if test="areaId != null">area_id,</if>
+            <if test="areaName != null">area_name,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="checkpointId != null">#{checkpointId},</if>
+            <if test="checkpointName != null">#{checkpointName},</if>
+            <if test="checkpointCard != null">#{checkpointCard},</if>
+            <if test="patrolmanId != null">#{patrolmanId},</if>
+            <if test="patrolmanName != null">#{patrolmanName},</if>
+            <if test="patrolmanCard != null">#{patrolmanCard},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="deviceId != null">#{deviceId},</if>
+            <if test="deviceName != null">#{deviceName},</if>
+            <if test="deviceCode != null">#{deviceCode},</if>
+            <if test="areaId != null">#{areaId},</if>
+            <if test="areaName != null">#{areaName},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTlInspectionLocationLog" parameterType="TlInspectionLocationLog">
+        update tl_inspection_location_log
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="checkpointId != null">checkpoint_id = #{checkpointId},</if>
+            <if test="checkpointName != null">checkpoint_name = #{checkpointName},</if>
+            <if test="checkpointCard != null">checkpoint_card = #{checkpointCard},</if>
+            <if test="patrolmanId != null">patrolman_id = #{patrolmanId},</if>
+            <if test="patrolmanName != null">patrolman_name = #{patrolmanName},</if>
+            <if test="patrolmanCard != null">patrolman_card = #{patrolmanCard},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="deviceId != null">device_id = #{deviceId},</if>
+            <if test="deviceName != null">device_name = #{deviceName},</if>
+            <if test="deviceCode != null">device_code = #{deviceCode},</if>
+            <if test="areaId != null">area_id = #{areaId},</if>
+            <if test="areaName != null">area_name = #{areaName},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteTlInspectionLocationLogById" parameterType="Long">
+        delete
+        from tl_inspection_location_log
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteTlInspectionLocationLogByIds" parameterType="String">
+        delete from tl_inspection_location_log where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>