Selaa lähdekoodia

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

tags/v1.0.0^2
wanjing 1 vuosi sitten
vanhempi
commit
d9a9d5bbde
2 muutettua tiedostoa jossa 24 lisäystä ja 8 poistoa
  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 Näytä tiedosto

@@ -160,13 +160,11 @@ public class AddDeptService {
private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) {
List<RoadInformation> roadInformationList = new ArrayList<>();
List<Section> sectionList = new ArrayList<>();

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

roadInformationList.add(road);
sectionList.addAll(sectionListTmp);
}
@@ -198,6 +196,14 @@ public class AddDeptService {
List<RoadDept> list = new ArrayList<>();
RoadDept roadDept;
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.setTenantId(tenantId);
roadDept.setDeptId(deptId);
@@ -231,6 +237,15 @@ public class AddDeptService {
List<SectionDept> list = new ArrayList<>();
SectionDept sectionDept;
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.setTenantId(tenantId);
sectionDept.setDeptId(deptId);

+ 7
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryDeptInfoService.java Näytä tiedosto

@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
@@ -167,14 +168,14 @@ public class QueryDeptInfoService {
List<RoadSectionDto> roadSectionDtoList = new ArrayList<>();
RoadSectionDto roadSectionDto;
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();
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.setSectionList(sectionListTmp);
roadSectionDtoList.add(roadSectionDto);

Loading…
Peruuta
Tallenna