Merge remote-tracking branch 'origin/master'
# Conflicts: # cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEdDataPO.java # cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java
This commit is contained in:
@@ -27,4 +27,8 @@ public interface DeviceMessageFeignClient {
|
||||
@ApiOperation("根据事件类型和用户id查询打开推送的用户信息")
|
||||
HttpResult<List<User>> getSendUserByType(@RequestBody DeviceMessageParam param);
|
||||
|
||||
@PostMapping("/getLineInfo")
|
||||
@ApiOperation("获取监测点信息")
|
||||
HttpResult<String> getLineInfo(@RequestParam("id") String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.SmsSendClientFallbackFactory;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/sms", fallbackFactory = SmsSendClientFallbackFactory.class,contextId = "sms")
|
||||
public interface SmsSendFeignClient {
|
||||
|
||||
@PostMapping("/send/simple")
|
||||
@ApiOperation("发送短信(简化参数)")
|
||||
HttpResult<String> sendSmsSimple(@RequestParam("receiver") String receiver
|
||||
, @RequestParam("content") String content
|
||||
, @RequestParam("messageType") String messageType);
|
||||
|
||||
}
|
||||
@@ -39,6 +39,12 @@ public class DeviceMessageClientFallbackFactory implements FallbackFactory<Devic
|
||||
log.error("{}异常,降级处理,异常为:{}","根据事件类型和用户id查询打开推送的用户信息数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> getLineInfo(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取监测点信息数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.SmsSendFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SmsSendClientFallbackFactory implements FallbackFactory<SmsSendFeignClient> {
|
||||
@Override
|
||||
public SmsSendFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SmsSendFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> sendSmsSimple(String receiver, String content, String messageType) {
|
||||
log.error("{}异常,降级处理,异常为:{}","发送短信(简化参数)数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-03-31
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统凭证请求 DTO
|
||||
*
|
||||
* @author msgpush
|
||||
*/
|
||||
@Data
|
||||
public class CredentialReqDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 上游系统名称
|
||||
*/
|
||||
@NotEmpty(message = "上游系统名称不能为空")
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
* 密钥(用于生成凭证)
|
||||
*/
|
||||
@NotEmpty(message = "密钥不能为空")
|
||||
private String secretKey;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class SendResult implements Serializable {
|
||||
|
||||
private final boolean success;
|
||||
private final String messageId;
|
||||
private final String failReason;
|
||||
private final boolean isTimeOut;
|
||||
private final boolean unauthorized;
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class CsEdDataAuditParm {
|
||||
private String versionType;
|
||||
|
||||
@ApiModelProperty(value = "crc信息")
|
||||
private String crcInfo;
|
||||
private String crc;
|
||||
@ApiModelProperty(value="0:删除 1:正常")
|
||||
private String status;
|
||||
@ApiModelProperty(value = ".bin文件")
|
||||
|
||||
@@ -88,9 +88,11 @@ public class CsEdDataPO extends BaseEntity {
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* crc校验
|
||||
* crc文件校验码
|
||||
*/
|
||||
@TableField(value = "crc")
|
||||
private String crc;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_sms_send_record")
|
||||
public class CsSmsSendRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
private String receiver;
|
||||
|
||||
private String content;
|
||||
|
||||
private String messageType;
|
||||
|
||||
private String credentialToken;
|
||||
|
||||
private Integer sendStatus;
|
||||
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String failReason;
|
||||
|
||||
private Integer retryCount;
|
||||
|
||||
private Integer maxRetry;
|
||||
|
||||
private Long responseTime;
|
||||
|
||||
private LocalDateTime sendTime;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import cn.hutool.core.lang.RegexPool;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-02-27
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "管理后台 - 消息记录发送 Request VO")
|
||||
public class MessageRecordReqVO {
|
||||
|
||||
private String channel;
|
||||
|
||||
@Schema(description = "消息类型", example = "verify_code/order_notify/marketing/system_notify")
|
||||
@NotBlank(message = "消息类型不能为空")
|
||||
private String messageType;
|
||||
|
||||
@Schema(description = "接收者")
|
||||
@NotBlank(message = "接收者不能为空")
|
||||
@Pattern(regexp = RegexPool.EMAIL + "|" + RegexPool.MOBILE, message = "必须是有效的邮箱或手机号格式")
|
||||
private String receiver;
|
||||
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "消息内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "模板编码")
|
||||
private String templateCode;
|
||||
|
||||
@Schema(description = "模板参数")
|
||||
private String templateParams;
|
||||
}
|
||||
@@ -1,74 +1,74 @@
|
||||
package com.njcn.csdevice.utils;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/8/2 13:41【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public class MqttTest {
|
||||
private static final String MQTT_BROKER = "tcp://192.168.1.13:1883";
|
||||
private static final String MQTT_TOPIC = "file/upload";
|
||||
private static final String FILE_PATH = "C:\\Users\\无名\\Desktop\\111.json"; // Replace with the path to your file
|
||||
|
||||
public static void main(String[] args) {
|
||||
MqttClient mqttClient = null;
|
||||
try {
|
||||
// Connect to the MQTT broker
|
||||
mqttClient = new MqttClient(MQTT_BROKER, MqttClient.generateClientId());
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
connOpts.setUserName("t_user");
|
||||
connOpts.setPassword("njcnpqs".toCharArray());
|
||||
|
||||
mqttClient.connect(connOpts);
|
||||
|
||||
// Read the file
|
||||
File file = new File(FILE_PATH);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
byte[] fileContent = new byte[(int) file.length()];
|
||||
fis.read(fileContent);
|
||||
fis.close();
|
||||
|
||||
// Create a new MQTT message
|
||||
MqttMessage message = new MqttMessage(fileContent);
|
||||
|
||||
// Set QoS level and retain flag as per your requirement
|
||||
message.setQos(1);
|
||||
// message.setRetained(false);
|
||||
|
||||
// Record the start time
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// Publish the message to the MQTT topic
|
||||
mqttClient.publish(MQTT_TOPIC, message);
|
||||
|
||||
// Record the end time
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
System.out.println("File published successfully!");
|
||||
System.out.println("Time taken: " + (endTime - startTime) + " ms");
|
||||
} catch (MqttException | IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// Disconnect from the MQTT broker
|
||||
if (mqttClient != null && mqttClient.isConnected()) {
|
||||
try {
|
||||
mqttClient.disconnect();
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.csdevice.utils;
|
||||
//
|
||||
//import org.eclipse.paho.client.mqttv3.*;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.FileInputStream;
|
||||
//import java.io.FileOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.nio.file.Files;
|
||||
//import java.nio.file.Paths;
|
||||
//
|
||||
///**
|
||||
// * Description:
|
||||
// * Date: 2023/8/2 13:41【需求编号】
|
||||
// *
|
||||
// * @author clam
|
||||
// * @version V1.0.0
|
||||
// */
|
||||
//public class MqttTest {
|
||||
// private static final String MQTT_BROKER = "tcp://192.168.1.13:1883";
|
||||
// private static final String MQTT_TOPIC = "file/upload";
|
||||
// private static final String FILE_PATH = "C:\\Users\\无名\\Desktop\\111.json"; // Replace with the path to your file
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// MqttClient mqttClient = null;
|
||||
// try {
|
||||
// // Connect to the MQTT broker
|
||||
// mqttClient = new MqttClient(MQTT_BROKER, MqttClient.generateClientId());
|
||||
// MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
// connOpts.setUserName("t_user");
|
||||
// connOpts.setPassword("njcnpqs".toCharArray());
|
||||
//
|
||||
// mqttClient.connect(connOpts);
|
||||
//
|
||||
// // Read the file
|
||||
// File file = new File(FILE_PATH);
|
||||
// FileInputStream fis = new FileInputStream(file);
|
||||
// byte[] fileContent = new byte[(int) file.length()];
|
||||
// fis.read(fileContent);
|
||||
// fis.close();
|
||||
//
|
||||
// // Create a new MQTT message
|
||||
// MqttMessage message = new MqttMessage(fileContent);
|
||||
//
|
||||
// // Set QoS level and retain flag as per your requirement
|
||||
// message.setQos(1);
|
||||
//// message.setRetained(false);
|
||||
//
|
||||
// // Record the start time
|
||||
// long startTime = System.currentTimeMillis();
|
||||
//
|
||||
// // Publish the message to the MQTT topic
|
||||
// mqttClient.publish(MQTT_TOPIC, message);
|
||||
//
|
||||
// // Record the end time
|
||||
// long endTime = System.currentTimeMillis();
|
||||
//
|
||||
// System.out.println("File published successfully!");
|
||||
// System.out.println("Time taken: " + (endTime - startTime) + " ms");
|
||||
// } catch (MqttException | IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// // Disconnect from the MQTT broker
|
||||
// if (mqttClient != null && mqttClient.isConnected()) {
|
||||
// try {
|
||||
// mqttClient.disconnect();
|
||||
// } catch (MqttException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user