设备配置同步MQ
This commit is contained in:
parent
e53fea5385
commit
b82015b84f
|
@ -287,4 +287,10 @@ public class AppCameraInfo implements Serializable {
|
|||
@ApiModelProperty(value = "球机移动速度")
|
||||
@TableField(exist = false)
|
||||
private String speed;
|
||||
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
}
|
||||
|
|
|
@ -30,17 +30,17 @@ public class AppTumsConfig implements Serializable {
|
|||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
private String tumsUrl; //获取图门系统地址
|
||||
private String tumsProjectId; //图门系统登录项目ID
|
||||
@TableField(exist = false)
|
||||
private String tumsProjectName; //图门系统登录项目ID
|
||||
private String tumsUserId; // 图门系统登录用户ID
|
||||
// private String tumsProjectId; //图门系统登录项目ID
|
||||
// @TableField(exist = false)
|
||||
// private String tumsProjectName; //图门系统登录项目ID
|
||||
// private String tumsUserId; // 图门系统登录用户ID
|
||||
private String tumsUsername; // 获取图门系统用户
|
||||
private String tumsPassword; //获取图门系统密码
|
||||
private String tumsRoleId; //图门系统角色ID
|
||||
// private String tumsRoleId; //图门系统角色ID
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
private String orgCode; //机构编码
|
||||
private String updateTime; //更新时间
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.nu.modules.iot.tplink.entity.AppTumsConfig;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-错误码
|
||||
* @Description: 护理单元-物联管理-配置信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-10
|
||||
* @Version: V1.0
|
||||
|
@ -13,6 +13,5 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
|
||||
@Mapper
|
||||
public interface AppTumsConfigMapper extends BaseMapper<AppTumsConfig> {
|
||||
AppTumsConfig getByCode(String orgCode);
|
||||
AppTumsConfig findProjectByCodeOrId(AppTumsConfig tumsConfig);
|
||||
AppTumsConfig getByCode();
|
||||
}
|
||||
|
|
|
@ -6,44 +6,17 @@
|
|||
select
|
||||
id,
|
||||
tums_url as tumsUrl,
|
||||
tums_project_id as tumsProjectId,
|
||||
tums_userId as tumsUserId,
|
||||
tums_username as tumsUsername,
|
||||
tums_password as tumsPassword,
|
||||
tums_roleId as tumsRoleId,
|
||||
ftp_ip as ftpIp,
|
||||
ftp_port as ftpPort,
|
||||
ftp_username as ftpUsername,
|
||||
ftp_password as ftpPassword,
|
||||
ftp_uploadpath as ftpUploadpath,
|
||||
org_code as orgCode
|
||||
update_time as updateTime
|
||||
from nu_iot_tplink_tums_base
|
||||
<where>
|
||||
<if test="orgCode != null and orgCode != ''">
|
||||
AND org_code = #{orgCode}
|
||||
</if>
|
||||
<if test="orgCode == null or orgCode == ''">
|
||||
AND ifnull(org_code,'') = ''
|
||||
</if>
|
||||
</where>
|
||||
order by id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="findProjectByCodeOrId" parameterType="String" resultType="com.nu.modules.iot.tplink.entity.AppTumsConfig">
|
||||
select p.project_id as tumsProjectId,
|
||||
p.project_name as tumsProjectName
|
||||
from nu_iot_tplink_project p
|
||||
inner join sys_depart d on p.institution_id = d.id
|
||||
<where>
|
||||
<if test="tumsProjectId != null and tumsProjectId != ''">
|
||||
AND p.project_id = #{tumsProjectId}
|
||||
</if>
|
||||
<if test="tumsProjectId == null or tumsProjectId == ''">
|
||||
AND d.org_code = #{orgCode}
|
||||
</if>
|
||||
</where>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -10,5 +10,5 @@ import com.nu.modules.iot.tplink.entity.AppTumsConfig;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface IAppTumsConfigService extends IService<AppTumsConfig> {
|
||||
AppTumsConfig getByCode(String orgCode);
|
||||
AppTumsConfig getByCode();
|
||||
}
|
||||
|
|
|
@ -1592,8 +1592,7 @@ public class AppCameraInfoServiceImpl extends ServiceImpl<AppCameraInfoMapper, A
|
|||
if(chnError.equals("0")){
|
||||
List<AppCameraInfo> chnList = (List)chnMap.get("data");
|
||||
if(chnList!=null&&chnList.size()>0){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
AppTumsConfig tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
AppTumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
for(int j=0;j<chnList.size();j++){
|
||||
AppCameraInfo chn = chnList.get(j);
|
||||
Map<String,Object> playbackMap = getPlaybackUrl(chn,1);
|
||||
|
@ -1773,8 +1772,7 @@ public class AppCameraInfoServiceImpl extends ServiceImpl<AppCameraInfoMapper, A
|
|||
Map<String,Object> multitransMap = getMultitransUrl(cameraInfo,1);
|
||||
String multitransError = multitransMap.get("error").toString();
|
||||
if(multitransError.equals("0")){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
AppTumsConfig tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
AppTumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
AppCameraInfo entity = (AppCameraInfo)multitransMap.get("data");
|
||||
entity.setQueryAddress(tumsConfig.getTumsUrl());
|
||||
return Result.OK(entity);
|
||||
|
@ -1793,8 +1791,26 @@ public class AppCameraInfoServiceImpl extends ServiceImpl<AppCameraInfoMapper, A
|
|||
*/
|
||||
@Override
|
||||
public Result uploadToServer(AppCameraInfo cameraInfo){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
AppTumsConfig tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
String ftpUsername = "";
|
||||
String ftpPassword = "";
|
||||
String ftpUploadpath = "";
|
||||
String ftpIp = "";
|
||||
String ftpPort = "";
|
||||
AppCameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if(entity.getFtpIp()!=null&&!entity.getFtpIp().equals("")){
|
||||
ftpIp = entity.getFtpIp();
|
||||
ftpPort = entity.getFtpPort();
|
||||
ftpUsername = entity.getFtpUsername();
|
||||
ftpPassword = entity.getFtpPassword();
|
||||
ftpUploadpath = entity.getFtpUploadpath();
|
||||
}else{
|
||||
AppTumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
ftpIp = tumsConfig.getFtpIp();
|
||||
ftpPort = tumsConfig.getFtpPort();
|
||||
ftpUsername = tumsConfig.getFtpUsername();
|
||||
ftpPassword = tumsConfig.getFtpPassword();
|
||||
ftpUploadpath = tumsConfig.getFtpUploadpath();
|
||||
}
|
||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||
String parentId = cameraInfo.getParentId();
|
||||
String fileName = cameraInfo.getFileName();
|
||||
|
@ -1817,11 +1833,11 @@ public class AppCameraInfoServiceImpl extends ServiceImpl<AppCameraInfoMapper, A
|
|||
sb.append("\"startTime\"").append(":").append(cameraInfo.getStartTime()).append(",");
|
||||
sb.append("\"endTime\"").append(":").append(cameraInfo.getEndTime()).append(",");
|
||||
sb.append("\"downloadInfo\"").append(":{");
|
||||
sb.append("\"username\"").append(":").append("\"").append(tumsConfig.getFtpUsername()).append("\",");
|
||||
sb.append("\"password\"").append(":").append("\"").append(tumsConfig.getFtpPassword()).append("\",");
|
||||
sb.append("\"path\"").append(":").append("\"").append(tumsConfig.getFtpUploadpath()).append("\",");
|
||||
sb.append("\"ftpIp\"").append(":").append("\"").append(tumsConfig.getFtpIp()).append("\",");
|
||||
sb.append("\"ftpPort\"").append(":").append(tumsConfig.getFtpPort());
|
||||
sb.append("\"username\"").append(":").append("\"").append(ftpUsername).append("\",");
|
||||
sb.append("\"password\"").append(":").append("\"").append(ftpPassword).append("\",");
|
||||
sb.append("\"path\"").append(":").append("\"").append(ftpUploadpath).append("\",");
|
||||
sb.append("\"ftpIp\"").append(":").append("\"").append(ftpIp).append("\",");
|
||||
sb.append("\"ftpPort\"").append(":").append(ftpPort);
|
||||
sb.append("}");
|
||||
sb.append("}");
|
||||
String res = tumsApi.uploadToServer(sb.toString());
|
||||
|
|
|
@ -17,8 +17,8 @@ import org.springframework.stereotype.Service;
|
|||
public class AppTumsConfigServiceImpl extends ServiceImpl<AppTumsConfigMapper, AppTumsConfig> implements IAppTumsConfigService {
|
||||
|
||||
@Override
|
||||
public AppTumsConfig getByCode(String orgCode){
|
||||
return baseMapper.getByCode(orgCode);
|
||||
public AppTumsConfig getByCode(){
|
||||
return baseMapper.getByCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ public class AppTumsApi {
|
|||
|
||||
private void initTumsConfig(){
|
||||
if(tumsConfig==null){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
tumsConfig = tumsConfigMapper.getByCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -24,7 +30,6 @@
|
|||
<artifactId>hibernate-re</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 企业微信/钉钉 api -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
|
@ -35,6 +40,12 @@
|
|||
<artifactId>tums-auth</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-system-local-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -301,4 +301,10 @@ public class CameraInfo implements Serializable {
|
|||
@ApiModelProperty(value = "球机移动速度")
|
||||
@TableField(exist = false)
|
||||
private String speed;
|
||||
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
}
|
||||
|
|
|
@ -2171,8 +2171,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
if(chnError.equals("0")){
|
||||
List<CameraInfo> chnList = (List)chnMap.get("data");
|
||||
if(chnList!=null&&chnList.size()>0){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
for(int j=0;j<chnList.size();j++){
|
||||
CameraInfo chn = chnList.get(j);
|
||||
Map<String,Object> playbackMap = getPlaybackUrl(chn,1);
|
||||
|
@ -2352,8 +2351,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
Map<String,Object> multitransMap = getMultitransUrl(cameraInfo,1);
|
||||
String multitransError = multitransMap.get("error").toString();
|
||||
if(multitransError.equals("0")){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
CameraInfo entity = (CameraInfo)multitransMap.get("data");
|
||||
entity.setQueryAddress(tumsConfig.getTumsUrl());
|
||||
return Result.OK(entity);
|
||||
|
@ -2372,8 +2370,26 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
*/
|
||||
@Override
|
||||
public Result uploadToServer(CameraInfo cameraInfo){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode(sysUser.getOrgCode());
|
||||
String ftpUsername = "";
|
||||
String ftpPassword = "";
|
||||
String ftpUploadpath = "";
|
||||
String ftpIp = "";
|
||||
String ftpPort = "";
|
||||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if(entity.getFtpIp()!=null&&!entity.getFtpIp().equals("")){
|
||||
ftpIp = entity.getFtpIp();
|
||||
ftpPort = entity.getFtpPort();
|
||||
ftpUsername = entity.getFtpUsername();
|
||||
ftpPassword = entity.getFtpPassword();
|
||||
ftpUploadpath = entity.getFtpUploadpath();
|
||||
}else{
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
ftpIp = tumsConfig.getFtpIp();
|
||||
ftpPort = tumsConfig.getFtpPort();
|
||||
ftpUsername = tumsConfig.getFtpUsername();
|
||||
ftpPassword = tumsConfig.getFtpPassword();
|
||||
ftpUploadpath = tumsConfig.getFtpUploadpath();
|
||||
}
|
||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||
String parentId = cameraInfo.getParentId();
|
||||
String fileName = cameraInfo.getFileName();
|
||||
|
@ -2396,11 +2412,11 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
sb.append("\"startTime\"").append(":").append(cameraInfo.getStartTime()).append(",");
|
||||
sb.append("\"endTime\"").append(":").append(cameraInfo.getEndTime()).append(",");
|
||||
sb.append("\"downloadInfo\"").append(":{");
|
||||
sb.append("\"username\"").append(":").append("\"").append(tumsConfig.getFtpUsername()).append("\",");
|
||||
sb.append("\"password\"").append(":").append("\"").append(tumsConfig.getFtpPassword()).append("\",");
|
||||
sb.append("\"path\"").append(":").append("\"").append(tumsConfig.getFtpUploadpath()).append("\",");
|
||||
sb.append("\"ftpIp\"").append(":").append("\"").append(tumsConfig.getFtpIp()).append("\",");
|
||||
sb.append("\"ftpPort\"").append(":").append(tumsConfig.getFtpPort());
|
||||
sb.append("\"username\"").append(":").append("\"").append(ftpUsername).append("\",");
|
||||
sb.append("\"password\"").append(":").append("\"").append(ftpPassword).append("\",");
|
||||
sb.append("\"path\"").append(":").append("\"").append(ftpUploadpath).append("\",");
|
||||
sb.append("\"ftpIp\"").append(":").append("\"").append(ftpIp).append("\",");
|
||||
sb.append("\"ftpPort\"").append(":").append(ftpPort);
|
||||
sb.append("}");
|
||||
sb.append("}");
|
||||
String res = tumsApi.uploadToServer(sb.toString());
|
||||
|
|
|
@ -30,8 +30,7 @@ public class TpLinkController {
|
|||
*/
|
||||
@GetMapping(value = "/login")
|
||||
public Result<Map<String,String>> login() {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigService.getByCode(sysUser.getOrgCode());
|
||||
TumsConfig tumsConfig = tumsConfigService.getByCode();
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("cookie","");
|
||||
map.put("serverUrl",tumsConfig.getTumsUrl());
|
||||
|
@ -52,22 +51,4 @@ public class TpLinkController {
|
|||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图门系统用户
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getUser")
|
||||
public Result<?> getUser(TumsConfig tumsConfig) {
|
||||
return tumsConfigService.getUser(tumsConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加和编辑图门系统用户
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/saveUser")
|
||||
public Result<String> saveUser(@RequestBody TumsConfig tumsConfig) {
|
||||
return tumsConfigService.saveUser(tumsConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,17 +30,17 @@ public class TumsConfig implements Serializable {
|
|||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
private String tumsUrl; //获取图门系统地址
|
||||
private String tumsProjectId; //图门系统登录项目ID
|
||||
@TableField(exist = false)
|
||||
private String tumsProjectName; //图门系统登录项目ID
|
||||
private String tumsUserId; // 图门系统登录用户ID
|
||||
// private String tumsProjectId; //图门系统登录项目ID
|
||||
// @TableField(exist = false)
|
||||
// private String tumsProjectName; //图门系统登录项目ID
|
||||
// private String tumsUserId; // 图门系统登录用户ID
|
||||
private String tumsUsername; // 获取图门系统用户
|
||||
private String tumsPassword; //获取图门系统密码
|
||||
private String tumsRoleId; //图门系统角色ID
|
||||
// private String tumsRoleId; //图门系统角色ID
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
private String orgCode; //机构编码
|
||||
private String updateDate; //更新时间
|
||||
}
|
||||
|
|
|
@ -15,8 +15,5 @@ import java.util.Map;
|
|||
|
||||
@Mapper
|
||||
public interface TumsConfigMapper extends BaseMapper<TumsConfig> {
|
||||
TumsConfig getByCode(String orgCode);
|
||||
TumsConfig findProjectByCodeOrId(TumsConfig tumsConfig);
|
||||
void addUser(Map<String, String> map);
|
||||
void updateUser(Map<String, String> map);
|
||||
TumsConfig getByCode();
|
||||
}
|
||||
|
|
|
@ -6,151 +6,17 @@
|
|||
select
|
||||
id,
|
||||
tums_url as tumsUrl,
|
||||
tums_project_id as tumsProjectId,
|
||||
tums_userId as tumsUserId,
|
||||
tums_username as tumsUsername,
|
||||
tums_password as tumsPassword,
|
||||
tums_roleId as tumsRoleId,
|
||||
ftp_ip as ftpIp,
|
||||
ftp_port as ftpPort,
|
||||
ftp_username as ftpUsername,
|
||||
ftp_password as ftpPassword,
|
||||
ftp_uploadpath as ftpUploadpath,
|
||||
org_code as orgCode
|
||||
update_date as updateDate
|
||||
from nu_iot_tplink_tums_base
|
||||
order by id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="findProjectByCodeOrId" parameterType="String" resultType="com.nu.modules.tplink.common.entity.TumsConfig">
|
||||
select p.project_id as tumsProjectId,
|
||||
p.project_name as tumsProjectName
|
||||
from nu_iot_tplink_project p
|
||||
inner join sys_depart d on p.institution_id = d.id
|
||||
<where>
|
||||
<if test="tumsProjectId != null and tumsProjectId != ''">
|
||||
AND p.project_id = #{tumsProjectId}
|
||||
</if>
|
||||
<if test="tumsProjectId == null or tumsProjectId == ''">
|
||||
AND d.org_code = #{orgCode}
|
||||
</if>
|
||||
</where>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="addUser">
|
||||
insert into nu_iot_tplink_tums_base(
|
||||
<if test="tumsUrl != null and tumsUrl != ''">
|
||||
tums_url,
|
||||
</if>
|
||||
<if test="tumsProjectId != null and tumsProjectId != ''">
|
||||
tums_project_id,
|
||||
</if>
|
||||
<if test="tumsUserId != null and tumsUserId != ''">
|
||||
tums_userId,
|
||||
</if>
|
||||
<if test="tumsUsername != null and tumsUsername != ''">
|
||||
tums_username,
|
||||
</if>
|
||||
<if test="tumsPassword != null and tumsPassword != ''">
|
||||
tums_password,
|
||||
</if>
|
||||
<if test="tumsRoleId != null and tumsRoleId != ''">
|
||||
tums_roleId,
|
||||
</if>
|
||||
<if test="ftpIp != null and ftpIp != ''">
|
||||
ftp_ip,
|
||||
</if>
|
||||
<if test="ftpPort != null and ftpPort != ''">
|
||||
ftp_port,
|
||||
</if>
|
||||
<if test="ftpUsername != null and ftpUsername != ''">
|
||||
ftp_username,
|
||||
</if>
|
||||
<if test="ftpPassword != null and ftpPassword != ''">
|
||||
ftp_password,
|
||||
</if>
|
||||
<if test="ftpUploadpath != null and ftpUploadpath != ''">
|
||||
ftp_uploadpath,
|
||||
</if>
|
||||
org_code
|
||||
)
|
||||
values(
|
||||
<if test="tumsUrl != null and tumsUrl != ''">
|
||||
#{tumsUrl},
|
||||
</if>
|
||||
<if test="tumsProjectId != null and tumsProjectId != ''">
|
||||
#{tumsProjectId},
|
||||
</if>
|
||||
<if test="tumsUserId != null and tumsUserId != ''">
|
||||
#{tumsUserId},
|
||||
</if>
|
||||
<if test="tumsUsername != null and tumsUsername != ''">
|
||||
#{tumsUsername},
|
||||
</if>
|
||||
<if test="tumsPassword != null and tumsPassword != ''">
|
||||
#{tumsPassword},
|
||||
</if>
|
||||
<if test="tumsRoleId != null and tumsRoleId != ''">
|
||||
#{tumsRoleId},
|
||||
</if>
|
||||
<if test="ftpIp != null and ftpIp != ''">
|
||||
#{ftpIp},
|
||||
</if>
|
||||
<if test="ftpPort != null and ftpPort != ''">
|
||||
#{ftpPort},
|
||||
</if>
|
||||
<if test="ftpUsername != null and ftpUsername != ''">
|
||||
#{ftpUsername},
|
||||
</if>
|
||||
<if test="ftpPassword != null and ftpPassword != ''">
|
||||
#{ftpPassword},
|
||||
</if>
|
||||
<if test="ftpUploadpath != null and ftpUploadpath != ''">
|
||||
#{ftpUploadpath},
|
||||
</if>
|
||||
#{orgCode}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateUser">
|
||||
update nu_iot_tplink_tums_base
|
||||
set
|
||||
<if test="tumsUrl != null and tumsUrl != ''">
|
||||
tums_url = #{tumsUrl},
|
||||
</if>
|
||||
<if test="tumsProjectId != null and tumsProjectId != ''">
|
||||
tums_project_id = #{tumsProjectId},
|
||||
</if>
|
||||
<if test="tumsUserId != null and tumsUserId != ''">
|
||||
tums_userId = #{tumsUserId},
|
||||
</if>
|
||||
<if test="tumsUsername != null and tumsUsername != ''">
|
||||
tums_username = #{tumsUsername},
|
||||
</if>
|
||||
<if test="tumsPassword != null and tumsPassword != ''">
|
||||
tums_password = #{tumsPassword},
|
||||
</if>
|
||||
<if test="tumsRoleId != null and tumsRoleId != ''">
|
||||
tums_roleId = #{tumsRoleId},
|
||||
</if>
|
||||
<if test="ftpIp != null and ftpIp != ''">
|
||||
ftp_ip = #{ftpIp},
|
||||
</if>
|
||||
<if test="ftpPort != null and ftpPort != ''">
|
||||
ftp_port = #{ftpPort},
|
||||
</if>
|
||||
<if test="ftpUsername != null and ftpUsername != ''">
|
||||
ftp_username = #{ftpUsername},
|
||||
</if>
|
||||
<if test="ftpPassword != null and ftpPassword != ''">
|
||||
ftp_password = #{ftpPassword},
|
||||
</if>
|
||||
<if test="ftpUploadpath != null and ftpUploadpath != ''">
|
||||
ftp_uploadpath = #{ftpUploadpath},
|
||||
</if>
|
||||
org_code = #{orgCode}
|
||||
where org_code = #{orgCode}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -11,7 +11,5 @@ import org.jeecg.common.api.vo.Result;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITumsConfigService extends IService<TumsConfig> {
|
||||
TumsConfig getByCode(String orgCode);
|
||||
Result<?> getUser(TumsConfig tumsConfig);
|
||||
Result<String> saveUser(TumsConfig tumsConfig);
|
||||
TumsConfig getByCode();
|
||||
}
|
||||
|
|
|
@ -22,157 +22,9 @@ import java.util.Map;
|
|||
@Service
|
||||
public class TumsConfigServiceImpl extends ServiceImpl<TumsConfigMapper, TumsConfig> implements ITumsConfigService {
|
||||
|
||||
@Autowired
|
||||
private TumsApi tumsApi;
|
||||
|
||||
@Override
|
||||
public TumsConfig getByCode(String orgCode){
|
||||
return baseMapper.getByCode(orgCode);
|
||||
public TumsConfig getByCode(){
|
||||
return baseMapper.getByCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> getUser(TumsConfig tumsConfig){
|
||||
TumsConfig entity = baseMapper.getByCode(tumsConfig.getOrgCode());
|
||||
if(entity == null){
|
||||
entity = new TumsConfig();
|
||||
entity.setOrgCode(tumsConfig.getOrgCode());
|
||||
}
|
||||
TumsConfig project = baseMapper.findProjectByCodeOrId(entity);
|
||||
if(project!=null){
|
||||
entity.setTumsProjectId(project.getTumsProjectId());
|
||||
entity.setTumsProjectName(project.getTumsProjectName());
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> saveUser(TumsConfig tumsConfig){
|
||||
TumsConfig entity = baseMapper.getByCode(tumsConfig.getOrgCode());
|
||||
if(entity!=null){
|
||||
String errorMsg = "";
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if(!entity.getTumsPassword().equals(tumsConfig.getTumsPassword())){
|
||||
//调用修改密码接口
|
||||
StringBuffer sbp = new StringBuffer();
|
||||
sbp.append("{");
|
||||
sbp.append("\"userId\"").append(":").append("\"").append(tumsConfig.getTumsUserId()).append("\",");
|
||||
sbp.append("\"oldPassword\"").append(":").append("\"").append(entity.getTumsPassword()).append("\",");
|
||||
sbp.append("\"newPassword\"").append(":").append("\"").append(tumsConfig.getTumsPassword()).append("\"");
|
||||
sbp.append("}");
|
||||
String jsonResponsep = tumsApi.changePassword(sbp.toString());
|
||||
JSONObject jsonObjectp = new JSONObject(jsonResponsep);
|
||||
String errorCodep = jsonObjectp.getStr("error_code");
|
||||
if(errorCodep.equals("0")){
|
||||
map.put("tumsPassword",tumsConfig.getTumsPassword());
|
||||
}else{
|
||||
if(errorCodep.equals("-82400")){
|
||||
errorMsg = "修改密码:密码格式错误!";
|
||||
}else{
|
||||
errorMsg = "修改密码:"+jsonObjectp.getStr("msg");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!entity.getTumsRoleId().equals(tumsConfig.getTumsRoleId())){
|
||||
//调用修改角色接口
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"userId\"").append(":").append("\"").append(tumsConfig.getTumsUserId()).append("\",");
|
||||
sb.append("\"roleList\"").append(":[").append(tumsConfig.getTumsRoleId()).append("]");
|
||||
sb.append("}");
|
||||
String jsonResponse = tumsApi.editUser(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
map.put("tumsRoleId",tumsConfig.getTumsRoleId());
|
||||
}else{
|
||||
if(!errorMsg.equals("")){
|
||||
errorMsg = errorMsg + "\n" + "修改角色:"+jsonObject.getStr("msg");
|
||||
}else{
|
||||
errorMsg = "修改角色:"+jsonObject.getStr("msg");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tumsConfig.getTumsUrl()!=null&&!tumsConfig.getTumsUrl().equals("")){
|
||||
map.put("tumsUrl",tumsConfig.getTumsUrl());
|
||||
}
|
||||
if(tumsConfig.getTumsProjectId()!=null&&!tumsConfig.getTumsProjectId().equals("")){
|
||||
map.put("tumsProjectId",tumsConfig.getTumsProjectId());
|
||||
}
|
||||
if(tumsConfig.getFtpIp()!=null&&!tumsConfig.getFtpIp().equals("")){
|
||||
map.put("ftpIp",tumsConfig.getFtpIp());
|
||||
}
|
||||
if(tumsConfig.getFtpPort()!=null&&!tumsConfig.getFtpPort().equals("")){
|
||||
map.put("ftpPort",tumsConfig.getFtpPort());
|
||||
}
|
||||
if(tumsConfig.getFtpUsername()!=null&&!tumsConfig.getFtpUsername().equals("")){
|
||||
map.put("ftpUsername",tumsConfig.getFtpUsername());
|
||||
}
|
||||
if(tumsConfig.getFtpPassword()!=null&&!tumsConfig.getFtpPassword().equals("")){
|
||||
map.put("ftpPassword",tumsConfig.getFtpPassword());
|
||||
}
|
||||
if(tumsConfig.getFtpUploadpath()!=null&&!tumsConfig.getFtpUploadpath().equals("")){
|
||||
map.put("ftpUploadpath",tumsConfig.getFtpUploadpath());
|
||||
}
|
||||
if(tumsConfig.getOrgCode()!=null&&!tumsConfig.getOrgCode().equals("")){
|
||||
map.put("orgCode",tumsConfig.getOrgCode());
|
||||
}
|
||||
baseMapper.updateUser(map);
|
||||
if(!errorMsg.equals("")){
|
||||
return Result.error(errorMsg);
|
||||
}else{
|
||||
return Result.OK("编辑用户成功!");
|
||||
}
|
||||
}else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"projectId\"").append(":").append("\"").append(tumsConfig.getTumsProjectId()).append("\",");
|
||||
sb.append("\"username\"").append(":").append("\"").append(tumsConfig.getTumsUsername()).append("\",");
|
||||
sb.append("\"password\"").append(":").append("\"").append(tumsConfig.getTumsPassword()).append("\",");
|
||||
sb.append("\"roleList\"").append(":[").append(tumsConfig.getTumsRoleId()).append("]");
|
||||
sb.append("}");
|
||||
String jsonResponse = tumsApi.addUser(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("tumsUserId",result.getStr("userId"));
|
||||
map.put("tumsUsername",result.getStr("username"));
|
||||
map.put("tumsPassword",tumsConfig.getTumsPassword());
|
||||
map.put("tumsRoleId",tumsConfig.getTumsRoleId());
|
||||
if(tumsConfig.getTumsUrl()!=null&&!tumsConfig.getTumsUrl().equals("")){
|
||||
map.put("tumsUrl",tumsConfig.getTumsUrl());
|
||||
}
|
||||
if(tumsConfig.getTumsProjectId()!=null&&!tumsConfig.getTumsProjectId().equals("")){
|
||||
map.put("tumsProjectId",tumsConfig.getTumsProjectId());
|
||||
}
|
||||
if(tumsConfig.getFtpIp()!=null&&!tumsConfig.getFtpIp().equals("")){
|
||||
map.put("ftpIp",tumsConfig.getFtpIp());
|
||||
}
|
||||
if(tumsConfig.getFtpPort()!=null&&!tumsConfig.getFtpPort().equals("")){
|
||||
map.put("ftpPort",tumsConfig.getFtpPort());
|
||||
}
|
||||
if(tumsConfig.getFtpUsername()!=null&&!tumsConfig.getFtpUsername().equals("")){
|
||||
map.put("ftpUsername",tumsConfig.getFtpUsername());
|
||||
}
|
||||
if(tumsConfig.getFtpPassword()!=null&&!tumsConfig.getFtpPassword().equals("")){
|
||||
map.put("ftpPassword",tumsConfig.getFtpPassword());
|
||||
}
|
||||
if(tumsConfig.getFtpUploadpath()!=null&&!tumsConfig.getFtpUploadpath().equals("")){
|
||||
map.put("ftpUploadpath",tumsConfig.getFtpUploadpath());
|
||||
}
|
||||
if(tumsConfig.getOrgCode()!=null&&!tumsConfig.getOrgCode().equals("")){
|
||||
map.put("orgCode",tumsConfig.getOrgCode());
|
||||
}
|
||||
baseMapper.addUser(map);
|
||||
return Result.OK("添加用户成功!");
|
||||
}else{
|
||||
if(errorCode.equals("-82400")){
|
||||
return Result.error("密码格式错误");
|
||||
}else{
|
||||
return Result.error(jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TumsApi {
|
|||
|
||||
private void initTumsConfig(){
|
||||
if(tumsConfig==null){
|
||||
tumsConfig = tumsConfigMapper.getByCode(null);
|
||||
tumsConfig = tumsConfigMapper.getByCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,4 +33,5 @@ public class TqConfig implements Serializable {
|
|||
private String authCode; //授权码
|
||||
private String randomCode; //随机字符串,签名时需要
|
||||
private String notifyUrl; //通知地址
|
||||
private String updateDate; //更新时间
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
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
|
||||
limit 1
|
||||
|
|
|
@ -8,10 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
|
@ -167,4 +164,38 @@ public class TqApi {
|
|||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Map<String, Object>> req = new ArrayList<>();
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("opr_id", HttpTool.generateOperateId());
|
||||
item.put("time_out", 0);
|
||||
item.put("must_online", true);
|
||||
item.put("retry_times", 1);
|
||||
item.put("cid", "250425201185");
|
||||
item.put("address", "250425201185");
|
||||
item.put("type", 3);
|
||||
req.add(item);
|
||||
String request_content = JSON.toJSONString(req);
|
||||
String url = "https://100.znchaobiao.com/Api_v2/ele_read";
|
||||
String notifyUrl = "https://www.focusnu.com/nursingunit101/iot/tq/api/electricityMeter/eleReadNotify";
|
||||
|
||||
// 时间戳
|
||||
String timestamp = String.valueOf(new Date().getTime()/1000);
|
||||
// 用于签名的内容
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("timestamp", timestamp);
|
||||
data.put("auth_code", "6d82b4941f64ce0db13463218b0eb1d3");
|
||||
data.put("request_content", request_content);
|
||||
data.put("notify_url", notifyUrl);
|
||||
// 获取签名
|
||||
String sign = SignTool.getSign("qU2OX8FTMzfDsNZWR47gmwANIJ",data);
|
||||
data.put("sign", sign);
|
||||
try {
|
||||
HttpTool.httpClientPost(url, data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,4 +30,5 @@ public class YiweilianConfig implements Serializable {
|
|||
private Integer id;
|
||||
private String requestUrl; //云平台系统地址
|
||||
private String clientId; //识别用户的唯一标识
|
||||
private String updateDate; //更新时间
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
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
|
||||
|
|
|
@ -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,56 @@
|
|||
package com.nu.mq.config.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("iotAsyncDQNP")
|
||||
public class DynamicQueueNameProvider {
|
||||
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
public String getSyncTumsQueueName() {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String orgCode = deptInfo.getString("code");
|
||||
if (StringUtils.isNotBlank(orgCode)) {
|
||||
return orgCode + ".tumsconfig.async";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSyncTumsKeyName() {
|
||||
return getSyncTumsQueueName();
|
||||
}
|
||||
|
||||
public String getSyncTqQueueName() {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String orgCode = deptInfo.getString("code");
|
||||
if (StringUtils.isNotBlank(orgCode)) {
|
||||
return orgCode + ".tqconfig.async";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSyncTqKeyName() {
|
||||
return getSyncTqQueueName();
|
||||
}
|
||||
|
||||
public String getSyncYiweilianQueueName() {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String orgCode = deptInfo.getString("code");
|
||||
if (StringUtils.isNotBlank(orgCode)) {
|
||||
return orgCode + ".yiweilianconfig.async";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSyncTYiweilianKeyName() {
|
||||
return getSyncYiweilianQueueName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.nu.mq.config.listener;
|
||||
|
||||
import com.nu.dto.IotTqConfigMQDto;
|
||||
import com.nu.dto.IotTumsConfigMQDto;
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tq.common.entity.TqConfig;
|
||||
import com.nu.modules.tq.common.service.ITqConfigService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TqConfigMQListener {
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
ITqConfigService tqConfigService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotAsyncDQNP.getSyncTqQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.tqconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotAsyncDQNP.getSyncTqKeyName()}"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void handleMessage_unify(IotTqConfigMQDto dto) {
|
||||
saveSysConfig(dto);
|
||||
}
|
||||
|
||||
private void saveSysConfig(IotTqConfigMQDto dto) {
|
||||
try {
|
||||
tqConfigService.removeById(dto.getId());
|
||||
TqConfig tqConfig = new TqConfig();
|
||||
BeanUtils.copyProperties(dto, tqConfig);
|
||||
tqConfigService.save(tqConfig);
|
||||
} catch (Exception e) {
|
||||
if (StringUtils.isNotBlank(dto.getLogId())) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setMessage("同步失败");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
rabbitMQUtil.sendToExchange("hldy.tqconfig", "tqconfig.async.result", statusMQDto);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getLogId())) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setMessage("同步成功");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
rabbitMQUtil.sendToExchange("hldy.tqconfig", "tqconfig.async.result", statusMQDto);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.nu.mq.config.listener;
|
||||
|
||||
import com.nu.dto.IotTumsConfigMQDto;
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TumsConfigMQListener {
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
ITumsConfigService tumsConfigService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotAsyncDQNP.getSyncTumsQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.tumsconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotAsyncDQNP.getSyncTumsKeyName()}"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void handleMessage_unify(IotTumsConfigMQDto dto) {
|
||||
saveSysConfig(dto);
|
||||
}
|
||||
|
||||
private void saveSysConfig(IotTumsConfigMQDto dto) {
|
||||
try {
|
||||
tumsConfigService.removeById(dto.getId());
|
||||
TumsConfig tumsConfig = new TumsConfig();
|
||||
BeanUtils.copyProperties(dto, tumsConfig);
|
||||
tumsConfigService.save(tumsConfig);
|
||||
} catch (Exception e) {
|
||||
if (StringUtils.isNotBlank(dto.getLogId())) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setMessage("同步失败");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
rabbitMQUtil.sendToExchange("hldy.tumsconfig", "tumsconfig.async.result", statusMQDto);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getLogId())) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setMessage("同步成功");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
rabbitMQUtil.sendToExchange("hldy.tumsconfig", "tumsconfig.async.result", statusMQDto);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.nu.mq.config.listener;
|
||||
|
||||
import com.nu.dto.IotYiweilianConfigMQDto;
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||
import com.nu.modules.yiweilian.common.service.IYiweilianConfigService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class YiweilianConfigMQListener {
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Autowired
|
||||
IYiweilianConfigService yiweilianConfigService;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{iotAsyncDQNP.getSyncYiweilianQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.yiweilianconfig", type = ExchangeTypes.DIRECT),
|
||||
key = "#{iotAsyncDQNP.getSyncTYiweilianKeyName()}"
|
||||
),
|
||||
errorHandler = "iotConfigMQErrorHandler"
|
||||
)
|
||||
public void handleMessage_unify(IotYiweilianConfigMQDto dto) {
|
||||
saveSysConfig(dto);
|
||||
}
|
||||
|
||||
private void saveSysConfig(IotYiweilianConfigMQDto dto) {
|
||||
try {
|
||||
yiweilianConfigService.removeById(dto.getId());
|
||||
YiweilianConfig yiweilianConfig = new YiweilianConfig();
|
||||
BeanUtils.copyProperties(dto, yiweilianConfig);
|
||||
yiweilianConfigService.save(yiweilianConfig);
|
||||
} catch (Exception e) {
|
||||
if (StringUtils.isNotBlank(dto.getLogId())) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setMessage("同步失败");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
rabbitMQUtil.sendToExchange("hldy.yiweilianconfig", "yiweilianconfig.async.result", statusMQDto);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getLogId())) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setMessage("同步成功");
|
||||
statusMQDto.setPrimaryKey(dto.getLogId());
|
||||
rabbitMQUtil.sendToExchange("hldy.yiweilianconfig", "yiweilianconfig.async.result", statusMQDto);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue