孔祥富
2021-03-02 267047add63a22b560789ddc2435aae2878492cf
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpBaseInfoController.java
@@ -15,6 +15,7 @@
import cc.mrbird.febs.server.hr.annotation.ControllerEndpoint;
import cc.mrbird.febs.server.hr.entity.EmpDimissionLog;
import cc.mrbird.febs.server.hr.entity.EmpJobChange;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wuwenze.poi.ExcelKit;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -98,7 +99,7 @@
        Map<String, Object> dataTable = FebsUtil.getDataTable(this.empBaseInfoService.findEmpBaseInfos(request, empBaseinfo));
        return new FebsResponse().data(dataTable);
    }
    @ApiOperation(value = "智搜人员基本信息翻页列表")
    @GetMapping("zslist")
    @PreAuthorize("hasAuthority('empBaseinfo:list')")
@@ -110,12 +111,11 @@
    @ApiOperation(value = "人员基本信息增加")
    @PostMapping
    @PreAuthorize("hasAuthority('empBaseinfo:add')")
    public void addEmpBaseInfo( MultipartFile file,@Valid EmpBaseInfo empBaseinfo) throws FebsException {
    public void addEmpBaseInfo(@Valid EmpBaseInfo empBaseinfo) throws FebsException {
       if(this.empBaseInfoService.verifyEmpNumb(empBaseinfo)){
           throw new FebsException("已存在此员工编号");
       }
        try {
            //EmpBaseInfo tempInfo = this.empBaseInfoService.
            this.empBaseInfoService.createEmpBaseInfo(empBaseinfo);
        } catch (Exception e) {
            String message = "新增员工基本信息失败";
@@ -153,7 +153,7 @@
    @ApiOperation(value = "人员基本信息修改")
    @PutMapping
    @PreAuthorize("hasAuthority('empBaseinfo:update')")
    public void updateEmpBaseInfo(MultipartFile file,@Valid EmpBaseInfo empBaseinfo) throws FebsException {
    public void updateEmpBaseInfo(@Valid EmpBaseInfo empBaseinfo) throws FebsException {
        if(this.empBaseInfoService.verifyEmpNumb(empBaseinfo)){
            throw new FebsException("已存在此员工编号:" + empBaseinfo.getEmpNumb());
        }
@@ -177,7 +177,16 @@
            throw new FebsException(message);
        }
    }
    @GetMapping("options")
    public FebsResponse roles() {
        QueryWrapper<EmpBaseInfo> wrapper=new QueryWrapper();
        wrapper.eq("empStatus",0);
        wrapper.eq("delFlag",0);
        wrapper.orderByDesc("createTime");
        List<EmpBaseInfo> allRoles = empBaseInfoService.list(wrapper);
        return new FebsResponse().data(allRoles);
    }
    @ApiOperation(value = "导出员工")
   @RequestMapping(value = "export",method= RequestMethod.POST)
    @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败")
@@ -185,6 +194,21 @@
        request.setPageSize(this.empBaseInfoService.count());
        List<EmpBaseInfo> records = this.empBaseInfoService.findZsEmpBaseInfos(request, empBaseinfo).getRecords();
        ExcelKit.$Export(EmpBaseInfo.class, response).downXlsx(records, false);
   }
    @ApiOperation(value = "导出员工")
   @RequestMapping(value = "exportWithField",method= RequestMethod.POST)
    @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败")
    public void exportWithField(QueryRequest request, HttpServletResponse response, String exportField,EmpBaseInfo empBaseinfo) throws IOException {
       request.setPageSize(25535);
       request.setPageNum(1);
      List<EmpBaseInfo> exportList = this.empBaseInfoService.findZsEmpBaseInfos(request, empBaseinfo).getRecords();
      List<Map<String, Object>> listMapDicItem = new ArrayList();
      List<Map<String, Object>> allList = PoiExportExcel.getDataList(exportField, exportList, listMapDicItem);
      String fileName = "在职员工列表";
      Date currentDate = new Date();
      String dateStr = DateUtil.formatDate(currentDate);
      boolean result = PoiExportExcel.exportCommonExcel(response, fileName + dateStr, fileName, allList);
   }
    @ApiOperation(value = "导入员工")
@@ -239,4 +263,16 @@
            throw new FebsException(message);
        }
    }
    @GetMapping("image/{empId}")
    public void getImage(@PathVariable String empId, HttpServletResponse response) throws FebsException {
        try {
            this.empBaseInfoService.getImage(empId,response);
        } catch (Exception e) {
            String message = "获取员工图片异常";
            log.error(message, e);
            throw new FebsException(message);
        }
    }
}