Procházet zdrojové kódy

完善考勤报表。

zhengqiang před 5 roky
rodič
revize
e687201ee5

+ 4 - 3
web/src/main/java/com/jpsoft/smart/modules/business/controller/WorkAttendanceController.java

@@ -17,6 +17,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.hssf.usermodel.HSSFRichTextString;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 import org.joda.time.DateTime;
@@ -227,7 +228,7 @@ public class WorkAttendanceController {
 
     private String createReport(DateTime startTime,DateTime endTime,List<Map> personMapList) throws Exception {
         int days = Days.daysBetween(startTime,endTime).getDays();
-        ClassPathResource resource = new ClassPathResource("static/workAttendanceReport.xlsx");
+        ClassPathResource resource = new ClassPathResource("static/workAttendanceReport.xls");
 
         Workbook wb = WorkbookFactory.create(resource.getInputStream());
 
@@ -347,7 +348,7 @@ public class WorkAttendanceController {
                         }
                     }
 
-                    XSSFRichTextString sText = new XSSFRichTextString(sb.toString());
+                    HSSFRichTextString sText = new HSSFRichTextString(sb.toString());
 
                     for (Map map : posList) {
                         int start = Integer.valueOf(map.get("start").toString());
@@ -382,7 +383,7 @@ public class WorkAttendanceController {
         byte[] buffer = output.toByteArray();
         ByteArrayInputStream input = new ByteArrayInputStream(buffer);
 
-        String fileName = "考勤统计表.xlsx";
+        String fileName = "考勤统计表.xls";
 
         String downloadUrl = OSSUtil.upload(ossConfig,"workAttendance",fileName,input);
 

+ 58 - 56
web/src/main/java/com/jpsoft/smart/schduled/UnmeasureTemperatureAlarmTask.java

@@ -7,10 +7,12 @@ import com.jpsoft.smart.modules.base.service.*;
 import com.jpsoft.smart.modules.business.entity.WorkAttendance;
 import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
+import com.jpsoft.smart.modules.common.utils.POIUtils;
 import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
 import com.sun.corba.se.spi.orbutil.threadpool.Work;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -371,7 +373,7 @@ public class UnmeasureTemperatureAlarmTask {
             && pusher.getMissingNoticeEnabled()!=null && pusher.getMissingNoticeEnabled()) {
                 String message = "尊敬的" + pusher.getName()
                         + ",当天时段" + startTime.toString("HH:mm") + "至" + endTime.toString("HH:mm")
-                        + ",有" + total + "人未测量体温,具体名单请点击下方链接查看。";
+                        + ",有" + total + "人未测量体温,具体名单请点击下方【查看详情】下载人员名单";
 
                 //todo 生成未测量人员名单
 
@@ -387,7 +389,7 @@ public class UnmeasureTemperatureAlarmTask {
                 WechatMessageUtil.sendUnmeasureAlarmInfo(
                         pusher.getOpenId(),
                         companyInfo.getName(),
-                        message,
+                        String.format(message,url),
                         url,
                         wxConfig.getAppId(), wxConfig.getAppSecret());
             }
@@ -395,81 +397,81 @@ public class UnmeasureTemperatureAlarmTask {
     }
 
     private String createUnMeasureReport(CompanyInfo companyInfo, List<PersonInfo> unmeasuredList, DateTime startTime, DateTime endTime) throws Exception{
-            ClassPathResource resource = new ClassPathResource("static/unMeasureReport.xlsx");
+        ClassPathResource resource = new ClassPathResource("static/unMeasureReport.xls");
 
-            Workbook wb = WorkbookFactory.create(resource.getInputStream());
+        Workbook wb = WorkbookFactory.create(resource.getInputStream());
 
-            Sheet sheet = wb.getSheetAt(0);
+        Sheet sheet = wb.getSheetAt(0);
 
-            Row row1 = sheet.getRow(0);
-            Row row2 = sheet.getRow(1);
-            Row row3 = sheet.getRow(2);
+        Row row1 = sheet.getRow(0);
+        Row row2 = sheet.getRow(1);
+        Row row3 = sheet.getRow(2);
 
-            String title = row1.getCell(0).getStringCellValue();
-            String subTitle = row2.getCell(0).getStringCellValue();
+        String title = row1.getCell(0).getStringCellValue();
+        String subTitle = row2.getCell(0).getStringCellValue();
 
-            row1.getCell(0).setCellValue(String.format(title, startTime.toString("HH:mm"), endTime.toString("HH:mm")));
-            row2.getCell(0).setCellValue(String.format(subTitle, DateTime.now().toString("yyyy-MM-dd HH:mm")));
+        row1.getCell(0).setCellValue(String.format(title, startTime.toString("HH:mm"), endTime.toString("HH:mm")));
+        row2.getCell(0).setCellValue(String.format(subTitle, DateTime.now().toString("yyyy-MM-dd HH:mm")));
 
-            //显示扩展字段
-            List<CompanyPosition> companyPositions = companyPositionService.findByCompanyId(companyInfo.getId());
+        //显示扩展字段
+        List<CompanyPosition> companyPositions = companyPositionService.findByCompanyId(companyInfo.getId());
 
-            if (companyPositions.size()>0){
-                CompanyPosition companyPosition = companyPositions.get(0);
+        if (companyPositions.size()>0){
+            CompanyPosition companyPosition = companyPositions.get(0);
 
-                if(StringUtils.isNotEmpty(companyPosition.getPosition1Name())) {
-                    row3.createCell(2).setCellValue(companyPosition.getPosition1Name());
-                }
-
-                if(StringUtils.isNotEmpty(companyPosition.getPosition2Name())) {
-                    row3.createCell(3).setCellValue(companyPosition.getPosition2Name());
-                }
+            if(StringUtils.isNotEmpty(companyPosition.getPosition1Name())) {
+                row3.createCell(3).setCellValue(companyPosition.getPosition1Name());
+            }
 
-                if(StringUtils.isNotEmpty(companyPosition.getPosition3Name())) {
-                    row3.createCell(4).setCellValue(companyPosition.getPosition3Name());
-                }
+            if(StringUtils.isNotEmpty(companyPosition.getPosition2Name())) {
+                row3.createCell(4).setCellValue(companyPosition.getPosition2Name());
+            }
 
-                if(StringUtils.isNotEmpty(companyPosition.getPosition4Name())) {
-                    row3.createCell(5).setCellValue(companyPosition.getPosition4Name());
-                }
+            if(StringUtils.isNotEmpty(companyPosition.getPosition3Name())) {
+                row3.createCell(5).setCellValue(companyPosition.getPosition3Name());
+            }
 
-                if(StringUtils.isNotEmpty(companyPosition.getPosition5Name())) {
-                    row3.createCell(6).setCellValue(companyPosition.getPosition5Name());
-                }
+            if(StringUtils.isNotEmpty(companyPosition.getPosition4Name())) {
+                row3.createCell(6).setCellValue(companyPosition.getPosition4Name());
             }
 
-            int rowIndex = 3;
+            if(StringUtils.isNotEmpty(companyPosition.getPosition5Name())) {
+                row3.createCell(7).setCellValue(companyPosition.getPosition5Name());
+            }
+        }
 
-            for (PersonInfo personInfo : unmeasuredList) {
-                Row row = sheet.createRow(rowIndex);
-                row.createCell(0).setCellValue(rowIndex-2);
-                row.createCell(1).setCellValue(personInfo.getCompanyName());
-                row.createCell(2).setCellValue(personInfo.getName());
-                row.createCell(3).setCellValue(personInfo.getPosition1());
-                row.createCell(4).setCellValue(personInfo.getPosition2());
-                row.createCell(5).setCellValue(personInfo.getPosition3());
-                row.createCell(6).setCellValue(personInfo.getPosition4());
-                row.createCell(7).setCellValue(personInfo.getPosition4());
+        int rowIndex = 3;
 
-                rowIndex++;
-            }
+        for (PersonInfo personInfo : unmeasuredList) {
+            Row row = sheet.createRow(rowIndex);
+            row.createCell(0).setCellValue(rowIndex-2);
+            row.createCell(1).setCellValue(personInfo.getCompanyName());
+            row.createCell(2).setCellValue(personInfo.getName());
+            row.createCell(3).setCellValue(personInfo.getPosition1());
+            row.createCell(4).setCellValue(personInfo.getPosition2());
+            row.createCell(5).setCellValue(personInfo.getPosition3());
+            row.createCell(6).setCellValue(personInfo.getPosition4());
+            row.createCell(7).setCellValue(personInfo.getPosition4());
+
+            rowIndex++;
+        }
 
-            //todo 将wb保存到oss
-            ByteArrayOutputStream output = new ByteArrayOutputStream();
-            wb.write(output);
+        //todo 将wb保存到oss
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+        wb.write(output);
+        byte[] buffer = output.toByteArray();
 
-            byte[] buffer = output.toByteArray();
-            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+        ByteArrayInputStream input = new ByteArrayInputStream(buffer);
 
-            String fileName = "未测温统计表.xlsx";
+        String fileName = "未测温统计表.xls";
 
-            String downloadUrl = OSSUtil.upload(ossConfig,"unmeasuredReport",fileName,input);
+        String downloadUrl = OSSUtil.upload(ossConfig, "unmeasuredReport", fileName, input);
 
-            wb.write(output);
-            wb.close();
-            output.close();
+        wb.write(output);
+        wb.close();
+        output.close();
 
-            return downloadUrl;
+        return downloadUrl;
     }
 
     public static void main(String[] args) {

binární
web/src/main/resources/static/unMeasureReport.xls


binární
web/src/main/resources/static/unMeasureReport.xlsx


binární
web/src/main/resources/static/workAttendanceReport.xls


binární
web/src/main/resources/static/workAttendanceReport.xlsx