Commit bdcab911 authored by hanbing's avatar hanbing

方案管理-渠化配置,测试删除进口方向

parent 1a85c2f5
......@@ -4,6 +4,8 @@ import net.wanji.web.po.scheme.CrossDirInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/12/20 10:32
......@@ -17,4 +19,6 @@ public interface CrossDirInfoMapper {
void updateIsPedestrian(@Param("isPersonCross") Integer isPersonCross, @Param("id") String id);
CrossDirInfoPO selectByCrossIdAndDirType(@Param("crossId") String crossId, @Param("dirType") Integer dirType);
List<CrossDirInfoPO> selectByCrossId(String crossId);
}
......@@ -267,8 +267,18 @@ public class CrossConfigServiceImpl implements CrossConfigService {
private void handleLaneData(SaveLaneInfoDTO saveLaneInfoDTO) {
String crossId = saveLaneInfoDTO.getCrossId();
List<DirListElement> dirList = saveLaneInfoDTO.getDirList();
List<CrossDirInfoPO> crossDirInfoPOList = crossDirInfoMapper.selectByCrossId(crossId);
List<Integer> dirListFromDb= crossDirInfoPOList.stream()
.map(CrossDirInfoPO::getDirType)
.collect(Collectors.toList());
// 删除数据库中有,前端对象中没有的数据
for (Integer dirFromDb : dirListFromDb) {
if (!dirList.contains(dirFromDb)) {
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectByCrossIdAndDir(crossId, dirFromDb);
cleanDataBase(crossId, dirFromDb, laneInfoPOList);
}
}
for (DirListElement dirListElement : dirList) {
// 获取数据库中已有数据
Integer dir = dirListElement.getDir();
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectByCrossIdAndDir(crossId, dir);
// 按车道代码排序
......@@ -278,17 +288,7 @@ public class CrossConfigServiceImpl implements CrossConfigService {
laneListFromDb.sort((x,y) -> String.CASE_INSENSITIVE_ORDER.compare(x.getName(), y.getName()));
// 比较入参数据与已有数据
if (!laneListFromClient.equals(laneListFromDb)) {
// 删除车道表数据
laneInfoMapper.deleteByCrossIdAndDir(crossId, dir);
// 删除路口方向表数据
crossDirInfoMapper.deleteInByDirType(crossId, dir);
List<String> laneIds = getLaneIds(laneInfoPOList);
if (laneIds.size()!=0){
// 删除灯组-车道关系表数据
crossLaneLightsMapper.deleteByLaneIds(laneIds);
// 删除车道状态表数据
laneSegmentMapper.deleteByLaneIds(laneIds);
}
cleanDataBase(crossId, dir, laneInfoPOList);
// 插入进口信息
List<LaneInfoPO> laneInfoPOListForInsert = getLaneInfoPOListForInsert(
crossId, dirListElement, dir, laneListFromClient);
......@@ -305,6 +305,20 @@ public class CrossConfigServiceImpl implements CrossConfigService {
}
}
private void cleanDataBase(String crossId, Integer dir, List<LaneInfoPO> laneInfoPOList) {
// 删除车道表数据
laneInfoMapper.deleteByCrossIdAndDir(crossId, dir);
// 删除路口方向表数据
crossDirInfoMapper.deleteInByDirType(crossId, dir);
List<String> laneIds = getLaneIds(laneInfoPOList);
if (laneIds.size()!=0){
// 删除灯组-车道关系表数据
crossLaneLightsMapper.deleteByLaneIds(laneIds);
// 删除车道状态表数据
laneSegmentMapper.deleteByLaneIds(laneIds);
}
}
@Override
public SaveLaneInfoDTO listLaneInfo(CrossIdDTO crossIdDTO) {
String crossId = crossIdDTO.getCrossId();
......
......@@ -36,4 +36,11 @@
from t_base_cross_dir_info
where cross_id = #{crossId} and dir_type = #{dirType}
</select>
<select id="selectByCrossId" resultType="net.wanji.web.po.scheme.CrossDirInfoPO">
select
id,dir_type,in_out_type,cross_id,length,is_pedestrian,gmt_create,gmt_modified
from t_base_cross_dir_info
where cross_id = #{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