@ -10,12 +10,11 @@ import com.epmet.dto.stats.form.FactUserHouseFormDTO;
import com.epmet.dto.stats.result.FactUserHouseResultDTO ;
import com.epmet.dto.stats.result.FactUserHouseResultDTO ;
import com.epmet.entity.stats.FactAgencyUserHouseDailyEntity ;
import com.epmet.entity.stats.FactAgencyUserHouseDailyEntity ;
import com.epmet.entity.stats.FactGridUserHouseDailyEntity ;
import com.epmet.entity.stats.FactGridUserHouseDailyEntity ;
import com.epmet.entity.stats.FactNeighborhoodUserHouseDailyEntity ;
import com.epmet.service.org.HouseService ;
import com.epmet.service.org.HouseService ;
import com.epmet.service.stats.DimGridService ;
import com.epmet.service.stats.* ;
import com.epmet.service.stats.FactAgencyUserHouseDailyService ;
import com.epmet.service.stats.FactGridUserHouseDailyService ;
import com.epmet.service.stats.FactUserHouseService ;
import com.epmet.service.user.IcResiUserService ;
import com.epmet.service.user.IcResiUserService ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
@ -29,6 +28,7 @@ import java.util.*;
* @since v1 . 0 . 0 2022 - 05 - 27
* @since v1 . 0 . 0 2022 - 05 - 27
* /
* /
@Service
@Service
@Slf4j
public class FactUserHouseServiceImpl implements FactUserHouseService {
public class FactUserHouseServiceImpl implements FactUserHouseService {
@Autowired
@Autowired
@ -37,6 +37,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService {
@Autowired
@Autowired
private FactGridUserHouseDailyService factGridUserHouseDailyService ;
private FactGridUserHouseDailyService factGridUserHouseDailyService ;
@Autowired
private FactNeighborhoodUserHouseDailyService factNeighborhoodUserHouseDailyService ;
@Autowired
@Autowired
private HouseService houseService ;
private HouseService houseService ;
@ -59,7 +62,10 @@ public class FactUserHouseServiceImpl implements FactUserHouseService {
params . put ( "dateId" , DateUtils . getBeforeNDay ( NumConstant . ONE ) ) ;
params . put ( "dateId" , DateUtils . getBeforeNDay ( NumConstant . ONE ) ) ;
}
}
if ( params . containsKey ( "level" ) ) {
if ( params . containsKey ( "level" ) ) {
if ( OrgLevelEnum . GRID . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) | | OrgLevelEnum . COMMUNITY . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
if ( "neighborhood" . equals ( params . get ( "level" ) . toString ( ) ) | | OrgLevelEnum . GRID . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
page = factNeighborhoodUserHouseDailyService . page ( params ) ;
} else if ( OrgLevelEnum . COMMUNITY . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
page = factGridUserHouseDailyService . page ( params ) ;
page = factGridUserHouseDailyService . page ( params ) ;
} else {
} else {
page = factAgencyUserHouseDailyService . page ( params ) ;
page = factAgencyUserHouseDailyService . page ( params ) ;
@ -83,7 +89,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService {
}
}
// 网格纬度查询网格统计表,其余纬度查询组织统计表
// 网格纬度查询网格统计表,其余纬度查询组织统计表
if ( params . containsKey ( "level" ) ) {
if ( params . containsKey ( "level" ) ) {
if ( OrgLevelEnum . GRID . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
if ( "neighborhood" . equals ( params . get ( "level" ) . toString ( ) ) ) {
dto = factNeighborhoodUserHouseDailyService . getTotal ( params ) ;
} else if ( OrgLevelEnum . GRID . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
dto = factGridUserHouseDailyService . getTotal ( params ) ;
dto = factGridUserHouseDailyService . getTotal ( params ) ;
} else {
} else {
dto = factAgencyUserHouseDailyService . getTotal ( params ) ;
dto = factAgencyUserHouseDailyService . getTotal ( params ) ;
@ -96,7 +104,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService {
public List < FactUserHouseResultDTO > list ( Map < String , Object > params ) {
public List < FactUserHouseResultDTO > list ( Map < String , Object > params ) {
List < FactUserHouseResultDTO > list = new ArrayList < > ( ) ;
List < FactUserHouseResultDTO > list = new ArrayList < > ( ) ;
if ( params . containsKey ( "level" ) ) {
if ( params . containsKey ( "level" ) ) {
if ( OrgLevelEnum . GRID . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) | | OrgLevelEnum . COMMUNITY . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
if ( "neighborhood" . equals ( params . get ( "level" ) . toString ( ) ) | | OrgLevelEnum . GRID . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
list = factNeighborhoodUserHouseDailyService . listExport ( params ) ;
} else if ( OrgLevelEnum . COMMUNITY . getCode ( ) . equals ( params . get ( "level" ) . toString ( ) ) ) {
list = factGridUserHouseDailyService . listExport ( params ) ;
list = factGridUserHouseDailyService . listExport ( params ) ;
} else {
} else {
list = factAgencyUserHouseDailyService . listExport ( params ) ;
list = factAgencyUserHouseDailyService . listExport ( params ) ;
@ -176,6 +186,74 @@ public class FactUserHouseServiceImpl implements FactUserHouseService {
factGridUserHouseDailyService . insertBatch ( entityList ) ;
factGridUserHouseDailyService . insertBatch ( entityList ) ;
}
}
/ * *
* 小区
* @author wgf
* @param formDTO
* /
@Override
public void statNeighborhood ( FactUserHouseFormDTO formDTO ) {
log . info ( "$$$进入业务逻辑" ) ;
if ( StringUtils . isBlank ( formDTO . getDateId ( ) ) ) {
formDTO . setDateId ( DateUtils . getBeforeNDay ( NumConstant . ONE ) ) ;
}
String dateId = formDTO . getDateId ( ) ;
String customerId = formDTO . getCustomerId ( ) ;
// 先删除历史
factNeighborhoodUserHouseDailyService . deleteByDateId ( formDTO ) ;
log . info ( "$$$删除历史完成" ) ;
// 保证小区是全部网格后,其余数据进行循环匹配
List < FactUserHouseResultDTO > neiList = houseService . neighborhoodStatNew ( formDTO ) ;
List < FactUserHouseResultDTO > houseList = houseService . houseStatNew ( formDTO ) ;
List < FactUserHouseResultDTO > userList = icResiUserService . userStatNew ( formDTO ) ;
List < FactUserHouseResultDTO > addList = new ArrayList < > ( ) ;
neiList . forEach ( item - > {
String gridId = item . getGridId ( ) = = null ? "" : item . getGridId ( ) ;
String neighborHoodsId = item . getNeighbourhoodsId ( ) ;
FactUserHouseResultDTO dto = new FactUserHouseResultDTO ( ) ;
dto . setCustomerId ( formDTO . getCustomerId ( ) ) ;
dto . setDateId ( dateId ) ;
dto . setGridId ( gridId ) ;
dto . setPid ( item . getPid ( ) = = null ? "" : item . getPid ( ) ) ;
dto . setPids ( item . getPids ( ) = = null ? "" : item . getPids ( ) ) ;
dto . setNeighbourhoodsCount ( item . getNeighbourhoodsCount ( ) ) ;
dto . setNeighbourhoodsId ( item . getNeighbourhoodsId ( ) ) ;
dto . setNeighborHoodName ( item . getNeighborHoodName ( ) ) ;
Optional < FactUserHouseResultDTO > houseOptional = houseList . stream ( ) . filter ( house - > neighborHoodsId . equals ( house . getNeighbourhoodsId ( ) ) & & customerId . equals ( house . getCustomerId ( ) ) ) . findFirst ( ) ;
if ( houseOptional . isPresent ( ) ) {
dto . setHouseCount ( houseOptional . get ( ) . getHouseCount ( ) ) ;
dto . setHouseSelfCount ( houseOptional . get ( ) . getHouseSelfCount ( ) ) ;
dto . setHouseLeaseCount ( houseOptional . get ( ) . getHouseLeaseCount ( ) ) ;
dto . setHouseIdleCount ( houseOptional . get ( ) . getHouseIdleCount ( ) ) ;
} else {
dto . setHouseCount ( NumConstant . ZERO ) ;
dto . setHouseSelfCount ( NumConstant . ZERO ) ;
dto . setHouseLeaseCount ( NumConstant . ZERO ) ;
dto . setHouseIdleCount ( NumConstant . ZERO ) ;
}
Optional < FactUserHouseResultDTO > userOptional = userList . stream ( ) . filter ( user - > neighborHoodsId . equals ( user . getNeighbourhoodsId ( ) ) & & customerId . equals ( user . getCustomerId ( ) ) ) . findFirst ( ) ;
if ( userOptional . isPresent ( ) ) {
dto . setUserCount ( userOptional . get ( ) . getUserCount ( ) ) ;
dto . setUserResiCount ( userOptional . get ( ) . getUserResiCount ( ) ) ;
dto . setUserFloatCount ( userOptional . get ( ) . getUserFloatCount ( ) ) ;
} else {
dto . setUserCount ( NumConstant . ZERO ) ;
dto . setUserResiCount ( NumConstant . ZERO ) ;
dto . setUserFloatCount ( NumConstant . ZERO ) ;
}
addList . add ( dto ) ;
} ) ;
log . info ( "$$$addList:::::" + addList ) ;
List < FactNeighborhoodUserHouseDailyEntity > entityList = ConvertUtils . sourceToTarget ( addList , FactNeighborhoodUserHouseDailyEntity . class ) ;
factNeighborhoodUserHouseDailyService . insertBatch ( entityList ) ;
}
@Override
@Override
public void statAgency ( FactUserHouseFormDTO formDTO ) {
public void statAgency ( FactUserHouseFormDTO formDTO ) {
if ( StringUtils . isBlank ( formDTO . getDateId ( ) ) ) {
if ( StringUtils . isBlank ( formDTO . getDateId ( ) ) ) {