Commit ffa69dc2 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 410327b3 f4e905a2
......@@ -5,10 +5,11 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.web.dto.*;
import net.wanji.web.po.RingPhasePO;
import net.wanji.web.service.impl.PlanSendServiceImpl;
import net.wanji.web.vo.PhaseListByTimeVO;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -16,8 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author hanbing
* @date 2023/01/04 16:10
......@@ -92,7 +91,7 @@ public class PlanSendController {
@AspectLog(description = "信号机方案同步", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "信号机方案同步", notes = "信号机方案同步")
@PostMapping("/syncScheme")
public JsonViewObject syncScheme(@RequestBody CrossIdBO crossIdBO) throws Exception{
public JsonViewObject syncScheme(@RequestBody CrossIdBO crossIdBO) throws Exception {
JsonViewObject jsonViewObject = planSendService.syncScheme(crossIdBO);
return jsonViewObject;
}
......@@ -100,7 +99,7 @@ public class PlanSendController {
@AspectLog(description = "信号机调度日计划同步", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "信号机调度日计划同步", notes = "信号机调度日计划同步")
@PostMapping("/syncSchedules")
public JsonViewObject syncSchedules(@RequestBody CrossIdBO crossIdBO) throws Exception{
public JsonViewObject syncSchedules(@RequestBody CrossIdBO crossIdBO) throws Exception {
// planSendService.syncSchedules(crossIdBO.getCrossId());
return JsonViewObject.newInstance().success("");
}
......@@ -125,11 +124,10 @@ public class PlanSendController {
@ApiResponse(code = 200, message = "OK", response = SaveSchemeConfigDTO.PhaseListElement.class),
})
public JsonViewObject phaseListByTimeSingleRing(@RequestBody CrossIdAndTimeDTO crossIdAndTimeDTO) {
List<SaveSchemeConfigDTO.PhaseListElement> phaseListByTime
= planSendService.phaseListByTimeSingleRing(crossIdAndTimeDTO);
RingPhasePO ringPhasePO = planSendService.phaseListByTimeSingleRing(crossIdAndTimeDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(phaseListByTime);
return jsonViewObject.success(ringPhasePO);
}
@AspectLog(description = "下发数据到UTC", operationType = BaseEnum.OperationTypeEnum.UPDATE)
......
package net.wanji.web.po;
import lombok.Data;
import net.wanji.web.dto.SaveSchemeConfigDTO;
import java.util.List;
/**
* @ClassName RingPhasePO
* @Description 根据当前时间返回相位列表
* @Author zhouleilei
* @Date 2024/11/24 15:54
*/
@Data
public class RingPhasePO {
//优化前的方案列表
private List<SaveSchemeConfigDTO.PhaseListElement> oriPhaseList;
//优化后的方案列表
private List<SaveSchemeConfigDTO.PhaseListElement> optPhaseList;
}
package net.wanji.web.service;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.web.dto.*;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.web.dto.CrossIdAndPhaseIdsDTO;
import net.wanji.web.dto.CrossIdAndTimeDTO;
import net.wanji.web.dto.ScheduleIdDTO;
import net.wanji.web.dto.SchemeIdDTO;
import net.wanji.web.po.RingPhasePO;
import net.wanji.web.vo.PhaseListByTimeVO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/3 16:14
......@@ -30,7 +32,7 @@ public interface PlanSendService {
PhaseListByTimeVO phaseListByTime(CrossIdAndTimeDTO crossIdAndTimeDTO);
List<SaveSchemeConfigDTO.PhaseListElement> phaseListByTimeSingleRing(CrossIdAndTimeDTO crossIdAndTimeDTO);
RingPhasePO phaseListByTimeSingleRing(CrossIdAndTimeDTO crossIdAndTimeDTO);
/**
* 下发数据到utc数据库
......
......@@ -13,19 +13,21 @@ import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.RunningPlanDTO;
import net.wanji.databus.dto.*;
import net.wanji.databus.po.BaseCrossLightsPO;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.databus.po.CrossSchemeInfoPO;
import net.wanji.databus.po.SaveToUtcPO;
import net.wanji.databus.vo.*;
import net.wanji.feign.service.UtcFeignClients;
import net.wanji.web.dto.*;
import net.wanji.web.po.RingPhasePO;
import net.wanji.web.service.FeignProxyService;
import net.wanji.web.service.PlanSendService;
import net.wanji.web.service.scheme.impl.RunningPlanServiceImpl;
import net.wanji.web.service.scheme.impl.SchemeConfigServiceImpl;
import net.wanji.web.vo.PhaseListByTimeVO;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
......@@ -453,7 +455,7 @@ public class PlanSendServiceImpl implements PlanSendService {
crossPlanPOList = planSectionVO.getCrossPlanPOList();
insertPlanInfo(crossId, crossPlanPOList);
List<CrossSectionPO> crossSectionPOList = planSectionVO.getCrossSectionPOList();
insertSectionInfo(crossId, schemePhaseLightsVO.getCrossSchemeList() , crossPlanPOList, crossSectionPOList);
insertSectionInfo(crossId, schemePhaseLightsVO.getCrossSchemeList(), crossPlanPOList, crossSectionPOList);
}
// 调度信息
......@@ -464,7 +466,8 @@ public class PlanSendServiceImpl implements PlanSendService {
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("信号机静态信息获取-调度信息-UTC服务调用异常");
}
List<CrossSchedulesPO> crossSchedulesPOList = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {});
List<CrossSchedulesPO> crossSchedulesPOList = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {
});
insertSchedulesInfo(crossId, crossSchedulesPOList, crossPlanPOList);
}
......@@ -622,23 +625,111 @@ public class PlanSendServiceImpl implements PlanSendService {
}
@Override
public List<SaveSchemeConfigDTO.PhaseListElement> phaseListByTimeSingleRing(CrossIdAndTimeDTO crossIdAndTimeDTO) {
List<SaveSchemeConfigDTO.PhaseListElement> phaseListByTime = new ArrayList<>();
public RingPhasePO phaseListByTimeSingleRing(CrossIdAndTimeDTO crossIdAndTimeDTO) {
RingPhasePO ringPhasePO = new RingPhasePO();
List<SaveSchemeConfigDTO.PhaseListElement> oriPhaseList = new ArrayList<>();
List<SaveSchemeConfigDTO.PhaseListElement> optPhaseList = new ArrayList<>();
//TODO
CrossIdDTO crossIdDTO = new CrossIdDTO();
crossIdDTO.setCrossId(crossIdAndTimeDTO.getCrossId());
//查询当前运行的方案
JsonViewObject jsonViewObject = utcFeignClients.getSchemeNoStr(crossIdDTO.getCrossId());
Integer code = jsonViewObject.getCode();
if (code != 200) {
log.error("获取当前方案号失败,路口id:{}", crossIdAndTimeDTO.getCrossId());
return ringPhasePO;
}
ObjectMapper objectMapper = JacksonUtils.getInstance();
CoordinationStatus content = objectMapper.convertValue(jsonViewObject.getContent(), CoordinationStatus.class);
String coordPatternStatus = content.getCoordPatternStatus();
//方案号
int schemeId = (Integer.valueOf(coordPatternStatus) + 2) / 3;
System.out.println(schemeId);
List<CrossSchemeInfoPO> crossSchemeInfoPOS = baseCrossSchemeMapper.selectSchemeInfoByCrossIdAndSchemeId(crossIdAndTimeDTO.getCrossId(), schemeId);
if (ObjectUtil.isNotEmpty(crossSchemeInfoPOS)) {
//根据相位号分组
Map<String, List<CrossSchemeInfoPO>> collect = crossSchemeInfoPOS.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getPhaseNo));
Set<String> set = collect.keySet();
for (String s : set) {
List<CrossSchemeInfoPO> infoPOS = collect.get(s);
CrossSchemeInfoPO crossSchemeInfoPO = infoPOS.get(0);
SaveSchemeConfigDTO.PhaseListElement phaseListElement = new SaveSchemeConfigDTO.PhaseListElement();
phaseListElement.setPhaseId(Integer.valueOf(crossSchemeInfoPO.getPhaseId()));
phaseListElement.setPhaseNo(crossSchemeInfoPO.getPhaseTime());
phaseListElement.setGreenTime(Integer.valueOf(crossSchemeInfoPO.getGreenTime()));
phaseListElement.setYellowTime(Integer.valueOf(crossSchemeInfoPO.getYellowTime()));
phaseListElement.setRedTime(Integer.valueOf(crossSchemeInfoPO.getRedTime()));
List<SaveSchemeConfigDTO.DirListElement> dirListElements = new ArrayList<>();
Map<String, List<CrossSchemeInfoPO>> dircollect = infoPOS.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getDir));
if (ObjectUtil.isNotEmpty(dircollect)) {
Set<String> dirSet = dircollect.keySet();
for (String string : dirSet) {
List<CrossSchemeInfoPO> crossSchemeInfoPOS1 = dircollect.get(string);
CrossSchemeInfoPO po = crossSchemeInfoPOS1.get(0);
SaveSchemeConfigDTO.DirListElement dirListElement = new SaveSchemeConfigDTO.DirListElement();
dirListElement.setDir(Integer.valueOf(po.getDir()));
List<SaveSchemeConfigDTO.LaneListElement> laneList = new ArrayList<>();
Map<String, List<CrossSchemeInfoPO>> laneCollect = crossSchemeInfoPOS1.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getLandId));
if (ObjectUtil.isNotEmpty(laneCollect)) {
Set<String> stringSet = laneCollect.keySet();
for (String s1 : stringSet) {
List<CrossSchemeInfoPO> crossSchemeInfoPOS2 = laneCollect.get(s1);
CrossSchemeInfoPO schemeInfoPO = crossSchemeInfoPOS2.get(0);
SaveSchemeConfigDTO.LaneListElement laneListElement = new SaveSchemeConfigDTO.LaneListElement();
laneListElement.setDirection(Integer.valueOf(schemeInfoPO.getDir()));
laneListElement.setLaneType(Integer.valueOf(schemeInfoPO.getLaneType()));
laneListElement.setLaneId(schemeInfoPO.getLandId());
laneListElement.setLightsId(Integer.valueOf(schemeInfoPO.getLightsId()));
laneList.add(laneListElement);
}
}
dirListElement.setLaneList(laneList);
dirListElements.add(dirListElement);
}
}
phaseListElement.setDirList(dirListElements);
oriPhaseList.add(phaseListElement);
}
}
if (ObjectUtil.isNotEmpty(oriPhaseList)) {
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(crossIdAndTimeDTO.getCrossId());
crossSchemeRingsDTO.setPattern(String.valueOf(schemeId));
//远程调用,获取优化后的方案信息
JsonViewObject optView = utcFeignClients.schemeOptLog(crossSchemeRingsDTO);
Integer optCode = optView.getCode();
if (optCode != 200 ) {
log.error("远程调用,获取优化后的方案信息 异常,路口id:{},方案号:", crossIdAndTimeDTO.getCrossId(), schemeId);
} else {
ObjectMapper mapper = JacksonUtils.getInstance();
List<CrossSchemeStageOptLogPO> crossSchedulesPOList = mapper.convertValue(optView.getContent(), new TypeReference<List<CrossSchemeStageOptLogPO>>() {
});
if (ObjectUtils.isNotEmpty(crossSchedulesPOList)) {
optPhaseList.addAll(oriPhaseList);
for (int i = 0; i < optPhaseList.size(); i++) {
CrossSchemeStageOptLogPO optLogPO = crossSchedulesPOList.get(i);
SaveSchemeConfigDTO.PhaseListElement optPhase = optPhaseList.get(i);
optPhase.setMinGreenTime(0);
optPhase.setMaxGreenTime(0);
optPhase.setGreenTime(optLogPO.getPhaseTime());
optPhase.setGreenFlashTime(0);
optPhase.setYellowFlashTime(0);
optPhase.setRedFlashTime(0);
optPhase.setYellowTime(0);
optPhase.setRedTime(0);
optPhase.setYellowFlash(0);
}
}
PhaseListByTimeVO phaseListByTimeVO = phaseListByTime(crossIdAndTimeDTO);
SaveSchemeConfigDTO.PhaseScheme phaseScheme = phaseListByTimeVO.getPhaseScheme();
if (phaseScheme != null) {
List<SaveSchemeConfigDTO.RingListElement> ringList = phaseScheme.getRingList();
SaveSchemeConfigDTO.RingListElement ringListElement = ringList.get(0);
List<SaveSchemeConfigDTO.GroupListElement> groupList = ringListElement.getGroupList();
for (SaveSchemeConfigDTO.GroupListElement groupListElement : groupList) {
List<SaveSchemeConfigDTO.PhaseListElement> phaseList = groupListElement.getPhaseList();
phaseListByTime.addAll(phaseList);
}
}
return phaseListByTime;
ringPhasePO.setOriPhaseList(oriPhaseList);
ringPhasePO.setOptPhaseList(optPhaseList);
return ringPhasePO;
}
private PhaseListByTimeVO getPhaseListByTimeVO(String planName, Date datetime, RunningPlanDTO runningPlanDTO,
......@@ -804,7 +895,7 @@ public class PlanSendServiceImpl implements PlanSendService {
}
@Override
public JsonViewObject saveToUtc(String crossId) throws Exception{
public JsonViewObject saveToUtc(String crossId) throws Exception {
SaveToUtcPO saveToUtcPO = buildSaveToUtcPO(crossId);
if (Objects.isNull(saveToUtcPO)) {
return JsonViewObject.newInstance().fail("下发到UTC数据参数异常");
......
......@@ -122,6 +122,10 @@ public interface FeignCommon {
@PostMapping("/staticInfo/crossSchemeNo")
JsonViewObject getSchemeNo(@RequestParam String crossId);
// 海信-获取方案号
@PostMapping("/staticInfo/crossSchemeNoStr")
JsonViewObject getSchemeNoStr(@RequestParam String crossId);
// 海信-下发临时方案
@PostMapping("/controlCommand/tempSchemeDetail")
JsonViewObject tempSchemeDetail(@RequestBody TempSchemeSendVO tempDetailVo);
......
utc.service.url=http://173.0.0.1:32000/utc
utc.dt.service.url=http://173.0.0.1:39002/utc-dt
utc.hisense.service.url=http://173.0.0.1:39003/utc-hisense
control.url=http://173.0.0.1:32001/web
ehualu.url=http://173.0.0.1:30015
\ No newline at end of file
utc.service.url=http://173.17.0.1:32000/utc
utc.dt.service.url=http://173.17.0.1:39002/utc-dt
utc.hisense.service.url=http://173.17.0.1:39003/utc-hisense
control.url=http://173.17.0.1:32001/web
ehualu.url=http://173.17.0.1:30015
\ No newline at end of file
......@@ -211,13 +211,11 @@ public class DiagnoServiceImpl implements DiagnoService {
@Override
public List<SchemeOptVO.PhaseOptTime> queryOptTime(CrossIdAndSchemeIdDTO crossIdAndSchemeIdDTO) {
//TODO
String crossId = crossIdAndSchemeIdDTO.getCrossId();
Integer schemeId = crossIdAndSchemeIdDTO.getSchemeId();
List<SchemeOptVO.PhaseOptTime> phaseOptTimeList = new ArrayList<>();
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(crossId);
//方案号*3-2
crossSchemeRingsDTO.setPattern(String.valueOf(schemeId));
//通过路口号和方案号查询方案id
......
......@@ -9,12 +9,11 @@ import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dao.entity.CrossSchemeStageOptLogPO;
import net.wanji.databus.dto.*;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import net.wanji.utc.hisense.pojo.result.CoordinationStatus;
import net.wanji.utc.hisense.pojo.result.CrossSchemeRings;
import net.wanji.utc.hisense.service.StaticInfoService;
import org.apache.commons.lang3.ObjectUtils;
......@@ -137,12 +136,6 @@ public class StaticInfoController {
@ApiResponse(code = 200, message = "OK", response = CrossSchemeRings.class)
})
public JsonViewObject schemeOptLog(@RequestBody @Validated CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
List<CrossSchemeStageOptLogPO> crossSchemeStageOptLogPOList = staticInfoService.schemeOptLog(crossSchemeRingsDTO);
if (ObjectUtils.isNotEmpty(crossSchemeStageOptLogPOList)) {
return JsonViewObject.newInstance().success(crossSchemeStageOptLogPOList);
} else {
return JsonViewObject.newInstance().fail("查询方案优化记录 失败");
}
return JsonViewObject.newInstance().success(staticInfoService.schemeOptLog(crossSchemeRingsDTO));
}
}
......@@ -6,7 +6,7 @@ import net.wanji.databus.dto.*;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import net.wanji.utc.hisense.pojo.result.CoordinationStatus;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.utc.hisense.pojo.result.CrossSchemeRings;
import java.util.List;
......
package net.wanji.utc.hisense.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
......@@ -34,6 +35,7 @@ import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author duanruiming
......@@ -379,8 +381,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
String pattern = tempSchemeSendVO.getPattern();
crossSchemeRingsDTO.setCrossId(crossId);
crossSchemeRingsDTO.setPattern(pattern);
boolean isOk = true;
//方案环图请求
CrossSchemeRings crossSchemeRings = staticInfoService.crossSchemeRings(crossSchemeRingsDTO);
long currentTimeMillis = System.currentTimeMillis();
if (Optional.ofNullable(crossSchemeRings).isPresent()) {
//环数
int ringCount = Integer.parseInt(crossSchemeRings.getRingCount());
......@@ -406,10 +410,18 @@ public class ControlCommandServiceImpl implements ControlCommandService {
try {
stagePhaseDTOList = staticInfoServiceImpl.stagePhaseList(cycle, ringCount, ringPhasesMap);
} catch (Exception e) {
CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO();
crossSchemeStageOptLogPO.setCrossId(crossId);
//方案号处理
int schemeId = (Integer.valueOf(crossSchemeRingsDTO.getPattern()) + 2) / 3;
crossSchemeStageOptLogPO.setSchemeId(schemeId);
crossSchemeStageOptLogPO.setOptResult(2);
crossSchemeStageOptLogPO.setDataInfo(JSONObject.toJSONString(tempSchemeSendVO));
crossSchemeStageOptLogPO.setBatchTime(currentTimeMillis);
crossSchemeStageOptLogMapper.insert(crossSchemeStageOptLogPO);
log.error("绿信比有误!");
throw new RuntimeException(e);
}
long currentTimeMillis = System.currentTimeMillis();
if (ObjectUtil.isNotEmpty(stagePhaseDTOList)) {
for (StagePhaseDTO stagePhaseDTO : stagePhaseDTOList) {
CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO();
......@@ -422,9 +434,22 @@ public class ControlCommandServiceImpl implements ControlCommandService {
crossSchemeStageOptLogPO.setOptResult(1);
crossSchemeStageOptLogPO.setDataInfo(JSONObject.toJSONString(tempSchemeSendVO));
crossSchemeStageOptLogPO.setBatchTime(currentTimeMillis);
List<RingPhaseDTO> ringPhaseList = stagePhaseDTO.getRingPhaseList();
List<Integer> list = ringPhaseList.stream().map(RingPhaseDTO::getPhaseId).collect(Collectors.toList());
String phases = CollectionUtil.join(list,",");
crossSchemeStageOptLogPO.setPhaseList(phases);
crossSchemeStageOptLogMapper.insert(crossSchemeStageOptLogPO);
}
} else {
isOk = false;
}
} else {
isOk = false;
}
if (!isOk) {
CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO();
crossSchemeStageOptLogPO.setCrossId(crossId);
//方案号处理
......@@ -436,7 +461,6 @@ public class ControlCommandServiceImpl implements ControlCommandService {
crossSchemeStageOptLogMapper.insert(crossSchemeStageOptLogPO);
}
}
}
/**
* @return java.lang.String
......
......@@ -22,7 +22,7 @@ import net.wanji.utc.hisense.common.constants.HttpConstants;
import net.wanji.utc.hisense.mapper.*;
import net.wanji.utc.hisense.pojo.dto.RingPhaseDTO;
import net.wanji.utc.hisense.pojo.dto.StagePhaseDTO;
import net.wanji.utc.hisense.pojo.result.CoordinationStatus;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.utc.hisense.pojo.result.CrossSchemeRings;
import net.wanji.utc.hisense.pojo.view.*;
import net.wanji.utc.hisense.service.StaticInfoService;
......@@ -246,11 +246,11 @@ public class StaticInfoServiceImpl implements StaticInfoService {
}
/**
* @return java.util.List<net.wanji.utc.hisense.pojo.dto.StagePhaseDTO>
* @Description 环封装阶段
* @Param [cycle, ringCount, ringPhasesMap]
* @return java.util.List<net.wanji.utc.hisense.pojo.dto.StagePhaseDTO>
**/
public List<StagePhaseDTO> stagePhaseList(int cycle, int ringCount,Map<Integer, List<RingPhaseDTO>> ringPhasesMap){
public List<StagePhaseDTO> stagePhaseList(int cycle, int ringCount, Map<Integer, List<RingPhaseDTO>> ringPhasesMap) {
//已经计算的阶段时长
int stageTime = 0;
//循环次数,也代表阶段号
......@@ -298,8 +298,15 @@ public class StaticInfoServiceImpl implements StaticInfoService {
//取最后一位
RingPhaseDTO phaseDTO = collect.get(collect.size() - 1);
//状态最后一次出现的1的下一个相位
int index = ringPhaseDTOS.lastIndexOf(phaseDTO)+1;
RingPhaseDTO ringPhaseDTO = ringPhaseDTOS.get(index);
int index = ringPhaseDTOS.lastIndexOf(phaseDTO) + 1;
RingPhaseDTO ringPhaseDTO = null;
/*if (index >= ringPhaseDTOS.size()) {
firstRingPhaseDTO = ringPhaseDTOS.get(ringPhaseDTOS.size() - 1);
int phaseTime = cycle - stageTime;
firstPhaseTime = phaseTime;
minStageMap.put(i, index - 1);
} else {*/
ringPhaseDTO = ringPhaseDTOS.get(index);
//计算该相位及走过的所有时间
int totalTime = ringPhaseDTOS.stream().filter(x -> ringPhaseDTOS.indexOf(x) <= index).mapToInt(RingPhaseDTO::getPhaseTime).sum();
//totalTime - stageTime 为该相位剩余时间
......@@ -319,6 +326,8 @@ public class StaticInfoServiceImpl implements StaticInfoService {
minStageMap.put(i, index);
}
}
// }
stageList.add(ringPhaseDTO);
} else {
//在第一个相位
......@@ -464,6 +473,8 @@ public class StaticInfoServiceImpl implements StaticInfoService {
crossLightsPO.setType(3);
} else if (wjPerson == 0 && wjLightsDir > 0) {
crossLightsPO.setType(1);
} else if (wjLightsDir == 7) {
crossLightsPO.setType(1);
}
//key
String lightMapKey = String.valueOf(wjLightsDir).concat(String.valueOf(wjLightsTurn)).concat(String.valueOf(crossLightsPO.getType()));
......@@ -772,8 +783,8 @@ public class StaticInfoServiceImpl implements StaticInfoService {
public List<CrossSchemeStageOptLogPO> schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
LambdaQueryWrapper<CrossSchemeStageOptLogPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CrossSchemeStageOptLogPO::getCrossId, crossSchemeRingsDTO.getCrossId())
.eq(CrossSchemeStageOptLogPO::getSchemeId,crossSchemeRingsDTO.getPattern())
.inSql(CrossSchemeStageOptLogPO::getBatchTime, "select max(batch_time) from t_cross_scheme_opt_log where cross_id = '"+crossSchemeRingsDTO.getCrossId()+"' and scheme_id = "+crossSchemeRingsDTO.getPattern());
.eq(CrossSchemeStageOptLogPO::getSchemeId, crossSchemeRingsDTO.getPattern())
.inSql(CrossSchemeStageOptLogPO::getBatchTime, "select max(batch_time) from t_cross_scheme_opt_log where cross_id = '" + crossSchemeRingsDTO.getCrossId() + "' and scheme_id = " + crossSchemeRingsDTO.getPattern());
List<CrossSchemeStageOptLogPO> crossSchemeStageOptLogPOS = crossSchemeStageOptLogMapper.selectList(queryWrapper);
return crossSchemeStageOptLogPOS;
}
......
......@@ -147,6 +147,18 @@ public class StaticInfoController {
public JsonViewObject crossSchemeNo(@Validated @RequestBody CrossIdDTO crossIdDTO) throws Exception {
return staticInfoService.crossSchemeNo(crossIdDTO.getCrossId());
}
@AspectLog(description = "获取当前运行方案号", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossSchemeNoStr", produces = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
@ApiOperation(value = "获取当前运行方案号", notes = "获取当前运行方案号")
public JsonViewObject gwr( String crossId) throws Exception {
return staticInfoService.crossSchemeNo(crossId);
}
@AspectLog(description = "方案环图请求", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossSchemeRings", produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "方案环图请求", notes = "方案环图请求")
......
......@@ -25,6 +25,9 @@ public class CrossSchemeStageOptLogPO {
@ApiModelProperty(value = "相位编号")
private String phaseNo;
@ApiModelProperty(value = "阶段对应的相位号")
private String phaseList;
@ApiModelProperty(value = "相位时长")
private Integer phaseTime;
......
package net.wanji.databus.dao.mapper;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.po.CrossSchemeInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -58,4 +59,5 @@ public interface BaseCrossSchemeMapper {
List<BaseCrossSchemePO> selectAll();
BaseCrossSchemePO selectByCrossIdAndSchemeId(String crossId, Integer schemeId);
List<CrossSchemeInfoPO> selectSchemeInfoByCrossIdAndSchemeId(String crossId, Integer schemeId);
}
package net.wanji.utc.hisense.pojo.result;
package net.wanji.databus.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
......
package net.wanji.databus.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName CrossSchemeInfoPO
* @Description 路口方案及相位等信息
* @Author zhouleilei
* @Date 2024/11/24 21:26
*/
@Data
public class CrossSchemeInfoPO {
@ApiModelProperty(name = "路口编号", notes = "")
private String crossId;
@ApiModelProperty(name = "方案id", notes = "")
private String schemeId;
@ApiModelProperty(name = "方案号", notes = "")
private String schemeNo;
@ApiModelProperty(name = "相位号", notes = "")
private String phaseNo;
@ApiModelProperty(name = "相位时间", notes = "")
private String phaseTime;
@ApiModelProperty(name = "相位id", notes = "")
private String phaseId;
@ApiModelProperty(name = "绿灯时间", notes = "")
private String greenTime;
@ApiModelProperty(name = "黄灯时间", notes = "")
private String yellowTime;
@ApiModelProperty(name = "红灯时间", notes = "")
private String redTime;
@ApiModelProperty(name = "灯组id", notes = "")
private String lightsId;
@ApiModelProperty(name = "灯组方向", notes = "")
private String dir;
@ApiModelProperty(name = "车道id", notes = "")
private String landId;
@ApiModelProperty(name = "车道转向", notes = "1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头")
private String turn;
@ApiModelProperty(name = "车道类别", notes = "1机动车;2非机动车;3公交专用;4可变;5潮汐")
private String laneType;
}
......@@ -4,7 +4,7 @@
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.databus.dao.entity.BaseCrossSchemePO" id="BaseResultMap">
<result property="id" column="id" />
<result property="id" column="id"/>
<result property="schemeNo" column="scheme_no"/>
<result property="name" column="name"/>
<result property="crossId" column="cross_id"/>
......@@ -164,7 +164,8 @@
<select id="selectByCrossIdAndPartialSchemeName"
resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
select <include refid="baseColumnList"/>
select
<include refid="baseColumnList"/>
from t_base_cross_scheme
where cross_id = #{crossId}
<if test="schemeName != null and schemeName != ''">
......@@ -184,5 +185,39 @@
from t_base_cross_scheme
where cross_id = #{crossId} and id = #{schemeId}
</select>
<select id="selectSchemeInfoByCrossIdAndSchemeId" resultType="net.wanji.databus.po.CrossSchemeInfoPO">
SELECT
sche.id AS schemeId,
sche.cross_id AS crossId,
sche.scheme_no AS schemeNo,
phase.phase_no AS phaseNo,
phase.phase_time AS phaseTime,
phase.id AS phaseId,
phase.green_time AS greenTime,
phase.yellow_time AS yellowTime,
phase.red_time AS redTime,
pl.lights_id AS lightsId,
light.dir,
ll.lane_id AS landId,
lane.turn,
lane.category AS laneType
FROM
t_base_cross_scheme sche
LEFT JOIN t_base_cross_phase phase ON sche.cross_id = phase.cross_id
AND sche.id = phase.plan_id
LEFT JOIN t_base_cross_phase_lights pl ON pl.cross_id = phase.cross_id
AND pl.phase_id = phase.id
LEFT JOIN t_base_cross_lights light ON light.cross_id = phase.cross_id
AND light.id = pl.lights_id
LEFT JOIN t_base_cross_lane_lights ll ON ll.cross_id = light.cross_id
AND ll.lights_id = light.id
LEFT JOIN t_base_lane_info lane ON lane.cross_id = ll.cross_id
AND lane.id = ll.lane_id
WHERE
sche.cross_id = #{crossId}
AND sche.scheme_no = #{schemeId}
ORDER BY
phaseNo ASC
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment