feat():补充过程数据保存和接口

This commit is contained in:
Penknife
2025-01-10 11:42:52 +08:00
parent d2c7766624
commit a90878e251
2 changed files with 24 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package com.fizz.business.controller;
import com.fizz.business.form.WebOperateMatForm;
import com.fizz.business.mq.RabbitMQ.RabbitQueueListener;
import com.fizz.business.service.TrackService;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
@@ -38,4 +39,10 @@ public class TrackController {
return R.ok();
}
@GetMapping("/measure/list")
@ApiOperation(value = "获取测量数据list")
public R<List<String>> measureList() {
return R.ok(RabbitQueueListener.measureList);
}
}

View File

@@ -4,14 +4,20 @@ import cn.hutool.json.JSONUtil;
import com.fizz.business.constants.CommonConstants;
import com.fizz.business.constants.enums.WsTypeEnum;
import com.fizz.business.utils.WebSocketUtil;
import com.google.common.collect.Lists;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import java.util.List;
@Log4j2
@Component
public class RabbitQueueListener {
public static List<String> measureList = Lists.newArrayList();
private Double LastRolledLength = 0d;
@RabbitListener(queues = CommonConstants.RabbitMQ.RECEIVE_MODEL)
@RabbitHandler
public void onHmiMessage(String message) {
@@ -24,7 +30,17 @@ public class RabbitQueueListener {
@RabbitHandler
public void onProcDataMessage(String message) {
log.info("消费端ProcData: " + message);
Double rolledLength = Double.parseDouble(
JSONUtil.parse(message).getByPath("rolledLength").toString()
);
if(LastRolledLength==rolledLength){
return;
}
if(LastRolledLength-rolledLength>300) {
measureList = Lists.newArrayList();
}
measureList.add(message);
LastRolledLength=rolledLength;
//socket
WebSocketUtil.sendMessage(WsTypeEnum.track_measure,message);
}