Commit 9607f4d2 authored by zhouleilei's avatar zhouleilei

解决计划关联时段问题

parent 80ee780d
...@@ -459,15 +459,48 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -459,15 +459,48 @@ public class StaticInfoServiceImpl implements StaticInfoService {
crossPhasePO.setControlMode(1); crossPhasePO.setControlMode(1);
} }
crossPhasePO.setPhaseTime(stageTime); crossPhasePO.setPhaseTime(stageTime);
crossPhasePO.setGreenTime(ringPhaseList.get(0).getGreenTime()); Integer index = null;
List<RingPhaseDTO> collect = ringPhaseList.stream().filter(x -> x.getYellowTime() + x.getRedTime() + x.getGreenTime() == stageTime).collect(Collectors.toList());
//首先取红绿黄灯和的时长=阶段时长,再次取有红灯时长的相位
if (CollectionUtil.isNotEmpty(collect)) {
List<RingPhaseDTO> collect1 = collect.stream().filter(x -> x.getRedTime() != 0).collect(Collectors.toList());
RingPhaseDTO ringPhaseDTO = null;
if (CollectionUtil.isNotEmpty(collect1)) {
ringPhaseDTO = collect1.get(0);
} else {
ringPhaseDTO = collect.get(0);
}
index = ringPhaseList.indexOf(ringPhaseDTO);
}
if (index != null) {
crossPhasePO.setGreenTime(ringPhaseList.get(index).getGreenTime());
crossPhasePO.setYellowTime(ringPhaseList.get(index).getYellowTime());
crossPhasePO.setRedTime(ringPhaseList.get(index).getRedTime());
crossPhasePO.setMinGreenTime(ringPhaseList.get(index).getMinGTime());
crossPhasePO.setMaxGreenTime(ringPhaseList.get(index).getMaxGTime());
} else {
//如果没有匹配到,则取有红灯相位的红灯,黄灯时间,通过阶段时长算出绿灯时长
List<RingPhaseDTO> collect1 = ringPhaseList.stream().filter(x -> x.getRedTime() != 0).collect(Collectors.toList());
RingPhaseDTO phaseDTO = null;
if (CollectionUtil.isNotEmpty(collect1)) {
phaseDTO = collect1.get(0);
} else {
phaseDTO = ringPhaseList.get(0);
}
Integer redTime = phaseDTO.getRedTime();
Integer yellowTime = phaseDTO.getYellowTime();
crossPhasePO.setYellowTime(yellowTime);
crossPhasePO.setRedTime(redTime);
crossPhasePO.setMinGreenTime(phaseDTO.getMinGTime());
crossPhasePO.setMaxGreenTime(phaseDTO.getMaxGTime());
crossPhasePO.setGreenTime(stageTime - redTime - yellowTime);
}
crossPhasePO.setGreenFlashTime(0); crossPhasePO.setGreenFlashTime(0);
crossPhasePO.setYellowFlashTime(0); crossPhasePO.setYellowFlashTime(0);
crossPhasePO.setRedFlashTime(0); crossPhasePO.setRedFlashTime(0);
crossPhasePO.setPedFlashTime(0); crossPhasePO.setPedFlashTime(0);
crossPhasePO.setYellowTime(ringPhaseList.get(0).getYellowTime());
crossPhasePO.setRedTime(ringPhaseList.get(0).getRedTime());
crossPhasePO.setMinGreenTime(ringPhaseList.get(0).getMinGTime());
crossPhasePO.setMaxGreenTime(ringPhaseList.get(0).getMaxGTime());
crossPhasePO.setGmtCreate(null); crossPhasePO.setGmtCreate(null);
crossPhasePO.setGmtModified(null); crossPhasePO.setGmtModified(null);
crossPhaseList.add(crossPhasePO); crossPhaseList.add(crossPhasePO);
...@@ -599,19 +632,19 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -599,19 +632,19 @@ public class StaticInfoServiceImpl implements StaticInfoService {
PlanSectionVO planSectionVO = new PlanSectionVO(); PlanSectionVO planSectionVO = new PlanSectionVO();
List<CrossSectionPO> crossSectionPOList = new ArrayList<>(); List<CrossSectionPO> crossSectionPOList = new ArrayList<>();
//时段数据 //时段数据
List<VNtcipTimeBaseDayplanDTO> dayplanDTOS = collect.get(i); List<VNtcipTimeBaseDayplanDTO> dayplanDTOS = collect.get(i).stream().sorted(Comparator.comparing(VNtcipTimeBaseDayplanDTO::getNDayPlanEventNumber)).collect(Collectors.toList());
for (int i1 = 0; i1 < dayplanDTOS.size(); i1++) { for (int i1 = 0; i1 < dayplanDTOS.size(); i1++) {
VNtcipTimeBaseDayplanDTO dayplanDTO = dayplanDTOS.get(i1); VNtcipTimeBaseDayplanDTO dayplanDTO = dayplanDTOS.get(i1);
CrossSectionPO crossSectionPO = new CrossSectionPO(); CrossSectionPO crossSectionPO = new CrossSectionPO();
crossSectionPO.setCrossId(crossId); crossSectionPO.setCrossId(crossId);
//时段号 - 取的是时段序号 //时段号 - 取的是时段序号
crossSectionPO.setSectionNo(dayplanDTO.getNDayPlanEventNumber() + ""); crossSectionPO.setSectionNo(dayplanDTO.getNDayPlanEventNumber() + "");
crossSectionPO.setStartTime(dayplanDTO.getNDayPlanHour() + ":" + dayplanDTO.getNDayPlanMinute()); crossSectionPO.setStartTime(String.format("%02d", Integer.valueOf(dayplanDTO.getNDayPlanHour())) + ":" + String.format("%02d", Integer.valueOf(dayplanDTO.getNDayPlanMinute())));
if (i1 == dayplanDTOS.size() - 1) { if (i1 == dayplanDTOS.size() - 1) {
crossSectionPO.setEndTime("23:59"); crossSectionPO.setEndTime("23:59");
} else { } else {
VNtcipTimeBaseDayplanDTO dto = dayplanDTOS.get(i1 + 1); VNtcipTimeBaseDayplanDTO dto = dayplanDTOS.get(i1 + 1);
crossSectionPO.setEndTime(dto.getNDayPlanHour() + ":" + dto.getNDayPlanMinute()); crossSectionPO.setEndTime(String.format("%02d", Integer.valueOf(dto.getNDayPlanHour())) + ":" + String.format("%02d", Integer.valueOf(dto.getNDayPlanMinute())));
} }
// 计划ID - 取的是时段表号 // 计划ID - 取的是时段表号
crossSectionPO.setPlanId(dayplanDTO.getNDayPlanNumber()); crossSectionPO.setPlanId(dayplanDTO.getNDayPlanNumber());
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
resultMap="BaseResultMap" resultMap="BaseResultMap"
resultType="net.wanji.utc.hisense.pojo.view.VNtcipTimeBaseDayplanDTO"> resultType="net.wanji.utc.hisense.pojo.view.VNtcipTimeBaseDayplanDTO">
SELECT SELECT
DISTINCT
plan.NDAYPLANNUMBER , plan.NDAYPLANNUMBER ,
plan.NDAYPLANEVENTNUMBER , plan.NDAYPLANEVENTNUMBER ,
plan.NDAYPLANHOUR , plan.NDAYPLANHOUR ,
...@@ -29,11 +30,14 @@ ...@@ -29,11 +30,14 @@
action.NTIMEBASEASCAUXILLARYFUNCTION, action.NTIMEBASEASCAUXILLARYFUNCTION,
action.NTIMEBASEASCSPECIALFUNCTION action.NTIMEBASEASCSPECIALFUNCTION
FROM FROM
hicon.V_NTCIPTIMEBASEDAYPLAN plan hicon.V_NTCIPTIMEBASESCHEDULE schedele
LEFT JOIN hicon.V_NTCIPTIMEBASEDAYPLAN plan ON schedele.CINTSID = plan.CINTSID
AND schedele.NTIMEBASESCHEDULEDAYPLAN = plan.NDAYPLANNUMBER
LEFT JOIN hicon.V_NTCIPTIMEBASEASCACTION action ON plan.CINTSID = action.CINTSID LEFT JOIN hicon.V_NTCIPTIMEBASEASCACTION action ON plan.CINTSID = action.CINTSID
AND action.NTIMEBASEASCACTIONNUMBER = plan.NDAYPLANACTIONNUMBEROID AND action.NTIMEBASEASCACTIONNUMBER = plan.NDAYPLANACTIONNUMBEROID
WHERE WHERE
plan.NDAYPLANACTIONNUMBEROID != 0 plan.NDAYPLANACTIONNUMBEROID != 0
AND action.NTIMEBASEASCPATTERN != 0
<if test="crossId != null"> <if test="crossId != null">
AND plan.CINTSID = #{crossId} AND plan.CINTSID = #{crossId}
</if> </if>
......
...@@ -124,15 +124,15 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -124,15 +124,15 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
List<PlanSectionVO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<PlanSectionVO>>() {}); List<PlanSectionVO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<PlanSectionVO>>() {});
if (!CollectionUtils.isEmpty(content)) { if (!CollectionUtils.isEmpty(content)) {
crossSectionMapper.deleteOne(crossId, null,null); crossSectionMapper.deleteOne(crossId, null,null);
for (PlanSectionVO planSectionVO : content) { List<CrossPlanPO> crossPlanPOList = content.get(0).getCrossPlanPOList();
List<CrossPlanPO> crossPlanPOList = planSectionVO.getCrossPlanPOList();
crossPlanPOList.forEach(crossPlanPO -> { crossPlanPOList.forEach(crossPlanPO -> {
crossPlanMapper.deleteOne(crossId, Integer.parseInt(crossPlanPO.getPlanNo())); crossPlanMapper.deleteOne(crossId, Integer.parseInt(crossPlanPO.getPlanNo()));
crossPlanMapper.insertOne(crossPlanPO); crossPlanMapper.insertOne(crossPlanPO);
}); });
for (PlanSectionVO planSectionVO : content) {
List<CrossSectionPO> crossSectionPOList = planSectionVO.getCrossSectionPOList(); List<CrossSectionPO> crossSectionPOList = planSectionVO.getCrossSectionPOList();
crossSectionPOList.forEach(crossSectionPO -> { crossSectionPOList.forEach(crossSectionPO -> {
//crossSectionMapper.deleteOne(crossId, Integer.parseInt(crossSectionPO.getSectionNo()), null); // crossSectionMapper.deleteOne(crossId, Integer.parseInt(crossSectionPO.getSectionNo()), null);
Integer id = crossPlanMapper.selectIdByNo(crossSectionPO.getCrossId(), crossSectionPO.getPlanId()); Integer id = crossPlanMapper.selectIdByNo(crossSectionPO.getCrossId(), crossSectionPO.getPlanId());
crossSectionPO.setPlanId(id); crossSectionPO.setPlanId(id);
CrossSchemePO baseCrossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, crossSectionPO.getSchemeId()); CrossSchemePO baseCrossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, crossSectionPO.getSchemeId());
......
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