feat():RabbitMQ配置及轧辊上线发送
This commit is contained in:
@@ -85,6 +85,11 @@
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.fizz.business.config;
|
||||
|
||||
import com.fizz.business.constants.CommonConstants;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RabbitConfig {
|
||||
@Bean
|
||||
public Queue receiveModelQueue() {
|
||||
return new Queue(CommonConstants.RabbitMQ.RECEIVE_MODEL, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue sendModelQueue() {
|
||||
return new Queue(CommonConstants.RabbitMQ.SEND_MODEL, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,4 +21,10 @@ public class CommonConstants {
|
||||
|
||||
public static final String TOPIC_COIL_DEFECT = "ZG-COIL-DEFECT";
|
||||
}
|
||||
|
||||
public class RabbitMQ {
|
||||
public static final String RECEIVE_MODEL = "plateform.hmi.queue";
|
||||
public static final String SEND_MODEL = "plateform.modpt.queue";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RollerController {
|
||||
public R<String> backupRoll(@RequestBody List<ReadyRollDataVO> rollList) {
|
||||
String msg = rollDataService.BackupRoll(rollList);
|
||||
if(ObjectUtil.isEmpty(msg)){
|
||||
return R.ok();
|
||||
return R.ok("处理成功");
|
||||
}
|
||||
else{
|
||||
return R.fail(msg);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
11111
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.fizz.business.mq.RabbitMQ;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Log4j2
|
||||
@Component
|
||||
public class RabbitQueueListener {
|
||||
@RabbitListener(queues = "plateform.hmi.queue")
|
||||
@RabbitHandler
|
||||
public void onProcDataMessage(String message) {
|
||||
log.info("消费端ProcData: " + message);
|
||||
|
||||
//socket
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package com.fizz.business.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fizz.business.constants.CommonConstants;
|
||||
import com.fizz.business.constants.enums.RollerPositionEnum;
|
||||
import com.fizz.business.constants.enums.RollerTypeEnum;
|
||||
import com.fizz.business.domain.PlantConfig;
|
||||
@@ -20,13 +20,17 @@ import com.fizz.business.vo.ReadyRollDataVO;
|
||||
|
||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.amqp.core.MessagePropertiesBuilder;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -43,6 +47,9 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> i
|
||||
@Resource
|
||||
RollHistoryService rollHistoryService;
|
||||
|
||||
@Resource
|
||||
RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Override
|
||||
public List<RollData> getList(String position,String type,String status) {
|
||||
QueryWrapper<RollData> queryWrapper = new QueryWrapper<>();
|
||||
@@ -253,6 +260,15 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> i
|
||||
});
|
||||
this.updateBatchById(changeRollList);
|
||||
rollHistoryService.saveBatch(rollHistoryList);
|
||||
|
||||
//发送MQ
|
||||
MessageProperties props = MessagePropertiesBuilder.newInstance()
|
||||
.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
|
||||
.setMessageId("ROLL_CHANGE")
|
||||
.build();
|
||||
rabbitTemplate.send(CommonConstants.RabbitMQ.SEND_MODEL,new Message("ROLL_CHANGE".getBytes(StandardCharsets.UTF_8),props));
|
||||
|
||||
|
||||
return getOnlineRollList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user