Bläddra i källkod

2023-10-27 气瓶入库,查询过滤绑定蓝牙网关的实验室列表。

chaiyunlong 2 år sedan
förälder
incheckning
0ced8a91cf

+ 6 - 0
zd-api/zd-airbottle-api/src/main/java/com/zd/airbottle/api/feign/RemoteAirBottleService.java

@@ -52,6 +52,12 @@ public interface RemoteAirBottleService {
     /**
      * 根据实验室id查询信标列表
      */
+    @GetMapping(value = "/bluetooth/getBluetoothBySubIds")
+    ResultData<List <Map<String,Object>>> getBluetoothBySubIds(@RequestParam("subIds") Long[] subIds);
+
+    /**
+     * 根据实验室id查询信标列表
+     */
     @GetMapping(value = "/stock/findBySubId")
     ResultData<List <Map<String,Object>>> findBySubId(@RequestParam("subId") Long subId);
 

+ 5 - 0
zd-api/zd-airbottle-api/src/main/java/com/zd/airbottle/api/feign/fallback/RemoteAirBottleFallbackFactory.java

@@ -49,6 +49,11 @@ public class RemoteAirBottleFallbackFactory implements FallbackFactory<RemoteAir
             }
 
             @Override
+            public ResultData <List <Map <String, Object>>> getBluetoothBySubIds(Long[] subIds) {
+                return ResultData.fail("获取蓝牙网关列表失败"+throwable.getMessage());
+            }
+
+            @Override
             public ResultData <List <Map <String, Object>>> findBySubId(Long subId) {
                 return ResultData.fail("获取信标列表失败"+throwable.getMessage());
             }

+ 9 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/DbBluetoothGatewayController.java

@@ -180,6 +180,15 @@ public class DbBluetoothGatewayController extends BaseController {
         return ResultData.success(list);
     }
 
+    /**
+     * 获取蓝牙网关信息
+     */
+    @ApiOperation(value = "获取蓝牙网关信息")
+    @GetMapping(value = "/getBluetoothBySubIds")
+    public ResultData getBluetoothBySubIds(Long[] subIds) {
+        List <DbBluetoothGateway> list = dbBluetoothGatewayService.getBluetoothBySubIds(subIds);
+        return ResultData.success(list);
+    }
 
 
     /**

+ 8 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/mapper/DbBluetoothGatewayMapper.java

@@ -21,6 +21,14 @@ public interface DbBluetoothGatewayMapper {
     List <DbBluetoothGateway> selectDbBluetoothGatewayList(DbBluetoothGateway dbBluetoothGateway);
 
     /**
+     * 查询蓝牙网关列表
+     *
+     * @param subIds 实验室ids
+     * @return 蓝牙网关集合
+     */
+    List <DbBluetoothGateway> getBluetoothBySubIds(Long[] subIds);
+
+    /**
      * 查询蓝牙网关信息
      *
      * @param id 蓝牙网关id

+ 8 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/DbBluetoothGatewayService.java

@@ -19,6 +19,14 @@ public interface DbBluetoothGatewayService {
     List <DbBluetoothGateway> selectDbBluetoothGatewayList(DbBluetoothGateway dbBluetoothGateway);
 
     /**
+     * 查询蓝牙网关列表
+     *
+     * @param subIds 实验室ids
+     * @return 蓝牙网关集合
+     */
+    List <DbBluetoothGateway> getBluetoothBySubIds(Long[] subIds);
+
+    /**
      * 查询蓝牙网关信息
      *
      * @param id 蓝牙网关id

+ 5 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/DbBluetoothGatewayServiceImpl.java

@@ -35,6 +35,11 @@ public class DbBluetoothGatewayServiceImpl implements DbBluetoothGatewayService
     }
 
     @Override
+    public List <DbBluetoothGateway> getBluetoothBySubIds(Long[] subIds) {
+        return dbBluetoothGatewayMapper.getBluetoothBySubIds(subIds);
+    }
+
+    @Override
     public DbBluetoothGateway selectDbBluetoothGatewayById(Long id) {
         return dbBluetoothGatewayMapper.selectDbBluetoothGatewayById(id);
     }

+ 10 - 0
zd-modules/zd-airbottle/src/main/resources/mapper/airbottle/DbBluetoothGatewayMapper.xml

@@ -47,6 +47,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="getBluetoothBySubIds" resultMap="DbBluetoothGatewayResult">
+        select distinct sub_id, sub_name from db_bluetooth_gateway
+        <where>
+            sub_id in
+            <foreach item="id" collection="array" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
 
     <select id="selectDbBluetoothGatewayById" resultMap="DbBluetoothGatewayResult">
         <include refid="selectDbBluetoothGatewayVo"/>

+ 28 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectController.java

@@ -1,6 +1,7 @@
 package com.zd.laboratory.controller;
 
 import cn.hutool.core.util.StrUtil;
+import com.zd.airbottle.api.feign.RemoteAirBottleService;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.model.domain.DTO.UserPhoneInfo;
 import com.zd.common.core.annotation.Log;
@@ -40,10 +41,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 
@@ -87,6 +85,9 @@ public class LabSubjectController extends BaseController {
     @Autowired
     RedisService redisService;
 
+    @Autowired
+    private RemoteAirBottleService remoteAirBottleService;
+
 
 
     /**
@@ -144,6 +145,29 @@ public class LabSubjectController extends BaseController {
         return ResultData.success(list);
     }
 
+    @GetMapping("/list/subJoinbeacon")
+    public ResultData subJoinbeacon(LabSubject labSubject) {
+        //获取当前登录用户所属学校和学院的deptid
+        R<List<Long>> listdeptids = remoteUserService.getLogingUserDeptids();
+        List<Long> deptIds= listdeptids.getData();
+        labSubject.setDeptIds(deptIds);
+        List<LabSubject> list = labSubjectService.selectLabSubjectListByadminidNotnull(labSubject);
+        Long[] subIds = list.stream().map(a -> a.getId()).toArray(Long[]::new);
+        ResultData<List <Map<String,Object>>> resultData = remoteAirBottleService.getBluetoothBySubIds(subIds);
+        List<LabSubject> allList = new ArrayList <>();
+        if(resultData.getCode()==200 && resultData.getData().size()>0){
+            for(LabSubject subject:list){
+                for(Map<String,Object> map:resultData.getData()){
+                    Long subId = Long.parseLong(map.get("subId")+"");
+                    if(subject.getId().longValue()==subId.longValue()){
+                        allList.add(subject);
+                    }
+                }
+            }
+        }
+        return ResultData.success(allList);
+    }
+
     @GetMapping("/list/listSubAdmin")
     public ResultData listSubAdmin(LabSubject labSubject) {
         List<LabSubject> list = labSubjectService.selectLabSubjectListByadminidNotnull(labSubject);