feat:() 新增数据处理事件
parent
c0800ce466
commit
b51d6ed389
|
@ -42,7 +42,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<LoginUser> getFirmUserInfo(String username, Long firmId, String inner) {
|
public Result<LoginUser> getFirmUserInfo(String username, Long firmId, String inner) {
|
||||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
return Result.error("公司员工登录失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class TestKafka {
|
||||||
@GetMapping("/send")
|
@GetMapping("/send")
|
||||||
public String sendMsg(){
|
public String sendMsg(){
|
||||||
JSONObject entries = new JSONObject();
|
JSONObject entries = new JSONObject();
|
||||||
entries.set("vin",VIN);
|
entries.set("VIN码",VIN);
|
||||||
entries.set("name","宝马");
|
entries.set("name","宝马");
|
||||||
String entriesString = entries.toString();
|
String entriesString = entries.toString();
|
||||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<>(TIPSY, entriesString);
|
ProducerRecord<String, String> producerRecord = new ProducerRecord<>(TIPSY, entriesString);
|
||||||
|
|
|
@ -27,10 +27,9 @@ public class AddDatabaseListener implements EventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(EventCustom event) {
|
public void onEvent(EventCustom event) {
|
||||||
log.info("数据库添加");
|
|
||||||
log.info("数据为: {}",event.getData());
|
log.info("数据为: {}",event.getData());
|
||||||
JSONObject jsonObject = event.getData();
|
JSONObject jsonObject = event.getData();
|
||||||
String vin = (String) jsonObject.get("vin");
|
String vin = (String) jsonObject.get("VIN码");
|
||||||
Map<String, Object> map = (Map<String, Object>) cacheUtil.get(vin);
|
Map<String, Object> map = (Map<String, Object>) cacheUtil.get(vin);
|
||||||
if (map != null){
|
if (map != null){
|
||||||
log.info("本地缓存数据为: {}",map);
|
log.info("本地缓存数据为: {}",map);
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.muyu.processing.listener;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.muyu.domain.resp.WarnRuleResp;
|
||||||
|
import com.muyu.processing.basic.EventCustom;
|
||||||
|
import com.muyu.processing.basic.EventListener;
|
||||||
|
import com.muyu.processing.utils.CacheUtil;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 警告规则响应事件
|
||||||
|
* @Author:杨鹏
|
||||||
|
* @Package:com.muyu.processing.listener
|
||||||
|
* @Project:cloud-vehicle
|
||||||
|
* @name:WarnRuleRespListener
|
||||||
|
* @Date:2024/10/9 18:41
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class WarnRuleRespListener implements EventListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CacheUtil cacheUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件处理
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onEvent(EventCustom event) {
|
||||||
|
// 获得数据
|
||||||
|
JSONObject jsonObject = event.getData();
|
||||||
|
// 获得VIN码
|
||||||
|
String vin = (String) jsonObject.get("VIN码");
|
||||||
|
// 获得本地缓存数据
|
||||||
|
Map<String, Object> map = (Map<String, Object>) cacheUtil.get(vin);
|
||||||
|
if (map != null){
|
||||||
|
log.info("本地缓存数据为: {}",map);
|
||||||
|
WarnRuleResp warnRuleResp = (WarnRuleResp) map.get("warnRuleResp");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(EventCustom event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue