From dcc8bb8f47544cbad6e6440640dcdaa946086013 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 06 五月 2026 17:31:54 +0800
Subject: [PATCH] feat(staff): 员工模块新增民族出生日期入职日期字段

---
 src/main/java/com/ruoyi/staff/service/impl/StaffOnJobServiceImpl.java |  345 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 248 insertions(+), 97 deletions(-)

diff --git a/src/main/java/com/ruoyi/staff/service/impl/StaffOnJobServiceImpl.java b/src/main/java/com/ruoyi/staff/service/impl/StaffOnJobServiceImpl.java
index 6fb0cd0..8cecf7b 100644
--- a/src/main/java/com/ruoyi/staff/service/impl/StaffOnJobServiceImpl.java
+++ b/src/main/java/com/ruoyi/staff/service/impl/StaffOnJobServiceImpl.java
@@ -1,16 +1,19 @@
 package com.ruoyi.staff.service.impl;
 
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.dto.WordDateDto;
+import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysPost;
+import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.mapper.SysPostMapper;
 import com.ruoyi.staff.dto.StaffOnJobDto;
+import com.ruoyi.staff.dto.StaffOnJobImportDto;
 import com.ruoyi.staff.mapper.StaffContractMapper;
 import com.ruoyi.staff.mapper.StaffLeaveMapper;
 import com.ruoyi.staff.mapper.StaffOnJobMapper;
@@ -21,113 +24,126 @@
 import freemarker.template.Configuration;
 import freemarker.template.Template;
 import lombok.AllArgsConstructor;
-
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.time.Instant;
 import java.time.LocalDate;
 import java.time.ZoneId;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @AllArgsConstructor
 @Service
