Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
earlywarning
Commits
ee9bd6c6
Commit
ee9bd6c6
authored
Jul 02, 2025
by
p x
Browse files
对完8.5
parent
8bd7108c
Changes
23
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/cusc/adas/v2x/events/VehAdviceEvent.kt
View file @
ee9bd6c6
package
com.cusc.adas.v2x.events
package
com.cusc.adas.v2x.events
import
com.cusc.adas.v2x.dto.VehAdviceDto
import
com.cusc.adas.v2x.
clouddecision.
dto.VehAdviceDto
class
VehAdviceEvent
{
class
VehAdviceEvent
{
var
vehAdviceDto
:
VehAdviceDto
<
Any
>?
=
null
var
vehAdviceDto
:
VehAdviceDto
<
Any
>?
=
null
...
...
src/main/java/com/cusc/adas/v2x/utils/Parse.java
View file @
ee9bd6c6
...
@@ -340,13 +340,28 @@ public class Parse {
...
@@ -340,13 +340,28 @@ public class Parse {
// public static void convoterBean( Object source , Object target) throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException, NoSuchFieldException, SecurityException {
// public static void convoterBean( Object source , Object target) throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException, NoSuchFieldException, SecurityException {
public
static
void
convoterBean
(
Object
source
,
Object
target
)
{
public
static
void
convoterBean
(
Object
source
,
Object
target
)
{
Field
[]
fields
=
source
.
getClass
().
getDeclaredFields
();
List
<
Field
>
fList
=
new
ArrayList
<>();
for
(
Field
field
:
fields
)
{
if
(
field
.
isAnnotationPresent
(
Order
.
class
))
{
fList
.
add
(
field
);
}
}
Collections
.
sort
(
fList
,
new
Comparator
<
Field
>()
{
@Override
public
int
compare
(
Field
f1
,
Field
f2
)
{
return
f1
.
getAnnotation
(
Order
.
class
).
value
()
-
f2
.
getAnnotation
(
Order
.
class
).
value
();
}
});
Field
tField
=
null
;
Field
tField
=
null
;
try
{
try
{
Field
[]
fields
=
source
.
getClass
().
getDeclaredFields
();
//
Field[] fields = source.getClass().getDeclaredFields();
//获取目标对象指定的属性
//获取目标对象指定的属性
//List<Field> fList = new ArrayList<>();
//List<Field> fList = new ArrayList<>();
//SortedMap<Integer,Field> rstMap = new TreeMap<>();
//SortedMap<Integer,Field> rstMap = new TreeMap<>();
for
(
Field
field
:
f
ields
)
{
for
(
Field
field
:
f
List
)
{
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
Object
o
=
field
.
get
(
source
);
Object
o
=
field
.
get
(
source
);
if
(
o
==
null
)
{
if
(
o
==
null
)
{
...
@@ -435,26 +450,39 @@ public class Parse {
...
@@ -435,26 +450,39 @@ public class Parse {
}
else
if
(
List
.
class
.
isAssignableFrom
(
field
.
getType
()))
{
}
else
if
(
List
.
class
.
isAssignableFrom
(
field
.
getType
()))
{
// 集合类型
// 集合类型
//读取属性的注解是否引用其他字段的长度
//读取属性的注解是否引用其他字段的长度
if
(
field
.
isAnnotationPresent
(
RefNumFlag
.
class
))
{
if
(
field
.
isAnnotationPresent
(
RefNumFlag
.
class
)
&&
!
field
.
isAnnotationPresent
(
DynamicsClassDef
.
class
))
{
List
<?>
temp
=
(
List
<?>)
o
;
// RefNumFlag refNumFlag = field.getAnnotation(RefNumFlag.class);
RefNumFlag
refNumFlag
=
field
.
getAnnotation
(
RefNumFlag
.
class
);
// String refField = refNumFlag.value();
String
refField
=
refNumFlag
.
value
();
// Class<?> clazz1 = t.getClass();
Class
<?>
clazz1
=
target
.
getClass
();
// Field nameField = clazz1.getDeclaredField(refField);
Field
nameField
=
clazz1
.
getDeclaredField
(
refField
);
// Type genericType = nameField.getGenericType();
Type
genericType
=
field
.
getGenericType
();
// nameField.setAccessible(true);
Type
targetType
=
tField
.
getGenericType
();
//
nameField
.
setAccessible
(
true
);
// if (genericType instanceof ParameterizedType) {
if
(
genericType
instanceof
ParameterizedType
)
{
// ParameterizedType pt = (ParameterizedType) genericType;
List
<
Object
>
dsts
=
new
ArrayList
<>();
// Type[] actualTypes = pt.getActualTypeArguments();
ParameterizedType
pt
=
(
ParameterizedType
)
genericType
;
// if (actualTypes.length > 0) {
Type
[]
actualTypes
=
pt
.
getActualTypeArguments
();
// actualTypes[0].getClass();
ParameterizedType
dspt
=
(
ParameterizedType
)
targetType
;
// int len= (int) nameField.get(t);
Type
[]
dstTypes
=
dspt
.
getActualTypeArguments
();
// for(int i=0;i<len;i++) {
if
(
actualTypes
.
length
>
0
&&
actualTypes
!=
null
)
{
// actualTypes[0].getClass();
for
(
int
i
=
0
;
i
<
temp
.
size
();
i
++)
{
// }
Object
src
=
temp
.
get
(
i
);
// }
Object
dst
=
null
;
// }
if
(
src
instanceof
Short
)
{
dst
=
(
Short
)
src
;
}
else
if
(
src
instanceof
Integer
)
{
dst
=
(
int
)
src
;
}
else
{
Class
<?>
cls
=
Class
.
forName
(
dstTypes
[
0
].
getTypeName
());
dst
=
cls
.
newInstance
();
convoterBean
(
src
,
dst
);
}
dsts
.
add
(
dst
);
}
tField
.
set
(
target
,
dsts
);
}
}
}
}
}
else
if
(
field
.
getType
()
==
String
.
class
)
{
}
else
if
(
field
.
getType
()
==
String
.
class
)
{
...
@@ -467,13 +495,27 @@ public class Parse {
...
@@ -467,13 +495,27 @@ public class Parse {
// e.printStackTrace();
// e.printStackTrace();
// }
// }
}
else
{
}
else
{
//其他对象类型
//其他对象类型
Class
<?>
cls
=
Class
.
forName
(
tField
.
getType
().
getName
());
if
(
field
.
isAnnotationPresent
(
DynamicsClassDef
.
class
))
{
Object
obj
=
cls
.
newInstance
();
DynamicsClassDef
dynamicsClassDef
=
field
.
getAnnotation
(
DynamicsClassDef
.
class
);
String
classtype
=
dynamicsClassDef
.
classtype
();
DependencyDef
dependencyDef
=
field
.
getAnnotation
(
DependencyDef
.
class
);
String
fieldname
=
dependencyDef
.
value
();
Field
tField2
=
target
.
getClass
().
getDeclaredField
(
fieldname
);
tField2
.
setAccessible
(
true
);
Short
key
=
(
Short
)
tField2
.
get
(
target
);
Class
<?>
cls
=
DynamicsClassMap
.
getDto
(
classtype
,
key
);
Object
obj
=
cls
.
newInstance
();
convoterBean
(
o
,
obj
);
tField
.
set
(
target
,
obj
);
}
else
{
Class
<?>
cls
=
Class
.
forName
(
tField
.
getType
().
getName
());
Object
obj
=
cls
.
newInstance
();
convoterBean
(
o
,
obj
);
convoterBean
(
o
,
obj
);
tField
.
set
(
target
,
obj
);
tField
.
set
(
target
,
obj
);
}
}
}
}
}
}
}
...
...
src/main/java/com/cusc/adas/v2x/vo/DynamicsClassMap.java
View file @
ee9bd6c6
...
@@ -4,6 +4,12 @@ import java.util.HashMap;
...
@@ -4,6 +4,12 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
com.cusc.adas.v2x.assist.vo.TrafficLight
;
import
com.cusc.adas.v2x.assist.vo.TrafficLight
;
import
com.cusc.adas.v2x.clouddecision.dto.AbnormalVehicleDto
;
import
com.cusc.adas.v2x.clouddecision.dto.AutoSpeedLimitDto
;
import
com.cusc.adas.v2x.clouddecision.dto.EmergencyVehicleDto
;
import
com.cusc.adas.v2x.clouddecision.dto.FawWarnningDto
;
import
com.cusc.adas.v2x.clouddecision.dto.RSIWarnningDto
;
import
com.cusc.adas.v2x.clouddecision.dto.TrafficLightDto
;
import
com.cusc.adas.v2x.clouddecision.vo.AbnormalVehicle
;
import
com.cusc.adas.v2x.clouddecision.vo.AbnormalVehicle
;
import
com.cusc.adas.v2x.clouddecision.vo.AutoSpeedLimit
;
import
com.cusc.adas.v2x.clouddecision.vo.AutoSpeedLimit
;
import
com.cusc.adas.v2x.clouddecision.vo.EmergencyVehicle
;
import
com.cusc.adas.v2x.clouddecision.vo.EmergencyVehicle
;
...
@@ -12,31 +18,46 @@ import com.cusc.adas.v2x.clouddecision.vo.RSIWarnning;
...
@@ -12,31 +18,46 @@ import com.cusc.adas.v2x.clouddecision.vo.RSIWarnning;
import
com.cusc.adas.v2x.clouddecision.vo.TrafficLightInfo
;
import
com.cusc.adas.v2x.clouddecision.vo.TrafficLightInfo
;
public
class
DynamicsClassMap
{
public
class
DynamicsClassMap
{
private
static
Map
<
String
,
Map
<
Short
,
Class
>>
map
=
new
HashMap
<>();
private
static
Map
<
String
,
Map
<
Short
,
Class
>>
map
=
new
HashMap
<>();
private
static
Map
<
String
,
Map
<
Short
,
Class
>>
mapDto
=
new
HashMap
<>();
static
{
Map
<
Short
,
Class
>
cloundDecisionsubMap
=
new
HashMap
<>();
static
{
Map
<
Short
,
Class
>
cloundDecisionsubMap
=
new
HashMap
<>();
// 参考 adviceType 列表定义
cloundDecisionsubMap
.
put
((
short
)
1
,
TrafficLightInfo
.
class
);
//信号灯路口车速引导功能指令
// 参考 adviceType 列表定义
cloundDecisionsubMap
.
put
((
short
)
5
,
AutoSpeedLimit
.
class
);
//动态车道级限速指令
cloundDecisionsubMap
.
put
((
short
)
1
,
TrafficLightInfo
.
class
);
//信号灯路口车速引导功能指令
cloundDecisionsubMap
.
put
((
short
)
9
,
FawWarnning
.
class
);
//前向碰撞预警
cloundDecisionsubMap
.
put
((
short
)
5
,
AutoSpeedLimit
.
class
);
//动态车道级限速指令
cloundDecisionsubMap
.
put
((
short
)
11
,
AbnormalVehicle
.
class
);
//异常车辆预警
cloundDecisionsubMap
.
put
((
short
)
9
,
FawWarnning
.
class
);
//前向碰撞预警
cloundDecisionsubMap
.
put
((
short
)
13
,
EmergencyVehicle
.
class
);
//紧急车辆预警
cloundDecisionsubMap
.
put
((
short
)
11
,
AbnormalVehicle
.
class
);
//异常车辆预警
cloundDecisionsubMap
.
put
((
short
)
17
,
RSIWarnning
.
class
);
//通用 RSI 预警
cloundDecisionsubMap
.
put
((
short
)
13
,
EmergencyVehicle
.
class
);
//紧急车辆预警
map
.
put
(
"CloudDecision"
,
cloundDecisionsubMap
);
cloundDecisionsubMap
.
put
((
short
)
17
,
RSIWarnning
.
class
);
//通用 RSI 预警
map
.
put
(
"CloudDecision"
,
cloundDecisionsubMap
);
Map
<
Short
,
Class
>
assistSubMap
=
new
HashMap
<>();
assistSubMap
.
put
((
short
)
7
,
TrafficLight
.
class
);
Map
<
Short
,
Class
>
assistSubMap
=
new
HashMap
<>();
map
.
put
(
"assist"
,
assistSubMap
);
assistSubMap
.
put
((
short
)
7
,
TrafficLight
.
class
);
map
.
put
(
"assist"
,
assistSubMap
);
// 参考 adviceType 列表定义
}
Map
<
Short
,
Class
>
cloundDecisionsubMapDto
=
new
HashMap
<>();
cloundDecisionsubMapDto
.
put
((
short
)
1
,
TrafficLightDto
.
class
);
//信号灯路口车速引导功能指令
public
static
Class
get
(
String
classtype
,
Short
classkey
)
{
cloundDecisionsubMapDto
.
put
((
short
)
5
,
AutoSpeedLimitDto
.
class
);
//动态车道级限速指令
Map
<
Short
,
Class
>
subMap
=
map
.
get
(
classtype
);
cloundDecisionsubMapDto
.
put
((
short
)
9
,
FawWarnningDto
.
class
);
//前向碰撞预警
return
subMap
.
get
(
classkey
);
cloundDecisionsubMapDto
.
put
((
short
)
11
,
AbnormalVehicleDto
.
class
);
//异常车辆预警
}
cloundDecisionsubMapDto
.
put
((
short
)
13
,
EmergencyVehicleDto
.
class
);
//紧急车辆预警
cloundDecisionsubMapDto
.
put
((
short
)
17
,
RSIWarnningDto
.
class
);
//通用 RSI 预警
//Android Dto
mapDto
.
put
(
"CloudDecision"
,
cloundDecisionsubMapDto
);
}
public
static
Class
get
(
String
classtype
,
Short
classkey
)
{
Map
<
Short
,
Class
>
subMap
=
map
.
get
(
classtype
);
return
subMap
.
get
(
classkey
);
}
public
static
Class
getDto
(
String
classtype
,
Short
classkey
)
{
Map
<
Short
,
Class
>
subMap
=
mapDto
.
get
(
classtype
);
return
subMap
.
get
(
classkey
);
}
}
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment