GlobalLocationServiceImpl.java 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. package com.welampiot.service.impl;
  2. import com.welampiot.dao.GlobalLocationDao;
  3. import com.welampiot.dto.GlobalLocationDTO;
  4. import com.welampiot.service.GlobalLocationService;
  5. import com.welampiot.vo.GlobalLocationVO;
  6. import org.apache.ibatis.annotations.Param;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. import java.util.Objects;
  12. /**
  13. * ClassName: GlobalLocationServiceImpl
  14. * Package: com.welampiot.service.impl
  15. * Description:
  16. *
  17. * @Author: zhj_Start
  18. * @Create: 2023/3/22 - 17:37
  19. * @Version: v1.0
  20. */
  21. @Service
  22. public class GlobalLocationServiceImpl implements GlobalLocationService {
  23. @Autowired
  24. private GlobalLocationDao globalLocationDao;
  25. @Override
  26. public List<GlobalLocationDTO> getAreaByLevel(Integer version,Integer level) {
  27. return globalLocationDao.getAreaByLevel(version,level);
  28. }
  29. @Override
  30. public List<GlobalLocationDTO> getAreaByLevelAndPid(Integer version,Integer level, Integer pid) {
  31. return globalLocationDao.getAreaByLevelAndPid(version,level,pid);
  32. }
  33. @Override
  34. public List<GlobalLocationDTO> getListByPid(Integer pid) {return globalLocationDao.getListByPid(pid);}
  35. @Override
  36. public List<GlobalLocationDTO> getListByPidList(List pids) {return globalLocationDao.getListByPidList(pids);}
  37. @Override
  38. public List<GlobalLocationDTO> getUserProvinceNav(GlobalLocationVO globalLocationVO) {
  39. List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
  40. List<GlobalLocationDTO> data = new ArrayList<>();
  41. List<Integer> idList = new ArrayList<>();
  42. for (GlobalLocationDTO g:userProvinceNav) {
  43. if (g.getLevel1() != null && g.getLevel1() == 2){
  44. g.setName(g.getName1());
  45. g.setName1(null);
  46. g.setId(g.getId1());
  47. g.setId1(null);
  48. }else if (g.getLevel2() != null && g.getLevel2() == 2){
  49. g.setName(g.getName2());
  50. g.setName2(null);
  51. g.setId(g.getId2());
  52. g.setId2(null);
  53. }else if (g.getLevel3() != null && g.getLevel3() == 2){
  54. g.setName(g.getName3());
  55. g.setName3(null);
  56. g.setId(g.getId3());
  57. g.setId3(null);
  58. }else if (g.getLevel1() != null && g.getLevel1() == 1){
  59. g.setName(g.getName1());
  60. g.setName1(null);
  61. g.setId(g.getId1());
  62. g.setId1(null);
  63. }
  64. if (g.getId() != null) {
  65. if (!idList.contains(g.getId())){
  66. data.add(g);
  67. idList.add(g.getId());
  68. }
  69. }
  70. }
  71. return data;
  72. }
  73. @Override
  74. public List<GlobalLocationDTO> getUserCityNav(GlobalLocationVO globalLocationVO) {
  75. List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
  76. List<GlobalLocationDTO> data = new ArrayList<>();
  77. List<Integer> idList = new ArrayList<>();
  78. List<Integer> idList1 = new ArrayList<>();
  79. for (GlobalLocationDTO g:userProvinceNav) {
  80. if (g.getLevel1() != null && g.getLevel1() == 3){
  81. g.setName(g.getName1());
  82. g.setName1(null);
  83. g.setId(g.getId1());
  84. g.setId1(null);
  85. if (!idList.contains(g.getId())){
  86. idList.add(g.getId());
  87. }
  88. }else if (g.getLevel2() != null && g.getLevel2() == 3){
  89. g.setName(g.getName2());
  90. g.setName2(null);
  91. g.setId(g.getId2());
  92. g.setId2(null);
  93. if (!idList1.contains(g.getId())){
  94. idList1.add(g.getId());
  95. }
  96. }else if (g.getLevel3() != null && g.getLevel3() == 3){
  97. g.setName(g.getName3());
  98. g.setName3(null);
  99. g.setId(g.getId3());
  100. g.setId3(null);
  101. }else{
  102. g.setName(g.getName1());
  103. g.setName1(null);
  104. g.setId(g.getId1());
  105. g.setId1(null);
  106. if (!idList.contains(g.getId())){
  107. idList.add(g.getId());
  108. }
  109. }
  110. }
  111. globalLocationVO.setIdList(idList);
  112. List<GlobalLocationDTO> areaLampPoleCountList = globalLocationDao.getAreaLampPoleCountList(globalLocationVO);
  113. List<GlobalLocationDTO> areaLampCountList = globalLocationDao.getAreaLampCountList(globalLocationVO);
  114. for (GlobalLocationDTO g : areaLampCountList) {
  115. for (GlobalLocationDTO g1 : areaLampPoleCountList) {
  116. if (Objects.equals(g.getId(), g1.getId())) {
  117. g.setLampPoleCount(g1.getLampPoleCount());
  118. data.add(g);
  119. break;
  120. }
  121. }
  122. }
  123. globalLocationVO.setIdList(idList1);
  124. List<GlobalLocationDTO> cityLampPoleCountList = globalLocationDao.getCityLampPoleCountList(globalLocationVO);
  125. List<GlobalLocationDTO> cityLampCountList = globalLocationDao.getCityLampCountList(globalLocationVO);
  126. for (GlobalLocationDTO g : cityLampCountList) {
  127. for (GlobalLocationDTO g1 : cityLampPoleCountList) {
  128. if (Objects.equals(g.getId(), g1.getId())) {
  129. g.setLampPoleCount(g1.getLampPoleCount());
  130. data.add(g);
  131. break;
  132. }
  133. }
  134. }
  135. return data;
  136. }
  137. @Override
  138. public List<GlobalLocationDTO> getUserAreaNav(GlobalLocationVO globalLocationVO) {
  139. List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
  140. List<GlobalLocationDTO> data = new ArrayList<>();
  141. List<Integer> idList = new ArrayList<>();
  142. for (GlobalLocationDTO g:userProvinceNav) {
  143. if (g.getLevel1() != null && g.getLevel1() == 4){
  144. g.setName(g.getName1());
  145. g.setName1(null);
  146. g.setId(g.getId1());
  147. g.setId1(null);
  148. }else if (g.getLevel2() != null && g.getLevel2() == 4){
  149. g.setName(g.getName2());
  150. g.setName2(null);
  151. g.setId(g.getId2());
  152. g.setId2(null);
  153. }else if (g.getLevel3() != null && g.getLevel3() == 4){
  154. g.setName(g.getName3());
  155. g.setName3(null);
  156. g.setId(g.getId3());
  157. g.setId3(null);
  158. }else{
  159. g.setName(g.getName1());
  160. g.setName1(null);
  161. g.setId(g.getId1());
  162. g.setId1(null);
  163. }
  164. if (g.getId() != null) {
  165. if (!idList.contains(g.getId())){
  166. // data.add(g);
  167. idList.add(g.getId());
  168. }
  169. }
  170. }
  171. globalLocationVO.setIdList(idList);
  172. List<GlobalLocationDTO> areaLampPoleCountList = globalLocationDao.getAreaLampPoleCountList(globalLocationVO);
  173. List<GlobalLocationDTO> areaLampCountList = globalLocationDao.getAreaLampCountList(globalLocationVO);
  174. for (GlobalLocationDTO g : areaLampCountList) {
  175. for (GlobalLocationDTO g1 : areaLampPoleCountList) {
  176. if (Objects.equals(g.getId(), g1.getId())) {
  177. g.setLampPoleCount(g1.getLampPoleCount());
  178. data.add(g);
  179. break;
  180. }
  181. }
  182. }
  183. return data;
  184. }
  185. @Override
  186. public GlobalLocationDTO getOneById(Integer id) {
  187. return globalLocationDao.getOneById(id);
  188. }
  189. @Override
  190. public GlobalLocationDTO getGlobalLocationDTOById(Integer id, Integer version) {
  191. return globalLocationDao.getGlobalLocationDTOById(id,version);
  192. }
  193. @Override
  194. public List<GlobalLocationDTO> getLocationListByPid(Integer pid, Integer version) {
  195. return globalLocationDao.getLocationListByPid(pid,version);
  196. }
  197. @Override
  198. public List<GlobalLocationDTO> getGlobalList(@Param("level") Integer level, @Param("version") Integer version) {
  199. return globalLocationDao.getGlobalList(level,version);
  200. }
  201. @Override
  202. public Integer getAreaTimezoneById(Integer id) {
  203. return globalLocationDao.getAreaTimezoneById(id);
  204. }
  205. @Override
  206. public List<GlobalLocationDTO> getAreaListByPid(Integer pid, Integer version) {
  207. return globalLocationDao.getAreaListByPid(pid,version);
  208. }
  209. @Override
  210. public List<GlobalLocationDTO> getCityListByPid(Integer pid, Integer version) {
  211. return globalLocationDao.getCityListByPid(pid,version);
  212. }
  213. @Override
  214. public List<GlobalLocationDTO> getOnlyOneLevelList(Integer level, Integer version) {
  215. return globalLocationDao.getOnlyOneLevelList(level,version);
  216. }
  217. @Override
  218. public List<GlobalLocationDTO> getCountryOfSectionList(Integer level, Integer version) {
  219. return globalLocationDao.getCountryOfSectionList(level,version);
  220. }
  221. @Override
  222. public GlobalLocationDTO getDataByDto(GlobalLocationDTO dto){
  223. return globalLocationDao.getDataByDto(dto);
  224. }
  225. @Override
  226. public List<GlobalLocationDTO> getAreaList(GlobalLocationDTO dto){
  227. return globalLocationDao.getAreaList(dto);
  228. }
  229. }