yuanzhi_kuang 1 semana atrás
pai
commit
6ca62ecf18

+ 29 - 5
src/com/kingdee/eas/custom/synctask/SyncTranForAtsFacadeControllerBean.java

@@ -75,10 +75,12 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
             }else if( offset < 0 ) {
                 start = start.plusDays(offset);
             }
-        }else  if(!StringUtils.isEmpty(beginDate) ){
+        }
+        if(!StringUtils.isEmpty(beginDate) ){
             //开始日期字定义,结束日期都是今天
             start = LocalDate.parse(beginDate, dateFormatter);
-        }else  if(!StringUtils.isEmpty(endDate)){
+        }
+        if(!StringUtils.isEmpty(endDate)){
             //开始日期,结束日期都是今天
             end = LocalDate.parse(endDate, dateFormatter);
         }
@@ -332,11 +334,33 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
         logger.error("打卡同步时不存在考勤档案数量-----" + notExistRecords.size());
         logger.error("seccussArray--Size-----" + seccussArray.size());
 //        logger.error("seccussArray-----" + seccussArray);
-
         if (cardCollFinally.size() > 0) {
-            IObjectPK[] iObjectPKS = PunchCardRecordFactory.getLocalInstance(ctx).saveBatchData(cardCollFinally);
-            logger.error("iObjectPKS----" + iObjectPKS.length);
+            // 分批大小
+            int batchSize = 500;
+            // 总记录数
+            int totalRecords = cardCollFinally.size();
+            // 计算需要分多少批
+            int batchCount = (totalRecords + batchSize - 1) / batchSize;  // 向上取整
+            logger.error("开始分批保存打卡数据,总记录数: " + totalRecords + ",将分" + batchCount + "批执行");
+            // 分批处理
+            for (int i = 0; i < batchCount; i++) {
+                int fromIndex = i * batchSize;
+                int toIndex = Math.min((i + 1) * batchSize, totalRecords);
+
+                // 获取当前批次的数据
+                CoreBaseCollection batch = new CoreBaseCollection();
+                for (int j = fromIndex; j < toIndex; j++) {
+                    batch.add(cardCollFinally.get(j));
+                }
+
+                // 执行批量保存
+                IObjectPK[] iObjectPKS = PunchCardRecordFactory.getLocalInstance(ctx).saveBatchData(batch);
+                logger.error("第" + (i + 1) + "批保存完成,记录数: " + iObjectPKS.length +
+                        ",范围: " + fromIndex + "-" + (toIndex - 1));
+            }
+            logger.error("打卡数据分批保存完成,共处理" + totalRecords + "条记录");
         }
+
     }