|
@@ -2,10 +2,15 @@ package com.bz.smart_city.service.impl;
|
|
|
|
|
|
import com.bz.smart_city.commom.exception.ServiceException;
|
|
|
import com.bz.smart_city.commom.model.Pagination;
|
|
|
+import com.bz.smart_city.commom.util.TreeUtil;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
|
+import com.bz.smart_city.commom.util.Util;
|
|
|
+import com.bz.smart_city.dao.AreaMapper;
|
|
|
import com.bz.smart_city.dao.CommunityMapper;
|
|
|
+import com.bz.smart_city.dto.BuildingSelectDto;
|
|
|
import com.bz.smart_city.dto.CommunityDto;
|
|
|
import com.bz.smart_city.dto.LoginUser;
|
|
|
+import com.bz.smart_city.entity.Area;
|
|
|
import com.bz.smart_city.entity.Community;
|
|
|
import com.bz.smart_city.entity.ProgramItem;
|
|
|
import com.bz.smart_city.service.CommunityService;
|
|
@@ -18,6 +23,8 @@ import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static com.google.common.collect.Lists.newArrayList;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class CommunityServiceImpl implements CommunityService{
|
|
@@ -25,6 +32,8 @@ public class CommunityServiceImpl implements CommunityService{
|
|
|
@Resource
|
|
|
private CommunityMapper communityMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AreaMapper areaMapper;
|
|
|
|
|
|
@Override
|
|
|
public int insert(Community community){
|
|
@@ -184,4 +193,49 @@ public class CommunityServiceImpl implements CommunityService{
|
|
|
public List<Community> getMaxCodeBySiteId(Integer siteId){
|
|
|
return communityMapper.getMaxCodeBySiteId(siteId);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BuildingSelectDto> getAreaTree() {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+
|
|
|
+ List<Integer> ids = newArrayList();
|
|
|
+ List<BuildingSelectDto> buildingSelectDtoArrayList = newArrayList();
|
|
|
+
|
|
|
+ List<CommunityDto> communityList =newArrayList();
|
|
|
+ if (loginUser.getSiteType() != 2) {
|
|
|
+ communityList = communityMapper.findBySiteId(loginUser.getSiteId());
|
|
|
+ }else {
|
|
|
+ communityList = communityMapper.findByCustomerId(loginUser.getCustomerId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (communityList != null && communityList.size() > 0) {
|
|
|
+ communityList.forEach(community -> {
|
|
|
+ ids.add(community.getProvince());
|
|
|
+ ids.add(community.getCity());
|
|
|
+ ids.add(community.getRegion());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //查询所有建筑的区域
|
|
|
+ List<Area> areaList = newArrayList();
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ areaList = areaMapper.findByIds(Util.removeDuplicate(ids));
|
|
|
+ }
|
|
|
+ if (areaList != null && areaList.size() > 0) {
|
|
|
+ areaList.forEach(area -> {
|
|
|
+ BuildingSelectDto buildingSelectDto = new BuildingSelectDto();
|
|
|
+ buildingSelectDto.setCode(area.getId());
|
|
|
+ buildingSelectDto.setPid(area.getParentId());
|
|
|
+ buildingSelectDto.setName(area.getName());
|
|
|
+ buildingSelectDto.setStatus(0);
|
|
|
+ if(area.getLevelType() == 1)buildingSelectDto.setDimensionCode("PROVINCE");
|
|
|
+ if(area.getLevelType() == 2)buildingSelectDto.setDimensionCode("CITY");
|
|
|
+ if(area.getLevelType() == 3)buildingSelectDto.setDimensionCode("REGION");
|
|
|
+
|
|
|
+ buildingSelectDtoArrayList.add(buildingSelectDto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return TreeUtil.getBuildingSelect(buildingSelectDtoArrayList, 100000, "", 1);
|
|
|
+ }
|
|
|
}
|