设备同步
This commit is contained in:
parent
63da8e002c
commit
2c9d4e93ee
|
|
@ -0,0 +1,50 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: TPLINK摄像头能力集信息
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotCameraCapabilityMQDto{
|
||||
/**ID*/
|
||||
private Integer id;
|
||||
/**设备序号*/
|
||||
private String deviceIndex;
|
||||
/**力集属性*/
|
||||
private String motionDetection;
|
||||
/**视频封面*/
|
||||
private String videoCover;
|
||||
/**云台*/
|
||||
private String ptz;
|
||||
private String motor;
|
||||
/**变焦,0不可变焦 1可变焦*/
|
||||
private String smartCode;
|
||||
/**强制在H.264编码过程中生成IDR帧的函数*/
|
||||
private String forceIdrFrame;
|
||||
/**音频*/
|
||||
private String audio;
|
||||
/**本地存储*/
|
||||
private String localStorage;
|
||||
/**回放API本版*/
|
||||
private String playbackApiVersionTwo;
|
||||
/**多变性*/
|
||||
private String multitrans;
|
||||
/**客流*/
|
||||
private String passengerFlow;
|
||||
/**获取预览缩略图*/
|
||||
private String getPreviewThumbnail;
|
||||
/**JPG预览缩略图*/
|
||||
private String previewThumbnailJpeg;
|
||||
/**走廊*/
|
||||
private String corridorMod;
|
||||
/**背光共存*/
|
||||
private String backlightCoexistence;
|
||||
/**是否同步 0 未同步 1已同步*/
|
||||
private String syncType;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: TPLINK摄像头信息
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotCameraInfoMQDto{
|
||||
/**ID*/
|
||||
private Integer id;
|
||||
/**sn*/
|
||||
private String sn;
|
||||
/**设备序号*/
|
||||
private String deviceIndex;
|
||||
/**设备名称*/
|
||||
private String deviceName;
|
||||
/**设备类型*/
|
||||
private String deviceType;
|
||||
/**设备状态 0 离线 1 在线 2 重启中 3 升级中 4 配置中 5 同步中*/
|
||||
private String deviceStatus;
|
||||
/**设备型号*/
|
||||
private String deviceModel;
|
||||
/**IP地址*/
|
||||
private String ip;
|
||||
/**MAC地址*/
|
||||
private String mac;
|
||||
/**分组ID*/
|
||||
private String regionId;
|
||||
/**分组名称*/
|
||||
private String regionName;
|
||||
/**父设备ID*/
|
||||
private String parentId;
|
||||
/**父设备名称*/
|
||||
private String parentDeviceName;
|
||||
/**项目ID*/
|
||||
private String projectId;
|
||||
/**项目名称*/
|
||||
private String projectName;
|
||||
/**软件版本*/
|
||||
private String firmwareVer;
|
||||
/**硬件版本*/
|
||||
private String hardwareVer;
|
||||
/**用户权限类型 -1 无权限 0 可读 1 可控制 2 可配置 3 可控制/配置 4 所有*/
|
||||
private String managerAuthType;
|
||||
/**告警消息权限 1 有权限 -1 无权限*/
|
||||
private String msgAuthType;
|
||||
/**国标编码*/
|
||||
private String sipCode;
|
||||
/**位置名称*/
|
||||
private String locationName;
|
||||
/**系统类型 public 通用*/
|
||||
private String systemType;
|
||||
/**协议类型*/
|
||||
private String protocol;
|
||||
/**录像计划ID**/
|
||||
private String recordPlanId;
|
||||
/**回放视频转FTP上传IP**/
|
||||
private String ftpIp;
|
||||
/**回放视频转FTP上传端口**/
|
||||
private String ftpPort;
|
||||
/**回放视频转FTP上传用户**/
|
||||
private String ftpUsername;
|
||||
/**回放视频转FTP上传密码**/
|
||||
private String ftpPassword;
|
||||
/**回放视频转FTP上传路径**/
|
||||
private String ftpUploadpath;
|
||||
/**区域编码*/
|
||||
private String nuId;
|
||||
/**区域编码*/
|
||||
private String nuName;
|
||||
/**机构ID*/
|
||||
private String departId;
|
||||
/**机构名称*/
|
||||
private String departName;
|
||||
/**机构服务地址*/
|
||||
private String departServerUrl;
|
||||
/**是否同步 0 未同步 1已同步*/
|
||||
private String syncType;
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 电水表采集器
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotEleWaterCollectorMQDto{
|
||||
/**主键*/
|
||||
private Integer id;
|
||||
/**采集器*/
|
||||
private String cid;
|
||||
/**在线状态*/
|
||||
private String online;
|
||||
/**信号值*/
|
||||
private String csq;
|
||||
/**上次掉线时间*/
|
||||
private String disconnectTime;
|
||||
/**上次上线时间*/
|
||||
private String connectTime;
|
||||
/**描述*/
|
||||
private String remark;
|
||||
/**是否同步 0 未同步 1已同步*/
|
||||
private String syncType;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 水表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotElectricityMeterMQDto{
|
||||
/**主键*/
|
||||
private Integer id;
|
||||
/**采集器*/
|
||||
private String cid;
|
||||
/**表号*/
|
||||
private String address;
|
||||
/**电表值*/
|
||||
private String eleValue;
|
||||
/**阀门状态*/
|
||||
private String relayState;
|
||||
/**描述*/
|
||||
private String remark;
|
||||
/**区域编码*/
|
||||
private String nuId;
|
||||
/**区域名称*/
|
||||
private String nuName;
|
||||
/**机构ID*/
|
||||
private String departId;
|
||||
/**机构名称*/
|
||||
private String departName;
|
||||
/**机构服务地址*/
|
||||
private String departServerUrl;
|
||||
/**是否同步*/
|
||||
private String syncType;
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 温湿度计
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotHumidDeviceMQDto{
|
||||
/**主键*/
|
||||
private Integer id;
|
||||
/**设备SN号*/
|
||||
private String sn;
|
||||
/**设备名称*/
|
||||
private String deviceName;
|
||||
/**设备所在时区*/
|
||||
private String timeCode;
|
||||
/**设备类型*/
|
||||
private String deviceTypes;
|
||||
/**上报间隔*/
|
||||
private String reportingInterval;
|
||||
/**记录间隔*/
|
||||
private String recordInterval;
|
||||
/**历史数据上报时刻*/
|
||||
private String historyReportTime;
|
||||
/**历史数据上报间隔*/
|
||||
private String historyInterval;
|
||||
/**温度预警范围 上限值*/
|
||||
private String temperatureHigh;
|
||||
/**温度预警范围 下限值*/
|
||||
private String temperatureLow;
|
||||
/**温度缓冲值*/
|
||||
private String temperatureBuffer;
|
||||
/**湿度预警范围 上限值*/
|
||||
private String humidityHigh;
|
||||
/**湿度预警范围 下限值*/
|
||||
private String humidityLow;
|
||||
/**湿度缓冲值*/
|
||||
private String humidityBuffer;
|
||||
/**断电报警"*/
|
||||
private String izOutages;
|
||||
/**低电报警*/
|
||||
private String izLowBattery;
|
||||
/**上下线通知*/
|
||||
private String izOnline;
|
||||
/**温度*/
|
||||
private String temperature;
|
||||
/**湿度*/
|
||||
private String humidity;
|
||||
/**在线状态*/
|
||||
private String status;
|
||||
/**最新上报时间*/
|
||||
private String reportingTime;
|
||||
/**电量*/
|
||||
private String electricity;
|
||||
/**区域编码*/
|
||||
private String nuId;
|
||||
/**区域名称*/
|
||||
private String nuName;
|
||||
/**机构ID*/
|
||||
private String departId;
|
||||
/**机构名称*/
|
||||
private String departName;
|
||||
/**机构服务地址*/
|
||||
private String departServerUrl;
|
||||
/**是否同步 0 未同步 1已同步*/
|
||||
private String syncType;
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IotNuBaseInfoMQDto {
|
||||
/**ID*/
|
||||
private String id;
|
||||
/**区域编码*/
|
||||
private String nuId;
|
||||
/**区域名称*/
|
||||
private String nuName;
|
||||
/**区域标签*/
|
||||
private String areaFlag;
|
||||
/**是否删除*/
|
||||
private String delFlag;
|
||||
/**所属机构*/
|
||||
private String orgCode;
|
||||
/**所属机构*/
|
||||
private String orgName;
|
||||
/**是否同步*/
|
||||
private String izSync;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class IotSyncBizMQDto {
|
||||
private IotNuBaseInfoMQDto nuBaseInfo;
|
||||
private List<IotCameraInfoMQDto> cameraInfoList;
|
||||
private List<IotCameraCapabilityMQDto> capabilityList;
|
||||
private List<IotElectricityMeterMQDto> electricityMeterList;
|
||||
private List<IotWaterMeterMQDto> waterMeterList;
|
||||
private List<IotEleWaterCollectorMQDto> collectorList;
|
||||
private List<IotHumidDeviceMQDto> humidDeviceList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 电表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotWaterMeterMQDto{
|
||||
/**主键*/
|
||||
private Integer id;
|
||||
/**采集器*/
|
||||
private String cid;
|
||||
/**表号*/
|
||||
private String address;
|
||||
/**水表值*/
|
||||
private String waterValue;
|
||||
/**阀门状态*/
|
||||
private String relayState;
|
||||
/**水表电池状态*/
|
||||
private String batteryState;
|
||||
/**描述*/
|
||||
private String remark;
|
||||
/**区域编码*/
|
||||
private String nuId;
|
||||
/**区域名称*/
|
||||
private String nuName;
|
||||
/**机构ID*/
|
||||
private String departId;
|
||||
/**机构名称*/
|
||||
private String departName;
|
||||
/**机构服务地址*/
|
||||
private String departServerUrl;
|
||||
/**是否同步*/
|
||||
private String syncType;
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
/**日志ID*/
|
||||
private String logId;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StatusListMQDto {
|
||||
List<StatusMQDto> statusList;
|
||||
}
|
||||
|
|
@ -52,6 +52,12 @@
|
|||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-admin-biz</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
package com.nu.modules.tplink.camera.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: TPLINK摄像头能力集信息
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_iot_tplink_camera_capability")
|
||||
public class CameraCapability implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**ID*/
|
||||
private Integer id;
|
||||
/**设备序号*/
|
||||
private String deviceIndex;
|
||||
/**力集属性*/
|
||||
private String motionDetection;
|
||||
/**视频封面*/
|
||||
private String videoCover;
|
||||
/**云台*/
|
||||
private String ptz;
|
||||
private String motor;
|
||||
/**变焦,0不可变焦 1可变焦*/
|
||||
private String smartCode;
|
||||
/**强制在H.264编码过程中生成IDR帧的函数*/
|
||||
private String forceIdrFrame;
|
||||
/**音频*/
|
||||
private String audio;
|
||||
/**本地存储*/
|
||||
private String localStorage;
|
||||
/**回放API本版*/
|
||||
private String playbackApiVersionTwo;
|
||||
/**多变性*/
|
||||
private String multitrans;
|
||||
/**客流*/
|
||||
private String passengerFlow;
|
||||
/**获取预览缩略图*/
|
||||
private String getPreviewThumbnail;
|
||||
/**JPG预览缩略图*/
|
||||
private String previewThumbnailJpeg;
|
||||
/**走廊*/
|
||||
private String corridorMod;
|
||||
/**背光共存*/
|
||||
private String backlightCoexistence;
|
||||
}
|
||||
|
|
@ -33,6 +33,10 @@ public class CameraInfo implements Serializable {
|
|||
@TableId(type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
/**设备编码*/
|
||||
@Excel(name = "设备编码", width = 15)
|
||||
@ApiModelProperty(value = "设备编码")
|
||||
private String sn;
|
||||
/**设备序号*/
|
||||
@Excel(name = "设备序号", width = 15)
|
||||
@ApiModelProperty(value = "设备序号")
|
||||
|
|
@ -307,4 +311,6 @@ public class CameraInfo implements Serializable {
|
|||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.tplink.camera.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.tplink.camera.entity.CameraCapability;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-摄像头能力集信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface CameraCapabilityMapper extends BaseMapper<CameraCapability> {
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.tplink.camera.mapper.CameraCapabilityMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.nu.modules.tplink.camera.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.tplink.camera.entity.CameraCapability;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-摄像头能力集信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ICameraCapabilityService extends IService<CameraCapability> {
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nu.modules.tplink.camera.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.tplink.camera.entity.CameraCapability;
|
||||
import com.nu.modules.tplink.camera.mapper.CameraCapabilityMapper;
|
||||
import com.nu.modules.tplink.camera.service.ICameraCapabilityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-摄像头能力集信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CameraCapabilityServiceImpl extends ServiceImpl<CameraCapabilityMapper, CameraCapability> implements ICameraCapabilityService {
|
||||
|
||||
}
|
||||
|
|
@ -78,5 +78,7 @@ public class ElectricityMeter implements Serializable {
|
|||
private String syncType;//是否同步 0 未同步 1已同步
|
||||
private String oldDepartId;//原机构id
|
||||
private String oldDepartName;//原机构名称
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.nu.modules.tq.electricity.entity.ElectricityMeter">
|
||||
insert into nu_iot_tq_water_meter(
|
||||
insert into nu_iot_tq_electricity_meter(
|
||||
cid,
|
||||
address,
|
||||
relay_state,
|
||||
|
|
|
|||
|
|
@ -76,4 +76,6 @@ public class WaterMeter implements Serializable {
|
|||
private String nuName;//护理单元
|
||||
private String departId;//机构ID
|
||||
private String departName;//机构名称
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
}
|
||||
|
|
@ -116,5 +116,6 @@ public class HumidDevice implements Serializable {
|
|||
private String syncType;//是否同步 0 未同步 1已同步
|
||||
private String oldDepartId;//原机构id
|
||||
private String oldDepartName;//原机构名称
|
||||
|
||||
/**维修状态*/
|
||||
private String maintainStatus;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import org.jeecg.common.system.api.ISysBaseAPI;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("iotAsyncDQNP")
|
||||
@Component("iotConfigAsyncDQNP")
|
||||
public class DynamicQueueNameProvider {
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ public class TqConfigMQListener {
|
|||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotAsyncDQNP.getSyncTqQueueName()}"),
|
||||
value = @Queue(name = "#{iotConfigAsyncDQNP.getSyncTqQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.tqconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotAsyncDQNP.getSyncTqKeyName()}"
|
||||
key = "#{iotConfigAsyncDQNP.getSyncTqKeyName()}"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ public class TumsConfigMQListener {
|
|||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotAsyncDQNP.getSyncTumsQueueName()}"),
|
||||
value = @Queue(name = "#{iotConfigAsyncDQNP.getSyncTumsQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.tumsconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotAsyncDQNP.getSyncTumsKeyName()}"
|
||||
key = "#{iotConfigAsyncDQNP.getSyncTumsKeyName()}"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ public class YiweilianConfigMQListener {
|
|||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotAsyncDQNP.getSyncYiweilianQueueName()}"),
|
||||
value = @Queue(name = "#{iotConfigAsyncDQNP.getSyncYiweilianQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.yiweilianconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotAsyncDQNP.getSyncTYiweilianKeyName()}"
|
||||
key = "#{iotConfigAsyncDQNP.getSyncTYiweilianKeyName()}"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.nu.mq.device.exceptionhandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.listener.api.RabbitListenerErrorHandler;
|
||||
import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component("iotDeviceMQErrorHandler")
|
||||
public class IotDeviceMQExceptionHandler implements RabbitListenerErrorHandler {
|
||||
|
||||
@Override
|
||||
public Object handleError(Message message, org.springframework.messaging.Message<?> message1, ListenerExecutionFailedException e) {
|
||||
log.error("MQ消息处理失败 | 消息体: {} | 异常原因: {}", new String(message.getBody()), e.getCause().getMessage());
|
||||
|
||||
// 根据异常类型选择处理策略
|
||||
// if (isRetryable(e)) {
|
||||
// // 可重试异常:抛出异常触发重试
|
||||
// throw e;
|
||||
// } else {
|
||||
// 不可恢复异常:拒绝消息且不重新入队
|
||||
throw new AmqpRejectAndDontRequeueException("消息处理失败且禁止重试", e);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.nu.mq.device.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("iotDeviceAsyncDQNP")
|
||||
public class DynamicQueueNameProvider {
|
||||
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
public String getSyncDeviceQueueName() {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String orgCode = deptInfo.getString("code");
|
||||
if (StringUtils.isNotBlank(orgCode)) {
|
||||
return orgCode + ".iotsyncbiz.async";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSyncDeviceKeyName() {
|
||||
return getSyncDeviceQueueName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,328 @@
|
|||
package com.nu.mq.device.listener;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.dto.*;
|
||||
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
|
||||
import com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
|
||||
import com.nu.modules.nuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
import com.nu.modules.tplink.camera.entity.CameraCapability;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import com.nu.modules.tplink.camera.service.ICameraCapabilityService;
|
||||
import com.nu.modules.tplink.camera.service.ICameraInfoService;
|
||||
import com.nu.modules.tq.common.entity.TqDeviceInfo;
|
||||
import com.nu.modules.tq.common.service.ITqDeviceInfoService;
|
||||
import com.nu.modules.tq.electricity.entity.ElectricityMeter;
|
||||
import com.nu.modules.tq.electricity.service.IElectricityMeterService;
|
||||
import com.nu.modules.tq.water.entity.WaterMeter;
|
||||
import com.nu.modules.tq.water.service.IWaterMeterService;
|
||||
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||
import com.nu.modules.yiweilian.humid.service.IHumidDeviceService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.ExchangeTypes;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class IotSyncBizMQListener {
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
private INuBaseInfoService nuBaseInfoService;
|
||||
|
||||
@Autowired
|
||||
private ICameraInfoService cameraInfoService;
|
||||
|
||||
@Autowired
|
||||
private ICameraCapabilityService cameraCapabilityService;
|
||||
|
||||
@Autowired
|
||||
private IElectricityMeterService electricityMeterService;
|
||||
|
||||
@Autowired
|
||||
private IWaterMeterService waterMeterService;
|
||||
|
||||
@Autowired
|
||||
private ITqDeviceInfoService collectorService;
|
||||
|
||||
@Autowired
|
||||
private IHumidDeviceService humidDeviceService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotDeviceAsyncDQNP.getSyncDeviceQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.iotsyncbiz", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotDeviceAsyncDQNP.getSyncDeviceKeyName()}"
|
||||
),
|
||||
errorHandler = "iotDeviceMQErrorHandler"
|
||||
)
|
||||
public void handleMessage_unify(IotSyncBizMQDto dto) {
|
||||
saveSyncBizInfo(dto);
|
||||
}
|
||||
|
||||
private void saveSyncBizInfo(IotSyncBizMQDto dto) {
|
||||
List<StatusMQDto> statusList = new ArrayList<>();
|
||||
IotNuBaseInfoMQDto iotNuBaseInfoMQDto = dto.getNuBaseInfo();
|
||||
try {
|
||||
QueryWrapper<NuBaseInfo> nuBaseInfoQw = new QueryWrapper<>();
|
||||
nuBaseInfoQw.eq("nu_id",iotNuBaseInfoMQDto.getNuId());
|
||||
NuBaseInfo entity = nuBaseInfoService.getOne(nuBaseInfoQw);
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotNuBaseInfoMQDto.getId());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotNuBaseInfoMQDto.getLogId());
|
||||
statusMQDto.setNote("区域");
|
||||
if(entity!=null){
|
||||
if(iotNuBaseInfoMQDto.getDelFlag().equals(entity.getDelFlag())){
|
||||
statusMQDto.setMessage("忽略");
|
||||
}else{
|
||||
entity.setDelFlag(iotNuBaseInfoMQDto.getDelFlag());
|
||||
nuBaseInfoService.updateById(entity);
|
||||
}
|
||||
}else{
|
||||
NuBaseInfo nuBaseInfo = new NuBaseInfo();
|
||||
BeanUtils.copyProperties(iotNuBaseInfoMQDto, nuBaseInfo);
|
||||
nuBaseInfoService.save(nuBaseInfo);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
} catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotNuBaseInfoMQDto.getId());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotNuBaseInfoMQDto.getLogId());
|
||||
statusMQDto.setNote("区域");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
List<IotCameraInfoMQDto> cameraList = dto.getCameraInfoList();
|
||||
if(cameraList!=null&&cameraList.size()>0){
|
||||
for(int i=0;i<cameraList.size();i++){
|
||||
IotCameraInfoMQDto iotCameraInfoMQDto = cameraList.get(i);
|
||||
try {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotCameraInfoMQDto.getId().toString());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotCameraInfoMQDto.getLogId());
|
||||
statusMQDto.setNote("摄像头");
|
||||
QueryWrapper<CameraInfo> cameraQw = new QueryWrapper<>();
|
||||
cameraQw.eq("device_index",iotCameraInfoMQDto.getDeviceIndex());
|
||||
CameraInfo entity = cameraInfoService.getOne(cameraQw);
|
||||
if(entity!=null){
|
||||
if(iotCameraInfoMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
|
||||
statusMQDto.setMessage("忽略");
|
||||
}else{
|
||||
entity.setMaintainStatus(iotCameraInfoMQDto.getMaintainStatus());
|
||||
cameraInfoService.updateById(entity);
|
||||
}
|
||||
}else{
|
||||
CameraInfo cameraInfo = new CameraInfo();
|
||||
BeanUtils.copyProperties(iotCameraInfoMQDto, cameraInfo);
|
||||
cameraInfoService.save(cameraInfo);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
}
|
||||
catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotCameraInfoMQDto.getId().toString());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotCameraInfoMQDto.getLogId());
|
||||
statusMQDto.setNote("摄像头");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IotCameraCapabilityMQDto> capabilityList = dto.getCapabilityList();
|
||||
if(capabilityList!=null&&capabilityList.size()>0){
|
||||
for(int i=0;i<capabilityList.size();i++){
|
||||
IotCameraCapabilityMQDto iotCameraCapabilityMQDto = capabilityList.get(i);
|
||||
try {
|
||||
QueryWrapper<CameraCapability> capabilityQw = new QueryWrapper<>();
|
||||
capabilityQw.eq("device_index",iotCameraCapabilityMQDto.getDeviceIndex());
|
||||
CameraCapability entity = cameraCapabilityService.getOne(capabilityQw);
|
||||
cameraCapabilityService.removeById(entity);
|
||||
CameraCapability cameraCapability = new CameraCapability();
|
||||
BeanUtils.copyProperties(iotCameraCapabilityMQDto, cameraCapability);
|
||||
cameraCapabilityService.save(cameraCapability);
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotCameraCapabilityMQDto.getId().toString());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotCameraCapabilityMQDto.getLogId());
|
||||
statusMQDto.setNote("摄像头能力集");
|
||||
statusList.add(statusMQDto);
|
||||
}
|
||||
catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotCameraCapabilityMQDto.getId().toString());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotCameraCapabilityMQDto.getLogId());
|
||||
statusMQDto.setNote("摄像头能力集");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IotElectricityMeterMQDto> electricityList = dto.getElectricityMeterList();
|
||||
if(electricityList!=null&&electricityList.size()>0){
|
||||
for(int i=0;i<electricityList.size();i++){
|
||||
IotElectricityMeterMQDto iotElectricityMeterMQDto = electricityList.get(i);
|
||||
try {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotElectricityMeterMQDto.getId().toString());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotElectricityMeterMQDto.getLogId());
|
||||
statusMQDto.setNote("电表");
|
||||
QueryWrapper<ElectricityMeter> electricityQw = new QueryWrapper<>();
|
||||
electricityQw.eq("cid",iotElectricityMeterMQDto.getCid());
|
||||
ElectricityMeter entity = electricityMeterService.getOne(electricityQw);
|
||||
if(entity!=null){
|
||||
if(iotElectricityMeterMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
|
||||
statusMQDto.setMessage("忽略");
|
||||
}else{
|
||||
entity.setMaintainStatus(iotElectricityMeterMQDto.getMaintainStatus());
|
||||
electricityMeterService.updateById(entity);
|
||||
}
|
||||
}else{
|
||||
ElectricityMeter electricityMeter = new ElectricityMeter();
|
||||
BeanUtils.copyProperties(iotElectricityMeterMQDto, electricityMeter);
|
||||
electricityMeterService.save(electricityMeter);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
}
|
||||
catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotElectricityMeterMQDto.getId().toString());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotElectricityMeterMQDto.getLogId());
|
||||
statusMQDto.setNote("电表");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IotWaterMeterMQDto> waterMeterList = dto.getWaterMeterList();
|
||||
if(waterMeterList!=null&&waterMeterList.size()>0){
|
||||
for(int i=0;i<waterMeterList.size();i++){
|
||||
IotWaterMeterMQDto iotWaterMeterMQDto = waterMeterList.get(i);
|
||||
try {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotWaterMeterMQDto.getId().toString());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotWaterMeterMQDto.getLogId());
|
||||
statusMQDto.setNote("水表");
|
||||
QueryWrapper<WaterMeter> waterQw = new QueryWrapper<>();
|
||||
waterQw.eq("cid",iotWaterMeterMQDto.getCid());
|
||||
WaterMeter entity = waterMeterService.getOne(waterQw);
|
||||
if(entity!=null){
|
||||
if(iotWaterMeterMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
|
||||
statusMQDto.setMessage("忽略");
|
||||
}else{
|
||||
entity.setMaintainStatus(iotWaterMeterMQDto.getMaintainStatus());
|
||||
waterMeterService.updateById(entity);
|
||||
}
|
||||
}else{
|
||||
WaterMeter waterMeter = new WaterMeter();
|
||||
BeanUtils.copyProperties(iotWaterMeterMQDto, waterMeter);
|
||||
waterMeterService.save(waterMeter);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
}
|
||||
catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotWaterMeterMQDto.getId().toString());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotWaterMeterMQDto.getLogId());
|
||||
statusMQDto.setNote("水表");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IotEleWaterCollectorMQDto> collectorList = dto.getCollectorList();
|
||||
if(collectorList!=null&&collectorList.size()>0){
|
||||
for(int i=0;i<collectorList.size();i++){
|
||||
IotEleWaterCollectorMQDto iotEleWaterCollectorMQDto = collectorList.get(i);
|
||||
try {
|
||||
QueryWrapper<TqDeviceInfo> collectorQw = new QueryWrapper<>();
|
||||
collectorQw.eq("cid",iotEleWaterCollectorMQDto.getCid());
|
||||
TqDeviceInfo entity = collectorService.getOne(collectorQw);
|
||||
collectorService.removeById(entity);
|
||||
TqDeviceInfo tqDeviceInfo = new TqDeviceInfo();
|
||||
BeanUtils.copyProperties(iotEleWaterCollectorMQDto, tqDeviceInfo);
|
||||
collectorService.save(tqDeviceInfo);
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotEleWaterCollectorMQDto.getId().toString());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotEleWaterCollectorMQDto.getLogId());
|
||||
statusMQDto.setNote("电水表采集器");
|
||||
statusList.add(statusMQDto);
|
||||
}
|
||||
catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotEleWaterCollectorMQDto.getId().toString());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotEleWaterCollectorMQDto.getLogId());
|
||||
statusMQDto.setNote("电水表采集器");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IotHumidDeviceMQDto> humidDeviceList = dto.getHumidDeviceList();
|
||||
if(humidDeviceList!=null&&humidDeviceList.size()>0){
|
||||
for(int i=0;i<humidDeviceList.size();i++){
|
||||
IotHumidDeviceMQDto iotHumidDeviceMQDto = humidDeviceList.get(i);
|
||||
try {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotHumidDeviceMQDto.getId().toString());
|
||||
statusMQDto.setMessage("成功");
|
||||
statusMQDto.setPrimaryKey(iotHumidDeviceMQDto.getLogId());
|
||||
statusMQDto.setNote("温湿度计");
|
||||
QueryWrapper<HumidDevice> humidQw = new QueryWrapper<>();
|
||||
humidQw.eq("sn",iotHumidDeviceMQDto.getSn());
|
||||
HumidDevice entity = humidDeviceService.getOne(humidQw);
|
||||
if(entity!=null){
|
||||
if(iotHumidDeviceMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
|
||||
statusMQDto.setMessage("忽略");
|
||||
}else{
|
||||
entity.setMaintainStatus(iotHumidDeviceMQDto.getMaintainStatus());
|
||||
humidDeviceService.updateById(entity);
|
||||
}
|
||||
}else{
|
||||
HumidDevice humidDevice = new HumidDevice();
|
||||
BeanUtils.copyProperties(iotHumidDeviceMQDto, humidDevice);
|
||||
humidDeviceService.save(humidDevice);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
}
|
||||
catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setAsyncId(iotHumidDeviceMQDto.getId().toString());
|
||||
statusMQDto.setMessage("失败");
|
||||
statusMQDto.setPrimaryKey(iotHumidDeviceMQDto.getLogId());
|
||||
statusMQDto.setNote("温湿度计");
|
||||
statusList.add(statusMQDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
StatusListMQDto statusListMQDto = new StatusListMQDto();
|
||||
statusListMQDto.setStatusList(statusList);
|
||||
rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", "iotsyncbiz.async.result", statusListMQDto);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue