yubo
2026-04-08 d90db860b7ea15a6d6c58a3e77b649966f3ab6bf
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpBaseInfoController.java
@@ -2,6 +2,7 @@
import cc.mrbird.febs.common.core.entity.FebsResponse;
import cc.mrbird.febs.common.core.entity.QueryRequest;
import cc.mrbird.febs.common.core.entity.constant.StringConstant;
import cc.mrbird.febs.common.core.entity.system.DicItem;
import cc.mrbird.febs.common.core.exception.FebsException;
import cc.mrbird.febs.common.core.utils.FebsUtil;
@@ -9,6 +10,7 @@
import cc.mrbird.febs.server.hr.entity.EmpBaseInfo;
import cc.mrbird.febs.server.hr.entity.EmpDimissionLog;
import cc.mrbird.febs.server.hr.entity.EmpJobChange;
import cc.mrbird.febs.server.hr.feign.IRemoteDeptService;
import cc.mrbird.febs.server.hr.feign.IRemoteDicItemService;
import cc.mrbird.febs.server.hr.service.*;
import cc.mrbird.febs.server.hr.util.PoiExportExcel;
@@ -25,6 +27,7 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@@ -51,7 +54,7 @@
@RequestMapping("empBaseInfo")
@RequiredArgsConstructor
public class EmpBaseInfoController {
    private final IRemoteDeptService remoteDeptService;
    private final IEmpBaseInfoService empBaseInfoService;
    private final IEmpWorkExperienceService empWorkExperienceService;
    private final IEmpPhysicalExamService empPhysicalExamService;
@@ -101,6 +104,7 @@
           throw new FebsException("已存在此身份证号:" + empBaseinfo.getCertificateNumb());
       }
        try {
            empBaseinfo.setEntryType("20");
            this.empBaseInfoService.createEmpBaseInfo(empBaseinfo);
        } catch (Exception e) {
            String message = "新增员工基本信息失败";
@@ -165,10 +169,11 @@
    @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);
        wrapper.eq("a.empStatus",0);
        wrapper.eq("a.delFlag",0);
        wrapper.orderByDesc("a.createTime");
        wrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA));
        List<EmpBaseInfo> allRoles = empBaseInfoService.listAll(wrapper);
        return new FebsResponse().data(allRoles);
    }
@@ -220,7 +225,7 @@
            empPhysicalExamService.importEmpPhysicalExam(listObject.get(2),returnList,dicItems);
            empContractInfoService.importEmpContractInfo(listObject.get(3),returnList,dicItems);
            empDimissionAttendService.importEmpDimissionAttend(listObject.get(4),returnList);
            empLeaveInfoService.importEmpLeaveInfo(listObject.get(5),returnList);
            empLeaveInfoService.importEmpLeaveInfo(listObject.get(5),returnList,dicItems);
            empResignService.importEmpResign(listObject.get(6),returnList);
            empUnemploymentService.importEmpUnemployment(listObject.get(7),returnList);
            empInsuranceService.importEmpInsurance(listObject.get(8),returnList,dicItems);
