| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return R.ok(); |
| | | } |
| | | //列表 |
| | | @ApiOperation(value = "查询",tags = {"后台-评审委员会管理","web-评审委员会"}) |
| | | @ApiOperation(value = "查询",tags = {"后台-评审委员会管理"}) |
| | | @PostMapping("/list") |
| | | public R<Page<TCommittee>> list(@RequestBody CommitteeQuery informationQuery){ |
| | | Page<TCommittee> page = tCommitteeService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName()) |
| | | .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeLevel, informationQuery.getCommitteeUnit()) |
| | | .eq(informationQuery.getRegionId() != null, TCommittee::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel()) |
| | | .orderByDesc(TCommittee::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | Page<TCommittee> page; |
| | | if(StringUtils.isEmpty(informationQuery.getProvinceName())){ |
| | | if(informationQuery.getSortType() == 1){ |
| | | page = tCommitteeService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName()) |
| | | .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeUnit, informationQuery.getCommitteeUnit()) |
| | | .eq(informationQuery.getRegionId() != null, TCommittee::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel()) |
| | | .orderByDesc(TCommittee::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | }else { |
| | | page = tCommitteeService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName()) |
| | | .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeUnit, informationQuery.getCommitteeUnit()) |
| | | .eq(informationQuery.getRegionId() != null, TCommittee::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel()) |
| | | .orderByDesc(TCommittee::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | } |
| | | }else { |
| | | List<TRegion> list; |
| | | // 查询省份下的市 |
| | | if(informationQuery.getProvinceName().equals("直辖市")){ |
| | | List<String> cityList = new ArrayList<>(); |
| | | cityList.add("北京市"); |
| | | cityList.add("天津市"); |
| | | cityList.add("重庆市"); |
| | | cityList.add("上海市"); |
| | | list = regionService.lambdaQuery().in(TRegion::getProvinceName, cityList).list(); |
| | | }else { |
| | | list = regionService.lambdaQuery().eq(TRegion::getProvinceName, informationQuery.getProvinceName()).list(); |
| | | } |
| | | List<Integer> ids = list.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | if(informationQuery.getSortType() == 1){ |
| | | page = tCommitteeService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName()) |
| | | .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeUnit, informationQuery.getCommitteeUnit()) |
| | | .in( TCommittee::getRegionId, ids) |
| | | .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel()) |
| | | .orderByDesc(TCommittee::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | }else { |
| | | page = tCommitteeService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName()) |
| | | .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeUnit, informationQuery.getCommitteeUnit()) |
| | | .in( TCommittee::getRegionId, ids) |
| | | .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel()) |
| | | .orderByDesc(TCommittee::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | } |
| | | } |
| | | List<TCommittee> records = page.getRecords(); |
| | | List<Integer> regionIds = records.stream().map(TCommittee::getRegionId).collect(Collectors.toList()); |
| | | List<TRegion> regions = regionService.lambdaQuery().in(TRegion::getId, regionIds).list(); |
| | | |
| | | for (TCommittee record : page.getRecords()) { |
| | | TRegion byId = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(byId.getProvinceName()+"-"+byId.getName()); |
| | | TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId() ); |
| | | TTitleMajor byId2 = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()); |
| | | List<Long> technicalIds = records.stream().map(TCommittee::getTechnicalId).collect(Collectors.toList()); |
| | | List<TTechnicalTitle> tTechnicalTitles = tTechnicalTitleService.lambdaQuery().in(TTechnicalTitle::getId, technicalIds).list(); |
| | | |
| | | List<Long> majorIds = records.stream().map(TCommittee::getMajorId).collect(Collectors.toList()); |
| | | List<TTitleMajor> tTitleMajors = majorService.lambdaQuery().in(TTitleMajor::getId, majorIds).list(); |
| | | |
| | | List<TCommitteeTechnical> tCommitteeTechnicals = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getCommitteeId, record.getId()).list(); |
| | | List<TCommitteeMajor> tCommitteeMajors =tCommitteeMajorService.lambdaQuery().eq(TCommitteeMajor::getCommitteeId, record.getId()).list(); |
| | | List<Long> ids = records.stream().map(TCommittee::getId).collect(Collectors.toList()); |
| | | List<TCommitteeTechnical> committeeTechnicals = committeeTechnicalService.lambdaQuery().in(TCommitteeTechnical::getCommitteeId, ids).list(); |
| | | List<TCommitteeMajor> committeeMajors = tCommitteeMajorService.lambdaQuery().in(TCommitteeMajor::getCommitteeId, ids).list(); |
| | | |
| | | for (TCommittee record : records) { |
| | | TRegion region = regions.stream().filter(e -> e.getId().equals(record.getRegionId())).findFirst().orElse(null); |
| | | record.setRegionName(region.getProvinceName()+"-"+region.getName()); |
| | | TTechnicalTitle tTechnicalTitle = tTechnicalTitles.stream().filter(e -> e.getId().equals(record.getTechnicalId())).findFirst().orElse(null); |
| | | TTitleMajor tTitleMajor = tTitleMajors.stream().filter(e -> e.getId().equals(record.getMajorId())).findFirst().orElse(null); |
| | | record.setTechnicalName(tTechnicalTitle.getTitileName()+"-"+tTitleMajor.getMajorName()); |
| | | List<TCommitteeTechnical> tCommitteeTechnicals = committeeTechnicals.stream().filter(e -> e.getCommitteeId().equals(record.getId())).collect(Collectors.toList()); |
| | | List<TCommitteeMajor> tCommitteeMajors = committeeMajors.stream().filter(e -> e.getCommitteeId().equals(record.getId())).collect(Collectors.toList()); |
| | | record.setTCommitteeTechnicals(tCommitteeTechnicals); |
| | | record.setTCommitteeMajors(tCommitteeMajors); |
| | | } |