|
|
@ -1,21 +1,30 @@ |
|
|
|
package com.epmet.service.evaluationindex.indexcoll.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.constant.OrgTypeConstant; |
|
|
|
import com.epmet.dao.evaluationindex.extract.FactOriginProjectOrgPeriodDailyDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; |
|
|
|
import com.epmet.dto.extract.result.OrgStatisticsResultDTO; |
|
|
|
import com.epmet.dto.stats.DimAgencyDTO; |
|
|
|
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyEntity; |
|
|
|
import com.epmet.service.evaluationindex.extract.FactOriginProjectLogDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.FactOriginProjectMainDailyService; |
|
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyService; |
|
|
|
import com.epmet.service.evaluationindex.indexcoll.IndexCollCommunityService; |
|
|
|
import com.epmet.service.stats.DimAgencyService; |
|
|
|
import com.epmet.util.DimIdGenerator; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author zhaoqifeng |
|
|
@ -27,7 +36,9 @@ import java.util.List; |
|
|
|
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|
|
|
public class IndexCollCommunityServiceImpl implements IndexCollCommunityService { |
|
|
|
@Autowired |
|
|
|
private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao; |
|
|
|
private DimAgencyService dimAgencyService; |
|
|
|
@Autowired |
|
|
|
private FactIndexGovrnAblityOrgMonthlyService factIndexGovrnAblityOrgMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactOriginProjectLogDailyService factOriginProjectLogDailyService; |
|
|
|
@Autowired |
|
|
@ -36,19 +47,90 @@ public class IndexCollCommunityServiceImpl implements IndexCollCommunityService |
|
|
|
private FactOriginProjectMainDailyService factOriginProjectMainDailyService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveCommunityAbility() { |
|
|
|
public void saveCommunityAbility(String customerId, String dateId) { |
|
|
|
//当前日期前一天
|
|
|
|
Date date = DateUtils.getBeforeDay(new Date()); |
|
|
|
Date date = DateUtils.getBeforeDay(DateUtils.stringToDate(dateId, DateUtils.DATE_PATTERN_YYYYMMDD)); |
|
|
|
//获取日期相关维度
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); |
|
|
|
//获取社区列表
|
|
|
|
List<DimAgencyDTO>agencyList = dimAgencyService.getAgencyByLevel(customerId, OrgTypeConstant.COMMUNITY); |
|
|
|
//社区数据初始化
|
|
|
|
List<FactIndexGovrnAblityOrgMonthlyEntity> list = agencyList.stream().map(agency ->{ |
|
|
|
FactIndexGovrnAblityOrgMonthlyEntity entity = new FactIndexGovrnAblityOrgMonthlyEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setAgencyId(agency.getId()); |
|
|
|
entity.setParentId(agency.getPid()); |
|
|
|
entity.setYearId(dimId.getYearId()); |
|
|
|
entity.setQuarterId(dimId.getQuarterId()); |
|
|
|
entity.setMonthId(dimId.getMonthId()); |
|
|
|
entity.setDataType(OrgTypeConstant.COMMUNITY); |
|
|
|
entity.setTransferedCount(NumConstant.ZERO); |
|
|
|
entity.setClosedProjectCount(NumConstant.ZERO); |
|
|
|
entity.setRespProjectRatio(new BigDecimal(NumConstant.ZERO)); |
|
|
|
entity.setOverdueProjectRatio(new BigDecimal(NumConstant.ZERO)); |
|
|
|
entity.setClosedProjectRatio(new BigDecimal(NumConstant.ZERO)); |
|
|
|
entity.setSatisfactionRatio(new BigDecimal(NumConstant.ZERO)); |
|
|
|
entity.setHandleProjectRatio(new BigDecimal(NumConstant.ZERO)); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
//被吹哨次数统计
|
|
|
|
List<OrgStatisticsResultDTO> transferCount = factOriginProjectLogDailyService.getAgencyTransferCount(dimId.getMonthId(), "community"); |
|
|
|
List<OrgStatisticsResultDTO> transferCount = factOriginProjectLogDailyService.getAgencyTransferCount(customerId, dimId.getMonthId(), |
|
|
|
OrgTypeConstant.COMMUNITY); |
|
|
|
if (null != transferCount && !transferCount.isEmpty()) { |
|
|
|
list.forEach(entity -> transferCount.stream().filter(dto -> dto.getAgencyId().equals(entity.getAgencyId())).forEach(count -> { |
|
|
|
entity.setTransferedCount(count.getCount()); |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
//社区项目响应度
|
|
|
|
// List<OrgStatisticsResultDTO> responsiveness = factOriginProjectOrgPeriodDailyDao.selectResponsiveness(dimId.getMonthId(), "community",
|
|
|
|
// "agency");
|
|
|
|
List<OrgStatisticsResultDTO> responsiveness = factOriginProjectOrgPeriodDailyDao.selectResponsiveness(customerId, dimId.getMonthId(), |
|
|
|
OrgTypeConstant.COMMUNITY, OrgTypeConstant.AGENCY); |
|
|
|
if (null != responsiveness && !responsiveness.isEmpty()) { |
|
|
|
list.forEach(entity -> responsiveness.stream().filter(dto -> dto.getAgencyId().equals(entity.getAgencyId())).forEach(response -> { |
|
|
|
if (response.getCount() != NumConstant.ZERO) { |
|
|
|
BigDecimal count = new BigDecimal(response.getCount()); |
|
|
|
BigDecimal sum = new BigDecimal(response.getSum()); |
|
|
|
entity.setRespProjectRatio(sum.divide(count, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
//社区超期项目率
|
|
|
|
List<OrgStatisticsResultDTO> overdueCount = factOriginProjectMainDailyService.getOverdueCount(dimId.getMonthId()); |
|
|
|
List<OrgStatisticsResultDTO> overdueCount = factOriginProjectMainDailyService.getOverdueCount(customerId, dimId.getMonthId()); |
|
|
|
if (null != overdueCount && !overdueCount.isEmpty()) { |
|
|
|
list.forEach(entity -> overdueCount.stream().filter(dto -> dto.getAgencyId().equals(entity.getAgencyId())).forEach(overdue -> { |
|
|
|
if (overdue.getSum() != NumConstant.ZERO) { |
|
|
|
BigDecimal count = new BigDecimal(overdue.getCount()); |
|
|
|
BigDecimal sum = new BigDecimal(overdue.getSum()); |
|
|
|
entity.setOverdueProjectRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
//社区办结项目满意度
|
|
|
|
List<OrgStatisticsResultDTO> satisfaction = factOriginProjectLogDailyService.getSatisfaction(customerId, dimId.getMonthId(), OrgTypeConstant.COMMUNITY); |
|
|
|
if (null != satisfaction && !satisfaction.isEmpty()) { |
|
|
|
list.forEach(entity -> satisfaction.stream().filter(dto -> dto.getAgencyId().equals(entity.getAgencyId())).forEach(sa -> { |
|
|
|
if (sa.getCount() != NumConstant.ZERO) { |
|
|
|
BigDecimal count = new BigDecimal(sa.getCount()); |
|
|
|
BigDecimal sum = new BigDecimal(sa.getSum()); |
|
|
|
entity.setOverdueProjectRatio(sum.divide(count, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
factIndexGovrnAblityOrgMonthlyService.deleteByCustomer(customerId, dimId.getMonthId(), OrgTypeConstant.COMMUNITY); |
|
|
|
factIndexGovrnAblityOrgMonthlyService.insertBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveCommunityPartyAbility(String customerId, String dateId) { |
|
|
|
//当前日期前一天
|
|
|
|
Date date = DateUtils.getBeforeDay(DateUtils.stringToDate(dateId, DateUtils.DATE_PATTERN_YYYYMMDD)); |
|
|
|
//获取日期相关维度
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); |
|
|
|
//获取社区列表
|
|
|
|
List<DimAgencyDTO>agencyList = dimAgencyService.getAgencyByLevel(customerId, OrgTypeConstant.COMMUNITY); |
|
|
|
//获取社区发文数量
|
|
|
|
} |
|
|
|
} |
|
|
|