Commit e6ff3bb0 authored by duanruiming's avatar duanruiming

[add] 干线运行监测优化

parent 8f1ed8b5
package net.wanji.opt.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author duanruiming
* @date 2024/12/05 19:29
*/
@Getter
@AllArgsConstructor
public enum StrategyControlEnum {
ZERO(0, "绿波带"),
ONE(1, "失衡"),
TWO(2, "溢出"),
THREE(3, "空放");
private int code;
private String desc;
public static String getDesc(int code) {
for (StrategyControlEnum value : StrategyControlEnum.values()) {
if (code == value.getCode()) {
return value.getDesc();
}
}
return "";
}
}
...@@ -8,19 +8,21 @@ import net.wanji.common.framework.rest.JsonViewObject; ...@@ -8,19 +8,21 @@ import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO; import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.service.signalopt.GreenBeltInfoService; import net.wanji.opt.service.signalopt.GreenBeltInfoService;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO; import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
* @author duanruiming * @author duanruiming
* @date 2024/11/28 16:03 * @date 2024/11/28 16:03
*/ */
@Api(value = "CrossIndexController", description = "路口指标控制器") @Api(value = "GreenBeltController", description = "绿波干线")
@RequestMapping("/greenBelt") @RequestMapping("/greenBelt")
@RestController @RestController
public class GreenBeltController { public class GreenBeltController {
...@@ -35,7 +37,28 @@ public class GreenBeltController { ...@@ -35,7 +37,28 @@ public class GreenBeltController {
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class), @ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
}) })
public JsonViewObject greenBeltCrossDetailHist(Integer greenId) { public JsonViewObject greenBeltCrossDetailHist(Integer greenId) {
List<GreenBeltFlowStopTimeVO> greenBeltFlowStopTimeVOS = greenBeltInfoService.greenBeltCrossDetailHist(greenId); List<GreenBeltFlowStopTimeVO> greenBeltFlowStopTimeVOS = Collections.EMPTY_LIST;
try {
greenBeltFlowStopTimeVOS = greenBeltInfoService.greenBeltCrossDetailHist(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("绿波协调方向路口流量停车次数异常");
}
return JsonViewObject.newInstance().success(greenBeltFlowStopTimeVOS);
}
@ApiOperation(value = "绿波带宽曲线", notes = "优化监测-绿波带宽曲线", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltSpeedWidth")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
})
public JsonViewObject greenBeltSpeedWidth(Integer greenId) {
List<GreenBeltSpeedWidthVO> greenBeltFlowStopTimeVOS = Collections.EMPTY_LIST;
try {
greenBeltFlowStopTimeVOS = greenBeltInfoService.greenBeltSpeedWidth(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("绿波带宽曲线异常");
}
return JsonViewObject.newInstance().success(greenBeltFlowStopTimeVOS); return JsonViewObject.newInstance().success(greenBeltFlowStopTimeVOS);
} }
} }
package net.wanji.opt.service.signalopt; package net.wanji.opt.service.signalopt;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO; import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
import java.util.List; import java.util.List;
...@@ -9,5 +10,6 @@ import java.util.List; ...@@ -9,5 +10,6 @@ import java.util.List;
* @date 2024/11/19 18:07 * @date 2024/11/19 18:07
*/ */
public interface GreenBeltInfoService { public interface GreenBeltInfoService {
List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId); List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId) throws Exception;
List<GreenBeltSpeedWidthVO> greenBeltSpeedWidth(Integer greenId) throws Exception;
} }
package net.wanji.opt.service.signalopt.impl; package net.wanji.opt.service.signalopt.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.DateUtil;
import net.wanji.databus.dao.mapper.CrossDataHistMapper; import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper; import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.po.CrossDataHistPO; import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.dao.mapper.StrategyControlInfoMapper;
import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper;
import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.service.signalopt.GreenBeltInfoService; import net.wanji.opt.service.signalopt.GreenBeltInfoService;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO; import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
...@@ -21,15 +30,47 @@ import java.util.stream.Collectors; ...@@ -21,15 +30,47 @@ import java.util.stream.Collectors;
* @date 2024/12/02 13:42 * @date 2024/12/02 13:42
*/ */
@Service @Service
@Slf4j
public class GreenBeltServiceImpl implements GreenBeltInfoService { public class GreenBeltServiceImpl implements GreenBeltInfoService {
@Resource @Resource
private GreenwaveInfoMapper greenwaveInfoMapper; private GreenwaveInfoMapper greenwaveInfoMapper;
@Resource @Resource
private CrossDataHistMapper crossDataHistMapper; private CrossDataHistMapper crossDataHistMapper;
@Resource
private StrategyGreenOptHistMapper strategyGreenOptHistMapper;
@Override @Override
public List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId) { public List<GreenBeltSpeedWidthVO> greenBeltSpeedWidth(Integer greenId) throws Exception {
try {
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
LocalDate currentDate = LocalDate.now();
LocalTime startTime = LocalTime.MIDNIGHT;
LocalDateTime startOfDay = LocalDateTime.of(currentDate, startTime);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay);
List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
List<GreenBeltSpeedWidthVO> results = new ArrayList<>();
if (!CollectionUtils.isEmpty(entities)) {
for (StrategyGreenOptHistEntity entity : entities) {
GreenBeltSpeedWidthVO greenBeltSpeedWidthVO = new GreenBeltSpeedWidthVO();
Date date = DateUtil.parse(entity.getControlTime(), "yyyy-MM-dd HH:mm:ss");
greenBeltSpeedWidthVO.setStartTime(date);
greenBeltSpeedWidthVO.setSpeed(entity.getMaxSpeed());
greenBeltSpeedWidthVO.setWidth(entity.getGreenWidthTime());
results.add(greenBeltSpeedWidthVO);
}
}
return results;
} catch (Exception e) {
log.error("绿波带宽曲线异常:", e);
throw new RuntimeException(e);
}
}
@Override
public List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId) throws Exception {
try {
List<String> crossIds = greenwaveInfoMapper.selectCrossIdsById(greenId); List<String> crossIds = greenwaveInfoMapper.selectCrossIdsById(greenId);
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
int startSecond = (int) (currentTimeMillis / 1000 - 3600); int startSecond = (int) (currentTimeMillis / 1000 - 3600);
...@@ -62,5 +103,9 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -62,5 +103,9 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
return results; return results;
} }
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} catch (Exception e) {
log.error("绿波协调方向路口流量停车次数查询异常:", e);
throw new RuntimeException(e);
}
} }
} }
...@@ -19,6 +19,8 @@ import net.wanji.databus.po.BaseCrossInfoPO; ...@@ -19,6 +19,8 @@ import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.po.TBaseCrossInfo; import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.opt.cache.BaseCrossInfoCache; import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.cache.GreenWaveInfoCache; import net.wanji.opt.cache.GreenWaveInfoCache;
import net.wanji.opt.common.enums.CrossOptStrategyEnum;
import net.wanji.opt.common.enums.StrategyControlEnum;
import net.wanji.opt.dao.mapper.*; import net.wanji.opt.dao.mapper.*;
import net.wanji.opt.po.StrategyGreenOptHistEntity; import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.synthesis.enums.StrategyCrossAlgoEnum; import net.wanji.opt.synthesis.enums.StrategyCrossAlgoEnum;
...@@ -400,19 +402,12 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -400,19 +402,12 @@ public class StrategyControlServiceImpl implements StrategyControlService {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try { try {
List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type); List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type);
List<StrategyFactoryEntity> strategyFactoryEntities = strategyFactoryMapper.selectList(null);
List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>(); List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>();
for (StrategyControlDataEntity strategyControlDataEntity : currentStrateInfoList) { for (StrategyControlDataEntity strategyControlDataEntity : currentStrateInfoList) {
Integer strategy = strategyControlDataEntity.getStrategy(); Integer strategy = strategyControlDataEntity.getStrategy();
StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt(); StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt();
BeanUtils.copyProperties(strategyControlDataEntity, strategyControlDataExt); BeanUtils.copyProperties(strategyControlDataEntity, strategyControlDataExt);
String strategyName = ""; strategyControlDataExt.setStrategyName(StrategyControlEnum.getDesc(strategy));
for (StrategyFactoryEntity strategyFactoryEntity : strategyFactoryEntities) {
if (Objects.equals(strategy, strategyFactoryEntity.getScene())) {
strategyName = strategyFactoryEntity.getStrategyName();
}
}
strategyControlDataExt.setStrategyName(strategyName);
strategyControlDataExt.setOptStatus("未执行"); strategyControlDataExt.setOptStatus("未执行");
if (StringUtils.isNotBlank(strategyControlDataEntity.getTime())) { if (StringUtils.isNotBlank(strategyControlDataEntity.getTime())) {
strategyControlDataExt.setOptStatus("优化中"); strategyControlDataExt.setOptStatus("优化中");
...@@ -635,7 +630,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -635,7 +630,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
for (StrategyPlanDTO strategyPlanDTO : strategyPlanDTOS) { for (StrategyPlanDTO strategyPlanDTO : strategyPlanDTOS) {
Integer dailyPlanId = planDetail.getDailyPlanId(); Integer dailyPlanId = planDetail.getDailyPlanId();
List<Integer> weeks = planDetail.getWeeks(); List<Integer> weeks = planDetail.getWeeks();
if (dailyPlanId == strategyPlanDTO.getDailyPlanId()) { if (Objects.equals(dailyPlanId, strategyPlanDTO.getDailyPlanId())) {
strategyPlanDTO.setPlanId(planId); strategyPlanDTO.setPlanId(planId);
strategyPlanDTO.setStartTime(startTime); strategyPlanDTO.setStartTime(startTime);
strategyPlanDTO.setEndTime(endTime); strategyPlanDTO.setEndTime(endTime);
......
package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
* @date 2024/12/05 19:48
*/
@Data
@ApiModel(value = "优化监测-绿波带宽曲线实体")
public class GreenBeltSpeedWidthVO {
@ApiModelProperty("时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ApiModelProperty("流量")
private Double speed;
@ApiModelProperty("带宽")
private Double width;
}
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