浏览代码

bug修改 代码提交

jingyuanchao 1 年之前
父节点
当前提交
d5d976d968

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/ProtectionMapper.java

@@ -24,6 +24,8 @@ public interface ProtectionMapper extends BaseMapper<IotAlarmSubsystem> {
     String getHostName(String hostCode);
 
     void updateInBookStatus(@Param("orgId") Long orgId, @Param("id") Long id);
+
+    int checkExitDevice(@Param("orgId") Long orgId, @Param("deviceId") Long deviceId);
 //    MePage<pageSensorVo> pageSensorList(@Param("mePage") MePage<pageSensorVo> mePage, @Param("request") pageSensorDto request);
 //
 //    MePage<ProtectionPageVo4Mybatis> pageByMybatis(@Param("request") ProtectionPageDto4Mybatis request, MePage<ProtectionPageVo4Mybatis> mePage);

+ 14 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/ProtectionServiceImpl.java

@@ -296,13 +296,25 @@ public class ProtectionServiceImpl extends ServiceImpl<ProtectionMapper, IotAlar
 
     @Override
     public int checkExitDevice(Long orgId, Long deviceId) {
-        return lambdaQuery()
+       /*  LambdaQueryWrapper<IotAlarmSubsystem> wrapper=new LambdaQueryWrapper<>();
+        wrapper.eq(IotAlarmSubsystem::getOrgId,orgId);
+        wrapper.eq(IotAlarmSubsystem::getDeleted,0);
+        final List<IotAlarmSubsystem> subsystemList = baseMapper.selectList(wrapper);
+        if (subsystemList.isEmpty()){
+            return 0;
+        }
+        final boolean match = subsystemList.stream().anyMatch(r -> ObjectUtil.equal(r.getSource(), 1));
+        if (!match){
+            return 1;
+        }
+       return lambdaQuery()
                 .eq(IotAlarmSubsystem::getOrgId, orgId)
                 .ne(ObjectUtil.isNotNull(deviceId), IotAlarmSubsystem::getDeviceId, deviceId)
                 .eq(IotAlarmSubsystem::getSource, 1)
                 .eq(IotAlarmSubsystem::getDeleted, 0)
                 .count()
-                .intValue();
+                .intValue();*/
+        return  baseMapper.checkExitDevice(orgId,deviceId);
     }
 
     @Override

+ 12 - 0
soc-modules/soc-modules-core/src/main/resources/mapper/device/ProtectionMapper.xml

@@ -59,6 +59,18 @@
     <update id="updateInBookStatus">
         update iot_alarm_subsystem set in_book=0 where org_id=#{orgId}  and id != #{id}
     </update>
+
+    <select id="checkExitDevice" resultType="int">
+        SELECT count(1)
+        FROM iot_alarm_subsystem
+        WHERE
+        org_id = #{orgId}
+        <if test="deviceId != null">
+            AND (device_id != #{deviceId} OR device_id IS NULL)
+        </if>
+        AND source = 1
+        AND deleted = 0
+    </select>
     <!--    <select id="pageLog" resultType="com.xunmei.core.resumption.vo.protection.ProtectionLogPageVo">-->
     <!--        select a.id, a.name as name,a.status as status,a.status_update_time,a.status_updator_name-->
     <!--        from iot_alarm_subsystem_log a-->