Commit 4f471a35 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 79b13ba4 e9cb7517
......@@ -44,9 +44,7 @@ public class CrossConfigController {
})
public JsonViewObject saveLaneInfo(@RequestBody SaveLaneInfoDTO saveLaneInfoDTO) {
crossConfigService.saveLaneInfo(saveLaneInfoDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success();
return JsonViewObject.newInstance().success();
}
@AspectLog(description = "渠化配置/灯组设置、车道配置列表", operationType = BaseEnum.OperationTypeEnum.UPDATE)
......@@ -59,8 +57,6 @@ public class CrossConfigController {
})
public JsonViewObject listLaneInfo(@RequestBody @Valid CrossIdDTO crossIdDTO) {
SaveLaneInfoDTO saveLaneInfoDTO = crossConfigService.listLaneInfo(crossIdDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(saveLaneInfoDTO);
return JsonViewObject.newInstance().success(saveLaneInfoDTO);
}
}
......@@ -90,8 +90,6 @@ public class SchemeConfigController {
})
public JsonViewObject listSchemeConfig(@RequestBody CrossIdDTO crossIdDTO) {
SaveSchemeConfigDTO saveSchemeConfigDTO = schemeConfigService.listSchemeConfig(crossIdDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(saveSchemeConfigDTO);
return JsonViewObject.newInstance().success(saveSchemeConfigDTO);
}
}
......@@ -274,11 +274,8 @@ public class CrossConfigServiceImpl implements CrossConfigService {
for (DirListElement dirListElement : dirList) {
Integer dir = dirListElement.getDir();
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectByCrossIdAndDir(crossId, dir);
// 按车道代码排序
List<LaneListElement> laneListFromClient = dirListElement.getLaneList();
laneListFromClient.sort((x,y) -> String.CASE_INSENSITIVE_ORDER.compare(x.getName(), y.getName()));
List<LaneListElement> laneListFromDb = buildLaneListFromDb(laneInfoPOList);
laneListFromDb.sort((x,y) -> String.CASE_INSENSITIVE_ORDER.compare(x.getName(), y.getName()));
// 比较入参数据与已有数据
if (!laneListFromClient.equals(laneListFromDb) || CollectionUtil.isEmpty(laneListFromClient)) {
cleanDataBase(crossId, dir, laneInfoPOList);
......@@ -406,10 +403,13 @@ public class CrossConfigServiceImpl implements CrossConfigService {
CrossDirInfoPO crossDirInfoPO = crossDirInfoMapper.selectByCrossIdAndDirType(crossId, key);
Integer isPedestrian = crossDirInfoPO.getIsPedestrian();
dirListElement.setIsPersonCross(isPedestrian);
// 构造内层List
// 构造laneList
List<LaneInfoPO> value = entry.getValue();
List<LaneInfoPO> sortedValue = value.stream().
sorted(Comparator.comparing(LaneInfoPO::getSort)).
collect(Collectors.toList());
List<LaneListElement> laneListElementList = new ArrayList<>();
for (LaneInfoPO laneInfoPO : value) {
for (LaneInfoPO laneInfoPO : sortedValue) {
LaneListElement laneListElement = new LaneListElement();
String laneId = laneInfoPO.getId();
laneListElement.setId(laneId);
......@@ -480,13 +480,12 @@ public class CrossConfigServiceImpl implements CrossConfigService {
private List<LaneInfoPO> getLaneInfoPOListForInsert(
String crossId, Integer dir, List<LaneListElement> laneListFromClient) {
List<LaneInfoPO> laneInfoPOListForInsert = new ArrayList<>();
for (LaneListElement laneListElement : laneListFromClient) {
for (int i = 0; i < laneListFromClient.size(); i++) {
LaneListElement laneListElement = laneListFromClient.get(i);
LaneInfoPO laneInfoPO = new LaneInfoPO();
// 序号
String name = laneListElement.getName(); // 01
String substring = name.substring(name.length() - 1);// 1
String s = 1 + substring;
int sort = Integer.parseInt(s);
String sortStr = "1" + (i + 1);
int sort = Integer.parseInt(sortStr);
// 上一个路口ID
String preId = laneInfoMapper.selectPreId(crossId, dir);
if (ObjectUtil.isEmpty(preId)) {
......@@ -494,7 +493,7 @@ public class CrossConfigServiceImpl implements CrossConfigService {
}
// 0 主路;900 进口道渠化序号。信控车道类型都是进口车道
laneInfoPO.setId(preId + crossId + 0 + 900 + sort);
laneInfoPO.setCode(name);
laneInfoPO.setCode(laneListElement.getName());
laneInfoPO.setSort(sort);
laneInfoPO.setDir(dir);
Integer direction = laneListElement.getDirection();
......@@ -502,6 +501,9 @@ public class CrossConfigServiceImpl implements CrossConfigService {
laneInfoPO.setCategory(laneListElement.getLaneType());
laneInfoPO.setCrossId(crossId);
laneInfoPOListForInsert.add(laneInfoPO);
}
for (LaneListElement laneListElement : laneListFromClient) {
}
return laneInfoPOListForInsert;
}
......@@ -517,7 +519,10 @@ public class CrossConfigServiceImpl implements CrossConfigService {
private List<LaneListElement> buildLaneListFromDb(List<LaneInfoPO> laneInfoPOList) {
List<LaneListElement> laneListElements = new ArrayList<>();
for (LaneInfoPO laneInfoPO : laneInfoPOList) {
List<LaneInfoPO> collect = laneInfoPOList.stream()
.sorted(Comparator.comparing(LaneInfoPO::getSort))
.collect(Collectors.toList());
for (LaneInfoPO laneInfoPO : collect) {
LaneListElement laneListElement = new LaneListElement();
Integer turn = laneInfoPO.getTurn();
laneListElement.setDirection(turn);
......
......@@ -37,7 +37,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
/**
......@@ -117,7 +116,6 @@ public class SchemeConfigServiceImpl implements SchemeConfigService {
// 构造方案列表
List<SaveSchemeConfigDTO.PhaseScheme> phaseSchemeList = buildPhaseSchemeList(crossId);
saveSchemeConfigDTO.setPhaseSchemeList(phaseSchemeList);
// todo 暂时只有环式
saveSchemeConfigDTO.setTimeType(2);
return saveSchemeConfigDTO;
......@@ -365,7 +363,7 @@ public class SchemeConfigServiceImpl implements SchemeConfigService {
}
}
// 构造车道列表
List<SaveSchemeConfigDTO.LaneListElement> laneList = buildLaneList(crossId, dir, phaseId);
List<SaveSchemeConfigDTO.LaneListElement> laneList = buildLaneList(dir, phaseId);
dirListElement.setLaneList(laneList);
dirList.add(dirListElement);
......@@ -378,12 +376,11 @@ public class SchemeConfigServiceImpl implements SchemeConfigService {
*
* @author Kent HAN
* @date 2023/1/12 15:02
* @param crossId
* @param dir
* @param phaseId
* @return java.util.List<net.wanji.web.dto.SaveSchemeConfigDTO.LaneListElement>
*/
private List<SaveSchemeConfigDTO.LaneListElement> buildLaneList(String crossId, Integer dir, Integer phaseId) {
private List<SaveSchemeConfigDTO.LaneListElement> buildLaneList(Integer dir, Integer phaseId) {
List<SaveSchemeConfigDTO.LaneListElement> laneList = new ArrayList<>();
List<CrossPhaseLightsPO> crossPhaseLightsPOList = crossPhaseLightsMapper.selectByPhaseId(phaseId);
List<Integer> lightsIds = crossPhaseLightsPOList.stream()
......@@ -400,15 +397,14 @@ public class SchemeConfigServiceImpl implements SchemeConfigService {
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(laneIds)) {
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectByLaneIds(laneIds);
// 根据转向去重
TreeSet<LaneInfoPO> laneInfoPOTreeSet = laneInfoPOList.stream()
.collect(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(LaneInfoPO::getTurn))));
for (LaneInfoPO laneInfoPO : laneInfoPOTreeSet) {
// 根据sort排序
List<LaneInfoPO> collect = laneInfoPOList.stream()
.sorted(Comparator.comparing(LaneInfoPO::getSort))
.collect(Collectors.toList());
for (LaneInfoPO laneInfoPO : collect) {
SaveSchemeConfigDTO.LaneListElement laneListElement = new SaveSchemeConfigDTO.LaneListElement();
laneListElement.setDirection(laneInfoPO.getTurn());
laneListElement.setLaneType(laneInfoPO.getCategory());
laneList.add(laneListElement);
}
}
......@@ -676,7 +672,7 @@ public class SchemeConfigServiceImpl implements SchemeConfigService {
private void updateCrossScheme(SaveSchemeConfigDTO saveSchemeConfigDTO) {
String crossId = saveSchemeConfigDTO.getCrossId();
List<SaveSchemeConfigDTO.PhaseScheme> phaseSchemeList = saveSchemeConfigDTO.getPhaseSchemeList();
// 删除数据里有,但是DTO里没有的方案ID对应的记录
// 删除数据里有,但是DTO里没有的方案ID对应的记录
Set<Integer> existedIds = crossSchemeMapper.selectIdsByCrossId(crossId);
if (CollectionUtil.isNotEmpty(existedIds)) {
Set<Integer> dtoIds = phaseSchemeList.stream()
......
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