浏览代码

新增新版考勤导入模版

anderx 1 年之前
父节点
当前提交
9b7be8b038
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

+ 25 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -10,6 +10,7 @@ import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.common.utils.file.MimeTypeUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.project.bo.*;
@@ -22,6 +23,8 @@ import com.ruoyi.project.service.ProjectStaffService;
 import com.ruoyi.project.service.ProjectTaskService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.http.HttpStatus;
+import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -496,4 +499,26 @@ public class ProjectTaskController extends BaseController {
         List<Map<Integer,String >>  list = util.importMapExcel(file.getInputStream(),0);
         return success(projectStaffRecordService.importClockData(list));
     }
+
+
+    /**
+     * 考勤打卡导入模版
+     */
+    @PostMapping("/importClockDataTemplate")
+    @Log(title = "项目管理", businessType = BusinessType.IMPORT)
+    @ApiOperation("考勤打卡导入模版")
+    public void importClockDataTemplate(HttpServletResponse response){
+        try
+        {
+            String realFileName = System.currentTimeMillis() + "_考勤模版".substring("考勤模版".indexOf("_") + 1);
+            String filePath = RuoYiConfig.getDownloadPath() + "考勤模版.xlsx";
+            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+            FileUtils.setAttachmentResponseHeader(response, realFileName);
+            FileUtils.writeBytes(filePath, response.getOutputStream());
+        }
+        catch (Exception e)
+        {
+            throw new ServiceException("下载文件失败", HttpStatus.SC_BAD_REQUEST);
+        }
+    }
 }