Преглед изворни кода

1.考勤报表增加查询。
2.人员列表增加微信通知开关。

zhengqiang пре 5 година
родитељ
комит
82d92abc75

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/PersonInfoDTO.java

@@ -35,6 +35,8 @@ public class PersonInfoDTO {
     private Boolean passwordEnabled;
     @ApiModelProperty(value = "访客")
     private Boolean guestEnabled;
+    @ApiModelProperty(value = "微信通知是否开启")
+    private Boolean wechatNoticeEnabled;
     @ApiModelProperty(value = "位置1")
     private String position1;
     @ApiModelProperty(value = "位置2")

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/business/entity/WorkAttendance.java

@@ -16,7 +16,7 @@ import lombok.Data;
  */
 @Data
 @ApiModel(value = "business_work_attendance的实体类")
-public class WorkAttendance {
+public class WorkAttendance implements Serializable {
     /**
      * 缺卡
      */

+ 55 - 4
web/src/main/java/com/jpsoft/smart/config/RedisConfig.java

@@ -1,5 +1,9 @@
 package com.jpsoft.smart.config;
 
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.CacheManager;
 import org.springframework.cache.annotation.CachingConfigurerSupport;
@@ -7,11 +11,13 @@ import org.springframework.cache.annotation.EnableCaching;
 import org.springframework.cache.interceptor.KeyGenerator;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
 import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
 import org.springframework.data.redis.core.*;
-import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
+import org.springframework.data.redis.serializer.*;
 
 import java.lang.reflect.Method;
 
@@ -47,9 +53,9 @@ public class RedisConfig extends CachingConfigurerSupport {
      */
     private void initDomainRedisTemplate(RedisTemplate<String, Object> redisTemplate, RedisConnectionFactory factory) {
         redisTemplate.setKeySerializer(new StringRedisSerializer());
-        redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
+        redisTemplate.setValueSerializer(valueSerializer());
         redisTemplate.setHashKeySerializer(new StringRedisSerializer());
-        redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
+        redisTemplate.setHashValueSerializer(valueSerializer());
         redisTemplate.setConnectionFactory(factory);
     }
 
@@ -124,4 +130,49 @@ public class RedisConfig extends CachingConfigurerSupport {
     public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
         return redisTemplate.opsForZSet();
     }
+
+    @Bean
+    public RedisCacheManager redisCacheManager(RedisConnectionFactory redisConnectionFactory) {
+        RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory);
+        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
+                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(valueSerializer()));
+        redisCacheConfiguration.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()));
+        return new RedisCacheManager(redisCacheWriter, redisCacheConfiguration);
+    }
+
+    /**
+     * 使用Jackson序列化器
+     * @return
+     */
+    private RedisSerializer<Object> valueSerializer() {
+        Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
+        ObjectMapper objectMapper = new ObjectMapper();
+        objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        /**
+         * 这一句必须要,作用是序列化时将对象全类名一起保存下来
+         * 设置之后的序列化结果如下:
+         *  [
+         *   "com.dxy.cache.pojo.Dept",
+         *   {
+         *     "pid": 1,
+         *     "code": "11",
+         *     "name": "财务部1"
+         *   }
+         * ]
+         *
+         * 不设置的话,序列化结果如下,将无法反序列化
+         *
+         *  {
+         *     "pid": 1,
+         *     "code": "11",
+         *     "name": "财务部1"
+         *   }
+         */
+//                objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        //因为上面那句代码已经被标记成作废,因此用下面这个方法代替,仅仅测试了一下,不知道是否完全正确
+        objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,ObjectMapper.DefaultTyping.NON_FINAL);
+        serializer.setObjectMapper(objectMapper);
+
+        return serializer;
+    }
 }

+ 40 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -753,6 +753,46 @@ public class PersonInfoController {
         return msgResult;
     }
 
