物联设备释放区域绑定

This commit is contained in:
曹磊 2026-03-12 10:09:19 +08:00
parent e189f707a6
commit b5c7172dbc
5 changed files with 104 additions and 0 deletions

View File

@ -20,5 +20,9 @@ public interface IotDeviceInfoMapper extends BaseMapper<IotDeviceInfo> {
void unbindElectricity(IotDeviceInfo iotDeviceInfo);
void unbindWater(IotDeviceInfo iotDeviceInfo);
void unbindHumid(IotDeviceInfo iotDeviceInfo);
void releaseTplink(IotDeviceInfo iotDeviceInfo);
void releaseElectricity(IotDeviceInfo iotDeviceInfo);
void releaseWater(IotDeviceInfo iotDeviceInfo);
void releaseHumid(IotDeviceInfo iotDeviceInfo);
}

View File

@ -293,6 +293,9 @@
from sys_depart a
inner join nu_iot_tplink_camera b on a.id = b.depart_id
where a.org_code = #{orgCode}
<if test="nuId != null and nuId != ''">
AND b.nu_id = #{nuId}
</if>
union all
select
a.id as departId,
@ -304,6 +307,9 @@
from sys_depart a
inner join nu_iot_ds_electricity_meter b on a.id = b.depart_id
where a.org_code = #{orgCode}
<if test="nuId != null and nuId != ''">
AND b.nu_id = #{nuId}
</if>
union all
select
a.id as departId,
@ -316,6 +322,9 @@
inner join nu_iot_tq_water_meter b on a.id = b.depart_id
inner join nu_iot_tq_collector c on c.cid = b.cid
where a.org_code = #{orgCode}
<if test="nuId != null and nuId != ''">
AND b.nu_id = #{nuId}
</if>
union all
select
a.id as departId,
@ -327,6 +336,9 @@
from sys_depart a
inner join nu_iot_yiweilian_humid_device b on a.id = b.depart_id
where a.org_code = #{orgCode}
<if test="nuId != null and nuId != ''">
AND b.nu_id = #{nuId}
</if>
</select>
<update id="bindTplink">
@ -409,4 +421,36 @@
where sn = #{sn}
</update>
<update id="releaseTplink">
update nu_iot_tplink_camera
set
nu_id = null,
nu_name = null
where device_index = #{sn}
</update>
<update id="releaseElectricity">
update nu_iot_ds_electricity_meter
set
nu_id = null,
nu_name = null
where sn = #{sn}
</update>
<update id="releaseWater">
update nu_iot_tq_water_meter
set
nu_id = null,
nu_name = null
where cid = #{sn}
</update>
<update id="releaseHumid">
update nu_iot_yiweilian_humid_device
set
nu_id = null,
nu_name = null
where sn = #{sn}
</update>
</mapper>

View File

@ -17,4 +17,5 @@ public interface IIotDeviceInfoService extends IService<IotDeviceInfo> {
IPage<IotDeviceInfo> findCanAddDevicePage(Page<IotDeviceInfo> page, IotDeviceInfo iotDeviceInfo);
Result<String> addBatch(IotDeviceInfo iotDeviceInfo);
Result<String> unbindOrg(IotDeviceInfo iotDeviceInfo);
Result<String> releaseNu(IotDeviceInfo iotDeviceInfo);
}

View File

@ -111,4 +111,36 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
}
return Result.OK("解绑设备成功");
}
@Override
@Transactional
public Result<String> releaseNu(IotDeviceInfo iotDeviceInfo){
List<IotDeviceInfo> list = baseMapper.findOrgDeviceList(iotDeviceInfo);
for(int i=0;i<list.size();i++){
IotDeviceInfo idi = list.get(i);
if(idi.getDeviceCategory().equals("tplink")){
baseMapper.releaseTplink(idi);
}
if(idi.getDeviceCategory().equals("electricity")){
baseMapper.releaseElectricity(idi);
}
if(idi.getDeviceCategory().equals("water")){
baseMapper.releaseWater(idi);
}
if(idi.getDeviceCategory().equals("humid")){
baseMapper.releaseHumid(idi);
}
IotDeviceLog log = new IotDeviceLog();
log.setOptType("释放");
log.setDeviceId(idi.getSn());
log.setDeviceType(idi.getDeviceType());
log.setNuId(idi.getNuId());
log.setOrgCode(idi.getOrgCode());
log.setRemark(idi.getNuId()+"区域释放");
log.setUpdateDate(new Date());
logService.addLog(log);
}
return Result.OK("释放设备成功");
}
}

View File

@ -1,7 +1,10 @@
package com.nu.mq.device.listener;
import com.nu.dto.IotNuBaseInfoMQDto;
import com.nu.dto.StatusListMQDto;
import com.nu.dto.StatusMQDto;
import com.nu.modules.manager.entity.IotDeviceInfo;
import com.nu.modules.manager.service.IIotDeviceInfoService;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
import com.nu.modules.syncLog.entity.SyncBizLog;
@ -57,6 +60,9 @@ public class IotDeviceMQListener {
@Autowired
private IHumidDeviceService humidDeviceService;
@Autowired
private IIotDeviceInfoService iotDeviceInfoService;
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "iotsyncbiz.async.result", durable = "true"),
@ -128,4 +134,21 @@ public class IotDeviceMQListener {
}
}
}
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "hldy.iotDeviceRelease.result.async", durable = "true"),
exchange = @Exchange(name = "hldy.iotDeviceRelease", type = ExchangeTypes.DIRECT),
key = "hldy.iotDeviceRelease.result.async"
),
errorHandler = "iotDeviceMQErrorHandler"
)
public void releaseNuDevices(IotNuBaseInfoMQDto dto) {
String orgCode = dto.getOrgCode();
String nuId = dto.getNuId();
IotDeviceInfo idi = new IotDeviceInfo();
idi.setNuId(nuId);
idi.setOrgCode(orgCode);
iotDeviceInfoService.releaseNu(idi);
}
}