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
b5a033ef
Commit
b5a033ef
authored
Nov 08, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 策略管理页面接口
parent
fbfc162a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
122 additions
and
52 deletions
+122
-52
SignalOptimizeApplication.java
...rc/main/java/net/wanji/opt/SignalOptimizeApplication.java
+2
-1
Swagger2.java
...-service/src/main/java/net/wanji/opt/config/Swagger2.java
+3
-1
StrategyControlInfoMapper.java
...a/net/wanji/opt/dao/mapper/StrategyControlInfoMapper.java
+1
-1
StrategyControlController.java
...i/opt/synthesis/controller/StrategyControlController.java
+16
-6
StrategyControlDataEntity.java
...t/wanji/opt/synthesis/pojo/StrategyControlDataEntity.java
+1
-1
StrategyControlDetailList.java
...t/wanji/opt/synthesis/pojo/StrategyControlDetailList.java
+1
-0
StrategyControlService.java
...t/wanji/opt/synthesis/service/StrategyControlService.java
+3
-8
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+94
-33
StrategyControlInfoMapper.xml
...e/src/main/resources/mapper/StrategyControlInfoMapper.xml
+1
-1
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/SignalOptimizeApplication.java
View file @
b5a033ef
...
...
@@ -10,7 +10,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author
*/
@SpringBootApplication
(
scanBasePackages
=
{
"net.wanji.opt"
,
"net.wanji.databus"
,
"net.wanji.common"
})
@SpringBootApplication
(
scanBasePackages
=
{
"net.wanji.opt"
,
"net.wanji.databus"
,
"net.wanji.common"
,
"net.wanji.opt.controller"
,
"net.wanji.opt.synthesis.controller"
})
@MapperScan
(
basePackages
=
{
"net.wanji.opt.dao.mapper"
,
"net.wanji.databus.dao.mapper"
})
@EnableTransactionManagement
@EnableScheduling
...
...
signal-optimize-service/src/main/java/net/wanji/opt/config/Swagger2.java
View file @
b5a033ef
package
net
.
wanji
.
opt
.
config
;
import
com.google.common.base.Predicates
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
...
...
@@ -21,7 +22,8 @@ public class Swagger2 {
.
apiInfo
(
apiInfo
())
.
select
()
//为当前包路径
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"net.wanji.opt.controller"
))
.
apis
(
Predicates
.
or
(
RequestHandlerSelectors
.
basePackage
(
"net.wanji.opt.controller"
),
RequestHandlerSelectors
.
basePackage
(
"net.wanji.opt.synthesis.controller"
)))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
...
...
signal-optimize-service/src/main/java/net/wanji/opt/dao/mapper/StrategyControlInfoMapper.java
View file @
b5a033ef
package
net
.
wanji
.
opt
.
dao
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
net.wanji.opt.
p
o.StrategyControlDataEntity
;
import
net.wanji.opt.
synthesis.poj
o.StrategyControlDataEntity
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyControlController.java
View file @
b5a033ef
...
...
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiResponse;
import
io.swagger.annotations.ApiResponses
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.opt.dao.mapper.SynthesisOptimizeLogInfoMapper
;
import
net.wanji.opt.
p
o.StrategyControlDataEntity
;
import
net.wanji.opt.
synthesis.poj
o.StrategyControlDataEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
...
...
@@ -55,16 +55,26 @@ public class StrategyControlController {
return
strategyControlService
.
strategyInfoPageList
(
entity
);
}
@ApiOperation
(
value
=
"策略
管理计划列表查询"
,
notes
=
"策略管理计划列表查询
"
,
@ApiOperation
(
value
=
"策略
控制查询列表"
,
notes
=
"策略控制查询列表
"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/strategyPlanList"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/crossStrategyInfoList"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
StrategyControlDataEntity
.
class
),
})
public
JsonViewObject
strategyPlanList
(
@RequestParam
String
crossId
)
throws
Exception
{
return
strategyControlService
.
strategyPlanList
(
crossId
);
public
JsonViewObject
crossStrategyInfoList
(
@RequestParam
Integer
type
)
throws
Exception
{
return
strategyControlService
.
crossStrategyInfoList
(
type
);
}
@ApiOperation
(
value
=
"策略管理计划详情查询"
,
notes
=
"策略管理计划详情查询"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/strategyPlanDetail"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
StrategyControlDetailList
.
class
),
})
public
JsonViewObject
strategyPlanDetail
(
@RequestParam
String
crossId
)
throws
Exception
{
return
strategyControlService
.
strategyPlanDetail
(
crossId
);
}
@ApiOperation
(
value
=
"策略管理计划保存"
,
notes
=
"策略管理计划列表查询"
,
...
...
signal-optimize-service/src/main/java/net/wanji/opt/
p
o/StrategyControlDataEntity.java
→
signal-optimize-service/src/main/java/net/wanji/opt/
synthesis/poj
o/StrategyControlDataEntity.java
View file @
b5a033ef
package
net
.
wanji
.
opt
.
p
o
;
package
net
.
wanji
.
opt
.
synthesis
.
poj
o
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/StrategyControlDetailList.java
View file @
b5a033ef
...
...
@@ -13,6 +13,7 @@ import java.util.List;
*/
@Data
public
class
StrategyControlDetailList
{
private
String
crossId
;
@NotEmpty
private
List
<
ExecutePlan
>
plans
;
@NotEmpty
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/StrategyControlService.java
View file @
b5a033ef
package
net
.
wanji
.
opt
.
synthesis
.
service
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.opt.
p
o.StrategyControlDataEntity
;
import
net.wanji.opt.
synthesis.poj
o.StrategyControlDataEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
...
...
@@ -13,13 +13,8 @@ public interface StrategyControlService {
JsonViewObject
strategyInfoOperation
(
StrategyControlVO
strategyControlVO
)
throws
Exception
;
JsonViewObject
strategyInfoPageList
(
StrategyControlDataEntity
entity
)
throws
Exception
;
JsonViewObject
crossStrategyInfoList
(
Integer
type
)
throws
Exception
;
/**
* 策略管理查询
* @param crossId
* @return
* @throws Exception
*/
JsonViewObject
strategyPlanList
(
String
crossId
)
throws
Exception
;
JsonViewObject
strategyPlanDetail
(
String
crossId
)
throws
Exception
;
JsonViewObject
strategyPlanSave
(
StrategyControlDetailList
list
)
throws
Exception
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
b5a033ef
package
net
.
wanji
.
opt
.
synthesis
.
service
.
impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -14,7 +15,6 @@ import net.wanji.common.utils.tool.JacksonUtils;
import
net.wanji.opt.dao.mapper.StrategyControlInfoMapper
;
import
net.wanji.opt.dao.mapper.StrategyDailyPlanInfoMapper
;
import
net.wanji.opt.dao.mapper.StrategyPlanInfoMapper
;
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
;
...
...
@@ -146,7 +146,55 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
@Override
public
JsonViewObject
strategyPlanList
(
String
crossId
)
throws
Exception
{
public
JsonViewObject
crossStrategyInfoList
(
Integer
type
)
throws
Exception
{
ObjectMapper
instance
=
JacksonUtils
.
getInstance
();
LambdaQueryWrapper
<
StrategyControlDataEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getBizType
,
type
);
List
<
StrategyControlDataEntity
>
entities
=
strategyControlInfoMapper
.
selectList
(
queryWrapper
);
List
<
StrategyControlDataEntity
>
results
=
new
ArrayList
<>(
entities
.
size
());
Date
current
=
new
Date
();
for
(
StrategyControlDataEntity
entity
:
entities
)
{
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
result
,
entity
);
Date
start
=
entity
.
getScheduleStart
();
Date
end
=
entity
.
getScheduleEnd
();
if
(
current
.
before
(
start
)
||
current
.
after
(
end
))
{
result
.
setTime
(
""
);
}
else
{
String
time
=
entity
.
getTime
();
List
<
StrategyControlDataVO
.
TimeTable
>
timeTables
=
instance
.
readValue
(
time
,
new
TypeReference
<
List
<
StrategyControlDataVO
.
TimeTable
>>()
{});
for
(
StrategyControlDataVO
.
TimeTable
timeTable
:
timeTables
)
{
int
currentWeek
=
DateUtil
.
thisDayOfWeek
();
if
(
currentWeek
!=
timeTable
.
getWeek
())
{
result
.
setTime
(
""
);
}
else
{
String
[]
timeList
=
timeTable
.
getTimeList
();
for
(
String
s
:
timeList
)
{
String
[]
hours
=
s
.
split
(
","
);
for
(
String
hour
:
hours
)
{
String
[]
currentHour
=
hour
.
split
(
"-"
);
String
startHour
=
currentHour
[
0
];
String
entHour
=
currentHour
[
1
];
String
format
=
DateUtil
.
format
(
current
,
"HH:mm"
);
DateTime
currentTime
=
DateUtil
.
parse
(
format
,
"HH:mm"
);
DateTime
startHourDate
=
DateUtil
.
parse
(
startHour
,
"HH:mm"
);
DateTime
endHourDate
=
DateUtil
.
parse
(
entHour
,
"HH:mm"
);
if
(
currentTime
.
before
(
startHourDate
)
||
currentTime
.
after
(
endHourDate
))
{
result
.
setTime
(
hour
);
}
}
}
}
results
.
add
(
result
);
}
}
}
return
JsonViewObject
.
newInstance
().
success
(
results
);
}
@Override
public
JsonViewObject
strategyPlanDetail
(
String
crossId
)
throws
Exception
{
try
{
ObjectMapper
instance
=
JacksonUtils
.
getInstance
();
StrategyControlDetailList
result
=
new
StrategyControlDetailList
();
...
...
@@ -222,6 +270,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyDailyPlanInfoMapper
.
insert
(
dailyPlanInfoEntity
);
}
}
convertDataList
(
list
);
return
JsonViewObject
.
newInstance
().
success
();
}
catch
(
Exception
e
)
{
log
.
error
(
"策略管理数据保存失败,:{}"
,
e
);
...
...
@@ -235,7 +284,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
*
* @param list
*/
public
void
convertDataList
(
StrategyControlDetailList
list
)
{
public
void
convertDataList
(
StrategyControlDetailList
list
)
throws
Exception
{
try
{
if
(
Objects
.
nonNull
(
list
))
{
List
<
StrategyControlDetailList
.
DailyPlan
>
dailyPlans
=
list
.
getDailyPlans
();
List
<
StrategyPlanDTO
>
strategyPlanDTOS
=
new
ArrayList
<>();
...
...
@@ -248,11 +298,12 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyPlanDTO
.
setStrategy
(
dailyPlanDetail
.
getStrategy
());
strategyPlanDTO
.
setTimes
(
dailyPlanDetail
.
getTimes
());
strategyPlanDTO
.
setDailyPlanId
(
dailyPlanId
);
dailyPlans
.
add
(
dailyPlan
);
strategyPlanDTOS
.
add
(
strategyPlanDTO
);
}
}
}
List
<
StrategyPlanDTO
>
resultList
=
new
ArrayList
<>();
List
<
StrategyControlDetailList
.
ExecutePlan
>
plans
=
list
.
getPlans
();
if
(!
CollectionUtils
.
isEmpty
(
plans
)
&&
!
CollectionUtils
.
isEmpty
(
dailyPlans
))
{
for
(
StrategyControlDetailList
.
ExecutePlan
plan
:
plans
)
{
...
...
@@ -269,12 +320,22 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyPlanDTO
.
setPlanId
(
planId
);
strategyPlanDTO
.
setStartTime
(
startTime
);
strategyPlanDTO
.
setEndTime
(
endTime
);
strategyPlanDTO
.
setWeeks
(
weeks
);
resultList
.
add
(
strategyPlanDTO
);
}
}
}
}
}
}
for
(
StrategyPlanDTO
strategyPlanDTO
:
strategyPlanDTOS
)
{
System
.
err
.
println
(
strategyPlanDTO
);
}
log
.
error
(
"神思数据:{}"
,
JacksonUtils
.
getInstance
().
writeValueAsString
(
strategyPlanDTOS
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
"数据转化神思数据结构异常:{}"
,
e
);
throw
new
Exception
(
e
);
}
}
}
signal-optimize-service/src/main/resources/mapper/StrategyControlInfoMapper.xml
View file @
b5a033ef
...
...
@@ -5,7 +5,7 @@
<mapper
namespace=
"net.wanji.opt.dao.mapper.StrategyControlInfoMapper"
>
<insert
id=
"insertBatch"
parameterType=
"net.wanji.opt.
p
o.StrategyControlDataEntity"
>
<insert
id=
"insertBatch"
parameterType=
"net.wanji.opt.
synthesis.poj
o.StrategyControlDataEntity"
>
INSERT INTO t_strategy_control_info (
biz_id,
biz_type,
...
...
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