-public class StaffOnJobServiceImpl extends ServiceImpl<StaffOnJobMapper, StaffOnJob>  implements IStaffOnJobService {
+public class StaffOnJobServiceImpl extends ServiceImpl<StaffOnJobMapper, StaffOnJob> implements IStaffOnJobService {
 
-
+    @Autowired
     private StaffOnJobMapper staffOnJobMapper;
-
+    @Autowired
     private SysPostMapper sysPostMapper;
-
+    @Autowired
+    private SysDeptMapper sysDeptMapper;
+    @Autowired
     private StaffContractMapper staffContractMapper;
+    @Autowired
     private StaffLeaveMapper staffLeaveMapper;
 
-
-    //鍦ㄨ亴鍛樺伐鍙拌处鍒嗛〉鏌ヨ
     @Override
     public IPage<StaffOnJobDto> staffOnJobListPage(Page page, StaffOnJob staffOnJob) {
-        return staffOnJobMapper.staffOnJobListPage(page,staffOnJob);
+        IPage<StaffOnJobDto> result = staffOnJobMapper.staffOnJobListPage(page, staffOnJob);
+        fillNationFallback(result.getRecords());
+        return result;
     }
 
-    //鏂板鍏ヨ亴
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int add(StaffOnJobDto staffOnJobPrams) {
-        String[] ignoreProperties = {"id"};//鎺掗櫎id灞炴��
-        // 鍒ゆ柇缂栧彿鏄惁瀛樺湪
-        List<StaffOnJob> staffOnJobs = staffOnJobMapper.selectList(Wrappers.<StaffOnJob>lambdaQuery().eq(StaffOnJob::getStaffNo, staffOnJobPrams.getStaffNo()));
-        if (staffOnJobs.size()>0){
-            throw new BaseException("缂栧彿涓�"+staffOnJobPrams.getStaffNo()+"鐨勫憳宸ュ凡缁忓瓨鍦�,鏃犳硶鏂板!!!");
-        }
-        // 鍒涘缓鍏ヨ亴鏁版嵁
-        staffOnJobPrams.setContractExpireTime(staffOnJobPrams.getContractEndTime());
-        staffOnJobMapper.insert(staffOnJobPrams);
+    public int add(StaffOnJobDto staffOnJobParams) {
+        syncStaffBasicFields(staffOnJobParams);
 
-        // 鍒涘缓鍚堝悓璁板綍
+        List<StaffOnJob> existedStaffNo = staffOnJobMapper.selectList(Wrappers.<StaffOnJob>lambdaQuery()
+                .eq(StaffOnJob::getStaffNo, staffOnJobParams.getStaffNo()));
+        if (!CollectionUtils.isEmpty(existedStaffNo)) {
+            throw new BaseException("Duplicate staffNo: " + staffOnJobParams.getStaffNo());
+        }
+
+        staffOnJobParams.setContractExpireTime(staffOnJobParams.getContractEndTime());
+        staffOnJobParams.setStaffState(1);
+        staffOnJobMapper.insert(staffOnJobParams);
+
         StaffContract staffContract = new StaffContract();
-        staffContract.setStaffOnJobId(staffOnJobPrams.getId());
-        staffContract.setContractTerm(staffOnJobPrams.getContractTerm());
-        staffContract.setContractStartTime(staffOnJobPrams.getContractStartTime());
-        staffContract.setContractEndTime(staffOnJobPrams.getContractEndTime());
+        staffContract.setStaffOnJobId(staffOnJobParams.getId());
+        staffContract.setContractTerm(staffOnJobParams.getContractTerm());
+        staffContract.setContractStartTime(staffOnJobParams.getContractStartTime());
+        staffContract.setContractEndTime(staffOnJobParams.getContractEndTime());
         return staffContractMapper.insert(staffContract);
     }
 
-    //鏇存柊鍏ヨ亴淇℃伅
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int update(Long id, StaffOnJobDto staffOnJobParams) {
-        // 鍒ゆ柇瀵硅薄鏄惁瀛樺湪
+        syncStaffBasicFields(staffOnJobParams);
+        staffOnJobParams.setId(id);
+
         StaffOnJob job = staffOnJobMapper.selectById(id);
-        if (job == null){
-            throw new BaseException("缂栧彿涓�"+staffOnJobParams.getStaffNo()+"鐨勫憳宸ヤ笉瀛樺湪,鏃犳硶鏇存柊!!!");
+        if (job == null) {
+            throw new BaseException("Staff not found, id=" + id);
         }
 
-        String[] ignoreProperties = {"id"};//鎺掗櫎id灞炴��
+        if (StringUtils.isNotBlank(staffOnJobParams.getStaffNo())) {
+            List<StaffOnJob> existedStaffNo = staffOnJobMapper.selectList(Wrappers.<StaffOnJob>lambdaQuery()
+                    .eq(StaffOnJob::getStaffNo, staffOnJobParams.getStaffNo())
+                    .ne(StaffOnJob::getId, id));
+            if (!CollectionUtils.isEmpty(existedStaffNo)) {
+                throw new BaseException("Duplicate staffNo: " + staffOnJobParams.getStaffNo());
+            }
+        }
 
-        // 鑾峰彇鏈�鏂板悎鍚屾暟鎹紝骞朵笖鏇存柊
+        String[] ignoreProperties = {"id"};
         StaffContract contract = staffContractMapper.selectOne(Wrappers.<StaffContract>lambdaQuery()
                 .eq(StaffContract::getStaffOnJobId, id)
-                .last("limit 1")
-                .orderByDesc(StaffContract::getId));
-        if (contract != null){
-            BeanUtils.copyProperties(staffOnJobParams,contract,ignoreProperties);
+                .orderByDesc(StaffContract::getId)
+                .last("limit 1"));
+        if (contract != null) {
+            BeanUtils.copyProperties(staffOnJobParams, contract, ignoreProperties);
             staffContractMapper.updateById(contract);
         }
 
-        // 鏇存柊鍛樺伐鏁版嵁
-        BeanUtils.copyProperties(staffOnJobParams,job,ignoreProperties);
-        job.setContractExpireTime(staffOnJobParams.getContractEndTime());
-        return staffOnJobMapper.updateById(job);
+        staffOnJobParams.setContractExpireTime(staffOnJobParams.getContractEndTime());
+        return staffOnJobMapper.updateById(staffOnJobParams);
     }
 
-    //鍒犻櫎鍏ヨ亴
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int delStaffOnJobs(List<Integer> ids) {
-        // 鍒犻櫎鍏ヨ亴鏁版嵁
         staffOnJobMapper.deleteBatchIds(ids);
-        // 鍒犻櫎绂昏亴鏁版嵁
         staffLeaveMapper.delete(Wrappers.<StaffLeave>lambdaQuery().in(StaffLeave::getStaffOnJobId, ids));
-        // 鍒犻櫎鍚堝悓鏁版嵁
         return staffContractMapper.delete(Wrappers.<StaffContract>lambdaQuery().in(StaffContract::getStaffOnJobId, ids));
     }
 
-    // 缁鍚堝悓
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int renewContract(Long id, StaffContract staffContract) {
-        // 鍒ゆ柇瀵硅薄鏄惁瀛樺湪
         StaffOnJob job = staffOnJobMapper.selectById(id);
-        if (job == null){
-            throw new BaseException("璇ュ憳宸ヤ笉瀛樺湪,鏃犳硶鏇存柊!!!");
+        if (job == null) {
+            throw new BaseException("Staff not found, id=" + id);
         }
 
-        // 澧炲姞鍚堝悓
         StaffContract newStaffContract = new StaffContract();
         newStaffContract.setStaffOnJobId(id);
         newStaffContract.setContractTerm(staffContract.getContractTerm());
@@ -135,96 +151,237 @@
         newStaffContract.setContractEndTime(staffContract.getContractEndTime());
         staffContractMapper.insert(newStaffContract);
 
-        // 鏇存柊鍛樺伐鍚堝悓杩囨湡鏃堕棿
         job.setContractExpireTime(staffContract.getContractEndTime());
         staffOnJobMapper.updateById(job);
         return 0;
     }
 
-    //鍦ㄨ亴鍛樺伐璇︽儏
     @Override
     public StaffOnJobDto staffOnJobDetail(Long id) {
-        StaffOnJob staffOnJob  = staffOnJobMapper.selectById(id);
+        StaffOnJob staffOnJob = staffOnJobMapper.selectById(id);
         if (staffOnJob == null) {
-            throw new IllegalArgumentException("璇ュ憳宸ヤ笉瀛樺湪");
+            throw new BaseException("Staff not found, id=" + id);
         }
 
         StaffOnJobDto staffOnJobDto = new StaffOnJobDto();
         BeanUtils.copyProperties(staffOnJob, staffOnJobDto);
-        // 鏌ヨ宀椾綅鍚嶇О
-        SysPost post = sysPostMapper.selectPostById((long) staffOnJob.getSysPostId());
-        staffOnJobDto.setPostName(post.getPostName());
 
-        // 鏌ヨ鍚堝悓淇℃伅
+        if (staffOnJob.getSysPostId() != null) {
+            SysPost post = sysPostMapper.selectPostById(staffOnJob.getSysPostId().longValue());
+            if (post != null) {
+                staffOnJobDto.setPostName(post.getPostName());
+            }
+        }
+
         StaffContract contract = staffContractMapper.selectOne(Wrappers.<StaffContract>lambdaQuery()
                 .eq(StaffContract::getStaffOnJobId, staffOnJob.getId())
-                .last("limit 1")
-                .orderByDesc(StaffContract::getId));
-        if (contract != null){
+                .orderByDesc(StaffContract::getId)
+                .last("limit 1"));
+        if (contract != null) {
             staffOnJobDto.setContractTerm(contract.getContractTerm());
             staffOnJobDto.setContractStartTime(contract.getContractStartTime());
             staffOnJobDto.setContractEndTime(contract.getContractEndTime());
         }
+
+        fillNationFallback(staffOnJobDto);
         return staffOnJobDto;
     }
 
-    //鍦ㄨ亴鍛樺伐瀵煎嚭
     @Override
     public void staffOnJobExport(HttpServletResponse response, StaffOnJob staffOnJob) {
         List<StaffOnJobDto> staffOnJobs = staffOnJobMapper.staffOnJobList(staffOnJob);
-        ExcelUtil<StaffOnJobDto> util = new ExcelUtil<StaffOnJobDto>(StaffOnJobDto.class);
+        fillNationFallback(staffOnJobs);
+        ExcelUtil<StaffOnJobDto> util = new ExcelUtil<>(StaffOnJobDto.class);
         util.exportExcel(response, staffOnJobs, "鍦ㄨ亴鍛樺伐鍙拌处瀵煎嚭");
     }
 
     @Override
     public List<StaffOnJobDto> staffOnJobList(StaffOnJob staffOnJob) {
-        return staffOnJobMapper.staffOnJobList(staffOnJob);
+        List<StaffOnJobDto> staffOnJobs = staffOnJobMapper.staffOnJobList(staffOnJob);
+        fillNationFallback(staffOnJobs);
+        return staffOnJobs;
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean importData(MultipartFile file) {
         try {
-            ExcelUtil<StaffOnJob> util = new ExcelUtil<>(StaffOnJob.class);
-            List<StaffOnJob> staffOnJobs = util.importExcel(file.getInputStream());
-            return saveOrUpdateBatch(staffOnJobs);
+            ExcelUtil<StaffOnJobImportDto> util = new ExcelUtil<>(StaffOnJobImportDto.class);
+            List<StaffOnJobImportDto> staffOnJobs = util.importExcel(file.getInputStream());
+            if (CollectionUtils.isEmpty(staffOnJobs)) {
+                throw new BaseException("Import data is empty");
+            }
+
+            Map<String, SysPost> postMap = buildPostMap();
+            Map<String, SysDept> deptMap = buildDeptMap();
+            Set<String> importedStaffNos = new HashSet<>();
+            for (int i = 0; i < staffOnJobs.size(); i++) {
+                StaffOnJobDto staffOnJobDto = buildImportStaff(staffOnJobs.get(i), i + 2, postMap, deptMap, importedStaffNos);
+                add(staffOnJobDto);
+            }
+            return true;
         } catch (Exception e) {
-            e.printStackTrace();
-            return false;
+            if (e instanceof BaseException) {
+                throw (BaseException) e;
+            }
+            throw new BaseException("Import failed, please check template and data format");
         }
     }
 
+    private StaffOnJobDto buildImportStaff(StaffOnJobImportDto row, int rowNum, Map<String, SysPost> postMap,
+                                           Map<String, SysDept> deptMap, Set<String> importedStaffNos) {
+        String staffNo = normalizeValue(row.getStaffNo());
+        String postName = normalizeValue(row.getPostName());
+        String deptName = normalizeValue(row.getDeptName());
+
+        if (StringUtils.isBlank(staffNo)) {
+            throw new BaseException("Row " + rowNum + " staffNo cannot be blank");
+        }
+        if (!importedStaffNos.add(staffNo)) {
+            throw new BaseException("Row " + rowNum + " duplicated staffNo: " + staffNo);
+        }
+        if (StringUtils.isBlank(normalizeValue(row.getStaffName()))) {
+            throw new BaseException("Row " + rowNum + " staffName cannot be blank");
+        }
+        if (StringUtils.isBlank(postName)) {
+            throw new BaseException("Row " + rowNum + " postName cannot be blank");
+        }
+        if (StringUtils.isBlank(deptName)) {
+            throw new BaseException("Row " + rowNum + " deptName cannot be blank");
+        }
+        if (row.getContractStartTime() == null) {
+            throw new BaseException("Row " + rowNum + " contractStartTime cannot be blank");
+        }
+        if (row.getContractEndTime() == null) {
+            throw new BaseException("Row " + rowNum + " contractEndTime cannot be blank");
+        }
+        if (row.getEntryDate() == null) {
+            throw new BaseException("Row " + rowNum + " entryDate cannot be blank");
+        }
+
+        SysPost post = postMap.get(postName);
+        if (post == null) {
+            throw new BaseException("Row " + rowNum + " post not found or disabled: " + postName);
+        }
+        SysDept dept = deptMap.get(deptName);
+        if (dept == null) {
+            throw new BaseException("Row " + rowNum + " dept not found or disabled: " + deptName);
+        }
+
+        StaffOnJobDto staffOnJobDto = new StaffOnJobDto();
+        BeanUtils.copyProperties(row, staffOnJobDto);
+        staffOnJobDto.setStaffNo(staffNo);
+        staffOnJobDto.setStaffName(normalizeValue(row.getStaffName()));
+        staffOnJobDto.setSex(normalizeValue(row.getSex()));
+        staffOnJobDto.setNation(normalizeValue(row.getNation()));
+        staffOnJobDto.setNativePlace(normalizeValue(row.getNation()));
+        staffOnJobDto.setBirthDate(row.getBirthDate());
+        staffOnJobDto.setIdentityCard(normalizeValue(row.getIdentityCard()));
+        staffOnJobDto.setAdress(normalizeValue(row.getAdress()));
+        staffOnJobDto.setPhone(normalizeValue(row.getPhone()));
+        staffOnJobDto.setEmergencyContactPhone(normalizeValue(row.getEmergencyContactPhone()));
+        staffOnJobDto.setEntryDate(row.getEntryDate());
+        staffOnJobDto.setContractTerm(normalizeValue(row.getContractTerm()));
+        staffOnJobDto.setSysPostId(post.getPostId().intValue());
+        staffOnJobDto.setSysDeptId(dept.getDeptId().intValue());
+        syncStaffBasicFields(staffOnJobDto);
+        return staffOnJobDto;
+    }
+
+    private void syncStaffBasicFields(StaffOnJobDto staffOnJobDto) {
+        if (staffOnJobDto == null) {
+            return;
+        }
+        staffOnJobDto.setStaffNo(normalizeValue(staffOnJobDto.getStaffNo()));
+        staffOnJobDto.setStaffName(normalizeValue(staffOnJobDto.getStaffName()));
+        staffOnJobDto.setNation(normalizeValue(staffOnJobDto.getNation()));
+        staffOnJobDto.setNativePlace(normalizeValue(staffOnJobDto.getNativePlace()));
+        if (StringUtils.isBlank(staffOnJobDto.getNation())) {
+            staffOnJobDto.setNation(staffOnJobDto.getNativePlace());
+        }
+        if (StringUtils.isBlank(staffOnJobDto.getNativePlace())) {
+            staffOnJobDto.setNativePlace(staffOnJobDto.getNation());
+        }
+        if (staffOnJobDto.getEntryDate() == null) {
+            staffOnJobDto.setEntryDate(staffOnJobDto.getContractStartTime());
+        }
+    }
+
+    private void fillNationFallback(StaffOnJob staffOnJob) {
+        if (staffOnJob == null) {
+            return;
+        }
+        if (StringUtils.isBlank(staffOnJob.getNation())) {
+            staffOnJob.setNation(staffOnJob.getNativePlace());
+        }
+        if (StringUtils.isBlank(staffOnJob.getNativePlace())) {
+            staffOnJob.setNativePlace(staffOnJob.getNation());
+        }
+    }
+
+    private void fillNationFallback(List<? extends StaffOnJob> staffOnJobs) {
+        if (CollectionUtils.isEmpty(staffOnJobs)) {
+            return;
+        }
+        staffOnJobs.forEach(this::fillNationFallback);
+    }
+
+    private Map<String, SysPost> buildPostMap() {
+        SysPost query = new SysPost();
+        query.setStatus("0");
+        return buildUniqueMap(sysPostMapper.selectPostList(query), SysPost::getPostName, "post");
+    }
+
+    private Map<String, SysDept> buildDeptMap() {
+        SysDept query = new SysDept();
+        query.setStatus("0");
+        return buildUniqueMap(sysDeptMapper.selectDeptList(query), SysDept::getDeptName, "dept");
+    }
+
+    private <T> Map<String, T> buildUniqueMap(List<T> dataList, Function<T, String> nameGetter, String fieldName) {
+        Map<String, List<T>> groupedMap = dataList.stream()
+                .filter(Objects::nonNull)
+                .filter(item -> StringUtils.isNotBlank(normalizeValue(nameGetter.apply(item))))
+                .collect(Collectors.groupingBy(item -> normalizeValue(nameGetter.apply(item))));
+
+        List<String> duplicateNames = groupedMap.entrySet().stream()
+                .filter(entry -> entry.getValue().size() > 1)
+                .map(Map.Entry::getKey)
+                .sorted()
+                .collect(Collectors.toList());
+        if (!duplicateNames.isEmpty()) {
+            throw new BaseException("Duplicate " + fieldName + " names: " + String.join(", ", duplicateNames));
+        }
+
+        return groupedMap.entrySet().stream()
+                .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get(0)));
+    }
+
+    private String normalizeValue(String value) {
+        return value == null ? null : value.trim();
+    }
 
     @Override
     public String exportCopy(HttpServletResponse response, StaffOnJob staffOnJob) throws Exception {
         String url = "/javaWork/product-inventory-management/file/prod/" + staffOnJob.getStaffName() + "-鍔冲姩鍚堝悓涔�.docx";
         Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
-        // 璁剧疆妯℃澘鏂囦欢鎵�鍦ㄧ洰褰曪紙缁濆璺緞锛屼緥濡傦細/templates/锛�
         cfg.setClassForTemplateLoading(StaffOnJobServiceImpl.class, "/static");
         cfg.setDefaultEncoding("UTF-8");
-        //2.瀹氫箟闇�瑕佸~鍏呯殑鍙橀噷
-        // 鈶� 鏋勯�犲憳宸ヤ俊鎭紙瀹為檯椤圭洰涓彲浠庢暟鎹簱/Excel璇诲彇锛�
+
         WordDateDto staff = new WordDateDto();
         BeanUtils.copyProperties(staffOnJob, staff);
-        // 閫氳繃鍚堝悓骞撮檺锛屽悎鍚屽埌鏈熸棩鏈熻绠楀悎鍚屽紑濮嬫棩鏈燂紝鍦ㄨ幏鍙栧紑濮嬫棩鏈燂紝缁撴潫鏃ユ湡鐨勫勾鏈堟棩鏁板瓧
-        // 鍚堝悓鍒版湡鏃ユ湡 - 鍚堝悓骞撮檺锛圖ate绫诲瀷锛�
-        // 1. 灏咲ate杞崲涓篒nstant锛堟椂闂存埑锛�
+
         Instant instant = staff.getContractExpireTime().toInstant();
-
-        // 涔熷彲浠ユ寚瀹氬叿浣撴椂鍖猴紝渚嬪Asia/Shanghai锛�
-        LocalDate localDate = instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDate();  // 鍚堝悓缁撴潫鏃堕棿
-        LocalDate localDate1 = localDate.minusYears(Integer.parseInt(staff.getContractTerm()));// 鍚堝悓寮�濮嬫椂闂�
-
-        // 绛捐鏃ユ湡杞崲lcoaldate
+        LocalDate localDate = instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDate();
+        LocalDate localDate1 = localDate.minusYears(Integer.parseInt(staff.getContractTerm()));
         LocalDate localDate2 = staff.getSignDate().toInstant().atZone(ZoneId.of("Asia/Shanghai")).toLocalDate();
-
-        // 璇曠敤鏃ユ湡杞崲lcoaldate
         LocalDate localDate3 = staff.getTrialStartDate().toInstant().atZone(ZoneId.of("Asia/Shanghai")).toLocalDate();
         LocalDate localDate4 = staff.getTrialEndDate().toInstant().atZone(ZoneId.of("Asia/Shanghai")).toLocalDate();
 
         staff.setQyear(localDate2.getYear() + "");
         staff.setQmoth(localDate2.getMonthValue() + "");
         staff.setQday(localDate2.getDayOfMonth() + "");
-        if(staff.getDateSelect().equals("A")){
+        if (staff.getDateSelect().equals("A")) {
             staff.setSyear(localDate1.getYear() + "");
             staff.setSmoth(localDate1.getMonthValue() + "");
             staff.setSday(localDate1.getDayOfMonth() + "");
@@ -238,8 +395,7 @@
             staff.setSeyear(localDate4.getYear() + "");
             staff.setSemoth(localDate4.getMonthValue() + "");
             staff.setSeday(localDate4.getDayOfMonth() + "");
-        }else if (staff.getDateSelect().equals("B")){
-
+        } else if (staff.getDateSelect().equals("B")) {
             staff.setBsyear(localDate1.getYear() + "");
             staff.setBsmoth(localDate1.getMonthValue() + "");
             staff.setBsday(localDate1.getDayOfMonth() + "");
@@ -250,29 +406,24 @@
             staff.setBseyear(localDate4.getYear() + "");
             staff.setBsemoth(localDate4.getMonthValue() + "");
             staff.setBseday(localDate4.getDayOfMonth() + "");
-        }else if (staff.getDateSelect().equals("C")){
+        } else if (staff.getDateSelect().equals("C")) {
             staff.setCsyear(localDate1.getYear() + "");
             staff.setCsmoth(localDate1.getMonthValue() + "");
             staff.setCsday(localDate1.getDayOfMonth() + "");
         }
 
-        Map<String,Object> data = new HashMap<>();
-        data.put("item",staff);
-        //3.鍔犺浇XML 妯℃澘
+        Map<String, Object> data = new HashMap<>();
+        data.put("item", staff);
         Template template = cfg.getTemplate("鍔冲姩鍚堝悓涔�.xml");
-        //4.鐢熸垚濉厖鍚庣殑 XML 鍐呭
         StringWriter out = new StringWriter();
         template.process(data, out);
         String filledXml = out.toString();
-        //5.灏哫ML鍐呭鍐欏叆浜や欢骞舵敼涓�.docx 鏍煎紡
+
         File outputFile = new File(url);
-        try(FileOutputStream fos = new FileOutputStream(outputFile);
-            OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
+        try (FileOutputStream fos = new FileOutputStream(outputFile);
+             OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
             osw.write(filledXml);
         }
         return url;
     }
-
-
-
 }

--
Gitblit v1.9.3