From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/EmployeeController.java |  476 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 476 insertions(+), 0 deletions(-)

diff --git a/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/EmployeeController.java b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/EmployeeController.java
new file mode 100644
index 0000000..9419371
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/EmployeeController.java
@@ -0,0 +1,476 @@
+package jnpf.controller;
+
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+import com.alibaba.fastjson.JSON;
+import feign.Response;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import jnpf.base.ActionResult;
+import jnpf.base.controller.SuperController;
+import jnpf.base.vo.DownloadVO;
+import jnpf.base.vo.PageListVO;
+import jnpf.base.vo.PaginationVO;
+import jnpf.config.ConfigValueUtil;
+import jnpf.constant.FileTypeConstant;
+import jnpf.constant.MsgCode;
+import jnpf.entity.EmployeeEntity;
+import jnpf.exception.DataException;
+import jnpf.exception.ImportException;
+import jnpf.file.FileApi;
+import jnpf.file.FileUploadApi;
+import jnpf.model.EmployeeModel;
+import jnpf.model.employee.*;
+import jnpf.model.upload.UploadFileModel;
+import jnpf.service.EmployeeService;
+import jnpf.util.*;
+import jnpf.util.type.StringNumber;
+import lombok.Cleanup;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.dromara.x.file.storage.core.FileInfo;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鑱屽憳淇℃伅
+ *
+ * @author JNPF寮�鍙戝钩鍙扮粍
+ * @version V3.1.0
+ * @copyright 寮曡繄淇℃伅鎶�鏈湁闄愬叕鍙�
+ */
+@Slf4j
+@Tag(name = "鑱屽憳淇℃伅", description = "Employee")
+@RestController
+@RequestMapping("/Employee")
+@RequiredArgsConstructor
+public class EmployeeController extends SuperController<EmployeeService, EmployeeEntity> {
+
+    private final EmployeeService employeeService;
+
+    private final ConfigValueUtil configValueUtil;
+
+    private final FileApi fileApi;
+
+    private final FileUploadApi fileUploadApi;
+
+    private static final String BIRTHDAY = "birthday";
+
+    private static final String GRADUATION_ACADEMY = "graduationAcademy";
+
+    private static final String EDUCATION = "education";
+    private static final String XLSX = ".xlsx";
+    private static final String FULL_NAME = "fullName";
+    private static final String GENDER = "gender";
+    private static final String DEPARTMENT_NAME = "departmentName";
+    private static final String POSITION_NAME = "positionName";
+    private static final String WORKING_NATURE = "workingNature";
+    private static final String ID_NUMBER = "idNumber";
+    private static final String TELEPHONE = "telephone";
+    private static final String MAJOR = "major";
+    private static final String ATTEND_WORK_TIME = "attendWorkTime";
+    private static final String GRADUATION_TIME = "graduationTime";
+    private static final String TIME = "yyyyMMdd";
+    private static final String YYYY_MM_DD = "yyyy-MM-dd";
+    private static final String MESSAGE = "淇℃伅瀵煎嚭Excel閿欒:{}";
+    private static final String EN_CODE = "enCode";
+
+    /**
+     * 鍒楄〃(蹇界暐楠岃瘉Token)
+     *
+     * @param paginationEmployee 鍒嗛〉妯″瀷
+     * @return
+     */
+    @Operation(summary = "鑾峰彇鑱屽憳鍒楄〃")
+    @GetMapping
+    public ActionResult<PageListVO<EmployeeListVO>> getList(PaginationEmployee paginationEmployee) {
+        List<EmployeeEntity> data = employeeService.getList(paginationEmployee);
+        List<EmployeeListVO> list = JsonUtil.getJsonToList(data, EmployeeListVO.class);
+        PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationEmployee, PaginationVO.class);
+        return ActionResult.page(list, paginationVO);
+    }
+
+    /**
+     * 淇℃伅
+     *
+     * @param id 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鑾峰彇鑱屽憳淇℃伅")
+    @GetMapping("/{id}")
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    public ActionResult<EmployeeInfoVO> info(@PathVariable("id") String id) throws DataException {
+        EmployeeEntity entity = employeeService.getInfo(id);
+        EmployeeInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, EmployeeInfoVO.class);
+        return ActionResult.success(vo);
+    }
+
+    /**
+     * 鏂板缓
+     *
+     * @param employeeCrForm 鑱屽伐妯″瀷
+     * @return
+     */
+    @Operation(summary = "app娣诲姞鑱屽憳淇℃伅")
+    @PostMapping
+    @Parameter(name = "employeeCrForm", description = "鑱屽伐妯″瀷", required = true)
+    public ActionResult<Object> create(@RequestBody @Valid EmployeeCrForm employeeCrForm) {
+        EmployeeEntity entity = JsonUtil.getJsonToBean(employeeCrForm, EmployeeEntity.class);
+        employeeService.create(entity);
+        return ActionResult.success(MsgCode.SU001.get());
+    }
+
+    /**
+     * 鏇存柊
+     *
+     * @param id             涓婚敭
+     * @param employeeUpForm 鑱屽伐妯″瀷
+     * @return
+     */
+    @Operation(summary = "app淇敼鑱屽憳淇℃伅")
+    @PutMapping("/{id}")
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    @Parameter(name = "employeeUpForm", description = "鑱屽伐妯″瀷", required = true)
+    public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid EmployeeUpForm employeeUpForm) {
+        EmployeeEntity entity = JsonUtil.getJsonToBean(employeeUpForm, EmployeeEntity.class);
+        employeeService.update(id, entity);
+        return ActionResult.success(MsgCode.SU004.get());
+    }
+
+    /**
+     * 鍒犻櫎
+     *
+     * @param id 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鍒犻櫎鑱屽憳淇℃伅")
+    @DeleteMapping("/{id}")
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    public ActionResult<Object> delete(@PathVariable("id") String id) {
+        EmployeeEntity entity = employeeService.getInfo(id);
+        if (entity != null) {
+            employeeService.delete(entity);
+            return ActionResult.success(MsgCode.SU003.get());
+        }
+        return ActionResult.fail(MsgCode.FA003.get());
+    }
+
+    /**
+     * 妯℃澘涓嬭浇
+     *
+     * @return
+     */
+    @Operation(summary = "妯℃澘涓嬭浇")
+    @GetMapping("/TemplateDownload")
+    public ActionResult<DownloadVO> templateDownload() {
+        String fileName = "鑱屽憳淇℃伅.xlsx";
+        DownloadVO vo = DownloadVO.builder().build();
+        try {
+            vo.setName(fileName);
+            vo.setUrl(UploaderUtil.uploaderFile(fileName + "#" + FileTypeConstant.TEMPLATEFILE) + "&name=" + fileName);
+        } catch (Exception e) {
+            log.error(MESSAGE, e.getMessage());
+        }
+        return ActionResult.success(vo);
+    }
+
+    /**
+     * 瀵煎嚭Excel
+     *
+     * @return
+     */
+    @Operation(summary = "瀵煎嚭Excel")
+    @GetMapping("/ExportExcel")
+    public ActionResult<DownloadVO> exportExcel() {
+        List<EmployeeEntity> entityList = employeeService.getList();
+        List<EmployeeExportVO> list = JsonUtil.listToJsonField(JsonUtil.getJsonToList(JsonUtilEx.getObjectToStringDateFormat(entityList, YYYY_MM_DD), EmployeeExportVO.class));
+        List<ExcelExportEntity> entitys = new ArrayList<>();
+        entitys.add(new ExcelExportEntity("宸ュ彿", EN_CODE));
+        entitys.add(new ExcelExportEntity("濮撳悕", FULL_NAME));
+        entitys.add(new ExcelExportEntity("鎬у埆", GENDER));
+        entitys.add(new ExcelExportEntity("閮ㄩ棬", DEPARTMENT_NAME));
+        entitys.add(new ExcelExportEntity("鑱屽姟", POSITION_NAME, 25));
+        entitys.add(new ExcelExportEntity("鐢ㄥ伐鎬ц川", WORKING_NATURE));
+        entitys.add(new ExcelExportEntity("韬唤璇佸彿", ID_NUMBER, 25));
+        entitys.add(new ExcelExportEntity("鑱旂郴鐢佃瘽", TELEPHONE, 20));
+        entitys.add(new ExcelExportEntity("鍑虹敓骞存湀", BIRTHDAY, 20));
+        entitys.add(new ExcelExportEntity("鍙傚姞宸ヤ綔", ATTEND_WORK_TIME, 20));
+        entitys.add(new ExcelExportEntity("鏈�楂樺鍘�", EDUCATION));
+        entitys.add(new ExcelExportEntity("鎵�瀛︿笓涓�", MAJOR));
+        entitys.add(new ExcelExportEntity("姣曚笟闄㈡牎", GRADUATION_ACADEMY));
+        entitys.add(new ExcelExportEntity("姣曚笟鏃堕棿", GRADUATION_TIME, 20));
+        ExportParams exportParams = new ExportParams(null, "鑱屽憳淇℃伅");
+        exportParams.setType(ExcelType.XSSF);
+        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
+        String name = "鑱屽憳淇℃伅" + DateUtil.dateNow(TIME) + "_" + RandomUtil.uuId() + XLSX;
+        String fileName = fileApi.getLocalBasePath() + fileApi.getPath(FileTypeConstant.TEMPORARY) + name;
+        DownloadVO vo = DownloadVO.builder().build();
+        try {
+            @Cleanup FileOutputStream output = new FileOutputStream(fileName);
+            workbook.write(output);
+            vo.setName(name);
+            vo.setUrl(UploaderUtil.uploaderFile(name + "#" + FileTypeConstant.TEMPORARY));
+        } catch (Exception e) {
+            log.error(MESSAGE, e.getMessage());
+        }
+        return ActionResult.success(vo);
+    }
+
+    /**
+     * 瀵煎嚭Word
+     *
+     * @return
+     */
+    @Operation(summary = "瀵煎嚭Word")
+    @GetMapping("/ExportWord")
+    public ActionResult<DownloadVO> exportWord() {
+        List<EmployeeEntity> list = employeeService.getList();
+        //妯℃澘鏂囦欢鍦板潃
+        String inputUrl = fileApi.getPath(FileTypeConstant.TEMPLATEFILE) + "employee_export_template.docx";
+        //鏂扮敓浜х殑妯℃澘鏂囦欢
+        String name = "鑱屽憳淇℃伅" + DateUtil.dateNow(TIME) + "_" + RandomUtil.uuId() + ".docx";
+        String outputUrl = fileApi.getLocalBasePath() + fileApi.getPath(FileTypeConstant.TEMPORARY) + name;
+        List<String[]> testList = new ArrayList<>();
+        Map<String, String> testMap = new HashMap<>();
+        for (int i = 0; i < list.size(); i++) {
+            String[] employee = new String[13];
+            EmployeeEntity entity = list.get(i);
+            employee[0] = entity.getFullName();
+            employee[1] = entity.getGender();
+            employee[2] = entity.getDepartmentName();
+            employee[3] = entity.getPositionName();
+            employee[4] = entity.getWorkingNature();
+            employee[5] = entity.getIdNumber();
+            employee[6] = entity.getTelephone();
+            employee[7] = entity.getBirthday() != null ? DateUtil.daFormat(entity.getBirthday()) : "";
+            employee[8] = entity.getAttendWorkTime() != null ? DateUtil.daFormat(entity.getAttendWorkTime()) : "";
+            employee[9] = entity.getEducation();
+            employee[10] = entity.getMajor();
+            employee[11] = entity.getGraduationAcademy();
+            employee[12] = entity.getGraduationTime() != null ? DateUtil.daFormat(entity.getGraduationTime()) : "";
+            testList.add(employee);
+        }
+        WordUtil.changWord(inputUrl, outputUrl, testMap, testList);
+        if (FileUtil.fileIsFile(outputUrl)) {
+            DownloadVO vo = DownloadVO.builder().name(name).url(UploaderUtil.uploaderFile(name + "#" + FileTypeConstant.TEMPORARY)).build();
+            return ActionResult.success(vo);
+        }
+        return ActionResult.success(MsgCode.ETD109.get());
+    }
+
+    /**
+     * 瀵煎嚭pdf
+     *
+     * @return
+     */
+    @Operation(summary = "瀵煎嚭pdf")
+    @GetMapping("/ExportPdf")
+    public ActionResult<DownloadVO> exportPdf() {
+        String name = "鑱屽憳淇℃伅" + DateUtil.dateNow(TIME) + "_" + RandomUtil.uuId() + ".pdf";
+        String fileName = fileApi.getLocalBasePath() + fileApi.getPath(FileTypeConstant.TEMPORARY) + name;
+        employeeService.exportPdf(employeeService.getList(), fileName);
+        if (FileUtil.fileIsFile(fileName)) {
+            DownloadVO vo = DownloadVO.builder().name(name).url(UploaderUtil.uploaderFile(name + "#" + FileTypeConstant.TEMPORARY)).build();
+            return ActionResult.success(vo);
+        }
+        return ActionResult.success(MsgCode.ETD109.get());
+    }
+
+    /**
+     * 瀵煎嚭Excel
+     *
+     * @return
+     */
+    @Operation(summary = "瀵煎嚭Excel(澶囩敤)")
+    @GetMapping("/Excel")
+    public void excel() {
+        Map<String, Object> map = new HashMap<>();
+        List<EmployeeEntity> list = employeeService.getList();
+        TemplateExportParams param = new TemplateExportParams(fileApi.getPath(FileTypeConstant.TEMPLATEFILE) + "employee_import_template.xlsx", true);
+        map.put("Employee", JSON.parse(JSON.toJSONStringWithDateFormat(list, YYYY_MM_DD)));
+        Workbook workbook = ExcelExportUtil.exportExcel(param, map);
+        ExcelUtil.dowloadExcel(workbook, "鑱屽憳淇℃伅.xlsx");
+    }
+
+
+    /**
+     * 涓婁紶鏂囦欢(excel)
+     *
+     * @return
+     */
+    @Operation(summary = "涓婁紶鏂囦欢")
+    @PostMapping("/Uploader")
+    public ActionResult<DownloadVO> uploader() {
+        List<MultipartFile> list = UpUtil.getFileAll();
+        MultipartFile file = list.get(0);
+        if (file.getOriginalFilename().endsWith(XLSX) || file.getOriginalFilename().endsWith(".xls")) {
+            String fileName = RandomUtil.uuId() + "." + UpUtil.getFileType(file);
+            //涓婁紶鏂囦欢
+            FileInfo fileInfo = fileUploadApi.uploadFile(file, FileTypeConstant.TEMPORARY, fileName);
+            DownloadVO vo = DownloadVO.builder().build();
+            vo.setName(fileInfo.getFilename());
+            return ActionResult.success(vo);
+        } else {
+            return ActionResult.fail(MsgCode.ETD110.get());
+        }
+
+    }
+
+    /**
+     * 瀵煎叆棰勮
+     *
+     * @param fileName 鏂囦欢鍚嶇О
+     * @return
+     */
+    @Operation(summary = "瀵煎叆棰勮")
+    @GetMapping("/ImportPreview")
+    @Parameter(name = "fileName", description = "鏂囦欢鍚嶇О")
+    public ActionResult<Object> importPreview(@RequestParam("fileName") String fileName) throws ImportException {
+        Map<String, Object> map = new HashMap<>();
+        try {
+            @Cleanup Response response = fileUploadApi.downFile(new UploadFileModel(FileTypeConstant.TEMPORARY, fileName));
+            @Cleanup InputStream inputStream = response.body().asInputStream();
+            // 寰楀埌鏁版嵁
+            List<EmployeeModel> personList = ExcelUtil.importExcelByInputStream(inputStream, 0, 1, EmployeeModel.class);
+            //棰勮鏁版嵁
+            map = employeeService.importPreview(personList);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            throw new ImportException(e.getMessage());
+        }
+        return ActionResult.success(map);
+    }
+
+    /**
+     * 瀵煎叆鏁版嵁
+     *
+     * @param data 鑱屽伐妯″瀷
+     * @return
+     */
+    @Operation(summary = "瀵煎叆鏁版嵁")
+    @PostMapping("/ImportData")
+    @Parameter(name = "data", description = "鑱屽伐妯″瀷")
+    public ActionResult<EmployeeImportVO> importData(@RequestBody EmployeeModel data) throws Exception {
+        List<EmployeeModel> dataList  = new ArrayList<>();
+        if (data.isType()){
+            ActionResult<Object> result = importPreview(data.getFileName());
+            if (result == null){
+                throw new IllegalArgumentException(MsgCode.FA018.get());
+            }
+            if (result.getCode() != 200){
+                throw new IllegalArgumentException(result.getMsg());
+            }
+            if (result.getData() instanceof Map){
+                Map<String,Object> dataMap = (Map<String, Object>) result.getData();
+                dataList = JsonUtil.getJsonToList(dataMap.get("dataRow"),EmployeeModel.class);
+            }
+        }else {
+            dataList = data.getList();
+        }
+        //瀵煎叆鏁版嵁
+        EmployeeImportVO result = employeeService.importData(dataList);
+        return ActionResult.success(result);
+    }
+
+    /**
+     * 瀵煎嚭Excel(鍙�夊瓧娈�)
+     *
+     * @param paginationEmployee 鍒嗛〉妯″瀷
+     * @return
+     */
+    @Operation(summary = "瀵煎嚭Excel锛堝彲閫夊瓧娈碉級")
+    @GetMapping("/ExportData")
+    public ActionResult<DownloadVO> exportExcelData(PaginationEmployee paginationEmployee) {
+        String dataType = paginationEmployee.getDataType();
+        String selectKey = paginationEmployee.getSelectKey();
+        List<EmployeeEntity> entityList = new ArrayList<>();
+        if (StringNumber.ZERO.equals(dataType)) {
+            entityList = employeeService.getList(paginationEmployee);
+        } else if (StringNumber.ONE.equals(dataType)) {
+            entityList = employeeService.getList();
+        }
+        List<EmployeeExportVO> list = JsonUtil.listToJsonField(JsonUtil.getJsonToList(JsonUtilEx.getObjectToStringDateFormat(entityList, "yyyy-MM-dd HH:mm:ss"), EmployeeExportVO.class));
+        List<ExcelExportEntity> entitys = new ArrayList<>();
+        String[] splitData = selectKey.split(",");
+        for (String splitDatum : splitData) {
+            if (EN_CODE.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("宸ュ彿", EN_CODE));
+            }
+            if (FULL_NAME.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("濮撳悕", FULL_NAME));
+            }
+            if (GENDER.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鎬у埆", GENDER));
+            }
+            if (DEPARTMENT_NAME.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("閮ㄩ棬", DEPARTMENT_NAME));
+            }
+            if (POSITION_NAME.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鑱屽姟", POSITION_NAME, 25));
+            }
+            if (WORKING_NATURE.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鐢ㄥ伐鎬ц川", WORKING_NATURE));
+            }
+            if (ID_NUMBER.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("韬唤璇佸彿", ID_NUMBER, 25));
+            }
+            if (TELEPHONE.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鑱旂郴鐢佃瘽", TELEPHONE, 20));
+            }
+            if (BIRTHDAY.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鍑虹敓骞存湀", BIRTHDAY, 20));
+            }
+            if (ATTEND_WORK_TIME.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鍙傚姞宸ヤ綔", ATTEND_WORK_TIME, 20));
+            }
+            if (EDUCATION.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鏈�楂樺鍘�", EDUCATION));
+            }
+            if (MAJOR.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鎵�瀛︿笓涓�", MAJOR));
+            }
+            if (GRADUATION_ACADEMY.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("姣曚笟闄㈡牎", GRADUATION_ACADEMY));
+            }
+            if (GRADUATION_TIME.equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("姣曚笟鏃堕棿", GRADUATION_TIME, 20));
+            }
+            if ("creatorTime".equals(splitDatum)) {
+                entitys.add(new ExcelExportEntity("鍒涘缓鏃堕棿", "creatorTime"));
+            }
+        }
+        ExportParams exportParams = new ExportParams(null, "鑱屽憳淇℃伅");
+        exportParams.setType(ExcelType.XSSF);
+        DownloadVO vo = DownloadVO.builder().build();
+        try {
+            @Cleanup Workbook workbook = new HSSFWorkbook();
+            if (!entitys.isEmpty()) {
+                workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
+            }
+            String name = "鑱屽憳淇℃伅" + DateUtil.dateNow(TIME) + "_" + RandomUtil.uuId() + XLSX;
+            //涓婁紶鏂囦欢
+            MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, name);
+            FileInfo fileInfo = fileUploadApi.uploadFile(multipartFile, FileTypeConstant.TEMPORARY, name);
+            vo.setName(fileInfo.getFilename());
+            vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + FileTypeConstant.TEMPORARY) + "&name=" + name);
+        } catch (Exception e) {
+            log.error(MESSAGE, e.getMessage());
+        }
+        return ActionResult.success(vo);
+    }
+
+}

--
Gitblit v1.8.0