|
@@ -7488,13 +7488,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
workDescriptionText.setLanguageCode("ZH");
|
|
|
SapPeriod datePeriod=new SapPeriod();
|
|
|
SapPeriod timePeriod=new SapPeriod();
|
|
|
- List<Map<String, Object>> finalResultList = resultList;
|
|
|
- //创建多个个线程来处理 每个线程处理10条数据
|
|
|
- int size = finalResultList.size();
|
|
|
- //需要创建的线程数量 防止有小数 获取整数+1 多加一个作为预算工时推送
|
|
|
- BigDecimal divide = new BigDecimal(size).divide(new BigDecimal(10));
|
|
|
- int threadNum= divide.intValue() + 2;
|
|
|
- ExecutorService executor = Executors.newFixedThreadPool(threadNum);
|
|
|
+ Map<String, List<Map<String, Object>>> listGroupEmployeeID = resultList.stream().collect(Collectors.groupingBy(r -> String.valueOf(r.get("EmployeeID"))));
|
|
|
+ List<String> employeeIDList = resultList.stream().map(r -> String.valueOf(r.get("EmployeeID"))).distinct().collect(Collectors.toList());
|
|
|
+ //按照人员集合长度来创建多个个线程来处理
|
|
|
+ int threadNum = employeeIDList.size();
|
|
|
+ //多加一个作为预算工时推送
|
|
|
+ ExecutorService executor = Executors.newFixedThreadPool(threadNum+1);
|
|
|
/*execute()让线程池中的线程来执行业务,每次调用都会将一个线程加入到就绪队列*/
|
|
|
executor.execute(new Runnable() {
|
|
|
@Override
|
|
@@ -7505,17 +7504,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- for (int i = 0; i <threadNum ; i++) {
|
|
|
- //目标数据进行分组
|
|
|
- int start=i*10;
|
|
|
- int end=(i+1)*10;
|
|
|
- if(end>finalResultList.size()){
|
|
|
- end=finalResultList.size();
|
|
|
- }
|
|
|
- if(start>finalResultList.size()){
|
|
|
- start=finalResultList.size();
|
|
|
- }
|
|
|
- List<Map<String, Object>> mapList = finalResultList.subList(start, end);
|
|
|
+ for (int i = 0; i <employeeIDList.size() ; i++) {
|
|
|
+ List<Map<String, Object>> mapList = listGroupEmployeeID.get(employeeIDList.get(i));
|
|
|
executor.execute(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|