feat: 优化代码
parent
db1368379e
commit
7d77386b3a
|
@ -17,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,14 +17,14 @@ public interface AnalyzeEventContents {
|
|||
/**
|
||||
* 电子围栏
|
||||
*/
|
||||
static final String ELECTRONIC_FENCE = "electronic-fence";
|
||||
static final String ELECTRONIC_FENCE = "electronic_fence";
|
||||
/**
|
||||
* 实时数据
|
||||
*/
|
||||
static final String REAL_TIME_DATA = "real-time-data";
|
||||
static final String REAL_TIME_DATA = "real_time_data";
|
||||
|
||||
/**
|
||||
* 存储
|
||||
*/
|
||||
static final String STORED_EVENT = "stored-event";
|
||||
static final String STORED_EVENT = "stored_event";
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -76,12 +76,6 @@ public class ModelsKafkaMessage {
|
|||
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
// return message;
|
||||
// });
|
||||
|
||||
try {
|
||||
sleep(100);
|
||||
} catch (Exception e) {
|
||||
throw new VehicleException("睡眠失败" + e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||
import com.couplet.analyze.msg.contents.StateConstant;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
|
@ -26,7 +27,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @Date: 2024/4/2
|
||||
* @Description: 故障事件
|
||||
*/
|
||||
@Service("breakdown")
|
||||
@Service(AnalyzeEventContents.BREAKDOWN)
|
||||
public class BreakdownServiceImpl extends KeyExpirationEventMessageListener implements IncidentService {
|
||||
|
||||
/**
|
||||
|
@ -93,7 +94,7 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "breakdown";
|
||||
return AnalyzeEventContents.BREAKDOWN;
|
||||
}
|
||||
|
||||
public void scheduledRedis() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.text.Convert;
|
||||
|
@ -22,7 +23,7 @@ import java.util.Set;
|
|||
* @Date: 2024/4/2
|
||||
* @Description: 电子围栏事件服务实现类
|
||||
*/
|
||||
@Service("electronic_fence")
|
||||
@Service(AnalyzeEventContents.ELECTRONIC_FENCE)
|
||||
@Log4j2
|
||||
public class ElectronicFenceServiceImpl implements IncidentService {
|
||||
|
||||
|
@ -86,7 +87,7 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "electronic-fence";
|
||||
return AnalyzeEventContents.ELECTRONIC_FENCE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.mapper.IncidentMapper;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
|
@ -18,7 +19,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @Date: 2024/4/2
|
||||
* @Description: 实时数据事件
|
||||
*/
|
||||
@Service("real_time_data")
|
||||
@Service(AnalyzeEventContents.REAL_TIME_DATA)
|
||||
@Log4j2
|
||||
public class RealTimeDataServiceImpl implements IncidentService {
|
||||
|
||||
|
@ -37,7 +38,8 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
* @param coupletMsgData
|
||||
*/
|
||||
@Override
|
||||
public void incident(CoupletMsgData coupletMsgData) {
|
||||
public synchronized void incident(CoupletMsgData coupletMsgData) {
|
||||
|
||||
|
||||
log.info("实时数据事件开始.....");
|
||||
|
||||
|
@ -69,6 +71,6 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "real-time-data";
|
||||
return AnalyzeEventContents.REAL_TIME_DATA;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.mapper.IncidentMapper;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
|
@ -12,7 +13,7 @@ import org.springframework.stereotype.Service;
|
|||
* @Date: 2024/4/2
|
||||
* @Description: 事件存储服务
|
||||
*/
|
||||
@Service("stored_event")
|
||||
@Service(AnalyzeEventContents.STORED_EVENT)
|
||||
@Log4j2
|
||||
public class StoredEventServiceImpl implements IncidentService {
|
||||
@Autowired
|
||||
|
@ -36,6 +37,6 @@ public class StoredEventServiceImpl implements IncidentService {
|
|||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stored-event";
|
||||
return AnalyzeEventContents.STORED_EVENT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
@ -50,9 +48,3 @@ logging:
|
|||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
# RabbitMQ配置
|
||||
mq:
|
||||
queueName: queue
|
||||
exchangeName: exchange
|
||||
routingKey: routingKey
|
||||
|
|
|
@ -16,11 +16,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
@ -38,7 +36,7 @@ mqtt:
|
|||
# broker: mqtt://115.159.47.13:1883
|
||||
username:
|
||||
password:
|
||||
clientId: liuyunhu
|
||||
clientId: xiaoYao
|
||||
qos: 0
|
||||
topic: liuyunhu
|
||||
topic: xiaoYao
|
||||
|
||||
|
|
Loading…
Reference in New Issue