Commit c6c0433d authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

parents 80366e8f 6073c8be
......@@ -4,20 +4,25 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import net.wanji.common.utils.tool.StringUtils;
import java.util.Objects;
/**
* @author duanruiming
* @date 2024/12/03 19:14
* @description
*/
@Getter
@AllArgsConstructor
public enum GreenBeltDirEnum {
E2W("e2w", "东向西"),
W2E("w2e", "西向东"),
N2S("n2s", "北向南"),
S2N("s2n", "南向北");
//
E2W("e2w", "东向西", 3),
W2E("w2e", "西向东", 7),
N2S("n2s", "北向南", 1),
S2N("s2n", "南向北", 5);
private String code;
private String desc;
private Integer inDir;
public static String getDesc(String code) {
for (GreenBeltDirEnum dirEnum : GreenBeltDirEnum.values()) {
......@@ -27,4 +32,22 @@ public enum GreenBeltDirEnum {
}
return "";
}
public static Integer getInDir(String code) {
for (GreenBeltDirEnum value : GreenBeltDirEnum.values()) {
if (StringUtils.equalsIgnoreCase(code, value.getCode())) {
return value.getInDir();
}
}
return 1;
}
public static String getInDirName(Integer dir) {
for (GreenBeltDirEnum value : GreenBeltDirEnum.values()) {
if (Objects.equals(dir, value.getInDir())) {
return value.getDesc();
}
}
return "";
}
}
......@@ -55,13 +55,13 @@ public class GreenBeltController {
@ApiResponse(code = 200, message = "OK", response = GreenBeltSpeedWidthVO.class),
})
public JsonViewObject greenBeltSpeedWidth(Integer greenId) {
Map<String, List<GreenBeltSpeedWidthVO>> map = Collections.EMPTY_MAP;
List<GreenBeltSpeedWidthVO> list = Collections.EMPTY_LIST;
try {
map = greenBeltInfoService.greenBeltSpeedWidth(greenId);
list = greenBeltInfoService.greenBeltSpeedWidth(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("绿波带宽曲线异常");
}
return JsonViewObject.newInstance().success(map);
return JsonViewObject.newInstance().success(list);
}
@ApiOperation(value = "绿波关键路口流量绿信比", notes = "优化监测-绿波关键路口流量绿信比", response = JsonViewObject.class,
......@@ -71,13 +71,13 @@ public class GreenBeltController {
@ApiResponse(code = 200, message = "OK", response = GreenBeltKeyCrossFlowTimeVO.class),
})
public JsonViewObject greenBeltKeyCrossFlowTime(Integer greenId) {
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> map = Collections.EMPTY_MAP;
List<GreenBeltKeyCrossFlowTimeVO> list = Collections.EMPTY_LIST;
try {
map = greenBeltInfoService.greenBeltKeyCrossFlowTime(greenId);
list = greenBeltInfoService.greenBeltKeyCrossFlowTime(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("绿波带宽曲线异常");
}
return JsonViewObject.newInstance().success(map);
return JsonViewObject.newInstance().success(list);
}
@ApiOperation(value = "干线详情", notes = "优化监测-干线详情", response = JsonViewObject.class,
......
......@@ -452,9 +452,9 @@ public class TrendServiceImpl implements TrendService {
abnormalCrossDetailVO.setCrossStopTimes(crossDataRealtimePO.getStopTimes());
abnormalCrossDetailVO.setSpeed(crossDataRealtimePO.getSpeed());
Double sturation = crossDataRealtimePO.getSturation();
abnormalCrossDetailVO.setSturation((double) Math.round(sturation) * 100);
String serviceLevel = CrossUtil.getServiceLevel(sturation);
abnormalCrossDetailVO.setServiceLevel(serviceLevel);
abnormalCrossDetailVO.setSturation((int)(sturation * 100));
//String serviceLevel = CrossUtil.getServiceLevel(sturation);
abnormalCrossDetailVO.setServiceLevel(crossDataRealtimePO.getServiceLevel());
abnormalCrossDetailVO.setHourFlow(crossDataRealtimePO.getFlow() * 12);
BigDecimal bigDecimal = BigDecimal.valueOf(crossDataRealtimePO.getTrafficIndex()).setScale(2, RoundingMode.HALF_UP);
abnormalCrossDetailVO.setCongestionIndex(bigDecimal);
......
......@@ -6,15 +6,13 @@ import net.wanji.opt.vo.GreenBeltKeyCrossFlowTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
import java.util.List;
import java.util.Map;
/**
* @author duanruiming
* @date 2024/11/19 18:07
*/
public interface GreenBeltInfoService {
List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId) throws Exception;
Map<String, List<GreenBeltSpeedWidthVO>> greenBeltSpeedWidth(Integer greenId) throws Exception;
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception;
List<GreenBeltSpeedWidthVO> greenBeltSpeedWidth(Integer greenId) throws Exception;
List<GreenBeltKeyCrossFlowTimeVO> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception;
GreenBeltCrossDetailVO greenBeltCrossDetailList(Integer greenId) throws Exception;
}
......@@ -14,7 +14,6 @@ import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.opt.cache.BaseCrossInfoCache;
......@@ -29,11 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
......@@ -103,133 +98,212 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
}
@Override
public Map<String, List<GreenBeltKeyCrossFlowTimeVO>> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception {
public List<GreenBeltKeyCrossFlowTimeVO> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception {
try {
ObjectMapper mapper = JacksonUtils.getInstance();
DecimalFormat df = new DecimalFormat("#0.00");
List<GreenBeltKeyCrossFlowTimeVO> tempResult = new ArrayList<>();
List<GreenBeltKeyCrossFlowTimeVO> results = new ArrayList<>();
LocalDate currentDate = LocalDate.now();
LocalTime startTime = LocalTime.MIDNIGHT;
LocalDateTime startOfDay = LocalDateTime.of(currentDate, startTime);
// 最少有一条数据
List<GreenBeltKeyCrossFlowTimeVO.Detail> optResults = getGreenOptList(greenId, startOfDay);
GreenBeltKeyCrossFlowTimeVO.Detail optDetail = optResults.get(0);
String crossId = optDetail.getCrossId();
GreenwaveInfoPO greenwaveInfoPO = GreenWaveInfoCache.greenWaveMap.get(greenId);
String greenDir = greenwaveInfoPO.getGreenDir();
String[] split = greenDir.split(",");
List<Integer> dirList = new ArrayList<>();
for (String s : split) {
dirList.add(Integer.valueOf(s));
}
Instant instant = startOfDay.atZone(ZoneId.systemDefault()).toInstant();
int start = (int) (instant.toEpochMilli() / 1000) + 300;
int end = (int) (System.currentTimeMillis() / 1000) + 300;
List<CrossDirDataHistPO> dirDataHistPOS = crossDirDataHistMapper.selectDirDataList(crossId, dirList, start, end);
if (!CollectionUtils.isEmpty(dirDataHistPOS)) {
Map<Integer, List<CrossDirDataHistPO>> dirHistMap = dirDataHistPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getDirType));
Integer dir = null;
for (Map.Entry<Integer, List<CrossDirDataHistPO>> entry : dirHistMap.entrySet()) {
dir = entry.getKey();
List<CrossDirDataHistPO> value = entry.getValue();
Double greenTimeRatio = 0.0;
List<GreenBeltKeyCrossFlowTimeVO.Detail> details = new ArrayList<>();
for (CrossDirDataHistPO dirDataHistPO : value) {
GreenBeltKeyCrossFlowTimeVO.Detail detail = new GreenBeltKeyCrossFlowTimeVO.Detail();
detail.setCrossId(crossId);
String crossName = baseCrossInfoCache.getCrossName(crossId);
detail.setCrossName(crossName);
Integer dirType = dirDataHistPO.getDirType();
detail.setDir(String.valueOf(dirType));
detail.setFlow(dirDataHistPO.getFlow());
detail.setStartTime(dirDataHistPO.getStartTime());
detail.setGreenTimeRatio(greenTimeRatio);
for (GreenBeltKeyCrossFlowTimeVO.Detail optResult : optResults) {
Integer curDir = GreenBeltDirEnum.getInDir(optResult.getDir());
if (StringUtils.equalsIgnoreCase("cancel", optResult.getDir()) && Objects.equals(curDir, dirType)
&& dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) {
greenTimeRatio = 0.0;
}
if (StringUtils.equalsIgnoreCase(crossId, optResult.getCrossId()) && Objects.equals(curDir, dirType)
&& dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) {
detail.setGreenTimeRatio(optResult.getGreenTimeRatio() * 100);
greenTimeRatio = optResult.getGreenTimeRatio() * 100;
}
}
details.add(detail);
}
if (!CollectionUtils.isEmpty(details)) {
GreenBeltKeyCrossFlowTimeVO greenBeltKeyCrossFlowTimeVO = new GreenBeltKeyCrossFlowTimeVO();
String crossName = "";
if (!CollectionUtils.isEmpty(value)) {
GreenBeltKeyCrossFlowTimeVO.Detail detail = details.get(0);
crossName = detail.getCrossName();
}
greenBeltKeyCrossFlowTimeVO.setCrossName(crossName);
greenBeltKeyCrossFlowTimeVO.setDirName(GreenBeltDirEnum.getInDirName(Integer.valueOf(dir)));
List<GreenBeltKeyCrossFlowTimeVO.Detail> collect = details.stream().sorted(Comparator.comparing(GreenBeltKeyCrossFlowTimeVO.Detail::getStartTime)).collect(Collectors.toList());
greenBeltKeyCrossFlowTimeVO.setDetailList(collect);
results.add(greenBeltKeyCrossFlowTimeVO);
}
}
}
return results;
} catch (Exception e) {
log.error("绿波关键路口流量绿信比查询异常:", e);
throw new RuntimeException(e);
}
}
/**
* 获取绿波优化列表
*
* @param greenId
* @param startOfDay
* @return
* @throws JsonProcessingException
*/
private List<GreenBeltKeyCrossFlowTimeVO.Detail> getGreenOptList(Integer greenId, LocalDateTime startOfDay) throws Exception {
List<GreenBeltKeyCrossFlowTimeVO.Detail> optResults = null;
try {
optResults = new ArrayList<>();
// 绿波优化数据
List<StrategyGreenOptHistEntity> entities = new ArrayList<>();
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay);
List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
// 随机路口编号,通过路口编号查询时间轴
String tempCrossId = "";
entities = strategyGreenOptHistMapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(entities)) {
// 如果路口没有绿波,获取当前绿波最大的一条数据
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapperMaxId = new LambdaQueryWrapper<>();
queryWrapperMaxId.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapperMaxId.ge(StrategyGreenOptHistEntity::getControlMethod, 1);
queryWrapperMaxId.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay.minusDays(1));
queryWrapperMaxId.orderByDesc(StrategyGreenOptHistEntity::getControlTime);
queryWrapperMaxId.last("limit 1");
entities = strategyGreenOptHistMapper.selectList(queryWrapperMaxId);
}
// 一个绿波只有一个关键路口
if (!CollectionUtils.isEmpty(entities)) {
for (StrategyGreenOptHistEntity entity : entities) {
GreenBeltKeyCrossFlowTimeVO vo = new GreenBeltKeyCrossFlowTimeVO();
GreenBeltKeyCrossFlowTimeVO.Detail detail = new GreenBeltKeyCrossFlowTimeVO.Detail();
String keyCross = entity.getKeyCross();
vo.setCrossId(keyCross);
vo.setDirName(GreenBeltDirEnum.getDesc(entity.getDir()));
detail.setCrossId(keyCross);
detail.setDir(entity.getDir());
Date controlTime = get5MinuteDate(entity.getControlTime());
vo.setStartTime(controlTime);
detail.setStartTime(controlTime);
String crossGreenDetail = entity.getCrossGreenDetail();
Integer cycle = entity.getCycle();
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetails = mapper.readValue(crossGreenDetail, new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() {});
ObjectMapper mapper = JacksonUtils.getInstance();
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetails = mapper.readValue(crossGreenDetail, new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() {
});
if (!CollectionUtils.isEmpty(crossGreenDetails)) {
List<GreenBeltInfoVO.CrossGreenDetail> keyCrossDetail = crossGreenDetails.stream().filter(details -> StringUtils.equalsIgnoreCase(keyCross, details.getCrossId())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(keyCrossDetail)) {
GreenBeltInfoVO.CrossGreenDetail curKeyCross = keyCrossDetail.get(0);
tempCrossId = curKeyCross.getCrossId();
for (GreenBeltInfoVO.CrossGreenDetail curKeyCross : keyCrossDetail) {
String currentCrossId = curKeyCross.getCrossId();
if (StringUtils.equalsIgnoreCase(keyCross, currentCrossId)) {
Double phaseStartTime = curKeyCross.getPhaseStartTime();
Double phaseEndTime = curKeyCross.getPhaseEndTime();
Double greenTimeRatio = Double.parseDouble(df.format(phaseEndTime - phaseStartTime / cycle));
vo.setGreenTimeRatio(greenTimeRatio);
Double greenTimeRatio = (phaseEndTime - phaseStartTime) / cycle;
detail.setGreenTimeRatio(greenTimeRatio);
}
}
tempResult.add(vo);
}
// 关键路口历史数据
LambdaQueryWrapper<CrossDataHistPO> histQuery = new LambdaQueryWrapper<>();
histQuery.eq(CrossDataHistPO::getCrossId, tempCrossId);
histQuery.ge(CrossDataHistPO::getStartTime, startOfDay);
List<CrossDataHistPO> crossDataHistPOS = crossDataHistMapper.selectList(histQuery);
if (!CollectionUtils.isEmpty(crossDataHistPOS)) {
for (CrossDataHistPO crossDataHistPO : crossDataHistPOS) {
Date crossStartTime = crossDataHistPO.getStartTime();
String format = DateUtil.format(crossStartTime, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND);
Date minuteDate = get5MinuteDate(format);
Integer flow = crossDataHistPO.getFlow();
GreenBeltKeyCrossFlowTimeVO resultVO = new GreenBeltKeyCrossFlowTimeVO();
resultVO.setStartTime(minuteDate);
resultVO.setFlow(flow);
resultVO.setGreenTimeRatio(0.0);
resultVO.setCrossId(tempCrossId);
resultVO.setDirName("未执行");
String crossName = baseCrossInfoCache.getCrossName(tempCrossId);
resultVO.setCrossName(crossName);
for (GreenBeltKeyCrossFlowTimeVO result : tempResult) {
if (StringUtils.equalsIgnoreCase(tempCrossId, result.getCrossId())
&& minuteDate.getTime() == result.getStartTime().getTime()) {
resultVO.setFlow(flow);
resultVO.setGreenTimeRatio(result.getGreenTimeRatio());
}
}
results.add(resultVO);
}
}
}
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> map = results.stream().collect(Collectors.groupingBy(GreenBeltKeyCrossFlowTimeVO::getDirName));
return map;
}
// 设置中间变量 优化结束
if (entity.getControlMethod() <= 0) {
detail.setDir("cancel");
}
optResults.add(detail);
}
}
} catch (Exception e) {
log.error("绿波关键路口流量绿信比查询异常:", e);
throw new RuntimeException(e);
log.error("绿波优化列表数据异常;", e);
throw new Exception(e);
}
return optResults;
}
@Override
public Map<String, List<GreenBeltSpeedWidthVO>> greenBeltSpeedWidth(Integer greenId) throws Exception {
public List<GreenBeltSpeedWidthVO> greenBeltSpeedWidth(Integer greenId) throws Exception {
try {
List<GreenBeltSpeedWidthVO> results = new ArrayList<>();
LocalDate currentDate = LocalDate.now();
LocalTime startTime = LocalTime.MIDNIGHT;
LocalDateTime startOfDay = LocalDateTime.of(currentDate, startTime);
// 绿波历史数据
LambdaQueryWrapper<GreenwaveHistPO> greenWrapper = new LambdaQueryWrapper<>();
greenWrapper.eq(GreenwaveHistPO::getGreenId, greenId);
greenWrapper.ge(GreenwaveHistPO::getStartTime, startOfDay);
// 绿波历史数据
List<GreenwaveHistPO> greenwaveHistPOS = greenwaveHistMapper.selectList(greenWrapper);
// 绿波优化数据
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlMethod, 1);
List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(greenwaveHistPOS) && !CollectionUtils.isEmpty(entities)) {
for (GreenwaveHistPO histPO : greenwaveHistPOS) {
if (!CollectionUtils.isEmpty(greenwaveHistPOS)) {
Map<String, List<GreenwaveHistPO>> greenDirMap = greenwaveHistPOS.stream().collect(Collectors.groupingBy(GreenwaveHistPO::getRoadDirection));
for (Map.Entry<String, List<GreenwaveHistPO>> entry : greenDirMap.entrySet()) {
String dir = entry.getKey();
GreenBeltSpeedWidthVO greenBeltSpeedWidthVO = new GreenBeltSpeedWidthVO();
greenBeltSpeedWidthVO.setDirName(GreenBeltDirEnum.getDesc(dir));
List<GreenBeltSpeedWidthVO.Detail> details = new ArrayList<>();
List<GreenwaveHistPO> value = entry.getValue();
double greenWidthTime = 0.0;
for (GreenwaveHistPO histPO : value) {
Integer curGreenId = histPO.getGreenId();
Date curStartTime = histPO.getStartTime();
String curStartTimeStr = DateUtil.format(curStartTime, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND);
Date startTimeminuteDate = get5MinuteDate(curStartTimeStr);
String roadDirection = histPO.getRoadDirection();
Double speed = histPO.getSpeed();
GreenBeltSpeedWidthVO.Detail detail = new GreenBeltSpeedWidthVO.Detail();
for (StrategyGreenOptHistEntity entity : entities) {
Integer optGreenId = entity.getGreenId();
String controlTime = entity.getControlTime();
String dir = entity.getDir();
String optDir = entity.getDir();
Date minuteDate = get5MinuteDate(controlTime);
Double greenWidthTime = entity.getGreenWidthTime();
if (Objects.equals(curGreenId, optGreenId) && StringUtils.equalsIgnoreCase(dir, roadDirection)
if (Objects.equals(curGreenId, optGreenId) && StringUtils.equalsIgnoreCase(optDir, dir)
&& minuteDate.getTime() == startTimeminuteDate.getTime()) {
GreenBeltSpeedWidthVO vo = new GreenBeltSpeedWidthVO();
vo.setStartTime(curStartTime);
vo.setSpeed(speed);
vo.setWidth(greenWidthTime);
vo.setDirName(GreenBeltDirEnum.getDesc(dir));
results.add(vo);
greenWidthTime = entity.getGreenWidthTime();
}
if (entity.getControlMethod() <= 0) {
greenWidthTime = 0.0;
}
}
detail.setStartTime(curStartTime);
detail.setSpeed(speed);
detail.setWidth(greenWidthTime);
detail.setDir(dir);
details.add(detail);
}
greenBeltSpeedWidthVO.setDetailList(details);
results.add(greenBeltSpeedWidthVO);
}
Map<String, List<GreenBeltSpeedWidthVO>> map = results.stream().collect(Collectors.groupingBy(GreenBeltSpeedWidthVO::getDirName));
return map;
}
return results;
} catch (Exception e) {
log.error("绿波带宽曲线异常:", e);
throw new RuntimeException(e);
......
package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -21,10 +22,13 @@ public class AbnormalCrossDetailVO {
@ApiModelProperty(value = "路口状态:0正常;1失衡;2拥堵;3溢出")
private Integer crossStatus;
@ApiModelProperty(value = "最大排队")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double crossQueueLength;
@ApiModelProperty(value = "流率")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double crossFlowRate;
@ApiModelProperty(value = "平均停车次数")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double crossStopTimes;
@ApiModelProperty(value = "拥堵指数")
private BigDecimal congestionIndex;
......@@ -35,9 +39,10 @@ public class AbnormalCrossDetailVO {
@ApiModelProperty(value = "方向实时数据")
private List<DirDataElement> dirData;
@ApiModelProperty(value = "平均速度")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double speed;
@ApiModelProperty(value = "饱和度")
private Double sturation;
private Integer sturation;
@ApiModelProperty(value = "路口服务水平")
private String serviceLevel;
@ApiModelProperty(value = "小时流量")
......
package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wanji.opt.config.Double2TwoDecimalPlacesSerializer;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
......@@ -14,17 +17,26 @@ import java.util.Date;
@Data
@ApiModel(value = "优化监测-绿波关键路口流量绿信比实体")
public class GreenBeltKeyCrossFlowTimeVO {
@ApiModelProperty("干线方向")
private String dirName;
@ApiModelProperty("路口名称")
private String crossName;
private List<Detail> detailList;
@Data
public static class Detail {
@ApiModelProperty("路口编号")
private String crossId;
@ApiModelProperty("干线方向")
private String dir;
@ApiModelProperty("路口名称")
private String crossName;
@ApiModelProperty("时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ApiModelProperty("干线方向")
private String dirName;
@ApiModelProperty("流量")
private Integer flow;
@ApiModelProperty("绿信比")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double greenTimeRatio;
}
}
......@@ -8,6 +8,7 @@ import lombok.Data;
import net.wanji.opt.config.Double2TwoDecimalPlacesSerializer;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
......@@ -16,15 +17,21 @@ import java.util.Date;
@Data
@ApiModel(value = "优化监测-绿波带宽曲线实体")
public class GreenBeltSpeedWidthVO {
@ApiModelProperty("干线方向名称")
private String dirName;
private List<Detail> detailList;
@Data
public static class Detail {
@ApiModelProperty("时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ApiModelProperty("干线方向")
private String dirName;
private String dir;
@ApiModelProperty("速度")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double speed;
@ApiModelProperty("带宽")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double width;
}
}
......@@ -15,15 +15,21 @@ import java.util.Objects;
@AllArgsConstructor
@RequiredArgsConstructor
public enum DataBrainControlModeEnum {
//海信线协调控制是单个干线绿波,区域协调控制是多个干线绿波,到万集都是21,绿波协调
//对信号机来说都是绿波协调
LOCK(2, 52, "锁定"),
ALL_RED(3, 12, "全红"),
YELLOW_FLASH(4, 13, "黄闪"),
CLOSED_FLASH(5, 11, "关灯"),
STEP_CONTROL(9, 52, "步进"),
FIX_CYCLE(11, 21, "定周期"),
SELF_ADAPTION(100, 23, "单点自适应控制"),
LINE_COORDINATE(100, 31, "线协调控制"),
REGION_COORDINATE(100, 41, "区域协调控制"),
SELF_ADAPTION(20, 23, "单点自适应控制"),
LINE_COORDINATE(21, 31, "线协调控制"),
REGION_COORDINATE(21, 41, "区域协调控制"),
MANUAL_CONTROL(31, 51, "手动控制"),
MANUAL_LOCK(31, 52, "手动控制-锁定阶段"),
MANUAL_TEMP_SCHEME(31, 53, "手动控制-指定方案"),
MANUAL_LOCK_CHANNEL(31, 54, "手动控制-锁定通道"),
TEMP_PLAN(255, 53, "临时方案");
private Integer wjControl;
......
......@@ -264,12 +264,12 @@ public class SignalStatusServiceImpl implements SignalStatusService {
try {
OkHttpClientUtil.jsonPost(shensiUrl, jackson.writeValueAsString(hisenseLightStatusPojos));
} catch (Exception e) {
log.error("海信灯态推送百度失败:{}", e);
log.error("海信灯态推送神思失败:{}", e.getMessage());
}
try {
OkHttpClientUtil.jsonPost(baiduUrl, jackson.writeValueAsString(hisenseLightStatusPojos));
} catch (Exception e) {
log.error("海信灯态推送百度失败:{}", e);
log.error("海信灯态推送百度失败:{}", e.getMessage());
}
}
......
......@@ -65,7 +65,7 @@ public class OkHttpClientUtil {
return responseString;
}
} catch (Exception e) {
log.error("OkHttpClientUtil远程服务url:{}, 调用异常:{}", url, e);
log.error("OkHttpClientUtil远程服务url:{}, 调用异常:{}", url, e.getMessage());
throw new Exception();
}
return null;
......
......@@ -43,8 +43,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${LOG_PATH}/hisense/%d{yyyy-MM-dd}/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
<totalSizeCap >10GB</totalSizeCap >
<MaxHistory>15</MaxHistory>
<totalSizeCap >50GB</totalSizeCap >
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
</appender>
......@@ -62,8 +62,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${LOG_PATH}/hisense/%d{yyyy-MM-dd}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
<totalSizeCap >10GB</totalSizeCap >
<MaxHistory>15</MaxHistory>
<totalSizeCap >50GB</totalSizeCap >
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
</appender>
......
package net.wanji.utc.service.control.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.IpAddressUtil;
import net.wanji.common.utils.tool.LocalDateTimeUtil;
import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.ExtendPhaseDTO;
......@@ -19,20 +24,22 @@ import net.wanji.utc.common.typeenum.DateStyle;
import net.wanji.utc.po.hk.request.DelBaseConfigPO;
import net.wanji.utc.service.control.ControlCommandService;
import net.wanji.utc.service.control.ControlCommandStrategyService;
import net.wanji.utc.task.SignalStatusTask;
import net.wanji.utc.util.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author duanruiming
......@@ -57,6 +64,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
private final CrossInfoCache crossInfoCache;
private final CrossLightsMapper crossLightsMapper;
private final CrossPhaseLightsMapper crossPhaseLightsMapper;
private final SignalCommandLogPOMapper signalCommandLogPOMapper;
private final CrossPhaseDirTurnCache crossPhaseDirTurnCache;
private final CrossSchemePhaseTimeCountCache crossSchemePhaseTimeCountCache;
......@@ -230,28 +238,89 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override
public JsonViewObject lockControlStrategy(ControlCommandVO commandVO) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject;
try {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(commandVO.getCrossCode());
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) {
jsonViewObject = hkControlCommandService.lockControl(commandVO);
} else {
jsonViewObject = wanJiControlCommandService.lockControl(commandVO);
}
} catch (Exception e) {
jsonViewObject = JsonViewObject.newInstance().fail(e.getMessage());
}
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(commandVO));
jsonObject.put("crossId",commandVO.getCrossCode());
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,3);
return jsonViewObject;
}
@Override
public JsonViewObject stepControlStrategy(String crossId, Integer command, Integer stepNum) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject;
try {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) {
jsonViewObject = hkControlCommandService.stepControl(crossId, command, stepNum);
} else {
jsonViewObject = wanJiControlCommandService.stepControl(crossId, command, stepNum);
}
} catch (Exception e) {
jsonViewObject = JsonViewObject.newInstance().fail(e.getMessage());
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("crossId",crossId);
jsonObject.put("command",command);
jsonObject.put("stepNum",stepNum);
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,1);
return jsonViewObject;
}
/**
* @Description 插入命令日志
* @Param nowTime 请求时间戳
* @Param jsonViewObject 操作结果
* @Param jsonObject 参数
* @return void
**/
public void insertCommandLog(String queryTime,JsonViewObject jsonViewObject, JSONObject jsonObject,int commandType){
SignalCommandLogPO signalCommandLogPO = new SignalCommandLogPO();
signalCommandLogPO.setCrossId(jsonObject.getString("crossId"));
signalCommandLogPO.setDataInfo(jsonObject.toJSONString());
signalCommandLogPO.setCommandType(commandType);
signalCommandLogPO.setQueryTime(queryTime);
Integer code = jsonViewObject.getCode();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ip = IpAddressUtil.getIpAddress(request);
signalCommandLogPO.setIp(ip);
if (code == 200){
signalCommandLogPO.setCommandResult(1);
}else {
signalCommandLogPO.setCommandResult(2);
}
signalCommandLogPO.setResultMessage(jsonViewObject.getMessage());
ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = SignalStatusTask.produceListMap;
if (!produceListMap.isEmpty()) {
List<LightsStatusVO2> list = produceListMap.get(jsonObject.get("crossId"));
if (ObjectUtil.isNotEmpty(list)){
LightsStatusVO2 lightsStatusVO2 = list.get(0);
String runMode = lightsStatusVO2.getRunMode();
String lampTime = lightsStatusVO2.getTimeStamp();
//时间转换
lampTime = LocalDateTimeUtil.formatTimeStamp(Long.valueOf(lampTime), LocalDateTimeUtil.TIMEFORMATTER);
signalCommandLogPO.setRunMode(runMode);
signalCommandLogPO.setLampTime(lampTime);
}
}
signalCommandLogPOMapper.insert(signalCommandLogPO);
}
@Override
public JsonViewObject setSignalControlStrategy(String crossId, Integer command, Integer commandType) throws Exception {
JsonViewObject jsonViewObject;
......@@ -266,6 +335,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override
public JsonViewObject recoverScheduleStrategy(String crossId) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.isBlank(crossId)) {
return jsonViewObject.fail("路口编号不能为空");
......@@ -276,6 +346,10 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
} else {
jsonViewObject = wanJiControlCommandService.recoverSchedule(crossId);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("crossId",crossId);
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,2);
return jsonViewObject;
}
......@@ -358,12 +432,20 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override
public JsonViewObject tempSchemeDetail(TempSchemeSendVO tempSchemeSendVO) throws Exception {
String manufacturerCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
String manufacturerCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerCode)) {
} else {
jsonViewObject = wanJiControlCommandService.tempSchemeDetail(tempSchemeSendVO);
}
} catch (Exception e) {
jsonViewObject = JsonViewObject.newInstance().fail(e.getMessage());
}
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(tempSchemeSendVO));
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,4);
return jsonViewObject;
}
......
......@@ -15,7 +15,6 @@ import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.po.hk.request.DelBaseConfigPO;
import net.wanji.utc.service.control.ControlCommandService;
import net.wanji.utc.util.HttpRestUtil;
import net.wanji.utc.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
......@@ -48,9 +47,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(schemeSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).schemeSend(schemeSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发方案成功!");
}
}*/
return jsonViewObject;
}
......@@ -58,9 +57,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject planSend(PlanSendVO planSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(planSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).planSend(planSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发计划成功!");
}
}*/
return jsonViewObject;
}
......@@ -68,9 +67,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(scheduleSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).scheduleSend(scheduleSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发时间表成功!");
}
}*/
return jsonViewObject;
}
......@@ -83,9 +82,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
lockControlVO.setDuration(commandVO.getDuration());
lockControlVO.setPhaseList(commandVO.getPhaseList());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).lockControl(lockControlVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议锁定控制成功!");
}
}*/
return jsonViewObject;
}
......@@ -93,9 +92,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject stepControl(String crossId, Integer command, Integer stepNum) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepControl(crossId, command, stepNum);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议步进控制成功!");
}
}*/
return jsonViewObject;
}
......@@ -129,9 +128,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
controlCommandVO.setControlType(Constants.ALL_RED_CONTROL);
jsonViewObject = utcFeignClientService.closeLightControl(controlCommandVO);
}
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议设置信号机控制模式成功!");
}
}*/
return jsonViewObject;
}
......@@ -139,9 +138,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject recoverSchedule(String crossId) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).recoverSchedule(crossId);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议恢复时间表成功!");
}
}*/
return jsonViewObject;
}
......@@ -149,9 +148,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(phaseTimingSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).recoverSchedule(phaseTimingSendVO.getCrossCode());
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发相位配时成功!");
}
}*/
return jsonViewObject;
}
......@@ -169,10 +168,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject timing(String crossCode, Date date) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossCode);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).signalTiming(crossCode, date);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议校时成功!");
}
return jsonViewObject.fail("万集标准协议校时失败!");
return jsonViewObject.fail("万集标准协议校时失败!");*/
return jsonViewObject;
}
@Override
......@@ -187,10 +187,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
TempSchemeSendVO tempSchemeSendVO = getTempSchemeSendVO(schemeOptSendVO);
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).tempSchemeDetail(tempSchemeSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发临时方案成功!");
}
return jsonViewObject.fail("万集标准协议下发临时方案失败!");
return jsonViewObject.fail("万集标准协议下发临时方案失败!");*/
return jsonViewObject;
}
/**
......@@ -262,10 +263,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
insertStageOptLog(jsonViewObject.getCode(),tempSchemeSendVO);
}
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("下发临时方案成功!");
}
return jsonViewObject.fail("下发临时方案失败!");
return jsonViewObject.fail("下发临时方案失败!");*/
return jsonViewObject;
}
/**
......@@ -311,19 +313,21 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject extendPhase(ExtendPhaseDTO extendPhase) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(extendPhase.getCrossId());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).extendPhase(extendPhase);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("海信-延长相位成功!");
}
return jsonViewObject.fail("海信-延长相位失败!");
return jsonViewObject.fail("海信-延长相位失败!");*/
return jsonViewObject;
}
@Override
public JsonViewObject stepingPhase(StepingPhaseDTO stepingPhaseDTO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(stepingPhaseDTO.getCrossId());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepingPhase(stepingPhaseDTO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
/*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("步进相位成功!");
}
return jsonViewObject.fail("步进相位失败!");
return jsonViewObject.fail("步进相位失败!");*/
return jsonViewObject;
}
}
package net.wanji.utc.service.staticinfo.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
......@@ -9,6 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.common.utils.tool.LocalDateTimeUtil;
import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*;
......@@ -24,6 +26,7 @@ import net.wanji.feign.service.common.FeignCommon;
import net.wanji.utc.cache.CrossInfoCache;
import net.wanji.utc.cache.UtcFeignClientCache;
import net.wanji.utc.common.Result;
import net.wanji.utc.service.control.impl.ControlCommandStrategyServiceImpl;
import net.wanji.utc.service.staticinfo.WanJiCommonStaticInfoService;
import net.wanji.utc.util.HttpRestUtil;
import org.springframework.beans.factory.annotation.Value;
......@@ -59,6 +62,7 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
private final UtcFeignClientCache utcFeignClientCache;
private final BaseCrossSchemeMapper baseCrossSchemeMapper;
private final CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper;
private final ControlCommandStrategyServiceImpl controlCommandStrategyService;
@Override
......@@ -209,23 +213,32 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
@Override
public JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossSchemeRingsDTO.getCrossId());
JsonViewObject jsonViewObject = null;
String crossId = crossSchemeRingsDTO.getCrossId();
if ("HISENSE".equals(manufacturerIdCode)) {
FeignCommon utcFeignClientService = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode);
jsonViewObject = utcFeignClientService.crossSchemeRings(crossSchemeRingsDTO);
log.info("方案环图请求,crossId:{},result:{}",crossId,jsonViewObject);
Integer code = jsonViewObject.getCode();
if (code != 200){
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(crossSchemeRingsDTO));
//插入命令操作日志
controlCommandStrategyService.insertCommandLog(now,jsonViewObject, jsonObject,10);
}
} else {
CrossSchemeRings crossSchemeRings = getCrossSchemeRings(crossSchemeRingsDTO);
if (ObjectUtil.isNotEmpty(crossSchemeRings)) {
jsonViewObject = JsonViewObject.newInstance().success(crossSchemeRings);
} else {
jsonViewObject = JsonViewObject.newInstance().fail();
jsonViewObject = JsonViewObject.newInstance().fail("该方案信息未同步");
}
}
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
/*if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("方案环图请求远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
}*/
return jsonViewObject;
}
......
......@@ -84,7 +84,7 @@ public class SignalStatusTask {
@Autowired
private EHualuFeignClients eHualuFeignClients;
private static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>();
// 运行状态、告警,1分钟一次
@Scheduled(fixedRate = 60 * 1000)
......
......@@ -18,7 +18,7 @@ public class GreenwaveRealtimePO {
/** 绿波ID */
@ApiModelProperty(name = "id",notes = "")
@TableId
private Integer id ;
private Long id ;
@ApiModelProperty(name = "绿波ID",notes = "")
private Integer greenId;
/** 交通状态:1畅通;2缓行;3拥堵;4严重拥堵;5未知 */
......
package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.sql.Date;
/**
* @ClassName CrossSchemeOptLog
* @Description 命令操作日志
* @Author zhouleilei
* @Date 2024/12/23 15:23
*/
@Data
@TableName("t_signal_command_log")
public class SignalCommandLogPO {
@ApiModelProperty(value = "路口编号")
private String crossId;
@ApiModelProperty(value = "请求信息")
private String dataInfo;
@ApiModelProperty(value = "控制类型:1-步进控制/恢复(信控系统);2-恢复时间表(公用);3-相位锁定/解锁(公用);4-临时方案下发(公用);5-步进相位(神思);10-查询环图失败记录")
private Integer commandType;
@ApiModelProperty(value = "优化结果:1-成功 2-失败")
private Integer commandResult;
@ApiModelProperty(value = "返回信息")
private String resultMessage;
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`,`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`")
private String runMode;
@ApiModelProperty(value = "调用IP")
private String ip;
@ApiModelProperty(value = "请求时间")
private String queryTime;
@ApiModelProperty(value = "灯态时间")
private String lampTime;
@ApiModelProperty(value = "数据插入时间")
private Date insertTime;
}
......@@ -53,6 +53,7 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> {
List<CrossDirDataHistPO> selectByCrossIdsDirsAndTimestamp(List<String> crossIdList, List<Integer> dirCodeList, int startTimeStamp, int endTimeStamp);
List<CrossDirDataHistPO> selectByCrossIdDirsAndTimestamp(String crossId, List<Integer> dirCodeList, int startTimeStamp, int endTimeStamp);
List<CrossDirDataHistPO> selectDirDataList(String crossId, List<Integer> dirCodeList, int startTimeStamp, int endTimeStamp);
List<CrossDirDataHistPO> selectByCrossDirAndTimeSection(
@Param("crossId") String crossId,
......
package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dao.entity.SignalCommandLogPO;
/**
* @ClassName SignalCommandLogPOMapper
* @Description SignalCommandLogPOMapper
* @Author zhouleilei
* @Date 2024/12/23 15:23
*/
public interface SignalCommandLogPOMapper extends BaseMapper<SignalCommandLogPO> {
}
......@@ -16,7 +16,8 @@ import java.util.Map;
@ApiModel(value = "LightsStatusVO", description = "实时灯态信息实体")
public class LightsStatusVO extends BaseCrossInfo {
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`")
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`," +
"`20=单点自适应控制`,`21=绿波协调`,`31=手动控制`,`255=临时控制方案`")
private String runMode;
@ApiModelProperty(value = "控制模式")
private String controlMode;
......
......@@ -18,7 +18,8 @@ import java.util.List;
@ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2")
public class LightsStatusVO2 extends BaseCrossInfo {
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`")
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`," +
"`20=单点自适应控制`,`21=绿波协调`,`31=手动控制`,`255=临时控制方案`")
private String runMode;
@ApiModelProperty(value = "控制模式")
private String controlMode;
......
......@@ -241,7 +241,7 @@
AND schedules.`week` = #{week}
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 DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) ASC LIMIT 1
ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) DESC LIMIT 1
</select>
<select id="selectSchemeByParams" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
......@@ -258,7 +258,7 @@
AND schedules.`week` = #{week}
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 DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) ASC LIMIT 1
ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) DESC LIMIT 1
</select>
......
<?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.databus.dao.mapper.CrossDirDataHistMapper"> <resultMap id="BaseResultMap" type="net.wanji.databus.po.CrossDirDataHistPO"> <result column="id" property="id"></result> <result column="dir_type" property="dirType"></result> <result column="in_out_type" property="inOutType"></result> <result column="cross_id" property="crossId"></result> <result column="length" property="length"></result> <result column="status" property="status"></result> <result column="traffic_index" property="trafficIndex"></result> <result column="start_time" property="startTime"></result> <result column="capacity" property="capacity"></result> <result column="duration" property="duration"></result> <result column="flow" property="flow"></result> <result column="speed" property="speed"></result> <result column="queue_length" property="queueLength"></result> <result column="stop_times" property="stopTimes"></result> <result column="delay_time" property="delayTime"></result> <result column="sturation" property="sturation"></result> <result column="batch_time" property="batchTime"></result> <result column="gmt_create" property="gmtCreate"></result> <result column="gmt_modified" property="gmtModified"></result> <result column="effusion_rate" property="effusionRate"></result> <result column="green_light_efficiency" property="greenLightEfficiency"></result> </resultMap> <sql id="Base_Column_List"> id,dir_type,in_out_type,cross_id,length,status,traffic_index,start_time,capacity,duration,flow,speed,queue_length,stop_times, delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate, green_light_efficiency </sql> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO"> insert ignore into t_cross_dir_data_hist (<include refid="Base_Column_List"></include>) values <foreach collection="list" item="entity" separator=","> ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, #{entity.gmtCreate}, #{entity.gmtModified},#{entity.effusionRate},#{entity.greenLightEfficiency}) </foreach> </insert> <delete id="deleteBatch" parameterType="String"> delete from t_cross_dir_data_hist where cross_id in <foreach collection="list" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> </delete> <select id="selectByCrossIdAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.databus.bo.CrossDirDataHistAvgBO"> SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow, avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex, avg(effusion_rate) as avgeffusionRate FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = #{inOutType} AND batch_time <![CDATA[ >= ]]> #{preSeconds} AND batch_time <![CDATA[ < ]]> #{endSeconds} GROUP BY dir_type </select> <select id="selectNoPark" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueue" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectNoParkEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueueEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} order by batch_time </select> <select id="selectByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxDelayTime" resultType="java.lang.Integer"> select max(delay_time) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxQueueLength" resultType="java.lang.Double"> select max(queue_length) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxSaturation" resultType="java.lang.Double"> select max(sturation) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxGreenLightEfficiency" resultType="java.lang.Double"> select max(green_light_efficiency) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirCode} and in_out_type = #{code} and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} </select> <select id="selectByMetrics" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"/> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = 1 AND dir_type = #{dirInt} AND batch_time <![CDATA[ <= ]]> #{endTimeStamp} AND batch_time <![CDATA[ >= ]]> #{startTimeStamp} </select> <select id="selectByCrossIdsDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id in <foreach collection="crossIdList" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach><!-- and in_out_type = 1--> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type = #{dirCode} AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByCrossIdDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirsAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"><!-- SELECT <include refid="Base_Column_List"></include>--><!-- FROM t_cross_dir_data_hist--><!-- WHERE in_out_type = 1--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr}--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr}--> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> </mapper>
\ No newline at end of file
<?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.databus.dao.mapper.CrossDirDataHistMapper"> <resultMap id="BaseResultMap" type="net.wanji.databus.po.CrossDirDataHistPO"> <result column="id" property="id"></result> <result column="dir_type" property="dirType"></result> <result column="in_out_type" property="inOutType"></result> <result column="cross_id" property="crossId"></result> <result column="length" property="length"></result> <result column="status" property="status"></result> <result column="traffic_index" property="trafficIndex"></result> <result column="start_time" property="startTime"></result> <result column="capacity" property="capacity"></result> <result column="duration" property="duration"></result> <result column="flow" property="flow"></result> <result column="speed" property="speed"></result> <result column="queue_length" property="queueLength"></result> <result column="stop_times" property="stopTimes"></result> <result column="delay_time" property="delayTime"></result> <result column="sturation" property="sturation"></result> <result column="batch_time" property="batchTime"></result> <result column="gmt_create" property="gmtCreate"></result> <result column="gmt_modified" property="gmtModified"></result> <result column="effusion_rate" property="effusionRate"></result> <result column="green_light_efficiency" property="greenLightEfficiency"></result> </resultMap> <sql id="Base_Column_List"> id,dir_type,in_out_type,cross_id,length,status,traffic_index,start_time,capacity,duration,flow,speed,queue_length,stop_times, delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate, green_light_efficiency </sql> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO"> insert ignore into t_cross_dir_data_hist (<include refid="Base_Column_List"></include>) values <foreach collection="list" item="entity" separator=","> ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, #{entity.gmtCreate}, #{entity.gmtModified},#{entity.effusionRate},#{entity.greenLightEfficiency}) </foreach> </insert> <delete id="deleteBatch" parameterType="String"> delete from t_cross_dir_data_hist where cross_id in <foreach collection="list" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> </delete> <select id="selectByCrossIdAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.databus.bo.CrossDirDataHistAvgBO"> SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow, avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex, avg(effusion_rate) as avgeffusionRate FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = #{inOutType} AND batch_time <![CDATA[ >= ]]> #{preSeconds} AND batch_time <![CDATA[ < ]]> #{endSeconds} GROUP BY dir_type </select> <select id="selectNoPark" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueue" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectNoParkEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueueEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} order by batch_time </select> <select id="selectByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxDelayTime" resultType="java.lang.Integer"> select max(delay_time) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxQueueLength" resultType="java.lang.Double"> select max(queue_length) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxSaturation" resultType="java.lang.Double"> select max(sturation) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxGreenLightEfficiency" resultType="java.lang.Double"> select max(green_light_efficiency) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirCode} and in_out_type = #{code} and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} </select> <select id="selectByMetrics" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"/> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = 1 AND dir_type = #{dirInt} AND batch_time <![CDATA[ <= ]]> #{endTimeStamp} AND batch_time <![CDATA[ >= ]]> #{startTimeStamp} </select> <select id="selectByCrossIdsDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id in <foreach collection="crossIdList" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach><!-- and in_out_type = 1--> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type = #{dirCode} AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByCrossIdDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <!-- 神思推送数据in_out_type=0 --> <select id="selectDirDataList" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirsAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"><!-- SELECT <include refid="Base_Column_List"></include>--><!-- FROM t_cross_dir_data_hist--><!-- WHERE in_out_type = 1--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr}--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr}--> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> </mapper>
\ No newline at end of file
......
......@@ -88,10 +88,13 @@
<insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveHistPO">
insert into t_greenwave_hist
(<include refid="Base_Column_List"/>)
(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,
strategy, strategy_duration, optimize_count, optimize_seconds,
green_wave_width, direction, plan_cycle, speed_high, speed_down, road_direction, sturation, batch_time)
values
<foreach collection="list" item="entity" separator=",">
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed},
(#{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified},
......@@ -100,6 +103,8 @@
#{entity.speedDown}, #{entity.roadDirection}, #{entity.sturation}, #{entity.batchTime}
)
</foreach>
ON DUPLICATE KEY UPDATE
gmt_modified = values(gmt_modified)
</insert>
</mapper>
......@@ -54,10 +54,13 @@
<insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveRealtimePO">
insert into t_greenwave_realtime
(<include refid="Base_Column_List"></include>)
(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,
strategy, strategy_duration, optimize_count, optimize_seconds,
green_wave_width, direction, plan_cycle, speed_high, speed_down, road_direction, sturation, batch_time)
values
<foreach collection="list" item="entity" separator=",">
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed},
(#{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified},
......
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