|
|
@ -1,14 +1,19 @@ |
|
|
|
package com.epmet.dataaggre.service.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.enums.CoverageEnums; |
|
|
|
import com.epmet.commons.tools.enums.CoveragePlaceTypeEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
import com.epmet.dataaggre.constant.OrgConstant; |
|
|
|
import com.epmet.dataaggre.dto.coverage.AnalysisGovernedTargetsResult; |
|
|
|
import com.epmet.dataaggre.dto.coverage.AnalysisResourceCategoriesResult; |
|
|
|
import com.epmet.dataaggre.dto.epmetuser.result.IcResiInfoResultDTO; |
|
|
@ -33,6 +38,7 @@ import com.epmet.dataaggre.service.heart.HeartService; |
|
|
|
import com.epmet.dataaggre.service.opercustomize.IcResiCategoryWarnService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -97,12 +103,11 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<CoverageAnalisisDataListResultDTO> analysisDataList(List<String> coverageTypes, List<String> categoryKeys, |
|
|
|
public PageData<CoverageAnalisisDataListResultDTO> analysisDataList(String customerId,String staffId,String orgId,String orgType, |
|
|
|
List<String> coverageTypes, List<String> categoryKeys, |
|
|
|
String search, Integer pageNo, Integer pageSize, Boolean isPage) { |
|
|
|
|
|
|
|
// 获取跟组织的坐标
|
|
|
|
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|
|
|
String staffId = EpmetRequestHolder.getLoginUserId(); |
|
|
|
CustomerAgencyEntity rootAgency = govOrgService.getRootAgencyByCustomerId(customerId); |
|
|
|
|
|
|
|
// 1.根据categoryKeys分类key列表,查询他们和图层时间的关系,映射为一个map
|
|
|
@ -122,15 +127,9 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
} |
|
|
|
|
|
|
|
// 2.循环coverageTypes,使用key到map中查询(为了顺序),得到categoryKeys列表之后,根据实际情况做相应的查询
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, staffId); |
|
|
|
|
|
|
|
if (staffInfo == null) { |
|
|
|
String msg = "未找到当前登录人信息。staffId:" + EpmetRequestHolder.getLoginUserId(); |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), msg, msg); |
|
|
|
} |
|
|
|
|
|
|
|
String staffPids = getStaffPidsFromStaffInfo(staffInfo); |
|
|
|
String agencyId = staffInfo.getAgencyId(); |
|
|
|
Map<String,String> agencyMap=getStaffPidsFromStaffInfo(customerId,staffId,orgId,orgType); |
|
|
|
String agencyPath = agencyMap.get(OrgConstant.AGENC_PATH); |
|
|
|
String agencyId = agencyMap.get(OrgConstant.AGENCY_ID); |
|
|
|
|
|
|
|
// 分页不太好分,先查出所有的数据,然后partation()吧
|
|
|
|
int start = (pageNo - 1) * pageSize; |
|
|
@ -158,7 +157,7 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
} |
|
|
|
for (GovOrgCoverageService.CategoryCoverageMapping e : ccm) { |
|
|
|
|
|
|
|
Integer tempCount = doDataListCount(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, staffPids, e.getPlaceType(), |
|
|
|
Integer tempCount = doDataListCount(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, agencyPath, e.getPlaceType(), |
|
|
|
e.getCategoryKey(), search); |
|
|
|
lastTotalCount = totalCount; |
|
|
|
totalCount += tempCount; |
|
|
@ -167,7 +166,7 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
// 不分页,查询所有
|
|
|
|
// 检索数据
|
|
|
|
List<CoverageAnalisisDataListResultDTO> dataSegment = doDataListSearch( |
|
|
|
EpmetRequestHolder.getLoginUserCustomerId(), agencyId, staffPids, e.getPlaceType(), |
|
|
|
EpmetRequestHolder.getLoginUserCustomerId(), agencyId, agencyPath, e.getPlaceType(), |
|
|
|
e.getCategoryKey(), search, null, null, isPage, rootAgency); |
|
|
|
rls.addAll(dataSegment); |
|
|
|
continue; |
|
|
@ -189,7 +188,7 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
|
|
|
|
// 检索数据
|
|
|
|
List<CoverageAnalisisDataListResultDTO> dataSegment = doDataListSearch( |
|
|
|
EpmetRequestHolder.getLoginUserCustomerId(), agencyId, staffPids, e.getPlaceType(), |
|
|
|
EpmetRequestHolder.getLoginUserCustomerId(), agencyId, agencyPath, e.getPlaceType(), |
|
|
|
e.getCategoryKey(), search, 1, end, isPage, rootAgency); |
|
|
|
|
|
|
|
if (firstTimeDataAppear) { |
|
|
@ -239,6 +238,41 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, String> getStaffPidsFromStaffInfo(String customerId, String staffId, String orgId, String orgType) { |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
String agencyPath = StrConstant.EPMETY_STR; |
|
|
|
String agencyId = StrConstant.EPMETY_STR; |
|
|
|
if (StringUtils.isBlank(orgId)) { |
|
|
|
// 默认查询的是当前登录用户所属组织及下级
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, staffId); |
|
|
|
if (staffInfo == null) { |
|
|
|
String msg = "未找到当前登录人信息。staffId:" + EpmetRequestHolder.getLoginUserId(); |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), msg, msg); |
|
|
|
} |
|
|
|
// staffPids
|
|
|
|
agencyPath = getStaffPidsFromStaffInfo(staffInfo); |
|
|
|
agencyId = staffInfo.getAgencyId(); |
|
|
|
} else { |
|
|
|
// 根据传入的组织id来
|
|
|
|
if (OrgConstant.AGENCY.equals(orgType)) { |
|
|
|
AgencyInfoCache agencyInfoCache = CustomerOrgRedis.getAgencyInfo(orgId); |
|
|
|
if (agencyInfoCache == null) { |
|
|
|
String msg = "查询组织缓存信息异常。orgId:" + orgId; |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), msg, msg); |
|
|
|
} |
|
|
|
agencyId = orgId; |
|
|
|
if (StringUtils.isNotBlank(agencyInfoCache.getPids()) && !"0".equals(agencyInfoCache.getPids()) && !"0".equals(agencyInfoCache)) { |
|
|
|
agencyPath = agencyInfoCache.getPids().concat(":").concat(agencyId); |
|
|
|
} else { |
|
|
|
agencyPath = orgId; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
map.put(OrgConstant.AGENCY_ID, agencyId); |
|
|
|
map.put(OrgConstant.AGENC_PATH, agencyPath); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算数据条数 |
|
|
|
* @param customerId |
|
|
@ -346,7 +380,8 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
|
|
|
|
return icEventEntities.stream() |
|
|
|
.map(e -> new CoverageAnalisisDataListResultDTO( |
|
|
|
e.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null, placeType, isPage ? e.getName() : null, |
|
|
|
e.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null, placeType, |
|
|
|
e.getEventContent().length() < 51 ? e.getEventContent() : e.getEventContent().substring(NumConstant.ZERO, NumConstant.FIFTY).concat(StrConstant.ELLIPSIS), |
|
|
|
e.getLatitude(), e.getLongitude())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
@ -601,9 +636,31 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<CoverageAnalisisDataListResultDTOV2> dataListLeft(CoverageAnalisisDataListLeftFormDTO formDTO) { |
|
|
|
//todo
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
PageData<CoverageAnalisisDataListResultDTO> page = analysisDataList(formDTO.getCustomerId(), formDTO.getStaffId(), formDTO.getOrgId(), formDTO.getOrgType(), |
|
|
|
formDTO.getCoverageTypes(), formDTO.getCategoryKeys(), |
|
|
|
StrConstant.EPMETY_STR,// 搜索关键词 默认空字符串
|
|
|
|
NumConstant.ONE, |
|
|
|
NumConstant.TWENTY, |
|
|
|
false // 不分页
|
|
|
|
); |
|
|
|
List<CoverageAnalisisDataListResultDTOV2> list = new ArrayList<>(); |
|
|
|
if (CollectionUtils.isNotEmpty(page.getList())) { |
|
|
|
Map<String, List<CoverageAnalisisDataListResultDTO>> group = page.getList().stream().collect(Collectors.groupingBy(CoverageAnalisisDataListResultDTO::getLongLat)); |
|
|
|
if (MapUtils.isNotEmpty(group)) { |
|
|
|
for (Map.Entry<String, List<CoverageAnalisisDataListResultDTO>> entry : group.entrySet()) { |
|
|
|
if (CollectionUtils.isEmpty(entry.getValue())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
CoverageAnalisisDataListResultDTOV2 res = new CoverageAnalisisDataListResultDTOV2(); |
|
|
|
res.setLatitude(entry.getValue().get(NumConstant.ZERO).getLatitude()); |
|
|
|
res.setLongitude(entry.getValue().get(NumConstant.ZERO).getLongitude()); |
|
|
|
res.setDataList(entry.getValue()); |
|
|
|
list.add(res); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// int totalCount = CollectionUtils.isNotEmpty(list) ? list.size() : NumConstant.ZERO;//这个是实际返回的几个坐标点
|
|
|
|
// page.getTotal()是多少条业务数据
|
|
|
|
return new PageData<>(list, page.getTotal()); |
|
|
|
} |
|
|
|
} |