Commit a1879b60 authored by hanbing's avatar hanbing

方案下发-信号机方案同步

parent 3a722535
......@@ -25,7 +25,7 @@ public class CrossLightsPO {
private Integer dir ;
/** 灯组序号 */
@ApiModelProperty(name = "灯组序号",notes = "")
private Integer sort ;
private Integer sort = 0 ;
/** 路口ID */
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId ;
......
......@@ -275,14 +275,16 @@ public class PlanSendServiceImpl implements PlanSendService {
}
}
List<CrossPhaseLightsPO> crossPhaseLightsPOList = schemePhaseLightsVO.getCrossPhaseLightsPOList();
for (CrossPhaseLightsPO crossPhaseLightsPO : crossPhaseLightsPOList) {
Integer lightsId = crossPhaseLightsPO.getLightsId();
Integer phaseId = crossPhaseLightsPO.getPhaseId();
String crossId = crossPhaseLightsPO.getCrossId();
Integer id = crossPhaseLightsMapper.selectIdByThreeIds(lightsId, phaseId, crossId);
// 如果数据库中有记录则跳过,无记录则插入
if (ObjectUtil.isEmpty(id)) {
crossPhaseLightsMapper.insertOne(crossPhaseLightsPO);
if (crossPhaseLightsPOList != null) {
for (CrossPhaseLightsPO crossPhaseLightsPO : crossPhaseLightsPOList) {
Integer lightsId = crossPhaseLightsPO.getLightsId();
Integer phaseId = crossPhaseLightsPO.getPhaseId();
String crossId = crossPhaseLightsPO.getCrossId();
Integer id = crossPhaseLightsMapper.selectIdByThreeIds(lightsId, phaseId, crossId);
// 如果数据库中有记录则跳过,无记录则插入
if (ObjectUtil.isEmpty(id)) {
crossPhaseLightsMapper.insertOne(crossPhaseLightsPO);
}
}
}
}
......
......@@ -4,6 +4,7 @@ import net.wanji.utc.po.CrossPhaseLightsPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* @author Kent HAN
......@@ -13,5 +14,9 @@ public interface CrossPhaseLightsMapper {
void deleteByCrossId(@Param("crossId") String crossId);
void insertBatch(@Param("entities") Set<CrossPhaseLightsPO> crossPhaseLightsPOSet);
void insertBatch(@Param("entities") List<CrossPhaseLightsPO> crossPhaseLightsPOList);
List<CrossPhaseLightsPO> selectByCrossId(String crossId);
}
......@@ -62,7 +62,7 @@ public class HkSchemePhaseLightsServiceImpl implements HkSchemePhaseLightsServic
private void handleLightsData(String crossId, String crossCode, Map<Integer, PhaseCache> laneNoMap)
throws Exception {
Map<String, String> path = PathUtil.getPathMapByApiCode("getCrossInfo");
List<CrossPhaseLightsPO> crossPhaseLightsPOList = new ArrayList<>();
Set<CrossPhaseLightsPO> crossPhaseLightsPOSet = new HashSet<>();
JSONObject requestContent = new JSONObject();
// 海康固定入参字段名
requestContent.put("pageNo", 1);
......@@ -118,7 +118,7 @@ public class HkSchemePhaseLightsServiceImpl implements HkSchemePhaseLightsServic
crossPhaseLightsPO.setLightsId(crossLightsPOId);
crossPhaseLightsPO.setPhaseId(id);
crossPhaseLightsPO.setCrossId(crossId);
crossPhaseLightsPOList.add(crossPhaseLightsPO);
crossPhaseLightsPOSet.add(crossPhaseLightsPO);
}
}
}
......@@ -127,7 +127,7 @@ public class HkSchemePhaseLightsServiceImpl implements HkSchemePhaseLightsServic
}
// 更新相位-灯组关系
crossPhaseLightsMapper.deleteByCrossId(crossId);
crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOList);
crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOSet);
}
private void handlePhaseData(String crossCode, Map<Integer, PhaseCache> phaseNoMap,
......
......@@ -36,6 +36,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
private final CrossSchemeMapper crossSchemeMapper;
private final CrossPhaseMapper crossPhaseMapper;
private final CrossLightsMapper crossLightsMapper;
private final CrossPhaseLightsMapper crossPhaseLightsMapper;
private final CrossPlanMapper crossPlanMapper;
private final CrossSectionMapper crossSectionMapper;
private final CrossSchedulesMapper crossSchedulesMapper;
......@@ -143,11 +144,14 @@ public class StaticInfoServiceImpl implements StaticInfoService {
List<CrossSchemePO> crossSchemePOList = crossSchemeMapper.selectByCrossId(crossId);
List<CrossPhasePO> crossPhasePOList = crossPhaseMapper.selectByCrossId(crossId);
List<CrossLightsPO> crossLightsPOList = crossLightsMapper.selectByCrossId(crossId);
List<CrossPhaseLightsPO> crossPhaseLightsPOList = crossPhaseLightsMapper.selectByCrossId(crossId);
SchemePhaseLightsVO schemePhaseLightsVO = new SchemePhaseLightsVO();
schemePhaseLightsVO.setCrossSchemeList(crossSchemePOList);
schemePhaseLightsVO.setCrossPhaseList(crossPhasePOList);
schemePhaseLightsVO.setCrossLightsList(crossLightsPOList);
schemePhaseLightsVO.setCrossPhaseLightsPOList(crossPhaseLightsPOList);
return schemePhaseLightsVO;
}
......
......@@ -24,5 +24,12 @@
where cross_id = #{crossId}
</delete>
<select id="selectByCrossId" resultType="net.wanji.utc.po.CrossPhaseLightsPO">
select
id,lights_id,phase_id,cross_id,gmt_create,gmt_modified
from t_cross_phase_lights
where crossId = #{crossId}
</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