+    @ApiOperation(value="微信通知切换")
+    @PostMapping("enabledWechatNotice")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "人员编号", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<PersonInfo> enabledWechatNotice(@RequestParam(value="id",defaultValue="") Long id,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(id);
+
+            if(personInfo.getWechatNoticeEnabled()!=null && personInfo.getWechatNoticeEnabled()){
+                personInfo.setWechatNoticeEnabled(false);
+            }else{
+                personInfo.setWechatNoticeEnabled(true);
+            }
+
+            personInfo.setUpdateBy(subject);
+            personInfo.setUpdateTime(new Date());
+
+            int affectCount = personInfoService.update(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库保存失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value="导入人员(非企业账户需要输入企业ID)")
     @PostMapping("importXls")
     @ApiImplicitParams({

+ 173 - 125
web/src/main/java/com/jpsoft/smart/modules/business/controller/WorkAttendanceController.java

@@ -27,11 +27,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
+import org.springframework.data.redis.core.ListOperations;
+import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
 import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @RestController
@@ -58,24 +61,25 @@ public class WorkAttendanceController {
     @Autowired
     private OSSConfig ossConfig;
 
-    @ApiOperation(value="导出考勤记录")
+    @Autowired
+    private ValueOperations<String, Object> valueOperations;
+
+    @ApiOperation(value="考勤统计列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name="companyId",value = "单位编号",required = true,paramType = "form"),
             @ApiImplicitParam(name = "startDate",value = "开始时间", required = true,paramType="form"),
             @ApiImplicitParam(name = "endDate",value = "截止时间", required = true,paramType="form"),
             @ApiImplicitParam(name = "subject",value = "subject", required = false,paramType="form")
     })
-    @RequestMapping(value = "exportXls",method = RequestMethod.POST)
-    public MessageResult<String> exportXls(
+    @RequestMapping(value = "statList",method = RequestMethod.POST)
+    public MessageResult<Map> statList(
             String companyId,
             @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
             @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
             @RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
 
-        //当前用户ID
-        System.out.println(subject);
-
-        MessageResult<String> msgResult = new MessageResult<>();
+        Map<String,Object> dataMap = new HashMap<>();
 
         try {
             if (startDate==null){
@@ -165,7 +169,7 @@ public class WorkAttendanceController {
                             else if(result.equals(WorkAttendance.MISSING)){
                                 if (workAttendance.getClassifier().equals("1")){
                                     //上班缺卡
-                                    missCardOffWorkCount++;
+                                    missCardOnWorkCount++;
                                 }
                                 else{
                                     //下班缺卡
@@ -181,7 +185,7 @@ public class WorkAttendanceController {
                     }
                 }
 
-                personMap.put("personInfo",personInfo);
+                personMap.put("name",personInfo.getName());
                 personMap.put("company",personInfo.getPosition1());
                 personMap.put("department",personInfo.getPosition2());
                 personMap.put("jobNumber",personInfo.getPosition3());
@@ -197,11 +201,29 @@ public class WorkAttendanceController {
                 personMapList.add(personMap);
             }
 
-            //todo 生成报表
-//            String tmplFilePath = "E:\\workAttendanceReport.xlsx";
-            String downloadUrl = createReport(startTime,endTime,personMapList);
+            //todo 保存到redis
+            String tmplKey = "workAttendance_" + DateTime.now().toString("yyMMddHHmmssSSS");
+            valueOperations.set(tmplKey,personMapList,5, TimeUnit.MINUTES);
 
-            msgResult.setData(downloadUrl);
+            dataMap.put("list",personMapList);
+//          dataMap.put("url",downloadUrl);
+
+            List<Map> dayColumns = new ArrayList<>();
+
+            for (int i=0;i<days;i++){
+                Map<String,Object> map = new HashMap<>();
+                DateTime dt = startTime.plusDays(i);
+
+                map.put("name",dt.toString("yyyy-MM-dd"));
+                map.put("label",dt.toString("MM-dd") + " " + dt.dayOfWeek().getAsShortText(Locale.CHINA));
+
+                dayColumns.add(map);
+            }
+
+            dataMap.put("dayColumns", dayColumns);
+            dataMap.put("tmplKey",tmplKey);
+
+            msgResult.setData(dataMap);
             msgResult.setResult(true);
         }
         catch (Exception ex){
@@ -226,172 +248,198 @@ public class WorkAttendanceController {
         return cellStyle;
     }
 
-    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.xls");
+    @ApiOperation(value="导出考勤报表")
+    @RequestMapping(value = "exportXls",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="tmplKey",value = "模板数据key",required = true,paramType = "form"),
+            @ApiImplicitParam(name = "startDate",value = "开始时间", required = true,paramType="form"),
+            @ApiImplicitParam(name = "endDate",value = "截止时间", required = true,paramType="form"),
+            @ApiImplicitParam(name = "subject",value = "subject", required = false,paramType="form")
+    })
+    public MessageResult<String> exportXls(
+            String tmplKey,
+            @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
+            @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
+            @RequestAttribute String subject) throws Exception {
+        MessageResult<String> msgResult = new MessageResult<>();
 
-        Workbook wb = WorkbookFactory.create(resource.getInputStream());
+        try {
+            DateTime startTime = new DateTime(startDate);
+            DateTime endTime = new DateTime(endDate);
 
-        Sheet sheet = wb.getSheetAt(0);
+            List<Map> personMapList = (List<Map>) valueOperations.get(tmplKey);
 
-        Row row1 = sheet.getRow(0);
-        Row row2 = sheet.getRow(1);
-        Row row3 = sheet.getRow(2);
+            int days = Days.daysBetween(startTime, endTime).getDays();
+            ClassPathResource resource = new ClassPathResource("static/workAttendanceReport.xls");
 
-        String title = row1.getCell(0).getStringCellValue();
-        String subTitle = row2.getCell(0).getStringCellValue();
+            Workbook wb = WorkbookFactory.create(resource.getInputStream());
 
-        row1.getCell(0).setCellValue(String.format(title,startTime.toString("yyyy-MM-dd"),endTime.toString("yyyy-MM-dd")));
-        row2.getCell(0).setCellValue(String.format(subTitle,DateTime.now().toString("yyyy-MM-dd HH:mm")));
+            Sheet sheet = wb.getSheetAt(0);
 
-        int dayStartColIndex = 11;
+            Row row1 = sheet.getRow(0);
+            Row row2 = sheet.getRow(1);
+            Row row3 = sheet.getRow(2);
 
-        for (int i=0;i<days;i++){
-            DateTime dt = startTime.plusDays(i);
-            row3.getCell(dayStartColIndex + i).setCellValue(dt.toString("MM-dd") + "\r\n" + dt.dayOfWeek().getAsShortText(Locale.CHINA));
-        }
+            String title = row1.getCell(0).getStringCellValue();
+            String subTitle = row2.getCell(0).getStringCellValue();
 
-        //todo 写考勤记录
-        int startRowIndex = 3;
+            row1.getCell(0).setCellValue(String.format(title, startTime.toString("yyyy-MM-dd"), endTime.toString("yyyy-MM-dd")));
+            row2.getCell(0).setCellValue(String.format(subTitle, DateTime.now().toString("yyyy-MM-dd HH:mm")));
 
-        Font redFont = wb.createFont();
-        redFont.setColor(Font.COLOR_RED);
+            int dayStartColIndex = 11;
 
-        for (int i=0;i<personMapList.size();i++) {
-            Row row = sheet.createRow(startRowIndex + i);
-            Map personMap = personMapList.get(i);
+            for (int i = 0; i < days; i++) {
+                DateTime dt = startTime.plusDays(i);
+                row3.getCell(dayStartColIndex + i).setCellValue(dt.toString("MM-dd") + "\r\n" + dt.dayOfWeek().getAsShortText(Locale.CHINA));
+            }
 
-            PersonInfo personInfo = (PersonInfo)personMap.get("personInfo");
-            row.createCell(0).setCellValue(personInfo.getName());
+            //todo 写考勤记录
+            int startRowIndex = 3;
 
-            String companyName = (String)personMap.get("company");
-            row.createCell(1).setCellValue(companyName);
+            Font redFont = wb.createFont();
+            redFont.setColor(Font.COLOR_RED);
 
-            String department = (String)personMap.get("department");
-            row.createCell(2).setCellValue(department);
+            for (int i = 0; i < personMapList.size(); i++) {
+                Row row = sheet.createRow(startRowIndex + i);
+                Map personMap = personMapList.get(i);
 
-            String jobNumber = (String)personMap.get("jobNumber");
-            row.createCell(3).setCellValue(jobNumber);
+                String name = (String) personMap.get("name");
+                row.createCell(0).setCellValue(name);
 
-            Integer workDays = Integer.valueOf(personMap.get("workDays").toString());
-            row.createCell(4).setCellValue(workDays);
+                String companyName = (String) personMap.get("company");
+                row.createCell(1).setCellValue(companyName);
 
-            Integer restDays = Integer.valueOf(personMap.get("restDays").toString());
-            row.createCell(5).setCellValue(restDays);
+                String department = (String) personMap.get("department");
+                row.createCell(2).setCellValue(department);
 
-            Integer lateNum = Integer.valueOf(personMap.get("lateNum").toString());
-            row.createCell(6).setCellValue(lateNum);
+                String jobNumber = (String) personMap.get("jobNumber");
+                row.createCell(3).setCellValue(jobNumber);
 
-            Integer leaveNum = Integer.valueOf(personMap.get("leaveNum").toString());
-            row.createCell(7).setCellValue(leaveNum);
+                Integer workDays = Integer.valueOf(personMap.get("workDays").toString());
+                row.createCell(4).setCellValue(workDays);
 
-            Integer missCardOnWorkCount = Integer.valueOf(personMap.get("missCardOnWorkCount").toString());
-            row.createCell(8).setCellValue(missCardOnWorkCount);
+                Integer restDays = Integer.valueOf(personMap.get("restDays").toString());
+                row.createCell(5).setCellValue(restDays);
 
-            Integer missCardOffWorkCount = Integer.valueOf(personMap.get("missCardOffWorkCount").toString());
-            row.createCell(9).setCellValue(missCardOffWorkCount);
+                Integer lateNum = Integer.valueOf(personMap.get("lateNum").toString());
+                row.createCell(6).setCellValue(lateNum);
 
-            Integer missCardAllDayCount = Integer.valueOf(personMap.get("missCardAllDayCount").toString());
-            row.createCell(10).setCellValue(missCardAllDayCount);
+                Integer leaveNum = Integer.valueOf(personMap.get("leaveNum").toString());
+                row.createCell(7).setCellValue(leaveNum);
 
-            Map<String,List> workAttendanceMap = (Map<String,List>)personMap.get("workAttendanceMap");
+                Integer missCardOnWorkCount = Integer.valueOf(personMap.get("missCardOnWorkCount").toString());
+                row.createCell(8).setCellValue(missCardOnWorkCount);
 
-            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
+                Integer missCardOffWorkCount = Integer.valueOf(personMap.get("missCardOffWorkCount").toString());
+                row.createCell(9).setCellValue(missCardOffWorkCount);
 
-            for(int j=0;j<days;j++){
-                String key = startTime.plusDays(j).toString("yyyy-MM-dd");
+                Integer missCardAllDayCount = Integer.valueOf(personMap.get("missCardAllDayCount").toString());
+                row.createCell(10).setCellValue(missCardAllDayCount);
 
-                if (workAttendanceMap.containsKey(key)){
-                    List<WorkAttendance> workAttendanceList = workAttendanceMap.get(key);
+                Map<String, List> workAttendanceMap = (Map<String, List>) personMap.get("workAttendanceMap");
 
-                    List<Map> posList = new ArrayList<>();
+                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
 
-                    StringBuilder sb = new StringBuilder();
+                for (int j = 0; j < days; j++) {
+                    String key = startTime.plusDays(j).toString("yyyy-MM-dd");
 
-                    for (WorkAttendance item : workAttendanceList) {
-                        if (sb.length()!=0){
-                            sb.append("\r\n");
-                        }
+                    if (workAttendanceMap.containsKey(key)) {
+                        List<WorkAttendance> workAttendanceList = workAttendanceMap.get(key);
 
-                        if(item.getClassifier().equals(1)){
-                            sb.append("上班");
-                        }
-                        else{
-                            sb.append("下班");
-                        }
+                        List<Map> posList = new ArrayList<>();
 
-                        if (WorkAttendance.SUCCESS.equals(item.getResult())){
-                            sb.append("打卡");
-                        }
-                        else if (WorkAttendance.LATE.equals(item.getResult())){
-                            sb.append("迟到");
-                        }
-                        else if (WorkAttendance.LEAVE_EARLY.equals(item.getResult())){
-                            sb.append("早退");
-                        }
+                        StringBuilder sb = new StringBuilder();
 
-                        Map<String,Integer> pos = null;
+                        for (WorkAttendance item : workAttendanceList) {
+                            if (sb.length() != 0) {
+                                sb.append("\r\n");
+                            }
 
-                        if(WorkAttendance.MISSING.equals(item.getResult())){
-                            pos = new HashMap<>();
-                            pos.put("start",sb.length()-2);
-                            sb.append("缺卡");
-                        }
+                            if (item.getClassifier().equals(1)) {
+                                sb.append("上班");
+                            } else {
+                                sb.append("下班");
+                            }
 
-                        if(item.getRecordTime()!=null) {
-                            sb.append(" " + sdf.format(item.getRecordTime()));
+                            if (WorkAttendance.SUCCESS.equals(item.getResult())) {
+                                sb.append("打卡");
+                            } else if (WorkAttendance.LATE.equals(item.getResult())) {
+                                sb.append("迟到");
+                            } else if (WorkAttendance.LEAVE_EARLY.equals(item.getResult())) {
+                                sb.append("早退");
+                            }
+
+                            Map<String, Integer> pos = null;
 
-                            if(pos!=null) {
-                                pos.put("end", sb.length());
-                                posList.add(pos);
+                            if (WorkAttendance.MISSING.equals(item.getResult())) {
+                                pos = new HashMap<>();
+                                pos.put("start", sb.length() - 2);
+                                sb.append("缺卡");
+                            }
+
+                            if (item.getRecordTime() != null) {
+                                sb.append(" " + sdf.format(item.getRecordTime()));
+
+                                if (pos != null) {
+                                    pos.put("end", sb.length());
+                                    posList.add(pos);
+                                }
                             }
                         }
-                    }
 
-                    HSSFRichTextString sText = new HSSFRichTextString(sb.toString());
+                        HSSFRichTextString sText = new HSSFRichTextString(sb.toString());
 
-                    for (Map map : posList) {
-                        int start = Integer.valueOf(map.get("start").toString());
-                        int end = Integer.valueOf(map.get("end").toString());
+                        for (Map map : posList) {
+                            int start = Integer.valueOf(map.get("start").toString());
+                            int end = Integer.valueOf(map.get("end").toString());
 
-                        sText.applyFont(start,end,redFont);
-                    }
+                            sText.applyFont(start, end, redFont);
+                        }
 
-                    row.createCell(dayStartColIndex + j).setCellValue(sText);
+                        row.createCell(dayStartColIndex + j).setCellValue(sText);
+                    }
                 }
             }
-        }
 
-        CellStyle cellStyle1 = createCellStyle(wb);
+            CellStyle cellStyle1 = createCellStyle(wb);
 
-        for (int i=0;i<personMapList.size();i++) {
-            Row row = sheet.getRow(startRowIndex + i);
+            for (int i = 0; i < personMapList.size(); i++) {
+                Row row = sheet.getRow(startRowIndex + i);
 
-            if (row!=null) {
-                for (int j = 0; j < row.getLastCellNum(); j++) {
-                    if (row.getCell(j) != null) {
-                        row.getCell(j).setCellStyle(cellStyle1);
+                if (row != null) {
+                    for (int j = 0; j < row.getLastCellNum(); j++) {
+                        if (row.getCell(j) != null) {
+                            row.getCell(j).setCellStyle(cellStyle1);
+                        }
                     }
                 }
             }
-        }
 
-        //todo 将wb保存到oss
-        ByteArrayOutputStream output = new ByteArrayOutputStream();
-        wb.write(output);
+            //todo 将wb保存到oss
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            wb.write(output);
 
-        byte[] buffer = output.toByteArray();
-        ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
 
-        String fileName = "考勤统计表.xls";
+            String fileName = "考勤统计表.xls";
 
-        String downloadUrl = OSSUtil.upload(ossConfig,"workAttendance",fileName,input);
+            String downloadUrl = OSSUtil.upload(ossConfig, "workAttendance", fileName, input);
 
-        wb.write(output);
-        wb.close();
-        output.close();
+            wb.write(output);
+            wb.close();
+            output.close();
 
-        return downloadUrl;
+            msgResult.setData(downloadUrl);
+            msgResult.setResult(true);
+        }
+        catch (Exception ex){
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+            logger.error(ex.getMessage());
+        }
+
+        return msgResult;
     }
 
     @ApiOperation(value="更新考勤记录")