feat():补充过程数据保存和接口
This commit is contained in:
@@ -2,6 +2,7 @@ package com.fizz.business.controller;
|
|||||||
|
|
||||||
|
|
||||||
import com.fizz.business.form.WebOperateMatForm;
|
import com.fizz.business.form.WebOperateMatForm;
|
||||||
|
import com.fizz.business.mq.RabbitMQ.RabbitQueueListener;
|
||||||
import com.fizz.business.service.TrackService;
|
import com.fizz.business.service.TrackService;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -38,4 +39,10 @@ public class TrackController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/measure/list")
|
||||||
|
@ApiOperation(value = "获取测量数据list")
|
||||||
|
public R<List<String>> measureList() {
|
||||||
|
return R.ok(RabbitQueueListener.measureList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,20 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import com.fizz.business.constants.CommonConstants;
|
import com.fizz.business.constants.CommonConstants;
|
||||||
import com.fizz.business.constants.enums.WsTypeEnum;
|
import com.fizz.business.constants.enums.WsTypeEnum;
|
||||||
import com.fizz.business.utils.WebSocketUtil;
|
import com.fizz.business.utils.WebSocketUtil;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
public class RabbitQueueListener {
|
public class RabbitQueueListener {
|
||||||
|
|
||||||
|
public static List<String> measureList = Lists.newArrayList();
|
||||||
|
private Double LastRolledLength = 0d;
|
||||||
@RabbitListener(queues = CommonConstants.RabbitMQ.RECEIVE_MODEL)
|
@RabbitListener(queues = CommonConstants.RabbitMQ.RECEIVE_MODEL)
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void onHmiMessage(String message) {
|
public void onHmiMessage(String message) {
|
||||||
@@ -24,7 +30,17 @@ public class RabbitQueueListener {
|
|||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void onProcDataMessage(String message) {
|
public void onProcDataMessage(String message) {
|
||||||
log.info("消费端ProcData: " + 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
|
//socket
|
||||||
WebSocketUtil.sendMessage(WsTypeEnum.track_measure,message);
|
WebSocketUtil.sendMessage(WsTypeEnum.track_measure,message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user