forked from luyan/epmet-cloud-lingshan
16 changed files with 563 additions and 4 deletions
@ -0,0 +1,23 @@ |
|||
package com.epmet.dto.form.stats; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* 人房信息查询dto |
|||
*/ |
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class UserHouseStatsQueryFormDTO { |
|||
|
|||
private String orgId; |
|||
private String orgType; |
|||
|
|||
@NotBlank(message = "dateId不能为空") |
|||
private String dateId; |
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.epmet.stats; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 人房信息统计 |
|||
*/ |
|||
@Data |
|||
public class UserHouseStatsResultDTO { |
|||
private Integer houseTotal = 0; |
|||
private Integer zzHouseTotal = 0; |
|||
private Integer czHouseTotal = 0; |
|||
private Integer xzHouseTotal = 0; |
|||
private Integer userTotal = 0; |
|||
private Integer czUserTotal = 0; |
|||
private Integer ldUserTotal = 0; |
|||
private Integer usingCommunityNum = 0; |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.epmet.datareport.controller.stats; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.datareport.service.stats.UserHouseStatsService; |
|||
import com.epmet.dto.form.stats.UserHouseStatsQueryFormDTO; |
|||
import com.epmet.stats.UserHouseStatsResultDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("userHouse") |
|||
public class UserHouseController { |
|||
|
|||
@Autowired |
|||
private UserHouseStatsService userHouseStatsService; |
|||
|
|||
/** |
|||
* 通过dateId查询人房统计信息 |
|||
* @param input |
|||
* @return |
|||
*/ |
|||
@PostMapping("getUserHouseDailyStatsByDateId") |
|||
public Result<UserHouseStatsResultDTO> getUserHouseDailyStatsByDateId(@RequestBody UserHouseStatsQueryFormDTO input) { |
|||
ValidatorUtils.validateEntity(input); |
|||
String orgId = input.getOrgId(); |
|||
String orgType = input.getOrgType(); |
|||
String dateId = input.getDateId(); |
|||
|
|||
UserHouseStatsResultDTO r = userHouseStatsService.getUserHouseDailyStats(orgId, orgType, dateId); |
|||
return new Result<UserHouseStatsResultDTO>().ok(r); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.datareport.dao.stats; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.datareport.entity.stats.FactAgencyUserHouseDailyEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
|
|||
/** |
|||
* 人房信息统计数,按天统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-05-27 |
|||
*/ |
|||
@Mapper |
|||
public interface FactAgencyUserHouseDailyDao extends BaseDao<FactAgencyUserHouseDailyEntity> { |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.datareport.dao.stats; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.datareport.entity.stats.FactGridUserHouseDailyEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
|
|||
/** |
|||
* 网格的人房信息统计数,按天统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-05-27 |
|||
*/ |
|||
@Mapper |
|||
public interface FactGridUserHouseDailyDao extends BaseDao<FactGridUserHouseDailyEntity> { |
|||
|
|||
} |
@ -0,0 +1,115 @@ |
|||
package com.epmet.datareport.entity.stats; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 人房信息统计数,按天统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-05-27 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("fact_agency_user_house_daily") |
|||
public class FactAgencyUserHouseDailyEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 数据更新至:yyyyMMdd; |
|||
*/ |
|||
private String dateId; |
|||
|
|||
/** |
|||
* 组织id |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* agency_id所属的机关级别(社区级:community, |
|||
乡(镇、街道)级:street, |
|||
区县级: district, |
|||
市级: city |
|||
省级:province) |
|||
*/ |
|||
private String level; |
|||
|
|||
/** |
|||
* 组织i所属的组织id |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 组织i所有上级id |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 小区总数 |
|||
*/ |
|||
private Integer neighbourhoodsCount; |
|||
|
|||
/** |
|||
* 房屋总数 |
|||
*/ |
|||
private Integer houseCount; |
|||
|
|||
/** |
|||
* 自住房屋总数 |
|||
*/ |
|||
private Integer houseSelfCount; |
|||
|
|||
/** |
|||
* 出租房屋总数 |
|||
*/ |
|||
private Integer houseLeaseCount; |
|||
|
|||
/** |
|||
* 闲置房屋总数 |
|||
*/ |
|||
private Integer houseIdleCount; |
|||
|
|||
/** |
|||
* 居民总数 |
|||
*/ |
|||
private Integer userCount; |
|||
|
|||
/** |
|||
* 常住居民总数 |
|||
*/ |
|||
private Integer userResiCount; |
|||
|
|||
/** |
|||
* 流动居民总数 |
|||
*/ |
|||
private Integer userFloatCount; |
|||
|
|||
/** |
|||
* 当日新增房屋数 |
|||
*/ |
|||
private Integer houseIncr; |
|||
|
|||
/** |
|||
* 当日修改房屋数 |
|||
*/ |
|||
private Integer houseModify; |
|||
|
|||
/** |
|||
* 当日新增居民数 |
|||
*/ |
|||
private Integer userIncr; |
|||
|
|||
/** |
|||
* 当日修改居民数 |
|||
*/ |
|||
private Integer userModify; |
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
package com.epmet.datareport.entity.stats; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 网格的人房信息统计数,按天统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-05-27 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("fact_grid_user_house_daily") |
|||
public class FactGridUserHouseDailyEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 数据更新至:yyyyMMdd; |
|||
*/ |
|||
private String dateId; |
|||
|
|||
/** |
|||
* 网格id |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 网格所属的组织id |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 网格所有上级id |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 小区总数 |
|||
*/ |
|||
private Integer neighbourhoodsCount; |
|||
|
|||
/** |
|||
* 房屋总数 |
|||
*/ |
|||
private Integer houseCount; |
|||
|
|||
/** |
|||
* 自住房屋总数 |
|||
*/ |
|||
private Integer houseSelfCount; |
|||
|
|||
/** |
|||
* 出租房屋总数 |
|||
*/ |
|||
private Integer houseLeaseCount; |
|||
|
|||
/** |
|||
* 闲置房屋总数 |
|||
*/ |
|||
private Integer houseIdleCount; |
|||
|
|||
/** |
|||
* 居民总数 |
|||
*/ |
|||
private Integer userCount; |
|||
|
|||
/** |
|||
* 常住居民总数 |
|||
*/ |
|||
private Integer userResiCount; |
|||
|
|||
/** |
|||
* 流动居民总数 |
|||
*/ |
|||
private Integer userFloatCount; |
|||
|
|||
/** |
|||
* 当日新增房屋数 |
|||
*/ |
|||
private Integer houseIncr; |
|||
|
|||
/** |
|||
* 当日修改房屋数 |
|||
*/ |
|||
private Integer houseModify; |
|||
|
|||
/** |
|||
* 当日新增居民数 |
|||
*/ |
|||
private Integer userIncr; |
|||
|
|||
/** |
|||
* 当日修改居民数 |
|||
*/ |
|||
private Integer userModify; |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.epmet.datareport.service.stats; |
|||
|
|||
import com.epmet.stats.UserHouseStatsResultDTO; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
/** |
|||
* 人房统计service |
|||
*/ |
|||
public interface UserHouseStatsService { |
|||
|
|||
/** |
|||
* 查询指定dateId的人房统计信息 |
|||
* @param orgId |
|||
* @param orgType |
|||
* @param dateId |
|||
* @return |
|||
*/ |
|||
UserHouseStatsResultDTO getUserHouseDailyStats(String orgId, String orgType, String dateId); |
|||
} |
@ -0,0 +1,87 @@ |
|||
package com.epmet.datareport.service.stats.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.datareport.dao.stats.FactAgencyUserHouseDailyDao; |
|||
import com.epmet.datareport.dao.stats.FactGridUserHouseDailyDao; |
|||
import com.epmet.datareport.entity.stats.FactAgencyUserHouseDailyEntity; |
|||
import com.epmet.datareport.entity.stats.FactGridUserHouseDailyEntity; |
|||
import com.epmet.datareport.service.stats.UserHouseStatsService; |
|||
import com.epmet.stats.UserHouseStatsResultDTO; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@DataSource(DataSourceConstant.STATS) |
|||
public class UserHouseStatsServiceImpl implements UserHouseStatsService { |
|||
|
|||
@Autowired |
|||
private FactGridUserHouseDailyDao factGridUserHouseDailyDao; |
|||
|
|||
@Autowired |
|||
private FactAgencyUserHouseDailyDao factAgencyUserHouseDailyDao; |
|||
|
|||
@Override |
|||
public UserHouseStatsResultDTO getUserHouseDailyStats(String orgId, String orgType, String dateId) { |
|||
// 没有传参,使用当前登录人的
|
|||
if (StringUtils.isEmpty(orgId) || StringUtils.isEmpty(orgType)) { |
|||
String userId = EpmetRequestHolder.getLoginUserId(); |
|||
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|||
|
|||
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); |
|||
if (null == staffInfo) { |
|||
throw new EpmetException(String.format("查询工作人员%s缓存信息失败:%s", userId)); |
|||
} |
|||
|
|||
orgId = staffInfo.getAgencyId(); |
|||
orgType = "agency"; |
|||
} |
|||
|
|||
// 结果对象初始化
|
|||
UserHouseStatsResultDTO result = new UserHouseStatsResultDTO(); |
|||
|
|||
if ("agency".equals(orgType)) { |
|||
// 查询的目标是组织
|
|||
LambdaQueryWrapper<FactAgencyUserHouseDailyEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(FactAgencyUserHouseDailyEntity::getDateId, dateId); |
|||
query.eq(FactAgencyUserHouseDailyEntity::getAgencyId, orgId); |
|||
FactAgencyUserHouseDailyEntity agencyDailyStats = factAgencyUserHouseDailyDao.selectOne(query); |
|||
if (agencyDailyStats != null) { |
|||
result.setHouseTotal(agencyDailyStats.getHouseCount()); |
|||
result.setCzHouseTotal(agencyDailyStats.getHouseLeaseCount()); |
|||
result.setXzHouseTotal(agencyDailyStats.getHouseIdleCount()); |
|||
result.setZzHouseTotal(agencyDailyStats.getHouseSelfCount()); |
|||
result.setUserTotal(agencyDailyStats.getUserCount()); |
|||
result.setCzUserTotal(agencyDailyStats.getUserResiCount()); |
|||
result.setLdUserTotal(agencyDailyStats.getUserFloatCount()); |
|||
} |
|||
} else { |
|||
// 查询的目标是网格
|
|||
LambdaQueryWrapper<FactGridUserHouseDailyEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(FactGridUserHouseDailyEntity::getDateId, dateId); |
|||
query.eq(FactGridUserHouseDailyEntity::getGridId, orgId); |
|||
FactGridUserHouseDailyEntity gridDailyStats = factGridUserHouseDailyDao.selectOne(query); |
|||
if (gridDailyStats != null) { |
|||
result.setHouseTotal(gridDailyStats.getHouseCount()); |
|||
result.setCzHouseTotal(gridDailyStats.getHouseLeaseCount()); |
|||
result.setXzHouseTotal(gridDailyStats.getHouseIdleCount()); |
|||
result.setZzHouseTotal(gridDailyStats.getHouseSelfCount()); |
|||
result.setUserTotal(gridDailyStats.getUserCount()); |
|||
result.setCzUserTotal(gridDailyStats.getUserResiCount()); |
|||
result.setLdUserTotal(gridDailyStats.getUserFloatCount()); |
|||
} |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.datareport.dao.stats.FactAgencyUserHouseDailyDao"> |
|||
|
|||
<resultMap type="com.epmet.datareport.entity.stats.FactAgencyUserHouseDailyEntity" id="factAgencyUserHouseDailyMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="dateId" column="DATE_ID"/> |
|||
<result property="agencyId" column="AGENCY_ID"/> |
|||
<result property="level" column="LEVEL"/> |
|||
<result property="pid" column="PID"/> |
|||
<result property="pids" column="PIDS"/> |
|||
<result property="neighbourhoodsCount" column="NEIGHBOURHOODS_COUNT"/> |
|||
<result property="houseCount" column="HOUSE_COUNT"/> |
|||
<result property="houseSelfCount" column="HOUSE_SELF_COUNT"/> |
|||
<result property="houseLeaseCount" column="HOUSE_LEASE_COUNT"/> |
|||
<result property="houseIdleCount" column="HOUSE_IDLE_COUNT"/> |
|||
<result property="userCount" column="USER_COUNT"/> |
|||
<result property="userResiCount" column="USER_RESI_COUNT"/> |
|||
<result property="userFloatCount" column="USER_FLOAT_COUNT"/> |
|||
<result property="houseIncr" column="HOUSE_INCR"/> |
|||
<result property="houseModify" column="HOUSE_MODIFY"/> |
|||
<result property="userIncr" column="USER_INCR"/> |
|||
<result property="userModify" column="USER_MODIFY"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
</mapper> |
@ -0,0 +1,32 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.datareport.dao.stats.FactGridUserHouseDailyDao"> |
|||
|
|||
<resultMap type="com.epmet.datareport.entity.stats.FactGridUserHouseDailyEntity" id="factGridUserHouseDailyMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="dateId" column="DATE_ID"/> |
|||
<result property="gridId" column="GRID_ID"/> |
|||
<result property="pid" column="PID"/> |
|||
<result property="pids" column="PIDS"/> |
|||
<result property="neighbourhoodsCount" column="NEIGHBOURHOODS_COUNT"/> |
|||
<result property="houseCount" column="HOUSE_COUNT"/> |
|||
<result property="houseSelfCount" column="HOUSE_SELF_COUNT"/> |
|||
<result property="houseLeaseCount" column="HOUSE_LEASE_COUNT"/> |
|||
<result property="houseIdleCount" column="HOUSE_IDLE_COUNT"/> |
|||
<result property="userCount" column="USER_COUNT"/> |
|||
<result property="userResiCount" column="USER_RESI_COUNT"/> |
|||
<result property="userFloatCount" column="USER_FLOAT_COUNT"/> |
|||
<result property="houseIncr" column="HOUSE_INCR"/> |
|||
<result property="houseModify" column="HOUSE_MODIFY"/> |
|||
<result property="userIncr" column="USER_INCR"/> |
|||
<result property="userModify" column="USER_MODIFY"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
</mapper> |
Loading…
Reference in new issue