Commit fc0728d1 authored by zhouleilei's avatar zhouleilei

Merge remote-tracking branch 'origin/master'

parents 8d3da2e4 9ebadf1a
...@@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils; ...@@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -74,7 +75,8 @@ public class BaseCrossInfoCache implements CommandLineRunner { ...@@ -74,7 +75,8 @@ public class BaseCrossInfoCache implements CommandLineRunner {
public void init() { public void init() {
List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll(new CrossInfoVO()); List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll(new CrossInfoVO());
if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) { if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) {
crossInfoList.addAll(baseCrossInfoPOS); List<BaseCrossInfoPO> collect = baseCrossInfoPOS.stream().filter(po -> Objects.equals(po.getIsSignal(), 1)).collect(Collectors.toList());
crossInfoList.addAll(collect);
} }
} }
} }
...@@ -12,7 +12,7 @@ import java.text.DecimalFormat; ...@@ -12,7 +12,7 @@ import java.text.DecimalFormat;
* @date 2024/12/01 16:17 * @date 2024/12/01 16:17
*/ */
public class Double2TwoDecimalPlacesSerializer extends JsonSerializer<Double> { public class Double2TwoDecimalPlacesSerializer extends JsonSerializer<Double> {
private static final DecimalFormat df = new DecimalFormat("#.00"); private static final DecimalFormat df = new DecimalFormat("#0.00");
@Override @Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
......
...@@ -202,6 +202,9 @@ public class TrendServiceImpl implements TrendService { ...@@ -202,6 +202,9 @@ public class TrendServiceImpl implements TrendService {
Integer greenId = entry.getKey(); Integer greenId = entry.getKey();
List<GreenwaveListVO> value = entry.getValue(); List<GreenwaveListVO> value = entry.getValue();
if (Objects.equals(1, value.size())) { if (Objects.equals(1, value.size())) {
value.forEach(vo -> {
vo.setType("单向绿波");
});
greenwaveListVOList.addAll(value); greenwaveListVOList.addAll(value);
} }
if (Objects.equals(2, value.size())) { if (Objects.equals(2, value.size())) {
...@@ -227,6 +230,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -227,6 +230,7 @@ public class TrendServiceImpl implements TrendService {
wDirVo.setStopTimes((int) (stopTimes / 2)); wDirVo.setStopTimes((int) (stopTimes / 2));
wDirVo.setTrafficIndex(trafficIndex / 2 < 1 ? 1 : trafficIndex / 2); wDirVo.setTrafficIndex(trafficIndex / 2 < 1 ? 1 : trafficIndex / 2);
wDirVo.setTravelTime(travelTime / 2); wDirVo.setTravelTime(travelTime / 2);
wDirVo.setType("双向绿波");
greenwaveListVOList.add(wDirVo); greenwaveListVOList.add(wDirVo);
} }
......
...@@ -7,8 +7,8 @@ import io.swagger.annotations.ApiResponses; ...@@ -7,8 +7,8 @@ import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity; import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.service.StrategyControlService; import net.wanji.opt.synthesis.service.StrategyControlService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
......
...@@ -19,7 +19,6 @@ import net.wanji.databus.po.BaseCrossInfoPO; ...@@ -19,7 +19,6 @@ 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.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;
...@@ -72,6 +71,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -72,6 +71,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private StrategyGreenOptHistMapper strategyGreenOptHistMapper; private StrategyGreenOptHistMapper strategyGreenOptHistMapper;
@Resource @Resource
private StrategyCrossResultMapper strategyCrossResultMapper; private StrategyCrossResultMapper strategyCrossResultMapper;
@Resource
private BaseCrossInfoCache baseCrossInfoCache;
@Override @Override
...@@ -355,7 +356,6 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -355,7 +356,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() { List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() {
}); });
for (StrategyControlDataVO.TimeTable timeTable : timeTables) { for (StrategyControlDataVO.TimeTable timeTable : timeTables) {
int currentWeek = DateUtil.thisDayOfWeek() - 1;
String[] timeList = timeTable.getTimeList(); String[] timeList = timeTable.getTimeList();
for (String s : timeList) { for (String s : timeList) {
String[] hours = s.split(","); String[] hours = s.split(",");
...@@ -370,28 +370,25 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -370,28 +370,25 @@ public class StrategyControlServiceImpl implements StrategyControlService {
DateTime currentTime = DateUtil.parse(format, "HH:mm"); DateTime currentTime = DateUtil.parse(format, "HH:mm");
DateTime startHourDate = DateUtil.parse(startHour, "HH:mm"); DateTime startHourDate = DateUtil.parse(startHour, "HH:mm");
DateTime endHourDate = DateUtil.parse(entHour, "HH:mm"); DateTime endHourDate = DateUtil.parse(entHour, "HH:mm");
if (currentTime.after(startHourDate) && currentTime.before(endHourDate)) { if (currentTime.isAfter(startHourDate) && currentTime.isBefore(endHourDate)) {
result.setTime(hour); result.setTime(hour);
result.setStatus(1); result.setStatus(1);
} else { } else {
// 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置 // 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置
result.setStatus(0); result.setStatus(0);
result.setTime(null);
} }
} }
} }
} }
if (type == 0) {
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
result.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
result.setWkt(location);
}
if (type == 1) { if (type == 1) {
GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId())); Map<Integer, GreenwaveInfoPO> greenWaveMap = GreenWaveInfoCache.greenWaveMap;
if (!greenWaveMap.isEmpty()) {
GreenwaveInfoPO greenwaveInfoPO = greenWaveMap.get(Integer.valueOf(entity.getBizId()));
result.setCrossName(greenwaveInfoPO.getName()); result.setCrossName(greenwaveInfoPO.getName());
result.setWkt(greenwaveInfoPO.getWkt()); result.setWkt(greenwaveInfoPO.getWkt());
} }
}
results.add(result); results.add(result);
} }
return results; return results;
...@@ -403,19 +400,43 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -403,19 +400,43 @@ public class StrategyControlServiceImpl implements StrategyControlService {
try { try {
List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type); List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type);
List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>(); List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>();
List<StrategyControlDataExt> results = 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);
strategyControlDataExt.setStrategyName(StrategyControlEnum.getDesc(strategy)); strategyControlDataExt.setStrategyName(StrategyControlEnum.getDesc(strategy));
strategyControlDataExt.setOptStatus("未执行");
if (StringUtils.isNotBlank(strategyControlDataEntity.getTime())) { if (StringUtils.isNotBlank(strategyControlDataEntity.getTime())) {
strategyControlDataExt.setOptStatus("优化中"); strategyControlDataExt.setOptStatus("优化中");
}
strategyControlDataExts.add(strategyControlDataExt); strategyControlDataExts.add(strategyControlDataExt);
} }
strategyControlDataExts.sort(Comparator.comparing(StrategyControlDataExt::getOptStatus)); }
return jsonViewObject.success(strategyControlDataExts, "路网优化监测查询成功"); if (Objects.equals(0, type)) {
List<BaseCrossInfoPO> crossInfoCache = baseCrossInfoCache.getCrossInfoCache();
if (!CollectionUtils.isEmpty(crossInfoCache)) {
for (BaseCrossInfoPO baseCrossInfoPO : crossInfoCache) {
StrategyControlDataExt ext = new StrategyControlDataExt();
ext.setBizId(baseCrossInfoPO.getId());
ext.setStrategyName("无策略");
ext.setOptStatus("未优化");
ext.setStatus(0);
for (StrategyControlDataExt strategyControlDataExt : strategyControlDataExts) {
if (StringUtils.equals(baseCrossInfoPO.getId(), strategyControlDataExt.getBizId())) {
ext = strategyControlDataExt;
}
}
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
ext.setWkt(location);
results.add(ext);
}
}
}
if (Objects.equals(1, type)) {
results.addAll(strategyControlDataExts);
}
results.sort(Comparator.comparing(StrategyControlDataExt::getOptStatus));
return jsonViewObject.success(results, "路网优化监测查询成功");
} catch (Exception e) { } catch (Exception e) {
log.error("路网优化监测查询失败: {}", e); log.error("路网优化监测查询失败: {}", e);
return jsonViewObject.fail("路网优化监测查询失败"); return jsonViewObject.fail("路网优化监测查询失败");
......
...@@ -12,7 +12,7 @@ import java.text.DecimalFormat; ...@@ -12,7 +12,7 @@ import java.text.DecimalFormat;
* @date 2024/12/01 16:17 * @date 2024/12/01 16:17
*/ */
public class DoubleToTwoDecimalPlacesSerializer extends JsonSerializer<Double> { public class DoubleToTwoDecimalPlacesSerializer extends JsonSerializer<Double> {
private static final DecimalFormat df = new DecimalFormat("#.00"); private static final DecimalFormat df = new DecimalFormat("#0.00");
@Override @Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
......
...@@ -18,6 +18,8 @@ import java.util.List; ...@@ -18,6 +18,8 @@ import java.util.List;
public class GreenwaveListVO { public class GreenwaveListVO {
@ApiModelProperty(value = "绿波ID") @ApiModelProperty(value = "绿波ID")
private Integer id; private Integer id;
@ApiModelProperty(value = "绿波方向类型")
private String type;
@ApiModelProperty(value = "子区名称") @ApiModelProperty(value = "子区名称")
private String name; private String name;
@ApiModelProperty(value = "协调方式:0未开启;1相位差优化;2选择方案") @ApiModelProperty(value = "协调方式:0未开启;1相位差优化;2选择方案")
......
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