Commit 6cb7fb76 authored by suhuiguang's avatar suhuiguang

1.openapi发出消息,气瓶服务订阅消息进行业务处理

2.气瓶问题模块订阅消息创建充装检查不合格类型的问题
parent ac832c1d
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.cylinder.biz.event.listener;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderQuestionInfoDto;
......@@ -63,6 +64,7 @@ public class CylinderQuestionCreateEventListener implements ApplicationListener<
@Override
public void onApplicationEvent(CylinderQuestionCreateEvent event) {
log.info("2.收到问题创建消息:{}", JSON.toJSONString(event.getCylinderQuestionInfoDto()));
// 按照一定的规则将不同的问题对象放到不同的队列里,保证多线程不会同时操作不同的问题对象数据,减少了线程的冲突,提高执行效率
int queueIndex = Math.abs(event.getCylinderQuestionInfoDto().getQuestionObjectId().hashCode()) % threadNumber;
hashCodeBlockingQueues.get(queueIndex).add(event.getCylinderQuestionInfoDto());
......@@ -117,6 +119,7 @@ public class CylinderQuestionCreateEventListener implements ApplicationListener<
return cylinderQuestionInfo;
}).collect(Collectors.toList());
cylinderQuestionInfoService.saveBatch(cylinderQuestionInfos);
log.info("3.问题入库创建成功:{}", JSON.toJSONString(cylinderQuestionInfos));
}
private String getQuestionObjectName(String sequenceCode, String appId) {
......
package com.yeejoin.amos.boot.module.cylinder.biz.listener;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderQuestionInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.enums.QuestionTypeEnum;
import com.yeejoin.amos.boot.module.cylinder.biz.event.CylinderQuestionCreateEvent;
......@@ -16,6 +16,7 @@ import org.typroject.tyboot.component.emq.EmqxListener;
import javax.annotation.PostConstruct;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -95,9 +96,9 @@ public class CylinderFillingInsertEventListener extends EmqxListener {
@Override
public void processMessage(String topic, MqttMessage message) {
log.info("收到充装信息插入消息:{}", JSONObject.toJSONString(message));
String msg = new String(message.getPayload(), StandardCharsets.UTF_8);
CylinderFillingRecordDto cylinderFillingRecordDto = JSONObject.parseObject(msg, CylinderFillingRecordDto.class);
blockingQueue.add(cylinderFillingRecordDto);
log.info("1.收到充装信息插入消息:{}", msg);
List<CylinderFillingRecordDto> cylinderFillingRecordDtos = JSONArray.parseArray(msg, CylinderFillingRecordDto.class);
blockingQueue.addAll(cylinderFillingRecordDtos);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment