Commit 4f471a35 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

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