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
c3c89fa9
Commit
c3c89fa9
authored
Nov 04, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 策略查询接口
parent
92556429
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
91 additions
and
72 deletions
+91
-72
MybatisPlusConfig.java
...src/main/java/net/wanji/opt/config/MybatisPlusConfig.java
+21
-0
StrategyControlDataEntity.java
...main/java/net/wanji/opt/po/StrategyControlDataEntity.java
+17
-5
StrategyControlController.java
...i/opt/synthesis/controller/StrategyControlController.java
+14
-0
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
+25
-32
StrategyControlInfoMapper.xml
...e/src/main/resources/mapper/StrategyControlInfoMapper.xml
+5
-9
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 @
c3c89fa9
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/po/StrategyControlDataEntity.java
View file @
c3c89fa9
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
;
...
...
@@ -9,16 +14,23 @@ import java.util.Date;
* @date 2024/11/04 10:53
*/
@Data
public
class
StrategyControlDataEntity
{
/** value = 路口干线Id */
@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-干线 */
/** value = 类型 0-路口 1-干线 */
@TableField
(
"biz_type"
)
private
Integer
bizType
;
/** value = 策略类型 0-绿波带 1-失衡 2-溢出 3-空放 */
private
Integer
strategy
;
/** value = 开始时间日期 */
/** value = 开始时间日期 */
@TableField
(
"schedule_start"
)
private
Date
scheduleStart
;
/** value = 结束时间日期 */
/** value = 结束时间日期 */
@TableField
(
"schedule_end"
)
private
Date
scheduleEnd
;
/** value = 日计划表 */
private
String
time
;
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyControlController.java
View file @
c3c89fa9
...
...
@@ -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/service/PushStrategyControlService.java
View file @
c3c89fa9
...
...
@@ -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 @
c3c89fa9
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 @
c3c89fa9
...
...
@@ -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
));
Result
result
=
mapper
.
readValue
(
resultStr
,
Result
.
class
);
if
(
Objects
.
nonNull
(
result
))
{
if
(
StringUtils
.
endsWithIgnoreCase
(
"200"
,
result
.
getCode
()))
{
return
result
;
}
if
(
StringUtils
.
isNotBlank
(
resultStr
))
{
Result
result
=
mapper
.
readValue
(
resultStr
,
Result
.
class
);
return
result
;
}
else
{
log
.
error
(
"策略推送url:{}失败:返回数据异常"
,
url
);
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
c3c89fa9
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
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.enums.DateStyle
;
import
net.wanji.common.framework.Constants
;
...
...
@@ -13,11 +14,14 @@ import net.wanji.opt.synthesis.pojo.*;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* @author duanruiming
...
...
@@ -43,12 +47,11 @@ public class StrategyControlServiceImpl implements StrategyControlService {
StrategyControlDataEntity
entity
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
entity
,
dataVO
);
entity
.
setTime
(
JacksonUtils
.
getInstance
().
writeValueAsString
(
dataVO
.
getTime
()));
entities
.
add
(
entity
);
}
strategyControlInfoMapper
.
insertBatch
(
entities
);
StrategyControlReq
req
=
convertReq
(
strategyControlVO
);
// todo 测试数据
//req.setData(Arrays.asList(detailData));
Result
result
=
pushStrategyControlService
.
push
(
req
);
if
(
Objects
.
nonNull
(
result
))
{
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
...
...
@@ -102,33 +105,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
View file @
c3c89fa9
...
...
@@ -7,28 +7,24 @@
<insert
id=
"insertBatch"
parameterType=
"net.wanji.opt.po.StrategyControlDataEntity"
>
INSERT INTO t_strategy_control_info (
biz
I
d,
biz
T
ype,
biz
_i
d,
biz
_t
ype,
strategy,
schedule_start,
schedule_end,
`time`,
frequency,
status,
create_time,
gmt_modified
status
) VALUES
<foreach
collection=
"list"
item=
"entity"
separator=
","
>
#{entity.bizId},
(
#{entity.bizId},
#{entity.bizType},
#{entity.strategy},
#{entity.scheduleStart},
#{entity.scheduleEnd},
#{entity.time},
#{entity.frequency},
#{entity.status},
#{createTime, jdbcType=TIMESTAMP, default=CURRENT_TIMESTAMP},
#{gmtModified, jdbcType=TIMESTAMP, default=CURRENT_TIMESTAMP, update="CURRENT_TIMESTAMP"}
#{entity.status})
</foreach>
</insert>
</mapper>
\ No newline at end of file
wj-databus/src/main/java/net/wanji/databus/vo/PageVO.java
View file @
c3c89fa9
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