Commit 54c4384a authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 38f53bd4 4b90d2ea
/*
* 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 { ...@@ -49,7 +49,7 @@ public class RunningEvaluateController {
return JsonViewObject.newInstance().success(res); 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) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossEvaluate", @PostMapping(value = "/crossEvaluate",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......
...@@ -104,7 +104,7 @@ public class InduceSendController { ...@@ -104,7 +104,7 @@ public class InduceSendController {
param.setEndTime(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[1]); param.setEndTime(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[1]);
} else { } else {
param.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND)); param.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
param.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 30, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND)); param.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 60, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
} }
induceSendService.send(param); induceSendService.send(param);
} }
......
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;
}
...@@ -97,7 +97,7 @@ public class GreenwaveInducesHist implements Serializable { ...@@ -97,7 +97,7 @@ public class GreenwaveInducesHist implements Serializable {
* 0 未发布 1 已发布 * 0 未发布 1 已发布
*/ */
@TableField("status") @TableField("status")
private Integer status; private Integer status=0;
/** /**
* 执行时段 * 执行时段
......
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;
}
}
...@@ -3,6 +3,7 @@ package net.wanji.opt.task; ...@@ -3,6 +3,7 @@ package net.wanji.opt.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import freemarker.template.TemplateException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.Constants; import net.wanji.common.framework.Constants;
...@@ -21,10 +22,12 @@ import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper; ...@@ -21,10 +22,12 @@ import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper;
import net.wanji.opt.dto.induce.MessageParam; import net.wanji.opt.dto.induce.MessageParam;
import net.wanji.opt.entity.GreenwaveInduces; import net.wanji.opt.entity.GreenwaveInduces;
import net.wanji.opt.entity.GreenwaveInducesHist; import net.wanji.opt.entity.GreenwaveInducesHist;
import net.wanji.opt.entity.InduceTemplate;
import net.wanji.opt.po.StrategyGreenOptHistEntity; import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.service.induce.GreenwaveInducesHistService; import net.wanji.opt.service.induce.GreenwaveInducesHistService;
import net.wanji.opt.service.induce.GreenwaveInducesService; import net.wanji.opt.service.induce.GreenwaveInducesService;
import net.wanji.opt.service.induce.InduceSendService; import net.wanji.opt.service.induce.InduceSendService;
import net.wanji.opt.service.induce.InduceTemplateService;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity; import net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity;
import net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity; import net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity;
...@@ -34,6 +37,7 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -34,6 +37,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -82,6 +86,10 @@ public class InducesMonitorTask { ...@@ -82,6 +86,10 @@ public class InducesMonitorTask {
@Autowired @Autowired
private InduceSendService induceSendService; private InduceSendService induceSendService;
@Autowired
private InduceTemplateService induceTemplateService;
/** /**
* #绿波调度计划扫描周期 * #绿波调度计划扫描周期
* 5 分钟 300000 * 5 分钟 300000
...@@ -162,7 +170,7 @@ public class InducesMonitorTask { ...@@ -162,7 +170,7 @@ public class InducesMonitorTask {
for (StrategyGreenOptHistEntity greenOptHistEntity : strategyGreenOptHistEntitiesList) { for (StrategyGreenOptHistEntity greenOptHistEntity : strategyGreenOptHistEntitiesList) {
LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, greenwaveInfoPO.getId()); greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, greenwaveInfoPO.getId());
// greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getDir, getDir(greenOptHistEntity.getDir())); greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getDir, getDir(greenOptHistEntity.getDir()));
GreenwaveInducesHist greenwaveInducesHist = greenwaveInducesHistService.getOne(greenwaveInducesHistQueryWrapper); GreenwaveInducesHist greenwaveInducesHist = greenwaveInducesHistService.getOne(greenwaveInducesHistQueryWrapper);
if (Objects.isNull(greenwaveInducesHist)) { if (Objects.isNull(greenwaveInducesHist)) {
greenwaveInducesHist = new GreenwaveInducesHist(); greenwaveInducesHist = new GreenwaveInducesHist();
...@@ -172,8 +180,8 @@ public class InducesMonitorTask { ...@@ -172,8 +180,8 @@ public class InducesMonitorTask {
} }
greenwaveInducesHist.setStrategyId(strategyId.get()); greenwaveInducesHist.setStrategyId(strategyId.get());
greenwaveInducesHist.setStrategyName(greenwaveInfoPO.getName());//当前策略名称 greenwaveInducesHist.setStrategyName(greenwaveInfoPO.getName());//当前策略名称
if(StringUtils.isNotBlank(greenOptHistEntity.getControlTime()) && greenOptHistEntity.getControlDuration()>0) { if (StringUtils.isNotBlank(greenOptHistEntity.getControlTime()) && greenOptHistEntity.getControlDuration() > 0) {
greenwaveInducesHist.setControlOptTimes(greenOptHistEntity.getControlTime() + "|" + DateUtil.format(DateUtil.addSecond(greenOptHistEntity.getControlTime(),greenOptHistEntity.getControlDuration()), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));//执行时段 greenwaveInducesHist.setControlOptTimes(greenOptHistEntity.getControlTime() + "|" + DateUtil.format(DateUtil.addSecond(greenOptHistEntity.getControlTime(), greenOptHistEntity.getControlDuration()), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));//执行时段
} }
greenwaveInducesHist.setType(greenOptHistEntity.getType());// 执行策略 greenwaveInducesHist.setType(greenOptHistEntity.getType());// 执行策略
greenwaveInducesHist.setMinSpeed(greenOptHistEntity.getMinSpeed()); greenwaveInducesHist.setMinSpeed(greenOptHistEntity.getMinSpeed());
...@@ -181,18 +189,56 @@ public class InducesMonitorTask { ...@@ -181,18 +189,56 @@ public class InducesMonitorTask {
greenwaveInducesHist.setDir(greenOptHistEntity.getDirType()); greenwaveInducesHist.setDir(greenOptHistEntity.getDirType());
//5、获取绿波信息,调用上屏服务;发布互联网诱导方案 //5、获取绿波信息,调用上屏服务;发布互联网诱导方案
//[{"crossId":"13MOD0B5SI0","phaseStartTime":32.0,"phaseEndTime":122.0,"greenStartTime":35.0,"speed":"39.71","offset":208.0,"travelTime":57.0,"distance":"628.81"},{"crossId":"13MQJ0B5SI0","phaseStartTime":43.0,"phaseEndTime":158.0,"greenStartTime":0.0,"speed":"35.54","offset":69.0,"travelTime":42.0,"distance":"414.62"},{"crossId":"13MS20B5SI0","phaseStartTime":32.0,"phaseEndTime":142.0,"greenStartTime":8.0,"speed":"22.72","offset":114.0,"travelTime":116.0,"distance":"732.00"},{"crossId":"13MUK0B5SH0","phaseStartTime":0.0,"phaseEndTime":135.0,"greenStartTime":0.0,"speed":"42.33","offset":50.0,"travelTime":45.0,"distance":"529.16"},{"crossId":"13N0F0B5SH0","phaseStartTime":25.0,"phaseEndTime":156.0,"greenStartTime":70.0,"speed":"40.67","offset":0.0,"travelTime":40.0,"distance":"451.89"},{"crossId":"13N200B5SH0","phaseStartTime":23.0,"phaseEndTime":150.0,"greenStartTime":0.0,"speed":"-1.00","offset":112.0,"travelTime":-1.0,"distance":"-1.00"}] //[{"crossId":"13MOD0B5SI0","phaseStartTime":32.0,"phaseEndTime":122.0,"greenStartTime":35.0,"speed":"39.71","offset":208.0,"travelTime":57.0,"distance":"628.81"},{"crossId":"13MQJ0B5SI0","phaseStartTime":43.0,"phaseEndTime":158.0,"greenStartTime":0.0,"speed":"35.54","offset":69.0,"travelTime":42.0,"distance":"414.62"},{"crossId":"13MS20B5SI0","phaseStartTime":32.0,"phaseEndTime":142.0,"greenStartTime":8.0,"speed":"22.72","offset":114.0,"travelTime":116.0,"distance":"732.00"},{"crossId":"13MUK0B5SH0","phaseStartTime":0.0,"phaseEndTime":135.0,"greenStartTime":0.0,"speed":"42.33","offset":50.0,"travelTime":45.0,"distance":"529.16"},{"crossId":"13N0F0B5SH0","phaseStartTime":25.0,"phaseEndTime":156.0,"greenStartTime":70.0,"speed":"40.67","offset":0.0,"travelTime":40.0,"distance":"451.89"},{"crossId":"13N200B5SH0","phaseStartTime":23.0,"phaseEndTime":150.0,"greenStartTime":0.0,"speed":"-1.00","offset":112.0,"travelTime":-1.0,"distance":"-1.00"}]
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetailList = new ArrayList<>(); // List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetailList = new ArrayList<>();
// try {
// crossGreenDetailList = JacksonUtils.getInstance().readValue(greenOptHistEntity.getCrossGreenDetail(), new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() {});
// } catch (JsonProcessingException e) {
// log.error("绿波详情转换失败:" + greenOptHistEntity.getGreenId() + "---" + e.getMessage());
// }
greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist);
////自动发送诱导消息
MessageParam messageParam = new MessageParam();
messageParam.setFlg(1);
messageParam.setGreenId(greenwaveInfoPO.getId());
messageParam.setContents(new String[]{greenOptHistEntity.getMaxSpeed()+"-"+greenOptHistEntity.getMaxSpeed()+"km/h"});
messageParam.setType("TFMH");
try { try {
crossGreenDetailList = JacksonUtils.getInstance().readValue(greenOptHistEntity.getCrossGreenDetail(), new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() { if(greenwaveInducesHist.getStatus()==0||greenwaveInducesHist.getModifyTime()!=greenOptHistEntity.getCreateTime()) {
}); LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>();
} catch (JsonProcessingException e) { greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, greenwaveInfoPO.getId());
log.error("绿波详情转换失败:" + greenOptHistEntity.getGreenId() + "---" + e.getMessage()); List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(greenwaveInducesQueryWrapper);
for(GreenwaveInduces greenwaveCross :greenwaveInducesList){
LambdaQueryWrapper<InduceTemplate> induceTemplateQueryWrapper = new LambdaQueryWrapper<>();
induceTemplateQueryWrapper.eq(InduceTemplate::getEquipCode, greenwaveCross.getEquipCode());
List<InduceTemplate> induceTemplateList=induceTemplateService.list(induceTemplateQueryWrapper);
for(InduceTemplate induceTemplate:induceTemplateList) {
messageParam.setTemplateId(induceTemplate.getId());
messageParam.setInduceId(greenwaveCross.getId());
messageParam.setEquipCode(greenwaveCross.getEquipCode());
messageParam.setPlayorder(induceTemplateList.size());
messageParam.setDuration(greenwaveCross.getDuration());
if ( greenwaveInducesHist.getControlOptTimes().split("\\|").length > 0 && DateUtil.isBetween(new Date(), DateUtil.parse(greenwaveInducesHist.getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), DateUtil.parse(greenwaveInducesHist.getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND))) {
messageParam.setStartTime(greenwaveInducesHist.getControlOptTimes().split("\\|")[0]);
messageParam.setEndTime(greenwaveInducesHist.getControlOptTimes().split("\\|")[1]);
} else {
messageParam.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
messageParam.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 60, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
}
induceSendService.send(messageParam);
}
} }
// greenwaveInducesHist.setStatus(1); greenwaveInducesHist.setStatus(1);
greenwaveInducesHist.setModifyTime(new Date()); greenwaveInducesHist.setModifyTime(greenOptHistEntity.getCreateTime());
greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist); greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist);
}
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
log.info("发送上屏信息异常" + e.getMessage());
}
synCount.getAndIncrement(); synCount.getAndIncrement();
log.info("同步绿波状态信息成功->" +greenwaveInfoPO.getName()); log.info("同步绿波状态信息成功->" + greenwaveInfoPO.getName());
} }
} }
} }
...@@ -215,7 +261,13 @@ public class InducesMonitorTask { ...@@ -215,7 +261,13 @@ public class InducesMonitorTask {
messageParam.setSourceId(v.getSourceId()); messageParam.setSourceId(v.getSourceId());
messageParam.setType("TFMH"); messageParam.setType("TFMH");
//屏蔽此处功能,因为上屏的时候可以设置生效时间 //屏蔽此处功能,因为上屏的时候可以设置生效时间
//induceSendService.send(messageParam); try {
induceSendService.send(messageParam);
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
log.info("发送下屏信息异常"+e.getMessage());
}
log.info("发送下屏信息成功."); log.info("发送下屏信息成功.");
}); });
} }
......
...@@ -8,8 +8,5 @@ spring: ...@@ -8,8 +8,5 @@ spring:
namespace: signal namespace: signal
username: nacos username: nacos
password: nacos password: nacos
application:
# dubbo启动需要程序名称
name: signal-optimize-service
main: main:
allow-circular-references: true allow-circular-references: true
...@@ -5,7 +5,7 @@ spring: ...@@ -5,7 +5,7 @@ spring:
cloud: cloud:
nacos: nacos:
config: config:
server-addr: 10.102.1.182:8848 server-addr: 37.12.182.29:8848
file-extension: yaml file-extension: yaml
group: signal group: signal
namespace: 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>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<mapper namespace="net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper"> <mapper namespace="net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper">
<select id="selectByGreenId" resultType="net.wanji.opt.po.StrategyGreenOptHistEntity" parameterType="String" > <select id="selectByGreenId" resultType="net.wanji.opt.po.StrategyGreenOptHistEntity" parameterType="String" >
select * from t_strategy_green_opt_hist where `green_id` = #{greenId} and TIMESTAMPDIFF(SECOND,`control_time`, now()) &lt; `control_duration` order by create_time desc limit 1; select * from t_strategy_green_opt_hist where `green_id` = #{greenId} and TIMESTAMPDIFF(SECOND,`control_time`, now()) &lt; `control_duration` order by create_time desc limit 2;
</select> </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