Selaa lähdekoodia

查询监测点的设备信息列表

459242451@qq.com 3 vuotta sitten
vanhempi
commit
9653c78c57

+ 2 - 0
README.md

@@ -35,6 +35,8 @@
 17. 在线构建器:拖动表单元素生成相应的HTML代码。
 18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
 
+>  打包:mvn clean package -DskipTests -DsendCredentialsOverHttp=true
+
 ## 需求
 ### 区域管理
 > 1.新增页面:区域类型、编号、名称、描述、范围(类型为1,4时显示)、点位(类型为2,3时显示)、备注

+ 3 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionDeviceController.java

@@ -96,9 +96,9 @@ public class TlInspectionDeviceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('qdtl:device:remove')")
     @Log(title = "巡检设备管理", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
+	@DeleteMapping("/{id}")
+    public AjaxResult remove(@PathVariable Long id)
     {
-        return toAjax(tlInspectionDeviceService.deleteTlInspectionDeviceByIds(ids));
+        return toAjax(tlInspectionDeviceService.deleteTlInspectionDeviceById(id));
     }
 }

+ 22 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionLocationController.java

@@ -1,7 +1,13 @@
 package com.ruoyi.web.controller.qdtl;
 
+import java.util.ArrayList;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.StrUtil;
+import com.ruoyi.qdtl.domain.TlInspectionDevice;
+import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -33,6 +39,8 @@ public class TlInspectionLocationController extends BaseController
 {
     @Autowired
     private ITlInspectionLocationService tlInspectionLocationService;
+    @Autowired
+    private ITlInspectionDeviceService tlInspectionDeviceService;
 
     /**
      * 查询巡检点管理列表
@@ -43,6 +51,20 @@ public class TlInspectionLocationController extends BaseController
     {
         startPage();
         List<TlInspectionLocation> list = tlInspectionLocationService.selectTlInspectionLocationList(tlInspectionLocation);
+
+        for (TlInspectionLocation inspectionLocation : list) {
+            List<TlInspectionDevice> devices = new ArrayList<>();
+            if (StrUtil.isNotBlank(inspectionLocation.getDeviceIds())) {
+                for (String s : inspectionLocation.getDeviceIds().split(",")) {
+                    // 查询设备id所对应的名称
+                    TlInspectionDevice tlInspectionDevice = tlInspectionDeviceService.selectTlInspectionDeviceById(Convert.toLong(s));
+                    if (tlInspectionDevice != null) {
+                        devices.add(tlInspectionDevice);
+                    }
+                }
+            }
+            inspectionLocation.setDeviceNames(devices);
+        }
         return getDataTable(list);
     }
 

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionLocation.java

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import java.util.List;
+
 /**
  * 巡检点管理对象 tl_inspection_location
  * 
@@ -34,6 +36,8 @@ public class TlInspectionLocation extends BaseEntity
     @Excel(name = "巡检设备")
     private String deviceIds;
 
+    private List<TlInspectionDevice> deviceNames;
+
     /** 所属区域 */
     @Excel(name = "所属区域")
     private Long areaId;
@@ -135,4 +139,12 @@ public class TlInspectionLocation extends BaseEntity
             .append("updateTime", getUpdateTime())
             .toString();
     }
+
+    public List<TlInspectionDevice> getDeviceNames() {
+        return deviceNames;
+    }
+
+    public void setDeviceNames(List<TlInspectionDevice> deviceNames) {
+        this.deviceNames = deviceNames;
+    }
 }

+ 31 - 24
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionDeviceServiceImpl.java

@@ -4,11 +4,14 @@ 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;
@@ -16,49 +19,53 @@ import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 
 /**
  * 巡检设备管理Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
 @Service
-public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService 
-{
+public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService {
     @Autowired
     private TlInspectionDeviceMapper tlInspectionDeviceMapper;
+    @Autowired
+    private RedisCache redisCache;
 
     /**
      * 查询巡检设备管理
-     * 
+     *
      * @param id 巡检设备管理主键
      * @return 巡检设备管理
      */
     @Override
