|
@ -7,13 +7,16 @@ import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.datareport.dao.screen.ScreenIndexDataMonthlyDao; |
|
|
import com.epmet.datareport.dao.screen.ScreenIndexDataMonthlyDao; |
|
|
import com.epmet.datareport.dao.screen.ScreenIndexDataYearlyDao; |
|
|
import com.epmet.datareport.dao.screen.ScreenIndexDataYearlyDao; |
|
|
import com.epmet.datareport.service.screen.IndexService; |
|
|
import com.epmet.datareport.service.screen.IndexService; |
|
|
|
|
|
import com.epmet.datareport.utils.DateUtils; |
|
|
import com.epmet.screen.dto.form.MonthBarchartFormDTO; |
|
|
import com.epmet.screen.dto.form.MonthBarchartFormDTO; |
|
|
import com.epmet.screen.dto.form.MonthPieChartFormDTO; |
|
|
import com.epmet.screen.dto.form.MonthPieChartFormDTO; |
|
|
import com.epmet.screen.dto.form.SubAgencyIndexRankFormDTO; |
|
|
import com.epmet.screen.dto.form.SubAgencyIndexRankFormDTO; |
|
|
import com.epmet.screen.dto.form.YearAverageIndexFormDTO; |
|
|
import com.epmet.screen.dto.form.YearAverageIndexFormDTO; |
|
|
import com.epmet.screen.dto.result.*; |
|
|
import com.epmet.screen.dto.result.*; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
@ -36,6 +39,8 @@ public class IndexServiceImpl implements IndexService { |
|
|
private ScreenIndexDataMonthlyDao screenIndexDataMonthlyDao; |
|
|
private ScreenIndexDataMonthlyDao screenIndexDataMonthlyDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private PartyMemberLeadServiceImpl partyMemberLeadServiceImpl; |
|
|
private PartyMemberLeadServiceImpl partyMemberLeadServiceImpl; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DateUtils dateUtils; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 1、年度平均指数 |
|
|
* @Description 1、年度平均指数 |
|
@ -62,7 +67,16 @@ public class IndexServiceImpl implements IndexService { |
|
|
@DataSource(value = DataSourceConstant.STATS,datasourceNameFromArg = true) |
|
|
@DataSource(value = DataSourceConstant.STATS,datasourceNameFromArg = true) |
|
|
@Override |
|
|
@Override |
|
|
public MonthPieChartResultDTO monthPieChart(MonthPieChartFormDTO monthPieChartFormDTO) { |
|
|
public MonthPieChartResultDTO monthPieChart(MonthPieChartFormDTO monthPieChartFormDTO) { |
|
|
MonthPieChartResultDTO monthPieChartResultDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId()); |
|
|
|
|
|
|
|
|
MonthPieChartResultDTO monthPieChartResultDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId(),null); |
|
|
|
|
|
String monthId = dateUtils.getCurrentMonthId(); |
|
|
|
|
|
int time = NumConstant.TWELVE; |
|
|
|
|
|
//保证获取月度指数数据的最大可能性
|
|
|
|
|
|
while(null == monthPieChartResultDTO && time > NumConstant.ONE){ |
|
|
|
|
|
time--; |
|
|
|
|
|
monthId = dateUtils.getPreviousMonthIdByDest(null,monthId); |
|
|
|
|
|
monthPieChartResultDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId(),monthId); |
|
|
|
|
|
} |
|
|
if (null == monthPieChartResultDTO){ |
|
|
if (null == monthPieChartResultDTO){ |
|
|
return new MonthPieChartResultDTO(); |
|
|
return new MonthPieChartResultDTO(); |
|
|
} |
|
|
} |
|
@ -85,7 +99,7 @@ public class IndexServiceImpl implements IndexService { |
|
|
List<Double> totalIndexData = new ArrayList<>(); |
|
|
List<Double> totalIndexData = new ArrayList<>(); |
|
|
// 1. x轴
|
|
|
// 1. x轴
|
|
|
result.setXAxis(partyMemberLeadServiceImpl.getXPro()); |
|
|
result.setXAxis(partyMemberLeadServiceImpl.getXPro()); |
|
|
// 2. 查询近一年的指数值【不包括本月】
|
|
|
// 2. 查询近一年的指数值【包括本月】
|
|
|
List<MonthBarchartResult> monthBarchartResults = screenIndexDataMonthlyDao.selectMonthBarchart(monthBarchartFormDTO.getAgencyId()); |
|
|
List<MonthBarchartResult> monthBarchartResults = screenIndexDataMonthlyDao.selectMonthBarchart(monthBarchartFormDTO.getAgencyId()); |
|
|
if (monthBarchartResults.size() == NumConstant.ZERO){ |
|
|
if (monthBarchartResults.size() == NumConstant.ZERO){ |
|
|
for (int i = NumConstant.ZERO; i <= NumConstant.TWELVE; i++) { |
|
|
for (int i = NumConstant.ZERO; i <= NumConstant.TWELVE; i++) { |
|
@ -101,12 +115,48 @@ public class IndexServiceImpl implements IndexService { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
List<MonthBarchartResult> collect = monthBarchartResults.stream().sorted(Comparator.comparing(MonthBarchartResult::getMonthId)).collect(Collectors.toList()); |
|
|
List<MonthBarchartResult> collect = monthBarchartResults.stream().sorted(Comparator.comparing(MonthBarchartResult::getMonthId)).collect(Collectors.toList()); |
|
|
collect.forEach(month -> { |
|
|
//升序 当前月份在队尾
|
|
|
|
|
|
List<String> _ymList = dateUtils.getXpro().keySet().stream().collect(Collectors.toList()); |
|
|
|
|
|
//针对集合collect的游标
|
|
|
|
|
|
int cursor = NumConstant.ZERO; |
|
|
|
|
|
//针对X轴,数据集合不全则进行数据填充
|
|
|
|
|
|
a:for(int i = NumConstant.ZERO; i < _ymList.size(); i++){ |
|
|
|
|
|
//这里的collect必须是有序且升序的
|
|
|
|
|
|
if(cursor >= collect.size()) break a; |
|
|
|
|
|
//如果存在过期数据,即从数据库中查询出超出横坐标左边界的月份值
|
|
|
|
|
|
if(Integer.parseInt(collect.get(cursor).getMonthId()) < Integer.parseInt(_ymList.get(NumConstant.ZERO))) { |
|
|
|
|
|
//控制当前循环重复进行
|
|
|
|
|
|
i--; |
|
|
|
|
|
//忽略过期数据
|
|
|
|
|
|
cursor++; |
|
|
|
|
|
continue ; |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.equals(collect.get(cursor).getMonthId(),_ymList.get(i))){ |
|
|
|
|
|
//SET DEFAULT
|
|
|
|
|
|
serviceAbilityData.add(NumConstant.ZERO_DOT_ZERO); |
|
|
|
|
|
partyDevAbilityData.add(NumConstant.ZERO_DOT_ZERO); |
|
|
|
|
|
governAbilityData.add(NumConstant.ZERO_DOT_ZERO); |
|
|
|
|
|
totalIndexData.add(NumConstant.ZERO_DOT_ZERO); |
|
|
|
|
|
//保持cursor不变
|
|
|
|
|
|
}else{ |
|
|
|
|
|
MonthBarchartResult data = collect.get(cursor); |
|
|
|
|
|
//SET DATA
|
|
|
|
|
|
serviceAbilityData.add(null == data.getServiceAbility() ? NumConstant.ZERO_DOT_ZERO : data.getServiceAbility()); |
|
|
|
|
|
partyDevAbilityData.add(null == data.getPartyDevAbility() ? NumConstant.ZERO_DOT_ZERO : data.getPartyDevAbility()); |
|
|
|
|
|
governAbilityData.add(null == data.getGovernAbility() ? NumConstant.ZERO_DOT_ZERO : data.getGovernAbility()); |
|
|
|
|
|
totalIndexData.add(null == data.getIndexTotal() ? NumConstant.ZERO_DOT_ZERO : data.getIndexTotal()); |
|
|
|
|
|
//统计日期一致后移动游标
|
|
|
|
|
|
cursor++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*collect.forEach(month -> { |
|
|
serviceAbilityData.add(null == month.getServiceAbility() ? NumConstant.ZERO_DOT_ZERO : month.getServiceAbility()); |
|
|
serviceAbilityData.add(null == month.getServiceAbility() ? NumConstant.ZERO_DOT_ZERO : month.getServiceAbility()); |
|
|
partyDevAbilityData.add(null == month.getPartyDevAbility() ? NumConstant.ZERO_DOT_ZERO : month.getPartyDevAbility()); |
|
|
partyDevAbilityData.add(null == month.getPartyDevAbility() ? NumConstant.ZERO_DOT_ZERO : month.getPartyDevAbility()); |
|
|
governAbilityData.add(null == month.getGovernAbility() ? NumConstant.ZERO_DOT_ZERO : month.getGovernAbility()); |
|
|
governAbilityData.add(null == month.getGovernAbility() ? NumConstant.ZERO_DOT_ZERO : month.getGovernAbility()); |
|
|
totalIndexData.add(null == month.getIndexTotal() ? NumConstant.ZERO_DOT_ZERO : month.getIndexTotal()); |
|
|
totalIndexData.add(null == month.getIndexTotal() ? NumConstant.ZERO_DOT_ZERO : month.getIndexTotal()); |
|
|
}); |
|
|
});*/ |
|
|
result.setServiceAbilityData(serviceAbilityData); |
|
|
result.setServiceAbilityData(serviceAbilityData); |
|
|
result.setPartyDevAbilityData(partyDevAbilityData); |
|
|
result.setPartyDevAbilityData(partyDevAbilityData); |
|
|
result.setGovernAbilityData(governAbilityData); |
|
|
result.setGovernAbilityData(governAbilityData); |
|
@ -127,7 +177,7 @@ public class IndexServiceImpl implements IndexService { |
|
|
int yearId = now.getYear(); |
|
|
int yearId = now.getYear(); |
|
|
subAgencyIndexRankFormDTO.setYearId(String.valueOf(yearId)); |
|
|
subAgencyIndexRankFormDTO.setYearId(String.valueOf(yearId)); |
|
|
List<SubAgencyIndexRankResultDTO> subAgencyIndexRankResultDTOS = screenIndexDataMonthlyDao.selectSubAgencyIndexRank(subAgencyIndexRankFormDTO); |
|
|
List<SubAgencyIndexRankResultDTO> subAgencyIndexRankResultDTOS = screenIndexDataMonthlyDao.selectSubAgencyIndexRank(subAgencyIndexRankFormDTO); |
|
|
if (subAgencyIndexRankResultDTOS.size() == NumConstant.ZERO){ |
|
|
if (CollectionUtils.isEmpty(subAgencyIndexRankResultDTOS)){ |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
return subAgencyIndexRankResultDTOS; |
|
|
return subAgencyIndexRankResultDTOS; |
|
|