Commit 78f94631 authored by zhouleilei's avatar zhouleilei

策略管理-方案优化对比

parent 2caa76a6
...@@ -138,4 +138,8 @@ public interface FeignCommon { ...@@ -138,4 +138,8 @@ public interface FeignCommon {
@PostMapping("/controlCommand/stepingPhase") @PostMapping("/controlCommand/stepingPhase")
JsonViewObject stepingPhase(@RequestBody StepingPhaseDTO stepingPhaseDTO); JsonViewObject stepingPhase(@RequestBody StepingPhaseDTO stepingPhaseDTO);
// 海信-查询方案优化记录
@PostMapping("/staticInfo/schemeOptLog")
JsonViewObject schemeOptLog(@RequestBody CrossSchemeRingsDTO crossSchemeRingsDTO);
} }
utc.service.url=http://173.17.0.1:32000/utc utc.service.url=http://192.168.150.1:32000/utc
utc.dt.service.url=http://173.17.0.1:39002/utc-dt utc.dt.service.url=http://192.168.150.1:39002/utc-dt
utc.hisense.service.url=http://173.17.0.1:39003/utc-hisense utc.hisense.service.url=http://192.168.150.1:39003/utc-hisense
control.url=http://173.17.0.1:32001/web control.url=http://192.168.150.1:32001/web
ehualu.url=http://173.17.0.1:30015 ehualu.url=http://192.168.150.1:30015
\ No newline at end of file \ No newline at end of file
...@@ -2,21 +2,26 @@ package net.wanji.opt.service.impl; ...@@ -2,21 +2,26 @@ package net.wanji.opt.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.LightsAddressEnum; import net.wanji.common.enums.LightsAddressEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.CrossUtil; import net.wanji.common.utils.tool.CrossUtil;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.bo.CrossIdAndSchemeIdBO; import net.wanji.databus.bo.CrossIdAndSchemeIdBO;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.BaseCrossDirInfoPO; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.dao.entity.CrossPhasePO;
import net.wanji.databus.dao.entity.RidInfoEntity;
import net.wanji.databus.dao.mapper.*; import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.CrossSchemeRingsDTO;
import net.wanji.databus.po.*; import net.wanji.databus.po.*;
import net.wanji.databus.vo.SchemeOptSendVO;
import net.wanji.databus.vo.SchemeSendVO; import net.wanji.databus.vo.SchemeSendVO;
import net.wanji.feign.service.UtcFeignClients;
import net.wanji.opt.dao.mapper.CrossSchemeOptLogMapper; import net.wanji.opt.dao.mapper.CrossSchemeOptLogMapper;
import net.wanji.opt.dao.mapper.strategy.SceneMapper; import net.wanji.opt.dao.mapper.strategy.SceneMapper;
import net.wanji.opt.dto.*; import net.wanji.opt.dto.*;
...@@ -29,11 +34,12 @@ import net.wanji.opt.service.signalcontrol.FeignProxyService; ...@@ -29,11 +34,12 @@ import net.wanji.opt.service.signalcontrol.FeignProxyService;
import net.wanji.opt.service.strategy.SceneService; import net.wanji.opt.service.strategy.SceneService;
import net.wanji.opt.vo.CrossIdAndLocationVO; import net.wanji.opt.vo.CrossIdAndLocationVO;
import net.wanji.opt.vo.OptEffectVO; import net.wanji.opt.vo.OptEffectVO;
import net.wanji.databus.vo.SchemeOptSendVO;
import net.wanji.opt.vo.SchemeOptVO; import net.wanji.opt.vo.SchemeOptVO;
import org.apache.commons.lang3.ObjectUtils;
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 java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -61,10 +67,13 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -61,10 +67,13 @@ public class DiagnoServiceImpl implements DiagnoService {
private final CrossDirDataRealtimeMapper crossDirDataRealtimeMapper; private final CrossDirDataRealtimeMapper crossDirDataRealtimeMapper;
private final BaseCrossLaneLightsMapper baseCrossLaneLightsMapper; private final BaseCrossLaneLightsMapper baseCrossLaneLightsMapper;
private final BaseCrossLightsMapper baseCrossLightsMapper; private final BaseCrossLightsMapper baseCrossLightsMapper;
@Resource
private UtcFeignClients utcFeignClients;
private Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); private Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
// 机动车灯数据库类型与前端类型对应关系 // 机动车灯数据库类型与前端类型对应关系
private static final Map<Integer, Integer> MOTOR_VEH_MAP = new HashMap<>(5); private static final Map<Integer, Integer> MOTOR_VEH_MAP = new HashMap<>(5);
static { static {
MOTOR_VEH_MAP.put(1, 1); MOTOR_VEH_MAP.put(1, 1);
MOTOR_VEH_MAP.put(2, 3); MOTOR_VEH_MAP.put(2, 3);
...@@ -72,8 +81,10 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -72,8 +81,10 @@ public class DiagnoServiceImpl implements DiagnoService {
MOTOR_VEH_MAP.put(4, 5); MOTOR_VEH_MAP.put(4, 5);
MOTOR_VEH_MAP.put(5, 6); MOTOR_VEH_MAP.put(5, 6);
} }
// 非机动车灯数据库类型与前端类型对应关系 // 非机动车灯数据库类型与前端类型对应关系
private static final Map<Integer, Integer> NON_MOTOR_VEH_MAP = new HashMap<>(5); private static final Map<Integer, Integer> NON_MOTOR_VEH_MAP = new HashMap<>(5);
static { static {
MOTOR_VEH_MAP.put(10, 2); MOTOR_VEH_MAP.put(10, 2);
MOTOR_VEH_MAP.put(11, 3); MOTOR_VEH_MAP.put(11, 3);
...@@ -200,22 +211,59 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -200,22 +211,59 @@ 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();
List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId); crossSchemeRingsDTO.setCrossId(crossId);
for (CrossSchemeOptLogPO crossSchemeOptLogPO : maxList) { //方案号*3-2
crossSchemeRingsDTO.setPattern(String.valueOf(schemeId));
//通过路口号和方案号查询方案id
Integer integer = baseCrossSchemeMapper.selectIdByCrossIdAndSchemeNo(crossId, String.valueOf(schemeId));
List<CrossPhasePO> phasePOList = baseCrossPhaseMapper.selectByCrossIdAndSchemeId(crossId, integer);
if (ObjectUtils.isEmpty(phasePOList) || ObjectUtils.isEmpty(integer)) {
return phaseOptTimeList;
}
JsonViewObject jsonViewObject = utcFeignClients.schemeOptLog(crossSchemeRingsDTO);
Integer code = jsonViewObject.getCode();
ObjectMapper mapper = JacksonUtils.getInstance();
List<CrossSchemeStageOptLogPO> crossSchedulesPOList = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchemeStageOptLogPO>>() {
});
//
if (code != 200 || ObjectUtils.isEmpty(crossSchedulesPOList)) {
log.info("该路口方案暂未优化,{}", JSONObject.toJSONString(crossIdAndSchemeIdDTO));
//将优化后的方案都设置为0
for (CrossPhasePO crossPhasePO : phasePOList) {
SchemeOptVO.PhaseOptTime phaseOptTime = new SchemeOptVO.PhaseOptTime(); SchemeOptVO.PhaseOptTime phaseOptTime = new SchemeOptVO.PhaseOptTime();
String phaseNo = crossSchemeOptLogPO.getPhaseNo(); phaseOptTime.setPhaseNo(crossPhasePO.getPhaseNo());
phaseOptTime.setPhaseNo(phaseNo); phaseOptTime.setOriGreenTime(crossPhasePO.getPhaseTime());
Integer oriGreenTime = crossSchemeOptLogPO.getOriGreenTime(); phaseOptTime.setOptGreenTime(0);
phaseOptTime.setOriGreenTime(oriGreenTime); phaseOptTime.setOptTime(0);
Integer optGreenTime = getNewGreenTime(crossId, schemeId, phaseNo);
phaseOptTime.setOptGreenTime(optGreenTime);
phaseOptTime.setOptTime(optGreenTime - oriGreenTime);
phaseOptTimeList.add(phaseOptTime); phaseOptTimeList.add(phaseOptTime);
} }
} else {
for (CrossPhasePO crossPhasePO : phasePOList) {
SchemeOptVO.PhaseOptTime phaseOptTime = new SchemeOptVO.PhaseOptTime();
phaseOptTime.setPhaseNo(crossPhasePO.getPhaseNo());
Integer oriPhaseTime = crossPhasePO.getPhaseTime();
phaseOptTime.setOriGreenTime(oriPhaseTime);
List<CrossSchemeStageOptLogPO> list = crossSchedulesPOList.stream().filter(x -> x.getPhaseNo().equals(String.valueOf(crossPhasePO.getSort()))).collect(Collectors.toList());
if (ObjectUtils.isEmpty(list)) {
phaseOptTime.setOptGreenTime(0);
phaseOptTime.setOptTime(0);
} else {
CrossSchemeStageOptLogPO optLogPO = list.get(0);
Integer optPhaseTime = optLogPO.getPhaseTime();
phaseOptTime.setOptGreenTime(optPhaseTime);
//两个时间的绝对值
int optTime = Math.abs(oriPhaseTime - optPhaseTime);
phaseOptTime.setOptTime(optTime);
}
phaseOptTimeList.add(phaseOptTime);
}
}
return phaseOptTimeList; return phaseOptTimeList;
} }
......
spring: spring:
profiles: profiles:
active: dev active: docker
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ import net.wanji.common.annotation.aspect.AspectLog; ...@@ -9,6 +9,7 @@ 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.CrossInfoPO; import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO; import net.wanji.databus.vo.PlanSectionVO;
...@@ -127,4 +128,21 @@ public class StaticInfoController { ...@@ -127,4 +128,21 @@ public class StaticInfoController {
} }
} }
@AspectLog(description = "查询方案优化记录", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/schemeOptLog")
@ApiOperation(value = "查询方案优化记录", notes = "查询方案优化记录", response = CrossSchemeRings.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@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("查询方案优化记录 失败");
}
}
} }
package net.wanji.utc.hisense.service; package net.wanji.utc.hisense.service;
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.CrossInfoPO; import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO; import net.wanji.databus.vo.PlanSectionVO;
...@@ -31,4 +32,11 @@ public interface StaticInfoService { ...@@ -31,4 +32,11 @@ public interface StaticInfoService {
**/ **/
CrossSchemeRings crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception; CrossSchemeRings crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
/**
* @Description : 查询方案优化记录
* @Param crossId 路口编号
* @Param pattern 方案号
**/
List<CrossSchemeStageOptLogPO> schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
} }
package net.wanji.utc.hisense.service.impl; package net.wanji.utc.hisense.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.CrossSchemeStageOptLogPO;
import net.wanji.databus.dao.mapper.CrossInfoMapper; import net.wanji.databus.dao.mapper.CrossInfoMapper;
import net.wanji.databus.dao.mapper.CrossSchemeStageOptLogMapper;
import net.wanji.databus.dto.CrossSchemeRingsDTO; import net.wanji.databus.dto.CrossSchemeRingsDTO;
import net.wanji.databus.dto.ExtendPhaseDTO; import net.wanji.databus.dto.ExtendPhaseDTO;
import net.wanji.databus.dto.StepingPhaseDTO; import net.wanji.databus.dto.StepingPhaseDTO;
...@@ -46,6 +49,10 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -46,6 +49,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
private CrossInfoMapper crossInfoMapper; private CrossInfoMapper crossInfoMapper;
@Resource @Resource
private StaticInfoService staticInfoService; private StaticInfoService staticInfoService;
@Resource
private StaticInfoServiceImpl staticInfoServiceImpl;
@Resource
private CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper;
@Override @Override
public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception { public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception {
...@@ -354,11 +361,8 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -354,11 +361,8 @@ public class ControlCommandServiceImpl implements ControlCommandService {
if (code != 200) { if (code != 200) {
optResult = 2; optResult = 2;
} }
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(tempSchemeSendVO.getCrossId());
crossSchemeRingsDTO.setPattern(tempSchemeSendVO.getPattern());
//方案优化记录 //方案优化记录
crossSchemeOptLog(crossSchemeRingsDTO, tempSchemeSendVO.getSplit(), optResult); crossSchemeOptLog(tempSchemeSendVO, tempSchemeSendVO.getSplit(), optResult);
return jsonViewObject; return jsonViewObject;
} }
...@@ -369,8 +373,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -369,8 +373,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
* @Param split 优化的绿信比 * @Param split 优化的绿信比
* @Param result 下发结果 * @Param result 下发结果
**/ **/
private void crossSchemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO, String split, int result) throws Exception { private void crossSchemeOptLog(TempSchemeSendVO tempSchemeSendVO, String greenTime, int result) throws Exception {
//TODO CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
String crossId = tempSchemeSendVO.getCrossId();
String pattern = tempSchemeSendVO.getPattern();
crossSchemeRingsDTO.setCrossId(crossId);
crossSchemeRingsDTO.setPattern(pattern);
//方案环图请求 //方案环图请求
CrossSchemeRings crossSchemeRings = staticInfoService.crossSchemeRings(crossSchemeRingsDTO); CrossSchemeRings crossSchemeRings = staticInfoService.crossSchemeRings(crossSchemeRingsDTO);
if (Optional.ofNullable(crossSchemeRings).isPresent()) { if (Optional.ofNullable(crossSchemeRings).isPresent()) {
...@@ -386,21 +394,62 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -386,21 +394,62 @@ public class ControlCommandServiceImpl implements ControlCommandService {
int schemeNo = (Integer.valueOf(crossSchemeRings.getPattern()) + 2) / 3; int schemeNo = (Integer.valueOf(crossSchemeRings.getPattern()) + 2) / 3;
List<CrossSchemeRings.Phase> phaseList = crossSchemeRings.getPhaseList(); List<CrossSchemeRings.Phase> phaseList = crossSchemeRings.getPhaseList();
CrossSchemeRings.Phase phase = phaseList.get(0); CrossSchemeRings.Phase phase = phaseList.get(0);
//红灯黄灯时间给默认值0
phase.setRedTime(getDefaultPhaseTime());
phase.setYellowTime(getDefaultPhaseTime());
//绿灯时间为神思绿信比时间
phase.setGreenTime(greenTime);
//封装环和环上相位数据 //封装环和环上相位数据
Map<Integer, List<RingPhaseDTO>> ringPhasesMap = StaticInfoServiceImpl.getRingPhasesMap(ringCount, cycleJSONObject, phase); Map<Integer, List<RingPhaseDTO>> ringPhasesMap = staticInfoServiceImpl.getRingPhasesMap(ringCount, cycleJSONObject, phase);
//环封装阶段 //环封装阶段
List<StagePhaseDTO> stagePhaseDTOList = StaticInfoServiceImpl.stagePhaseList(cycle, ringCount, ringPhasesMap); List<StagePhaseDTO> stagePhaseDTOList = null;
System.out.println(stagePhaseDTOList); try {
stagePhaseDTOList = staticInfoServiceImpl.stagePhaseList(cycle, ringCount, ringPhasesMap);
} catch (Exception e) {
log.error("绿信比有误!");
throw new RuntimeException(e);
}
long currentTimeMillis = System.currentTimeMillis();
if (ObjectUtil.isNotEmpty(stagePhaseDTOList)) {
for (StagePhaseDTO stagePhaseDTO : stagePhaseDTOList) {
CrossSchemeStageOptLogPO crossSchemeStageOptLogPO = new CrossSchemeStageOptLogPO();
crossSchemeStageOptLogPO.setCrossId(crossId);
//方案号处理
int schemeId = (Integer.valueOf(crossSchemeRingsDTO.getPattern()) + 2) / 3;
crossSchemeStageOptLogPO.setSchemeId(schemeId);
crossSchemeStageOptLogPO.setPhaseNo(stagePhaseDTO.getStageId() + "");
crossSchemeStageOptLogPO.setPhaseTime(stagePhaseDTO.getStageTime());
crossSchemeStageOptLogPO.setOptResult(1);
crossSchemeStageOptLogPO.setDataInfo(JSONObject.toJSONString(tempSchemeSendVO));
crossSchemeStageOptLogPO.setBatchTime(currentTimeMillis);
crossSchemeStageOptLogMapper.insert(crossSchemeStageOptLogPO);
}
} else {
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);
}
} }
} }
public static void main(String[] args) { /**
* @return java.lang.String
* @Description 默认的相位时间
* @Param []
**/
private String getDefaultPhaseTime() {
StringBuilder str = new StringBuilder();
for (int i = 0; i < 16; i++) {
str.append("0").append(" ");
}
StringBuilder stringBuilder = str.deleteCharAt(str.lastIndexOf("") - 1);
return stringBuilder.toString();
} }
@Override @Override
......
...@@ -9,6 +9,7 @@ import net.wanji.common.utils.tool.ScheduleUtil; ...@@ -9,6 +9,7 @@ import net.wanji.common.utils.tool.ScheduleUtil;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.*; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.CrossInfoMapper; import net.wanji.databus.dao.mapper.CrossInfoMapper;
import net.wanji.databus.dao.mapper.CrossSchemeStageOptLogMapper;
import net.wanji.databus.dao.mapper.ManufacturerInfoMapper; import net.wanji.databus.dao.mapper.ManufacturerInfoMapper;
import net.wanji.databus.dto.*; import net.wanji.databus.dto.*;
import net.wanji.databus.po.CrossInfoPO; import net.wanji.databus.po.CrossInfoPO;
...@@ -68,6 +69,8 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -68,6 +69,8 @@ public class StaticInfoServiceImpl implements StaticInfoService {
private VNtcipChannelViewMapper vNtcipChannelViewMapper; private VNtcipChannelViewMapper vNtcipChannelViewMapper;
@Resource @Resource
private VNtcipPatternMapper vNtcipPatternMapper; private VNtcipPatternMapper vNtcipPatternMapper;
@Resource
private CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper;
@Override @Override
public List<CrossInfoPO> crossBasicInfo(CrossInfoDTO crossInfoDTO) throws Exception { public List<CrossInfoPO> crossBasicInfo(CrossInfoDTO crossInfoDTO) throws Exception {
...@@ -177,7 +180,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -177,7 +180,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
* @Param greenTime 绿 * @Param greenTime 绿
* @Param yellowTime 黄 * @Param yellowTime 黄
**/ **/
public static 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。
...@@ -247,7 +250,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -247,7 +250,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
* @Param [cycle, ringCount, ringPhasesMap] * @Param [cycle, ringCount, ringPhasesMap]
* @return java.util.List<net.wanji.utc.hisense.pojo.dto.StagePhaseDTO> * @return java.util.List<net.wanji.utc.hisense.pojo.dto.StagePhaseDTO>
**/ **/
public static 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;
//循环次数,也代表阶段号 //循环次数,也代表阶段号
...@@ -295,7 +298,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -295,7 +298,7 @@ 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 = ringPhaseDTOS.get(index);
//计算该相位及走过的所有时间 //计算该相位及走过的所有时间
int totalTime = ringPhaseDTOS.stream().filter(x -> ringPhaseDTOS.indexOf(x) <= index).mapToInt(RingPhaseDTO::getPhaseTime).sum(); int totalTime = ringPhaseDTOS.stream().filter(x -> ringPhaseDTOS.indexOf(x) <= index).mapToInt(RingPhaseDTO::getPhaseTime).sum();
...@@ -764,4 +767,14 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -764,4 +767,14 @@ public class StaticInfoServiceImpl implements StaticInfoService {
} }
return null; return null;
} }
@Override
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());
List<CrossSchemeStageOptLogPO> crossSchemeStageOptLogPOS = crossSchemeStageOptLogMapper.selectList(queryWrapper);
return crossSchemeStageOptLogPOS;
}
} }
...@@ -156,6 +156,15 @@ public class StaticInfoController { ...@@ -156,6 +156,15 @@ public class StaticInfoController {
public JsonViewObject crossSchemeRings(@Validated @RequestBody CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception { public JsonViewObject crossSchemeRings(@Validated @RequestBody CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
return staticInfoService.crossSchemeRings(crossSchemeRingsDTO); return staticInfoService.crossSchemeRings(crossSchemeRingsDTO);
} }
@AspectLog(description = "查询方案优化记录", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/schemeOptLog", produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "查询方案优化记录", notes = "查询方案优化记录")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
public JsonViewObject schemeOptLog(@Validated @RequestBody CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
return staticInfoService.schemeOptLog(crossSchemeRingsDTO);
}
} }
...@@ -31,4 +31,5 @@ public interface StaticInfoService { ...@@ -31,4 +31,5 @@ public interface StaticInfoService {
JsonViewObject signalTime(String crossId) throws Exception; JsonViewObject signalTime(String crossId) throws Exception;
JsonViewObject crossSchemeNo(String crossId) throws Exception; JsonViewObject crossSchemeNo(String crossId) throws Exception;
JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception; JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
JsonViewObject schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
} }
...@@ -53,4 +53,5 @@ public interface WanJiCommonStaticInfoService { ...@@ -53,4 +53,5 @@ public interface WanJiCommonStaticInfoService {
**/ **/
JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception; JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
JsonViewObject schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
} }
...@@ -229,4 +229,11 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -229,4 +229,11 @@ public class StaticInfoServiceImpl implements StaticInfoService {
jsonViewObject = wanjiCommonStaticInfoService.crossSchemeRings(crossSchemeRingsDTO); jsonViewObject = wanjiCommonStaticInfoService.crossSchemeRings(crossSchemeRingsDTO);
return jsonViewObject; return jsonViewObject;
} }
@Override
public JsonViewObject schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
jsonViewObject = wanjiCommonStaticInfoService.schemeOptLog(crossSchemeRingsDTO);
return jsonViewObject;
}
} }
...@@ -206,4 +206,15 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -206,4 +206,15 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
return jsonViewObject; return jsonViewObject;
} }
@Override
public JsonViewObject schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossSchemeRingsDTO.getCrossId());
FeignCommon utcFeignClientService = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode);
JsonViewObject jsonViewObject = utcFeignClientService.schemeOptLog(crossSchemeRingsDTO);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("查询方案优化记录远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
return jsonViewObject;
}
} }
package net.wanji.databus.dao.entity; package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -12,38 +13,31 @@ import java.sql.Date; ...@@ -12,38 +13,31 @@ import java.sql.Date;
* @Date 2024/11/23 14:23 * @Date 2024/11/23 14:23
*/ */
@Data @Data
public class CrossSchemeOptLogPO { @TableName("t_cross_scheme_opt_log")
@ApiModelProperty(value = "主键id") public class CrossSchemeStageOptLogPO {
private Integer id;
@ApiModelProperty(value = "") @ApiModelProperty(value = "路口编号")
private String crossId; private String crossId;
@ApiModelProperty(value = "") @ApiModelProperty(value = "方案号")
private Integer schemeId; private Integer schemeId;
@ApiModelProperty(value = "") @ApiModelProperty(value = "相位编号")
private Integer offset;
@ApiModelProperty(value = "")
private String phaseNo; private String phaseNo;
@ApiModelProperty(value = "") @ApiModelProperty(value = "相位时长")
private Integer oriPhaseTime; private Integer phaseTime;
@ApiModelProperty(value = "")
private Integer optPhaseTime;
@ApiModelProperty(value = "")
private Integer optTime;
@ApiModelProperty(value = "优化结果:1-成功 2-失败") @ApiModelProperty(value = "优化结果:1-成功 2-失败")
private String optResult; private Integer optResult;
@ApiModelProperty(value = "请求信息")
private String dataInfo;
@ApiModelProperty(value = "") @ApiModelProperty(value = "数据批次时间")
private Integer batchTime; private Long batchTime;
@ApiModelProperty(value = "") @ApiModelProperty(value = "数据插入时间")
private Date insertTime; private Date insertTime;
} }
package net.wanji.databus.dao.mapper; package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dao.entity.CrossSchemeOptLogPO; import net.wanji.databus.dao.entity.CrossSchemeStageOptLogPO;
/** /**
* @ClassName CrossSchemeOptLogMapper * @ClassName CrossSchemeOptLogMapper
...@@ -9,5 +9,5 @@ import net.wanji.databus.dao.entity.CrossSchemeOptLogPO; ...@@ -9,5 +9,5 @@ import net.wanji.databus.dao.entity.CrossSchemeOptLogPO;
* @Author zhouleilei * @Author zhouleilei
* @Date 2024/11/23 14:34 * @Date 2024/11/23 14:34
*/ */
public interface CrossSchemeOptLogMapper extends BaseMapper<CrossSchemeOptLogPO> { public interface CrossSchemeStageOptLogMapper extends BaseMapper<CrossSchemeStageOptLogPO> {
} }
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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.CrossSchemeOptLogMapper"> <mapper namespace="net.wanji.databus.dao.mapper.CrossSchemeStageOptLogMapper">
</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