|
|
@ -1,15 +1,21 @@ |
|
|
|
package com.epmet.service.evaluationindex.extract.toscreen.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
|
import com.epmet.constant.OrgTypeConstant; |
|
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; |
|
|
|
import com.epmet.dto.extract.result.OrgStatisticsResultDTO; |
|
|
|
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenGovernRankDataEntity; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectMainDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.toscreen.GovernRankDataExtractService; |
|
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyService; |
|
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenGovernRankDataService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
@ -21,6 +27,7 @@ import java.util.List; |
|
|
|
* @dscription |
|
|
|
* @date 2020/9/24 14:31 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class GovernRankDataExtractServiceImpl implements GovernRankDataExtractService { |
|
|
|
@Autowired |
|
|
|
private ScreenGovernRankDataService screenGovernRankDataService; |
|
|
@ -28,37 +35,138 @@ public class GovernRankDataExtractServiceImpl implements GovernRankDataExtractSe |
|
|
|
private FactIndexGovrnAblityOrgMonthlyService factIndexGovrnAblityOrgMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactIndexGovrnAblityGridMonthlyService factIndexGovrnAblityGridMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactOriginProjectLogDailyService factOriginProjectLogDailyService; |
|
|
|
@Autowired |
|
|
|
private FactOriginProjectMainDailyService factOriginProjectMainDailyService; |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
String monthId = "202006"; |
|
|
|
System.out.println(monthId.substring(0,4)); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void extractGridData(String customerId, String monthId) { |
|
|
|
List<ScreenGovernRankDataEntity> list = screenGovernRankDataService.initList(customerId, OrgTypeConstant.GRID, null); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
list.forEach(entity -> { |
|
|
|
entity.setYearId(monthId.substring(NumConstant.ZERO, NumConstant.FOUR)); |
|
|
|
entity.setMonthId(monthId); |
|
|
|
}); |
|
|
|
List<FactIndexGovrnAblityGridMonthlyEntity> gridList = factIndexGovrnAblityGridMonthlyService.getGridByCustomer(customerId, monthId); |
|
|
|
list.forEach(entity -> gridList.stream().filter(gridAblity -> entity.getOrgId().equals(gridAblity.getGridId())).forEach(grid -> { |
|
|
|
BigDecimal total = new BigDecimal(grid.getProjectTotal()); |
|
|
|
entity.setYearId(grid.getYearId()); |
|
|
|
entity.setMonthId(grid.getMonthId()); |
|
|
|
//TODO 响应率
|
|
|
|
//解决率
|
|
|
|
list.forEach(entity -> gridList.stream().filter(gridAbility -> entity.getOrgId().equals(gridAbility.getGridId())).forEach(grid -> { |
|
|
|
|
|
|
|
BigDecimal resolveCount = new BigDecimal(grid.getResolveProjectCount()); |
|
|
|
entity.setResolvedRatio(resolveCount.divide(total, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
//自治率
|
|
|
|
BigDecimal selfCount = new BigDecimal(grid.getSelfSolveProjectCount()); |
|
|
|
entity.setGovernRatio(selfCount.divide(total, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
if(grid.getResolveProjectCount()!= NumConstant.ZERO) { |
|
|
|
entity.setGovernRatio(selfCount.divide(resolveCount, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
//满意率
|
|
|
|
entity.setSatisfactionRatio(grid.getSatisfactionRatio()); |
|
|
|
})); |
|
|
|
|
|
|
|
//响应率 响应次数/流转到网格的次数
|
|
|
|
List<OrgStatisticsResultDTO> responseList = factOriginProjectLogDailyService.getGridResponse(customerId, monthId); |
|
|
|
list.forEach(entity -> responseList.stream().filter(response -> entity.getOrgId().equals(response.getOrgId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setResponseRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
|
|
|
|
//解决率 已解决项目数/办结项目数
|
|
|
|
List<OrgStatisticsResultDTO> resolveList = factOriginProjectMainDailyService.getGridResolveProject(customerId, monthId); |
|
|
|
list.forEach(entity -> resolveList.stream().filter(resolve -> entity.getOrgId().equals(resolve.getOrgId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setResolvedRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
|
|
|
|
screenGovernRankDataService.delAndSaveRankData(customerId, OrgTypeConstant.GRID, monthId, IndexCalConstant.DELETE_SIZE, list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void extractCommunityData(String customerId, String monthId) { |
|
|
|
List<ScreenGovernRankDataEntity> list = screenGovernRankDataService.initList(customerId, OrgTypeConstant.AGENCY, OrgTypeConstant.COMMUNITY); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
list.forEach(entity -> { |
|
|
|
entity.setYearId(monthId.substring(NumConstant.ZERO, NumConstant.FOUR)); |
|
|
|
entity.setMonthId(monthId); |
|
|
|
}); |
|
|
|
List<FactIndexGovrnAblityOrgMonthlyEntity> orgList = factIndexGovrnAblityOrgMonthlyService.getOrgByCustomer(customerId, monthId, |
|
|
|
OrgTypeConstant.COMMUNITY); |
|
|
|
list.forEach(entity -> orgList.stream().filter(orgAbility -> entity.getOrgId().equals(orgAbility.getAgencyId())).forEach(org -> { |
|
|
|
//满意率
|
|
|
|
entity.setSatisfactionRatio(org.getSatisfactionRatio()); |
|
|
|
})); |
|
|
|
|
|
|
|
//响应率 响应次数/流转到网格的次数
|
|
|
|
List<OrgStatisticsResultDTO> responseList = factOriginProjectLogDailyService.getOrgResponse(customerId, monthId, OrgTypeConstant.COMMUNITY); |
|
|
|
list.forEach(entity -> responseList.stream().filter(response -> entity.getOrgId().equals(response.getAgencyId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setResponseRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
//自制率 自治项目数/办结项目数
|
|
|
|
List<OrgStatisticsResultDTO> selfList = factOriginProjectMainDailyService.getSelfProject(customerId, monthId, OrgTypeConstant.COMMUNITY); |
|
|
|
list.forEach(entity -> selfList.stream().filter(self -> entity.getOrgId().equals(self.getAgencyId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setGovernRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
//解决率 已解决项目数/办结项目数
|
|
|
|
List<OrgStatisticsResultDTO> resolveList = factOriginProjectMainDailyService.getResolveProject(customerId, monthId, |
|
|
|
OrgTypeConstant.COMMUNITY); |
|
|
|
list.forEach(entity -> resolveList.stream().filter(resolve -> entity.getOrgId().equals(resolve.getAgencyId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setResolvedRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
screenGovernRankDataService.delAndSaveRankData(customerId, OrgTypeConstant.AGENCY, monthId, IndexCalConstant.DELETE_SIZE, list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void extractStreetData(String customerId, String monthId) { |
|
|
|
List<ScreenGovernRankDataEntity> list = screenGovernRankDataService.initList(customerId, OrgTypeConstant.AGENCY, OrgTypeConstant.STREET); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
list.forEach(entity -> { |
|
|
|
entity.setYearId(monthId.substring(NumConstant.ZERO, NumConstant.FOUR)); |
|
|
|
entity.setMonthId(monthId); |
|
|
|
}); |
|
|
|
List<FactIndexGovrnAblityOrgMonthlyEntity> orgList = factIndexGovrnAblityOrgMonthlyService.getOrgByCustomer(customerId, monthId, |
|
|
|
OrgTypeConstant.STREET); |
|
|
|
list.forEach(entity -> orgList.stream().filter(orgAbility -> entity.getOrgId().equals(orgAbility.getAgencyId())).forEach(org -> { |
|
|
|
//满意率
|
|
|
|
entity.setSatisfactionRatio(org.getSatisfactionRatio()); |
|
|
|
})); |
|
|
|
|
|
|
|
//响应率 响应次数/流转到网格的次数
|
|
|
|
List<OrgStatisticsResultDTO> responseList = factOriginProjectLogDailyService.getOrgResponse(customerId, monthId, OrgTypeConstant.STREET); |
|
|
|
list.forEach(entity -> responseList.stream().filter(response -> entity.getOrgId().equals(response.getAgencyId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setResponseRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
//自制率 自治项目数/办结项目数
|
|
|
|
List<OrgStatisticsResultDTO> selfList = factOriginProjectMainDailyService.getSelfProject(customerId, monthId, OrgTypeConstant.STREET); |
|
|
|
list.forEach(entity -> selfList.stream().filter(self -> entity.getOrgId().equals(self.getAgencyId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setGovernRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
//解决率 已解决项目数/办结项目数
|
|
|
|
List<OrgStatisticsResultDTO> resolveList = factOriginProjectMainDailyService.getResolveProject(customerId, monthId, |
|
|
|
OrgTypeConstant.STREET); |
|
|
|
list.forEach(entity -> resolveList.stream().filter(resolve -> entity.getOrgId().equals(resolve.getAgencyId())).forEach(dto -> { |
|
|
|
BigDecimal sum = new BigDecimal(dto.getSum()); |
|
|
|
BigDecimal count = new BigDecimal(dto.getCount()); |
|
|
|
entity.setResolvedRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP)); |
|
|
|
})); |
|
|
|
screenGovernRankDataService.delAndSaveRankData(customerId, OrgTypeConstant.AGENCY, monthId, IndexCalConstant.DELETE_SIZE, list); |
|
|
|
} |
|
|
|
} |
|
|
|