|
|
@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
@ -16,6 +18,7 @@ import com.epmet.dto.IcResiCategoryWarnConfigDTO; |
|
|
|
import com.epmet.dto.form.IcResiCategoryStatsConfigFormDTO; |
|
|
|
import com.epmet.dto.form.IcUserWarnNoticeFormDTO; |
|
|
|
import com.epmet.dto.form.StatsResiListFormDTO; |
|
|
|
import com.epmet.dto.form.StatsResiWarnFormDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.entity.IcStatsResiWarnEntity; |
|
|
@ -24,12 +27,13 @@ import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
import com.epmet.service.IcStatsResiWarnService; |
|
|
|
import com.epmet.service.StatsResiWarnService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -173,20 +177,18 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { |
|
|
|
//根据buildingID,tableName he columnName获取名字
|
|
|
|
//限制条数 一栋楼内最多显示1000 即可
|
|
|
|
for (String s : buildingIdList) { |
|
|
|
PageHelper.startPage(NumConstant.ONE,NumConstant.ONE_HUNDRED,false).doSelectPage(()->{ |
|
|
|
List<UserWarnNameListResultDTO> dtos = icStatsResiWarnDao.userWarnListDTO(customerId, Arrays.asList(s), icResiCategoryWarnConfigDTO.getTableName(), icResiCategoryWarnConfigDTO.getColumnName()); |
|
|
|
if (!CollectionUtils.isEmpty(dtos)){ |
|
|
|
Map<String, List<UserWarnNameListResultDTO>> groupByBuild = dtos.stream().collect(Collectors.groupingBy(UserWarnNameListResultDTO::getBuildingId)); |
|
|
|
result.forEach(item->{ |
|
|
|
item.setConfigId(configId); |
|
|
|
groupByBuild.forEach((k,v) -> { |
|
|
|
if (item.getBuildingId().equals(k)){ |
|
|
|
item.setUserList(v); |
|
|
|
} |
|
|
|
}); |
|
|
|
List<UserWarnNameListResultDTO> dtos = icStatsResiWarnDao.userWarnListDTO(customerId, Arrays.asList(s), icResiCategoryWarnConfigDTO.getTableName(), icResiCategoryWarnConfigDTO.getColumnName()); |
|
|
|
if (!CollectionUtils.isEmpty(dtos)){ |
|
|
|
Map<String, List<UserWarnNameListResultDTO>> groupByBuild = dtos.stream().collect(Collectors.groupingBy(UserWarnNameListResultDTO::getBuildingId)); |
|
|
|
result.forEach(item->{ |
|
|
|
item.setConfigId(configId); |
|
|
|
groupByBuild.forEach((k,v) -> { |
|
|
|
if (item.getBuildingId().equals(k)){ |
|
|
|
item.setCount(v.size()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
/*PageHelper.startPage(NumConstant.ONE,NumConstant.ONE_THOUSAND,false).doSelectPage(()->{ |
|
|
|
List<UserWarnNameListResultDTO> dtos = icStatsResiWarnDao.userWarnListDTO(customerId, buildingIdList, icResiCategoryWarnConfigDTO.getTableName(), icResiCategoryWarnConfigDTO.getColumnName()); |
|
|
@ -205,6 +207,41 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { |
|
|
|
return mapResult; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserWarnNameListResultDTO> allUserWarnList(StatsResiWarnFormDTO formDTO) { |
|
|
|
//获取configId预警配置信息
|
|
|
|
IcResiCategoryWarnConfigDTO formDto = new IcResiCategoryWarnConfigDTO(); |
|
|
|
formDto.setId(formDTO.getConfigId()); |
|
|
|
Result<IcResiCategoryWarnConfigDTO> warnResult = operCustomizeOpenFeignClient.resiCategoryWarnInfoById(formDto); |
|
|
|
if (!warnResult.success() || null == warnResult.getData()) { |
|
|
|
throw new RenException("获取预警配置信息失败,configId="+ formDTO.getConfigId()); |
|
|
|
} |
|
|
|
IcResiCategoryWarnConfigDTO icResiCategoryWarnConfigDTO = warnResult.getData(); |
|
|
|
|
|
|
|
PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize()); |
|
|
|
List<UserWarnNameListResultDTO> list = icStatsResiWarnDao.userWarnListDTO(formDTO.getCustomerId(), |
|
|
|
Collections.singletonList(formDTO.getBuildingId()), |
|
|
|
icResiCategoryWarnConfigDTO.getTableName(), |
|
|
|
icResiCategoryWarnConfigDTO.getColumnName()); |
|
|
|
PageInfo<UserWarnNameListResultDTO> pageInfo = new PageInfo<>(list); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
Set<String> homeIds = list.stream().map(UserWarnNameListResultDTO::getHomeId).collect(Collectors.toSet()); |
|
|
|
Result<List<HouseInfoDTO>> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(homeIds, formDTO.getCustomerId()); |
|
|
|
if (!houseInfoRes.success() || CollectionUtils.isEmpty(houseInfoRes.getData())){ |
|
|
|
throw new EpmetException("查询居民所属房屋失败..."); |
|
|
|
} |
|
|
|
Map<String, HouseInfoDTO> houseMap = houseInfoRes.getData().stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity())); |
|
|
|
list.forEach(item -> { |
|
|
|
HouseInfoDTO houseInfo = houseMap.get(item.getHomeId()); |
|
|
|
if (null != houseInfo) { |
|
|
|
item.setUnitName(houseInfo.getUnitName()); |
|
|
|
item.setDoorName(houseInfo.getDoorName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<IcStatsResiResultDTO> list(String customerId,String id, String level) { |
|
|
|
//获取所有配置类项 getshow
|
|
|
|