Selaa lähdekoodia

修复 不同租户可以添加同一台设备的问题

zhaiyifei 9 kuukautta sitten
vanhempi
commit
d97d4145e7

+ 3 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotDeviceServiceImpl.java

@@ -265,11 +265,12 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
      * 查询设备基础列表
      * 查询设备基础列表
      *
      *
      * @param iotDevice 设备基础
      * @param iotDevice 设备基础
+     * @param isTid 是否查询租户ID,true查询当前租户下的设备,false 查询全局所有设备
      * @return 设备基础
      * @return 设备基础
      */
      */
     public List<IotDevice> selectIotDeviceList(IotDevice iotDevice, boolean isTid) {
     public List<IotDevice> selectIotDeviceList(IotDevice iotDevice, boolean isTid) {
         // 生产环境
         // 生产环境
-        if ("0".equals(runMode) && !isTid) {
+        if (!isTid) {
             iotDevice.setTid(null);
             iotDevice.setTid(null);
         } else {
         } else {
             iotDevice.setTid(SecurityUtils.getTid());
             iotDevice.setTid(SecurityUtils.getTid());
@@ -383,6 +384,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
         List<String> devtypeBidList = IotMqttConstant.getDevtypeBidList(devtypeBid);
         List<String> devtypeBidList = IotMqttConstant.getDevtypeBidList(devtypeBid);
         IotDevice selectIotDevice = new IotDevice();
         IotDevice selectIotDevice = new IotDevice();
         selectIotDevice.setDevtypeBidList(devtypeBidList);
         selectIotDevice.setDevtypeBidList(devtypeBidList);
+        selectIotDevice.setDevCodeList(Arrays.asList(devCode));
         List<IotDevice> iotDeviceList = selectIotDeviceList(selectIotDevice, false);
         List<IotDevice> iotDeviceList = selectIotDeviceList(selectIotDevice, false);
 
 
         Set<String> newDevCodeSet = new HashSet<>(Arrays.asList(devCode));
         Set<String> newDevCodeSet = new HashSet<>(Arrays.asList(devCode));

+ 7 - 0
src/main/resources/mapper/IotDeviceMapper.xml

@@ -115,6 +115,13 @@
                 </foreach>
                 </foreach>
             </if>
             </if>
 
 
+            <if test="devCodeList != null  and devCodeList.size() > 0">
+                and d.devCode in
+                <foreach collection="devCodeList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+
         </where>
         </where>
     </select>
     </select>