|
|
@ -20,6 +20,7 @@ import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
@ -112,7 +113,7 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService |
|
|
|
} |
|
|
|
BranchBuildTrendResultDTO result = new BranchBuildTrendResultDTO(); |
|
|
|
//生成近十二个月的横坐标数组
|
|
|
|
Map<String,String> monthMap = getX(); |
|
|
|
Map<String,String> monthMap = dateUtils.getXpro(); |
|
|
|
result.setXAxis(monthMap.values().stream().collect(Collectors.toList())); |
|
|
|
|
|
|
|
List<BranchTrendSeriesDataResultDTO> dataArray = new LinkedList<>(); |
|
|
@ -155,12 +156,22 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService |
|
|
|
|
|
|
|
result.setSeriesData(dataArray); |
|
|
|
result.setLegend(null == result.getLegend() ? new ArrayList<>() : result.getLegend()); |
|
|
|
List<String> _ymList = monthMap.keySet().stream().collect(Collectors.toList()); |
|
|
|
//总组织次数
|
|
|
|
Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,param.getAgencyId(),monthMap.keySet().iterator().next()); |
|
|
|
//自旋一次
|
|
|
|
totalOrganizationCount = Optional.ofNullable(totalOrganizationCount).orElse( |
|
|
|
screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,param.getAgencyId(),_ymList.get(NumConstant.ONE)) |
|
|
|
); |
|
|
|
//总参与人数
|
|
|
|
Integer totalJoinUserCount = screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,param.getAgencyId(),monthMap.keySet().iterator().next()); |
|
|
|
result.setTotalOrganizationCount(null == totalOrganizationCount ? NumConstant.ZERO : totalOrganizationCount); |
|
|
|
result.setTotalJoinUserCount(null == totalJoinUserCount ? NumConstant.ZERO : totalJoinUserCount); |
|
|
|
//自旋一次
|
|
|
|
totalJoinUserCount = Optional.ofNullable(totalJoinUserCount).orElse( |
|
|
|
screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,param.getAgencyId(),_ymList.get(NumConstant.ONE)) |
|
|
|
); |
|
|
|
|
|
|
|
result.setTotalOrganizationCount(Optional.ofNullable(totalOrganizationCount).orElse(NumConstant.ZERO)); |
|
|
|
result.setTotalJoinUserCount(Optional.ofNullable(totalJoinUserCount).orElse(NumConstant.ZERO)); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -193,6 +204,15 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService |
|
|
|
List<BranchBuildOrderByCountResultDTO> orderList = |
|
|
|
screenPartyBranchDataDao.selectBranchDataByTypeOrder(param.getAgencyId(),param.getCategory(),param.getMonthId(),param.getBottomMonthId()); |
|
|
|
|
|
|
|
int time = NumConstant.TWELVE; |
|
|
|
while(CollectionUtils.isEmpty(orderList) && time > NumConstant.ONE){ |
|
|
|
time --; |
|
|
|
param.setMonthId(dateUtils.getPreviousMonthIdByDest(null,param.getMonthId())); |
|
|
|
orderList = |
|
|
|
screenPartyBranchDataDao.selectBranchDataByTypeOrder(param.getAgencyId(),param.getCategory(),param.getMonthId(),param.getBottomMonthId()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BranchBuildRankResultDTO result = new BranchBuildRankResultDTO(); |
|
|
|
result.setJoinData(new LinkedList<>()); |
|
|
|
result.setOrganizeData(new LinkedList<>()); |
|
|
@ -212,59 +232,6 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService |
|
|
|
return percentStr.concat(ModuleConstant.SYMBOL_PERCENT); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 返回当前月以及前十一个月,升序 |
|
|
|
* @param |
|
|
|
* @return Map<String,String> key:202001 value:1月 |
|
|
|
* @author wangc |
|
|
|
* @date 2020.08.19 12:46 |
|
|
|
**/ |
|
|
|
public Map<String,String> getX(){ |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMM"); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(new Date()); // 设置为当前时间
|
|
|
|
//calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月
|
|
|
|
String currentMonth = format.format(calendar.getTime()); |
|
|
|
Integer monthCounter = Integer.parseInt(currentMonth); |
|
|
|
Map<String,String> monthMap = new HashMap<>(); |
|
|
|
int i = NumConstant.ONE; |
|
|
|
while(i <= NumConstant.TWELVE){ |
|
|
|
|
|
|
|
if(monthCounter.toString().endsWith("00")){ |
|
|
|
monthCounter -= NumConstant.EIGHTY_EIGHT; |
|
|
|
} |
|
|
|
|
|
|
|
String abscissa = monthCounter.toString().substring(monthCounter.toString().length() - NumConstant.TWO); |
|
|
|
if(abscissa.startsWith("0")) { |
|
|
|
abscissa = abscissa.replace("0","").concat("月"); |
|
|
|
}else{ |
|
|
|
abscissa = abscissa.concat("月"); |
|
|
|
} |
|
|
|
monthMap.put(monthCounter.toString(),abscissa); |
|
|
|
monthCounter-- ; |
|
|
|
i++; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, String> result = Maps.newLinkedHashMap(); |
|
|
|
monthMap.entrySet().stream().sorted(Map.Entry.comparingByKey()) |
|
|
|
.forEachOrdered((e -> result.put(e.getKey(),e.getValue()))); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 得到上个月的monthId |
|
|
|
* @param |
|
|
|
* @return |
|
|
|
* @author wangc |
|
|
|
* @date 2020.08.20 10:19 |
|
|
|
**/ |
|
|
|
private String getPreviousMonthId(){ |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMM"); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(new Date()); // 设置为当前时间
|
|
|
|
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月
|
|
|
|
return format.format(calendar.getTime()); |
|
|
|
} |
|
|
|
} |
|
|
|