Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/2021-04-28' into 2021-04-28

zouxuan 4 gadi atpakaļ
vecāks
revīzija
5f2bd80ee2

+ 15 - 43
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -36,8 +36,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.ym.mec.biz.dal.enums.IndexDataType.FINANCE_AMOUNT;
-import static com.ym.mec.biz.dal.enums.IndexDataType.VIP_GROUP_ONLINE_COURSE;
+import static com.ym.mec.biz.dal.enums.IndexDataType.*;
 import static com.ym.mec.biz.dal.enums.IndexErrorType.WAIT_CREATE_PAYMENT_CALENDER;
 
 @Service
@@ -112,11 +111,11 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 
 		Map<Date, Map<IndexDataType, Map<String, Integer>>> vipCategoryCourseListMap = new HashMap<>();
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains("VIP_GROUP_COURSE")||dataTypes.contains("VIP_GROUP_ONLINE_COURSE")||dataTypes.contains("VIP_GROUP_OFFLINE_COURSE")){
-			dataTypes.clear();
-			dataTypes.add("VIP_GROUP_COURSE");
-			dataTypes.add("VIP_GROUP_ONLINE_COURSE");
-			dataTypes.add("VIP_GROUP_OFFLINE_COURSE");
-			List<IndexBaseMonthData> indexBaseDataList = indexBaseMonthDataDao.getIndexBaseDataList(organIds, dataTypes, startDate.toString(), endDate.toString());
+			Set<String> vipDataTypes = new HashSet<>();
+			vipDataTypes.add("VIP_GROUP_COURSE");
+			vipDataTypes.add("VIP_GROUP_ONLINE_COURSE");
+			vipDataTypes.add("VIP_GROUP_OFFLINE_COURSE");
+			List<IndexBaseMonthData> indexBaseDataList = indexBaseMonthDataDao.getIndexBaseDataList(organIds, vipDataTypes, startDate.toString(), endDate.toString());
 			if(!CollectionUtils.isEmpty(indexBaseDataList)){
 				for (IndexBaseMonthData indexBaseMonthData : indexBaseDataList) {
 					if(StringUtils.isBlank(indexBaseMonthData.getExtendInfo())){
@@ -140,43 +139,16 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		}
 
 		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().filter(d->Objects.nonNull(d.getDataType())).collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
-		List<IndexBaseMonthData> financePayDataWithTimely = indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
-		typeDateMap.put(IndexDataType.FINANCE_PAY,financePayDataWithTimely);
-		typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
-		typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
-		List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
-
-		/*if(financePayDataWithTimely.size() > 0){
-			for (IndexBaseMonthData indexBaseMonthData : financePayDataWithTimely) {
-				BigDecimal percent = indexBaseMonthData.getPercent();
-				if(percent != null && percent.doubleValue() != 0d){
-					List<IndexBaseMonthData> collect = totalAmountDataWithTimely.stream().filter(e -> DateUtil.format(e.getMonth(), DateUtil.ISO_EXPANDED_DATE_FORMAT).
-							equals(DateUtil.format(indexBaseMonthData.getMonth(), DateUtil.ISO_EXPANDED_DATE_FORMAT))).collect(Collectors.toList());
-					IndexBaseMonthData totalAmountDate = null;
-					if(collect != null && collect.size() > 0){
-						totalAmountDate = collect.get(0);
-					}
-					if(totalAmountDate == null){
-						totalAmountDate = new IndexBaseMonthData();
-						totalAmountDate.setTotalNum(percent.negate());
-						totalAmountDate.setDataType(FINANCE_AMOUNT);
-						totalAmountDate.setActivateNum(percent.negate());
-						totalAmountDate.setOrganId(indexBaseMonthData.getOrganId());
-						totalAmountDate.setMonth(indexBaseMonthData.getMonth());
-						totalAmountDate.setPercent(percent.negate());
-						totalAmountDataWithTimely.add(totalAmountDate);
-					}else {
-						BigDecimal totalAmount = totalAmountDate.getPercent();
-						totalAmountDate.setActivateNum(totalAmount.subtract(percent));
-						totalAmountDate.setTotalNum(totalAmount.subtract(percent));
-						totalAmountDate.setPercent(totalAmount.subtract(percent));
-					}
-				}
-			}
-			totalAmountDataWithTimely = totalAmountDataWithTimely.stream().sorted(Comparator.comparing(IndexBaseMonthData::getMonth)).collect(Collectors.toList());
-		}*/
 
-		typeDateMap.put(IndexDataType.TOTAL_AMOUNT,totalAmountDataWithTimely);
+		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(FINANCE_PAY.getCode())||dataTypes.contains(FINANCE_BALANCE_AMOUNT.getCode())||dataTypes.contains(FINANCE_AMOUNT.getCode())){
+			List<IndexBaseMonthData> financePayDataWithTimely = indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
+			typeDateMap.put(IndexDataType.FINANCE_PAY,financePayDataWithTimely);
+			typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
+			typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
+			List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
+
+			typeDateMap.put(IndexDataType.TOTAL_AMOUNT,totalAmountDataWithTimely);
+		}
 
 
 		for (IndexDataType dataType : IndexDataType.values()) {