فهرست منبع

巡检员数据同步

459242451@qq.com 3 سال پیش
والد
کامیت
0ee6dc50f9

+ 24 - 17
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionLineController.java

@@ -1,30 +1,29 @@
 package com.ruoyi.web.controller.qdtl;
 
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import javax.servlet.http.HttpServletResponse;
-
+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.qdtl.domain.TlInspectionLine;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
+import com.ruoyi.qdtl.service.ITlInspectionLineService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
-import org.springframework.security.access.prepost.PreAuthorize;
 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.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.qdtl.domain.TlInspectionLine;
-import com.ruoyi.qdtl.service.ITlInspectionLineService;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 巡检线路管理Controller
@@ -80,7 +79,15 @@ public class TlInspectionLineController extends BaseController {
     @PreAuthorize("@ss.hasPermi('qdtl:line:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
-        return AjaxResult.success(tlInspectionLineService.selectTlInspectionLineById(id));
+        TlInspectionLine tlInspectionLine = tlInspectionLineService.selectTlInspectionLineById(id);
+        // 查询线路的点位数据
+        List<Long> ids = new ArrayList<>();
+        ids.add(id);
+        List<TlInspectionLocation> locations = tlInspectionLocationService.queryLocationByLineIds(ids);
+        for (TlInspectionLocation location : locations) {
+            // 查询点位的设备数据
+        }
+        return AjaxResult.success();
     }
 
     /**

+ 98 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlPatrolmanController.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.TlPatrolman;
+import com.ruoyi.qdtl.service.ITlPatrolmanService;
+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-25
+ */
+@RestController
+@RequestMapping("/qdtl/patrolman")
+public class TlPatrolmanController extends BaseController {
+    @Autowired
+    private ITlPatrolmanService tlPatrolmanService;
+
+    /**
+     * 查询巡检员列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:patrolman:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TlPatrolman tlPatrolman) {
+        startPage();
+        List<TlPatrolman> list = tlPatrolmanService.selectTlPatrolmanList(tlPatrolman);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出巡检员列表
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:patrolman:export')")
+    @Log(title = "巡检员", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TlPatrolman tlPatrolman) {
+        List<TlPatrolman> list = tlPatrolmanService.selectTlPatrolmanList(tlPatrolman);
+        ExcelUtil<TlPatrolman> util = new ExcelUtil<TlPatrolman>(TlPatrolman.class);
+        util.exportExcel(response, list, "巡检员数据");
+    }
+
+    /**
+     * 获取巡检员详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:patrolman:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return AjaxResult.success(tlPatrolmanService.selectTlPatrolmanById(id));
+    }
+
+    /**
+     * 新增巡检员
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:patrolman:add')")
+    @Log(title = "巡检员", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TlPatrolman tlPatrolman) {
+        return toAjax(tlPatrolmanService.insertTlPatrolman(tlPatrolman));
+    }
+
+    /**
+     * 修改巡检员
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:patrolman:edit')")
+    @Log(title = "巡检员", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TlPatrolman tlPatrolman) {
+        return toAjax(tlPatrolmanService.updateTlPatrolman(tlPatrolman));
+    }
+
+    /**
+     * 删除巡检员
+     */
+    @PreAuthorize("@ss.hasPermi('qdtl:patrolman:remove')")
+    @Log(title = "巡检员", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(tlPatrolmanService.deleteTlPatrolmanByIds(ids));
+    }
+}

+ 40 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/XunTask.java

@@ -11,11 +11,13 @@ import com.ruoyi.qdtl.domain.TlInspectionDevice;
 import com.ruoyi.qdtl.domain.TlInspectionDeviceTrail;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+import com.ruoyi.qdtl.domain.TlPatrolman;
 import com.ruoyi.qdtl.service.IQdCommonService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceTrailService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
+import com.ruoyi.qdtl.service.ITlPatrolmanService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -40,6 +42,8 @@ public class XunTask {
     private ITlInspectionLocationLogService tlInspectionLocationLogService;
     @Autowired
     private ITlInspectionDeviceTrailService tlInspectionDeviceTrailService;
+    @Autowired
+    private ITlPatrolmanService tlPatrolmanService;
 
     /**
      * 同步设备列表
@@ -149,4 +153,40 @@ public class XunTask {
         // 暂无
     }
 
+    /**
+     * 同步巡检员
+     */
+    public void syncPatrolman() {
+        JSONArray patrolmans = qdCommonService.getPatrolman();
+        if (patrolmans != null && patrolmans.size() > 0) {
+            // 获取当前需要更新的版本号
+            int version = qdCommonService.getVersion("tl:version:patrolman");
+            for (Object patrolman : patrolmans) {
+                JSONObject jsonObject = JSONUtil.parseObj(patrolman);
+                String thirdId = jsonObject.getStr("id");
+                String name = jsonObject.getStr("name");
+                String card = jsonObject.getStr("card");
+//                String areaId = jsonObject.getStr("areaId");
+//                String areaName = jsonObject.getStr("areaName");
+                // 根据thirdId查询是否存在
+                TlPatrolman tlPatrolman = tlPatrolmanService.queryByThirdId(thirdId);
+                if (tlPatrolman != null) {
+                    tlPatrolman.setName(name);
+                    tlPatrolman.setCard(card);
+                    tlPatrolman.setVersion(version);
+                    tlPatrolmanService.updateTlPatrolman(tlPatrolman);
+                } else {
+                    tlPatrolman = new TlPatrolman();
+                    tlPatrolman.setName(name);
+                    tlPatrolman.setCard(card);
+                    tlPatrolman.setVersion(version);
+                    tlPatrolman.setThirdId(thirdId);
+                    tlPatrolmanService.insertTlPatrolman(tlPatrolman);
+                }
+            }
+            // 删除非此版本号的数据
+            tlPatrolmanService.deletePatrolmanByVersion(version);
+        }
+    }
+
 }

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

@@ -128,5 +128,6 @@ third:
   xundevice: https://api.5ixun.com/api/v1/device # 设备列表
   xuncheckpointLog: https://api.5ixun.com/api/v1/checkpointLog # 设备巡检历史
   xuncheckpoint: https://api.5ixun.com/api/v1/checkpoint # 巡检点
+  xunpatrolman: https://api.5ixun.com/api/v1/patrolman # 巡检员
   xuntrail: https://api.5ixun.com/api/v1/trail # 设备轨迹
 

+ 126 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlPatrolman.java

@@ -0,0 +1,126 @@
+package com.ruoyi.qdtl.domain;
+
+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_patrolman
+ *
+ * @author ruoyi
+ * @date 2022-03-25
+ */
+public class TlPatrolman extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * 巡检员姓名
+     */
+    @Excel(name = "巡检员姓名")
+    private String name;
+
+    /**
+     * 巡检员卡号
+     */
+    @Excel(name = "巡检员卡号")
+    private String card;
+
+    /**
+     * 组织id
+     */
+    @Excel(name = "组织id")
+    private String areaId;
+
+    /**
+     * 组织名称
+     */
+    @Excel(name = "组织名称")
+    private String areaName;
+
+    /**
+     * 第三方id
+     */
+    @Excel(name = "第三方id")
+    private String thirdId;
+
+    /**
+     * 同步版本
+     */
+    @Excel(name = "同步版本")
+    private Integer version;
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setCard(String card) {
+        this.card = card;
+    }
+
+    public String getCard() {
+        return card;
+    }
+
+    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;
+    }
+
+    public void setThirdId(String thirdId) {
+        this.thirdId = thirdId;
+    }
+
+    public String getThirdId() {
+        return thirdId;
+    }
+
+    public void setVersion(Integer version) {
+        this.version = version;
+    }
+
+    public Integer getVersion() {
+        return version;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("name", getName())
+                .append("card", getCard())
+                .append("areaId", getAreaId())
+                .append("areaName", getAreaName())
+                .append("thirdId", getThirdId())
+                .append("version", getVersion())
+                .toString();
+    }
+}

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionDeviceMapper.java

