Min 1 year ago
parent
commit
7d8a4ba328

+ 8 - 18
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -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() {

+ 8 - 16
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -1711,14 +1711,12 @@ public class TimingTask {
 //            if(projectPlanSapSyncLogs.size()>0){
 //                sapSyncLogService.saveBatch(projectPlanSapSyncLogs);
 //            }
-            List<Map<String, Object>> finalResultList = mapList;
-            //创建多个个线程来处理 每个线程处理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);
-            /*execute()让线程池中的线程来执行业务,每次调用都会将一个线程加入到就绪队列*/
+            Map<String, List<Map<String, Object>>> listGroupEmployeeID = pushProjectPlanHour.stream().collect(Collectors.groupingBy(r -> String.valueOf(r.get("EmployeeID"))));
+            List<String> employeeIDList = pushProjectPlanHour.stream().map(r -> String.valueOf(r.get("EmployeeID"))).distinct().collect(Collectors.toList());
+            //按照人员集合长度来创建多个个线程来处理
+            int threadNum = employeeIDList.size();
+            //多加一个作为预算工时推送
+            ExecutorService executor = Executors.newFixedThreadPool(threadNum+1);
             executor.execute(new Runnable() {
                 @Override
                 public void run() {
@@ -1728,14 +1726,8 @@ public class TimingTask {
                     }
                 }
             });
-            for (int i = 0; i <threadNum ; i++) {
-                //目标数据进行分组
-                int start=i*10;
-                int end=(i+1)*10;
-                if(end>finalResultList.size()){
-                    end=finalResultList.size();
-                }
-                List<Map<String, Object>> targetList = finalResultList.subList(start, end);
+            for (int i = 0; i <employeeIDList.size() ; i++) {
+                List<Map<String, Object>> targetList = listGroupEmployeeID.get(employeeIDList.get(i));
                 executor.execute(new Runnable() {
                     @Override
                     public void run() {

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/WebServiceUtils.java

@@ -47,7 +47,8 @@ public class WebServiceUtils {
             outObject.write(sendMsg.getBytes("UTF-8"));
 
             if (200 != (httpConn.getResponseCode())) {
-                throw new Exception("HTTP Request is not success, Response code is " + httpConn.getResponseCode());
+                throw new Exception("HTTP Request is not success, Response code is " + httpConn.getResponseCode()+" Response msg is "+httpConn.getResponseMessage());
+
             }
             // 获取HTTP响应数据
             isr = new InputStreamReader(