feat:() 新增数据处理事件

dev.processing.admire
晨哀 2024-10-09 18:52:30 +08:00
parent c0800ce466
commit b51d6ed389
4 changed files with 53 additions and 4 deletions

View File

@ -42,7 +42,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
@Override
public Result<LoginUser> getFirmUserInfo(String username, Long firmId, String inner) {
return Result.error("注册用户失败:" + throwable.getMessage());
return Result.error("公司员工登录失败:" + throwable.getMessage());
}
};
}

View File

@ -47,7 +47,7 @@ public class TestKafka {
@GetMapping("/send")
public String sendMsg(){
JSONObject entries = new JSONObject();
entries.set("vin",VIN);
entries.set("VIN码",VIN);
entries.set("name","宝马");
String entriesString = entries.toString();
ProducerRecord<String, String> producerRecord = new ProducerRecord<>(TIPSY, entriesString);

View File

@ -27,10 +27,9 @@ public class AddDatabaseListener implements EventListener {
@Override
public void onEvent(EventCustom event) {
log.info("数据库添加");
log.info("数据为: {}",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);
if (map != null){
log.info("本地缓存数据为: {}",map);

View File

@ -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
* @Packagecom.muyu.processing.listener
* @Projectcloud-vehicle
* @nameWarnRuleRespListener
* @Date2024/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) {
}
}