From cae58d56278ba46dd180e53acecd28b0bdab34e8 Mon Sep 17 00:00:00 2001
From: lius <Lius2225@163.com>
Date: 星期三, 02 八月 2023 14:35:27 +0800
Subject: [PATCH] 根据部门查询一个设备

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java    |   16 ++++++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java |   12 ++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java         |    5 +++++
 3 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
index 36a2173..b3bcf11 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
@@ -453,4 +453,20 @@
         MdcEquipment mdcEquipment = mdcEquipmentService.getEquipmentByPid(pid, userId);
         return Result.OK(mdcEquipment);
     }
+
+    /**
+     * 鏍规嵁閮ㄩ棬灞傜骇鏌ヨ鍗曚釜璁惧
+     *
+     * @param pid
+     * @return
+     */
+    @AutoLog(value = "璁惧琛�-鏍规嵁閮ㄩ棬灞傜骇鏌ヨ鍗曚釜璁惧")
+    @ApiOperation(value = "璁惧琛�-鏍规嵁閮ㄩ棬灞傜骇鏌ヨ鍗曚釜璁惧", notes = "璁惧琛�-鏍规嵁閮ㄩ棬灞傜骇鏌ヨ鍗曚釜璁惧")
+    @GetMapping("/getEquipmentByDepPid")
+    public Result<MdcEquipment> getEquipmentByDepPid(@RequestParam(name = "pid", required = false) String pid) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = user.getId();
+        MdcEquipment mdcEquipment = mdcEquipmentService.getEquipmentByDepPid(pid, userId);
+        return Result.OK(mdcEquipment);
+    }
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
index e57d140..d70061b 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
@@ -157,4 +157,9 @@
      * @return
      */
     List<MdcEquProDto> findEquProList(List<String> equipmentIdList);
+
+    /**
+     * 鏍规嵁閮ㄩ棬灞傜骇鏌ヨ璁惧鍗曚釜
+     */
+    MdcEquipment getEquipmentByDepPid(String pid, String userId);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
index 45cca50..cfcd078 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -669,4 +669,16 @@
         return this.baseMapper.findEquProList(equipmentIdList);
     }
 
+    /**
+     * 鏍规嵁閮ㄩ棬灞傜骇鏌ヨ璁惧鍗曚釜
+     */
+    @Override
+    public MdcEquipment getEquipmentByDepPid(String pid, String userId) {
+        List<String> idsByDepart = this.getEquipmentIdsByDepart(userId, pid);
+        if (idsByDepart != null && !idsByDepart.isEmpty()) {
+            return super.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, idsByDepart.get(0)));
+        }
+        return null;
+    }
+
 }

--
Gitblit v1.9.3