Browse Source

-修改:可视化-人房信息统计:子级人房信息统计,增加"开通社区数"的返回

master
wangxianzhang 3 years ago
parent
commit
8c02d2ea8a
  1. 15
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UsingCommunityStatsFormDTO.java
  2. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubUserHouseListResultDTO.java
  3. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UsingCommunityStatsResultDTO.java
  4. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  5. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  6. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  7. 55
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  8. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  9. 17
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

15
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;
}

5
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;
}

21
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;
}

11
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<List<CustomerTreeDTO>>().ok(agencyService.getCustomerTree(tokenDto));
}
/**
* 开通平台的社区数统计
* @return
*/
@RequestMapping("usingCommunityStats")
public Result<UsingCommunityStatsResultDTO> usingCommunityStats(@RequestBody UsingCommunityStatsFormDTO input) {
String orgId = input.getOrgId();
String orgType = input.getOrgType();
return new Result<UsingCommunityStatsResultDTO>().ok(agencyService.usingCommunityStats(orgId, orgType));
}
}

9
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> {
*/
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);
}

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java

@ -199,4 +199,9 @@ public interface AgencyService {
*/
List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto);
/**
* 开通平台的社区数统计
* @return
*/
UsingCommunityStatsResultDTO usingCommunityStats(String orgId, String orgType);
}

55
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);
}
}

14
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;

17
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -1011,4 +1011,21 @@
LIMIT 1
</select>
<!--开通社区数统计-->
<select id="getUsingCommunityStats" resultType="java.lang.Integer">
select count(1)
from (select ca.ID
, ca.ORGANIZATION_NAME
, count(csa.ID) community_count
from customer_agency ca
inner join customer_staff_agency csa on (ca.ID = csa.AGENCY_ID and csa.DEL_FLAG = 0)
where ca.DEL_FLAG = 0
and ca.LEVEL = 'community'
<if test="endDate != null">
and csa.CREATED_TIME <![CDATA[<]]> #{endDate}
</if>
and (ca.ID = #{agencyId} or ca.PIDS like CONCAT(#{agencyOrgIdPath}, '%'))
group by ca.ID, ca.ORGANIZATION_NAME
having community_count > 0) t
</select>
</mapper>

Loading…
Cancel
Save