@@ -68,4 +68,6 @@ public interface TlInspectionDeviceMapper {
     TlInspectionDevice queryByThirdId(@Param("thirdId") String thirdId);
 
     void deleteLocationByVersion(@Param("version") int version);
+
+    int queryMaxVsersion();
 }

+ 68 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlPatrolmanMapper.java

@@ -0,0 +1,68 @@
+package com.ruoyi.qdtl.mapper;
+
+import com.ruoyi.qdtl.domain.TlPatrolman;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 巡检员Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-03-25
+ */
+public interface TlPatrolmanMapper {
+    /**
+     * 查询巡检员
+     *
+     * @param id 巡检员主键
+     * @return 巡检员
+     */
+    public TlPatrolman selectTlPatrolmanById(Long id);
+
+    /**
+     * 查询巡检员列表
+     *
+     * @param tlPatrolman 巡检员
+     * @return 巡检员集合
+     */
+    public List<TlPatrolman> selectTlPatrolmanList(TlPatrolman tlPatrolman);
+
+    /**
+     * 新增巡检员
+     *
+     * @param tlPatrolman 巡检员
+     * @return 结果
+     */
+    public int insertTlPatrolman(TlPatrolman tlPatrolman);
+
+    /**
+     * 修改巡检员
+     *
+     * @param tlPatrolman 巡检员
+     * @return 结果
+     */
+    public int updateTlPatrolman(TlPatrolman tlPatrolman);
+
+    /**
+     * 删除巡检员
+     *
+     * @param id 巡检员主键
+     * @return 结果
+     */
+    public int deleteTlPatrolmanById(Long id);
+
+    /**
+     * 批量删除巡检员
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTlPatrolmanByIds(Long[] ids);
+
+    int queryMaxVsersion();
+
+    TlPatrolman queryByThirdId(@Param("thirdId") String thirdId);
+
+    void deletePatrolmanByVersion(@Param("version") int version);
+}

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

@@ -18,6 +18,8 @@ public interface IQdCommonService {
 
     JSONArray getCheckpoint();
 
+    JSONArray getPatrolman();
+
     JSONArray getTrail(long startTime, long endTime, String deviceId);
 
     int getVersion(String key);

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

@@ -65,4 +65,7 @@ public interface ITlInspectionDeviceService {
     TlInspectionDevice queryByThirdId(String thirdId);
 
     void deleteLocationByVersion(int version);
+
+    int queryMaxVsersion();
+    
 }

+ 67 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlPatrolmanService.java

@@ -0,0 +1,67 @@
+package com.ruoyi.qdtl.service;
+
+import com.ruoyi.qdtl.domain.TlPatrolman;
+
+import java.util.List;
+
+/**
+ * 巡检员Service接口
+ *
+ * @author ruoyi
+ * @date 2022-03-25
+ */
+public interface ITlPatrolmanService {
+    /**
+     * 查询巡检员
+     *
+     * @param id 巡检员主键
+     * @return 巡检员
+     */
+    public TlPatrolman selectTlPatrolmanById(Long id);
+
+    /**
+     * 查询巡检员列表
+     *
+     * @param tlPatrolman 巡检员
+     * @return 巡检员集合
+     */
+    public List<TlPatrolman> selectTlPatrolmanList(TlPatrolman tlPatrolman);
+
+    /**
+     * 新增巡检员
+     *
+     * @param tlPatrolman 巡检员
+     * @return 结果
+     */
+    public int insertTlPatrolman(TlPatrolman tlPatrolman);
+
+    /**
+     * 修改巡检员
+     *
+     * @param tlPatrolman 巡检员
+     * @return 结果
+     */
+    public int updateTlPatrolman(TlPatrolman tlPatrolman);
+
+    /**
+     * 批量删除巡检员
+     *
+     * @param ids 需要删除的巡检员主键集合
+     * @return 结果
+     */
+    public int deleteTlPatrolmanByIds(Long[] ids);
+
+    /**
+     * 删除巡检员信息
+     *
+     * @param id 巡检员主键
+     * @return 结果
+     */
+    public int deleteTlPatrolmanById(Long id);
+
+    int queryMaxVsersion();
+
+    TlPatrolman queryByThirdId(String thirdId);
+
+    void deletePatrolmanByVersion(int version);
+}

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

@@ -12,7 +12,9 @@ import cn.hutool.json.JSONUtil;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.qdtl.service.IQdCommonService;
+import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
+import com.ruoyi.qdtl.service.ITlPatrolmanService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +43,8 @@ public class QdCommonServiceImpl implements IQdCommonService {
     private String xuncheckpointLogUrl;
     @Value("${third.xuncheckpoint}")
     private String xuncheckpointUrl;
+    @Value("${third.xunpatrolman}")
+    private String xunpatrolmanUrl;
     @Value("${third.xuntrail}")
     private String xuntrailUrl;
 
@@ -48,6 +52,10 @@ public class QdCommonServiceImpl implements IQdCommonService {
     private RedisCache redisCache;
     @Autowired
     private ITlInspectionLocationService tlInspectionLocationService;
+    @Autowired
+    private ITlInspectionDeviceService tlInspectionDeviceService;
+    @Autowired
+    private ITlPatrolmanService tlPatrolmanService;
 
     /**
      * 获取巡检接口的token
@@ -141,6 +149,16 @@ public class QdCommonServiceImpl implements IQdCommonService {
         return null;
     }
 
+    @Override
+    public JSONArray getPatrolman() {
+        String get = HttpRequest.get(xunpatrolmanUrl).header("Authorization", this.getXunToken()).execute().body();
+        JSONObject getJson = JSONUtil.parseObj(get);
+        if (200 == getJson.getInt("code")) {
+            return getJson.getJSONArray("data");
+        }
+        return null;
+    }
+
     /**
      * 查询设备运行轨迹
      *
@@ -167,10 +185,15 @@ public class QdCommonServiceImpl implements IQdCommonService {
         boolean hasKey = redisCache.hasKey(key);
         if (!hasKey) {
             // 查询数据库中最大的
+            int maxVsersion = 0;
             if (key.equals("tl:version:checkpoint")) {
-                int maxVsersion = tlInspectionLocationService.queryMaxVsersion();
-                redisCache.setCacheObject(key, maxVsersion);
+                maxVsersion = tlInspectionLocationService.queryMaxVsersion();
+            } else if (key.equals("tl:version:devicce")) {
+                maxVsersion = tlInspectionDeviceService.queryMaxVsersion();
+            } else if (key.equals("tl:version:patrolman")) {
+                maxVsersion = tlPatrolmanService.queryMaxVsersion();
             }
+            redisCache.setCacheObject(key, maxVsersion);
         }
         return Convert.toInt(redisCache.incr(key, 1));
     }

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

@@ -146,4 +146,9 @@ public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
     public void deleteLocationByVersion(int version) {
         tlInspectionDeviceMapper.deleteLocationByVersion(version);
     }
+
+    @Override
+    public int queryMaxVsersion() {
+        return tlInspectionDeviceMapper.queryMaxVsersion();
+    }
 }

+ 102 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlPatrolmanServiceImpl.java

@@ -0,0 +1,102 @@
+package com.ruoyi.qdtl.service.impl;
+
+import com.ruoyi.qdtl.domain.TlPatrolman;
+import com.ruoyi.qdtl.mapper.TlPatrolmanMapper;
+import com.ruoyi.qdtl.service.ITlPatrolmanService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 巡检员Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-03-25
+ */
+@Service
+public class TlPatrolmanServiceImpl implements ITlPatrolmanService {
+    @Autowired
+    private TlPatrolmanMapper tlPatrolmanMapper;
+
+    /**
+     * 查询巡检员
+     *
+     * @param id 巡检员主键
+     * @return 巡检员
+     */
+    @Override
+    public TlPatrolman selectTlPatrolmanById(Long id) {
+        return tlPatrolmanMapper.selectTlPatrolmanById(id);
+    }
+
+    /**
+     * 查询巡检员列表
+     *
+     * @param tlPatrolman 巡检员
+     * @return 巡检员
+     */
+    @Override
+    public List<TlPatrolman> selectTlPatrolmanList(TlPatrolman tlPatrolman) {
+        return tlPatrolmanMapper.selectTlPatrolmanList(tlPatrolman);
+    }
+
+    /**
+     * 新增巡检员
+     *
+     * @param tlPatrolman 巡检员
+     * @return 结果
+     */
+    @Override
+    public int insertTlPatrolman(TlPatrolman tlPatrolman) {
+        return tlPatrolmanMapper.insertTlPatrolman(tlPatrolman);
+    }
+
+    /**
+     * 修改巡检员
+     *
+     * @param tlPatrolman 巡检员
+     * @return 结果
+     */
+    @Override
+    public int updateTlPatrolman(TlPatrolman tlPatrolman) {
+        return tlPatrolmanMapper.updateTlPatrolman(tlPatrolman);
+    }
+
+    /**
+     * 批量删除巡检员
+     *
+     * @param ids 需要删除的巡检员主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlPatrolmanByIds(Long[] ids) {
+        return tlPatrolmanMapper.deleteTlPatrolmanByIds(ids);
+    }
+
+    /**
+     * 删除巡检员信息
+     *
+     * @param id 巡检员主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTlPatrolmanById(Long id) {
+        return tlPatrolmanMapper.deleteTlPatrolmanById(id);
+    }
+
+    @Override
+    public int queryMaxVsersion() {
+        return tlPatrolmanMapper.queryMaxVsersion();
+    }
+
+    @Override
+    public TlPatrolman queryByThirdId(String thirdId) {
+        return tlPatrolmanMapper.queryByThirdId(thirdId);
+    }
+
+    @Override
+    public void deletePatrolmanByVersion(int version) {
+        tlPatrolmanMapper.deletePatrolmanByVersion(version);
+    }
+}

+ 5 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionDeviceMapper.xml

@@ -78,6 +78,11 @@
         and del_flag = '0'
     </select>
 
+    <select id="queryMaxVsersion" resultType="java.lang.Integer">
+        select ifnull(max(version), 0)
+        from tl_inspection_device
+    </select>
+
     <insert id="insertTlInspectionDevice" parameterType="TlInspectionDevice" useGeneratedKeys="true" keyProperty="id">
         insert into tl_inspection_device
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 100 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlPatrolmanMapper.xml

@@ -0,0 +1,100 @@
+<?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.TlPatrolmanMapper">
+
+    <resultMap type="TlPatrolman" id="TlPatrolmanResult">
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="card" column="card"/>
+        <result property="areaId" column="area_id"/>
+        <result property="areaName" column="area_name"/>
+        <result property="thirdId" column="third_id"/>
+        <result property="version" column="version"/>
+    </resultMap>
+
+    <sql id="selectTlPatrolmanVo">
+        select id, name, card, area_id, area_name, third_id, version
+        from tl_patrolman
+    </sql>
+
+    <select id="selectTlPatrolmanList" parameterType="TlPatrolman" resultMap="TlPatrolmanResult">
+        <include refid="selectTlPatrolmanVo"/>
+        <where>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="card != null  and card != ''">and card = #{card}</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>
+            <if test="thirdId != null  and thirdId != ''">and third_id = #{thirdId}</if>
+            <if test="version != null ">and version = #{version}</if>
+        </where>
+    </select>
+
+    <select id="selectTlPatrolmanById" parameterType="Long" resultMap="TlPatrolmanResult">
+        <include refid="selectTlPatrolmanVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="queryMaxVsersion" resultType="java.lang.Integer">
+        select ifnull(max(version), 0)
+        from tl_patrolman
+    </select>
+
+    <select id="queryByThirdId" resultMap="TlPatrolmanResult">
+        <include refid="selectTlPatrolmanVo"/>
+        where third_id = #{thirdId}
+    </select>
+
+    <insert id="insertTlPatrolman" parameterType="TlPatrolman" useGeneratedKeys="true" keyProperty="id">
+        insert into tl_patrolman
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="name != null">name,</if>
+            <if test="card != null">card,</if>
+            <if test="areaId != null">area_id,</if>
+            <if test="areaName != null">area_name,</if>
+            <if test="thirdId != null">third_id,</if>
+            <if test="version != null">version,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="name != null">#{name},</if>
+            <if test="card != null">#{card},</if>
+            <if test="areaId != null">#{areaId},</if>
+            <if test="areaName != null">#{areaName},</if>
+            <if test="thirdId != null">#{thirdId},</if>
+            <if test="version != null">#{version},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTlPatrolman" parameterType="TlPatrolman">
+        update tl_patrolman
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="name != null">name = #{name},</if>
+            <if test="card != null">card = #{card},</if>
+            <if test="areaId != null">area_id = #{areaId},</if>
+            <if test="areaName != null">area_name = #{areaName},</if>
+            <if test="thirdId != null">third_id = #{thirdId},</if>
+            <if test="version != null">version = #{version},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteTlPatrolmanById" parameterType="Long">
+        delete
+        from tl_patrolman
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteTlPatrolmanByIds" parameterType="String">
+        delete from tl_patrolman where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <delete id="deletePatrolmanByVersion">
+        delete
+        from tl_patrolman
+        where version != #{version}
+    </delete>
+</mapper>