Commit 139b9b1f authored by zhouleilei's avatar zhouleilei

策略管理-根据当前时间返回相位列表(单环)

parent 78f94631
...@@ -5,10 +5,11 @@ import io.swagger.annotations.ApiOperation; ...@@ -5,10 +5,11 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.common.annotation.aspect.AspectLog; import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.web.dto.*; import net.wanji.web.dto.*;
import net.wanji.web.po.RingPhasePO;
import net.wanji.web.service.impl.PlanSendServiceImpl; import net.wanji.web.service.impl.PlanSendServiceImpl;
import net.wanji.web.vo.PhaseListByTimeVO; import net.wanji.web.vo.PhaseListByTimeVO;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -16,8 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -16,8 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody;
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 java.util.List;
/** /**
* @author hanbing * @author hanbing
* @date 2023/01/04 16:10 * @date 2023/01/04 16:10
...@@ -92,7 +91,7 @@ public class PlanSendController { ...@@ -92,7 +91,7 @@ public class PlanSendController {
@AspectLog(description = "信号机方案同步", operationType = BaseEnum.OperationTypeEnum.UPDATE) @AspectLog(description = "信号机方案同步", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "信号机方案同步", notes = "信号机方案同步") @ApiOperation(value = "信号机方案同步", notes = "信号机方案同步")
@PostMapping("/syncScheme") @PostMapping("/syncScheme")
public JsonViewObject syncScheme(@RequestBody CrossIdBO crossIdBO) throws Exception{ public JsonViewObject syncScheme(@RequestBody CrossIdBO crossIdBO) throws Exception {
JsonViewObject jsonViewObject = planSendService.syncScheme(crossIdBO); JsonViewObject jsonViewObject = planSendService.syncScheme(crossIdBO);
return jsonViewObject; return jsonViewObject;
} }
...@@ -100,7 +99,7 @@ public class PlanSendController { ...@@ -100,7 +99,7 @@ public class PlanSendController {
@AspectLog(description = "信号机调度日计划同步", operationType = BaseEnum.OperationTypeEnum.UPDATE) @AspectLog(description = "信号机调度日计划同步", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "信号机调度日计划同步", notes = "信号机调度日计划同步") @ApiOperation(value = "信号机调度日计划同步", notes = "信号机调度日计划同步")
@PostMapping("/syncSchedules") @PostMapping("/syncSchedules")
public JsonViewObject syncSchedules(@RequestBody CrossIdBO crossIdBO) throws Exception{ public JsonViewObject syncSchedules(@RequestBody CrossIdBO crossIdBO) throws Exception {
// planSendService.syncSchedules(crossIdBO.getCrossId()); // planSendService.syncSchedules(crossIdBO.getCrossId());
return JsonViewObject.newInstance().success(""); return JsonViewObject.newInstance().success("");
} }
...@@ -125,11 +124,10 @@ public class PlanSendController { ...@@ -125,11 +124,10 @@ public class PlanSendController {
@ApiResponse(code = 200, message = "OK", response = SaveSchemeConfigDTO.PhaseListElement.class), @ApiResponse(code = 200, message = "OK", response = SaveSchemeConfigDTO.PhaseListElement.class),
}) })
public JsonViewObject phaseListByTimeSingleRing(@RequestBody CrossIdAndTimeDTO crossIdAndTimeDTO) { public JsonViewObject phaseListByTimeSingleRing(@RequestBody CrossIdAndTimeDTO crossIdAndTimeDTO) {
List<SaveSchemeConfigDTO.PhaseListElement> phaseListByTime RingPhasePO ringPhasePO = planSendService.phaseListByTimeSingleRing(crossIdAndTimeDTO);
= planSendService.phaseListByTimeSingleRing(crossIdAndTimeDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(phaseListByTime); return jsonViewObject.success(ringPhasePO);
} }
@AspectLog(description = "下发数据到UTC", operationType = BaseEnum.OperationTypeEnum.UPDATE) @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; package net.wanji.web.service;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.common.framework.rest.JsonViewObject; 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 net.wanji.web.vo.PhaseListByTimeVO;
import java.util.List;
/** /**
* @author Kent HAN * @author Kent HAN
* @date 2022/11/3 16:14 * @date 2022/11/3 16:14
...@@ -30,7 +32,7 @@ public interface PlanSendService { ...@@ -30,7 +32,7 @@ public interface PlanSendService {
PhaseListByTimeVO phaseListByTime(CrossIdAndTimeDTO crossIdAndTimeDTO); PhaseListByTimeVO phaseListByTime(CrossIdAndTimeDTO crossIdAndTimeDTO);
List<SaveSchemeConfigDTO.PhaseListElement> phaseListByTimeSingleRing(CrossIdAndTimeDTO crossIdAndTimeDTO); RingPhasePO phaseListByTimeSingleRing(CrossIdAndTimeDTO crossIdAndTimeDTO);
/** /**
* 下发数据到utc数据库 * 下发数据到utc数据库
......
...@@ -122,6 +122,10 @@ public interface FeignCommon { ...@@ -122,6 +122,10 @@ public interface FeignCommon {
@PostMapping("/staticInfo/crossSchemeNo") @PostMapping("/staticInfo/crossSchemeNo")
JsonViewObject getSchemeNo(@RequestParam String crossId); JsonViewObject getSchemeNo(@RequestParam String crossId);
// 海信-获取方案号
@PostMapping("/staticInfo/crossSchemeNoStr")
JsonViewObject getSchemeNoStr(@RequestParam String crossId);
// 海信-下发临时方案 // 海信-下发临时方案
@PostMapping("/controlCommand/tempSchemeDetail") @PostMapping("/controlCommand/tempSchemeDetail")
JsonViewObject tempSchemeDetail(@RequestBody TempSchemeSendVO tempDetailVo); JsonViewObject tempSchemeDetail(@RequestBody TempSchemeSendVO tempDetailVo);
......
utc.service.url=http://192.168.150.1:32000/utc utc.service.url=http://173.17.0.1:32000/utc
utc.dt.service.url=http://192.168.150.1:39002/utc-dt utc.dt.service.url=http://173.17.0.1:39002/utc-dt
utc.hisense.service.url=http://192.168.150.1:39003/utc-hisense utc.hisense.service.url=http://173.17.0.1:39003/utc-hisense
control.url=http://192.168.150.1:32001/web control.url=http://173.17.0.1:32001/web
ehualu.url=http://192.168.150.1:30015 ehualu.url=http://173.17.0.1:30015
\ No newline at end of file \ No newline at end of file
...@@ -211,13 +211,11 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -211,13 +211,11 @@ public class DiagnoServiceImpl implements DiagnoService {
@Override @Override
public List<SchemeOptVO.PhaseOptTime> queryOptTime(CrossIdAndSchemeIdDTO crossIdAndSchemeIdDTO) { public List<SchemeOptVO.PhaseOptTime> queryOptTime(CrossIdAndSchemeIdDTO crossIdAndSchemeIdDTO) {
//TODO
String crossId = crossIdAndSchemeIdDTO.getCrossId(); String crossId = crossIdAndSchemeIdDTO.getCrossId();
Integer schemeId = crossIdAndSchemeIdDTO.getSchemeId(); Integer schemeId = crossIdAndSchemeIdDTO.getSchemeId();
List<SchemeOptVO.PhaseOptTime> phaseOptTimeList = new ArrayList<>(); List<SchemeOptVO.PhaseOptTime> phaseOptTimeList = new ArrayList<>();
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO(); CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(crossId); crossSchemeRingsDTO.setCrossId(crossId);
//方案号*3-2
crossSchemeRingsDTO.setPattern(String.valueOf(schemeId)); crossSchemeRingsDTO.setPattern(String.valueOf(schemeId));
//通过路口号和方案号查询方案id //通过路口号和方案号查询方案id
......
...@@ -9,12 +9,11 @@ import net.wanji.common.annotation.aspect.AspectLog; ...@@ -9,12 +9,11 @@ import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.entity.CrossSchedulesPO; import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dao.entity.CrossSchemeStageOptLogPO;
import net.wanji.databus.dto.*; import net.wanji.databus.dto.*;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.databus.po.CrossInfoPO; import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO; import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO; 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.pojo.result.CrossSchemeRings;
import net.wanji.utc.hisense.service.StaticInfoService; import net.wanji.utc.hisense.service.StaticInfoService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
...@@ -102,7 +101,7 @@ public class StaticInfoController { ...@@ -102,7 +101,7 @@ public class StaticInfoController {
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CoordinationStatus.class) @ApiResponse(code = 200, message = "OK", response = CoordinationStatus.class)
}) })
public JsonViewObject crossPlanId(@NotNull String crossId) throws Exception { public JsonViewObject crossPlanId(@NotNull String crossId) throws Exception {
CoordinationStatus coordinationStatus = staticInfoService.crossPlan(crossId); CoordinationStatus coordinationStatus = staticInfoService.crossPlan(crossId);
if (ObjectUtils.isNotEmpty(coordinationStatus)) { if (ObjectUtils.isNotEmpty(coordinationStatus)) {
return JsonViewObject.newInstance().success(coordinationStatus); return JsonViewObject.newInstance().success(coordinationStatus);
...@@ -137,12 +136,6 @@ public class StaticInfoController { ...@@ -137,12 +136,6 @@ public class StaticInfoController {
@ApiResponse(code = 200, message = "OK", response = CrossSchemeRings.class) @ApiResponse(code = 200, message = "OK", response = CrossSchemeRings.class)
}) })
public JsonViewObject schemeOptLog(@RequestBody @Validated CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception { public JsonViewObject schemeOptLog(@RequestBody @Validated CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
List<CrossSchemeStageOptLogPO> crossSchemeStageOptLogPOList = staticInfoService.schemeOptLog(crossSchemeRingsDTO); return JsonViewObject.newInstance().success(staticInfoService.schemeOptLog(crossSchemeRingsDTO));
if (ObjectUtils.isNotEmpty(crossSchemeStageOptLogPOList)) {
return JsonViewObject.newInstance().success(crossSchemeStageOptLogPOList);
} else {
return JsonViewObject.newInstance().fail("查询方案优化记录 失败");
}
} }
} }
...@@ -6,7 +6,7 @@ import net.wanji.databus.dto.*; ...@@ -6,7 +6,7 @@ import net.wanji.databus.dto.*;
import net.wanji.databus.po.CrossInfoPO; import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO; import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO; 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 net.wanji.utc.hisense.pojo.result.CrossSchemeRings;
import java.util.List; import java.util.List;
......
package net.wanji.utc.hisense.service.impl; package net.wanji.utc.hisense.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -34,6 +35,7 @@ import javax.annotation.Resource; ...@@ -34,6 +35,7 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @author duanruiming * @author duanruiming
...@@ -379,8 +381,10 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -379,8 +381,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
String pattern = tempSchemeSendVO.getPattern(); String pattern = tempSchemeSendVO.getPattern();
crossSchemeRingsDTO.setCrossId(crossId); crossSchemeRingsDTO.setCrossId(crossId);
crossSchemeRingsDTO.setPattern(pattern); crossSchemeRingsDTO.setPattern(pattern);
boolean isOk = true;
//方案环图请求 //方案环图请求
CrossSchemeRings crossSchemeRings = staticInfoService.crossSchemeRings(crossSchemeRingsDTO); CrossSchemeRings crossSchemeRings = staticInfoService.crossSchemeRings(crossSchemeRingsDTO);
long currentTimeMillis = System.currentTimeMillis();
if (Optional.ofNullable(crossSchemeRings).isPresent()) { if (Optional.ofNullable(crossSchemeRings).isPresent()) {
//环数 //环数
int ringCount = Integer.parseInt(crossSchemeRings.getRingCount()); int ringCount = Integer.parseInt(crossSchemeRings.getRingCount());
...@@ -406,10 +410,18 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -406,10 +410,18 @@ public class ControlCommandServiceImpl implements ControlCommandService {
try { try {
stagePhaseDTOList = staticInfoServiceImpl.stagePhaseList(cycle, ringCount, ringPhasesMap); stagePhaseDTOList = staticInfoServiceImpl.stagePhaseList(cycle, ringCount, ringPhasesMap);
} catch (Exception e) { } 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("绿信比有误!"); log.error("绿信比有误!");
throw new RuntimeException(e); throw new RuntimeException(e);
} }
long currentTimeMillis = System.currentTimeMillis();
if (ObjectUtil.isNotEmpty(stagePhaseDTOList)) { if (ObjectUtil.isNotEmpty(stagePhaseDTOList)) {
for (StagePhaseDTO stagePhaseDTO : stagePhaseDTOList) { for (StagePhaseDTO stagePhaseDTO : stagePhaseDTOList) {
CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO(); CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO();
...@@ -422,19 +434,31 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -422,19 +434,31 @@ public class ControlCommandServiceImpl implements ControlCommandService {
crossSchemeStageOptLogPO.setOptResult(1); crossSchemeStageOptLogPO.setOptResult(1);
crossSchemeStageOptLogPO.setDataInfo(JSONObject.toJSONString(tempSchemeSendVO)); crossSchemeStageOptLogPO.setDataInfo(JSONObject.toJSONString(tempSchemeSendVO));
crossSchemeStageOptLogPO.setBatchTime(currentTimeMillis); 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); crossSchemeStageOptLogMapper.insert(crossSchemeStageOptLogPO);
} }
} else { } else {
CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO(); isOk = false;
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);
} }
} else {
isOk = false;
}
if (!isOk) {
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);
} }
} }
......
...@@ -22,7 +22,7 @@ import net.wanji.utc.hisense.common.constants.HttpConstants; ...@@ -22,7 +22,7 @@ import net.wanji.utc.hisense.common.constants.HttpConstants;
import net.wanji.utc.hisense.mapper.*; import net.wanji.utc.hisense.mapper.*;
import net.wanji.utc.hisense.pojo.dto.RingPhaseDTO; import net.wanji.utc.hisense.pojo.dto.RingPhaseDTO;
import net.wanji.utc.hisense.pojo.dto.StagePhaseDTO; 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.result.CrossSchemeRings;
import net.wanji.utc.hisense.pojo.view.*; import net.wanji.utc.hisense.pojo.view.*;
import net.wanji.utc.hisense.service.StaticInfoService; import net.wanji.utc.hisense.service.StaticInfoService;
...@@ -69,7 +69,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -69,7 +69,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
private VNtcipChannelViewMapper vNtcipChannelViewMapper; private VNtcipChannelViewMapper vNtcipChannelViewMapper;
@Resource @Resource
private VNtcipPatternMapper vNtcipPatternMapper; private VNtcipPatternMapper vNtcipPatternMapper;
@Resource @Resource
private CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper; private CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper;
@Override @Override
...@@ -180,7 +180,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -180,7 +180,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
* @Param greenTime 绿 * @Param greenTime 绿
* @Param yellowTime 黄 * @Param yellowTime 黄
**/ **/
public Map<Integer, List<RingPhaseDTO>> getRingPhasesMap(int ringCount, JSONObject cycleJSONObject, CrossSchemeRings.Phase phaseDto) { public Map<Integer, List<RingPhaseDTO>> getRingPhasesMap(int ringCount, JSONObject cycleJSONObject, CrossSchemeRings.Phase phaseDto) {
//16 个相位的红灯时间(单位秒),中间用空格隔开,不存在的相位置 0。 //16 个相位的红灯时间(单位秒),中间用空格隔开,不存在的相位置 0。
String[] redTime = phaseDto.getRedTime().split(" "); String[] redTime = phaseDto.getRedTime().split(" ");
//16 个相位的绿灯时间(单位秒),中间用空格隔开,不存在的相位置 0。 //16 个相位的绿灯时间(单位秒),中间用空格隔开,不存在的相位置 0。
...@@ -246,11 +246,11 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -246,11 +246,11 @@ public class StaticInfoServiceImpl implements StaticInfoService {
} }
/** /**
* @Description 环封装阶段 * @return java.util.List<net.wanji.utc.hisense.pojo.dto.StagePhaseDTO>
* @Param [cycle, ringCount, ringPhasesMap] * @Description 环封装阶段
* @return java.util.List<net.wanji.utc.hisense.pojo.dto.StagePhaseDTO> * @Param [cycle, ringCount, ringPhasesMap]
**/ **/
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; int stageTime = 0;
//循环次数,也代表阶段号 //循环次数,也代表阶段号
...@@ -298,27 +298,36 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -298,27 +298,36 @@ public class StaticInfoServiceImpl implements StaticInfoService {
//取最后一位 //取最后一位
RingPhaseDTO phaseDTO = collect.get(collect.size() - 1); RingPhaseDTO phaseDTO = collect.get(collect.size() - 1);
//状态最后一次出现的1的下一个相位 //状态最后一次出现的1的下一个相位
int index = ringPhaseDTOS.lastIndexOf(phaseDTO)+1; int index = ringPhaseDTOS.lastIndexOf(phaseDTO) + 1;
RingPhaseDTO ringPhaseDTO = ringPhaseDTOS.get(index); RingPhaseDTO ringPhaseDTO = null;
//计算该相位及走过的所有时间 /*if (index >= ringPhaseDTOS.size()) {
int totalTime = ringPhaseDTOS.stream().filter(x -> ringPhaseDTOS.indexOf(x) <= index).mapToInt(RingPhaseDTO::getPhaseTime).sum(); firstRingPhaseDTO = ringPhaseDTOS.get(ringPhaseDTOS.size() - 1);
//totalTime - stageTime 为该相位剩余时间 int phaseTime = cycle - stageTime;
Integer phaseTime = totalTime - stageTime;
if (firstPhaseTime == 0) {
firstPhaseTime = phaseTime; firstPhaseTime = phaseTime;
firstRingPhaseDTO = ringPhaseDTO; minStageMap.put(i, index - 1);
minStageMap.put(i, index); } else {*/
} else { ringPhaseDTO = ringPhaseDTOS.get(index);
if (phaseTime <= firstPhaseTime) { //计算该相位及走过的所有时间
if (phaseTime < firstPhaseTime) { int totalTime = ringPhaseDTOS.stream().filter(x -> ringPhaseDTOS.indexOf(x) <= index).mapToInt(RingPhaseDTO::getPhaseTime).sum();
//清空缓存 //totalTime - stageTime 为该相位剩余时间
minStageMap.clear(); Integer phaseTime = totalTime - stageTime;
} if (firstPhaseTime == 0) {
firstPhaseTime = phaseTime; firstPhaseTime = phaseTime;
firstRingPhaseDTO = ringPhaseDTO; firstRingPhaseDTO = ringPhaseDTO;
minStageMap.put(i, index); minStageMap.put(i, index);
} else {
if (phaseTime <= firstPhaseTime) {
if (phaseTime < firstPhaseTime) {
//清空缓存
minStageMap.clear();
}
firstPhaseTime = phaseTime;
firstRingPhaseDTO = ringPhaseDTO;
minStageMap.put(i, index);
}
} }
} // }
stageList.add(ringPhaseDTO); stageList.add(ringPhaseDTO);
} else { } else {
//在第一个相位 //在第一个相位
...@@ -464,6 +473,8 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -464,6 +473,8 @@ public class StaticInfoServiceImpl implements StaticInfoService {
crossLightsPO.setType(3); crossLightsPO.setType(3);
} else if (wjPerson == 0 && wjLightsDir > 0) { } else if (wjPerson == 0 && wjLightsDir > 0) {
crossLightsPO.setType(1); crossLightsPO.setType(1);
} else if (wjLightsDir == 7) {
crossLightsPO.setType(1);
} }
//key //key
String lightMapKey = String.valueOf(wjLightsDir).concat(String.valueOf(wjLightsTurn)).concat(String.valueOf(crossLightsPO.getType())); String lightMapKey = String.valueOf(wjLightsDir).concat(String.valueOf(wjLightsTurn)).concat(String.valueOf(crossLightsPO.getType()));
...@@ -771,9 +782,9 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -771,9 +782,9 @@ public class StaticInfoServiceImpl implements StaticInfoService {
@Override @Override
public List<CrossSchemeStageOptLogPO> schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception { public List<CrossSchemeStageOptLogPO> schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
LambdaQueryWrapper<CrossSchemeStageOptLogPO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CrossSchemeStageOptLogPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CrossSchemeStageOptLogPO::getCrossId, crossSchemeRingsDTO.getCrossId()) queryWrapper.eq(CrossSchemeStageOptLogPO::getCrossId, crossSchemeRingsDTO.getCrossId())
.eq(CrossSchemeStageOptLogPO::getSchemeId,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()); .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); List<CrossSchemeStageOptLogPO> crossSchemeStageOptLogPOS = crossSchemeStageOptLogMapper.selectList(queryWrapper);
return crossSchemeStageOptLogPOS; return crossSchemeStageOptLogPOS;
} }
......
...@@ -147,6 +147,18 @@ public class StaticInfoController { ...@@ -147,6 +147,18 @@ public class StaticInfoController {
public JsonViewObject crossSchemeNo(@Validated @RequestBody CrossIdDTO crossIdDTO) throws Exception { public JsonViewObject crossSchemeNo(@Validated @RequestBody CrossIdDTO crossIdDTO) throws Exception {
return staticInfoService.crossSchemeNo(crossIdDTO.getCrossId()); 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) @AspectLog(description = "方案环图请求", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossSchemeRings", produces = MediaType.APPLICATION_JSON) @PostMapping(value = "/crossSchemeRings", produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "方案环图请求", notes = "方案环图请求") @ApiOperation(value = "方案环图请求", notes = "方案环图请求")
......
...@@ -25,6 +25,9 @@ public class CrossSchemeStageOptLogPO { ...@@ -25,6 +25,9 @@ public class CrossSchemeStageOptLogPO {
@ApiModelProperty(value = "相位编号") @ApiModelProperty(value = "相位编号")
private String phaseNo; private String phaseNo;
@ApiModelProperty(value = "阶段对应的相位号")
private String phaseList;
@ApiModelProperty(value = "相位时长") @ApiModelProperty(value = "相位时长")
private Integer phaseTime; private Integer phaseTime;
......
package net.wanji.databus.dao.mapper; package net.wanji.databus.dao.mapper;
import net.wanji.databus.dao.entity.BaseCrossSchemePO; import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.po.CrossSchemeInfoPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -58,4 +59,5 @@ public interface BaseCrossSchemeMapper { ...@@ -58,4 +59,5 @@ public interface BaseCrossSchemeMapper {
List<BaseCrossSchemePO> selectAll(); List<BaseCrossSchemePO> selectAll();
BaseCrossSchemePO selectByCrossIdAndSchemeId(String crossId, Integer schemeId); 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.AllArgsConstructor;
import lombok.Builder; 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 @@ ...@@ -4,7 +4,7 @@
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap type="net.wanji.databus.dao.entity.BaseCrossSchemePO" id="BaseResultMap"> <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="schemeNo" column="scheme_no"/>
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="crossId" column="cross_id"/> <result property="crossId" column="cross_id"/>
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<select id="selectByCrossId" resultMap="BaseResultMap"> <select id="selectByCrossId" resultMap="BaseResultMap">
select select
id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified
from t_base_cross_scheme from t_base_cross_scheme
where cross_id = #{crossId} where cross_id = #{crossId}
</select> </select>
...@@ -130,14 +130,14 @@ ...@@ -130,14 +130,14 @@
<select id="selectByCrossIdAndSchemeName" resultMap="BaseResultMap"> <select id="selectByCrossIdAndSchemeName" resultMap="BaseResultMap">
select select
id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified
from t_base_cross_scheme from t_base_cross_scheme
where cross_id = #{crossId} and name = #{schemeName} where cross_id = #{crossId} and name = #{schemeName}
</select> </select>
<select id="selectById" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO"> <select id="selectById" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
select select
id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified
from t_base_cross_scheme from t_base_cross_scheme
where id = #{id} where id = #{id}
</select> </select>
...@@ -157,32 +157,67 @@ ...@@ -157,32 +157,67 @@
<select id="selectByCrossIdAndSchemeNo" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO"> <select id="selectByCrossIdAndSchemeNo" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
select select
id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified
from t_base_cross_scheme from t_base_cross_scheme
where cross_id = #{crossId} and scheme_no = #{schemeNo} where cross_id = #{crossId} and scheme_no = #{schemeNo}
</select> </select>
<select id="selectByCrossIdAndPartialSchemeName" <select id="selectByCrossIdAndPartialSchemeName"
resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO"> resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
select <include refid="baseColumnList"/> select
<include refid="baseColumnList"/>
from t_base_cross_scheme from t_base_cross_scheme
where cross_id = #{crossId} where cross_id = #{crossId}
<if test="schemeName != null and schemeName != ''"> <if test="schemeName != null and schemeName != ''">
AND name LIKE CONCAT('%',#{schemeName},'%') AND name LIKE CONCAT('%',#{schemeName},'%')
</if> </if>
</select> </select>
<select id="selectAll" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO"> <select id="selectAll" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
select select
id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified
from t_base_cross_scheme from t_base_cross_scheme
</select> </select>
<select id="selectByCrossIdAndSchemeId" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO"> <select id="selectByCrossIdAndSchemeId" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
select select
id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified id,scheme_no,name,cross_id,cycle,coord_phase,offset,source,is_deleted,status,gmt_create,gmt_modified
from t_base_cross_scheme from t_base_cross_scheme
where cross_id = #{crossId} and id = #{schemeId} where cross_id = #{crossId} and id = #{schemeId}
</select> </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> </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