设备配置同步日志
This commit is contained in:
parent
5c781ec695
commit
7e0d4af40f
|
|
@ -0,0 +1,53 @@
|
|||
package com.nu.modules.syncLog.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.syncLog.entity.SyncConfigLog;
|
||||
import com.nu.modules.syncLog.service.ISyncConfigLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Description: 配置同步日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-08
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="配置同步日志")
|
||||
@RestController
|
||||
@RequestMapping("/iot/syncConfigLog")
|
||||
@Slf4j
|
||||
public class SyncConfigLogController extends JeecgController<SyncConfigLog, ISyncConfigLogService> {
|
||||
@Autowired
|
||||
private ISyncConfigLogService service;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param syncConfigLog
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="同步日志-分页列表查询", notes="同步日志-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<SyncConfigLog>> queryPageList(SyncConfigLog syncConfigLog,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SyncConfigLog> queryWrapper = QueryGenerator.initQueryWrapper(syncConfigLog, req.getParameterMap());
|
||||
Page<SyncConfigLog> page = new Page<SyncConfigLog>(pageNo, pageSize);
|
||||
IPage<SyncConfigLog> pageList = service.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.nu.modules.syncLog.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.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 配置同步日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-08
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_iot_config_sync_log")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_iot_config_sync_log", description="配置同步日志")
|
||||
public class SyncConfigLog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
private String logId;
|
||||
private String orgCode; //机构编码
|
||||
private String orgName; //机构名称
|
||||
private String content;
|
||||
private String syncType;
|
||||
private String status;
|
||||
private String serverType;
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nu.modules.syncLog.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.syncLog.entity.SyncConfigLog;
|
||||
|
||||
/**
|
||||
* @Description: 配置同步日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-08
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SyncConfigLogMapper extends BaseMapper<SyncConfigLog> {
|
||||
void addConfigLog(SyncConfigLog syncConfigLog);
|
||||
void updateConfigLog(SyncConfigLog syncConfigLog);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?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.syncLog.mapper.SyncConfigLogMapper">
|
||||
<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>
|
||||
|
||||
<select id="findSyncLogPage" parameterType="com.nu.modules.syncLog.entity.SyncConfigLog" resultType="com.nu.modules.syncLog.entity.SyncConfigLog">
|
||||
select
|
||||
id,
|
||||
log_id as logId,
|
||||
org_code as orgCode,
|
||||
org_name as orgName,
|
||||
content,
|
||||
sync_type as syncType,
|
||||
status,
|
||||
server_type as serverType,
|
||||
create_time as createTime,
|
||||
update_time as updateTime
|
||||
from nu_iot_config_sync_log
|
||||
order by id desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nu.modules.syncLog.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.syncLog.entity.SyncConfigLog;
|
||||
|
||||
/**
|
||||
* @Description: 配置同步日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-08
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISyncConfigLogService extends IService<SyncConfigLog> {
|
||||
void updateConfigLog(SyncConfigLog syncConfigLog);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.nu.modules.syncLog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.syncLog.entity.SyncConfigLog;
|
||||
import com.nu.modules.syncLog.mapper.SyncConfigLogMapper;
|
||||
import com.nu.modules.syncLog.service.ISyncConfigLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 配置同步日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-08
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SyncConfigLogServiceImpl extends ServiceImpl<SyncConfigLogMapper, SyncConfigLog> implements ISyncConfigLogService {
|
||||
@Override
|
||||
public void updateConfigLog(SyncConfigLog syncConfigLog){
|
||||
baseMapper.updateConfigLog(syncConfigLog);
|
||||
}
|
||||
}
|
||||
|
|
@ -45,26 +45,9 @@ public class TumsConfig implements Serializable {
|
|||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,5 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface TumsConfigMapper extends BaseMapper<TumsConfig> {
|
||||
TumsConfig getByCode();
|
||||
|
||||
List<TumsConfig> getOrgList();
|
||||
void addConfigLog(TumsConfig tumsConfig);
|
||||
void updateConfigLog(TumsConfig tumsConfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,35 +27,4 @@
|
|||
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,8 +14,6 @@ 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,8 +1,12 @@
|
|||
package com.nu.modules.tplink.common.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.dto.IotTumsConfigMQDto;
|
||||
import com.nu.modules.syncLog.entity.SyncConfigLog;
|
||||
import com.nu.modules.syncLog.mapper.SyncConfigLogMapper;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.mapper.TumsConfigMapper;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
|
|
@ -26,6 +30,9 @@ public class TumsConfigServiceImpl extends ServiceImpl<TumsConfigMapper, TumsCon
|
|||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
private SyncConfigLogMapper syncConfigLogMapper;
|
||||
|
||||
@Override
|
||||
public TumsConfig getByCode(){
|
||||
return baseMapper.getByCode();
|
||||
|
|
@ -45,11 +52,6 @@ public class TumsConfigServiceImpl extends ServiceImpl<TumsConfigMapper, TumsCon
|
|||
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);
|
||||
|
|
@ -58,21 +60,19 @@ public class TumsConfigServiceImpl extends ServiceImpl<TumsConfigMapper, TumsCon
|
|||
TumsConfig entity = orgList.get(i);
|
||||
String logId = UuidUtils.getUUID();
|
||||
String json = JSON.toJSONString(tumsConfig);
|
||||
TumsConfig log = new TumsConfig();
|
||||
SyncConfigLog log = new SyncConfigLog();
|
||||
log.setLogId(logId);
|
||||
log.setOrgCode(entity.getOrgCode());
|
||||
log.setOrgName(entity.getOrgName());
|
||||
log.setContent(json);
|
||||
log.setServerType(type);
|
||||
log.setSyncType(type);
|
||||
log.setStatus("同步中");
|
||||
log.setServerType("摄像头");
|
||||
baseMapper.addConfigLog(log);
|
||||
syncConfigLogMapper.addConfigLog(log);
|
||||
|
||||
itc.setLogId(logId);
|
||||
rabbitMQUtil.sendToExchange("hldy.tumsconfig", entity.getOrgCode() + ".tumsconfig.async", itc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,23 +38,7 @@ public class TqConfig implements Serializable {
|
|||
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "org_code")
|
||||
private String orgCode; //机构编码
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,5 @@ import java.util.Map;
|
|||
public interface TqConfigMapper extends BaseMapper<TqConfig> {
|
||||
TqConfig getConfig();
|
||||
List<TqConfig> getAllConfigList();
|
||||
void addConfigLog(TqConfig tqConfig);
|
||||
void updateConfigLog(TqConfig tqConfig);
|
||||
TqConfig getOrgName(String orgCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,37 +31,6 @@
|
|||
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>
|
||||
|
||||
<select id="getOrgName" parameterType="String" resultType="com.nu.modules.tq.common.entity.TqConfig">
|
||||
select
|
||||
org_code as orgCode,
|
||||
|
|
|
|||
|
|
@ -12,5 +12,4 @@ import com.nu.modules.tq.common.entity.TqConfig;
|
|||
public interface ITqConfigService extends IService<TqConfig> {
|
||||
void add(TqConfig tqConfig);
|
||||
void edit(TqConfig tqConfig);
|
||||
void updateConfigLog(TqConfig tqConfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ 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.syncLog.entity.SyncConfigLog;
|
||||
import com.nu.modules.syncLog.mapper.SyncConfigLogMapper;
|
||||
import com.nu.modules.tq.common.entity.TqConfig;
|
||||
import com.nu.modules.tq.common.mapper.TqConfigMapper;
|
||||
import com.nu.modules.tq.common.service.ITqConfigService;
|
||||
|
|
@ -27,6 +29,9 @@ public class TqConfigServiceImpl extends ServiceImpl<TqConfigMapper, TqConfig> i
|
|||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
private SyncConfigLogMapper syncConfigLogMapper;
|
||||
|
||||
@Override
|
||||
public void add(TqConfig tqConfig){
|
||||
tqConfig.setUpdateDate(DateUtils.formatDateTime());
|
||||
|
|
@ -41,11 +46,6 @@ public class TqConfigServiceImpl extends ServiceImpl<TqConfigMapper, TqConfig> i
|
|||
syncMq(tqConfig,"新增");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfigLog(TqConfig tqConfig){
|
||||
baseMapper.updateConfigLog(tqConfig);
|
||||
}
|
||||
|
||||
private void syncMq(TqConfig tqConfig,String type){
|
||||
String orgCode = tqConfig.getOrgCode();
|
||||
if(orgCode!=null&&!orgCode.equals("")){
|
||||
|
|
@ -54,15 +54,15 @@ public class TqConfigServiceImpl extends ServiceImpl<TqConfigMapper, TqConfig> i
|
|||
BeanUtils.copyProperties(tqConfig, itc);
|
||||
String logId = UuidUtils.getUUID();
|
||||
String json = JSON.toJSONString(tqConfig);
|
||||
TqConfig log = new TqConfig();
|
||||
SyncConfigLog log = new SyncConfigLog();
|
||||
log.setLogId(logId);
|
||||
log.setOrgCode(orgCode);
|
||||
log.setOrgName(org.getOrgName());
|
||||
log.setContent(json);
|
||||
log.setServerType(type);
|
||||
log.setSyncType(type);
|
||||
log.setStatus("同步中");
|
||||
log.setServerType("电水表");
|
||||
baseMapper.addConfigLog(log);
|
||||
syncConfigLogMapper.addConfigLog(log);
|
||||
itc.setLogId(logId);
|
||||
rabbitMQUtil.sendToExchange("hldy.tqconfig", orgCode + ".tqconfig.async", itc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,26 +33,9 @@ public class YiweilianConfig implements Serializable {
|
|||
private String requestUrl; //云平台系统地址
|
||||
private String clientId; //识别用户的唯一标识
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,4 @@ import java.util.List;
|
|||
public interface YiweilianConfigMapper extends BaseMapper<YiweilianConfig> {
|
||||
YiweilianConfig getConfig();
|
||||
List<YiweilianConfig> getOrgList();
|
||||
void addConfigLog(YiweilianConfig yiweilianConfig);
|
||||
void updateConfigLog(YiweilianConfig yiweilianConfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,35 +21,4 @@
|
|||
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>
|
||||
|
|
@ -13,5 +13,4 @@ public interface IYiweilianConfigService extends IService<YiweilianConfig> {
|
|||
YiweilianConfig getConfig();
|
||||
void add(YiweilianConfig yiweilianConfig);
|
||||
void edit(YiweilianConfig yiweilianConfig);
|
||||
void updateConfigLog(YiweilianConfig yiweilianConfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ 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.syncLog.entity.SyncConfigLog;
|
||||
import com.nu.modules.syncLog.mapper.SyncConfigLogMapper;
|
||||
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||
import com.nu.modules.yiweilian.common.mapper.YiweilianConfigMapper;
|
||||
import com.nu.modules.yiweilian.common.service.IYiweilianConfigService;
|
||||
|
|
@ -27,6 +29,9 @@ public class YiweilianConfigServiceImpl extends ServiceImpl<YiweilianConfigMappe
|
|||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
private SyncConfigLogMapper syncConfigLogMapper;
|
||||
|
||||
@Override
|
||||
public YiweilianConfig getConfig(){
|
||||
return baseMapper.getConfig();
|
||||
|
|
@ -46,11 +51,6 @@ public class YiweilianConfigServiceImpl extends ServiceImpl<YiweilianConfigMappe
|
|||
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);
|
||||
|
|
@ -59,15 +59,15 @@ public class YiweilianConfigServiceImpl extends ServiceImpl<YiweilianConfigMappe
|
|||
YiweilianConfig entity = orgList.get(i);
|
||||
String logId = UuidUtils.getUUID();
|
||||
String json = JSON.toJSONString(yiweilianConfig);
|
||||
YiweilianConfig log = new YiweilianConfig();
|
||||
SyncConfigLog log = new SyncConfigLog();
|
||||
log.setLogId(logId);
|
||||
log.setOrgCode(entity.getOrgCode());
|
||||
log.setOrgName(entity.getOrgName());
|
||||
log.setContent(json);
|
||||
log.setServerType(type);
|
||||
log.setSyncType(type);
|
||||
log.setStatus("同步中");
|
||||
log.setServerType("温湿度计");
|
||||
baseMapper.addConfigLog(log);
|
||||
syncConfigLogMapper.addConfigLog(log);
|
||||
|
||||
iyc.setLogId(logId);
|
||||
rabbitMQUtil.sendToExchange("hldy.yiweilianconfig", entity.getOrgCode() + ".yiweilianconfig.async", iyc);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.nu.mq.config.listener;
|
||||
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.syncLog.entity.SyncConfigLog;
|
||||
import com.nu.modules.syncLog.service.ISyncConfigLogService;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import com.nu.modules.tq.common.entity.TqConfig;
|
||||
|
|
@ -21,13 +23,7 @@ import org.springframework.stereotype.Component;
|
|||
public class IotConfigMQListener {
|
||||
|
||||
@Autowired
|
||||
ITumsConfigService tumsConfigService;
|
||||
|
||||
@Autowired
|
||||
ITqConfigService tqConfigService;
|
||||
|
||||
@Autowired
|
||||
IYiweilianConfigService yiweilianConfigService;
|
||||
ISyncConfigLogService syncConfigLogService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
|
|
@ -38,10 +34,10 @@ public class IotConfigMQListener {
|
|||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void tumsHandleMessage(StatusMQDto dto) {
|
||||
TumsConfig log = new TumsConfig();
|
||||
SyncConfigLog log = new SyncConfigLog();
|
||||
log.setLogId(dto.getPrimaryKey());
|
||||
log.setStatus(dto.getMessage());
|
||||
tumsConfigService.updateConfigLog(log);
|
||||
syncConfigLogService.updateConfigLog(log);
|
||||
}
|
||||
|
||||
@RabbitListener(
|
||||
|
|
@ -53,10 +49,10 @@ public class IotConfigMQListener {
|
|||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void tqHandleMessage(StatusMQDto dto) {
|
||||
TqConfig log = new TqConfig();
|
||||
SyncConfigLog log = new SyncConfigLog();
|
||||
log.setLogId(dto.getPrimaryKey());
|
||||
log.setStatus(dto.getMessage());
|
||||
tqConfigService.updateConfigLog(log);
|
||||
syncConfigLogService.updateConfigLog(log);
|
||||
}
|
||||
|
||||
@RabbitListener(
|
||||
|
|
@ -68,9 +64,9 @@ public class IotConfigMQListener {
|
|||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void yiweilianHandleMessage(StatusMQDto dto) {
|
||||
YiweilianConfig log = new YiweilianConfig();
|
||||
SyncConfigLog log = new SyncConfigLog();
|
||||
log.setLogId(dto.getPrimaryKey());
|
||||
log.setStatus(dto.getMessage());
|
||||
yiweilianConfigService.updateConfigLog(log);
|
||||
syncConfigLogService.updateConfigLog(log);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue