瀏覽代碼

首页查询优化

zouxuan 2 年之前
父節點
當前提交
7674c5a4b5
共有 1 個文件被更改,包括 26 次插入32 次删除
  1. 26 32
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

+ 26 - 32
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -66,7 +66,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 	private SysEmployeePositionService employeePositionService;
 	@Autowired
 	private MusicGroupCalenderRefundPeriodDao musicGroupCalenderRefundPeriodDao;
-	private static final ExecutorService exportExecutorService = Executors.newFixedThreadPool(3);
+	private static final ExecutorService exportExecutorService = Executors.newFixedThreadPool(10);
 
 	private static ThreadLocal<Set<Integer>> organIds = new ThreadLocal<Set<Integer>>(){
 		@Override
@@ -158,39 +158,12 @@ 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));
 
-		//按天汇总
-//		if((CollectionUtils.isEmpty(dataTypes) || dataTypes.contains(FINANCE_BALANCE_AMOUNT.getCode()) || dataTypes.contains(FINANCE_AMOUNT.getCode())) && organIds != null){
-////			List<IndexBaseMonthData> financePayDataWithTimely = indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate1, endDate1, arrayList,tenantId);
-////			typeDateMap.put(IndexDataType.FINANCE_PAY,financePayDataWithTimely);
-//			typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId));
-//			typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId));
-//			List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId);
-//			typeDateMap.put(IndexDataType.TOTAL_AMOUNT,totalAmountDataWithTimely);
-//			//经营报表细化
-//			List<IndexBaseMonthData> applyAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"APPLY,ADD_STUDENT",null,tenantId);
-//			typeDateMap.put(APPLY_AMOUNT,applyAmount);
-//			List<IndexBaseMonthData> renewAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"RENEW",null,tenantId);
-//			typeDateMap.put(RENEW_AMOUNT,renewAmount);
-//			List<IndexBaseMonthData> vipAmount = indexBaseMonthDataDao.getVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId);
-//			typeDateMap.put(VIP_AMOUNT,vipAmount);
-//			List<IndexBaseMonthData> practiceAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW",null,tenantId);
-//			typeDateMap.put(PRACTICE_AMOUNT,practiceAmount);
-//			List<IndexBaseMonthData> otherAmount = indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId);
-//			typeDateMap.put(OTHER_AMOUNT,otherAmount);
-//		}
 		//按分部汇总
 		if((CollectionUtils.isEmpty(dataTypes) || dataTypes.contains(ORGAN_FINANCE_BALANCE_AMOUNT.getCode()) ||
 				dataTypes.contains(ORGAN_FINANCE_AMOUNT.getCode())) && organIds != null){
 			CompletableFuture<List<IndexBaseDto>> future = CompletableFuture.supplyAsync(() -> {
 				System.out.println("start search 经营报表细化1");
 				List<IndexBaseDto> indexBaseDtoList = new ArrayList<>();
-				indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
-				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_FINANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
-				List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId);
-				indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_TOTAL_AMOUNT,totalAmountDataWithTimely));
-				//经营报表细化
-				List<IndexBaseMonthData> applyAmount = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"APPLY,ADD_STUDENT",null,tenantId);
-				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_APPLY_AMOUNT,applyAmount));
 				List<IndexBaseMonthData> renewAmount = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"RENEW",null,tenantId);
 				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_RENEW_AMOUNT,renewAmount));
 				List<IndexBaseMonthData> vipAmount = indexBaseMonthDataDao.getOrganVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId);
@@ -202,9 +175,22 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				System.out.println("end search 经营报表细化1");
 				return indexBaseDtoList;
 			},exportExecutorService);
-			CompletableFuture<Map<IndexDataType, List<IndexBaseMonthData>>> future1 = CompletableFuture.supplyAsync(()->{
+			CompletableFuture<List<IndexBaseDto>> future2 = CompletableFuture.supplyAsync(() -> {
 				System.out.println("start search 经营报表细化2");
-				Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap1 = new HashMap<>(8);
+				List<IndexBaseDto> indexBaseDtoList = new ArrayList<>();
+				indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
+				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_FINANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
+				List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId);
+				indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_TOTAL_AMOUNT,totalAmountDataWithTimely));
+				//经营报表细化
+				List<IndexBaseMonthData> applyAmount = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"APPLY,ADD_STUDENT",null,tenantId);
+				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_APPLY_AMOUNT,applyAmount));
+				System.out.println("end search 经营报表细化2");
+				return indexBaseDtoList;
+			},exportExecutorService);
+			CompletableFuture<Map<IndexDataType, List<IndexBaseMonthData>>> future3 = CompletableFuture.supplyAsync(()->{
+				System.out.println("start search 经营报表细化3");
+				Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap1 = new HashMap<>(4);
 				typeDateMap1.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId));
 				typeDateMap1.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId));
 				List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId);
@@ -212,6 +198,12 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				//经营报表细化
 				List<IndexBaseMonthData> applyAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"APPLY,ADD_STUDENT",null,tenantId);
 				typeDateMap1.put(APPLY_AMOUNT,applyAmount);
+				System.out.println("end search 经营报表细化3");
+				return typeDateMap1;
+			},exportExecutorService);
+			CompletableFuture<Map<IndexDataType, List<IndexBaseMonthData>>> future4 = CompletableFuture.supplyAsync(()->{
+				System.out.println("start search 经营报表细化4");
+				Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap1 = new HashMap<>(4);
 				List<IndexBaseMonthData> renewAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"RENEW",null,tenantId);
 				typeDateMap1.put(RENEW_AMOUNT,renewAmount);
 				List<IndexBaseMonthData> vipAmount = indexBaseMonthDataDao.getVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId);
@@ -220,11 +212,13 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				typeDateMap1.put(PRACTICE_AMOUNT,practiceAmount);
 				List<IndexBaseMonthData> otherAmount = indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId);
 				typeDateMap1.put(OTHER_AMOUNT,otherAmount);
-				System.out.println("end search 经营报表细化2");
+				System.out.println("end search 经营报表细化4");
 				return typeDateMap1;
 			},exportExecutorService);
 			result.addAll(future.join());
-			typeDateMap.putAll(future1.join());
+			result.addAll(future2.join());
+			typeDateMap.putAll(future3.join());
+			typeDateMap.putAll(future4.join());
 		}
 
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(MUSIC_GROUP_COURSE.getCode())||dataTypes.contains(VIP_GROUP_COURSE.getCode())