Commit baeda4ea authored by duanruiming's avatar duanruiming

[add] 依赖优化,删除无用模块

parent c2ab7dd2
......@@ -29,7 +29,6 @@
<module>signal-control-service</module>
<module>signal-optimize-service</module>
<module>signal-feign-service</module>
<module>signal-datacenter-service</module>
<module>wj-common</module>
<module>wj-databus</module>
<module>wj-identity</module>
......
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
This diff is collapsed.
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>1.0</id>
<formats>
<format>tar.gz</format>
<format>dir</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- for bin -->
<fileSet>
<directory>src/main/bin</directory>
<includes>
<include>*.*</include>
</includes>
<directoryMode>775</directoryMode>
<outputDirectory>bin/</outputDirectory>
</fileSet>
<!-- for configs -->
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>*.yml</include>
<include>*.xml</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
<!-- for jar -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
<!-- for lib -->
<dependencySets>
<dependencySet>
<outputDirectory>lib/</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>${groupId}:${artifactId}</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
package net.wanji.datacenter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication(scanBasePackages = {"net.wanji.datacenter", "net.wanji.common"})
@MapperScan(basePackages = {"net.wanji.datacenter.mapper", "net.wanji.databus.dao.mapper"})
@EnableTransactionManagement
@EnableScheduling
@EnableAsync
public class DataCenterApplication {
public static void main(String[] args) {
SpringApplication.run(DataCenterApplication.class, args);
}
}
package net.wanji.datacenter.cache;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.spring.ServiceBeanContext;
import net.wanji.datacenter.service.DataProcessService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author duanruiming
* @date 2023/03/10 14:04
*/
@Component
@Slf4j
public class DataProcessServiceRegistrator implements CommandLineRunner {
private final Map<String, DataProcessService> dataProcessServiceRegistor = new HashMap<>();
/**
* 获取注册器
* key:主题名/类名,value: bean
*
* @return
*/
public Map<String, DataProcessService> getDataProcessServiceRegistor() {
return dataProcessServiceRegistor;
}
@Override
public void run(String... args) throws Exception {
Map<String, DataProcessService> map = ServiceBeanContext.getInterfaceBeanMap(DataProcessService.class);
if (!map.isEmpty()) {
dataProcessServiceRegistor.putAll(map);
} else {
log.error("初始化数据处理注册器失败");
}
}
}
package net.wanji.datacenter.kafka;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.StringUtils;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.listener.KafkaListenerErrorHandler;
import org.springframework.kafka.listener.ListenerExecutionFailedException;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author duanruiming
* @date 2023/03/09 16:03
*/
@Component
@Slf4j
public class ConsumerHandler implements KafkaListenerErrorHandler {
/**
* kafka数据缓存
* key:topic value:data
*/
private static final Map<String, String> lanePeriodicDataMap = new ConcurrentHashMap<>();
/**
* 通过消息主题获取消息信息
*
* @param topic
* @return
*/
public String getTopicMessage(String topic) {
if (StringUtils.isNotBlank(topic) && !lanePeriodicDataMap.isEmpty()) {
return lanePeriodicDataMap.get(topic);
}
return null;
}
/**
* 通过主题移除缓存中消息
*
* @param topic
*/
public void removeTopicMessage(String topic) {
lanePeriodicDataMap.remove(topic);
}
@KafkaListener(topics = {"JN040001LanePeriodicData"})
public void receiveLanePeriodicData(ConsumerRecord<Object, Object> record, Acknowledgment acknowledgment) {
log.info("收到kafka消息,消息主题:" + record.topic());
log.info("收到kafka消息,消息内容:" + record.value());
lanePeriodicDataMap.put(record.topic(), String.valueOf(record.value()));
acknowledgment.acknowledge();
}
@Override
@NonNull
public Object handleError(Message<?> message, ListenerExecutionFailedException e) {
return new Object();
}
@Override
@NonNull
public Object handleError(Message<?> message, ListenerExecutionFailedException exception, Consumer<?, ?> consumer) {
String errorMessage = String.format("监听主题:%s,消费者详情:%s,异常信息:%s,消息详情:%s",
consumer.listTopics(), consumer.groupMetadata(), exception, message);
log.error(errorMessage);
return KafkaListenerErrorHandler.super.handleError(message, exception, consumer);
}
}
package net.wanji.datacenter.pojo.convert;
import net.wanji.databus.po.*;
import net.wanji.datacenter.pojo.dto.LanePeriodicDataDTO;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* @author duanruiming
* @date 2023/03/11 14:04
*/
@SuppressWarnings("all")
@Component
public class LanePeriodicDataEventListConvert {
public CrossDataRealtimePO convert2CrossDataRealTimePO(LanePeriodicDataDTO.EventList eventList, CrossBaseLaneInfoPO laneInfoPO) {
String id = laneInfoPO.getId();
String crossId = laneInfoPO.getCrossId();
// todo 路口状态
int trafficFlow = eventList.getTrafficFlow();
double meanV = eventList.getMeanV();
double staticQueueLengthMax = eventList.getStaticQueueLengthMax();
double stopTimes = eventList.getMeanStopsNumber();
double meanDelay = eventList.getMeanDelay();
Integer meanDelayInt = Double.valueOf(meanDelay).intValue();
double laneSaturation = eventList.getLaneSaturation();
Date now = new Date();
int batchTime = (int)now.getTime();
String dir = String.valueOf(laneInfoPO.getDir());
CrossDataRealtimePO crossDataRealTimePO = new CrossDataRealtimePO();
crossDataRealTimePO.setCrossId(crossId);
crossDataRealTimePO.setStatus(0000); // 路口状态
crossDataRealTimePO.setType(1); // 1常规 2异常
crossDataRealTimePO.setStartTime(now);
crossDataRealTimePO.setDuration(5); // todo 通过第二批次判断
crossDataRealTimePO.setIsUnbalance(0);
crossDataRealTimePO.setUnbalanceIndex(1.0);
crossDataRealTimePO.setUnbalanceDirs(dir);
crossDataRealTimePO.setIsCongestion(0);
crossDataRealTimePO.setCongestionIndex(1.0);
crossDataRealTimePO.setCongestionDirs(dir);
crossDataRealTimePO.setIsSpillover(0);
crossDataRealTimePO.setSpilloverIndex(1.0);
crossDataRealTimePO.setSpilloverDirs(dir);
crossDataRealTimePO.setTrafficIndex(1.0);// 交通指数
crossDataRealTimePO.setFlow(trafficFlow);
crossDataRealTimePO.setFlowRate(Double.valueOf(trafficFlow / 5 * 60));
crossDataRealTimePO.setSpeed(meanV);
crossDataRealTimePO.setQueueLength(staticQueueLengthMax);
crossDataRealTimePO.setStopTimes(stopTimes);
crossDataRealTimePO.setDelayTime(meanDelayInt);
crossDataRealTimePO.setSturation(laneSaturation);
crossDataRealTimePO.setBatchTime(batchTime);
crossDataRealTimePO.setGmtCreate(now);
crossDataRealTimePO.setGmtModified(now);
return crossDataRealTimePO;
}
public CrossDirDataRealtimePO convert2CrossDirDataRealTimePO(LanePeriodicDataDTO.EventList eventList, CrossBaseLaneInfoPO laneInfoPO) {
String crossId = laneInfoPO.getCrossId();
// todo 路口状态
int trafficFlow = eventList.getTrafficFlow();
double meanV = eventList.getMeanV();
double staticQueueLengthMax = eventList.getStaticQueueLengthMax();
double stopTimes = eventList.getMeanStopsNumber();
double meanDelay = eventList.getMeanDelay();
Integer meanDelayInt = Double.valueOf(meanDelay).intValue();
double laneSaturation = eventList.getLaneSaturation();
Date now = new Date();
int batchTime = (int)now.getTime();
Integer dir = laneInfoPO.getDir();
Integer type = laneInfoPO.getType();
CrossDirDataRealtimePO crossDirDataRealTimePO = new CrossDirDataRealtimePO();
// 路口方向ID(路口ID_方向_进出口_主辅路序号)
crossDirDataRealTimePO.setId(String.valueOf(dir).concat(String.valueOf(type)));
crossDirDataRealTimePO.setDirType(dir);
crossDirDataRealTimePO.setInOutType(type);
crossDirDataRealTimePO.setCrossId(crossId);
crossDirDataRealTimePO.setLength(staticQueueLengthMax);
crossDirDataRealTimePO.setStatus(0000);
crossDirDataRealTimePO.setTrafficIndex(0000.00);
crossDirDataRealTimePO.setStartTime(now);
crossDirDataRealTimePO.setCapacity(trafficFlow);
crossDirDataRealTimePO.setDuration(0000);
crossDirDataRealTimePO.setFlow(trafficFlow);
crossDirDataRealTimePO.setSpeed(meanV);
crossDirDataRealTimePO.setQueueLength(staticQueueLengthMax);
crossDirDataRealTimePO.setStopTimes(stopTimes);
crossDirDataRealTimePO.setDelayTime(meanDelayInt);
crossDirDataRealTimePO.setSturation(laneSaturation);
crossDirDataRealTimePO.setBatchTime(batchTime);
crossDirDataRealTimePO.setGmtCreate(now);
crossDirDataRealTimePO.setGmtModified(now);//
crossDirDataRealTimePO.setEffusionRate(0000.0);//
return crossDirDataRealTimePO;
}
public CrossTurnDataRealtimePO convert2CrossTurnDataRealtimePO(LanePeriodicDataDTO.EventList eventList, CrossBaseLaneInfoPO laneInfoPO) {
String crossId = laneInfoPO.getCrossId();
// todo 路口状态
int trafficFlow = eventList.getTrafficFlow();
double meanV = eventList.getMeanV();
double staticQueueLengthMax = eventList.getStaticQueueLengthMax();
double stopTimes = eventList.getMeanStopsNumber();
double meanDelay = eventList.getMeanDelay();
Integer meanDelayInt = Double.valueOf(meanDelay).intValue();
double laneSaturation = eventList.getLaneSaturation();
Date now = new Date();
int batchTime = (int)now.getTime();
Integer dir = laneInfoPO.getDir();
Integer type = laneInfoPO.getType();
Integer turn = laneInfoPO.getTurn();
CrossTurnDataRealtimePO crossTurnDataRealtimePO = new CrossTurnDataRealtimePO();
crossTurnDataRealtimePO.setId( crossId.concat("").concat(String.valueOf(turn)));
crossTurnDataRealtimePO.setTurnType("");
crossTurnDataRealtimePO.setInDir(0000);
crossTurnDataRealtimePO.setOutDir(0000);
crossTurnDataRealtimePO.setCrossId(crossId);
crossTurnDataRealtimePO.setFlow(trafficFlow);
crossTurnDataRealtimePO.setStatus(00000);
crossTurnDataRealtimePO.setTrafficIndex(0000.0);
crossTurnDataRealtimePO.setSpeed(meanV);
crossTurnDataRealtimePO.setInSpeed(0000.0);
crossTurnDataRealtimePO.setOutSpeed(0000.0);
crossTurnDataRealtimePO.setQueueLength(staticQueueLengthMax);
crossTurnDataRealtimePO.setStopTimes(stopTimes);
crossTurnDataRealtimePO.setDelayTime(meanDelayInt);
crossTurnDataRealtimePO.setSturation(laneSaturation);
crossTurnDataRealtimePO.setVehheadDist(0000.0);
crossTurnDataRealtimePO.setVehheadTime(0000.0);
crossTurnDataRealtimePO.setQuality(0000.0);
crossTurnDataRealtimePO.setBatchTime(batchTime);
crossTurnDataRealtimePO.setGmtCreate(now);
crossTurnDataRealtimePO.setGmtModified(now);
return crossTurnDataRealtimePO;
}
public CrossLaneDataRealTimePO convert2CrossLaneDataRealTimePO(LanePeriodicDataDTO.EventList eventList, CrossBaseLaneInfoPO laneInfoPO) {
String crossId = laneInfoPO.getCrossId();
// todo 路口状态
int trafficFlow = eventList.getTrafficFlow();
double meanV = eventList.getMeanV();
double staticQueueLengthMax = eventList.getStaticQueueLengthMax();
double stopTimes = eventList.getMeanStopsNumber();
double meanDelay = eventList.getMeanDelay();
Integer meanDelayInt = Double.valueOf(meanDelay).intValue();
double laneSaturation = eventList.getLaneSaturation();
Date now = new Date();
int batchTime = (int)now.getTime();
CrossLaneDataRealTimePO crossLaneDataRealTimePO = new CrossLaneDataRealTimePO();
crossLaneDataRealTimePO.setId(laneInfoPO.getId());
crossLaneDataRealTimePO.setCrossId(crossId);
crossLaneDataRealTimePO.setFlow(trafficFlow);
crossLaneDataRealTimePO.setSpeed(meanV);
crossLaneDataRealTimePO.setInSpeed(0000.0);
crossLaneDataRealTimePO.setOutSpeed(0000.0);
crossLaneDataRealTimePO.setQueueLength(staticQueueLengthMax);
crossLaneDataRealTimePO.setStopTimes(stopTimes);
crossLaneDataRealTimePO.setDelayTime(meanDelayInt);
crossLaneDataRealTimePO.setCapacity(trafficFlow);
crossLaneDataRealTimePO.setSturation(laneSaturation);
crossLaneDataRealTimePO.setVehheadTime(0000.0);
crossLaneDataRealTimePO.setVehheadDist(0000.0);
crossLaneDataRealTimePO.setQuality(0000.0);
crossLaneDataRealTimePO.setBatchTime(batchTime);
crossLaneDataRealTimePO.setGmtCreate(now);
crossLaneDataRealTimePO.setGmtModified(now);
return crossLaneDataRealTimePO;
}
}
package net.wanji.datacenter.pojo.dto;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/03/09 17:02
*/
@Data
public class LanePeriodicDataDTO {
/**
* 车道事件集合
*/
private List<EventList> eventList;
/**
* 车道数量
*/
private Integer laneNum;
/**
* 全域编号
*/
private String orgCode;
/**
* 数据生成时间: yyyy-MM-dd HH:mm:ss:SSS
*/
private String timeStamp;
@Data
public class EventList {
/**
* 最大动态排队长度
*/
private double dynamicQueueLengthMax;
/**
* 最小动态排队长度
*/
private double dynamicQueueLengthMin;
/**
* 绿灯有效利用率
*/
private double greenLightEfficiency;
/**
* 车道号(路网数据)
*/
private String laneId;
/**
* 车道通行能力
*/
private int laneCapacity;
/**
* 车道流率
*/
private double laneFlowRate;
/**
* 不停车率
*/
private double laneNoStopRate;
/**
* 一次停车率
*/
private double laneOneStopRate;
/**
* 车道饱和度
*/
private double laneSaturation;
/**
* 车道饱和流率
*/
private int laneSaturationFlowRate;
/**
* 三次停车率
*/
private double laneThreeStopRate;
/**
* 二次停车率
*/
private double laneTwoStopRate;
/**
* 绿灯结束排队长度
*/
private double lightGreenFinishQueueLength;
/**
* 绿灯起亮排队长度
*/
private double lightGreenStartQueueLength;
/**
* 平均延误
*/
private double meanDelay;
/**
* 平均停车次数
*/
private int meanStopsNumber;
/**
* 平均点速度
*/
private double meanV;
/**
* 最大静态排队长度
*/
private double staticQueueLengthMax;
/**
* 最小静态排队长度
*/
private double staticQueueLengthMin;
/**
* 时间占有率
*/
private double timeOccupancy;
/**
* 自然流量
*/
private int trafficFlow;
/**
* 小车当量
*/
private int trolleyEquivalent;
/**
* 平均空间密度(长度占比)
*/
private double vehicleLengthRatioMean;
/**
* 平均空间密度(车辆负荷比)
*/
private double vehicleNumsRatioMean;
}
}
package net.wanji.datacenter.service;
/**
* @author duanruiming
* @date 2023/03/10 9:48
*/
public interface DataProcessService {
/**
* 数据中心收到数据
*
* @param topic
* @return
*/
String receive(String topic);
/**
* 数据中心发送数据, 通过远程调用调用不同的服务
*
* @param convertData
*/
void send(String topic, Object convertData);
/**
* 数据中心转换数据
*
* @param originalData
* @return
*/
Object convert(String originalData) throws Exception;
/**
* 转换后保存数据
*/
void save(Object convertData) throws Exception;
}
package net.wanji.datacenter.service.impl;
import net.wanji.datacenter.service.DataProcessService;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/03/10 14:17
*/
@Service(value = "test")
public class Test implements DataProcessService {
@Override
public String receive(String originalData) {
System.err.println("test receice successful");
return null;
}
@Override
public void send(String topic, Object convertData) {
System.err.println("test send successful");
}
@Override
public String convert(String originalData) {
System.err.println("test convert successful");
return null;
}
@Override
public void save(Object convertData) throws Exception{
System.err.println("test save successful");
}
}
spring:
application:
# dubbo启动需要程序名称
name: dataCenter
main:
allow-circular-references: true
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
file-extension: yaml
group: signal
namespace: signal
username: nacos
password: nacos
\ No newline at end of file
spring:
profiles:
active: dev
\ No newline at end of file
......@@ -21,7 +21,6 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
</dependency>
<!--客户端负载均衡loadbalancer-->
<dependency>
......
......@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.Constants;
......@@ -16,7 +15,6 @@ import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.entity.basedata.ResultView;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.opt.cache.BaseCrossInfoCache;
......@@ -34,7 +32,6 @@ import net.wanji.opt.synthesis.pojo.vo.*;
import net.wanji.opt.synthesis.service.PushStrategyControlService;
import net.wanji.opt.synthesis.service.StrategyControlService;
import org.apache.commons.lang3.StringUtils;
import org.geotools.feature.visitor.CountVisitor;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
......@@ -813,7 +810,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
jsonViewObject.setStatus(StringUtils.equals("200", witchPustResult.getCode()) ? Constants.JsonView.STATUS_SUCCESS : Constants.JsonView.STATUS_FAIL);
StringBuilder sb = new StringBuilder();
List<LinkedHashMap<String, Object>> contentList = (List<LinkedHashMap<String, Object>>) witchPustResult.getData();
List<LinkedHashMap<String, Object>> contentList = (List<LinkedHashMap<String, Object>>) witchPustResult.getData();
for (LinkedHashMap<String, Object> item : contentList) {
Object result = item.get("result");
if (Objects.equals(1, result)) {
......
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