From df489701802ac39013a2d29c9b6e01e7f905bba7 Mon Sep 17 00:00:00 2001
From: luoyb <412940104@qq.com>
Date: 星期四, 15 四月 2021 20:23:10 +0800
Subject: [PATCH] fix(bug修复): 导出员工信息时相关证件的名称转换

---
 febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpLeaveInfoController.java |  159 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 94 insertions(+), 65 deletions(-)

diff --git a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpLeaveInfoController.java b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpLeaveInfoController.java
index 73892c8..31ad4d0 100644
--- a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpLeaveInfoController.java
+++ b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpLeaveInfoController.java
@@ -1,30 +1,38 @@
 package cc.mrbird.febs.server.hr.controller;
 
+import cc.mrbird.febs.server.hr.annotation.ControllerEndpoint;
+import cc.mrbird.febs.server.hr.entity.EmpLaborTrouble;
 import cc.mrbird.febs.server.hr.entity.EmpLeaveInfo;
 import cc.mrbird.febs.server.hr.service.IEmpLeaveInfoService;
 import cc.mrbird.febs.common.core.entity.FebsResponse;
 import cc.mrbird.febs.common.core.entity.QueryRequest;
 import cc.mrbird.febs.common.core.exception.FebsException;
 import cc.mrbird.febs.common.core.utils.FebsUtil;
+import com.wuwenze.poi.ExcelKit;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import java.util.List;
 import java.util.Map;
 
 /**
-*
-* name:EmpLeaveinfo
-* package:cc.mrbird.febs.server.hr.controller
-* description:员工请假记录控制器
-*
-* @author luoyibo
-* @date 2021-01-31 11:26:13
-* @since JDK1.8
-*/
+ * name:EmpLeaveinfo
+ * package:cc.mrbird.febs.server.hr.controller
+ * description:员工请假记录控制器
+ *
+ * @author luoyibo
+ * @date 2021-01-31 11:26:13
+ * @since JDK1.8
+ */
+@Api(tags = "人员请假信息录入接口")
 @Slf4j
 @Validated
 @RestController
