Commit 9b741610 authored by zhoushiguang's avatar zhoushiguang

干线评价指标接口

parent f708007b
/*
* Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD.
* All rights reserved.
* Official Web Site: http://www.xiaominfo.com.
* Developer Web Site: http://open.xiaominfo.com.
*/
package net.wanji.opt.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.google.common.collect.Lists;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.List;
//import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
//import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
//import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
/**
* @author <a href="mailto:xiaoymin@foxmail.com">xiaoymin@foxmail.com</a>
* 2020/11/07 9:26
* @since:knife4j-spring-boot-fast-demo 1.0
*/
@Configuration
//@EnableSwagger2WebMvc
@EnableSwagger2
@EnableKnife4j
public class Knife4jConfiguration {
/**
* 设置头,因为平台携带token进行验证,所以需要在Swagger添加头设置的功能
* @return
*/
private List<SecurityScheme> securitySchemes(){
return Lists.newArrayList(
new ApiKey("Authorization","token","header"));
}
private List<SecurityContext> securityContexts(){
return Lists.newArrayList(SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.regex("^(?!login).*$"))
.build()
);
}
private List<SecurityReference> defaultAuth() {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
return Lists.newArrayList(
new SecurityReference("Authorization",authorizationScopes)
);
}
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
String groupName="v0.1版本";
Docket docket=new Docket(DocumentationType.SWAGGER_2)
//.host(swaggerDocUrl)
.apiInfo(apiInfo())
.groupName(groupName)
.select()
.apis(RequestHandlerSelectors.basePackage("com.wanji.holo.restful"))
.paths(PathSelectors.any())
.build()
.securitySchemes(securitySchemes())
.securityContexts(securityContexts())
;//.extensions(openApiExtensionResolver.buildSettingExtensions());
return docket;
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("全息路段接口文档")
.description("全息路口监测系统 RESTful APIs")
//.termsOfServiceUrl(swaggerDocUrl)
.contact("wj@qq.com")
.version("0.1")
.build();
}
}
package net.wanji.opt.controller;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.AbstractRestServer;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.impl.AbstractRestServerImpl;
import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.service.GreenwaveHistProvider;
import net.wanji.opt.vo.GreenwaveCrossMetricsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
/**
* <p>
* 绿波历史数据 接口API
* </p>
* @version 1.0
* @author fengyi
* @Date 2024-11-18
*/
@RestController
@Slf4j
@RequestMapping("/greenwave-hist")
@Api(value="GreenwaveHistRestServer", description="绿波历史数据接口", tags = "绿波干线评价")
public class GreenwaveHistRestServer {
@Autowired
private GreenwaveHistProvider greenwaveHistProvider;
@GetMapping("/findStatisticIndexTrend")
@ApiOperation(httpMethod="GET",value="绿波历史数据-数据指标统计", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "String",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-05 00:00:00")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findStatisticIndex(String greenId,@RequestParam(defaultValue ="2024-11-12 00:00:00") String startTime,
@RequestParam(defaultValue ="2024-11-13 00:00:00") String endTime) {
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
JSONObject list = greenwaveHistProvider.findStatisticIndex(greenId,startTime,endTime,null);
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
@GetMapping("/findGreenCrossInfo")
@ApiOperation(httpMethod="GET",value="绿波干线路口信息查询", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "String",defaultValue = "1")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenCrossInfo(Integer greenId) {
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
List<Map<String,Object>> list = greenwaveHistProvider.findGreenCross(greenId);
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
@GetMapping("/findUnCoordinateDirIndex")
@ApiOperation(httpMethod="GET",value="绿波非协调方向指标趋势", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"),
@ApiImplicitParam(name = "greenDir", value = "绿波协调方向,多个逗号分隔", required = true, dataType = "String",defaultValue = "5,7"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-05 00:00:00")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findUnCoordinateDirIndex(String crossId,String greenDir,String startTime,String endTime) {
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
JSONObject list = greenwaveHistProvider.findUnCoordinateCrossIndex(crossId,greenDir,startTime,endTime);
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
}
......@@ -49,7 +49,7 @@ public class RunningEvaluateController {
return JsonViewObject.newInstance().success(res);
}
@ApiOperation(value = "路口评价", notes = "路口评价", response = JsonViewObject.class,
@ApiOperation(value = "信号评价-路口评价", notes = "路口评价", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossEvaluate",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......
package net.wanji.opt.dao.mapper;
import net.wanji.common.framework.mapper.BaseInterfaceMapper;
import net.wanji.opt.entity.GreenwaveHist;
import java.util.List;
import java.util.Map;
/**
* <p>
* 绿波历史数据
* </p>
*
* @Author fengyi
* @Date 2024-11-18
*/
public interface GreenwaveHistoryMapper extends BaseInterfaceMapper<GreenwaveHist> {
/**
* 绿波历史指标查询
* @param params
* @return
*/
public List<GreenwaveHist> findStatisticIndex(Map<String,Object> params);
/**
* 干线路口查询
* @param params
* @return
*/
List<Map<String,Object>> findGreenCross(Map<String,Object> params);
/**
* 查看非协调方向路口指标
* @return
*/
List<GreenwaveHist> findUnCoordinateCrossIndex(Map<String,Object> params);
}
package net.wanji.opt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wanji.common.framework.domain.TrackableEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
* 绿波历史数据
* </p>
*
* @Author fengyi
* @Date 2024-11-18
*/
@Data
@ApiModel(value="GreenwaveHist对象", description="绿波历史数据")
public class GreenwaveHist extends TrackableEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "绿波编号")
private Integer greenId;
@ApiModelProperty(value = "协调方向 0正向 1反向 2双向")
private int direction;
@ApiModelProperty(value = "交通状态:1畅通;2缓行;3拥堵;4严重拥堵;5未知")
private Integer status;
@ApiModelProperty(value = "拥堵类型:1常规;2异常")
private Integer type;
@ApiModelProperty(value = "交通指数")
private BigDecimal trafficIndex;
@ApiModelProperty(value = "行程速度(km/h)")
private BigDecimal speed;
@ApiModelProperty(value = "行程时间(秒)")
private Integer trvalTime;
@ApiModelProperty(value = "停车次数")
private BigDecimal stopTimes;
@ApiModelProperty(value = "拥堵距离(米)")
private BigDecimal queueLength;
@ApiModelProperty(value = "拥堵比例")
private BigDecimal congRate;
@ApiModelProperty(value = "延误时间(秒)")
private Integer delayTime;
@ApiModelProperty(value = "不停车通过率")
private BigDecimal noparkPassRate;
@ApiModelProperty(value = "协调方案可靠性")
private BigDecimal cordReliability;
@ApiModelProperty(value = "协调路段排队空间占比")
private BigDecimal cordQueueRatio;
@ApiModelProperty(value = "非协调相位二次排队")
private BigDecimal uncoordinatePhaseQueue;
@ApiModelProperty(value = "开始时间:yyyy-MM-dd HH:mm:ss")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date startTime;
@ApiModelProperty(value = "创建时间")
private Date gmtCreate;
@ApiModelProperty(value = "修改时间")
private Date gmtModified;
@ApiModelProperty(value = "绿波车流方向")
private String roadDirection;
@ApiModelProperty(value = "路口ID")
private String crossId;
}
package net.wanji.opt.service;
import com.alibaba.fastjson.JSONObject;
import net.wanji.common.framework.dubbointerface.BaseDubboInterface;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.opt.entity.GreenwaveHist;
import java.util.List;
import java.util.Map;
/**
* <p>
* 绿波历史数据
* </p>
*
* @Author fengyi
* @Date 2024-11-18
*/
public interface GreenwaveHistProvider extends BaseDubboInterface<GreenwaveHist> {
/**
*
* @param greenId
* @param startTime
* @param endTime
* @param type
* @return
* @throws DubboProviderException
*/
JSONObject findStatisticIndex(String greenId, String startTime, String endTime, String type) throws DubboProviderException;
/**
* 干线路口信息
* @param greenId
* @return
* @throws DubboProviderException
*/
List<Map<String, Object>> findGreenCross(Integer greenId) throws DubboProviderException;
/**
* 非协调方向路口指标统计
* @param crossId 路口ID
* @param greenDir 协调方向
* @param startTime 开始时间
* @param endTime 截止时间
* @return
*/
JSONObject findUnCoordinateCrossIndex(String crossId,String greenDir, String startTime, String endTime) throws DubboProviderException;
}
package net.wanji.opt.service.impl;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.dubbointerface.impl.BaseDubboInterfaceImpl;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.mapper.BaseInterfaceMapper;
import net.wanji.common.utils.tool.DateUtil;
import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper;
import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.service.GreenwaveHistProvider;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Collectors;
/**
* <p>
* 绿波历史数据
* </p>
*
* @Author fengyi
* @Date 2024-11-18
*/
@Slf4j
@Component
@DubboService
public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveHist> implements GreenwaveHistProvider {
@Resource
private GreenwaveHistoryMapper greenwaveHistoryMapper;
@Override
public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() {
return this.greenwaveHistoryMapper;
}
@Override
public JSONObject findStatisticIndex(String greenId, String startTime, String endTime, String type) {
Map<String, Object> params = new HashMap<>();
params.put("greenId", greenId);
params.put("startDate", startTime);
params.put("endDate", endTime);
List<GreenwaveHist> list = greenwaveHistoryMapper.findStatisticIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//存放时段
Set<String> sortedSet = new TreeSet<>();
//存放所有进口数据
List<Map<String, Object>> allList = new ArrayList<>();
//按时间分组分组
Map<String, List<GreenwaveHist>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getRoadDirection(), TreeMap::new, Collectors.toList()));
List<Map<String, Object>> turnList = new ArrayList<>();
for (Map.Entry<String, List<GreenwaveHist>> entry : groupByDir.entrySet()) {
String key = entry.getKey();
//按方向排序
List<GreenwaveHist> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
Map<String, Object> mapList = new HashMap<>();
mapList.put("direction", key);
mapList.put("list", value);
allList.add(mapList);
for (GreenwaveHist po : value) {
Map<String, Object> turnMap = new HashMap<>();
turnMap.put("direction", po.getDirection());
if (!turnList.contains(turnMap)) {
turnList.add(turnMap);
}
//提取时间
sortedSet.add(DateUtil.formatDate(po.getStartTime(), "HH:mm"));
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", type);
jsonObject.put("timeList", sortedSet);
jsonObject.put("dataList", allList);
jsonObject.put("directionList", new int[]{0, 1, 2});
return jsonObject;
}
@Override
public List<Map<String, Object>> findGreenCross(Integer greenId) throws DubboProviderException {
Map<String,Object> params = new HashMap<>();
params.put("greenId",greenId);
List<Map<String, Object>> list = greenwaveHistoryMapper.findGreenCross(params);
String dirs = list.stream().map(o->o.get("inDir").toString()).distinct().collect(Collectors.joining(","));
return list;
}
@Override
public JSONObject findUnCoordinateCrossIndex(String crossId, String greenDir, String startTime, String endTime) {
Map<String,Object> params = new HashMap<>();
params.put("crossId",crossId);
params.put("startDate",startTime);
params.put("endDate",endTime);
params.put("greenDir",greenDir);
List<GreenwaveHist> list = greenwaveHistoryMapper.findUnCoordinateCrossIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//存放时段
Set<String> sortedSet = new TreeSet<>();
//存放所有进口数据
List<Map<String, Object>> allList = new ArrayList<>();
//按时间分组分组
Map<Integer, List<GreenwaveHist>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getDirection(), TreeMap::new, Collectors.toList()));
List<Map<String, Object>> turnList = new ArrayList<>();
for (Map.Entry<Integer, List<GreenwaveHist>> entry : groupByDir.entrySet()) {
Integer key = entry.getKey();
//按方向排序
List<GreenwaveHist> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
Map<String, Object> mapList = new HashMap<>();
mapList.put("direction", key);
mapList.put("list", value);
allList.add(mapList);
for (GreenwaveHist po : value) {
Map<String, Object> turnMap = new HashMap<>();
turnMap.put("direction", po.getDirection());
if (!turnList.contains(turnMap)) {
turnList.add(turnMap);
}
//提取时间
sortedSet.add(DateUtil.formatDate(po.getStartTime(), "HH:mm"));
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet);
jsonObject.put("dataList", allList);
return jsonObject;
}
}
spring:
application:
# dubbo启动需要程序名称
name: signal-optimize-service
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
server-addr: 37.12.182.29:8848
file-extension: yaml
group: signal
namespace: signal
username: nacos
password: nacos
application:
# dubbo启动需要程序名称
name: signal-optimize-service
main:
allow-circular-references: true
\ No newline at end of file
......@@ -5,7 +5,7 @@ spring:
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
server-addr: 37.12.182.29:8848
file-extension: yaml
group: signal
namespace: signal
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.GreenwaveHistoryMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="net.wanji.opt.entity.GreenwaveHist">
<id column="id" property="id"/>
<result column="green_id" property="greenId"/>
<result column="status" property="status"/>
<result column="type" property="type"/>
<result column="traffic_index" property="trafficIndex"/>
<result column="speed" property="speed"/>
<result column="trval_time" property="trvalTime"/>
<result column="stop_times" property="stopTimes"/>
<result column="queue_length" property="queueLength"/>
<result column="cong_rate" property="congRate"/>
<result column="delay_time" property="delayTime"/>
<result column="nopark_pass_rate" property="noparkPassRate"/>
<result column="cord_reliability" property="cordReliability"/>
<result column="cord_queue_ratio" property="cordQueueRatio"/>
<result column="uncoordinate_phase_queue" property="uncoordinatePhaseQueue"/>
<result column="start_time" property="startTime"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="direction" property="direction"/>
<result column="road_direction" property="roadDirection"/>
<result column="cross_id" property="crossId"/>
</resultMap>
<sql id="Table_Name">
t_greenwave_hist
</sql>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, green_id, status, type, traffic_index, speed, trval_time, stop_times, queue_length, cong_rate, delay_time, nopark_pass_rate, cord_reliability, cord_queue_ratio, uncoordinate_phase_queue, start_time, gmt_create, gmt_modified,direction
</sql>
<!-- 绿波路口查询 -->
<select id="findGreenCross" resultType="map">
select a.green_id greenId, a.cross_id crossId, b.`name` crossName,a.in_dir inDir
from t_greenwave_cross a
join t_base_cross_info b on a.cross_id = b.id
where green_id = #{greenId}
</select>
<!-- 统计指标查询 -->
<select id="findStatisticIndex" resultMap="BaseResultMap">
SELECT
green_id,road_direction,
DATE_FORMAT( start_time, '%Y-%m-%d %H:%i:00' ) start_time,
round(AVG(speed),2) speed,
round(AVG(delay_time)) delay_time,
round(AVG(stop_times)) stop_times,
round(AVG(trval_time)) trval_time
FROM
t_greenwave_hist
where 1=1
<include refid="sql_query"/>
<include refid="fuzzySearch"/>
<if test="startDate !=null and endDate !=null">
AND start_time BETWEEN #{startDate}
AND #{endDate}
</if>
GROUP BY green_id,road_direction,DATE_FORMAT( start_time, '%Y-%m-%d %H:%i:00' );
</select>
<!-- 查看非协调方向路口指标 -->
<select id="findUnCoordinateCrossIndex" resultMap="BaseResultMap">
SELECT
t.cross_id ,t.direction, MAX(t.queue_length) queue_length,round(avg(stop_times),2) stop_times,DATE_FORMAT(t.start_time,'%Y-%m-%d %H:%i:00') start_time
FROM
(
SELECT
cross_id,
dir_type direction,
queue_length,
stop_times,
start_time
FROM
t_cross_dir_data_hist a
WHERE
cross_id = #{crossId}
AND dir_type not in (#{greenDir})
AND start_time BETWEEN #{startDate}
AND #{endDate}
) t
GROUP BY t.cross_id,DATE_FORMAT(start_time,'%Y-%m-%d %H:%i:00')
;
</select>
<!--新增操作 -->
<insert id="save" parameterType="net.wanji.opt.entity.GreenwaveHist">
insert into
<include refid="Table_Name"/>
(<include refid="Base_Column_List"/>)
values(
#{id}
,#{greenId}
,#{status}
,#{type}
,#{trafficIndex}
,#{speed}
,#{trvalTime}
,#{stopTimes}
,#{queueLength}
,#{congRate}
,#{delayTime}
,#{noparkPassRate}
,#{cordReliability}
,#{cordQueueRatio}
,#{uncoordinatePhaseQueue}
,#{startTime}
,#{gmtCreate}
,#{gmtModified}
)
</insert>
<!--根据ID查询-->
<select id="findById" resultMap="BaseResultMap" parameterType="String">
select
<include refid="Base_Column_List"/>
from
<include refid="Table_Name"/>
where id = #{id}
</select>
<!--获取数据总数-->
<select id="getCount" parameterType="java.util.Map" resultType="int">
select count(*) from
<include refid="Table_Name"/>
where 1=1
<include refid="sql_query"/>
<include refid="fuzzySearch"/>
</select>
<!-- 查询所有数据-->
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
<include refid="Table_Name"/>
<!--ORDER BY `dt_create_date` DESC-->
</select>
<!-- 通过条件查询所有数据-->
<select id="findByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
<include refid="Table_Name"/>
<where>
<include refid="sql_query"/>
<include refid="fuzzySearch"/>
</where>
<!--ORDER BY `dt_create_date` DESC-->
</select>
<!--分组分页查询-->
<select id="findByPage" parameterType="java.util.Map" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
<include refid="Table_Name"/>
<where>
<include refid="sql_query"/>
<include refid="fuzzySearch"/>
</where>
<!--ORDER BY `dt_create_date` DESC-->
limit #{startRowNum}, #{pageSize}
</select>
<!--更新-->
<update id="update" parameterType="net.wanji.opt.entity.GreenwaveHist">
update
<include refid="Table_Name"/>
<include refid="sql_update"/>
where
id = #{id}
</update>
<!--根据ID删除-->
<delete id="deleteById" parameterType="String">
delete from
<include refid="Table_Name"/>
where
id = #{id}
</delete>
<sql id="fuzzySearch">
<if test="keyword != null and keyword !=''">
and (locate(#{keyword,jdbcType=VARCHAR}, s_name)>0
)
</if>
</sql>
<sql id="sql_query">
<if test="id != null and id != '' ">
<![CDATA[ and id = #{id}]]>
</if>
<if test="greenId != null and greenId != '' ">
<![CDATA[ and green_id = #{greenId}]]>
</if>
<if test="status != null and status != '' ">
<![CDATA[ and status = #{status}]]>
</if>
<if test="type != null and type != '' ">
<![CDATA[ and type = #{type}]]>
</if>
<if test="trafficIndex != null and trafficIndex != '' ">
<![CDATA[ and traffic_index = #{trafficIndex}]]>
</if>
<if test="speed != null and speed != '' ">
<![CDATA[ and speed = #{speed}]]>
</if>
<if test="trvalTime != null and trvalTime != '' ">
<![CDATA[ and trval_time = #{trvalTime}]]>
</if>
<if test="stopTimes != null and stopTimes != '' ">
<![CDATA[ and stop_times = #{stopTimes}]]>
</if>
<if test="queueLength != null and queueLength != '' ">
<![CDATA[ and queue_length = #{queueLength}]]>
</if>
<if test="congRate != null and congRate != '' ">
<![CDATA[ and cong_rate = #{congRate}]]>
</if>
<if test="delayTime != null and delayTime != '' ">
<![CDATA[ and delay_time = #{delayTime}]]>
</if>
<if test="noparkPassRate != null and noparkPassRate != '' ">
<![CDATA[ and nopark_pass_rate = #{noparkPassRate}]]>
</if>
<if test="cordReliability != null and cordReliability != '' ">
<![CDATA[ and cord_reliability = #{cordReliability}]]>
</if>
<if test="cordQueueRatio != null and cordQueueRatio != '' ">
<![CDATA[ and cord_queue_ratio = #{cordQueueRatio}]]>
</if>
<if test="uncoordinatePhaseQueue != null and uncoordinatePhaseQueue != '' ">
<![CDATA[ and uncoordinate_phase_queue = #{uncoordinatePhaseQueue}]]>
</if>
<if test="startTime != null and startTime != '' ">
<![CDATA[ and start_time = #{startTime}]]>
</if>
<if test="gmtCreate != null and gmtCreate != '' ">
<![CDATA[ and gmt_create = #{gmtCreate}]]>
</if>
<if test="gmtModified != null and gmtModified != '' ">
<![CDATA[ and gmt_modified = #{gmtModified}]]>
</if>
</sql>
<!--更新操作-->
<sql id="sql_update">
<set>
<if test="id != null and id != '' ">
<![CDATA[ id = #{id}, ]]>
</if>
<if test="greenId != null and greenId != '' ">
<![CDATA[ green_id = #{greenId}, ]]>
</if>
<if test="status != null and status != '' ">
<![CDATA[ status = #{status}, ]]>
</if>
<if test="type != null and type != '' ">
<![CDATA[ type = #{type}, ]]>
</if>
<if test="trafficIndex != null and trafficIndex != '' ">
<![CDATA[ traffic_index = #{trafficIndex}, ]]>
</if>
<if test="speed != null and speed != '' ">
<![CDATA[ speed = #{speed}, ]]>
</if>
<if test="trvalTime != null and trvalTime != '' ">
<![CDATA[ trval_time = #{trvalTime}, ]]>
</if>
<if test="stopTimes != null and stopTimes != '' ">
<![CDATA[ stop_times = #{stopTimes}, ]]>
</if>
<if test="queueLength != null and queueLength != '' ">
<![CDATA[ queue_length = #{queueLength}, ]]>
</if>
<if test="congRate != null and congRate != '' ">
<![CDATA[ cong_rate = #{congRate}, ]]>
</if>
<if test="delayTime != null and delayTime != '' ">
<![CDATA[ delay_time = #{delayTime}, ]]>
</if>
<if test="noparkPassRate != null and noparkPassRate != '' ">
<![CDATA[ nopark_pass_rate = #{noparkPassRate}, ]]>
</if>
<if test="cordReliability != null and cordReliability != '' ">
<![CDATA[ cord_reliability = #{cordReliability}, ]]>
</if>
<if test="cordQueueRatio != null and cordQueueRatio != '' ">
<![CDATA[ cord_queue_ratio = #{cordQueueRatio}, ]]>
</if>
<if test="uncoordinatePhaseQueue != null and uncoordinatePhaseQueue != '' ">
<![CDATA[ uncoordinate_phase_queue = #{uncoordinatePhaseQueue}, ]]>
</if>
<if test="startTime != null and startTime != '' ">
<![CDATA[ start_time = #{startTime}, ]]>
</if>
<if test="gmtCreate != null and gmtCreate != '' ">
<![CDATA[ gmt_create = #{gmtCreate}, ]]>
</if>
<if test="gmtModified != null and gmtModified != '' ">
<![CDATA[ gmt_modified = #{gmtModified}, ]]>
</if>
</set>
</sql>
</mapper>
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