@@ -240,6 +245,7 @@
    @ApiOperation(value = "关闭员工档案")
    @PostMapping("dimission")
    @PreAuthorize("hasAuthority('empBaseinfo:dimission')")
    public void dimissionEmp(EmpDimissionLog empDimissionLog) throws FebsException {
        try {
            this.empBaseInfoService.closeEmpArchives(empDimissionLog);
@@ -251,6 +257,7 @@
    }
    @ApiOperation(value = "员工岗位变更")
    @PostMapping("jobChange")
    @PreAuthorize("hasAuthority('empBaseinfo:jobChange')")
    public void changeEmpJob(EmpJobChange empJobChange) throws FebsException {
        try {
            this.empBaseInfoService.changeEmpJob(empJobChange);
@@ -285,4 +292,122 @@
            throw new FebsException(message);
        }
    }
    @ApiOperation(value = "社保提醒人员基本信息翻页列表")
    @GetMapping("insurance/alert")
    @PreAuthorize("hasAuthority('empBaseinfo:list')")
    public FebsResponse insuranceAlertEmpBaseInfoList(QueryRequest request, EmpBaseInfo empBaseinfo) {
        empBaseinfo.setTimeRange(2);
        Map<String, Object> dataTable = FebsUtil.getDataTable(this.empBaseInfoService.findInsuranceEmpBaseInfos(request, empBaseinfo));
        return new FebsResponse().data(dataTable);
    }
    @ApiOperation(value = "退休提醒人员基本信息翻页列表")
    @GetMapping("retire/alert")
    @PreAuthorize("hasAuthority('empBaseinfo:list')")
    public FebsResponse retirementAlertEmpBaseInfoList(QueryRequest request, EmpBaseInfo empBaseinfo) {
        empBaseinfo.setTimeRange(2);
        Map<String, Object> dataTable = FebsUtil.getDataTable(this.empBaseInfoService.findRetirementEmpBaseInfos(request, empBaseinfo));
        return new FebsResponse().data(dataTable);
    }
    @ApiOperation(value = "退休解骋")
    @PostMapping("retire/dismiss")
    @PreAuthorize("hasAuthority('empBaseinfo:dimission')")
    public void retireDismissionEmp(EmpDimissionLog empDimissionLog) throws FebsException {
        try {
            empDimissionLog.setDimissionDate(new Date());
            this.empBaseInfoService.closeEmpArchives(empDimissionLog);
        } catch (Exception e) {
            String message = "退休解骋员工失败";
            log.error(message, e);
            throw new FebsException(message);
        }
    }
    @ApiOperation(value = "转正提醒人员基本信息翻页列表")
    @GetMapping("probation/alert")
    @PreAuthorize("hasAuthority('empBaseinfo:list')")
    public FebsResponse probationAlertEmpBaseInfoList(QueryRequest request, EmpBaseInfo empBaseinfo) {
        Map<String, Object> dataTable = FebsUtil.getDataTable(this.empBaseInfoService.findProbationEmpBaseInfos(request, empBaseinfo));
        return new FebsResponse().data(dataTable);
    }
    @ApiOperation(value = "设置人员转正信息")
    @PostMapping("probation/change")
    @PreAuthorize("hasAuthority('empBaseinfo:dimission')")
    public void probationChangeEmpBaseInfo(EmpBaseInfo empBaseinfo) {
        this.empBaseInfoService.probationEmpBaseInfo(empBaseinfo);
    }
    @ApiOperation(value = "导出社保四险员工")
    @PostMapping(value = "export/insurance")
    @ControllerEndpoint(operation = "导出社保四险数据", exceptionMessage = "导出 Excel 失败")
    public void exportInsuranceWithField(QueryRequest request, HttpServletRequest httpRequest, HttpServletResponse response, EmpBaseInfo empBaseinfo) throws IOException {
        String exportField = httpRequest.getParameter("exportField");
        log.info("exportField: {}", exportField);
        request.setPageSize(25535);
        request.setPageNum(1);
        List<EmpBaseInfo> exportList = this.empBaseInfoService.findInsuranceEmpBaseInfos(request, empBaseinfo).getRecords();
        exportExcel(response, exportField, exportList, "社保四险员工列表");
    }
    @ApiOperation(value = "导出退休提醒员工")
    @PostMapping(value = "export/retirement")
    @ControllerEndpoint(operation = "导出退休提醒数据", exceptionMessage = "导出 Excel 失败")
    public void exportRetirementWithField(QueryRequest request, HttpServletResponse response, String exportField, EmpBaseInfo empBaseinfo) throws IOException {
        request.setPageSize(25535);
        request.setPageNum(1);
        List<EmpBaseInfo> exportList = this.empBaseInfoService.findRetirementEmpBaseInfos(request, empBaseinfo).getRecords();
        exportExcel(response, exportField, exportList, "退休提醒员工列表");
    }
    @ApiOperation(value = "导出转正提醒员工")
    @PostMapping(value = "export/probation")
    @ControllerEndpoint(operation = "导出转正提醒数据", exceptionMessage = "导出 Excel 失败")
    public void exportProbationWithField(QueryRequest request, HttpServletResponse response, String exportField, EmpBaseInfo empBaseinfo) throws IOException {
        request.setPageSize(25535);
        request.setPageNum(1);
        List<EmpBaseInfo> exportList = this.empBaseInfoService.findProbationEmpBaseInfos(request, empBaseinfo).getRecords();
        exportExcel(response, exportField, exportList, "转正提醒员工列表");
    }
    @ApiOperation(value = "导出身份证到期员工")
    @PostMapping(value = "export/sfz")
    @ControllerEndpoint(operation = "导出身份证到期员工", exceptionMessage = "导出 Excel 失败")
    public void exportIdNumberWithField(QueryRequest request, HttpServletResponse response, String exportField, EmpBaseInfo empBaseinfo) throws IOException {
        request.setPageSize(25535);
        request.setPageNum(1);
        String index = empBaseinfo.getTimeRange().toString();
        List<EmpBaseInfo> exportList = this.empBaseInfoService.baseInfoList(index, null, null, "25535", "1", "11", null).getRecords();
        exportExcel(response, exportField, exportList, "身份证到期员工列表");
    }
    @ApiOperation(value = "导出合同到期员工")
    @PostMapping(value = "export/expireHt")
    @ControllerEndpoint(operation = "导出合同证到期员工", exceptionMessage = "导出 Excel 失败")
    public void exportExpireHtWithField(QueryRequest request, HttpServletResponse response, String exportField, EmpBaseInfo empBaseinfo) throws IOException {
        request.setPageSize(25535);
        request.setPageNum(1);
        String index = empBaseinfo.getTimeRange().toString();
        List<EmpBaseInfo> exportList = this.empBaseInfoService.baseInfoHeList(index, null, null, "25535", "1", "12", null).getRecords();
        exportExcel(response, exportField, exportList, "合同到期员工列表");
    }
    /**
     * 通用 Excel 导出方法
     *
     * @param response HTTP 响应对象
     * @param exportField 导出字段
     * @param exportList 导出数据列表
     * @param fileName 文件名(不含日期)
     * @throws IOException IO 异常
     */
    private void exportExcel(HttpServletResponse response, String exportField, List<EmpBaseInfo> exportList, String fileName) throws IOException {
        log.info("导出Excel - exportField: {}", exportField);
        log.info("导出Excel - exportList size: {}", exportList != null ? exportList.size() : 0);
        List<Map<String, Object>> allList = PoiExportExcel.getDataList(exportField, exportList, null);
        Date currentDate = new Date();
        String dateStr = DateUtil.formatDate(currentDate);
        PoiExportExcel.exportCommonExcel(response, fileName + dateStr, fileName, allList);
    }
}