@@ -32,66 +40,87 @@
 @RequiredArgsConstructor
 public class EmpLeaveInfoController {
 
-private final IEmpLeaveInfoService empLeaveinfoService;
+    private final IEmpLeaveInfoService empLeaveinfoService;
 
-@GetMapping
-@PreAuthorize("hasAuthority('empLeaveinfo:list')")
-public FebsResponse getAllEmpLeaveinfos(EmpLeaveInfo empLeaveinfo) {
-return new FebsResponse().data(empLeaveinfoService.findEmpLeaveinfos(empLeaveinfo));
-}
+    @GetMapping
+    @PreAuthorize("hasAuthority('empLeaveinfo:list')")
+    public FebsResponse getAllEmpLeaveinfos(EmpLeaveInfo empLeaveinfo) {
+        return new FebsResponse().data(empLeaveinfoService.findEmpLeaveInfos(empLeaveinfo));
+    }
 
-@GetMapping("list")
-@PreAuthorize("hasAuthority('empLeaveinfo:list')")
-public FebsResponse empLeaveinfoList(QueryRequest request, EmpLeaveInfo empLeaveinfo) {
-Map<String, Object> dataTable = FebsUtil.getDataTable(this.empLeaveinfoService.findEmpLeaveinfos(request, empLeaveinfo));
-return new FebsResponse().data(dataTable);
-}
+    @GetMapping("list")
+    @PreAuthorize("hasAuthority('empLeaveinfo:list')")
+    public FebsResponse empLeaveinfoList(QueryRequest request, EmpLeaveInfo empLeaveinfo) {
+        Map<String, Object> dataTable = FebsUtil.getDataTable(this.empLeaveinfoService.findEmpLeaveInfos(request, empLeaveinfo));
+        return new FebsResponse().data(dataTable);
+    }
 
-@PostMapping
-@PreAuthorize("hasAuthority('empLeaveinfo:add')")
-public void addEmpLeaveinfo(@Valid EmpLeaveInfo empLeaveinfo) throws FebsException {
-try {
-this.empLeaveinfoService.createEmpLeaveinfo(empLeaveinfo);
-} catch (Exception e) {
-String message = "新增员工请假记录失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @ApiOperation(value = "导出员工")
+    @RequestMapping(value = "export", method = RequestMethod.POST)
+    @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败")
+    public void export(QueryRequest request, EmpLeaveInfo empBaseinfo, HttpServletResponse response) {
+        request.setPageSize(this.empLeaveinfoService.count());
+        List<EmpLeaveInfo> records = this.empLeaveinfoService.findEmpLeaveInfos(request, empBaseinfo).getRecords();
+        ExcelKit.$Export(EmpLeaveInfo.class, response).downXlsx(records, false);
+    }
 
-@DeleteMapping
-@PreAuthorize("hasAuthority('empLeaveinfo:delete')")
-public void deleteEmpLeaveinfo(EmpLeaveInfo empLeaveinfo) throws FebsException {
-try {
-this.empLeaveinfoService.deleteEmpLeaveinfo(empLeaveinfo);
-} catch (Exception e) {
-String message = "删除员工请假记录失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @PostMapping
+    @PreAuthorize("hasAuthority('empLeaveinfo:add')")
+    public void addEmpLeaveinfo(@Valid EmpLeaveInfo empLeaveinfo) throws FebsException {
+        try {
+            this.empLeaveinfoService.createEmpLeaveinfo(empLeaveinfo);
+        } catch (Exception e) {
+            String message = "新增员工请假记录失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 
-@DeleteMapping("{ids}")
-@PreAuthorize("hasAuthority('empLeaveinfo:delete')")
-public void logicDeleteEmpLeaveinfo(@PathVariable("ids") String ids) throws FebsException {
-try {
-this.empLeaveinfoService.logicDelEmpLeaveinfo(ids);
-} catch (Exception e) {
-String message = "逻辑删除员工请假记录失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @DeleteMapping
+    @PreAuthorize("hasAuthority('empLeaveinfo:delete')")
+    public void deleteEmpLeaveinfo(EmpLeaveInfo empLeaveinfo) throws FebsException {
+        try {
+            this.empLeaveinfoService.deleteEmpLeaveinfo(empLeaveinfo);
+        } catch (Exception e) {
+            String message = "删除员工请假记录失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 
-@PutMapping
-@PreAuthorize("hasAuthority('empLeaveinfo:update')")
-public void updateEmpLeaveinfo(EmpLeaveInfo empLeaveinfo) throws FebsException {
-try {
-this.empLeaveinfoService.updateEmpLeaveinfo(empLeaveinfo);
-} catch (Exception e) {
-String message = "修改员工请假记录失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @DeleteMapping("{ids}")
+    public void logicDeleteEmpLeaveinfo(@PathVariable("ids") String ids) throws FebsException {
+        try {
+            this.empLeaveinfoService.logicDelEmpLeaveinfo(ids);
+        } catch (Exception e) {
+            String message = "逻辑删除员工请假记录失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+
+    @PutMapping
+    @PreAuthorize("hasAuthority('empLeaveinfo:update')")
+    public void updateEmpLeaveinfo(EmpLeaveInfo empLeaveinfo) throws FebsException {
+        try {
+            this.empLeaveinfoService.updateEmpLeaveinfo(empLeaveinfo);
+        } catch (Exception e) {
+            String message = "修改员工请假记录失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+
+    @ApiOperation(value = "请假申请信息提交")
+    @DeleteMapping("toNormal/{ids}")
+    @PreAuthorize("hasAuthority('empLeaveinfo:delete')")
+    public void momentToNormal(@NotBlank(message = "{required}") @PathVariable("ids") String ids) throws FebsException {
+        try {
+            this.empLeaveinfoService.momentToNormal(ids);
+        } catch (Exception e) {
+            String message = "请假申请信息提交失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 }

--
Gitblit v1.8.0