物联设备集成、管理、维护字段优化
This commit is contained in:
parent
d0a8fb3d82
commit
3ec7061575
|
|
@ -13,10 +13,6 @@ public class IotElectricityMeterMQDto{
|
|||
/**主键*/
|
||||
private Integer id;
|
||||
private String sn;
|
||||
/**采集器*/
|
||||
private String cid;
|
||||
/**表号*/
|
||||
private String address;
|
||||
/**电表值*/
|
||||
private String eleValue;
|
||||
/**阀门状态*/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
select
|
||||
a.nu_name as nuName,
|
||||
a.nu_id as nuId,
|
||||
b.mac as sn,
|
||||
replace(b.mac,'-','') as sn,
|
||||
b.dimension,
|
||||
(
|
||||
case b.device_type
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
<select id="findCanAddDevicePage" parameterType="com.nu.modules.manager.entity.IotDeviceInfo" resultType="com.nu.modules.manager.entity.IotDeviceInfo">
|
||||
select
|
||||
b.mac as id,
|
||||
b.mac as sn,
|
||||
replace(b.mac,'-','') as sn,
|
||||
b.dimension,
|
||||
( case b.device_type
|
||||
when 'SURVEILLANCECAMERA' then '摄像头'
|
||||
|
|
@ -279,7 +279,7 @@
|
|||
a.id as departId,
|
||||
a.org_code,
|
||||
b.nu_id as nuId,
|
||||
b.mac as sn,
|
||||
replace(b.mac,'-','') as sn,
|
||||
(
|
||||
case b.device_type
|
||||
when 'SURVEILLANCECAMERA' then '摄像头'
|
||||
|
|
@ -347,7 +347,7 @@
|
|||
nu_id = #{nuId},
|
||||
depart_id = #{departId},
|
||||
iz_allocate = 'Y'
|
||||
where mac = #{sn}
|
||||
where replace(mac,'-','') = #{sn}
|
||||
</update>
|
||||
|
||||
<update id="bindElectricity">
|
||||
|
|
@ -386,7 +386,7 @@
|
|||
depart_name = null,
|
||||
iz_allocate = 'N',
|
||||
maintain_status = 1
|
||||
where mac = #{sn}
|
||||
where replace(mac,'-','') = #{sn}
|
||||
</update>
|
||||
|
||||
<update id="unbindElectricity">
|
||||
|
|
@ -430,7 +430,7 @@
|
|||
set
|
||||
nu_id = null,
|
||||
nu_name = null
|
||||
where mac = #{sn}
|
||||
where replace(mac,'-','') = #{sn}
|
||||
</update>
|
||||
|
||||
<update id="releaseElectricity">
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.nu.modules.manager.entity.IotDeviceLog;
|
|||
import com.nu.modules.manager.mapper.IotDeviceInfoMapper;
|
||||
import com.nu.modules.manager.service.IIotDeviceInfoService;
|
||||
import com.nu.modules.manager.service.IIotDeviceLogService;
|
||||
import com.nu.modules.syncbiz.service.ISyncBizService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -30,6 +31,9 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|||
@Autowired
|
||||
IIotDeviceLogService logService;
|
||||
|
||||
@Autowired
|
||||
ISyncBizService syncBizService;
|
||||
|
||||
@Override
|
||||
public IPage<IotDeviceInfo> findPage(Page<IotDeviceInfo> page, IotDeviceInfo iotDeviceInfo){
|
||||
return baseMapper.findPage(page,iotDeviceInfo);
|
||||
|
|
@ -77,6 +81,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|||
log.setUpdateDate(new Date());
|
||||
logService.addLog(log);
|
||||
}
|
||||
syncBizService.syncIot(nuId);//mq同步设备
|
||||
return Result.OK("绑定设备成功");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 水表
|
||||
* @Description: 电表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
|
|
@ -17,10 +17,8 @@ public class ElectricityMeter implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
/**主键*/
|
||||
private Integer id;
|
||||
/**采集器*/
|
||||
private String cid;
|
||||
/**表号*/
|
||||
private String address;
|
||||
private String sn;
|
||||
/**电表值*/
|
||||
private String eleValue;
|
||||
/**阀门状态*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nu.modules.syncbiz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.dingshuo.electricity.entity.DsElectricityMeter;
|
||||
import com.nu.modules.syncbiz.entity.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -87,11 +87,30 @@
|
|||
order by a.id asc
|
||||
</select>
|
||||
|
||||
<!-- <select id="getElectricityMeterListByNuId" parameterType="String" resultType="com.nu.modules.syncbiz.entity.ElectricityMeter">-->
|
||||
<!-- select-->
|
||||
<!-- id,-->
|
||||
<!-- cid,-->
|
||||
<!-- address,-->
|
||||
<!-- ele_value as eleValue,-->
|
||||
<!-- relay_state as relayState,-->
|
||||
<!-- remark,-->
|
||||
<!-- nu_id as nuId,-->
|
||||
<!-- nu_name as nuName,-->
|
||||
<!-- depart_id as departId,-->
|
||||
<!-- depart_name as departName,-->
|
||||
<!-- depart_server_url as departServerUrl,-->
|
||||
<!-- sync_type as syncType,-->
|
||||
<!-- maintain_status as maintainStatus-->
|
||||
<!-- from nu_iot_tq_electricity_meter-->
|
||||
<!-- where nu_id = #{nuId}-->
|
||||
<!-- order by id asc-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="getElectricityMeterListByNuId" parameterType="String" resultType="com.nu.modules.syncbiz.entity.ElectricityMeter">
|
||||
select
|
||||
id,
|
||||
cid,
|
||||
address,
|
||||
sn,
|
||||
ele_value as eleValue,
|
||||
relay_state as relayState,
|
||||
remark,
|
||||
|
|
@ -102,7 +121,7 @@
|
|||
depart_server_url as departServerUrl,
|
||||
sync_type as syncType,
|
||||
maintain_status as maintainStatus
|
||||
from nu_iot_tq_electricity_meter
|
||||
from nu_iot_ds_electricity_meter
|
||||
where nu_id = #{nuId}
|
||||
order by id asc
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.dto.*;
|
||||
import com.nu.modules.dingshuo.electricity.entity.DsElectricityMeter;
|
||||
import com.nu.modules.syncLog.entity.SyncBizLog;
|
||||
import com.nu.modules.syncLog.service.ISyncBizLogService;
|
||||
import com.nu.modules.syncbiz.entity.*;
|
||||
|
|
@ -41,16 +42,16 @@ public class SyncBizServiceImpl extends ServiceImpl<SyncBizMapper, NuBaseInfo> i
|
|||
IotSyncBizMQDto dto = new IotSyncBizMQDto();
|
||||
String orgCode = nuBaseInfo.getOrgCode();
|
||||
String orgName = nuBaseInfo.getOrgName();
|
||||
String type = "更新";
|
||||
if(nuBaseInfo.getIzSync().equals("N")){
|
||||
type = "新增";
|
||||
}
|
||||
String logId = addLog(orgCode,orgName, JSON.toJSONString(nuBaseInfo),type,"区域");
|
||||
nuBaseInfo.setLogId(logId);
|
||||
IotNuBaseInfoMQDto iotNuBaseInfoMQDto = new IotNuBaseInfoMQDto();
|
||||
BeanUtils.copyProperties(nuBaseInfo,iotNuBaseInfoMQDto);
|
||||
// String type = "更新";
|
||||
// if(nuBaseInfo.getIzSync().equals("N")){
|
||||
// type = "新增";
|
||||
// }
|
||||
// String logId = addLog(orgCode,orgName, JSON.toJSONString(nuBaseInfo),type,"区域");
|
||||
// nuBaseInfo.setLogId(logId);
|
||||
// IotNuBaseInfoMQDto iotNuBaseInfoMQDto = new IotNuBaseInfoMQDto();
|
||||
// BeanUtils.copyProperties(nuBaseInfo,iotNuBaseInfoMQDto);
|
||||
//将区域信息存放到MQ类中
|
||||
dto.setNuBaseInfo(iotNuBaseInfoMQDto);
|
||||
// dto.setNuBaseInfo(iotNuBaseInfoMQDto);
|
||||
|
||||
//通过nuId获取摄像头列表
|
||||
List<CameraInfo> cameraList = baseMapper.getCameraListByNuId(nuId);
|
||||
|
|
@ -61,7 +62,7 @@ public class SyncBizServiceImpl extends ServiceImpl<SyncBizMapper, NuBaseInfo> i
|
|||
if(entity.getSyncType().equals("N")){
|
||||
actionType = "新增";
|
||||
}
|
||||
String resId = addLog(orgCode,orgName, JSON.toJSONString(entity),actionType,"摄像头");
|
||||
String resId = addLog(orgCode,orgName, JSON.toJSONString(entity),actionType,"TPLINK");
|
||||
entity.setLogId(resId);
|
||||
}
|
||||
List<IotCameraInfoMQDto> cameraMQDtoList = BeanUtil.copyToList(cameraList, IotCameraInfoMQDto.class);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -102,7 +102,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -151,7 +151,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -358,7 +358,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -416,7 +416,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
@ -523,7 +523,7 @@
|
|||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
replace(mac,'-','') as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
a.nu_id,
|
||||
d.nu_name,
|
||||
d.area_flag,
|
||||
a.mac as deviceName,
|
||||
replace(a.mac,'-','') as deviceName,
|
||||
a.device_index as deviceId,
|
||||
( case a.device_type
|
||||
when 'SURVEILLANCECAMERA' then '摄像头'
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
a.maintain_status as maintainStatus,
|
||||
b.update_date as updateDate
|
||||
from nu_iot_tplink_camera a
|
||||
left join nu_iot_device_log b on a.mac = b.device_id and b.id = (
|
||||
select id from nu_iot_device_log c where a.mac = c.device_id order by c.update_date desc limit 1
|
||||
left join nu_iot_device_log b on replace(a.mac,'-','') = b.device_id and b.id = (
|
||||
select id from nu_iot_device_log c where replace(a.mac,'-','') = c.device_id order by c.update_date desc limit 1
|
||||
)
|
||||
left join sys_depart c on a.depart_id = c.id
|
||||
left join nu_base_info d on a.nu_id = d.nu_id
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ 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.dingshuo.electricity.entity.DsElectricityMeter;
|
||||
import com.nu.modules.dingshuo.electricity.service.IDsElectricityMeterService;
|
||||
import com.nu.modules.manager.entity.IotDeviceInfo;
|
||||
import com.nu.modules.manager.service.IIotDeviceInfoService;
|
||||
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
|
||||
|
|
@ -49,7 +51,8 @@ public class IotDeviceMQListener {
|
|||
private ICameraCapabilityService cameraCapabilityService;
|
||||
|
||||
@Autowired
|
||||
private IElectricityMeterService electricityService;
|
||||
// private IElectricityMeterService electricityService;
|
||||
private IDsElectricityMeterService electricityService;
|
||||
|
||||
@Autowired
|
||||
private IWaterMeterService waterService;
|
||||
|
|
@ -87,13 +90,13 @@ public class IotDeviceMQListener {
|
|||
if(message.equals("成功")){
|
||||
String bizId = sdto.getAsyncId();
|
||||
String note = sdto.getNote();
|
||||
if(note.equals("区域")){
|
||||
NuBaseInfo nuBaseInfo = new NuBaseInfo();
|
||||
nuBaseInfo.setIzSync("Y");
|
||||
nuBaseInfo.setId(bizId);
|
||||
nuBaseInfoService.updateById(nuBaseInfo);
|
||||
}
|
||||
if(note.equals("摄像头")){
|
||||
// if(note.equals("区域")){
|
||||
// NuBaseInfo nuBaseInfo = new NuBaseInfo();
|
||||
// nuBaseInfo.setIzSync("Y");
|
||||
// nuBaseInfo.setId(bizId);
|
||||
// nuBaseInfoService.updateById(nuBaseInfo);
|
||||
// }
|
||||
if(note.equals("TPLINK")){
|
||||
CameraInfo cameraInfo = new CameraInfo();
|
||||
cameraInfo.setSyncType("Y");
|
||||
cameraInfo.setId(Integer.valueOf(bizId));
|
||||
|
|
@ -106,7 +109,8 @@ public class IotDeviceMQListener {
|
|||
cameraCapabilityService.updateById(cameraCapability);
|
||||
}
|
||||
if(note.equals("电表")){
|
||||
ElectricityMeter electricityMeter = new ElectricityMeter();
|
||||
// ElectricityMeter electricityMeter = new ElectricityMeter();
|
||||
DsElectricityMeter electricityMeter = new DsElectricityMeter();
|
||||
electricityMeter.setSyncType("Y");
|
||||
electricityMeter.setId(Integer.valueOf(bizId));
|
||||
electricityService.updateById(electricityMeter);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.nu.mq.tq.listener;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.dto.IotElectricityMeterMQDto;
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.dingshuo.electricity.entity.DsElectricityMeter;
|
||||
import com.nu.modules.dingshuo.electricity.service.IDsElectricityMeterService;
|
||||
import com.nu.modules.tq.electricity.entity.ElectricityMeter;
|
||||
import com.nu.modules.tq.electricity.service.IElectricityMeterService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
|
|
@ -23,7 +25,7 @@ public class IotSyncElectricityMQListener {
|
|||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
private IElectricityMeterService electricityMeterService;
|
||||
private IDsElectricityMeterService electricityMeterService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
|
|
@ -44,10 +46,9 @@ public class IotSyncElectricityMQListener {
|
|||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
statusMQDto.setNote("电表");
|
||||
QueryWrapper<ElectricityMeter> emQw = new QueryWrapper<>();
|
||||
emQw.eq("cid",dto.getCid());
|
||||
emQw.eq("address",dto.getAddress());
|
||||
ElectricityMeter entity = electricityMeterService.getOne(emQw);
|
||||
QueryWrapper<DsElectricityMeter> emQw = new QueryWrapper<>();
|
||||
emQw.eq("sn",dto.getSn());
|
||||
DsElectricityMeter entity = electricityMeterService.getOne(emQw);
|
||||
if(entity!=null){
|
||||
entity.setEleValue(dto.getEleValue());
|
||||
entity.setReadTime(dto.getReadTime());
|
||||
|
|
@ -83,10 +84,9 @@ public class IotSyncElectricityMQListener {
|
|||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
statusMQDto.setNote("电表");
|
||||
QueryWrapper<ElectricityMeter> emQw = new QueryWrapper<>();
|
||||
emQw.eq("cid",dto.getCid());
|
||||
emQw.eq("address",dto.getAddress());
|
||||
ElectricityMeter entity = electricityMeterService.getOne(emQw);
|
||||
QueryWrapper<DsElectricityMeter> emQw = new QueryWrapper<>();
|
||||
emQw.eq("sn",dto.getSn());
|
||||
DsElectricityMeter entity = electricityMeterService.getOne(emQw);
|
||||
if(entity!=null){
|
||||
entity.setRelayState(dto.getRelayState());
|
||||
electricityMeterService.updateRelayState(entity);
|
||||
|
|
|
|||
Loading…
Reference in New Issue