Bläddra i källkod

将打卡记录导出上限改为10W条,导出格式换成xlsx

zhengqiang 3 år sedan
förälder
incheckning
c9c6c1a978

+ 14 - 11
common/src/main/java/com/jpsoft/shinestar/modules/business/service/impl/WorkScheduleAttendanceServiceImpl.java

@@ -1112,23 +1112,26 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
             try {
                 //查询到有缺卡可能是本人排班休息,可能先缺卡后调班为休息,但考勤未更新的情况
                 WorkPersonScheduling workPersonScheduling = workPersonSchedulingService.findByPersonIdSchedulingDay(wsa.getPersonId(), sdf.parse(wsa.getAttendanceDate()));
-                String shiftIds = workPersonScheduling.getShiftIds();
 
-                String[] shiftIdArr = shiftIds.split(",");
+                if(workPersonScheduling!=null) {
+                    String shiftIds = workPersonScheduling.getShiftIds();
 
-                boolean rest = false;
+                    String[] shiftIdArr = shiftIds.split(",");
 
-                for (String shiftId : shiftIdArr) {
-                    WorkShiftInfo workShiftInfo = workShiftInfoService.get(shiftId);
+                    boolean rest = false;
 
-                    if ("0".equals(workShiftInfo.getNumber())){
-                        rest = true;
-                        break;
+                    for (String shiftId : shiftIdArr) {
+                        WorkShiftInfo workShiftInfo = workShiftInfoService.get(shiftId);
+
+                        if ("0".equals(workShiftInfo.getNumber())) {
+                            rest = true;
+                            break;
+                        }
                     }
-                }
 
-                if (!rest && wsa.getCoefficientDays() != null) {
-                    absenteeismNum = absenteeismNum.add(wsa.getCoefficientDays());
+                    if (!rest && wsa.getCoefficientDays() != null) {
+                        absenteeismNum = absenteeismNum.add(wsa.getCoefficientDays());
+                    }
                 }
             }
             catch (Exception ex){

+ 15 - 5
web/src/main/java/com/jpsoft/shinestar/modules/base/controller/PersonDeviceLogController.java

@@ -27,6 +27,7 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.joda.time.DateTime;
 import org.joda.time.Days;
 import org.slf4j.Logger;
@@ -253,7 +254,7 @@ public class PersonDeviceLogController {
         return msgResult;
     }
 
-    public void setExportProgress(String timestamp,String msg){
+    public void   setExportProgress(String timestamp,String msg){
         valueOperations.set(exportPrefix + timestamp , msg,5, TimeUnit.MINUTES);
     }
 
@@ -291,7 +292,7 @@ public class PersonDeviceLogController {
             User user = userService.get(subject);
             String userCompanyId = user.getCompanyId();
 
-            Workbook workbook = new HSSFWorkbook();
+            Workbook workbook = new XSSFWorkbook();
             Sheet sheet = workbook.createSheet();
 
             //表头
@@ -454,7 +455,9 @@ public class PersonDeviceLogController {
                 }
             }
 
-            while(pageNum<=totalPages){
+            boolean loop = true;
+
+            while(pageNum<=totalPages && loop){
                 Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams, pageNum, pageSize, needCount, sortList);
 
                 if(needCount){
@@ -464,9 +467,16 @@ public class PersonDeviceLogController {
                 }
 
                 for (int i = 0; i < page.size(); i++) {
+                    int rowNum = (pageNum-1)*pageSize + i + 1;
+
+                    if(rowNum>100000){
+                        loop = false;
+                        break;
+                    }
+
                     PersonDeviceLog personDeviceLog = page.get(i);
 
-                    Row rowContent = sheet.createRow( (pageNum-1)*pageSize + i + 1);
+                    Row rowContent = sheet.createRow( rowNum);
 
                     Cell cellContent1 = rowContent.createCell(0);
                     cellContent1.setCellValue(i + 1);
@@ -550,7 +560,7 @@ public class PersonDeviceLogController {
 
             logger.warn("原文件大小:" + buffer.length);
 
-            String fileName = DateTime.now().toString("yyyyMMddHHmmss") + ".xls";
+            String fileName = DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
 
             InputStream input = new ByteArrayInputStream(buffer);