diff --git a/business/pom.xml b/business/pom.xml index 263f2ae..eff6da5 100644 --- a/business/pom.xml +++ b/business/pom.xml @@ -85,6 +85,11 @@ 2.1.1 + + org.springframework.boot + spring-boot-starter-amqp + + com.alibaba easyexcel diff --git a/business/src/main/java/com/fizz/business/config/RabbitConfig.java b/business/src/main/java/com/fizz/business/config/RabbitConfig.java new file mode 100644 index 0000000..5d14e86 --- /dev/null +++ b/business/src/main/java/com/fizz/business/config/RabbitConfig.java @@ -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); + } + +} \ No newline at end of file diff --git a/business/src/main/java/com/fizz/business/constants/CommonConstants.java b/business/src/main/java/com/fizz/business/constants/CommonConstants.java index 74b2786..6f79e8e 100644 --- a/business/src/main/java/com/fizz/business/constants/CommonConstants.java +++ b/business/src/main/java/com/fizz/business/constants/CommonConstants.java @@ -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"; + + } } diff --git a/business/src/main/java/com/fizz/business/controller/RollerController.java b/business/src/main/java/com/fizz/business/controller/RollerController.java index d9bd792..a0f2909 100644 --- a/business/src/main/java/com/fizz/business/controller/RollerController.java +++ b/business/src/main/java/com/fizz/business/controller/RollerController.java @@ -54,7 +54,7 @@ public class RollerController { public R backupRoll(@RequestBody List rollList) { String msg = rollDataService.BackupRoll(rollList); if(ObjectUtil.isEmpty(msg)){ - return R.ok(); + return R.ok("处理成功"); } else{ return R.fail(msg); diff --git a/business/src/main/java/com/fizz/business/mq/10086.txt b/business/src/main/java/com/fizz/business/mq/10086.txt deleted file mode 100644 index 56b6510..0000000 --- a/business/src/main/java/com/fizz/business/mq/10086.txt +++ /dev/null @@ -1 +0,0 @@ -11111 \ No newline at end of file diff --git a/business/src/main/java/com/fizz/business/mq/RabbitMQ/RabbitQueueListener.java b/business/src/main/java/com/fizz/business/mq/RabbitMQ/RabbitQueueListener.java new file mode 100644 index 0000000..28a6af2 --- /dev/null +++ b/business/src/main/java/com/fizz/business/mq/RabbitMQ/RabbitQueueListener.java @@ -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 + } +} \ No newline at end of file diff --git a/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java b/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java index ef5a7a3..5497fd5 100644 --- a/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java +++ b/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java @@ -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 i @Resource RollHistoryService rollHistoryService; + @Resource + RabbitTemplate rabbitTemplate; + @Override public List getList(String position,String type,String status) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -253,6 +260,15 @@ public class RollDataServiceImpl extends ServiceImpl 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(); } diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 97fd464..3855b70 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -74,7 +74,7 @@ spring: # 数据库索引 database: 0 # 密码 abcd1234 fe2b3cef78b74d3692909bdcbdf46331 - password: fe2b3cef78b74d3692909bdcbdf46331 + password: #password: # 连接超时时间 timeout: 10s @@ -89,6 +89,13 @@ spring: # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms + rabbitmq: + username: admin + password: admin + virtual-host: / + host: localhost + port: 5672 + # token配置 token: # 令牌自定义标识 @@ -129,10 +136,10 @@ xss: # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* -rocketmq: - name-server: 127.0.0.1:9876 - producer: - group: test +#rocketmq: + #name-server: 127.0.0.1:9876 + #producer: + #group: test # Knife4j配置 knife4j: