Commit 2f9d6778 authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

parents 1c73e66b 82b52aa0
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.entity.judgeanalysis.CrossPoint; import net.wanji.opt.entity.judgeanalysis.CrossPoint;
import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity; import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity;
import net.wanji.opt.vo2.GreenwaveCrossResultDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -111,5 +112,9 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble ...@@ -111,5 +112,9 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble
* 获取路口优化数据 * 获取路口优化数据
*/ */
List<CrossOptAnalysisEntity> getCrossOptAnalysis(@Param("greenId") String greenId,@Param("crossID") String crossID, @Param("startTime")String startTime,@Param("endTime")String endTime); List<CrossOptAnalysisEntity> getCrossOptAnalysis(@Param("greenId") String greenId,@Param("crossID") String crossID, @Param("startTime")String startTime,@Param("endTime")String endTime);
List<GreenwaveCrossResultDTO> getTrunkLineCrossProblemByDay();
void insertAnalysisCrossDayData(List<GreenwaveCrossResultDTO> greenwaveCrossResultList);
} }
...@@ -74,4 +74,6 @@ public interface AnalysisProblemCrossDayService extends IService<AnalysisProblem ...@@ -74,4 +74,6 @@ public interface AnalysisProblemCrossDayService extends IService<AnalysisProblem
* @param date 日期 * @param date 日期
*/ */
CrossOptAnalysisVO getCrossOptAnalysis(String crossID, String startTime,String endTime); CrossOptAnalysisVO getCrossOptAnalysis(String crossID, String startTime,String endTime);
void insertAnalysisProblemCrossDay();
} }
...@@ -11,6 +11,8 @@ import net.wanji.opt.entity.judgeanalysis.CrossPoint; ...@@ -11,6 +11,8 @@ import net.wanji.opt.entity.judgeanalysis.CrossPoint;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDayService; import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDayService;
import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity; import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity;
import net.wanji.opt.vo2.CrossOptAnalysisVO; import net.wanji.opt.vo2.CrossOptAnalysisVO;
import net.wanji.opt.vo2.GreenwaveCrossResult;
import net.wanji.opt.vo2.GreenwaveCrossResultDTO;
import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Geometry;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -210,4 +212,11 @@ public class AnalysisProblemCrossDayServiceImpl extends ServiceImpl<AnalysisProb ...@@ -210,4 +212,11 @@ public class AnalysisProblemCrossDayServiceImpl extends ServiceImpl<AnalysisProb
return crossOptAnalysisVO; return crossOptAnalysisVO;
} }
@Override
public void insertAnalysisProblemCrossDay() {
List<GreenwaveCrossResultDTO> greenwaveCrossResultList = analysisProblemCrossDayMapper.getTrunkLineCrossProblemByDay();
analysisProblemCrossDayMapper.insertAnalysisCrossDayData(greenwaveCrossResultList);
}
} }
package net.wanji.opt.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDayService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
@Component
@Slf4j
public class AnalysisProblemCrossDayTask implements ApplicationRunner {
@Resource
private AnalysisProblemCrossDayService analysisProblemCrossDayService;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行时间:" + LocalDateTime.now());
// 干线协调方向频发拥堵/缓行路段
try {
// analysisProblemCrossDayService.insertAnalysisProblemCrossDay();
}catch (Exception e){
log.error("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行错误" + e);
}
log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行结束时间:" + LocalDateTime.now());
}
/**
* 每凌晨 0:30 执行的任务
*/
@Scheduled(cron = "0 10 0 * * ?") public void executeWeeklyTask() {
//干线协调方向频发拥堵/缓行路段
log.info("定时任务--干线协调方向频发拥堵/缓行路段--执行开始时间:" + LocalDateTime.now());
try {
analysisProblemCrossDayService.insertAnalysisProblemCrossDay();
}catch (Exception e){
log.error("定时任务--干线协调方向频发拥堵/缓行路段--任务执行错误" + e);
}
log.info("定时任务--干线协调方向频发拥堵/缓行路段--执行结束时间:" + LocalDateTime.now());
}
}
package net.wanji.opt.vo2;
import lombok.Data;
@Data
public class GreenwaveCrossResult {
// 字段映射 SQL 查询中的列
private Integer greenId;
private Integer dirCount; // count(*) AS dir_count
private String crossId; // b.cross_id
private Integer status; // status
private Integer dirType; // dir_type
private Integer inDir; // a.in_dir
private Integer outDir; // a.out_dir
private String name; // c.name
}
\ No newline at end of file
package net.wanji.opt.vo2;
import lombok.Data;
import java.util.Date;
@Data
public class GreenwaveCrossResultDTO {
// 字段映射 SQL 查询中的列
private String id;
private Integer greenId;
private Integer dirCount; // count(*) AS dir_count
private String crossId; // b.cross_id
private Integer status; // status
private Integer dirType; // dir_type
private Integer inDir; // a.in_dir
private Integer outDir; // a.out_dir
private String name; // c.name
private Date startTime;
private Date endTime;
}
\ No newline at end of file
...@@ -298,6 +298,22 @@ ...@@ -298,6 +298,22 @@
; ;
</insert> </insert>
<insert id="insertAnalysisCrossDayData" parameterType="java.util.List">
INSERT INTO t_analysis_green_wave_cross_day_data (
green_id, dir_count, cross_id, status, dir_type, in_dir, out_dir, name, start_time, end_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.greenId}, #{item.dirCount}, #{item.crossId}, #{item.status}, #{item.dirType},
#{item.inDir}, #{item.outDir}, #{item.name}, #{item.startTime}, #{item.endTime}
)
</foreach>
ON DUPLICATE KEY UPDATE
dir_count = VALUES(dir_count),
in_dir = VALUES(in_dir),
out_dir = VALUES(out_dir),
name = VALUES(name)
</insert>
<!-- 根据条件查询表t_analysis_problem_cross_day信息 --> <!-- 根据条件查询表t_analysis_problem_cross_day信息 -->
<select id="checkData" resultMap="AnalysisProblemCrossDayMap"> <select id="checkData" resultMap="AnalysisProblemCrossDayMap">
SELECT dt SELECT dt
...@@ -396,6 +412,27 @@ ...@@ -396,6 +412,27 @@
and t.dt >= date_format(#{startTime},'%Y%m%d') and t.dt &lt;= date_format(#{endTime},'%Y%m%d') and t.dt >= date_format(#{startTime},'%Y%m%d') and t.dt &lt;= date_format(#{endTime},'%Y%m%d')
group by status group by status
</select> </select>
<select id="getTrunkLineCrossProblemByDay" resultType="net.wanji.opt.vo2.GreenwaveCrossResultDTO">
SELECT
a.dir_count,
a.cross_id,
a.status,
a.dir_type,
b.in_dir,
b.out_dir,
c.name,
b.green_id,
DATE_SUB(CURDATE(), INTERVAL 1 DAY) as startTime,
DATE_SUB(CURDATE(), INTERVAL 1 SECOND) as endTime
FROM
( SELECT count(*) AS dir_count, cross_id, dir_type, status FROM t_cross_dir_data_hist
WHERE
start_time BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND)
GROUP BY cross_id, dir_type, status ) a
LEFT JOIN t_greenwave_cross b ON a.cross_id = b.cross_id
LEFT JOIN t_base_cross_info c ON a.cross_id = c.id
where ( b.in_dir = a.dir_type OR b.out_dir = a.dir_type )
</select>
</mapper> </mapper>
...@@ -210,10 +210,10 @@ public class StrategyPriorityController { ...@@ -210,10 +210,10 @@ public class StrategyPriorityController {
}) })
@GetMapping("/getParamConfigData") @GetMapping("/getParamConfigData")
public JsonViewObject getParamConfigData(@RequestParam(required = false) String crossId,@RequestParam(required = false) Integer greenId, public JsonViewObject getParamConfigData(@RequestParam(required = false) String crossId,@RequestParam(required = false) Integer greenId,
@RequestParam(required = true) Integer type){ @RequestParam(required = true) Integer type,@RequestParam(required = true) String strategyNo){
JsonViewObject jsonView = JsonViewObject.newInstance(); JsonViewObject jsonView = JsonViewObject.newInstance();
try { try {
List<StrategyParameterConfig>list=strategyPriorityService.getParamConfigData(crossId,greenId,type); List<StrategyParameterConfig>list=strategyPriorityService.getParamConfigData(crossId,greenId,type,strategyNo);
jsonView.success(list); jsonView.success(list);
} catch (Exception e) { } catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG")); jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG"));
......
...@@ -89,7 +89,7 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily ...@@ -89,7 +89,7 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily
void saveParamConfig(@Param("savePlanList") List<StrategyParameterConfig> savePlanList); void saveParamConfig(@Param("savePlanList") List<StrategyParameterConfig> savePlanList);
List<StrategyParameterConfig> getParamConfigData(@Param("crossId") String crossId,@Param("type")Integer type); List<StrategyParameterConfig> getParamConfigData(@Param("crossId") String crossId,@Param("type")Integer type,@Param("strategyNo") String strategyNo);
List<StrategyPriorityDailyInfo> getStrategyGreenWave(); List<StrategyPriorityDailyInfo> getStrategyGreenWave();
...@@ -111,6 +111,6 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily ...@@ -111,6 +111,6 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily
void deleteGreenParamterConfig(Integer greenId); void deleteGreenParamterConfig(Integer greenId);
List<StrategyParameterConfig> getGreenParamConfigData(@Param("greenId") Integer greenId, @Param("type") Integer type); List<StrategyParameterConfig> getGreenParamConfigData(@Param("greenId") Integer greenId, @Param("type") Integer type,@Param("strategyNo") String strategyNo);
} }
...@@ -44,7 +44,7 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI ...@@ -44,7 +44,7 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI
void saveParamterConfig(StrategyPriorityGroup strategyPriorityGroup) throws Exception; void saveParamterConfig(StrategyPriorityGroup strategyPriorityGroup) throws Exception;
List<StrategyParameterConfig> getParamConfigData(String crossId,Integer greenId, Integer type); List<StrategyParameterConfig> getParamConfigData(String crossId,Integer greenId, Integer type,String strategyNo);
List<StrategyPriorityDailyInfo> getStrategyGreenWave(); List<StrategyPriorityDailyInfo> getStrategyGreenWave();
} }
...@@ -416,7 +416,7 @@ import java.util.stream.Collectors; ...@@ -416,7 +416,7 @@ import java.util.stream.Collectors;
* 策略参数配置干线路口数据回显 * 策略参数配置干线路口数据回显
* */ * */
@Override @Override
public List<StrategyParameterConfig> getParamConfigData(String crossId,Integer greenId, Integer type) { public List<StrategyParameterConfig> getParamConfigData(String crossId,Integer greenId, Integer type,String strategyNo) {
try { try {
List<StrategyParameterConfig> paraterConfigList=new ArrayList<>(); List<StrategyParameterConfig> paraterConfigList=new ArrayList<>();
//type: 1路口 2干线 //type: 1路口 2干线
...@@ -424,12 +424,12 @@ import java.util.stream.Collectors; ...@@ -424,12 +424,12 @@ import java.util.stream.Collectors;
if (crossId.isEmpty()){ if (crossId.isEmpty()){
throw new IllegalArgumentException("crossId cannot be null"); throw new IllegalArgumentException("crossId cannot be null");
} }
paraterConfigList = strategyPriorityMapper.getParamConfigData(crossId,type); paraterConfigList = strategyPriorityMapper.getParamConfigData(crossId,type,strategyNo);
}else if(type==2){ }else if(type==2){
if (greenId==null){ if (greenId==null){
throw new IllegalArgumentException("greenId cannot be null"); throw new IllegalArgumentException("greenId cannot be null");
} }
paraterConfigList = strategyPriorityMapper.getGreenParamConfigData(greenId,type); paraterConfigList = strategyPriorityMapper.getGreenParamConfigData(greenId,type,strategyNo);
} }
return paraterConfigList; return paraterConfigList;
}catch (Exception e){ }catch (Exception e){
......
...@@ -65,10 +65,10 @@ ...@@ -65,10 +65,10 @@
select a.type , a.start_time as startTime , SUBSTR(a.dir, 2, length(a.dir)-2) as dir , a.event_serial_number as eventSerialNumber , TIMESTAMPDIFF(SECOND, a.start_time, ifnull(a.end_time,now())) as duration select a.type , a.start_time as startTime , SUBSTR(a.dir, 2, length(a.dir)-2) as dir , a.event_serial_number as eventSerialNumber , TIMESTAMPDIFF(SECOND, a.start_time, ifnull(a.end_time,now())) as duration
from t_event_info a from t_event_info a
where a.start_time = (select MAX(start_time) from t_event_info where cross_id = #{crossID} where a.start_time = (select MAX(start_time) from t_event_info where cross_id = #{crossID}
and start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and start_time >= DATE_FORMAT(DATE_SUB(#{time},INTERVAL 7 MINUTE), '%Y-%m-%d %H:%i:%s') and start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and start_time >= DATE_FORMAT(DATE_SUB(#{time},INTERVAL 30 MINUTE), '%Y-%m-%d %H:%i:%s')
and dt = DATE_FORMAT(#{time}, '%Y%m%d') ) and dt = DATE_FORMAT(#{time}, '%Y%m%d') and type in (701, 702,703, 707) )
and a.type in (701, 702,703, 707) and a.type in (701, 702,703, 707)
and a.cross_id = #{crossID} and a.cross_id = #{crossID}
</select> </select>
<select id="getCrossRealTimeAlarmsPlan" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap"> <select id="getCrossRealTimeAlarmsPlan" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap">
......
...@@ -42,10 +42,10 @@ ...@@ -42,10 +42,10 @@
select a.type , a.start_time as startTime , SUBSTR(a.dir, 2, length(a.dir)-2) as dir , TIMESTAMPDIFF(SECOND, a.start_time, ifnull(a.end_time,now())) as duration select a.type , a.start_time as startTime , SUBSTR(a.dir, 2, length(a.dir)-2) as dir , TIMESTAMPDIFF(SECOND, a.start_time, ifnull(a.end_time,now())) as duration
from t_event_info a from t_event_info a
where a.start_time = (select MAX(start_time) from t_event_info where green_id = #{greenID} where a.start_time = (select MAX(start_time) from t_event_info where green_id = #{greenID}
and start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and start_time >= DATE_FORMAT(DATE_SUB(#{time},INTERVAL 7 MINUTE), '%Y-%m-%d %H:%i:%s') and start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and start_time >= DATE_FORMAT(DATE_SUB(#{time},INTERVAL 30 MINUTE), '%Y-%m-%d %H:%i:%s')
and dt = DATE_FORMAT(#{time}, '%Y%m%d') ) and dt = DATE_FORMAT(#{time}, '%Y%m%d') and type in (705, 706) )
and a.type in (705, 706) and a.type in (705, 706)
and a.green_id = #{greenID} and a.green_id = #{greenID}
</select> </select>
<select id="getTrunkLineRealTimeAlarmPlan" parameterType="map" resultMap="tlRealTimeAlarmsResultMap"> <select id="getTrunkLineRealTimeAlarmPlan" parameterType="map" resultMap="tlRealTimeAlarmsResultMap">
......
...@@ -367,35 +367,25 @@ ...@@ -367,35 +367,25 @@
</select> </select>
<select id="getTrunkLineCrossProblem" resultType="net.wanji.opt.vo2.GreenwaveCrossResult"> <select id="getTrunkLineCrossProblem" resultType="net.wanji.opt.vo2.GreenwaveCrossResult">
SELECT SELECT
a.green_id, sum(dir_count) as dir_count,
count(*) AS dir_count, cross_id,
b.cross_id,
status, status,
dir_type, dir_type,
a.in_dir, in_dir,
a.out_dir, out_dir,
c.name name,
green_id
FROM FROM
t_greenwave_cross a t_analysis_green_wave_cross_day_data
LEFT JOIN t_base_cross_info AS c ON a.cross_id = c.id WHERE
LEFT JOIN t_cross_dir_data_hist b ON a.cross_id = b.cross_id 1=1
WHERE <if test="startTime != null and endTime != null">
1=1 and start_time BETWEEN #{startTime} AND #{endTime}
<if test="greenId != null"> </if>
AND a.green_id = #{greenId} <if test="greenId != null">
</if> and green_id = #{greenId}
<if test="startTime != null and endTime != null"> </if>
AND b.start_time BETWEEN #{startTime} GROUP BY cross_id, dir_type, status
AND #{endTime}
</if>
<if test="status != null">
AND b.status = #{status}
</if>
AND ( a.in_dir = b.dir_type OR a.out_dir = b.dir_type )
GROUP BY
b.cross_id,
dir_type,
status
</select> </select>
......
...@@ -372,6 +372,10 @@ ...@@ -372,6 +372,10 @@
<if test="type!=null and type!=''"> <if test="type!=null and type!=''">
and type = #{type} and type = #{type}
</if> </if>
<if test="strategyNo!=null and strategyNo!=''">
and strategy_no = #{strategyNo}
</if>
</select> </select>
<select id="getGreenParamConfigData" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyParameterConfig"> <select id="getGreenParamConfigData" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyParameterConfig">
SELECT SELECT
...@@ -386,6 +390,9 @@ ...@@ -386,6 +390,9 @@
<if test="type!=null and type!=''"> <if test="type!=null and type!=''">
and type = #{type} and type = #{type}
</if> </if>
<if test="strategyNo!=null and strategyNo!=''">
and strategy_no = #{strategyNo}
</if>
</select> </select>
<select id="getStrategyGreenWave" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo"> <select id="getStrategyGreenWave" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment