Commit e4063f7a authored by 黄伟铭's avatar 黄伟铭

Merge remote-tracking branch 'origin/master'

parents f918dcde 531fe038
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
select * from t_config_peak_hours; select * from t_config_peak_hours;
</select> </select>
<select id="selectGreenWaveWeekDataByTime" resultType="net.wanji.opt.entity.report.GreenWaveWeekData"> <select id="selectGreenWaveWeekDataByTime" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3 and status &lt;=4)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction
</select> </select>
<select id="selectGreenWaveWeekData" resultType="net.wanji.opt.entity.report.GreenWaveWeekData"> <select id="selectGreenWaveWeekData" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3 and status&lt;=4)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} GROUP BY green_id,road_direction from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} GROUP BY green_id,road_direction
</select> </select>
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
and TIME( start_time ) BETWEEN #{startTime} AND #{endTime} and TIME( start_time ) BETWEEN #{startTime} AND #{endTime}
</if> </if>
and green_id = #{greenId} and green_id = #{greenId}
and status >= 3 and road_direction = #{roadDirection} order by start_time and status >= 3 and status &lt;= 4 and road_direction = #{roadDirection} order by start_time
</select> </select>
<select id="getDataByWeek" resultType="net.wanji.opt.entity.report.GreenWaveWeekData"> <select id="getDataByWeek" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT SELECT
......
...@@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -49,7 +51,7 @@ public class BaseAreaInfoController { ...@@ -49,7 +51,7 @@ public class BaseAreaInfoController {
return jsonViewObject; return jsonViewObject;
} }
@ApiOperation(httpMethod="GET",value="区域基础信息-根据区划类型查询对应集合数据", notes="") @ApiOperation(httpMethod="GET",value="区域基础信息-根据区域ID删除区域记录", notes="")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "areaId", value = "区域ID", required = false, dataType = "Integer", defaultValue = ""), @ApiImplicitParam(name = "areaId", value = "区域ID", required = false, dataType = "Integer", defaultValue = ""),
}) })
...@@ -72,11 +74,21 @@ public class BaseAreaInfoController { ...@@ -72,11 +74,21 @@ public class BaseAreaInfoController {
} }
@ApiOperation(httpMethod="GET",value="区域基础信息-根据区划类型查询对应集合数据", notes="") @ApiOperation(httpMethod="GET",value="区域基础信息-根据区划类型查询对应集合数据", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "customQueryFlag", value = "是否查询自定义区域", required = false, dataType = "Boolean", defaultValue = "false"),
})
@GetMapping(value = "/byCondition") @GetMapping(value = "/byCondition")
public JsonViewObject getListByType(@RequestParam(value = "type", required = false, defaultValue = "2") String type) { public JsonViewObject getListByType(@RequestParam(value = "type", required = false, defaultValue = "2") String type,
@RequestParam(value = "customQueryFlag", required = false, defaultValue = "false") boolean customQueryFlag) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try { try {
List<BaseAreaInfoPO> list = baseAreaInfoService.selectByType(type); List<BaseAreaInfoPO> list = baseAreaInfoService.selectByType(type);
if (!list.isEmpty()) {
if (!customQueryFlag) {
//不查询自定义区域时,删除自定义区域记录
list.removeIf(o->Objects.equals(99,o.getCode()));
}
}
jsonViewObject.success(list); jsonViewObject.success(list);
} catch (Exception e) { } catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG")); jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
......
package net.wanji.opt.controllerv2.report.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author fengyi
* @date 2025/3/31
* @description
*/
@Data
public class ReportDataBody {
@ApiModelProperty(value = "文件名称", example = "",required = true)
String fileName;
@ApiModelProperty(required = true,value = "数据体")
String body;
}
...@@ -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<>();
......
...@@ -436,7 +436,7 @@ ...@@ -436,7 +436,7 @@
<select id="getListByStartAndEnd" parameterType="java.util.Map" resultType="java.util.Map"> <select id="getListByStartAndEnd" parameterType="java.util.Map" resultType="java.util.Map">
SELECT DATE_FORMAT(start_time,'%Y-%m-%d %H:%i:%s') startTime, SELECT DATE_FORMAT(start_time,'%Y-%m-%d %H:%i:%s') startTime,
DATE_FORMAT(end_time,'%Y-%m-%d %H:%i:%s') endTime, DATE_FORMAT(ifnull(end_time,now()) ,'%Y-%m-%d %H:%i:%s') endTime,
ABS(TIMESTAMPDIFF( SECOND, start_time, ifnull(end_time,now()) )) AS duration, ABS(TIMESTAMPDIFF( SECOND, start_time, ifnull(end_time,now()) )) AS duration,
info.type, info.type,
c.label as typeName, c.label as typeName,
...@@ -444,8 +444,7 @@ ...@@ -444,8 +444,7 @@
FROM t_event_info info FROM t_event_info info
JOIN t_config_event_category c ON info.type = c.event_type JOIN t_config_event_category c ON info.type = c.event_type
WHERE cross_id = #{crossId} WHERE cross_id = #{crossId}
and start_time BETWEEN #{startTime} and start_time BETWEEN #{startTime} AND #{endTime}
AND start_time AND #{endTime}
<!-- AND end_time is not null --> <!-- AND end_time is not null -->
ORDER BY ORDER BY
start_time DESC start_time DESC
......
...@@ -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