Commit 6bd1296f authored by duanruiming's avatar duanruiming

[update] 优化关联id关联关系

parent 9ee0946b
...@@ -65,6 +65,14 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -65,6 +65,14 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
List<CrossPhasePO> crossPhaseList = content.getCrossPhaseList(); List<CrossPhasePO> crossPhaseList = content.getCrossPhaseList();
crossPhaseMapper.deleteBatch(crossId, null); crossPhaseMapper.deleteBatch(crossId, null);
crossPhaseList.forEach(crossPhasePO -> { crossPhaseList.forEach(crossPhasePO -> {
BaseCrossSchemePO baseCrossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, crossPhasePO.getPlanId());
Integer id;
if (Objects.isNull(baseCrossSchemePO)) {
id = -1;
} else {
id = baseCrossSchemePO.getId();
}
crossPhasePO.setPlanId(id);
crossPhaseMapper.insertOne(crossPhasePO); crossPhaseMapper.insertOne(crossPhasePO);
}); });
...@@ -78,6 +86,20 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -78,6 +86,20 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
List<CrossPhaseLightsPO> crossPhaseLightsPOList = content.getCrossPhaseLightsPOList(); List<CrossPhaseLightsPO> crossPhaseLightsPOList = content.getCrossPhaseLightsPOList();
if (!CollectionUtils.isEmpty(crossPhaseLightsPOList)) { if (!CollectionUtils.isEmpty(crossPhaseLightsPOList)) {
crossPhaseLightsMapper.deleteByCrossId(crossPhaseLightsPOList.get(0).getCrossId()); crossPhaseLightsMapper.deleteByCrossId(crossPhaseLightsPOList.get(0).getCrossId());
for (CrossPhaseLightsPO crossPhaseLightsPO : crossPhaseLightsPOList) {
String currentCrossId = crossPhaseLightsPO.getCrossId();
Integer lightsId = crossPhaseLightsPO.getLightsId();
Integer phaseId = crossPhaseLightsPO.getPhaseId();
List<Integer> list = crossPhaseMapper.selectIdsByPhaseNo(currentCrossId, phaseId);
if (!CollectionUtils.isEmpty(list)) {
crossPhaseLightsPO.setPhaseId(list.get(0));
}
CrossLightsPO crossLightsPO = new CrossLightsPO();
crossLightsPO.setCrossId(currentCrossId);
crossLightsPO.setLightsNo(String.valueOf(lightsId));
CrossLightsPO result = crossLightsMapper.selectEntity(crossLightsPO);
crossPhaseLightsPO.setLightsId(result.getId());
}
crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOList); crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOList);
} }
} }
...@@ -105,6 +127,10 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -105,6 +127,10 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
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());
crossSectionPO.setPlanId(id);
BaseCrossSchemePO baseCrossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, crossSectionPO.getSchemeId());
crossSectionPO.setSchemeId(baseCrossSchemePO.getId());
crossSectionMapper.insertOne(crossSectionPO); crossSectionMapper.insertOne(crossSectionPO);
}); });
} }
...@@ -125,8 +151,13 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -125,8 +151,13 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
List<CrossSchedulesPO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {}); List<CrossSchedulesPO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {});
if (Objects.nonNull(content)) { if (Objects.nonNull(content)) {
crossSchedulesMapper.deleteByCrossId(crossId);
if (!CollectionUtils.isEmpty(content)) { if (!CollectionUtils.isEmpty(content)) {
crossSchedulesMapper.deleteByCrossId(crossId); for (CrossSchedulesPO crossSchedulesPO : content) {
Integer planId = crossSchedulesPO.getPlanId();
Integer id = crossPlanMapper.selectIdByNo(crossId, planId);
crossSchedulesPO.setPlanId(id);
}
crossSchedulesMapper.insertBatch(content); crossSchedulesMapper.insertBatch(content);
} }
} }
......
...@@ -18,4 +18,6 @@ public interface CrossLightsMapper { ...@@ -18,4 +18,6 @@ public interface CrossLightsMapper {
List<CrossLightsPO> selectByCrossId(@Param("crossId") String crossId); List<CrossLightsPO> selectByCrossId(@Param("crossId") String crossId);
void deleteByCrossId(String crossId); void deleteByCrossId(String crossId);
CrossLightsPO selectEntity(@Param("entity") CrossLightsPO entity);
} }
...@@ -22,6 +22,4 @@ public interface CrossPlanMapper { ...@@ -22,6 +22,4 @@ public interface CrossPlanMapper {
List<CrossPlanPO> selectByCrossIdAndPlanNo(@Param("crossId") String crossId, @Param("planNo")Integer planNo); List<CrossPlanPO> selectByCrossIdAndPlanNo(@Param("crossId") String crossId, @Param("planNo")Integer planNo);
CrossPlanPO selectById(@Param("planId")Integer planId);
} }
...@@ -36,5 +36,12 @@ ...@@ -36,5 +36,12 @@
where cross_id = #{crossId} where cross_id = #{crossId}
</select> </select>
<select id="selectEntity" resultType="net.wanji.databus.dao.entity.CrossLightsPO" parameterType="net.wanji.databus.dao.entity.CrossLightsPO">
select
id,lights_no,name,type,dir,turn,cross_id,in_out_type,gmt_create,gmt_modified
from t_cross_lights
where cross_id = #{entity.crossId} and lights_no = #{entity.lightsNo}
</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