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/SubUserHouseListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubUserHouseListResultDTO.java index 45ded6601b..dc5bbe6b52 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 @@ -79,4 +79,9 @@ public class SubUserHouseListResultDTO implements Serializable { */ private Double ldUserRatio = 0.0; + /** + * 开通平台的社区数 + */ + private Integer usingCommunityNum; + } 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 3d86d05fb6..2ab19bc5c1 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 @@ -613,5 +613,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/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 37e8d93c98..0e90d851e3 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,13 @@ 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 + */ + Integer getUsingCommunityStats(@Param("agencyId") String agencyId, @Param("agencyOrgIdPath") String agencyOrgIdPath, @Param("endDate") Date endDate); } 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/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index 10499f4b52..7896a7854f 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; @@ -1114,4 +1112,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()); + Integer currentUsingCommunityCount = customerAgencyDao.getUsingCommunityStats(orgId, agencyOrgIdPath, null); + Integer prefersUsingCommunityCount = customerAgencyDao.getUsingCommunityStats(orgId, agencyOrgIdPath, endTime); + return new UsingCommunityStatsResultDTO(currentUsingCommunityCount, currentUsingCommunityCount - prefersUsingCommunityCount); + } 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 d5daa597e8..d8389ffc37 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 @@ -977,6 +977,20 @@ 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); + } list.add(dto); } return list; 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..9a0dfa1d51 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,21 @@ LIMIT 1 + +