Commit 1d70fddd authored by fengyasheng's avatar fengyasheng

路口优化记录修正-修改查询的表

parent d26c933b
...@@ -51,4 +51,11 @@ public interface TEventOptimizeInfoMapper extends BaseMapper<TEventOptimizeInfo> ...@@ -51,4 +51,11 @@ public interface TEventOptimizeInfoMapper extends BaseMapper<TEventOptimizeInfo>
@Param("startDuration") Integer startDuration, @Param("startDuration") Integer startDuration,
@Param("endDuration") Integer endDuration @Param("endDuration") Integer endDuration
); );
List<String> getCrossIdList(@Param("greenId") Integer greenId);
Page<TEventOptimizeInfo> selectPageWithCrossIds(@Param("page") Page<TEventOptimizeInfo> page,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("crossIds") List<String> crossIds);
} }
\ No newline at end of file
package net.wanji.opt.servicev2.eventoptimize.impl; package net.wanji.opt.servicev2.eventoptimize.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -38,19 +39,39 @@ public class TEventOptimizeInfoServiceImpl extends ServiceImpl<TEventOptimizeInf ...@@ -38,19 +39,39 @@ public class TEventOptimizeInfoServiceImpl extends ServiceImpl<TEventOptimizeInf
@Override @Override
public Page<TEventOptimizeInfoVO> selectPageWithCrossIdAndGreenId(int currentPage, int pageSize, String startTime, String endTime, String crossId, Integer greenId) { public Page<TEventOptimizeInfoVO> selectPageWithCrossIdAndGreenId(int currentPage, int pageSize, String startTime, String endTime, String crossId, Integer greenId) {
Page<TEventOptimizeInfo> page = new Page<>(currentPage, pageSize); if(ObjectUtil.isNotEmpty(greenId)){
Page<TEventOptimizeInfo> tEventOptimizeInfoPage = baseMapper.selectPageWithCrossIdAndGreenId(page, startTime, endTime, crossId, greenId); List<String> crossIds = tEventOptimizeInfoMapper.getCrossIdList(greenId);
List<TEventOptimizeInfoVO> collect = tEventOptimizeInfoPage.getRecords().stream().map(x -> { Page<TEventOptimizeInfo> page = new Page<>(currentPage, pageSize);
TEventOptimizeInfoVO tEventOptimizeInfoVO = new TEventOptimizeInfoVO(); Page<TEventOptimizeInfo> tEventOptimizeInfoPage = baseMapper.selectPageWithCrossIds(page, startTime, endTime, crossIds);
BeanUtils.copyProperties(x, tEventOptimizeInfoVO); List<TEventOptimizeInfoVO> collect = tEventOptimizeInfoPage.getRecords().stream().map(x -> {
tEventOptimizeInfoVO.setEventLabal(getEventLabel(x.getEventType())); TEventOptimizeInfoVO tEventOptimizeInfoVO = new TEventOptimizeInfoVO();
return tEventOptimizeInfoVO; BeanUtils.copyProperties(x, tEventOptimizeInfoVO);
}).collect(Collectors.toList()); tEventOptimizeInfoVO.setEventLabal(getEventLabel1(x.getEventType()));
tEventOptimizeInfoVO.setOptStatus(1);
Page<TEventOptimizeInfoVO> pageVO = new Page<>(currentPage, pageSize); tEventOptimizeInfoVO.setGreenId(greenId);
pageVO.setTotal(page.getTotal()); return tEventOptimizeInfoVO;
pageVO.setRecords(collect); }).collect(Collectors.toList());
return pageVO;
Page<TEventOptimizeInfoVO> pageVO = new Page<>(currentPage, pageSize);
pageVO.setTotal(page.getTotal());
pageVO.setRecords(collect);
return pageVO;
}else {
Page<TEventOptimizeInfo> page = new Page<>(currentPage, pageSize);
Page<TEventOptimizeInfo> tEventOptimizeInfoPage = baseMapper.selectPageWithCrossIdAndGreenId(page, startTime, endTime, crossId, greenId);
List<TEventOptimizeInfoVO> collect = tEventOptimizeInfoPage.getRecords().stream().map(x -> {
TEventOptimizeInfoVO tEventOptimizeInfoVO = new TEventOptimizeInfoVO();
BeanUtils.copyProperties(x, tEventOptimizeInfoVO);
tEventOptimizeInfoVO.setEventLabal(getEventLabel1(x.getEventType()));
tEventOptimizeInfoVO.setOptStatus(1);
return tEventOptimizeInfoVO;
}).collect(Collectors.toList());
Page<TEventOptimizeInfoVO> pageVO = new Page<>(currentPage, pageSize);
pageVO.setTotal(page.getTotal());
pageVO.setRecords(collect);
return pageVO;
}
} }
@Override @Override
...@@ -113,7 +134,19 @@ public class TEventOptimizeInfoServiceImpl extends ServiceImpl<TEventOptimizeInf ...@@ -113,7 +134,19 @@ public class TEventOptimizeInfoServiceImpl extends ServiceImpl<TEventOptimizeInf
return eventLabel; return eventLabel;
} }
} }
// 获取事件名称(可以根据实际需求扩展)
private String getEventLabel1(String eventType) {
switch (eventType){
case "1":
return "绿灯空放";
case "2":
return "失衡";
case "3":
return "溢出";
default:
return "未知事件";
}
}
// 新增干线接口用于带有条件的分页查询 // 新增干线接口用于带有条件的分页查询
@Override @Override
public Page<TEventOptimizeInfo> pageWithLineConditions(int currentPage, int pageSize, String startTime, String endTime, Integer greenId, String eventType, Integer optStatus, Integer duration,Integer startOptDuration,Integer endOptDuration,Integer startDuration, Integer endDuration) { public Page<TEventOptimizeInfo> pageWithLineConditions(int currentPage, int pageSize, String startTime, String endTime, Integer greenId, String eventType, Integer optStatus, Integer duration,Integer startOptDuration,Integer endOptDuration,Integer startDuration, Integer endDuration) {
......
package net.wanji.opt.servicev2.report.impl; package net.wanji.opt.servicev2.report.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -328,11 +329,14 @@ public class GreenWaveWeekDataServiceImpl extends ServiceImpl<GreenWaveWeekDataM ...@@ -328,11 +329,14 @@ public class GreenWaveWeekDataServiceImpl extends ServiceImpl<GreenWaveWeekDataM
public List<GreenReportSamePeriodCompareData> getSamePeriodCompare(Integer year, Integer week, String ids) { public List<GreenReportSamePeriodCompareData> getSamePeriodCompare(Integer year, Integer week, String ids) {
Integer yearWeek = Integer.valueOf(year + "" + week); Integer yearWeek = Integer.valueOf(year + "" + week);
Integer yearWeekLast = Integer.valueOf(year + "" + (week-1)); Integer yearWeekLast = Integer.valueOf(year + "" + (week-1));
List<Integer> greenIdList = Arrays.stream(ids.split(",")) List<Integer> greenIdList = new ArrayList<>();
.map(String::trim) // 去除可能的空格 if(ObjectUtil.isNotEmpty(ids)){
.filter(s -> !s.isEmpty()) // 过滤掉空字符串 greenIdList = Arrays.stream(ids.split(","))
.map(Integer::parseInt) // 转换为整数 .map(String::trim) // 去除可能的空格
.collect(Collectors.toList()); .filter(s -> !s.isEmpty()) // 过滤掉空字符串
.map(Integer::parseInt) // 转换为整数
.collect(Collectors.toList());
}
List<GreenWaveWeekData> greenWaveWeekDatas = greenWaveWeekDataMapper.getDataByWeek(greenIdList,yearWeek); List<GreenWaveWeekData> greenWaveWeekDatas = greenWaveWeekDataMapper.getDataByWeek(greenIdList,yearWeek);
List<GreenWaveWeekData> greenWaveWeekDatasLast = greenWaveWeekDataMapper.getDataByWeek(greenIdList,yearWeek-1); List<GreenWaveWeekData> greenWaveWeekDatasLast = greenWaveWeekDataMapper.getDataByWeek(greenIdList,yearWeek-1);
List<GreenReportSamePeriodCompareData> result = new ArrayList<>(); List<GreenReportSamePeriodCompareData> result = new ArrayList<>();
......
...@@ -37,14 +37,34 @@ ...@@ -37,14 +37,34 @@
ORDER BY happen_start_time desc ORDER BY happen_start_time desc
</select> </select>
<select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo"> <select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT * SELECT
FROM t_event_optimize_info cross_id,
WHERE (#{startTime} IS NULL OR happen_start_time >= #{startTime}) current_algo AS event_type,
AND (#{endTime} IS NULL OR happen_end_time &lt;= #{endTime}) issue_time AS opt_start_time,
AND (#{crossId} IS NULL OR cross_id = #{crossId}) duration AS opt_duration,
AND (#{greenId} IS NULL OR green_id = #{greenId}) DATE_ADD( issue_time, INTERVAL duration SECOND ) AS opt_end_time
AND opt_status != 0 FROM
t_strategy_cross_result
WHERE
1=1
<if test="startTime != null and endTime != null">
AND issue_time >= #{startTime}
AND issue_time &lt; #{endTime}
</if>
<if test="crossId != null" >
AND cross_id = #{crossId}
</if>
AND response_code = 200
</select> </select>
<!-- <select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">-->
<!-- SELECT *-->
<!-- FROM t_event_optimize_info-->
<!-- WHERE (#{startTime} IS NULL OR happen_start_time >= #{startTime})-->
<!-- AND (#{endTime} IS NULL OR happen_end_time &lt;= #{endTime})-->
<!-- AND (#{crossId} IS NULL OR cross_id = #{crossId})-->
<!-- AND (#{greenId} IS NULL OR green_id = #{greenId})-->
<!-- AND opt_status != 0-->
<!-- </select>-->
<select id="getCrossOptimizeDistribute" parameterType="map" resultType="java.util.Map"> <select id="getCrossOptimizeDistribute" parameterType="map" resultType="java.util.Map">
SELECT SELECT
...@@ -123,4 +143,30 @@ ...@@ -123,4 +143,30 @@
</if> </if>
ORDER BY happen_start_time desc ORDER BY happen_start_time desc
</select> </select>
<select id="getCrossIdList" resultType="java.lang.String">
select cross_id from t_greenwave_cross where green_id = #{greenId}
</select>
<select id="selectPageWithCrossIds" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT
cross_id,
current_algo AS event_type,
issue_time AS opt_start_time,
duration AS opt_duration,
DATE_ADD( issue_time, INTERVAL duration SECOND ) AS opt_end_time
FROM
t_strategy_cross_result
WHERE
1=1
<if test="startTime != null and endTime != null">
AND issue_time >= #{startTime}
AND issue_time &lt; #{endTime}
</if>
<if test="crossIds != null" >
AND cross_id in
<foreach collection="crossIds" item="crossId" open="(" close=")" separator=",">
#{crossId}
</foreach>
</if>
AND response_code = 200
</select>
</mapper> </mapper>
\ No newline at end of file
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