|
@@ -35,6 +35,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.IndexDataType.*;
|
|
@@ -355,6 +356,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
result.add(indexBaseData);
|
|
|
}
|
|
|
}
|
|
|
+ System.out.println(System.currentTimeMillis());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -384,72 +386,91 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
return decimalMapDtos1.stream().sorted(Comparator.comparing(DecimalMapDto::getAmount).reversed()).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- private List<IndexBaseMonthData> completedList(List<IndexBaseMonthData> renew,List<Organization> organs){
|
|
|
- Map<Integer, IndexBaseMonthData> collect = renew.stream().collect(Collectors.groupingBy(e -> e.getOrganId(),Collectors.collectingAndThen(Collectors.toList(),v->v.get(0))));
|
|
|
- List<IndexBaseMonthData> completedRenew = new ArrayList<>();
|
|
|
+ private List<IndexBaseMonthData> completedList(List<IndexBaseMonthData> renew, List<Organization> organs) {
|
|
|
+ // 将 renew 转换为 Map,以组织 ID 为键,IndexBaseMonthData 为值
|
|
|
+ Map<Integer, IndexBaseMonthData> renewMap = renew.stream()
|
|
|
+ .collect(Collectors.toMap(IndexBaseMonthData::getOrganId, Function.identity()));
|
|
|
+ // 遍历 organs,根据组织 ID 获取对应的 IndexBaseMonthData,并进行处理
|
|
|
for (Organization organ : organs) {
|
|
|
- IndexBaseMonthData indexBaseMonthData = collect.get(organ.getId());
|
|
|
- if(Objects.isNull(indexBaseMonthData)){
|
|
|
+ IndexBaseMonthData indexBaseMonthData = renewMap.get(organ.getId());
|
|
|
+ if (indexBaseMonthData == null) {
|
|
|
indexBaseMonthData = new IndexBaseMonthData();
|
|
|
- indexBaseMonthData.setPercent(BigDecimal.ZERO);
|
|
|
indexBaseMonthData.setOrganId(organ.getId());
|
|
|
- indexBaseMonthData.setOrganName(organ.getName());
|
|
|
- }else {
|
|
|
- indexBaseMonthData.setOrganName(organ.getName());
|
|
|
+ renew.add(indexBaseMonthData); // 将新的 IndexBaseMonthData 对象添加到 renew 集合中
|
|
|
}
|
|
|
- completedRenew.add(indexBaseMonthData);
|
|
|
+ indexBaseMonthData.setOrganName(organ.getName());
|
|
|
}
|
|
|
- return completedRenew;
|
|
|
+ return renew;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//异步处理经营数据查询
|
|
|
public void syncOperation(String startDate1,String endDate1,List<Integer> arrayList,Integer tenantId,List<IndexBaseDto> indexBaseDtoList,Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap){
|
|
|
+// System.out.println(System.currentTimeMillis());
|
|
|
List<Organization> organs = organizationService.findOrgans(arrayList, tenantId);
|
|
|
CompletableFuture future1 = this.async(() -> {
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
List<IndexBaseMonthData> renew = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, "RENEW", null, tenantId);
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_RENEW_AMOUNT,this.completedList(renew,organs)));
|
|
|
List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, tenantId);
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_VIP_AMOUNT,this.completedList(details,organs)));
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
});
|
|
|
CompletableFuture future2 = this.async(() -> {
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
List<IndexBaseMonthData> data = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, "PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW", null, tenantId);
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_PRACTICE_AMOUNT,this.completedList(data,organs)));
|
|
|
List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, tenantId);
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_OTHER_AMOUNT,this.completedList(details,organs)));
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
+ });
|
|
|
+ CompletableFuture future6 = this.async(()->{
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
+ 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);
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
+ });
|
|
|
+ CompletableFuture future8 = this.async(()->{
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
+ typeDateMap.put(PRACTICE_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW",null,tenantId));
|
|
|
+ typeDateMap.put(OTHER_AMOUNT,indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId));
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
});
|
|
|
CompletableFuture future3 = this.async(() -> {
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimely(startDate1, endDate1, arrayList, tenantId);
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_TOTAL_AMOUNT,this.completedList(details,organs)));
|
|
|
List<IndexBaseMonthData> apply = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, "APPLY,ADD_STUDENT", null, tenantId);
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_APPLY_AMOUNT,this.completedList(apply,organs)));
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
});
|
|
|
CompletableFuture future4 = this.async(() -> {
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_BALANCE_AMOUNT,
|
|
|
this.completedList(indexBaseMonthDataDao.getOrganFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId),organs)));
|
|
|
indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_FINANCE_AMOUNT,
|
|
|
this.completedList(indexBaseMonthDataDao.getOrganFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId),organs)));
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
});
|
|
|
|
|
|
CompletableFuture future5 = this.async(()->{
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId));
|
|
|
typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId));
|
|
|
- });
|
|
|
- CompletableFuture future6 = this.async(()->{
|
|
|
- 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);
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
});
|
|
|
CompletableFuture future7 = this.async(()->{
|
|
|
+// long l = System.currentTimeMillis();
|
|
|
typeDateMap.put(IndexDataType.TOTAL_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId));
|
|
|
typeDateMap.put(APPLY_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"APPLY,ADD_STUDENT",null,tenantId));
|
|
|
+// System.out.println("Thread.currentThread :" + Thread.currentThread() + "---" + (System.currentTimeMillis() - l));
|
|
|
});
|
|
|
- CompletableFuture future8 = this.async(()->{
|
|
|
- typeDateMap.put(PRACTICE_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW",null,tenantId));
|
|
|
- typeDateMap.put(OTHER_AMOUNT,indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId));
|
|
|
- });
|
|
|
- future1.join();future2.join();future3.join();future4.join();
|
|
|
- future5.join();future6.join();future7.join();future8.join();
|
|
|
+// System.out.println(System.currentTimeMillis());
|
|
|
+ CompletableFuture<Void> allFutures = CompletableFuture.allOf(future1, future2, future3, future4, future5, future6, future7, future8);
|
|
|
+ allFutures.join();
|
|
|
+// System.out.println(System.currentTimeMillis());
|
|
|
}
|
|
|
|
|
|
@Override
|