diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerOrgRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerOrgRedis.java index 23a7f1dd3c..6d11f67930 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerOrgRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerOrgRedis.java @@ -1,7 +1,6 @@ package com.epmet.commons.tools.redis.common; import cn.hutool.core.bean.BeanUtil; -import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.dto.form.CustomerGridFormDTO; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.CommonAggFeignClient; @@ -13,6 +12,7 @@ import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -55,6 +55,10 @@ public class CustomerOrgRedis { * @date 2021/11/5 3:12 下午 */ public static GridInfoCache getGridInfo(String gridId){ + if (StringUtils.isBlank(gridId)) { + log.warn("查询网格缓存,gridId is null"); + return null; + } String key = RedisKeys.getGridInfoKey(gridId); Map grid = customerOrgRedis.redisUtils.hGetAll(key); if (!CollectionUtils.isEmpty(grid)) { @@ -110,4 +114,36 @@ public class CustomerOrgRedis { customerOrgRedis.redisUtils.delete(key); } + /** + * 拼接orgIdPath + * @param orgId + * @param orgType + * @return + */ + public static String getOrgIdPath(String orgId, String orgType) { + String orgPids = null; + + if ("grid".equals(orgType)) { + GridInfoCache gridInfo = getGridInfo(orgId); + if (gridInfo == null) { + log.error("查询网格信息失败:{}", orgId); + return null; + } + orgPids = gridInfo.getPids(); + } else if ("agency".equals(orgType)) { + AgencyInfoCache agencyInfo = getAgencyInfo(orgId); + if (agencyInfo == null) { + log.error("查询组织信息失败:{}", orgId); + return null; + } + orgPids = agencyInfo.getPids(); + } + + if (StringUtils.isBlank(orgPids) || "0".equals(orgPids)) { + return orgId; + } + + return orgPids.concat(":").concat(orgId); + } + } diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index 3fa85a8919..90c9b49999 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -80,6 +80,7 @@ spring: - Path=${server.servlet.context-path}/job/** filters: - StripPrefix=1 + - CpAuth=true #用户服务 - id: epmet-user-server uri: @gateway.routes.epmet-user-server.uri@ diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/DataSourceConstant.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/DataSourceConstant.java index d1e438d81a..d73da4247f 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/DataSourceConstant.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/DataSourceConstant.java @@ -7,5 +7,6 @@ public interface DataSourceConstant { */ String EVALUATION_INDEX = "evaluationIndex"; String STATS_DISPLAY = "statsDisplay"; + String STATS = "stats"; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/stats/UserHouseStatsQueryFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/stats/UserHouseStatsQueryFormDTO.java new file mode 100644 index 0000000000..ca6ea589fb --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/stats/UserHouseStatsQueryFormDTO.java @@ -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; + +} diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java index 862013f1a6..97771d20f0 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java @@ -2,11 +2,15 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.stats.UserHouseStatsQueryFormDTO; import com.epmet.dto.result.plugins.AgencyNodeDTO; import com.epmet.feign.impl.DataReportOpenFeignClientFallBackFactory; +import com.epmet.stats.UserHouseStatsResultDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -24,4 +28,12 @@ public interface DataReportOpenFeignClient { **/ @GetMapping("/data/report/screen/agency/querystaffagencytree/{agencyId}") Result queryStaffAgencyTree(@PathVariable("agencyId") String agencyId); + + /** + * 通过dateId查询人房统计信息 + * @param input 3个参数,就不用dto了,类太多: + * @return + */ + @PostMapping("/data/report/userHouse/getUserHouseDailyStatsByDateId") + Result getUserHouseDailyStatsByDateId(@RequestBody UserHouseStatsQueryFormDTO input); } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java index 247fe4499b..efc784a8b3 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java @@ -3,8 +3,10 @@ package com.epmet.feign.impl; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.stats.UserHouseStatsQueryFormDTO; import com.epmet.dto.result.plugins.AgencyNodeDTO; import com.epmet.feign.DataReportOpenFeignClient; +import com.epmet.stats.UserHouseStatsResultDTO; //@Component public class DataReportOpenFeignClientFallBack implements DataReportOpenFeignClient { @@ -17,4 +19,9 @@ public class DataReportOpenFeignClientFallBack implements DataReportOpenFeignCli public Result queryStaffAgencyTree(String agencyId) { return ModuleUtils.feignConError(ServiceConstant.DATA_REPORT_SERVER, "queryStaffAgencyTree",agencyId); } + + @Override + public Result getUserHouseDailyStatsByDateId(UserHouseStatsQueryFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.DATA_REPORT_SERVER, "getUserHouseDailyStatsByDateId",input); + } } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/stats/UserHouseStatsResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/stats/UserHouseStatsResultDTO.java new file mode 100644 index 0000000000..654bfed4cf --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/stats/UserHouseStatsResultDTO.java @@ -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; +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/stats/UserHouseController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/stats/UserHouseController.java new file mode 100644 index 0000000000..9556299271 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/stats/UserHouseController.java @@ -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 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().ok(r); + } + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/stats/FactAgencyUserHouseDailyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/stats/FactAgencyUserHouseDailyDao.java new file mode 100644 index 0000000000..bb2c98b36c --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/stats/FactAgencyUserHouseDailyDao.java @@ -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 { + +} \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/stats/FactGridUserHouseDailyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/stats/FactGridUserHouseDailyDao.java new file mode 100644 index 0000000000..da22c4a27b --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/stats/FactGridUserHouseDailyDao.java @@ -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 { + +} \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/stats/FactAgencyUserHouseDailyEntity.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/stats/FactAgencyUserHouseDailyEntity.java new file mode 100644 index 0000000000..8bae60daeb --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/stats/FactAgencyUserHouseDailyEntity.java @@ -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; + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/stats/FactGridUserHouseDailyEntity.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/stats/FactGridUserHouseDailyEntity.java new file mode 100644 index 0000000000..f2aded5df4 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/stats/FactGridUserHouseDailyEntity.java @@ -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; + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/stats/UserHouseStatsService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/stats/UserHouseStatsService.java new file mode 100644 index 0000000000..c898ed5ced --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/stats/UserHouseStatsService.java @@ -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); +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/stats/impl/UserHouseStatsServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/stats/impl/UserHouseStatsServiceImpl.java new file mode 100644 index 0000000000..e03c81ac8a --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/stats/impl/UserHouseStatsServiceImpl.java @@ -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 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 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; + } +} diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/stats/FactAgencyUserHouseDailyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/stats/FactAgencyUserHouseDailyDao.xml new file mode 100644 index 0000000000..8168105c8b --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/stats/FactAgencyUserHouseDailyDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/stats/FactGridUserHouseDailyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/stats/FactGridUserHouseDailyDao.xml new file mode 100644 index 0000000000..37ae699771 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/stats/FactGridUserHouseDailyDao.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommunityUserHouseStatsFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommunityUserHouseStatsFormDTO.java new file mode 100644 index 0000000000..075dc08b7c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommunityUserHouseStatsFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CommunityUserHouseStatsFormDTO { + private String orgId; + private String orgType; + private Integer pageNo = 1; + private Integer pageSize = 10; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UsingCommunityStatsFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UsingCommunityStatsFormDTO.java new file mode 100644 index 0000000000..c8afdd13ea --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UsingCommunityStatsFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UsingCommunityStatsFormDTO { + + private String orgId; + private String orgType; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java index 61bee2a9cc..eb7ee86152 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java @@ -56,6 +56,26 @@ public class HouseChartResultDTO implements Serializable { */ private Double wscHouseRatio = 0.0; + /** + * 房屋总数-较上月 + */ + private Integer houseTotalJSY; + + /** + * 自住房屋树-较上月 + */ + private Integer zzHouseTotalJSY; + + /** + * 出租房屋总数-较上月 + */ + private Integer czHouseTotalJSY; + + /** + * 闲置房屋总数-较上月 + */ + private Integer xzHouseTotalJSY; + @JsonIgnore private Integer num; //1:出租 0:自住 2:闲置 3:未出售 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubUserHouseListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubUserHouseListResultDTO.java index 45ded6601b..6124648323 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubUserHouseListResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubUserHouseListResultDTO.java @@ -1,8 +1,10 @@ package com.epmet.dto.result; +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; /** * @author sun @@ -79,4 +81,22 @@ public class SubUserHouseListResultDTO implements Serializable { */ private Double ldUserRatio = 0.0; + /** + * 开通平台的社区数 + */ + private Integer usingCommunityNum; + + /** + * 人户一致,人在户不在,户在人不在, + * 为空的 暂不清楚 + */ + private Integer rhyzUserTotal = NumConstant.ZERO; + private BigDecimal rhyzUserRatio = NumConstant.ZERO_DECIMAL; + private Integer rzhbzUserTotal = NumConstant.ZERO; + private BigDecimal rzhbzUserRatio = NumConstant.ZERO_DECIMAL; + private Integer hzrbzUserTotal = NumConstant.ZERO; + private BigDecimal hzrbzUserRatio = NumConstant.ZERO_DECIMAL; + private Integer zbqcUserTotal = NumConstant.ZERO; + private BigDecimal zbqcUserRatio = NumConstant.ZERO_DECIMAL; + } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UsingCommunityStatsResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UsingCommunityStatsResultDTO.java new file mode 100644 index 0000000000..2ba49424b6 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UsingCommunityStatsResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UsingCommunityStatsResultDTO { + + /** + * 开通平台社区数 + */ + private Integer usingCommunityNum; + /** + * 开通平台社区数-较上月 + */ + private Integer usingCommunityNumJSY; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index 7b3933ad70..c6576dde5e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -614,5 +614,14 @@ public class AgencyController { return new Result>().ok(agencyService.getCustomerTree(tokenDto)); } - + /** + * 开通平台的社区数统计 + * @return + */ + @RequestMapping("usingCommunityStats") + public Result usingCommunityStats(@RequestBody UsingCommunityStatsFormDTO input) { + String orgId = input.getOrgId(); + String orgType = input.getOrgType(); + return new Result().ok(agencyService.usingCommunityStats(orgId, orgType)); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 6a8c433250..e9fb4e56ef 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -342,6 +342,7 @@ public class CustomerAgencyController { /** * @Description 获取客户下组织树不含网格和部门 + * 哪些地方用到了比如:办事指南-指南管理查询条件 * @Param tokenDTO * @Return {@link Result< AgencyTreeResultDTO >} * @Author zhaoqifeng diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 0e2f57f7d9..6282777484 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -661,4 +661,20 @@ public class HouseController implements ResultDataResolver { return new Result>().ok(houseService.houseStatisListDetail(formDTO)); } + /** + * 针对社区的人房统计列表 + * @return + */ + @PostMapping("usingCommunityUserHouseStats") + public Result> communityUserHouseStats(@RequestBody CommunityUserHouseStatsFormDTO input) { + + String orgId = input.getOrgId(); + String orgType = input.getOrgType(); + Integer pageNo = input.getPageNo(); + Integer pageSize = input.getPageSize(); + + PageData r = houseService.usingCommunityUserHouseStats(orgId, orgType, pageNo, pageSize); + return new Result>().ok(r); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 37e8d93c98..fb1fc77855 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -27,6 +27,7 @@ import com.epmet.entity.CustomerAgencyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; /** @@ -387,5 +388,15 @@ public interface CustomerAgencyDao extends BaseDao { */ CustomerAgencyEntity getAgencyByUserId(@Param("userId") String userId, @Param("customerId") String customerId); + /** + * 开通社区列表 + * @param agencyId 机关组织的id + * @param agencyOrgIdPath agency的id路径path,包含自己 + * @param endDate 截止日期,也即查询,截止改日期,有多少社区在使用 + * @return + */ + List getUsingCommunityList(@Param("customerId") String customerId, @Param("agencyId") String agencyId, @Param("agencyOrgIdPath") String agencyOrgIdPath, @Param("endDate") Date endDate); + + List getCommunitysByOrgIdPath(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgIdPath") String orgIdPath); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java index 91dfa20ed9..becc763ba3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java @@ -90,7 +90,7 @@ public class EnterpriseImportExcelDTO { * 默认0 */ @ColumnWidth(20) - @ExcelProperty(value = "场所类别(九小场所/企事业单位)") + @ExcelProperty(value = "场所类别") private String placeCategoryName; @ColumnWidth(20) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java index 04c73a7756..d7bb4b2564 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -199,4 +199,9 @@ public interface AgencyService { */ List getCustomerTree(TokenDto tokenDto); + /** + * 开通平台的社区数统计 + * @return + */ + UsingCommunityStatsResultDTO usingCommunityStats(String orgId, String orgType); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index 239e844523..d1d1b87503 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -197,4 +197,6 @@ public interface HouseService { PageData listHouses4ReportTest(String houseId, Integer pageNo, Integer pageSize); PageData houseStatisListDetail(HouseChartFormDTO formDTO); + + PageData usingCommunityUserHouseStats(String orgId, String orgType, Integer pageNo, Integer pageSize); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index 3cf98078f5..6833141ad4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -34,9 +34,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.NodeTreeUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.constant.CustomerAgencyConstant; import com.epmet.constant.OrgInfoConstant; import com.epmet.constant.RoleKeyConstants; @@ -1117,4 +1115,55 @@ public class AgencyServiceImpl implements AgencyService { } + @Override + public UsingCommunityStatsResultDTO usingCommunityStats(String orgId, String orgType) { + String customerId = EpmetRequestHolder.getLoginUserCustomerId(); + String userId = EpmetRequestHolder.getLoginUserId(); + + // 所属组织的上级 + String agencyOrgIdPath = null; + if (StringUtils.isBlank(orgId)) { + // 没有传参数,使用当前登录人员所属的组织去查询 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); + if (staffInfo == null) { + String errorMsg = String.format("查询当前工作人员信息失败。staffId:%s", userId); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), errorMsg, errorMsg); + } + + orgId = staffInfo.getAgencyId(); + orgType = "agency"; + +// agencyOrgIdPath = getOrgIdPath(staffInfo); + } + + if ("agency".equals(orgType)) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + Date endTime = calendar.getTime(); + + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(orgId); + agencyOrgIdPath = getOrgIdPath(agencyInfo.getPids(), agencyInfo.getId()); + List currentUsingCommunityList = customerAgencyDao.getUsingCommunityList(customerId, orgId, agencyOrgIdPath, null); + List preferUsingCommunityList = customerAgencyDao.getUsingCommunityList(customerId, orgId, agencyOrgIdPath, endTime); + return new UsingCommunityStatsResultDTO(currentUsingCommunityList.size(), currentUsingCommunityList.size() - preferUsingCommunityList.size()); + } else if ("grid".equals(orgType)) { + // 网格下不会有该数据,给个0 + return new UsingCommunityStatsResultDTO(0, 0); + } + + return null; + } + + private String getOrgIdPath(String orgPids, String orgId) { + if (StringUtils.isBlank(orgPids) || "0".equals(orgPids)) { + return orgId; + } + + return orgPids.concat(":").concat(orgId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 31aa88b033..56b87d06fa 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -8,6 +8,7 @@ import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.HouseQrcodeEnum; @@ -34,17 +35,17 @@ import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.*; import com.epmet.dto.*; import com.epmet.dto.form.*; +import com.epmet.dto.form.stats.UserHouseStatsQueryFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.*; import com.epmet.enums.*; -import com.epmet.feign.EpmetAdminOpenFeignClient; -import com.epmet.feign.EpmetCommonServiceOpenFeignClient; -import com.epmet.feign.EpmetUserOpenFeignClient; -import com.epmet.feign.OssFeignClient; +import com.epmet.feign.*; import com.epmet.model.HouseInfoModel; import com.epmet.model.ImportHouseInfoListener; +import com.epmet.redis.CustomerAgencyRedis; import com.epmet.redis.IcHouseRedis; import com.epmet.service.*; +import com.epmet.stats.UserHouseStatsResultDTO; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.cache.Cache; @@ -68,6 +69,7 @@ import java.awt.image.BufferedImage; import java.io.*; import java.net.URLEncoder; import java.text.NumberFormat; +import java.time.LocalDate; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; @@ -132,6 +134,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { @Autowired private IcBuildingUnitDao icBuildingUnitDao; + @Autowired + private DataReportOpenFeignClient dataReportOpenFeignClient; + @Override @Transactional(rollbackFor = Exception.class) @@ -718,6 +723,17 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { resultDTO.setWscHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getWscHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getWscHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); resultDTO.setOrgId(formDTO.getOrgId()); resultDTO.setOrgType(formDTO.getOrgType()); + + // 加载上个月,该组织的人房统计信息,并且计算较上月信息 + Date lastDayOfLastMonth = DateUtils.getLastDayOfMonth(DateUtils.addDateMonths(new Date(), -1)); + UserHouseStatsQueryFormDTO form = new UserHouseStatsQueryFormDTO(formDTO.getOrgId(), formDTO.getOrgType(), DateUtils.format(lastDayOfLastMonth, "yyyyMMdd")); + UserHouseStatsResultDTO lastMonthUserHouseStats = getResultDataOrThrowsException(dataReportOpenFeignClient.getUserHouseDailyStatsByDateId(form), ServiceConstant.DATA_REPORT_SERVER, + EpmetErrorCode.SERVER_ERROR.getCode(), null, null); + + resultDTO.setHouseTotalJSY(resultDTO.getHouseTotal() - lastMonthUserHouseStats.getHouseTotal()); + resultDTO.setCzHouseTotalJSY(resultDTO.getCzHouseTotal() - lastMonthUserHouseStats.getCzHouseTotal()); + resultDTO.setXzHouseTotalJSY(resultDTO.getXzHouseTotal() - lastMonthUserHouseStats.getXzHouseTotal()); + resultDTO.setZzHouseTotalJSY(resultDTO.getZzHouseTotal() - lastMonthUserHouseStats.getZzHouseTotal()); return resultDTO; } @@ -927,6 +943,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { houseDTO.setOrgId(id); houseList.add(houseChart(houseDTO)); } + //start 2022.11.17需求:http://zentao.elinkservice.cn/story-view-718.html + //原来饼图是:居民总数、常住人口数、流动人口数 后改为下面的人户状况饼图,后面如果所有客户都上线了,就把第2步的查询注释掉。 //2.直属下级列表的居民数据 UserChartFormDTO userDTO = new UserChartFormDTO(); userDTO.setOrgType(orgType); @@ -935,6 +953,15 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { if (!userResult.success()) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民人房统计数据失败" + userResult.getInternalMsg(), userResult.getMsg()); } + //end + //3.居民总数、人户一致、人在户不在、户在人不在,没填写是暂不清楚 + RHZKStatisticsFormDTO rhzkStatisticsFormDTO = new RHZKStatisticsFormDTO(); + rhzkStatisticsFormDTO.setOrgIds(idList); + rhzkStatisticsFormDTO.setOrgType(orgType); + Result> rhzkResult = epmetUserOpenFeignClient.renHuCondition(rhzkStatisticsFormDTO); + if (!rhzkResult.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民人户状况统计数据失败" + rhzkResult.getInternalMsg(), rhzkResult.getMsg()); + } //3.汇总封装数据 SubUserHouseListResultDTO dto = null; for (String id : idList) { @@ -964,6 +991,35 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { dto.setLdUserRatio(u.getLdUserRatio()); } } + + // 为每一个子级组织,查询开通了多少个社区 + if ("agency".equals(dto.getOrgType())) { + AgencyService agencyService = SpringContextUtils.getBean(AgencyService.class); + if (agencyService != null) { + UsingCommunityStatsResultDTO usingCommunityStats = agencyService.usingCommunityStats(dto.getOrgId(), dto.getOrgType()); + if (usingCommunityStats != null) { + dto.setUsingCommunityNum(usingCommunityStats.getUsingCommunityNum()); + } + } + } else if ("grid".equals(dto.getOrgType())) { + // 网格这项数据为0 + dto.setUsingCommunityNum(0); + } + for (RHZKStatisticsResultDTO r : rhzkResult.getData()) { + if (StringUtils.isNotBlank(r.getOrgId())){ + if (r.getOrgId().equals(id)){ + dto.setRhyzUserTotal(r.getRhyzUserTotal()); + dto.setRhyzUserRatio(r.getRhyzUserRatio()); + dto.setRzhbzUserTotal(r.getRzhbzUserTotal()); + dto.setRzhbzUserRatio(r.getRzhbzUserRatio()); + dto.setHzrbzUserTotal(r.getHzrbzUserTotal()); + dto.setHzrbzUserRatio(r.getHzrbzUserRatio()); + dto.setZbqcUserTotal(r.getZbqcUserTotal()); + dto.setZbqcUserRatio(r.getZbqcUserRatio()); + dto.setUserTotal(r.getUserTotal()); + } + } + } list.add(dto); } return list; @@ -1365,5 +1421,62 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { return new PageData<>(list, pageInfo.getTotal()); } + @Override + public PageData usingCommunityUserHouseStats(String orgId, String orgType, Integer pageNo, Integer pageSize) { + + String customerId = EpmetRequestHolder.getLoginUserCustomerId(); + + if (StringUtils.isBlank(orgId)) { + // 没有传参数,使用当前登录人员所属的组织去查询 + String userId = EpmetRequestHolder.getLoginUserId(); + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); + if (staffInfo == null) { + String errorMsg = String.format("查询当前工作人员信息失败。staffId:%s", userId); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), errorMsg, errorMsg); + } + orgId = staffInfo.getAgencyId(); + orgType = "agency"; + } + + PageHelper.startPage(pageNo, pageSize); + List communityIds = customerAgencyDao.getUsingCommunityList(customerId, orgId, CustomerOrgRedis.getOrgIdPath(orgId, orgType), null); + // List communityIds = customerAgencyDao.getCommunitysByOrgIdPath(customerId, orgId, CustomerOrgRedis.getOrgIdPath(orgId, orgType)); + + + // 填充组织信息 + Map communityMap = communityIds.stream().collect(Collectors.toMap(id -> id, id -> concatAgencyNamePath(id))); + List communityUserHouseStats = houseUserChartList(communityIds, communityMap, "agency"); + + return new PageData(communityUserHouseStats, new PageInfo<>(communityIds).getTotal()); + } + + public String concatAgencyNamePath(String agencyId) { + List agencyNamePathList = new ArrayList(); + + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); + if (agencyInfo == null) { + return null; + } + + + String pidsStr = agencyInfo.getPids(); + if (StringUtils.isBlank(pidsStr)) { + // 没有pids,是顶级,直接返回 + agencyNamePathList.add(agencyInfo.getOrganizationName()); + return String.join("-", agencyNamePathList); + } + + String[] pidList = pidsStr.split(":"); + for (String pAgencyId : pidList) { + AgencyInfoCache pAgencyInfo = CustomerOrgRedis.getAgencyInfo(pAgencyId); + if (pAgencyInfo == null) { + continue; + } + agencyNamePathList.add(pAgencyInfo.getOrganizationName()); + } + // 最后把自己加上 + agencyNamePathList.add(agencyInfo.getOrganizationName()); + return String.join("-", agencyNamePathList); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 8493df5d81..d221f07b12 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -1011,4 +1011,33 @@ LIMIT 1 + + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index 0120d31bb0..326940bdd9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -160,7 +160,8 @@ AND a.DEL_FLAG = '0' - ORDER BY CAST(a.NEIGHBOR_HOOD_NAME AS SIGNED),CONVERT(a.NEIGHBOR_HOOD_NAME using gbk) + ORDER BY a.GRID_ID asc, + CAST(a.NEIGHBOR_HOOD_NAME AS SIGNED),CONVERT(a.NEIGHBOR_HOOD_NAME using gbk) select ic_resi_user.id as icResiUserId, @@ -200,9 +201,9 @@ AND ( - NAME = #{keyword} - or MOBILE = #{keyword} - or ID_CARD = #{keyword} + NAME like concat('%', #{keyword},'%') + or MOBILE like concat('%', #{keyword},'%') + or ID_CARD like concat('%', #{keyword},'%') ) @@ -212,13 +213,26 @@ ${groupTableName}.ID - ORDER BY - IC_RESI_USER.GRID_ID desc, - IC_RESI_USER.VILLAGE_ID ASC, - IC_RESI_USER.BUILD_ID ASC, - IC_RESI_USER.UNIT_ID ASC, - IC_RESI_USER.HOME_ID ASC, - IC_RESI_USER.ID ASC + + + ORDER BY + field( IC_RESI_USER.GRID_ID, '1537272060187049986', '1537272342477508609', '1537275342477501111', '1593432493598076929' ), + IC_RESI_USER.VILLAGE_ID ASC, + IC_RESI_USER.BUILD_ID ASC, + IC_RESI_USER.UNIT_ID ASC, + IC_RESI_USER.HOME_ID ASC, + IC_RESI_USER.ID ASC + + + ORDER BY + IC_RESI_USER.GRID_ID desc, + IC_RESI_USER.VILLAGE_ID ASC, + IC_RESI_USER.BUILD_ID ASC, + IC_RESI_USER.UNIT_ID ASC, + IC_RESI_USER.HOME_ID ASC, + IC_RESI_USER.ID ASC + + @@ -1359,6 +1373,18 @@ AND (is_floating != '0' or is_floating is null) + + AND RHZK = 'rhyz' + + + AND RHZK = 'rzhbz' + + + AND RHZK = 'hzrbz' + + + AND(RHZK = '' or RHZK IS null) + AND (agency_id = #{orgId} OR pids LIKE CONCAT('%', #{orgId}, '%')) @@ -1402,6 +1428,41 @@ AND ID_CARD = #{idCard} + + +