版本迭代
This commit is contained in:
parent
d12a283082
commit
900343db26
|
@ -1,4 +1,4 @@
|
||||||
package com.bootdo.datasend.dianxin.controller.standard;
|
package com.bootdo.datasend.dianxin.controller;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.bootdo.datasend.dianxin.controller.standard;
|
package com.bootdo.datasend.dianxin.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -27,7 +27,7 @@ public class ProducerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
// @PostConstruct
|
||||||
public String sendMessagetest() {
|
public String sendMessagetest() {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
|
@ -103,4 +103,6 @@ public class BaseHighThrowRecord {
|
||||||
*/
|
*/
|
||||||
private Long passTime;
|
private Long passTime;
|
||||||
|
|
||||||
|
private Integer isSend;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Auther: cyFeng
|
||||||
|
* @Date: 2024/11/18 14:23
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class HighThrowDto {
|
||||||
|
|
||||||
|
@JSONField(name = "requestData")
|
||||||
|
private HighThrowRequestDataDTO requestData;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class HighThrowRequestDataDTO {
|
||||||
|
@JSONField(name = "requestFlag")
|
||||||
|
private String requestFlag;
|
||||||
|
@JSONField(name = "requestDataList")
|
||||||
|
private List<HighThrowRequestDataListDTO> requestDataList;
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class HighThrowRequestDataListDTO {
|
||||||
|
@JSONField(name = "gatewaySN")
|
||||||
|
private String gatewaySN;
|
||||||
|
@JSONField(name = "warnType")
|
||||||
|
private String warnType;
|
||||||
|
@JSONField(name = "deviceType")
|
||||||
|
private String deviceType;
|
||||||
|
@JSONField(name = "deviceSN")
|
||||||
|
private String deviceSN;
|
||||||
|
@JSONField(name = "detailSN")
|
||||||
|
private String detailSN;
|
||||||
|
|
||||||
|
@JSONField(name = "eventName")
|
||||||
|
private String eventName;
|
||||||
|
@JSONField(name = "warnTime")
|
||||||
|
private String warnTime;
|
||||||
|
@JSONField(name = "eventDescribe")
|
||||||
|
private String eventDescribe;
|
||||||
|
@JSONField(name = "globalPicBase64")
|
||||||
|
private String globalPicBase64;
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ public class MessageConsumer {
|
||||||
//测试消费kafka
|
//测试消费kafka
|
||||||
// 监听队列 "myQueue"
|
// 监听队列 "myQueue"
|
||||||
// @RabbitListener(queues = "myQueue")
|
// @RabbitListener(queues = "myQueue")
|
||||||
public void receiveMessage(JSONObject message) {
|
public void receiveMessage(String message) {
|
||||||
try {
|
try {
|
||||||
// 处理接收到的消息
|
// 处理接收到的消息
|
||||||
logger.info("Received message: " + message.toString());
|
logger.info("Received message: " + message.toString());
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.bootdo.datasend.dianxin.task;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.BaseHighThrowRecord;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.dto.HighThrowDto;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.dto.HighThrowRequestDataDTO;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.dto.HighThrowRequestDataListDTO;
|
||||||
|
import com.bootdo.datasend.dianxin.service.BaseHighThrowRecordService;
|
||||||
|
import com.bootdo.util.Base64Util;
|
||||||
|
import com.bootdo.util.StringKit;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class StandardTask {
|
||||||
|
|
||||||
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
private final BaseHighThrowRecordService highThrowRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 设备发送
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0/5 * * * * ? ")
|
||||||
|
public void sendDevice() {
|
||||||
|
|
||||||
|
//获取高抛记录
|
||||||
|
List<BaseHighThrowRecord> highThrowRecords = highThrowRecordService.list(new QueryWrapper<BaseHighThrowRecord>()
|
||||||
|
.eq("is_send","0")
|
||||||
|
);
|
||||||
|
|
||||||
|
for (BaseHighThrowRecord h:highThrowRecords){
|
||||||
|
|
||||||
|
HighThrowDto dto = new HighThrowDto();
|
||||||
|
|
||||||
|
HighThrowRequestDataDTO dataDTO = new HighThrowRequestDataDTO();
|
||||||
|
dataDTO.setRequestFlag("1");
|
||||||
|
|
||||||
|
HighThrowRequestDataListDTO requestDataListDTO = new HighThrowRequestDataListDTO();
|
||||||
|
requestDataListDTO.setGatewaySN(h.getGeminiSn());
|
||||||
|
requestDataListDTO.setWarnType("1001");
|
||||||
|
requestDataListDTO.setDeviceType("302");
|
||||||
|
requestDataListDTO.setDeviceSN(h.getGbsChannelNo());
|
||||||
|
requestDataListDTO.setEventName("高抛报警");
|
||||||
|
requestDataListDTO.setWarnTime(StringKit.toString(h.getPassTime()));
|
||||||
|
requestDataListDTO.setGlobalPicBase64(Base64Util.getBase64ByUrl(h.getHighThrowImgurl()));
|
||||||
|
List<HighThrowRequestDataListDTO> list = new ArrayList<>();
|
||||||
|
list.add(requestDataListDTO);
|
||||||
|
dataDTO.setRequestDataList(list);
|
||||||
|
dto.setRequestData(dataDTO);
|
||||||
|
|
||||||
|
//循环发送mq
|
||||||
|
boolean b=sendHighThrowMq(dto);
|
||||||
|
if(b){
|
||||||
|
h.setIsSend(1);
|
||||||
|
highThrowRecordService.saveOrUpdate(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean sendHighThrowMq(HighThrowDto bean) {
|
||||||
|
try {
|
||||||
|
rabbitTemplate.convertAndSend("warnrecord", "routing.key.warnrecord", JSON.toJSONString( bean));
|
||||||
|
}catch (Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,10 @@ import javax.imageio.ImageIO;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
public class Base64Util {
|
public class Base64Util {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Base64Util.class);
|
private static final Logger logger = LoggerFactory.getLogger(Base64Util.class);
|
||||||
|
@ -73,4 +76,51 @@ public class Base64Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 功能描述: 获取网络地址的base64
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static String getBase64ByUrl(String imageUrl) {
|
||||||
|
try {
|
||||||
|
// 图片 URL 地址
|
||||||
|
// String imageUrl = "http://221.229.107.118:30521/box-im/image/20241117/1731789048895.png";
|
||||||
|
|
||||||
|
// 创建 URL 对象
|
||||||
|
URL url = new URL(imageUrl);
|
||||||
|
|
||||||
|
// 打开 HTTP 连接
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
|
||||||
|
// 获取输入流
|
||||||
|
InputStream inputStream = connection.getInputStream();
|
||||||
|
|
||||||
|
// 转换图片 InputStream 为字节数组
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
byteArrayOutputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取字节数组
|
||||||
|
byte[] imageBytes = byteArrayOutputStream.toByteArray();
|
||||||
|
|
||||||
|
// 将字节数组转换为 Base64 字符串
|
||||||
|
String base64String = Base64.getEncoder().encodeToString(imageBytes);
|
||||||
|
|
||||||
|
// 输出 Base64 字符串
|
||||||
|
// System.out.println("Base64 String: " + base64String);
|
||||||
|
|
||||||
|
// 关闭流
|
||||||
|
inputStream.close();
|
||||||
|
byteArrayOutputStream.close();
|
||||||
|
return base64String;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,19 @@ spring:
|
||||||
hibernate:
|
hibernate:
|
||||||
format_sql: true
|
format_sql: true
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: 110.1.200.11
|
host: 221.229.107.118
|
||||||
port: 19000
|
port: 30529
|
||||||
username: root
|
username: root
|
||||||
password: 'sm@rtC@m!n23ty'
|
password: 'sm@rtC@m!n23ty'
|
||||||
dynamic: true
|
dynamic: true
|
||||||
|
# rabbitmq:
|
||||||
|
# host: 110.1.200.11
|
||||||
|
# port: 19000
|
||||||
|
# username: root
|
||||||
|
# password: 'sm@rtC@m!n23ty'
|
||||||
|
# dynamic: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#mybatis:
|
#mybatis:
|
||||||
# type-aliases-package: com.bootdo.pretreatment.*.entity
|
# type-aliases-package: com.bootdo.pretreatment.*.entity
|
||||||
|
|
Loading…
Reference in New Issue