Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wj-datacenter-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jinan
wj-datacenter-platform
Commits
8cc00d1e
Commit
8cc00d1e
authored
Feb 09, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 优化失衡数据逻辑;
parent
3556c1a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
PhaseEmptyEnum.java
...main/java/net/wanji/datacenter/common/PhaseEmptyEnum.java
+10
-0
CrossStrategyOptConsumerHandler.java
...nji/datacenter/kafka/CrossStrategyOptConsumerHandler.java
+10
-6
CrossStrategyOptServiceImpl.java
.../datacenter/service/impl/CrossStrategyOptServiceImpl.java
+4
-1
No files found.
wj-datacenter-service/src/main/java/net/wanji/datacenter/common/PhaseEmptyEnum.java
View file @
8cc00d1e
...
@@ -12,6 +12,7 @@ import java.util.Objects;
...
@@ -12,6 +12,7 @@ import java.util.Objects;
@Getter
@Getter
@AllArgsConstructor
@AllArgsConstructor
public
enum
PhaseEmptyEnum
{
public
enum
PhaseEmptyEnum
{
//
EXT_NS
(-
100
,
"1,5"
,
"2"
,
"延长南北方向直行的绿灯"
),
EXT_NS
(-
100
,
"1,5"
,
"2"
,
"延长南北方向直行的绿灯"
),
EXT_EW
(-
101
,
"3,7"
,
"2"
,
"延长东西方向直行的绿灯"
),
EXT_EW
(-
101
,
"3,7"
,
"2"
,
"延长东西方向直行的绿灯"
),
EXT_NS_L
(-
102
,
"1,5"
,
"1"
,
" 延长南北方向左转的绿灯"
),
EXT_NS_L
(-
102
,
"1,5"
,
"1"
,
" 延长南北方向左转的绿灯"
),
...
@@ -65,6 +66,15 @@ public enum PhaseEmptyEnum {
...
@@ -65,6 +66,15 @@ public enum PhaseEmptyEnum {
private
final
String
turn
;
private
final
String
turn
;
private
final
String
desc
;
private
final
String
desc
;
public
static
String
getDesc
(
Integer
code
)
{
for
(
PhaseEmptyEnum
value
:
PhaseEmptyEnum
.
values
())
{
if
(
Objects
.
equals
(
code
,
value
.
getCode
()))
{
return
value
.
getDesc
();
}
}
return
null
;
}
public
static
String
getDir
(
Integer
code
)
{
public
static
String
getDir
(
Integer
code
)
{
for
(
PhaseEmptyEnum
value
:
PhaseEmptyEnum
.
values
())
{
for
(
PhaseEmptyEnum
value
:
PhaseEmptyEnum
.
values
())
{
if
(
Objects
.
equals
(
code
,
value
.
getCode
()))
{
if
(
Objects
.
equals
(
code
,
value
.
getCode
()))
{
...
...
wj-datacenter-service/src/main/java/net/wanji/datacenter/kafka/CrossStrategyOptConsumerHandler.java
View file @
8cc00d1e
...
@@ -61,12 +61,16 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
...
@@ -61,12 +61,16 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
@KafkaListener
(
topics
=
{
"${kafka-consumer.imbalanceAlgorithmResultTopic}"
},
groupId
=
"group"
)
@KafkaListener
(
topics
=
{
"${kafka-consumer.imbalanceAlgorithmResultTopic}"
},
groupId
=
"group"
)
public
void
receiveImbalanceData
(
ConsumerRecord
<
Object
,
Object
>
record
,
Acknowledgment
acknowledgment
)
throws
Exception
{
public
void
receiveImbalanceData
(
ConsumerRecord
<
Object
,
Object
>
record
,
Acknowledgment
acknowledgment
)
throws
Exception
{
String
message
=
String
.
valueOf
(
record
.
value
());
String
message
=
String
.
valueOf
(
record
.
value
());
if
(
StringUtils
.
isNotBlank
(
message
))
{
try
{
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
if
(
StringUtils
.
isNotBlank
(
message
))
{
ImbalanceAlgorithmDTO
imbalanceAlgorithmDTO
=
mapper
.
readValue
(
message
,
ImbalanceAlgorithmDTO
.
class
);
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
// 设置3,优化方案
ImbalanceAlgorithmDTO
imbalanceAlgorithmDTO
=
mapper
.
readValue
(
message
,
ImbalanceAlgorithmDTO
.
class
);
imbalanceAlgorithmDTO
.
setRtnType
(
3
);
// 设置3,优化方案
crossStrategyOptService
.
save
(
imbalanceAlgorithmDTO
);
imbalanceAlgorithmDTO
.
setRtnType
(
3
);
crossStrategyOptService
.
save
(
imbalanceAlgorithmDTO
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"当前数据处理异常:{}"
,
message
);
}
}
acknowledgment
.
acknowledge
();
acknowledgment
.
acknowledge
();
}
}
...
...
wj-datacenter-service/src/main/java/net/wanji/datacenter/service/impl/CrossStrategyOptServiceImpl.java
View file @
8cc00d1e
...
@@ -61,19 +61,21 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
...
@@ -61,19 +61,21 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
}
else
{
}
else
{
entity
.
setResponseCode
(
200
);
entity
.
setResponseCode
(
200
);
}
}
entity
.
setResponseContent
(
idx
.
getResponseContent
());
}
else
{
}
else
{
if
(
Objects
.
nonNull
(
idx
.
getResponseCode
())
&&
!
Objects
.
equals
(-
1
,
idx
.
getResponseCode
()))
{
if
(
Objects
.
nonNull
(
idx
.
getResponseCode
())
&&
!
Objects
.
equals
(-
1
,
idx
.
getResponseCode
()))
{
entity
.
setResponseCode
(
idx
.
getResponseCode
());
entity
.
setResponseCode
(
idx
.
getResponseCode
());
}
else
{
}
else
{
entity
.
setResponseCode
(
500
);
entity
.
setResponseCode
(
500
);
}
}
String
desc
=
PhaseEmptyEnum
.
getDesc
(
rtnType
);
entity
.
setResponseContent
(
desc
);
}
}
entity
.
setRtnType
(
rtnType
);
entity
.
setRtnType
(
rtnType
);
String
name
=
CrossInfoCache
.
getName
(
crossId
);
String
name
=
CrossInfoCache
.
getName
(
crossId
);
entity
.
setCrossName
(
name
);
entity
.
setCrossName
(
name
);
entity
.
setEmptyDir
(
PhaseEmptyEnum
.
getDir
(
rtnType
));
entity
.
setEmptyDir
(
PhaseEmptyEnum
.
getDir
(
rtnType
));
entity
.
setEmptyTurn
(
PhaseEmptyEnum
.
getTurn
(
rtnType
));
entity
.
setEmptyTurn
(
PhaseEmptyEnum
.
getTurn
(
rtnType
));
entity
.
setResponseContent
(
idx
.
getResponseContent
());
if
(
Objects
.
nonNull
(
date
))
{
if
(
Objects
.
nonNull
(
date
))
{
String
parse
=
DateUtil
.
format
(
date
,
"yyyyMMdd"
);
String
parse
=
DateUtil
.
format
(
date
,
"yyyyMMdd"
);
entity
.
setDt
(
Integer
.
valueOf
(
parse
));
entity
.
setDt
(
Integer
.
valueOf
(
parse
));
...
@@ -126,6 +128,7 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
...
@@ -126,6 +128,7 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
}
}
crossStrategyResultMapper
.
insert
(
crossStrategyResultEntity
);
crossStrategyResultMapper
.
insert
(
crossStrategyResultEntity
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"失衡优化策略数据处理失败:"
,
e
);
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
...
...
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