Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
18bfb5c66e
3 changed files with 24 additions and 11 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
  3. +0
    -3
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/StructureMapper.xml

+ 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);

+ 0
- 3
tuoheng-service/tuoheng-admin/src/main/resources/mapper/StructureMapper.xml View File

left JOIN th_section se ON sr.section_id=se.id left JOIN th_section se ON sr.section_id=se.id
left JOIN th_road rd ON sr.road_id=rd.id left JOIN th_road rd ON sr.road_id=rd.id
where sr.mark=1 and se.mark=1 and rd.mark=1 where sr.mark=1 and se.mark=1 and rd.mark=1
<if test="request.tenantId !=null abd request.tenantId !=''">
AND sr.tenant_id = #{request.tenantId}
</if>
<if test="request.structureName !=null and request.structureName !=''"> <if test="request.structureName !=null and request.structureName !=''">
AND sr.`structure_name` like concat('%',#{request.structureName},'%') AND sr.`structure_name` like concat('%',#{request.structureName},'%')
</if> </if>

Loading…
Cancel
Save