| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- package com.welampiot.service.impl;
- import com.welampiot.dao.GlobalLocationDao;
- import com.welampiot.dto.GlobalLocationDTO;
- import com.welampiot.service.GlobalLocationService;
- import com.welampiot.vo.GlobalLocationVO;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Objects;
- /**
- * ClassName: GlobalLocationServiceImpl
- * Package: com.welampiot.service.impl
- * Description:
- *
- * @Author: zhj_Start
- * @Create: 2023/3/22 - 17:37
- * @Version: v1.0
- */
- @Service
- public class GlobalLocationServiceImpl implements GlobalLocationService {
- @Autowired
- private GlobalLocationDao globalLocationDao;
- @Override
- public List<GlobalLocationDTO> getAreaByLevel(Integer version,Integer level) {
- return globalLocationDao.getAreaByLevel(version,level);
- }
- @Override
- public List<GlobalLocationDTO> getAreaByLevelAndPid(Integer version,Integer level, Integer pid) {
- return globalLocationDao.getAreaByLevelAndPid(version,level,pid);
- }
- @Override
- public List<GlobalLocationDTO> getListByPid(Integer pid) {return globalLocationDao.getListByPid(pid);}
- @Override
- public List<GlobalLocationDTO> getListByPidList(List pids) {return globalLocationDao.getListByPidList(pids);}
- @Override
- public List<GlobalLocationDTO> getUserProvinceNav(GlobalLocationVO globalLocationVO) {
- List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
- List<GlobalLocationDTO> data = new ArrayList<>();
- List<Integer> idList = new ArrayList<>();
- for (GlobalLocationDTO g:userProvinceNav) {
- if (g.getLevel1() != null && g.getLevel1() == 2){
- g.setName(g.getName1());
- g.setName1(null);
- g.setId(g.getId1());
- g.setId1(null);
- }else if (g.getLevel2() != null && g.getLevel2() == 2){
- g.setName(g.getName2());
- g.setName2(null);
- g.setId(g.getId2());
- g.setId2(null);
- }else if (g.getLevel3() != null && g.getLevel3() == 2){
- g.setName(g.getName3());
- g.setName3(null);
- g.setId(g.getId3());
- g.setId3(null);
- }else if (g.getLevel1() != null && g.getLevel1() == 1){
- g.setName(g.getName1());
- g.setName1(null);
- g.setId(g.getId1());
- g.setId1(null);
- }
- if (g.getId() != null) {
- if (!idList.contains(g.getId())){
- data.add(g);
- idList.add(g.getId());
- }
- }
- }
- return data;
- }
- @Override
- public List<GlobalLocationDTO> getUserCityNav(GlobalLocationVO globalLocationVO) {
- List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
- List<GlobalLocationDTO> data = new ArrayList<>();
- List<Integer> idList = new ArrayList<>();
- List<Integer> idList1 = new ArrayList<>();
- for (GlobalLocationDTO g:userProvinceNav) {
- if (g.getLevel1() != null && g.getLevel1() == 3){
- g.setName(g.getName1());
- g.setName1(null);
- g.setId(g.getId1());
- g.setId1(null);
- if (!idList.contains(g.getId())){
- idList.add(g.getId());
- }
- }else if (g.getLevel2() != null && g.getLevel2() == 3){
- g.setName(g.getName2());
- g.setName2(null);
- g.setId(g.getId2());
- g.setId2(null);
- if (!idList1.contains(g.getId())){
- idList1.add(g.getId());
- }
- }else if (g.getLevel3() != null && g.getLevel3() == 3){
- g.setName(g.getName3());
- g.setName3(null);
- g.setId(g.getId3());
- g.setId3(null);
- }else{
- g.setName(g.getName1());
- g.setName1(null);
- g.setId(g.getId1());
- g.setId1(null);
- if (!idList.contains(g.getId())){
- idList.add(g.getId());
- }
- }
- }
- globalLocationVO.setIdList(idList);
- List<GlobalLocationDTO> areaLampPoleCountList = globalLocationDao.getAreaLampPoleCountList(globalLocationVO);
- List<GlobalLocationDTO> areaLampCountList = globalLocationDao.getAreaLampCountList(globalLocationVO);
- for (GlobalLocationDTO g : areaLampCountList) {
- for (GlobalLocationDTO g1 : areaLampPoleCountList) {
- if (Objects.equals(g.getId(), g1.getId())) {
- g.setLampPoleCount(g1.getLampPoleCount());
- data.add(g);
- break;
- }
- }
- }
- globalLocationVO.setIdList(idList1);
- List<GlobalLocationDTO> cityLampPoleCountList = globalLocationDao.getCityLampPoleCountList(globalLocationVO);
- List<GlobalLocationDTO> cityLampCountList = globalLocationDao.getCityLampCountList(globalLocationVO);
- for (GlobalLocationDTO g : cityLampCountList) {
- for (GlobalLocationDTO g1 : cityLampPoleCountList) {
- if (Objects.equals(g.getId(), g1.getId())) {
- g.setLampPoleCount(g1.getLampPoleCount());
- data.add(g);
- break;
- }
- }
- }
- return data;
- }
- @Override
- public List<GlobalLocationDTO> getUserAreaNav(GlobalLocationVO globalLocationVO) {
- List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
- List<GlobalLocationDTO> data = new ArrayList<>();
- List<Integer> idList = new ArrayList<>();
- for (GlobalLocationDTO g:userProvinceNav) {
- if (g.getLevel1() != null && g.getLevel1() == 4){
- g.setName(g.getName1());
- g.setName1(null);
- g.setId(g.getId1());
- g.setId1(null);
- }else if (g.getLevel2() != null && g.getLevel2() == 4){
- g.setName(g.getName2());
- g.setName2(null);
- g.setId(g.getId2());
- g.setId2(null);
- }else if (g.getLevel3() != null && g.getLevel3() == 4){
- g.setName(g.getName3());
- g.setName3(null);
- g.setId(g.getId3());
- g.setId3(null);
- }else{
- g.setName(g.getName1());
- g.setName1(null);
- g.setId(g.getId1());
- g.setId1(null);
- }
- if (g.getId() != null) {
- if (!idList.contains(g.getId())){
- // data.add(g);
- idList.add(g.getId());
- }
- }
- }
- globalLocationVO.setIdList(idList);
- List<GlobalLocationDTO> areaLampPoleCountList = globalLocationDao.getAreaLampPoleCountList(globalLocationVO);
- List<GlobalLocationDTO> areaLampCountList = globalLocationDao.getAreaLampCountList(globalLocationVO);
- for (GlobalLocationDTO g : areaLampCountList) {
- for (GlobalLocationDTO g1 : areaLampPoleCountList) {
- if (Objects.equals(g.getId(), g1.getId())) {
- g.setLampPoleCount(g1.getLampPoleCount());
- data.add(g);
- break;
- }
- }
- }
- return data;
- }
- @Override
- public GlobalLocationDTO getOneById(Integer id) {
- return globalLocationDao.getOneById(id);
- }
- @Override
- public GlobalLocationDTO getGlobalLocationDTOById(Integer id, Integer version) {
- return globalLocationDao.getGlobalLocationDTOById(id,version);
- }
- @Override
- public List<GlobalLocationDTO> getLocationListByPid(Integer pid, Integer version) {
- return globalLocationDao.getLocationListByPid(pid,version);
- }
- @Override
- public List<GlobalLocationDTO> getGlobalList(@Param("level") Integer level, @Param("version") Integer version) {
- return globalLocationDao.getGlobalList(level,version);
- }
- @Override
- public Integer getAreaTimezoneById(Integer id) {
- return globalLocationDao.getAreaTimezoneById(id);
- }
- @Override
- public List<GlobalLocationDTO> getAreaListByPid(Integer pid, Integer version) {
- return globalLocationDao.getAreaListByPid(pid,version);
- }
- @Override
- public List<GlobalLocationDTO> getCityListByPid(Integer pid, Integer version) {
- return globalLocationDao.getCityListByPid(pid,version);
- }
- @Override
- public List<GlobalLocationDTO> getOnlyOneLevelList(Integer level, Integer version) {
- return globalLocationDao.getOnlyOneLevelList(level,version);
- }
- @Override
- public List<GlobalLocationDTO> getCountryOfSectionList(Integer level, Integer version) {
- return globalLocationDao.getCountryOfSectionList(level,version);
- }
- @Override
- public GlobalLocationDTO getDataByDto(GlobalLocationDTO dto){
- return globalLocationDao.getDataByDto(dto);
- }
- @Override
- public List<GlobalLocationDTO> getAreaList(GlobalLocationDTO dto){
- return globalLocationDao.getAreaList(dto);
- }
- }
|