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