| 
					
				 | 
			
			
				@@ -34,11 +34,12 @@ 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.IndexErrorType.WAIT_CREATE_PAYMENT_CALENDER; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBaseMonthData> implements IndexBaseMonthDataService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private IndexBaseMonthDataDao indexBaseMonthDataDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -107,10 +108,43 @@ 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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		typeDateMap.put(IndexDataType.FINANCE_PAY,indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		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(IndexDataType.FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		typeDateMap.put(IndexDataType.TOTAL_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimely(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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (IndexDataType dataType : IndexDataType.values()) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -132,7 +166,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			typeDateMap.put(dataType, new ArrayList<>(Arrays.asList(indexBaseMonthData))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		BigDecimal totalAmount = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (Map.Entry<IndexDataType, List<IndexBaseMonthData>> typeDateMapEntry : typeDateMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Set<String> hasMonths = typeDateMapEntry.getValue().stream().map(d -> DateUtil.dateToString(d.getMonth(), "yyyy-MM-dd")).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			LocalDate currentMonthDate = startDate; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -169,7 +203,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			IndexBaseDto indexBaseData = new IndexBaseDto(typeDateMapEntry.getKey(),typeDateMapEntry.getKey().getMsg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			indexBaseData.setIndexMonthData(typeDateMapEntry.getValue(), currentMonth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(IndexDataType.FINANCE_PAY.equals(typeDateMapEntry.getKey()) || IndexDataType.FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(IndexDataType.FINANCE_PAY.equals(typeDateMapEntry.getKey()) || FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				IndexDataType.FINANCE_BALANCE_AMOUNT.equals(typeDateMapEntry.getKey()) || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					IndexDataType.TOTAL_AMOUNT.equals(typeDateMapEntry.getKey())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				indexBaseData.setPercent(typeDateMapEntry.getValue().stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -225,10 +259,15 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_PRACTICE_COURSE_NUM); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//经营数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		saveData(indexBaseMonthDataDao.getFinancePayData(dayStr),dayStr,IndexDataType.FINANCE_PAY); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		saveData(indexBaseMonthDataDao.getFinanceBalanceData(dayStr),dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		saveData(indexBaseMonthDataDao.getFinanceActualData(dayStr),dayStr,IndexDataType.FINANCE_AMOUNT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		saveData(indexBaseMonthDataDao.getTotalAmountData(dayStr),dayStr,IndexDataType.TOTAL_AMOUNT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		List<IndexBaseMonthData> financePayData = indexBaseMonthDataDao.getFinancePayData(dayStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		List<IndexBaseMonthData> financeBalanceData = indexBaseMonthDataDao.getFinanceBalanceData(dayStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		List<IndexBaseMonthData> financeActualData = indexBaseMonthDataDao.getFinanceActualData(dayStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		saveData(financePayData,dayStr,IndexDataType.FINANCE_PAY); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		saveData(financeBalanceData,dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		saveData(financeActualData,dayStr,IndexDataType.FINANCE_AMOUNT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		saveData(totalAmountData,dayStr,IndexDataType.TOTAL_AMOUNT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//业务数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null), monday.toString(), IndexDataType.HOMEWORK_CREATE_RATE); 
			 |