Commit 2291c656 authored by 黄伟铭's avatar 黄伟铭
parents 91ae0430 fc1fd3b5
package net.wanji.opt.controllerv2.evaluation;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.controllerv2.judgeanalysis.design.response.areaproblem.AreaProblemOverview;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.servicev2.evaluation.EvaluationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
@RestController
@Slf4j
@RequestMapping("/evaluation-info")
@Api(value="EvaluationInfoController", description="方案评价信息接口", tags = "方案评价信息")
public class EvaluationInfoController {
@Autowired
EvaluationInfoService evaluationInfoService;
@ApiOperation(value = "方案评价-总结", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "分析时段开始时间", required = false, dataType = "string"),
@ApiImplicitParam(name = "endTime", value = "分析时段截止时间", required = false, dataType = "string"),
@ApiImplicitParam(name = "contrastStartTime", value = "对比时段开始时间", required = false, dataType = "string"),
@ApiImplicitParam(name = "constrastEndTime", value = "对比时段截止时间", required = false, dataType = "string"),
})
@GetMapping(value = "/overview")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AreaProblemOverview.class),
})
public JsonViewObject problemOverview(String crossId,String startTime, String endTime,String contrastStartTime,String constrastEndTime) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try{
Map<String,Object> resData=evaluationInfoService.getListEvaluationSummarize(crossId,startTime,endTime,contrastStartTime,constrastEndTime);
jsonViewObject.success(resData);
}catch (Exception e){
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
}
package net.wanji.opt.controllerv2.judgeanalysis;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -11,11 +12,13 @@ import net.wanji.common.framework.rest.AbstractRestServer;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.Page;
import net.wanji.common.framework.rest.impl.AbstractRestServerImpl;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.po.BaseAreaInfoPO;
import net.wanji.opt.entity.BaseAreaInfo;
import net.wanji.opt.servicev2.judgeanalysis.BaseAreaInfoService;
import net.wanji.opt.vo.GreenWaveRunStateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.MediaType;
......@@ -56,4 +59,53 @@ public class BaseAreaInfoController {
return jsonViewObject;
}
@ApiOperation(httpMethod="POST",value="区域基础信息-自定义区域", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "区域ID", required = true, dataType = "String"),
@ApiImplicitParam(name = "wkt", value = "区域边界", required = true, dataType = "String", defaultValue = "117.049347926,36.654744674;117.066122093,36.654772445;117.0800809517208,36.65440636491661;117.07979265456723,36.65214909599633;117.07706941120558,36.63829789737139;117.07414217382905,36.63736765765722;117.0707410731053,36.636677059391445;117.06550839703021,36.63722151604908;117.06267677771574,36.63667912391616;117.0577271202223,36.63483777099411;117.05251580910459,36.63437969486462;117.04433347163972,36.63696466063367;117.04843387376732,36.637934238407;117.04968488845323,36.638408635754985;117.049347926,36.654744674;117.066122093,36.654772445;117.0800809517208,36.65440636491661;117.07979265456723,36.65214909599633;117.07706941120558,36.63829789737139;117.07414217382905,36.63736765765722;117.0707410731053,36.636677059391445;117.06550839703021,36.63722151604908;117.06267677771574,36.63667912391616;117.0577271202223,36.63483777099411;117.05251580910459,36.63437969486462;117.04433347163972,36.63696466063367;117.04843387376732,36.637934238407;117.04968488845323,36.638408635754985;117.049347926,36.654744674"),
@ApiImplicitParam(name = "type", value = "区划类型:1行政区划;2交警辖区;3商圈;4交通小区;5热点区域;6道路", required = true, dataType = "Integer", defaultValue = "2"),
})
@PostMapping(value = "/insertAreaInfo")
public JsonViewObject insertAreaInfo(@RequestParam(value = "name", required = true) String name,
@RequestParam(value = "wkt", required = true) String wkt,
@RequestParam(value = "type", required = true,defaultValue = "2") Integer type) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
BaseAreaInfoPO baseAreaInfoPO = new BaseAreaInfoPO();
baseAreaInfoPO.setName(name);
baseAreaInfoPO.setPolylines(wkt);
baseAreaInfoPO.setType(type);
baseAreaInfoService.insertAreaInfo(baseAreaInfoPO);
jsonViewObject.success();
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
@ApiOperation(httpMethod="GET",value="干线路口基础信息-根据区域查询对应集合数据", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaId", value = "区域ID", required = false, dataType = "Integer", defaultValue = "12"),
@ApiImplicitParam(name = "wkt", value = "区域边界", required = false, dataType = "String", defaultValue = "117.049347926,36.654744674;117.066122093,36.654772445;117.0800809517208,36.65440636491661;117.07979265456723,36.65214909599633;117.07706941120558,36.63829789737139;117.07414217382905,36.63736765765722;117.0707410731053,36.636677059391445;117.06550839703021,36.63722151604908;117.06267677771574,36.63667912391616;117.0577271202223,36.63483777099411;117.05251580910459,36.63437969486462;117.04433347163972,36.63696466063367;117.04843387376732,36.637934238407;117.04968488845323,36.638408635754985;117.049347926,36.654744674;117.066122093,36.654772445;117.0800809517208,36.65440636491661;117.07979265456723,36.65214909599633;117.07706941120558,36.63829789737139;117.07414217382905,36.63736765765722;117.0707410731053,36.636677059391445;117.06550839703021,36.63722151604908;117.06267677771574,36.63667912391616;117.0577271202223,36.63483777099411;117.05251580910459,36.63437969486462;117.04433347163972,36.63696466063367;117.04843387376732,36.637934238407;117.04968488845323,36.638408635754985;117.049347926,36.654744674"),
@ApiImplicitParam(name = "type", value = "查询类型,1-干线信息 2-路口信息", required = false, dataType = "Integer", defaultValue = "1"),
})
@GetMapping(value = "/getGreenByArea")
public JsonViewObject getGreenByAre(@RequestParam(value = "areaId", required = false, defaultValue = "12") Integer areaId,
@RequestParam(value = "wkt", required = false) String wkt,
@RequestParam(value = "type", required = false) Integer type) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
JSONObject jsonObject = baseAreaInfoService.getGreenByWkt(areaId,wkt,type);
jsonViewObject.success(jsonObject);
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
}
package net.wanji.opt.servicev2.evaluation;
import com.baomidou.mybatisplus.extension.service.IService;
import net.wanji.databus.po.CrossDataHistPO;
import java.util.List;
import java.util.Map;
public interface EvaluationInfoService extends IService<CrossDataHistPO> {
Map<String,Object> getListEvaluationSummarize(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime);
}
package net.wanji.opt.servicev2.evaluation.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.constant.ServiceLevelEnum;
import net.wanji.opt.servicev2.evaluation.EvaluationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, CrossDataHistPO> implements EvaluationInfoService {
@Autowired
CrossDataHistMapper crossDataHistMapper;
@Override
public Map<String,Object> getListEvaluationSummarize(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) {
//分析时间的数据
List<CrossDataHistPO> analyseList= crossDataHistMapper.getListEvaluationanalyse(crossId,startTime,endTime);
//比较时间的数据
List<CrossDataHistPO> contrastList= crossDataHistMapper.getListEvaluationcontrast(crossId,contrastStartTime,constrastEndTime);
//分析时间服务水平
List<CrossDataHistPO> ServiceLevelanalyseList= crossDataHistMapper.getEvaluationanalyseServiceLevel(crossId,startTime,endTime);
//比较时间的服务水平
List<CrossDataHistPO> contrastServiceLevelList= crossDataHistMapper.getServiceLevelEvaluationcontrast(crossId,contrastStartTime,constrastEndTime);
//取出分析时间 的速度 延误 排队长度
Double speed=0.00;
Integer delayTime =0;
Double queueLength=0.00;
//分析的交通流量
int analyseFlow=0;
for (CrossDataHistPO analyselist:analyseList){
if (analyselist == null) {
continue; // 跳过空元素
}
speed = analyselist.getSpeed();
delayTime = analyselist.getDelayTime();
queueLength = analyselist.getQueueLength();
analyseFlow= analyselist.getFlow();
}
//取出对比时间 的速度 延误 排队长度
Double speedCompare=0.00;
Integer delayTimeCompare =0;
Double queueLengthCompare=0.00;
//对比的交通流量
int contrastFlow=0;
for (CrossDataHistPO contrastlist:contrastList){
if (contrastlist == null) {
continue; // 跳过空元素
}
speedCompare = contrastlist.getSpeed();
delayTimeCompare = contrastlist.getDelayTime();
queueLengthCompare = contrastlist.getQueueLength();
contrastFlow= contrastlist.getFlow();
}
// 计算速度变化百分比
double speedChangePercent = calculatePercentage(speed, speedCompare);
// 计算延误变化百分比
double delayTimeChangePercent = calculatePercentage(delayTime, delayTimeCompare);
// 计算排队长度变化百分比
double queueLengthChangePercent = calculatePercentage(queueLength, queueLengthCompare);
// 计算交通流量百分比
double flow= calculatePercentage(analyseFlow, contrastFlow);
//取出分析时间的服务水平
String analyseserviceLevel = getServiceLevel(ServiceLevelanalyseList);
//取出对比时间的服务水平
String compareServiceLevel = getServiceLevel(contrastServiceLevelList);
JSONObject jsonObject = new JSONObject();
jsonObject.put("speed", speedChangePercent+"%");
jsonObject.put("delay",delayTimeChangePercent+"%");
jsonObject.put("queueLength",queueLengthChangePercent+"%");
jsonObject.put("flow",flow+"%");
jsonObject.put("analyseserviceLevel",analyseserviceLevel);
jsonObject.put("compareServiceLevel",compareServiceLevel);
return jsonObject;
}
/**
* 计算变化百分比
*
* @param analyseValue 分析值
* @param contrastValue 对比值
* @return 变化百分比(保留两位小数)
*/
private static double calculatePercentage(double analyseValue, double contrastValue) {
// 防止除零错误
if (analyseValue == 0) {
return 0;
}
// 计算变化值(分析值 - 对比值)
double difference = analyseValue - contrastValue;
// 计算变化百分比,并保留两位小数(差值/对比值)
return Math.round((difference / contrastValue) * 100 * 100.0) / 100.0;
}
/*获取服务水平*/
public String getServiceLevel(List<CrossDataHistPO> list){
//按服务水平分组
Map<String, List<CrossDataHistPO>> groupByServerLevel = list.stream().collect(Collectors.groupingBy(o -> o.getServiceLevel()));
double total = 0;
for (Map.Entry<String, List<CrossDataHistPO>> entry1 : groupByServerLevel.entrySet()) {
String key = entry1.getKey();
total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue().size();
}
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total/list.size());
String serviceLevel = ServiceLevelEnum.getByVal(avgService)==null?"A":ServiceLevelEnum.getByVal(avgService).getType();
return serviceLevel;
}
}
......@@ -261,16 +261,16 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
// 优化时间计算
optMonitoringVO.setOptTime(optTime);
optMonitoringVO.setOptStatus(0);
if (Objects.nonNull(optTime)) {
if (Objects.nonNull(optTime) && StringUtils.endsWithIgnoreCase(type, evenType) &&
!StringUtils.endsWithIgnoreCase("700", evenType)) {
// 空放优化中,6秒钟结束,当前时间小于开始时间+持续时间
if (StringUtils.endsWithIgnoreCase(EventInfoTypeEnum.PHASE_EMPTY.getEventType(), evenType) && StringUtils.endsWithIgnoreCase(type, evenType)
&& (current - optTime.getTime() <= 6 * 1000)) {
log.error("当前路口空放:{}, 当前系统时间:{}, 优化时间:{}, 事件发生时间:{}", crossId, current, optTime.getTime());
if (StringUtils.endsWithIgnoreCase(EventInfoTypeEnum.PHASE_EMPTY.getEventType(), evenType) && (current - optTime.getTime() <= 6 * 1000)) {
log.error("当前路口空放:{}, 事件类型:{}, 优化类型:{}, ", crossId, evenType, type);
optMonitoringVO.setOptStatus(1);
optMonitoringVO.setOptStatusDesc("优化中");
// 其他事件优化中,当前时间小于优化时间+持续时间
} else if (StringUtils.endsWithIgnoreCase(type, evenType) && current - optTime.getTime() <= duration * 1000) {
log.error("当前路口失衡溢出事件:{}, 当前系统时间:{}, 优化时间:{}, 事件发生时间:{}", crossId, current, optTime.getTime());
} else if (current - optTime.getTime() <= duration * 1000) {
log.error("当前路口失衡溢出事件:{}, 事件类型:{}, 优化类型:{}, ", crossId, evenType, type);
optMonitoringVO.setOptStatus(1);
optMonitoringVO.setOptStatusDesc("优化中");
}
......
package net.wanji.opt.servicev2.judgeanalysis;
import com.alibaba.fastjson.JSONObject;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.po.BaseAreaInfoPO;
import java.util.List;
......@@ -15,4 +17,8 @@ import java.util.List;
*/
public interface BaseAreaInfoService {
List<BaseAreaInfoPO> selectByType(Integer type);
JSONObject getGreenByWkt(Integer areaId, String wkt, Integer type);
void insertAreaInfo(BaseAreaInfoPO baseAreaInfoPO);
}
package net.wanji.opt.servicev2.judgeanalysis.impl;
import com.alibaba.fastjson.JSONObject;
import net.wanji.common.framework.dubbointerface.impl.BaseDubboInterfaceImpl;
import net.wanji.common.framework.mapper.BaseInterfaceMapper;
import net.wanji.common.gts.service.GtsService;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.BaseAreaInfoMapper;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.po.BaseAreaInfoPO;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.opt.entity.BaseAreaInfo;
import lombok.extern.slf4j.Slf4j;
import net.wanji.opt.servicev2.judgeanalysis.BaseAreaInfoService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -32,7 +41,13 @@ public class BaseAreaInfoServiceImpl implements BaseAreaInfoService {
@Resource
private BaseAreaInfoMapper baseAreaInfoMapper;
@Resource
private GreenwaveInfoMapper greenwaveInfoMapper;
@Resource
private BaseCrossInfoMapper baseCrossInfoMapper;
@Resource
private GtsService gtsService;
/**
* 根据区划类型查询对应集合(含子集)
......@@ -50,4 +65,69 @@ public class BaseAreaInfoServiceImpl implements BaseAreaInfoService {
return retList;
}
@Override
public JSONObject getGreenByWkt(Integer areaId, String wkt, Integer type) {
if(ObjectUtils.isEmpty(wkt)){
BaseAreaInfoPO areaInfoPO = baseAreaInfoMapper.selectById(areaId);
wkt = areaInfoPO.getPolylines();
}
if(ObjectUtils.isEmpty(wkt)){
return null;
}
JSONObject jsonObject = new JSONObject();
if(ObjectUtils.isEmpty(type) || type == 1){
String finalWkt = wkt;
List<GreenwaveInfoPO> greenwaveInfoPOList = greenwaveInfoMapper.selectAll().stream().filter(x->{
//使用gts方法判断区域是否包含
boolean contains = gtsService.contains(finalWkt, x.getWkt());
if(contains){
return contains;
}
//使用gts方法判断区域是否相交
boolean intersects = gtsService.intersects(finalWkt, x.getWkt());
return intersects;
}).collect(Collectors.toList());
jsonObject.put("greenInfoList",greenwaveInfoPOList);
}
if(ObjectUtils.isEmpty(type) || type == 2){
String finalWkt1 = wkt;
List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll().stream().filter(x->{
boolean contains = gtsService.contains(finalWkt1, convertPointString(x.getLocation()));
return contains;
}).collect(Collectors.toList());
jsonObject.put("crossInfoList",baseCrossInfoPOS);
}
return jsonObject;
}
@Override
public void insertAreaInfo(BaseAreaInfoPO baseAreaInfoPO) {
baseAreaInfoPO.setCode(99);
baseAreaInfoPO.setRoadName("自定义区域");
baseAreaInfoPO.setLocation(gtsService.centroid(baseAreaInfoPO.getPolylines()));
baseAreaInfoPO.setParentCode(99);
baseAreaInfoPO.setRemark("");
baseAreaInfoMapper.insertOne(baseAreaInfoPO);
}
/**
* 将 POINT 类型的字符串转换为经纬度格式
*
* @param pointStr 输入的 POINT 字符串,例如 "POINT(116.875165 36.648904)"
* @return 转换后的经纬度字符串,例如 "116.875165,36.648904"
*/
public static String convertPointString(String pointStr) {
if (pointStr == null || !pointStr.startsWith("POINT(") || !pointStr.endsWith(")")) {
throw new IllegalArgumentException("输入字符串格式不正确,必须是 POINT(x y) 格式");
}
// 去掉前缀 "POINT(" 和后缀 ")"
String coordinates = pointStr.substring(6, pointStr.length() - 1);
// 替换空格为逗号
return coordinates.replace(" ", ",");
}
}
......@@ -137,9 +137,7 @@
)
</insert>
<select id="greenOptimizeByTimeTrend" parameterType="map" resultMap="AiOptimizeStatisticMap">
SELECT optimize_count,cross_id,
strategy,statistic_time,
type
SELECT sum(optimize_count) as optimize_count
FROM t_ai_optimize_statistic t1
WHERE
1=1
......
......@@ -39,6 +39,7 @@ public class CrossSchedulesPO {
private String weeks;
/** 特殊日期 */
@ApiModelProperty(value = "特殊日期",notes = "")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date specialDate ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
......
......@@ -33,4 +33,12 @@ public interface CrossDataHistMapper extends BaseMapper<CrossDataHistPO> {
List<CrossDataHistPO> selectByStartEnd(int startStamp, int endStamp);
List<CrossDataHistPOExt> selectExtByCrossIdAndStartEnd(String crossId, int startStamp, int endStamp);
List<CrossDataHistPO> getListEvaluationanalyse(@Param("crossId") String crossId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<CrossDataHistPO> getListEvaluationcontrast(@Param("crossId") String crossId, @Param("contrastStartTime") String contrastStartTime, @Param("constrastEndTime") String constrastEndTime);
List<CrossDataHistPO> getEvaluationanalyseServiceLevel(@Param("crossId")String crossId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<CrossDataHistPO> getServiceLevelEvaluationcontrast(@Param("crossId") String crossId, @Param("contrastStartTime") String contrastStartTime,@Param("constrastEndTime") String constrastEndTime);
}
......@@ -238,16 +238,26 @@
AND section.scheme_id = scheme.id
WHERE
schedules.cross_id = #{crossId}
AND schedules.`week` = #{week}
AND (
DATE_FORMAT(schedules.special_date, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
OR
(
schedules.week = #{week}
AND (
DATE_FORMAT(schedules.special_date, '%Y-%m-%d') != DATE_FORMAT(NOW(), '%Y-%m-%d')
OR schedules.special_date IS NULL
)
)
)
AND DATE_FORMAT( NOW(), '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' )
AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' )
ORDER BY schedules.special_date, DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) DESC LIMIT 1
ORDER BY schedules.special_date, DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ),schedules.special_date DESC LIMIT 1
</select>
<select id="selectSchemeByParams" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
SELECT
scheme.id AS id,scheme.scheme_no AS schemeNo,scheme.name AS name,scheme.cross_id AS crossId,scheme.cycle AS cycle,scheme.coord_phase AS coordPhase,scheme.offset AS offset,scheme.source AS source,scheme.is_deleted AS isDeleted,scheme.status AS status,scheme.gmt_create AS gmtCreate,scheme.gmt_modified AS gmtModified
FROM
scheme.id AS id,scheme.scheme_no AS schemeNo,scheme.name AS name,scheme.cross_id AS crossId,scheme.cycle AS cycle,scheme.coord_phase AS coordPhase,scheme.offset AS offset,scheme.source AS source,scheme.is_deleted AS isDeleted,scheme.status AS status,scheme.gmt_create AS gmtCreate,scheme.gmt_modified AS gmtModified
FROM
t_cross_schedules schedules
LEFT JOIN t_cross_section section ON section.cross_id = schedules.cross_id
AND schedules.plan_id = section.plan_id
......@@ -255,10 +265,21 @@
AND section.scheme_id = scheme.id
WHERE
schedules.cross_id = #{crossId}
AND schedules.`week` = #{week}
AND (
DATE_FORMAT(schedules.special_date, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
OR
(
schedules.week = #{week}
AND (
DATE_FORMAT(schedules.special_date, '%Y-%m-%d') != DATE_FORMAT(NOW(), '%Y-%m-%d')
OR schedules.special_date IS NULL
)
)
)
AND DATE_FORMAT( #{queryTime}, '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' )
AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' )
ORDER BY schedules.special_date, DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) DESC LIMIT 1
ORDER BY schedules.special_date, DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ),schedules.special_date DESC LIMIT 1
</select>
......
......@@ -158,4 +158,64 @@
order by batch_time
</select>
<select id="getListEvaluationanalyse" resultType="net.wanji.databus.po.CrossDataHistPO" resultMap="BaseResultMap">
select
cross_id,avg(speed) as speed,
avg(delay_time) as delay_time,
avg(queue_length) as queue_length,start_time,
sum(flow) as flow
FROM t_cross_data_hist
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
<if test="startTime!=null and startTime!='' and endTime!='' and endTime!=null">
AND start_time>=#{startTime} and start_time &lt;=#{endTime}
</if>
</select>
<select id="getListEvaluationcontrast" resultType="net.wanji.databus.po.CrossDataHistPO" resultMap="BaseResultMap">
select
cross_id,avg(speed) as speed,
avg(delay_time) as delay_time,
avg(queue_length) as queue_length,start_time,
sum(flow) as flow
FROM t_cross_data_hist
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
<if test="contrastStartTime!=null and contrastStartTime!='' and constrastEndTime!='' and constrastEndTime!=null">
AND start_time>=#{contrastStartTime} and start_time &lt;=#{constrastEndTime}
</if>
</select>
<select id="getEvaluationanalyseServiceLevel" resultType="net.wanji.databus.po.CrossDataHistPO" resultMap="BaseResultMap">
select
cross_id,service_level
FROM t_cross_data_hist
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
<if test="startTime!=null and startTime!='' and endTime!='' and endTime!=null">
AND start_time>=#{startTime} and start_time &lt;=#{endTime}
</if>
</select>
<select id="getServiceLevelEvaluationcontrast" resultType="net.wanji.databus.po.CrossDataHistPO" resultMap="BaseResultMap">
select
cross_id,service_level
FROM t_cross_data_hist
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
<if test="contrastStartTime!=null and contrastStartTime!='' and constrastEndTime!='' and constrastEndTime!=null">
AND start_time>=#{contrastStartTime} and start_time &lt;=#{constrastEndTime}
</if>
</select>
</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