From e83cdbeae135043cbf1b316660c32bc4c8ffdb83 Mon Sep 17 00:00:00 2001
From: yz_08 <yz_0812@outlook.com>
Date: 星期四, 13 五月 2021 15:41:57 +0800
Subject: [PATCH] 修改bug

---
 febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpPhysicalExamController.java |  149 +++++++++++++++++++++++++++++++------------------
 1 files changed, 94 insertions(+), 55 deletions(-)

diff --git a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpPhysicalExamController.java b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpPhysicalExamController.java
index fde104a..41c3e7d 100644
--- a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpPhysicalExamController.java
+++ b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpPhysicalExamController.java
@@ -1,85 +1,124 @@
 package cc.mrbird.febs.server.hr.controller;
 
+import cc.mrbird.febs.server.hr.annotation.ControllerEndpoint;
+import cc.mrbird.febs.server.hr.entity.EmpOccupational;
 import cc.mrbird.febs.server.hr.entity.EmpPhysicalExam;
 import cc.mrbird.febs.server.hr.service.IEmpPhysicalExamService;
 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:EmpPhysicalexam
-* package:cc.mrbird.febs.server.hr.controller
-* description:员工体检信息控制器
-*
-* @author luoyibo
-* @date 2021-01-24 20:35:19
-* @since JDK1.8
-*/
+ * name:EmpPhysicalexam
+ * package:cc.mrbird.febs.server.hr.controller
+ * description:员工体检信息控制器
+ *
+ * @author luoyibo
+ * @date 2021-01-31 09:11:00
+ * @since JDK1.8
+ */
+@Api(tags = "人员体检信息录入接口")
 @Slf4j
 @Validated
 @RestController
-@RequestMapping("empPhysicalexam")
+@RequestMapping("empPhysicalExam")
 @RequiredArgsConstructor
 public class EmpPhysicalExamController {
 
-private final IEmpPhysicalExamService empPhysicalexamService;
+    private final IEmpPhysicalExamService empPhysicalExamService;
 
-@GetMapping
-@PreAuthorize("hasAuthority('empPhysicalexam:list')")
-public FebsResponse getAllEmpPhysicalexams(EmpPhysicalExam empPhysicalexam) {
-return new FebsResponse().data(empPhysicalexamService.findEmpPhysicalexams(empPhysicalexam));
-}
+    @GetMapping
+    @PreAuthorize("hasAuthority('empPhysicalexam:list')")
+    public FebsResponse getAllEmpPhysicalExams(EmpPhysicalExam empPhysicalexam) {
+        return new FebsResponse().data(empPhysicalExamService.findEmpPhysicalExams(empPhysicalexam));
+    }
 
-@GetMapping("list")
-@PreAuthorize("hasAuthority('empPhysicalexam:list')")
-public FebsResponse empPhysicalexamList(QueryRequest request, EmpPhysicalExam empPhysicalexam) {
-Map<String, Object> dataTable = FebsUtil.getDataTable(this.empPhysicalexamService.findEmpPhysicalexams(request, empPhysicalexam));
-return new FebsResponse().data(dataTable);
-}
+    @GetMapping("list")
+    @PreAuthorize("hasAuthority('empPhysicalexam:list')")
+    public FebsResponse empPhysicalExamList(QueryRequest request, EmpPhysicalExam empPhysicalexam) {
+        Map<String, Object> dataTable = FebsUtil.getDataTable(this.empPhysicalExamService.findEmpPhysicalExams(request, empPhysicalexam));
+        return new FebsResponse().data(dataTable);
+    }
+    @ApiOperation(value = "导出员工")
+    @RequestMapping(value = "export",method= RequestMethod.POST)
+    @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败")
+    public void export(QueryRequest request, EmpPhysicalExam empBaseinfo, HttpServletResponse response) {
+        request.setPageSize(this.empPhysicalExamService.count());
+        List<EmpPhysicalExam> records = this.empPhysicalExamService.findEmpPhysicalExams(request, empBaseinfo).getRecords();
+        ExcelKit.$Export(EmpPhysicalExam.class, response).downXlsx(records, false);
+    }
+    @PostMapping
+    @PreAuthorize("hasAuthority('empPhysicalexam:add')")
+    public void addEmpPhysicalExam(@Valid EmpPhysicalExam empPhysicalexam) throws FebsException {
+        try {
+            this.empPhysicalExamService.createEmpPhysicalExam(empPhysicalexam);
+        } catch (Exception e) {
+            String message = "新增员工体检信息失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 
-@PostMapping
-@PreAuthorize("hasAuthority('empPhysicalexam:add')")
-public void addEmpPhysicalexam(@Valid EmpPhysicalExam empPhysicalexam) throws FebsException {
-try {
-this.empPhysicalexamService.createEmpPhysicalexam(empPhysicalexam);
-} catch (Exception e) {
-String message = "新增EmpPhysicalexam失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @DeleteMapping
+    @PreAuthorize("hasAuthority('empPhysicalexam:delete')")
+    public void deleteEmpPhysicalExam(EmpPhysicalExam empPhysicalexam) throws FebsException {
+        try {
+            this.empPhysicalExamService.deleteEmpPhysicalExam(empPhysicalexam);
+        } catch (Exception e) {
+            String message = "删除员工体检信息失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 
-@DeleteMapping
-@PreAuthorize("hasAuthority('empPhysicalexam:delete')")
-public void deleteEmpPhysicalexam(EmpPhysicalExam empPhysicalexam) throws FebsException {
-try {
-this.empPhysicalexamService.deleteEmpPhysicalexam(empPhysicalexam);
-} catch (Exception e) {
-String message = "删除EmpPhysicalexam失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @DeleteMapping("{ids}")
+    public void logicDeleteEmpPhysicalExam(@PathVariable("ids") String ids) throws FebsException {
+        try {
+            this.empPhysicalExamService.logicDelEmpPhysicalExam(ids);
+        } catch (Exception e) {
+            String message = "逻辑删除员工体检信息失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 
-@PutMapping
-@PreAuthorize("hasAuthority('empPhysicalexam:update')")
-public void updateEmpPhysicalexam(EmpPhysicalExam empPhysicalexam) throws FebsException {
-try {
-this.empPhysicalexamService.updateEmpPhysicalexam(empPhysicalexam);
-} catch (Exception e) {
-String message = "修改EmpPhysicalexam失败";
-log.error(message, e);
-throw new FebsException(message);
-}
-}
+    @PutMapping
+    @PreAuthorize("hasAuthority('empPhysicalexam:update')")
+    public void updateEmpPhysicalExam(EmpPhysicalExam empPhysicalexam) throws FebsException {
+        try {
+            this.empPhysicalExamService.updateEmpPhysicalExam(empPhysicalexam);
+        } catch (Exception e) {
+            String message = "修改员工体检信息失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+
+    @ApiOperation(value = "体检信息提交")
+    @DeleteMapping("toNormal/{ids}")
+    @PreAuthorize("hasAuthority('empPhysicalexam:delete')")
+    public void momentToNormal(@NotBlank(message = "{required}")  @PathVariable("ids") String ids) throws FebsException {
+        try {
+            this.empPhysicalExamService.momentToNormal(ids);
+        } catch (Exception e) {
+            String message = "体检信息提交失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
 }

--
Gitblit v1.8.0