-    public TlInspectionDevice selectTlInspectionDeviceById(Long id)
-    {
-        return tlInspectionDeviceMapper.selectTlInspectionDeviceById(id);
+    public TlInspectionDevice selectTlInspectionDeviceById(Long id) {
+        TlInspectionDevice cacheObject = redisCache.getCacheObject("tl:device:info:" + id);
+        if (cacheObject != null) {
+            return cacheObject;
+        }
+        TlInspectionDevice tlInspectionDevice = tlInspectionDeviceMapper.selectTlInspectionDeviceById(id);
+        redisCache.setCacheObject("tl:device:info:" + id, tlInspectionDevice);
+        return tlInspectionDevice;
     }
 
     /**
      * 查询巡检设备管理列表
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 巡检设备管理
      */
     @Override
-    public List<TlInspectionDevice> selectTlInspectionDeviceList(TlInspectionDevice tlInspectionDevice)
-    {
+    public List<TlInspectionDevice> selectTlInspectionDeviceList(TlInspectionDevice tlInspectionDevice) {
         return tlInspectionDeviceMapper.selectTlInspectionDeviceList(tlInspectionDevice);
     }
 
     /**
      * 新增巡检设备管理
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 结果
      */
     @Override
-    public int insertTlInspectionDevice(TlInspectionDevice tlInspectionDevice)
-    {
+    public int insertTlInspectionDevice(TlInspectionDevice tlInspectionDevice) {
         tlInspectionDevice.setCreateTime(DateUtils.getNowDate());
         // 控制编号和名称不能重复
         int count = tlInspectionDeviceMapper.selectExist(tlInspectionDevice);
@@ -70,13 +77,12 @@ public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
 
     /**
      * 修改巡检设备管理
-     * 
+     *
      * @param tlInspectionDevice 巡检设备管理
      * @return 结果
      */
     @Override
-    public int updateTlInspectionDevice(TlInspectionDevice tlInspectionDevice)
-    {
+    public int updateTlInspectionDevice(TlInspectionDevice tlInspectionDevice) {
         tlInspectionDevice.setUpdateTime(DateUtils.getNowDate());
         // 查询原有的数据
         TlInspectionDevice old = selectTlInspectionDeviceById(tlInspectionDevice.getId());
@@ -100,35 +106,36 @@ public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
                 }
             }
         }
-        return tlInspectionDeviceMapper.updateTlInspectionDevice(tlInspectionDevice);
+        int i = tlInspectionDeviceMapper.updateTlInspectionDevice(tlInspectionDevice);
+        redisCache.deleteObject("tl:device:info:" + tlInspectionDevice.getId());
+        return i;
     }
 
     /**
      * 批量删除巡检设备管理
-     * 
+     *
      * @param ids 需要删除的巡检设备管理主键
      * @return 结果
      */
     @Override
-    public int deleteTlInspectionDeviceByIds(Long[] ids)
-    {
+    public int deleteTlInspectionDeviceByIds(Long[] ids) {
         return tlInspectionDeviceMapper.deleteTlInspectionDeviceByIds(ids);
     }
 
     /**
      * 删除巡检设备管理信息
-     * 
+     *
      * @param id 巡检设备管理主键
      * @return 结果
      */
     @Override
-    public int deleteTlInspectionDeviceById(Long id)
-    {
+    public int deleteTlInspectionDeviceById(Long id) {
+        redisCache.deleteObject("tl:device:info:" + id);
         return tlInspectionDeviceMapper.deleteTlInspectionDeviceById(id);
     }
 
     @Override
-    public Map<String,Integer> queryDeviceByArea() {
+    public Map<String, Integer> queryDeviceByArea() {
         List<JSONObject> jsonObjects = tlInspectionDeviceMapper.queryDeviceByArea();
         return jsonObjects.stream().collect(Collectors.toMap(a -> a.getString("areaId"), b -> b.getInteger("cnt")));
     }