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-biz/src/main/java/jnpf/service/impl/EmployeeServiceImpl.java |  235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 235 insertions(+), 0 deletions(-)

diff --git a/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/service/impl/EmployeeServiceImpl.java b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/service/impl/EmployeeServiceImpl.java
new file mode 100644
index 0000000..4f5e42b
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/service/impl/EmployeeServiceImpl.java
@@ -0,0 +1,235 @@
+package jnpf.service.impl;
+
+import com.lowagie.text.Document;
+import com.lowagie.text.Element;
+import com.lowagie.text.Font;
+import com.lowagie.text.Phrase;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfPCell;
+import com.lowagie.text.pdf.PdfPTable;
+import com.lowagie.text.pdf.PdfWriter;
+import jnpf.base.service.SuperServiceImpl;
+import jnpf.entity.EmployeeEntity;
+import jnpf.mapper.EmployeeMapper;
+import jnpf.model.EmployeeModel;
+import jnpf.model.employee.EmployeeImportVO;
+import jnpf.model.employee.PaginationEmployee;
+import jnpf.service.EmployeeService;
+import jnpf.util.DateUtil;
+import jnpf.util.JsonUtil;
+import jnpf.util.RandomUtil;
+import jnpf.util.UserProvider;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.io.FileOutputStream;
+import java.util.*;
+
+/**
+ * 鑱屽憳淇℃伅
+ *
+ * @author JNPF寮�鍙戝钩鍙扮粍
+ * @version V3.1.0
+ * @copyright 寮曡繄淇℃伅鎶�鏈湁闄愬叕鍙�
+ */
+@Slf4j
+@Service
+public class EmployeeServiceImpl extends SuperServiceImpl<EmployeeMapper, EmployeeEntity> implements EmployeeService {
+
+    @Override
+    public List<EmployeeEntity> getList() {
+        return this.baseMapper.getList();
+    }
+
+    @Override
+    public List<EmployeeEntity> getList(PaginationEmployee paginationEmployee) {
+        return this.baseMapper.getList(paginationEmployee);
+    }
+
+    @Override
+    public EmployeeEntity getInfo(String id) {
+        return this.baseMapper.getInfo(id);
+    }
+
+    @Override
+    public void delete(EmployeeEntity entity) {
+        this.baseMapper.delete(entity);
+    }
+
+    @Override
+    public void create(EmployeeEntity entity) {
+        this.baseMapper.create(entity);
+    }
+
+    @Override
+    public void update(String id, EmployeeEntity entity) {
+        this.baseMapper.update(id, entity);
+    }
+
+    @Override
+    public Map<String, Object> importPreview(List<EmployeeModel> personList) {
+        List<Map<String, Object>> dataRow = new ArrayList<>();
+        List<Map<String, Object>> columns = new ArrayList<>();
+        for (int i = 0; i < personList.size(); i++) {
+            Map<String, Object> dataRowMap = new HashMap<>();
+            EmployeeModel model = personList.get(i);
+            dataRowMap.put("enCode", model.getEnCode());
+            dataRowMap.put("fullName", model.getFullName());
+            dataRowMap.put("gender", model.getGender());
+            dataRowMap.put("departmentName", model.getDepartmentName());
+            dataRowMap.put("positionName", model.getPositionName());
+            dataRowMap.put("workingNature", model.getWorkingNature());
+            dataRowMap.put("idNumber", model.getIdNumber());
+            dataRowMap.put("telephone", model.getTelephone());
+            dataRowMap.put("attendWorkTime", model.getAttendWorkTime());
+            dataRowMap.put("birthday", model.getBirthday());
+            dataRowMap.put("education", model.getEducation());
+            dataRowMap.put("major", model.getMajor());
+            dataRowMap.put("graduationAcademy", model.getGraduationAcademy());
+            dataRowMap.put("graduationTime", model.getGraduationTime());
+            dataRow.add(dataRowMap);
+        }
+        for (int i = 1; i < 15; i++) {
+            Map<String, Object> columnsMap = new HashMap<>();
+            columnsMap.put("AllowDBNull", true);
+            columnsMap.put("AutoIncrement", false);
+            columnsMap.put("AutoIncrementSeed", 0);
+            columnsMap.put("AutoIncrementStep", 1);
+            columnsMap.put("Caption", this.getColumns(i));
+            columnsMap.put("ColumnMapping", 1);
+            columnsMap.put("ColumnName", this.getColumns(i));
+            columnsMap.put("Container", null);
+            columnsMap.put("DataType", "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
+            columnsMap.put("DateTimeMode", 3);
+            columnsMap.put("DefaultValue", null);
+            columnsMap.put("DesignMode", false);
+            columnsMap.put("Expression", "");
+            columnsMap.put("ExtendedProperties", "");
+            columnsMap.put("MaxLength", -1);
+            columnsMap.put("Namespace", "");
+            columnsMap.put("Ordinal", 0);
+            columnsMap.put("Prefix", "");
+            columnsMap.put("ReadOnly", false);
+            columnsMap.put("Site", null);
+            columnsMap.put("Table", personList);
+            columnsMap.put("Unique", false);
+            columns.add(columnsMap);
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("dataRow", dataRow);
+        map.put("columns", columns);
+        return map;
+    }
+
+    @Override
+    public EmployeeImportVO importData(List<EmployeeModel> dt) {
+
+        for (EmployeeModel model : dt) {
+            model.setAttendWorkTime(DateUtil.cstFormat(model.getAttendWorkTime()));
+            model.setBirthday(DateUtil.cstFormat(model.getBirthday()));
+            model.setGraduationTime(DateUtil.cstFormat(model.getGraduationTime()));
+        }
+        List<EmployeeEntity> entitys = JsonUtil.getJsonToList(dt, EmployeeEntity.class);
+        //璁板綍鎴愬姛浜嗗嚑鏉�
+        int sum = 0;
+        //璁板綍绗嚑鏉″け璐�
+        int num = 0;
+        List<EmployeeEntity> errList = new ArrayList<>();
+        for (EmployeeEntity entity : entitys) {
+            entity.setId(RandomUtil.uuId());
+            entity.setCreatorUserId(UserProvider.getLoginUserId());
+            entity.setCreatorTime(new Date());
+            try {
+                this.baseMapper.insert(entity);
+                sum++;
+            } catch (Exception e) {
+                errList.add(entity);
+                num++;
+                log.error("瀵煎叆绗�" + (num + 1) + "鏉℃暟鎹け璐�");
+            }
+
+        }
+        EmployeeImportVO vo = new EmployeeImportVO();
+        vo.setSnum(sum);
+        vo.setFnum(num);
+        if (vo.getFnum() > 0) {
+            vo.setResultType(1);
+            vo.setFailResult(JsonUtil.getJsonToList(errList, EmployeeModel.class));
+            return vo;
+        } else {
+            vo.setResultType(0);
+            return vo;
+        }
+    }
+
+    @Override
+    public void exportPdf(List<EmployeeEntity> list, String outputUrl) {
+        try {
+            Document document = new Document();
+            BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
+            Font font = new Font(bfChinese, 11, Font.NORMAL);
+            PdfWriter.getInstance(document, new FileOutputStream(outputUrl));
+            document.open();
+            PdfPTable row;
+            row = new PdfPTable(13);
+            //琛ㄥ崰椤甸潰100%瀹藉害
+            row.setWidthPercentage(100f);
+            //鏍囬
+            String[] titles = {"濮撳悕", "鎬у埆", "閮ㄩ棬", "鑱屼綅", "鐢ㄥ伐鎬ц川", "韬唤璇佸彿", "鑱旂郴鐢佃瘽", "鍑虹敓骞存湀", "鍙傚姞宸ヤ綔", "鏈�楂樺鍘�", "鎵�瀛︿笓涓�", "姣曚笟闄㈡牎", "姣曚笟鏃堕棿"};
+            for (String title : titles) {
+                row.addCell(createCell(title, font));
+            }
+            document.add(row);
+            //鍐呭
+            for (EmployeeEntity entity : list) {
+                row = new PdfPTable(13);
+                //琛ㄥ崰椤甸潰100%瀹藉害
+                row.setWidthPercentage(100f);
+                row.addCell(createCell(entity.getFullName(), font));
+                row.addCell(createCell(entity.getGender(), font));
+                row.addCell(createCell(entity.getDepartmentName(), font));
+                row.addCell(createCell(entity.getPositionName(), font));
+                row.addCell(createCell(entity.getWorkingNature(), font));
+                row.addCell(createCell(entity.getIdNumber(), font));
+                row.addCell(createCell(entity.getTelephone(), font));
+                row.addCell(createCell(entity.getAttendWorkTime() != null ? DateUtil.daFormat(entity.getAttendWorkTime()) : "", font));
+                row.addCell(createCell(entity.getBirthday() != null ? DateUtil.daFormat(entity.getBirthday()) : "", font));
+                row.addCell(createCell(entity.getEducation(), font));
+                row.addCell(createCell(entity.getMajor(), font));
+                row.addCell(createCell(entity.getGraduationAcademy(), font));
+                row.addCell(createCell(entity.getGraduationTime() != null ? DateUtil.daFormat(entity.getGraduationTime()) : "", font));
+                document.add(row);
+            }
+            document.close();
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    private PdfPCell createCell(String value, Font font) {
+        PdfPCell cell = new PdfPCell();
+        cell.setVerticalAlignment(Element.ALIGN_CENTER);
+        cell.setPhrase(new Phrase(value, font));
+        return cell;
+    }
+
+
+    private String getColumns(Integer key) {
+        Map<Integer, String> map = new HashMap<>();
+        map.put(1, "宸ュ彿");
+        map.put(2, "濮撳悕");
+        map.put(3, "鎬у埆");
+        map.put(4, "閮ㄩ棬");
+        map.put(5, "鑱屽姟");
+        map.put(6, "鐢ㄥ伐鎬ц川");
+        map.put(7, "韬唤璇佸彿");
+        map.put(8, "鑱旂郴鐢佃瘽");
+        map.put(9, "鍑虹敓骞存湀");
+        map.put(10, "鍙傚姞宸ヤ綔");
+        map.put(11, "鏈�楂樺鍘�");
+        map.put(12, "鎵�瀛︿笓涓�");
+        map.put(13, "姣曚笟闄㈡牎");
+        map.put(14, "姣曚笟鏃堕棿");
+        return map.get(key);
+    }
+}

--
Gitblit v1.8.0