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
63837ff2
Commit
63837ff2
authored
Nov 05, 2024
by
zhouleilei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
25b55bf1
b5de02c9
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
185 additions
and
88 deletions
+185
-88
MybatisPlusConfig.java
...src/main/java/net/wanji/opt/config/MybatisPlusConfig.java
+21
-0
StrategyControlInfoMapper.java
...a/net/wanji/opt/dao/mapper/StrategyControlInfoMapper.java
+15
-0
StrategyControlDataEntity.java
...main/java/net/wanji/opt/po/StrategyControlDataEntity.java
+41
-0
StrategyControlController.java
...i/opt/synthesis/controller/StrategyControlController.java
+14
-0
StrategyControlDataVO.java
...a/net/wanji/opt/synthesis/pojo/StrategyControlDataVO.java
+3
-1
PushStrategyControlService.java
...nji/opt/synthesis/service/PushStrategyControlService.java
+0
-3
StrategyControlService.java
...t/wanji/opt/synthesis/service/StrategyControlService.java
+3
-0
PushStrategyControlServiceImpl.java
...ynthesis/service/impl/PushStrategyControlServiceImpl.java
+3
-23
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+52
-54
StrategyControlInfoMapper.xml
...e/src/main/resources/mapper/StrategyControlInfoMapper.xml
+30
-0
HisenseApplication.java
...c/main/java/net/wanji/utc/hisense/HisenseApplication.java
+0
-1
GetSchemeNoService.java
...c/hisense/netty/response/impl/get/GetSchemeNoService.java
+0
-6
PageVO.java
wj-databus/src/main/java/net/wanji/databus/vo/PageVO.java
+3
-0
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/config/MybatisPlusConfig.java
0 → 100644
View file @
63837ff2
package
net
.
wanji
.
opt
.
config
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author duanruiming
* @date 2024/11/04 18:44
*/
@Configuration
public
class
MybatisPlusConfig
{
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
()
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
interceptor
.
addInnerInterceptor
(
new
PaginationInnerInterceptor
());
return
interceptor
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/dao/mapper/StrategyControlInfoMapper.java
0 → 100644
View file @
63837ff2
package
net
.
wanji
.
opt
.
dao
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
net.wanji.opt.po.StrategyControlDataEntity
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @author duanruiming
* @date 2024/11/04 10:57
*/
public
interface
StrategyControlInfoMapper
extends
BaseMapper
<
StrategyControlDataEntity
>
{
int
insertBatch
(
@Param
(
"list"
)
List
<
StrategyControlDataEntity
>
list
);
}
signal-optimize-service/src/main/java/net/wanji/opt/po/StrategyControlDataEntity.java
0 → 100644
View file @
63837ff2
package
net
.
wanji
.
opt
.
po
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
net.wanji.databus.vo.PageVO
;
import
java.util.Date
;
/**
* @author duanruiming
* @date 2024/11/04 10:53
*/
@Data
@TableName
(
"t_strategy_control_info"
)
public
class
StrategyControlDataEntity
extends
PageVO
{
/** value = 路口干线Id */
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
@TableField
(
"biz_id"
)
private
String
bizId
;
/** value = 类型 0-路口 1-干线 */
@TableField
(
"biz_type"
)
private
Integer
bizType
;
/** value = 策略类型 0-绿波带 1-失衡 2-溢出 3-空放 */
private
Integer
strategy
;
/** value = 开始时间日期 */
@TableField
(
"schedule_start"
)
private
Date
scheduleStart
;
/** value = 结束时间日期 */
@TableField
(
"schedule_end"
)
private
Date
scheduleEnd
;
/** value = 日计划表 */
private
String
time
;
/** value = 调控频率(秒),策略下发的频率(只针对失衡和绿波带有效) */
private
Integer
frequency
;
/** value = 状态(1=开启,0=停止) */
private
Integer
status
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyControlController.java
View file @
63837ff2
...
...
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponses
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.opt.po.StrategyControlDataEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -39,4 +40,17 @@ public class StrategyControlController {
public
JsonViewObject
strategyInfoOperation
(
@RequestBody
StrategyControlVO
strategyControlVO
)
throws
Exception
{
return
strategyControlService
.
strategyInfoOperation
(
strategyControlVO
);
}
@ApiOperation
(
value
=
"策略控制信息分页查询"
,
notes
=
"策略控制信息分页查询"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/strategyInfoPageList"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
StrategyControlDataEntity
.
class
),
})
public
JsonViewObject
strategyInfoPageList
(
@RequestBody
StrategyControlDataEntity
entity
)
throws
Exception
{
return
strategyControlService
.
strategyInfoPageList
(
entity
);
}
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/StrategyControlDataVO.java
View file @
63837ff2
...
...
@@ -15,6 +15,8 @@ import java.util.List;
@Data
@ApiModel
(
value
=
"StrategyControlDataVO"
,
description
=
"策略控制操作数据实体"
)
public
class
StrategyControlDataVO
{
@ApiModelProperty
(
value
=
"id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"路口干线Id"
)
private
String
bizId
;
@ApiModelProperty
(
value
=
"类型 0-路口 1-干线"
)
...
...
@@ -28,7 +30,7 @@ public class StrategyControlDataVO {
@ApiModelProperty
(
value
=
"日计划表"
)
private
List
<
StrategyControlDataVO
.
TimeTable
>
time
;
@ApiModelProperty
(
value
=
"调控频率(秒),策略下发的频率(只针对失衡和绿波带有效)"
)
private
Integer
freq
;
private
Integer
freq
uency
;
@ApiModelProperty
(
value
=
"状态(1=开启,0=停止)"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"操作(insert=新增,update=更新,delete=删除)"
)
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/PushStrategyControlService.java
View file @
63837ff2
...
...
@@ -8,8 +8,5 @@ import net.wanji.opt.synthesis.pojo.StrategyControlReq;
* @date 2024/11/03 14:06
*/
public
interface
PushStrategyControlService
{
void
insert
();
void
update
();
void
delete
();
Result
push
(
StrategyControlReq
req
)
throws
Exception
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/StrategyControlService.java
View file @
63837ff2
package
net
.
wanji
.
opt
.
synthesis
.
service
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.opt.po.StrategyControlDataEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
/**
...
...
@@ -9,4 +10,6 @@ import net.wanji.opt.synthesis.pojo.StrategyControlVO;
*/
public
interface
StrategyControlService
{
JsonViewObject
strategyInfoOperation
(
StrategyControlVO
strategyControlVO
)
throws
Exception
;
JsonViewObject
strategyInfoPageList
(
StrategyControlDataEntity
entity
)
throws
Exception
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/PushStrategyControlServiceImpl.java
View file @
63837ff2
...
...
@@ -7,10 +7,8 @@ import net.wanji.common.utils.tool.JacksonUtils;
import
net.wanji.opt.synthesis.pojo.Result
;
import
net.wanji.opt.synthesis.pojo.StrategyControlReq
;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.Objects
;
/**
* @author duanruiming
...
...
@@ -20,32 +18,14 @@ import java.util.Objects;
@Slf4j
public
class
PushStrategyControlServiceImpl
implements
PushStrategyControlService
{
@Override
public
void
insert
()
{
}
@Override
public
void
update
()
{
}
@Override
public
void
delete
()
{
}
@Override
public
Result
push
(
StrategyControlReq
req
)
throws
Exception
{
String
url
=
""
;
try
{
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
String
resultStr
=
RestTemplateTool
.
post
(
url
,
mapper
.
writeValueAsString
(
req
));
if
(
StringUtils
.
isNotBlank
(
resultStr
))
{
Result
result
=
mapper
.
readValue
(
resultStr
,
Result
.
class
);
if
(
Objects
.
nonNull
(
result
))
{
if
(
StringUtils
.
endsWithIgnoreCase
(
"200"
,
result
.
getCode
()))
{
return
result
;
}
return
result
;
}
else
{
log
.
error
(
"策略推送url:{}失败:返回数据异常"
,
url
);
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
63837ff2
package
net
.
wanji
.
opt
.
synthesis
.
service
.
impl
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.druid.util.StringUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.enums.DateStyle
;
import
net.wanji.common.framework.Constants
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.opt.dao.mapper.StrategyControlInfoMapper
;
import
net.wanji.opt.po.StrategyControlDataEntity
;
import
net.wanji.opt.synthesis.pojo.*
;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.*
;
import
javax.annotation.Resource
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* @author duanruiming
...
...
@@ -24,36 +33,19 @@ import java.util.*;
@Service
public
class
StrategyControlServiceImpl
implements
StrategyControlService
{
@
Autowired
@
Resource
private
PushStrategyControlService
pushStrategyControlService
;
@Resource
private
StrategyControlInfoMapper
strategyControlInfoMapper
;
@Override
public
JsonViewObject
strategyInfoOperation
(
StrategyControlVO
strategyControlVO
)
throws
Exception
{
try
{
StrategyControlReq
req
=
convertReq
(
strategyControlVO
);
// 存库
// 调用推送
//StrategyControlDataReq detailData = new StrategyControlDataReq();
//detailData.setBiz_id("241940");
//detailData.setBiz_type(0);
//detailData.setStrategy(3);
//Date date = new Date();
//detailData.setSchedule_end(DateUtil.format(date, DateStyle.YYYY_MM_DD_HH_MM_SS.getValue()));
//detailData.setSchedule_end(DateUtil.format(date, DateStyle.YYYY_MM_DD_HH_MM_SS.getValue()));
//StrategyControlDataReq.Time_table timeTable = new StrategyControlDataReq.Time_table();
//timeTable.setWeek(1);
//timeTable.setTime_list(new String[]{"00:00-01:00", "01:00-02:00"});
//StrategyControlDataReq.Time_table timeTable1 = new StrategyControlDataReq.Time_table();
//timeTable1.setWeek(1);
//timeTable1.setTime_list(new String[]{"02:00-03:00", "03:00-04:00"});
//detailData.setTime(Arrays.asList(timeTable1, timeTable));
//detailData.setFreq(1000 * 60);
//detailData.setStrategy(1);
//detailData.setAction("insert");
insertAndUpdate
(
strategyControlVO
);
// todo 测试数据
//req.setData(Arrays.asList(detailData));
StrategyControlReq
req
=
convertReq
(
strategyControlVO
);
Result
result
=
pushStrategyControlService
.
push
(
req
);
if
(
Objects
.
nonNull
(
result
))
{
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
...
...
@@ -71,6 +63,22 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
private
void
insertAndUpdate
(
StrategyControlVO
strategyControlVO
)
throws
IllegalAccessException
,
InvocationTargetException
,
JsonProcessingException
{
List
<
StrategyControlDataVO
>
dataList
=
strategyControlVO
.
getDataList
();
for
(
StrategyControlDataVO
dataVO
:
dataList
)
{
StrategyControlDataEntity
entity
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
entity
,
dataVO
);
entity
.
setTime
(
JacksonUtils
.
getInstance
().
writeValueAsString
(
dataVO
.
getTime
()));
if
(
StringUtils
.
equals
(
"insert"
,
dataVO
.
getAction
()))
{
strategyControlInfoMapper
.
insert
(
entity
);
}
else
if
(
StringUtils
.
equals
(
"update"
,
dataVO
.
getAction
()))
{
strategyControlInfoMapper
.
updateById
(
entity
);
}
else
if
(
StringUtils
.
equals
(
"delete"
,
dataVO
.
getAction
()))
{
strategyControlInfoMapper
.
deleteById
(
entity
);
}
}
}
private
StrategyControlReq
convertReq
(
StrategyControlVO
vo
)
throws
Exception
{
try
{
List
<
StrategyControlDataVO
>
dataList
=
vo
.
getDataList
();
...
...
@@ -93,7 +101,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
timeTables
.
add
(
timeTable
);
});
detailData
.
setTime
(
timeTables
);
detailData
.
setFreq
(
dataVO
.
getFreq
());
detailData
.
setFreq
(
dataVO
.
getFreq
uency
());
detailData
.
setStatus
(
dataVO
.
getStatus
());
detailData
.
setAction
(
dataVO
.
getAction
());
dataReqList
.
add
(
detailData
);
...
...
@@ -107,33 +115,23 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
StrategyControlDataReq
detailData
=
new
StrategyControlDataReq
();
detailData
.
setBiz_id
(
"241940"
);
detailData
.
setBiz_type
(
0
);
detailData
.
setStrategy
(
3
);
Date
date
=
new
Date
();
detailData
.
setSchedule_start
(
DateUtil
.
format
(
date
,
DateStyle
.
YYYY_MM_DD_HH_MM_SS
.
getValue
()));
detailData
.
setSchedule_end
(
DateUtil
.
format
(
date
,
DateStyle
.
YYYY_MM_DD_HH_MM_SS
.
getValue
()));
StrategyControlDataReq
.
Time_table
timeTable
=
new
StrategyControlDataReq
.
Time_table
();
timeTable
.
setWeek
(
1
);
timeTable
.
setTime_list
(
new
String
[]{
"00:00-01:00"
,
"01:00-02:00"
});
StrategyControlDataReq
.
Time_table
timeTable1
=
new
StrategyControlDataReq
.
Time_table
();
timeTable1
.
setWeek
(
2
);
timeTable1
.
setTime_list
(
new
String
[]{
"02:00-03:00"
,
"03:00-04:00"
});
detailData
.
setTime
(
Arrays
.
asList
(
timeTable1
,
timeTable
));
detailData
.
setFreq
(
1000
*
60
);
detailData
.
setStatus
(
1
);
detailData
.
setAction
(
"insert"
);
// todo 测试数据
StrategyControlReq
req
=
new
StrategyControlReq
();
req
.
setData
(
Arrays
.
asList
(
detailData
));
System
.
err
.
println
(
JacksonUtils
.
getInstance
().
writeValueAsString
(
req
));
System
.
err
.
println
(
new
Date
());
@Override
public
JsonViewObject
strategyInfoPageList
(
StrategyControlDataEntity
entity
)
throws
Exception
{
LambdaQueryWrapper
<
StrategyControlDataEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
entity
.
getBizId
()))
{
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getBizId
,
entity
.
getBizId
());
}
if
(
Objects
.
nonNull
(
entity
.
getBizType
()))
{
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getBizType
,
entity
.
getBizType
());
}
if
(
Objects
.
nonNull
(
entity
.
getStrategy
()))
{
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getStrategy
,
entity
.
getStrategy
());
}
if
(
Objects
.
nonNull
(
entity
.
getStatus
()))
{
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getStatus
,
entity
.
getStatus
());
}
Page
<
StrategyControlDataEntity
>
page
=
new
Page
<>(
entity
.
getPageNum
(),
entity
.
getPageSize
());
Page
<
StrategyControlDataEntity
>
pageInfo
=
strategyControlInfoMapper
.
selectPage
(
page
,
queryWrapper
);
return
JsonViewObject
.
newInstance
().
success
(
pageInfo
.
getRecords
());
}
}
signal-optimize-service/src/main/resources/mapper/StrategyControlInfoMapper.xml
0 → 100644
View file @
63837ff2
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"net.wanji.opt.dao.mapper.StrategyControlInfoMapper"
>
<insert
id=
"insertBatch"
parameterType=
"net.wanji.opt.po.StrategyControlDataEntity"
>
INSERT INTO t_strategy_control_info (
biz_id,
biz_type,
strategy,
schedule_start,
schedule_end,
`time`,
frequency,
status
) VALUES
<foreach
collection=
"list"
item=
"entity"
separator=
","
>
(#{entity.bizId},
#{entity.bizType},
#{entity.strategy},
#{entity.scheduleStart},
#{entity.scheduleEnd},
#{entity.time},
#{entity.frequency},
#{entity.status})
</foreach>
</insert>
</mapper>
\ No newline at end of file
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/HisenseApplication.java
View file @
63837ff2
package
net
.
wanji
.
utc
.
hisense
;
import
net.wanji.utc.hisense.netty.TcpClient
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.CommandLineRunner
;
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/netty/response/impl/get/GetSchemeNoService.java
View file @
63837ff2
...
...
@@ -5,7 +5,6 @@ import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import
net.wanji.utc.hisense.netty.request.CommandRequestFactory
;
import
net.wanji.utc.hisense.netty.response.CommandResponseFactory
;
import
net.wanji.utc.hisense.pojo.xml.pojo.messagecontent.get.GetSchemeNoRequest
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -31,9 +30,4 @@ public class GetSchemeNoService implements CommandResponseFactory, CommandReques
return
commandPojo
.
getMsg
();
}
@Scheduled
(
initialDelay
=
30
*
1000
,
fixedRate
=
4000
)
public
void
test
(){
sendCommandRequest
(
1
);
System
.
err
.
println
(
"==============发送消息成功"
);
}
}
\ No newline at end of file
wj-databus/src/main/java/net/wanji/databus/vo/PageVO.java
View file @
63837ff2
package
net
.
wanji
.
databus
.
vo
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -12,7 +13,9 @@ import lombok.Data;
@ApiModel
(
value
=
"分页实体"
)
public
class
PageVO
{
@ApiModelProperty
(
required
=
true
,
value
=
"页号"
)
@TableField
(
exist
=
false
)
Integer
pageNum
;
@ApiModelProperty
(
required
=
true
,
value
=
"每页记录数"
)
@TableField
(
exist
=
false
)
Integer
pageSize
;
}
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