设备配置同步MQ
This commit is contained in:
parent
b811da7b3d
commit
180214c6dd
|
@ -0,0 +1,15 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IotTqConfigMQDto {
|
||||
private Integer id;
|
||||
private String requestUrl; //后台系统地址
|
||||
private String authCode; //授权码
|
||||
private String randomCode; //随机字符串,签名时需要
|
||||
private String notifyUrl; //通知地址
|
||||
private String orgCode; //机构编码
|
||||
private String updateDate; //更新时间
|
||||
private String logId; //日志ID
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IotTumsConfigMQDto {
|
||||
private Integer id;
|
||||
private String tumsUrl; //获取图门系统地址
|
||||
private String tumsUsername; // 获取图门系统用户
|
||||
private String tumsPassword; //获取图门系统密码
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
private String updateDate; //更新时间
|
||||
private String logId; //日志ID
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IotYiweilianConfigMQDto {
|
||||
private Integer id;
|
||||
private String requestUrl; //云平台系统地址
|
||||
private String clientId; //识别用户的唯一标识
|
||||
private String updateDate; //更新时间
|
||||
private String logId; //日志ID
|
||||
}
|
|
@ -15,6 +15,12 @@
|
|||
<artifactId>nu-iot-local-api</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
<!-- COMMON 通用工具模块 -->
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-common</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
|
|
|
@ -61,8 +61,7 @@ public class TumsConfigController extends JeecgController<TumsConfig, ITumsConfi
|
|||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody TumsConfig tumsConfig) {
|
||||
tumsConfig.setUpdateTime(DateUtils.formatDateTime());
|
||||
service.save(tumsConfig);
|
||||
service.add(tumsConfig);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
|
@ -74,8 +73,7 @@ public class TumsConfigController extends JeecgController<TumsConfig, ITumsConfi
|
|||
*/
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<String> edit(@RequestBody TumsConfig tumsConfig) {
|
||||
tumsConfig.setUpdateTime(DateUtils.formatDateTime());
|
||||
service.updateById(tumsConfig);
|
||||
service.edit(tumsConfig);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -42,5 +43,29 @@ public class TumsConfig implements Serializable {
|
|||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
private String updateTime; //更新时间
|
||||
@JsonIgnore
|
||||
private String updateDate; //更新时间
|
||||
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String orgCode; //机构编码
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String orgName; //机构名称
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String logId;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String content;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String syncType;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String status;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String serverType;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import com.nu.modules.tplink.common.entity.TumsConfig;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-错误码
|
||||
* @Author: jeecg-boot
|
||||
|
@ -17,4 +19,8 @@ import org.apache.ibatis.annotations.Param;
|
|||
@Mapper
|
||||
public interface TumsConfigMapper extends BaseMapper<TumsConfig> {
|
||||
TumsConfig getByCode();
|
||||
|
||||
List<TumsConfig> getOrgList();
|
||||
void addConfigLog(TumsConfig tumsConfig);
|
||||
void updateConfigLog(TumsConfig tumsConfig);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,49 @@
|
|||
ftp_username as ftpUsername,
|
||||
ftp_password as ftpPassword,
|
||||
ftp_uploadpath as ftpUploadpath,
|
||||
update_time as updateTime
|
||||
update_date as updateDate
|
||||
from nu_iot_tplink_tums_base
|
||||
order by id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getOrgList" parameterType="String" resultType="com.nu.modules.tplink.common.entity.TumsConfig">
|
||||
select
|
||||
org_code as orgCode,
|
||||
depart_name as orgName
|
||||
from sys_depart
|
||||
where del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="addConfigLog">
|
||||
insert into nu_iot_config_sync_log (
|
||||
log_id,
|
||||
org_code,
|
||||
org_name,
|
||||
content,
|
||||
sync_type,
|
||||
status,
|
||||
server_type,
|
||||
create_time
|
||||
)
|
||||
values (
|
||||
#{logId},
|
||||
#{orgCode},
|
||||
#{orgName},
|
||||
#{content},
|
||||
#{syncType},
|
||||
#{status},
|
||||
#{serverType},
|
||||
now()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateConfigLog">
|
||||
UPDATE nu_iot_config_sync_log
|
||||
SET
|
||||
status = #{status},
|
||||
update_time = now()
|
||||
where log_id = #{logId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -14,4 +14,8 @@ import org.jeecg.common.api.vo.Result;
|
|||
*/
|
||||
public interface ITumsConfigService extends IService<TumsConfig> {
|
||||
TumsConfig getByCode();
|
||||
|
||||
void add(TumsConfig tumsConfig);
|
||||
void edit(TumsConfig tumsConfig);
|
||||
void updateConfigLog(TumsConfig tumsConfig);
|
||||
}
|
||||
|
|
|
@ -1,25 +1,78 @@
|
|||
package com.nu.modules.tplink.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.dto.IotTumsConfigMQDto;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.mapper.TumsConfigMapper;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import me.zhyd.oauth.utils.UuidUtils;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: TP-LINK图门系统配置信息
|
||||
* @Author: caolei
|
||||
* @Date: 2025-08-06
|
||||
* @Date: 2025-08-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TumsConfigServiceImpl extends ServiceImpl<TumsConfigMapper, TumsConfig> implements ITumsConfigService {
|
||||
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Override
|
||||
public TumsConfig getByCode(){
|
||||
return baseMapper.getByCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(TumsConfig tumsConfig){
|
||||
tumsConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
this.save(tumsConfig);
|
||||
syncMq(tumsConfig,"新增");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(TumsConfig tumsConfig){
|
||||
tumsConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
this.updateById(tumsConfig);
|
||||
syncMq(tumsConfig,"编辑");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfigLog(TumsConfig tumsConfig){
|
||||
baseMapper.updateConfigLog(tumsConfig);
|
||||
}
|
||||
|
||||
private void syncMq(TumsConfig tumsConfig,String type){
|
||||
IotTumsConfigMQDto itc= new IotTumsConfigMQDto();
|
||||
BeanUtils.copyProperties(tumsConfig, itc);
|
||||
List<TumsConfig> orgList = baseMapper.getOrgList();
|
||||
for(int i=0;i<orgList.size();i++){
|
||||
TumsConfig entity = orgList.get(i);
|
||||
String logId = UuidUtils.getUUID();
|
||||
String json = JSON.toJSONString(tumsConfig);
|
||||
TumsConfig log = new TumsConfig();
|
||||
log.setLogId(logId);
|
||||
log.setOrgCode(entity.getOrgCode());
|
||||
log.setOrgName(entity.getOrgName());
|
||||
log.setContent(json);
|
||||
log.setServerType(type);
|
||||
log.setStatus("同步中");
|
||||
log.setServerType("电水表");
|
||||
baseMapper.addConfigLog(log);
|
||||
|
||||
itc.setLogId(logId);
|
||||
rabbitMQUtil.sendToExchange("hldy.tumsconfig", entity.getOrgCode() + ".tumsconfig.async", itc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,7 @@ public class TqConfigController extends JeecgController<TqConfig, ITqConfigServi
|
|||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody TqConfig tqConfig) {
|
||||
tqConfig.setUpdateTime(DateUtils.formatDateTime());
|
||||
service.save(tqConfig);
|
||||
service.add(tqConfig);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
|
@ -75,8 +74,7 @@ public class TqConfigController extends JeecgController<TqConfig, ITqConfigServi
|
|||
*/
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<String> edit(@RequestBody TqConfig tqConfig) {
|
||||
tqConfig.setUpdateTime(DateUtils.formatDateTime());
|
||||
service.updateById(tqConfig);
|
||||
service.edit(tqConfig);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -36,5 +37,25 @@ public class TqConfig implements Serializable {
|
|||
private String notifyUrl; //通知地址
|
||||
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "org_code")
|
||||
private String orgCode; //机构编码
|
||||
private String updateTime; //通知地址
|
||||
@JsonIgnore
|
||||
private String updateDate; //更新时间
|
||||
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String orgName; //机构名称
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String logId;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String content;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String syncType;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String status;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String serverType;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.nu.modules.tq.common.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.tq.common.entity.TqConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -15,4 +17,7 @@ import java.util.Map;
|
|||
@Mapper
|
||||
public interface TqConfigMapper extends BaseMapper<TqConfig> {
|
||||
TqConfig getConfig();
|
||||
List<TqConfig> getAllConfigList();
|
||||
void addConfigLog(TqConfig tqConfig);
|
||||
void updateConfigLog(TqConfig tqConfig);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface TqDeviceInfoMapper extends BaseMapper<TqDeviceInfo> {
|
||||
TqDeviceInfo getDeviceInfo(TqDeviceInfo tqDeviceInfo);
|
||||
TqDeviceInfo getByCid(String cid);
|
||||
int insert(TqDeviceInfo tqDeviceInfo);
|
||||
int update(TqDeviceInfo tqDeviceInfo);
|
||||
int deleteByCid(String cid);
|
||||
}
|
||||
|
|
|
@ -8,10 +8,58 @@
|
|||
request_url as requestUrl,
|
||||
auth_code as authCode,
|
||||
random_code as randomCode,
|
||||
notify_url as notifyUrl
|
||||
notify_url as notifyUrl,
|
||||
update_date as updateDate
|
||||
from nu_iot_tq_config
|
||||
order by id desc
|
||||
where org_code is null
|
||||
order by id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getAllConfigList" parameterType="String" resultType="com.nu.modules.tq.common.entity.TqConfig">
|
||||
select
|
||||
a.id,
|
||||
a.request_url as requestUrl,
|
||||
a.auth_code as authCode,
|
||||
a.random_code as randomCode,
|
||||
a.notify_url as notifyUrl,
|
||||
a.org_code as orgCode,
|
||||
a.update_date as updateDate,
|
||||
b.depart_name as orgName
|
||||
from nu_iot_tq_config a
|
||||
left join sys_depart b on a.org_code = b.org_code
|
||||
order by a.id asc
|
||||
</select>
|
||||
|
||||
<insert id="addConfigLog">
|
||||
insert into nu_iot_config_sync_log (
|
||||
log_id,
|
||||
org_code,
|
||||
org_name,
|
||||
content,
|
||||
sync_type,
|
||||
status,
|
||||
server_type,
|
||||
create_time
|
||||
)
|
||||
values (
|
||||
#{logId},
|
||||
#{orgCode},
|
||||
#{orgName},
|
||||
#{content},
|
||||
#{syncType},
|
||||
#{status},
|
||||
#{serverType},
|
||||
now()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateConfigLog">
|
||||
UPDATE nu_iot_config_sync_log
|
||||
SET
|
||||
status = #{status},
|
||||
update_time = now()
|
||||
where log_id = #{logId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -15,6 +15,19 @@
|
|||
where cid = #{cid}
|
||||
</select>
|
||||
|
||||
<select id="getByCid" parameterType="String" resultType="com.nu.modules.tq.common.entity.TqDeviceInfo">
|
||||
select
|
||||
id,
|
||||
cid as cid,
|
||||
online,
|
||||
csq,
|
||||
disconnect_time as disconnectTime,
|
||||
connect_time as connectTime,
|
||||
remark
|
||||
from nu_iot_tq_collector
|
||||
where cid = #{cid}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.nu.modules.tq.common.entity.TqDeviceInfo">
|
||||
insert into nu_iot_tq_collector(
|
||||
cid,
|
||||
|
@ -57,4 +70,8 @@
|
|||
where cid = #{cid}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByCid">
|
||||
DELETE FROM nu_iot_tq_collector WHERE cid = #{cid}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
|
@ -10,5 +10,7 @@ import com.nu.modules.tq.common.entity.TqConfig;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITqConfigService extends IService<TqConfig> {
|
||||
TqConfig getConfig();
|
||||
void add(TqConfig tqConfig);
|
||||
void edit(TqConfig tqConfig);
|
||||
void updateConfigLog(TqConfig tqConfig);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.nu.modules.tq.common.entity.TqDeviceInfo;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITqDeviceInfoService extends IService<TqDeviceInfo> {
|
||||
TqDeviceInfo getByCid(String cid);
|
||||
void getAllMeter(boolean isJob);
|
||||
void getAllCollector(boolean isJob);
|
||||
}
|
||||
|
|
|
@ -1,23 +1,76 @@
|
|||
package com.nu.modules.tq.common.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.dto.IotTqConfigMQDto;
|
||||
import com.nu.modules.tq.common.entity.TqConfig;
|
||||
import com.nu.modules.tq.common.mapper.TqConfigMapper;
|
||||
import com.nu.modules.tq.common.service.ITqConfigService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import me.zhyd.oauth.utils.UuidUtils;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-电水表配置信息
|
||||
* @Author: caolei
|
||||
* @Date: 2025-06-04
|
||||
* @Date: 2025-06-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TqConfigServiceImpl extends ServiceImpl<TqConfigMapper, TqConfig> implements ITqConfigService {
|
||||
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Override
|
||||
public TqConfig getConfig(){
|
||||
return baseMapper.getConfig();
|
||||
public void add(TqConfig tqConfig){
|
||||
tqConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
this.save(tqConfig);
|
||||
syncMq(tqConfig,"新增");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(TqConfig tqConfig){
|
||||
tqConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
this.updateById(tqConfig);
|
||||
syncMq(tqConfig,"新增");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfigLog(TqConfig tqConfig){
|
||||
baseMapper.updateConfigLog(tqConfig);
|
||||
}
|
||||
|
||||
private void syncMq(TqConfig tqConfig,String type){
|
||||
IotTqConfigMQDto itc = new IotTqConfigMQDto();
|
||||
BeanUtils.copyProperties(tqConfig, itc);
|
||||
List<TqConfig> orgList = baseMapper.getAllConfigList();
|
||||
for(int i=0;i<orgList.size();i++){
|
||||
TqConfig entity = orgList.get(i);
|
||||
if(entity.getOrgCode().equals("")){
|
||||
continue;
|
||||
}
|
||||
String logId = UuidUtils.getUUID();
|
||||
String json = JSON.toJSONString(tqConfig);
|
||||
TqConfig log = new TqConfig();
|
||||
log.setLogId(logId);
|
||||
log.setOrgCode(entity.getOrgCode());
|
||||
log.setOrgName(entity.getOrgName());
|
||||
log.setContent(json);
|
||||
log.setServerType(type);
|
||||
log.setStatus("同步中");
|
||||
log.setServerType("摄像头");
|
||||
baseMapper.addConfigLog(log);
|
||||
|
||||
itc.setLogId(logId);
|
||||
rabbitMQUtil.sendToExchange("hldy.tqconfig", entity.getOrgCode() + ".tqconfig.async", itc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,11 @@ public class TqDeviceInfoServiceImpl extends ServiceImpl<TqDeviceInfoMapper, TqD
|
|||
@Autowired
|
||||
WaterMeterMapper waterMeterMapper;
|
||||
|
||||
@Override
|
||||
public TqDeviceInfo getByCid(String cid){
|
||||
return baseMapper.getByCid(cid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @return
|
||||
|
|
|
@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.nu.modules.syncLog.entity.SyncLog;
|
||||
import com.nu.modules.syncLog.service.ISyncLogService;
|
||||
import com.nu.modules.tq.common.entity.TqApiLog;
|
||||
import com.nu.modules.tq.common.entity.TqDeviceInfo;
|
||||
import com.nu.modules.tq.common.mapper.TqDeviceInfoMapper;
|
||||
import com.nu.modules.tq.common.service.ITqApiLogService;
|
||||
import com.nu.modules.tq.utils.HttpTool;
|
||||
import com.nu.modules.tq.utils.SignTool;
|
||||
|
@ -37,6 +39,9 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
@Autowired
|
||||
ITqApiLogService logService;
|
||||
|
||||
@Autowired
|
||||
TqDeviceInfoMapper tqDeviceInfoMapper;
|
||||
|
||||
@Autowired
|
||||
public ISyncLogService nuIotTqElectricitySyncLogService;
|
||||
|
||||
|
@ -702,6 +707,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
|
||||
for (ElectricityMeter electricityMeter : list) {
|
||||
ElectricityMeter waterInfo = baseMapper.getElectricityMeter(electricityMeter);
|
||||
TqDeviceInfo tqDeviceInfo = tqDeviceInfoMapper.getByCid(waterInfo.getCid());
|
||||
String actionType = electricityMeter.getActionType();//操作类型
|
||||
if(actionType.equals("添加")){
|
||||
String orgCode = electricityMeter.getOrgCode();
|
||||
|
@ -718,7 +724,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
waterInfo.setOldDepartId(null);
|
||||
waterInfo.setOldDepartName(null);
|
||||
|
||||
boolean flag = syncImpl.syncDevice(orgCode,"更新",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(orgCode,"更新",waterInfo,tqDeviceInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(electricityMeter.getAddress());
|
||||
|
@ -756,7 +762,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
waterInfo.setOldDepartId(electricityMeter.getOldDepartId());
|
||||
waterInfo.setOldDepartName(electricityMeter.getOldDepartName());
|
||||
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo,tqDeviceInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(electricityMeter.getAddress());
|
||||
|
@ -792,7 +798,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
waterInfo.setOldServerUrl(null);
|
||||
waterInfo.setOldDepartId(null);
|
||||
waterInfo.setOldDepartName(null);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"更新",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"更新",waterInfo,tqDeviceInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(electricityMeter.getAddress());
|
||||
|
@ -828,7 +834,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
return "1";
|
||||
}
|
||||
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo,tqDeviceInfo);
|
||||
if(!flag){
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
|
@ -855,7 +861,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
waterInfo.setOldServerUrl(null);
|
||||
waterInfo.setOldDepartId(null);
|
||||
waterInfo.setOldDepartName(null);
|
||||
flag2 = syncImpl.syncDevice(orgCode,"更新",waterInfo);
|
||||
flag2 = syncImpl.syncDevice(orgCode,"更新",waterInfo,tqDeviceInfo);
|
||||
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
|
@ -913,7 +919,7 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
|
||||
//业务系统保存或者修改命令
|
||||
@DS("#dataSourceCode")
|
||||
public boolean syncDevice(String dataSourceCode,String type,ElectricityMeter electricityMeter) {
|
||||
public boolean syncDevice(String dataSourceCode, String type, ElectricityMeter electricityMeter, TqDeviceInfo tqDeviceInfo) {
|
||||
try {
|
||||
QueryWrapper<ElectricityMeter> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("address",electricityMeter.getAddress());
|
||||
|
@ -921,13 +927,34 @@ public class ElectricityMeterServiceImpl extends ServiceImpl<ElectricityMeterMap
|
|||
if(type.equals("更新")){
|
||||
if(oldParam == null){
|
||||
baseMapper.insert(electricityMeter);
|
||||
if(tqDeviceInfo!=null) {
|
||||
TqDeviceInfo oldCollector = tqDeviceInfoMapper.getByCid(tqDeviceInfo.getCid());
|
||||
if (oldCollector == null) {
|
||||
tqDeviceInfoMapper.insert(tqDeviceInfo);
|
||||
} else {
|
||||
tqDeviceInfo.setId(oldCollector.getId());
|
||||
tqDeviceInfoMapper.update(tqDeviceInfo);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
electricityMeter.setId(oldParam.getId());
|
||||
baseMapper.updateById(electricityMeter);
|
||||
if(tqDeviceInfo!=null) {
|
||||
TqDeviceInfo oldCollector = tqDeviceInfoMapper.getByCid(tqDeviceInfo.getCid());
|
||||
if (oldCollector == null) {
|
||||
tqDeviceInfoMapper.insert(tqDeviceInfo);
|
||||
} else {
|
||||
tqDeviceInfo.setId(oldCollector.getId());
|
||||
tqDeviceInfoMapper.update(tqDeviceInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type.equals("删除")){
|
||||
baseMapper.deleteById(oldParam);
|
||||
if(tqDeviceInfo!=null) {
|
||||
tqDeviceInfoMapper.deleteByCid(tqDeviceInfo.getCid());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -77,6 +77,7 @@ public class WaterMeter implements Serializable {
|
|||
@Dict(dicCode = "nu_type")
|
||||
@TableField(exist = false)
|
||||
private String areaFlag;//区域标签
|
||||
@TableField(exist = false)
|
||||
private Integer deviceNum;//已绑定设备数
|
||||
private String departId;//机构ID
|
||||
private String departName;//机构名称
|
||||
|
|
|
@ -12,7 +12,10 @@ import com.nu.modules.syncLog.entity.SyncLog;
|
|||
import com.nu.modules.syncLog.service.ISyncLogService;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import com.nu.modules.tq.common.entity.TqApiLog;
|
||||
import com.nu.modules.tq.common.entity.TqDeviceInfo;
|
||||
import com.nu.modules.tq.common.mapper.TqDeviceInfoMapper;
|
||||
import com.nu.modules.tq.common.service.ITqApiLogService;
|
||||
import com.nu.modules.tq.common.service.ITqDeviceInfoService;
|
||||
import com.nu.modules.tq.electricity.entity.ElectricityMeter;
|
||||
import com.nu.modules.tq.utils.HttpTool;
|
||||
import com.nu.modules.tq.utils.SignTool;
|
||||
|
@ -39,6 +42,8 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
@Autowired
|
||||
ITqApiLogService logService;
|
||||
|
||||
@Autowired
|
||||
TqDeviceInfoMapper tqDeviceInfoMapper;
|
||||
|
||||
@Autowired
|
||||
public ISyncLogService nuIotTqElectricitySyncLogService;
|
||||
|
@ -587,8 +592,6 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
baseMapper.updateDepartById(cameraInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<Map<String,Object>> list = (List<Map<String,Object>>) waterList.get("list");
|
||||
for (Map<String, Object> map : list) {
|
||||
WaterMeter waterInfo = new WaterMeter();
|
||||
|
@ -717,6 +720,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
|
||||
for (WaterMeter waterMeter : list) {
|
||||
WaterMeter waterInfo = baseMapper.getWaterMeter(waterMeter);
|
||||
TqDeviceInfo tqDeviceInfo = tqDeviceInfoMapper.getByCid(waterInfo.getCid());
|
||||
String actionType = waterMeter.getActionType();//操作类型
|
||||
if(actionType.equals("添加")){
|
||||
String orgCode = waterMeter.getOrgCode();
|
||||
|
@ -733,7 +737,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
waterInfo.setOldDepartId(null);
|
||||
waterInfo.setOldDepartName(null);
|
||||
|
||||
boolean flag = syncImpl.syncDevice(orgCode,"更新",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(orgCode,"更新",waterInfo,tqDeviceInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(waterMeter.getAddress());
|
||||
|
@ -771,7 +775,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
waterInfo.setOldDepartId(waterMeter.getOldDepartId());
|
||||
waterInfo.setOldDepartName(waterMeter.getOldDepartName());
|
||||
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo,tqDeviceInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(waterMeter.getAddress());
|
||||
|
@ -807,7 +811,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
waterInfo.setOldServerUrl(null);
|
||||
waterInfo.setOldDepartId(null);
|
||||
waterInfo.setOldDepartName(null);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"更新",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"更新",waterInfo,tqDeviceInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(waterMeter.getAddress());
|
||||
|
@ -843,7 +847,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
return "1";
|
||||
}
|
||||
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",waterInfo,tqDeviceInfo);
|
||||
if(!flag){
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
|
@ -870,7 +874,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
waterInfo.setOldServerUrl(null);
|
||||
waterInfo.setOldDepartId(null);
|
||||
waterInfo.setOldDepartName(null);
|
||||
flag2 = syncImpl.syncDevice(orgCode,"更新",waterInfo);
|
||||
flag2 = syncImpl.syncDevice(orgCode,"更新",waterInfo,tqDeviceInfo);
|
||||
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
|
@ -928,7 +932,7 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
|
||||
//业务系统保存或者修改命令
|
||||
@DS("#dataSourceCode")
|
||||
public boolean syncDevice(String dataSourceCode,String type,WaterMeter waterMeter) {
|
||||
public boolean syncDevice(String dataSourceCode,String type,WaterMeter waterMeter,TqDeviceInfo tqDeviceInfo) {
|
||||
try {
|
||||
QueryWrapper<WaterMeter> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("address",waterMeter.getAddress());
|
||||
|
@ -936,13 +940,34 @@ public class WaterMeterServiceImpl extends ServiceImpl<WaterMeterMapper, WaterMe
|
|||
if(type.equals("更新")){
|
||||
if(oldParam == null){
|
||||
baseMapper.insert(waterMeter);
|
||||
if(tqDeviceInfo!=null){
|
||||
TqDeviceInfo oldCollector = tqDeviceInfoMapper.getByCid(tqDeviceInfo.getCid());
|
||||
if(oldCollector == null){
|
||||
tqDeviceInfoMapper.insert(tqDeviceInfo);
|
||||
}else{
|
||||
tqDeviceInfo.setId(oldCollector.getId());
|
||||
tqDeviceInfoMapper.update(tqDeviceInfo);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
waterMeter.setId(oldParam.getId());
|
||||
baseMapper.updateById(waterMeter);
|
||||
if(tqDeviceInfo!=null){
|
||||
TqDeviceInfo oldCollector = tqDeviceInfoMapper.getByCid(tqDeviceInfo.getCid());
|
||||
if(oldCollector == null){
|
||||
tqDeviceInfoMapper.insert(tqDeviceInfo);
|
||||
}else{
|
||||
tqDeviceInfo.setId(oldCollector.getId());
|
||||
tqDeviceInfoMapper.update(tqDeviceInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type.equals("删除")){
|
||||
baseMapper.deleteById(oldParam);
|
||||
if(tqDeviceInfo!=null){
|
||||
tqDeviceInfoMapper.deleteByCid(tqDeviceInfo.getCid());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -62,8 +62,7 @@ public class YiweilianConfigController extends JeecgController<YiweilianConfig,
|
|||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody YiweilianConfig yiweilianConfig) {
|
||||
yiweilianConfig.setUpdateTime(DateUtils.formatDateTime());
|
||||
service.save(yiweilianConfig);
|
||||
service.add(yiweilianConfig);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
|
@ -75,8 +74,7 @@ public class YiweilianConfigController extends JeecgController<YiweilianConfig,
|
|||
*/
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<String> edit(@RequestBody YiweilianConfig yiweilianConfig) {
|
||||
yiweilianConfig.setUpdateTime(DateUtils.formatDateTime());
|
||||
service.updateById(yiweilianConfig);
|
||||
service.edit(yiweilianConfig);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.nu.modules.yiweilian.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -30,5 +32,28 @@ public class YiweilianConfig implements Serializable {
|
|||
private Integer id;
|
||||
private String requestUrl; //云平台系统地址
|
||||
private String clientId; //识别用户的唯一标识
|
||||
private String updateTime; //更新时间
|
||||
@JsonIgnore
|
||||
private String updateDate; //更新时间
|
||||
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String orgCode; //机构编码
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String orgName; //机构名称
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String logId;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String content;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String syncType;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String status;
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String serverType;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-易维联-配置信息
|
||||
* @Author: caolei
|
||||
|
@ -14,4 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface YiweilianConfigMapper extends BaseMapper<YiweilianConfig> {
|
||||
YiweilianConfig getConfig();
|
||||
List<YiweilianConfig> getOrgList();
|
||||
void addConfigLog(YiweilianConfig yiweilianConfig);
|
||||
void updateConfigLog(YiweilianConfig yiweilianConfig);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,50 @@
|
|||
select
|
||||
id,
|
||||
request_url as requestUrl,
|
||||
client_id as clientId
|
||||
client_id as clientId,
|
||||
update_date as updateDate
|
||||
from nu_iot_yiweilian_config
|
||||
order by id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getOrgList" parameterType="String" resultType="com.nu.modules.yiweilian.common.entity.YiweilianConfig">
|
||||
select
|
||||
org_code as orgCode,
|
||||
depart_name as orgName
|
||||
from sys_depart
|
||||
where del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="addConfigLog">
|
||||
insert into nu_iot_config_sync_log (
|
||||
log_id,
|
||||
org_code,
|
||||
org_name,
|
||||
content,
|
||||
sync_type,
|
||||
status,
|
||||
server_type,
|
||||
create_time
|
||||
)
|
||||
values (
|
||||
#{logId},
|
||||
#{orgCode},
|
||||
#{orgName},
|
||||
#{content},
|
||||
#{syncType},
|
||||
#{status},
|
||||
#{serverType},
|
||||
now()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateConfigLog">
|
||||
UPDATE nu_iot_config_sync_log
|
||||
SET
|
||||
status = #{status},
|
||||
update_time = now()
|
||||
where log_id = #{logId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -11,4 +11,7 @@ import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
|||
*/
|
||||
public interface IYiweilianConfigService extends IService<YiweilianConfig> {
|
||||
YiweilianConfig getConfig();
|
||||
void add(YiweilianConfig yiweilianConfig);
|
||||
void edit(YiweilianConfig yiweilianConfig);
|
||||
void updateConfigLog(YiweilianConfig yiweilianConfig);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
package com.nu.modules.yiweilian.common.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.dto.IotYiweilianConfigMQDto;
|
||||
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||
import com.nu.modules.yiweilian.common.mapper.YiweilianConfigMapper;
|
||||
import com.nu.modules.yiweilian.common.service.IYiweilianConfigService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import me.zhyd.oauth.utils.UuidUtils;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-易维联-配置信息
|
||||
* @Author: caolei
|
||||
|
@ -15,9 +24,54 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class YiweilianConfigServiceImpl extends ServiceImpl<YiweilianConfigMapper, YiweilianConfig> implements IYiweilianConfigService {
|
||||
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Override
|
||||
public YiweilianConfig getConfig(){
|
||||
return baseMapper.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(YiweilianConfig yiweilianConfig){
|
||||
yiweilianConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
this.save(yiweilianConfig);
|
||||
syncMq(yiweilianConfig,"新增");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(YiweilianConfig yiweilianConfig){
|
||||
yiweilianConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
this.updateById(yiweilianConfig);
|
||||
syncMq(yiweilianConfig,"新增");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfigLog(YiweilianConfig yiweilianConfig){
|
||||
baseMapper.updateConfigLog(yiweilianConfig);
|
||||
}
|
||||
|
||||
private void syncMq(YiweilianConfig yiweilianConfig,String type){
|
||||
IotYiweilianConfigMQDto iyc = new IotYiweilianConfigMQDto();
|
||||
BeanUtils.copyProperties(yiweilianConfig, iyc);
|
||||
List<YiweilianConfig> orgList = baseMapper.getOrgList();
|
||||
for(int i=0;i<orgList.size();i++){
|
||||
YiweilianConfig entity = orgList.get(i);
|
||||
String logId = UuidUtils.getUUID();
|
||||
String json = JSON.toJSONString(yiweilianConfig);
|
||||
YiweilianConfig log = new YiweilianConfig();
|
||||
log.setLogId(logId);
|
||||
log.setOrgCode(entity.getOrgCode());
|
||||
log.setOrgName(entity.getOrgName());
|
||||
log.setContent(json);
|
||||
log.setServerType(type);
|
||||
log.setStatus("同步中");
|
||||
log.setServerType("温湿度计");
|
||||
baseMapper.addConfigLog(log);
|
||||
|
||||
iyc.setLogId(logId);
|
||||
rabbitMQUtil.sendToExchange("hldy.yiweilianconfig", entity.getOrgCode() + ".yiweilianconfig.async", iyc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.nu.mq.config.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("iotConfigMQErrorHandler")
|
||||
public class IotConfigMQExceptionHandler 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,76 @@
|
|||
package com.nu.mq.config.listener;
|
||||
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import com.nu.modules.tq.common.entity.TqConfig;
|
||||
import com.nu.modules.tq.common.service.ITqConfigService;
|
||||
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||
import com.nu.modules.yiweilian.common.service.IYiweilianConfigService;
|
||||
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.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class IotConfigMQListener {
|
||||
|
||||
@Autowired
|
||||
ITumsConfigService tumsConfigService;
|
||||
|
||||
@Autowired
|
||||
ITqConfigService tqConfigService;
|
||||
|
||||
@Autowired
|
||||
IYiweilianConfigService yiweilianConfigService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "tumsconfig.async.result", durable = "true"),
|
||||
exchange = @Exchange(name = "hldy.tumsconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "tumsconfig.async.result"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void tumsHandleMessage(StatusMQDto dto) {
|
||||
TumsConfig log = new TumsConfig();
|
||||
log.setLogId(dto.getPrimaryKey());
|
||||
log.setStatus(dto.getMessage());
|
||||
tumsConfigService.updateConfigLog(log);
|
||||
}
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "tqconfig.async.result", durable = "true"),
|
||||
exchange = @Exchange(name = "hldy.tqconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "tqconfig.async.result"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void tqHandleMessage(StatusMQDto dto) {
|
||||
TqConfig log = new TqConfig();
|
||||
log.setLogId(dto.getPrimaryKey());
|
||||
log.setStatus(dto.getMessage());
|
||||
tqConfigService.updateConfigLog(log);
|
||||
}
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "yiweilianconfig.async.result", durable = "true"),
|
||||
exchange = @Exchange(name = "hldy.yiweilianconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "yiweilianconfig.async.result"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void yiweilianHandleMessage(StatusMQDto dto) {
|
||||
YiweilianConfig log = new YiweilianConfig();
|
||||
log.setLogId(dto.getPrimaryKey());
|
||||
log.setStatus(dto.getMessage());
|
||||
yiweilianConfigService.updateConfigLog(log);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue