Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-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
signal
traffic-signal-platform
Commits
0a24e219
Commit
0a24e219
authored
Jan 22, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 策略推送优化;保存推送策略;下发控制开关
parent
65031c8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
15 deletions
+80
-15
StrategyControlSwitchReq.java
...et/wanji/opt/synthesis/pojo/StrategyControlSwitchReq.java
+1
-1
PushStrategyControlServiceImpl.java
...ynthesis/service/impl/PushStrategyControlServiceImpl.java
+3
-1
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+76
-13
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/StrategyControlSwitchReq.java
View file @
0a24e219
...
@@ -9,7 +9,7 @@ import java.util.List;
...
@@ -9,7 +9,7 @@ import java.util.List;
*/
*/
@Data
@Data
public
class
StrategyControlSwitchReq
{
public
class
StrategyControlSwitchReq
{
private
List
<
Detail
>
req
;
private
List
<
Detail
>
data
;
@Data
@Data
public
static
class
Detail
{
public
static
class
Detail
{
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/PushStrategyControlServiceImpl.java
View file @
0a24e219
...
@@ -27,6 +27,7 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
...
@@ -27,6 +27,7 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
@Override
@Override
public
Result
push
(
StrategyControlReq
req
)
throws
Exception
{
public
Result
push
(
StrategyControlReq
req
)
throws
Exception
{
//String url = "http://37.12.182.50:8082/api/traffic/strategy/info";
//String url = "http://37.12.182.50:8082/api/traffic/strategy/info";
//String url = "http://37.12.182.50:8182/api/traffic/strategy/info";
try
{
try
{
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
String
resultStr
=
RestTemplateTool
.
post
(
url
,
mapper
.
writeValueAsString
(
req
));
String
resultStr
=
RestTemplateTool
.
post
(
url
,
mapper
.
writeValueAsString
(
req
));
...
@@ -45,7 +46,8 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
...
@@ -45,7 +46,8 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
@Override
@Override
public
Result
switchPush
(
StrategyControlSwitchReq
req
)
throws
Exception
{
public
Result
switchPush
(
StrategyControlSwitchReq
req
)
throws
Exception
{
String
switchUrl
=
"http://37.12.182.50:8082/api/traffic/strategy/control"
;
//String switchUrl = "http://37.12.182.50:8082/api/traffic/strategy/control";
//String switchUrl = "http://37.12.182.50:8182/api/traffic/strategy/control";
try
{
try
{
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
String
resultStr
=
RestTemplateTool
.
post
(
switchUrl
,
mapper
.
writeValueAsString
(
req
));
String
resultStr
=
RestTemplateTool
.
post
(
switchUrl
,
mapper
.
writeValueAsString
(
req
));
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
0a24e219
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.framework.Constants
;
import
net.wanji.common.framework.Constants
;
...
@@ -717,9 +718,41 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -717,9 +718,41 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyDailyPlanInfoMapper
.
insert
(
dailyPlanInfoEntity
);
strategyDailyPlanInfoMapper
.
insert
(
dailyPlanInfoEntity
);
}
}
}
}
return
JsonViewObject
.
newInstance
().
success
();
StrategyControlVO
strategyControlVO
=
convertDataList
(
list
);
StrategyControlReq
req
=
convertReq
(
strategyControlVO
);
List
<
StrategyControlDataReq
>
data
=
req
.
getData
();
for
(
StrategyControlDataReq
datum
:
data
)
{
StrategyControlDataEntity
strategyControlDataEntity
=
new
StrategyControlDataEntity
();
strategyControlDataEntity
.
setBizId
(
datum
.
getBiz_id
());
strategyControlDataEntity
.
setBizType
(
datum
.
getBiz_type
());
strategyControlDataEntity
.
setStrategy
(
datum
.
getStrategy
());
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
strategyControlDataEntity
.
setScheduleStart
(
simpleDateFormat
.
parse
(
datum
.
getSchedule_start
()));
strategyControlDataEntity
.
setScheduleStart
(
simpleDateFormat
.
parse
(
datum
.
getSchedule_start
()));
ObjectMapper
instance
=
JacksonUtils
.
getInstance
();
strategyControlDataEntity
.
setTime
(
instance
.
writeValueAsString
(
datum
.
getTime_table
()));
strategyControlDataEntity
.
setFrequency
(
datum
.
getStrategy
());
strategyControlDataEntity
.
setStatus
(
datum
.
getStatus
());
strategyControlInfoMapper
.
insert
(
strategyControlDataEntity
);
}
// 优化策略下发逻辑,保存是推送神思策略,下发时下发开关
log
.
error
(
"下发神思策略信息详情: {}"
,
JacksonUtils
.
getInstance
().
writeValueAsString
(
req
));
Result
result
=
pushStrategyControlService
.
push
(
req
);
if
(
Objects
.
nonNull
(
result
))
{
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
jsonViewObject
.
setCode
(
Integer
.
valueOf
(
result
.
getCode
()));
jsonViewObject
.
setMessage
(
result
.
getMsg
());
jsonViewObject
.
setContent
(
result
.
getData
());
jsonViewObject
.
setStatus
(
StringUtils
.
equals
(
"200"
,
result
.
getCode
())
?
Constants
.
JsonView
.
STATUS_SUCCESS
:
Constants
.
JsonView
.
STATUS_FAIL
);
return
jsonViewObject
;
}
else
{
log
.
error
(
"推送神思策略控制失败"
);
return
JsonViewObject
.
newInstance
().
fail
(
"推送神思策略控制失败!"
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"策略管理数据保存
失败,
:{}"
,
e
);
log
.
error
(
"策略管理数据保存
, 推送神思远程服务失败
:{}"
,
e
);
throw
new
Exception
(
e
);
throw
new
Exception
(
e
);
}
}
}
}
...
@@ -736,7 +769,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -736,7 +769,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
planInfoEntity
.
setCrossId
(
executePlan
.
getCrossId
());
planInfoEntity
.
setCrossId
(
executePlan
.
getCrossId
());
planInfoEntity
.
setPlanId
(
executePlan
.
getPlanId
());
planInfoEntity
.
setPlanId
(
executePlan
.
getPlanId
());
planInfoEntity
.
setType
(
executePlan
.
getType
());
planInfoEntity
.
setType
(
executePlan
.
getType
());
planInfoEntity
.
setCompany
(
"A厂商"
);
planInfoEntity
.
setCompany
(
executePlan
.
getCompany
()
);
planInfoEntity
.
setStatus
(
executePlan
.
getStatus
());
planInfoEntity
.
setStatus
(
executePlan
.
getStatus
());
planInfoEntity
.
setStartTime
(
executePlan
.
getStartTime
());
planInfoEntity
.
setStartTime
(
executePlan
.
getStartTime
());
planInfoEntity
.
setEndTime
(
executePlan
.
getEndTime
());
planInfoEntity
.
setEndTime
(
executePlan
.
getEndTime
());
...
@@ -760,20 +793,50 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -760,20 +793,50 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyControlDataEntity
.
setStatus
(
datum
.
getStatus
());
strategyControlDataEntity
.
setStatus
(
datum
.
getStatus
());
strategyControlInfoMapper
.
insert
(
strategyControlDataEntity
);
strategyControlInfoMapper
.
insert
(
strategyControlDataEntity
);
}
}
StrategyControlSwitchReq
switchReq
=
getSwitchReq
(
req
);
log
.
error
(
"下发神思策略信息详情: {}"
,
JacksonUtils
.
getInstance
().
writeValueAsString
(
req
));
Result
witchPustResult
=
pushStrategyControlService
.
switchPush
(
switchReq
);
Result
result
=
pushStrategyControlService
.
push
(
req
);
if
(
Objects
.
nonNull
(
witchPustResult
))
{
//Result result = new Result("200", "成功", null);
if
(
Objects
.
nonNull
(
result
))
{
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
jsonViewObject
.
setCode
(
Integer
.
valueOf
(
result
.
getCode
()));
jsonViewObject
.
setCode
(
Integer
.
valueOf
(
witchPustResult
.
getCode
()));
jsonViewObject
.
setMessage
(
result
.
getMsg
());
jsonViewObject
.
setMessage
(
witchPustResult
.
getMsg
());
jsonViewObject
.
setContent
(
result
.
getData
());
jsonViewObject
.
setStatus
(
StringUtils
.
equals
(
"200"
,
witchPustResult
.
getCode
())
?
Constants
.
JsonView
.
STATUS_SUCCESS
:
Constants
.
JsonView
.
STATUS_FAIL
);
jsonViewObject
.
setStatus
(
StringUtils
.
equals
(
"200"
,
result
.
getCode
())
?
Constants
.
JsonView
.
STATUS_SUCCESS
:
Constants
.
JsonView
.
STATUS_FAIL
);
StringBuilder
sb
=
new
StringBuilder
();
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
))
{
sb
.
append
(
item
.
get
(
"biz_id"
)).
append
(
item
.
get
(
"strategy"
)).
append
(
"策略控制成功"
);
jsonViewObject
.
setContent
(
sb
);
}
else
{
sb
.
append
(
item
.
get
(
"biz_id"
)).
append
(
item
.
get
(
"strategy"
)).
append
(
"策略控制失败"
);
jsonViewObject
.
setContent
(
sb
);
}
}
return
jsonViewObject
;
return
jsonViewObject
;
}
else
{
}
else
{
return
JsonViewObject
.
newInstance
().
fail
(
"推送神思策略控制失败!"
);
log
.
error
(
"推送神思策略控制开关失败"
);
return
JsonViewObject
.
newInstance
().
fail
(
"推送神思策略控制开关失败!"
);
}
}
private
StrategyControlSwitchReq
getSwitchReq
(
StrategyControlReq
req
)
{
StrategyControlSwitchReq
switchReq
=
new
StrategyControlSwitchReq
();
List
<
StrategyControlDataReq
>
data
=
req
.
getData
();
if
(!
CollectionUtils
.
isEmpty
(
data
))
{
List
<
StrategyControlSwitchReq
.
Detail
>
details
=
new
ArrayList
<>();
for
(
StrategyControlDataReq
datum
:
data
)
{
StrategyControlSwitchReq
.
Detail
detail
=
new
StrategyControlSwitchReq
.
Detail
();
detail
.
setBiz_id
(
datum
.
getBiz_id
());
detail
.
setBiz_type
(
datum
.
getBiz_type
());
detail
.
setStrategy
(
datum
.
getStrategy
());
detail
.
setStatus
(
0
);
details
.
add
(
detail
);
}
switchReq
.
setData
(
details
);
}
}
return
switchReq
;
}
}
/**
/**
...
...
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