Browse Source

1、修改展示部门公路路段代码;2、成功添加部门代码,增加部门与公路,部门与路段重复判断;

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
d9a9d5bbde
2 changed files with 24 additions and 8 deletions
  1. +17
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java
  2. +7
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryDeptInfoService.java

+ 17
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java View File

private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) { private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) {
List<RoadInformation> roadInformationList = new ArrayList<>(); List<RoadInformation> roadInformationList = new ArrayList<>();
List<Section> sectionList = new ArrayList<>(); List<Section> sectionList = new ArrayList<>();

RoadInformation road; RoadInformation road;
List<Section> sectionListTmp; List<Section> sectionListTmp;
for (RoadSectionDto roadSectionDto : roadSectionDtoList) { for (RoadSectionDto roadSectionDto : roadSectionDtoList) {
road = roadSectionDto.getRoad(); road = roadSectionDto.getRoad();
sectionListTmp = roadSectionDto.getSectionList(); sectionListTmp = roadSectionDto.getSectionList();

roadInformationList.add(road); roadInformationList.add(road);
sectionList.addAll(sectionListTmp); sectionList.addAll(sectionListTmp);
} }
List<RoadDept> list = new ArrayList<>(); List<RoadDept> list = new ArrayList<>();
RoadDept roadDept; RoadDept roadDept;
for (RoadInformation roadInformation : roadInformationList) { for (RoadInformation roadInformation : roadInformationList) {
Integer count = roadDeptMapper.selectCount(new LambdaQueryWrapper<RoadDept>()
.eq(RoadDept::getTenantId, tenantId)
.eq(RoadDept::getDeptId, deptId)
.eq(RoadDept::getRoadId, roadInformation.getId()));
if (count > 0) {
// 已经存在,不用在添加,防止出现冗余数据
continue;
}
roadDept = new RoadDept(); roadDept = new RoadDept();
roadDept.setTenantId(tenantId); roadDept.setTenantId(tenantId);
roadDept.setDeptId(deptId); roadDept.setDeptId(deptId);
List<SectionDept> list = new ArrayList<>(); List<SectionDept> list = new ArrayList<>();
SectionDept sectionDept; SectionDept sectionDept;
for (Section section : sectionList) { for (Section section : sectionList) {
Integer count = sectionDeptMapper.selectCount(new LambdaQueryWrapper<SectionDept>()
.eq(SectionDept::getTenantId, tenantId)
.eq(SectionDept::getDeptId, deptId)
.eq(SectionDept::getSectionId, section.getId()));
if (count > 0) {
// 已经存在,不用在添加,防止出现冗余数据
continue;
}

sectionDept = new SectionDept(); sectionDept = new SectionDept();
sectionDept.setTenantId(tenantId); sectionDept.setTenantId(tenantId);
sectionDept.setDeptId(deptId); sectionDept.setDeptId(deptId);

+ 7
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryDeptInfoService.java View File

import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;


/** /**
List<RoadSectionDto> roadSectionDtoList = new ArrayList<>(); List<RoadSectionDto> roadSectionDtoList = new ArrayList<>();
RoadSectionDto roadSectionDto; RoadSectionDto roadSectionDto;
List<Section> sectionListTmp; List<Section> sectionListTmp;
for (RoadInformation roadInformation : roadInformationList) {

Map<String, RoadInformation> roadInformationMap = roadInformationList.stream().collect(Collectors.toMap(RoadInformation::getId, Function.identity()));
RoadInformation roadInformation;
for (Section section : sectionList) {
roadSectionDto = new RoadSectionDto(); roadSectionDto = new RoadSectionDto();
sectionListTmp = new ArrayList<>(); sectionListTmp = new ArrayList<>();
for (Section section : sectionList) {
if (section.getRoadId().equals(roadInformation.getId())) {
sectionListTmp.add(section);
}
}
sectionListTmp.add(section);
roadInformation = roadInformationMap.get(section.getRoadId());
roadSectionDto.setRoad(roadInformation); roadSectionDto.setRoad(roadInformation);
roadSectionDto.setSectionList(sectionListTmp); roadSectionDto.setSectionList(sectionListTmp);
roadSectionDtoList.add(roadSectionDto); roadSectionDtoList.add(roadSectionDto);

Loading…
Cancel
Save