wwh 1 місяць тому
батько
коміт
59212f43c9

+ 2 - 1
huimv-farm/src/main/java/vip/xiaonuo/core/config/GlobalConfigure.java

@@ -147,7 +147,8 @@ public class GlobalConfigure implements WebMvcConfigurer {
             "/sys/userCenter/findPasswordGetPhoneValidCode",
             "/sys/userCenter/findPasswordGetEmailValidCode",
             "/sys/userCenter/findPasswordByPhone",
-            "/sys/userCenter/findPasswordByEmail"
+            "/sys/userCenter/findPasswordByEmail",
+            "/importData"
     };
 
     /**

+ 2 - 3
huimv-farm/src/main/java/vip/xiaonuo/hr/modular/basedepartment/entity/HrBaseDepartment.java

@@ -33,9 +33,8 @@ import java.util.Date;
 public class HrBaseDepartment  {
 
     /** ID */
-    @TableId
-    @ApiModelProperty(value = "ID", position = 1)
-    private String id;
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
 
     /** 父id */
     @ApiModelProperty(value = "父id", position = 2)

+ 2 - 3
huimv-farm/src/main/java/vip/xiaonuo/hr/modular/baseemployeeinfo/controller/HrBaseEmployeeInfoController.java

@@ -58,7 +58,7 @@ public class HrBaseEmployeeInfoController {
 
     @ApiOperationSupport(order = 1)
     @ApiOperation("获取人员明细分页")
-    @GetMapping("/hr/baseemployeeinfo/page")
+    @PostMapping("/hr/baseemployeeinfo/page")
     public CommonResult<Page<HrBaseEmployeeInfo>> page(@RequestBody HrBaseEmployeeInfoPageParam hrBaseEmployeeInfoPageParam) {
         return CommonResult.data(hrBaseEmployeeInfoService.page(hrBaseEmployeeInfoPageParam));
     }
@@ -85,8 +85,7 @@ public class HrBaseEmployeeInfoController {
     @ApiOperation("删除人员明细")
     @CommonLog("删除人员明细")
     @PostMapping("/hr/baseemployeeinfo/delete")
-    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
-                                                   CommonValidList<HrBaseEmployeeInfoIdParam> hrBaseEmployeeInfoIdParamList) {
+    public CommonResult<String> delete(@RequestBody HrBaseEmployeeInfoIdParam hrBaseEmployeeInfoIdParamList) {
         hrBaseEmployeeInfoService.delete(hrBaseEmployeeInfoIdParamList);
         return CommonResult.ok();
     }

+ 15 - 4
huimv-farm/src/main/java/vip/xiaonuo/hr/modular/baseemployeeinfo/entity/HrBaseEmployeeInfo.java

@@ -13,6 +13,7 @@
 package vip.xiaonuo.hr.modular.baseemployeeinfo.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fhs.core.trans.anno.Trans;
 import com.fhs.core.trans.constant.TransType;
 import io.swagger.annotations.Api;
@@ -36,9 +37,8 @@ import java.util.Date;
 public class HrBaseEmployeeInfo {
 
     /** ID */
-    @TableId
-    @ApiModelProperty(value = "ID", position = 1)
-    private String id;
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
 
     /** 头像 */
     @ApiModelProperty(value = "头像", position = 2)
@@ -58,6 +58,7 @@ public class HrBaseEmployeeInfo {
 
     /** 出生日期 */
     @ApiModelProperty(value = "出生日期", position = 6)
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date birthday;
 
     /** 民族 */
@@ -102,6 +103,7 @@ public class HrBaseEmployeeInfo {
 
     /** 入职日期 */
     @ApiModelProperty(value = "入职日期", position = 17)
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date entryDate;
 
     /** 机构id */
@@ -157,7 +159,7 @@ public class HrBaseEmployeeInfo {
 
     /** 0 未婚 1已婚 */
     @ApiModelProperty(value = "0 未婚 1已婚", position = 29)
-    private Integer marriage;
+    private String marriage;
 
     /** 工龄 */
     @ApiModelProperty(value = "工龄", position = 30)
@@ -170,9 +172,11 @@ public class HrBaseEmployeeInfo {
     private String hukouNature;
 
     @ApiModelProperty(value = "招入集团时间",position = 33)
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date joinGroup;
 
     @ApiModelProperty(value = "合同开始时间",position = 34)
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date contactStartTime;
 
     @ApiModelProperty(value = "专业",position = 35)
@@ -194,6 +198,7 @@ public class HrBaseEmployeeInfo {
     private String newSalary;
 
     @ApiModelProperty(value = "转正日期",position = 41)
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date confirmationTime;
 
     @ApiModelProperty(value = "定额工资",position = 42)
@@ -216,4 +221,10 @@ public class HrBaseEmployeeInfo {
 
     @ApiModelProperty(value = "岗位", position = 49)
     private String post;
+
+    @ApiModelProperty(value = "部门名称", position = 50)
+    private String departmentName;
+
+    @ApiModelProperty(value = "序号", position = 51)
+    private String number;
 }

+ 1 - 1
huimv-farm/src/main/java/vip/xiaonuo/hr/modular/baseemployeeinfo/service/HrBaseEmployeeInfoService.java

@@ -62,7 +62,7 @@ public interface HrBaseEmployeeInfoService extends IService<HrBaseEmployeeInfo>
      * @author 余
      * @date  2024/11/14 15:02
      */
-    void delete(List<HrBaseEmployeeInfoIdParam> hrBaseEmployeeInfoIdParamList);
+    void delete(HrBaseEmployeeInfoIdParam hrBaseEmployeeInfoIdParamList);
 
     /**
      * 获取人员明细详情

+ 5 - 3
huimv-farm/src/main/java/vip/xiaonuo/hr/modular/baseemployeeinfo/service/impl/HrBaseEmployeeInfoServiceImpl.java

@@ -43,6 +43,7 @@ import vip.xiaonuo.purchase.param.DongShiPurchaseParam;
 import vip.xiaonuo.purchase.param.GongYingShangParam;
 import vip.xiaonuo.purchase.param.PurchaseAllParam;
 
+import javax.validation.constraints.NotBlank;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -95,9 +96,10 @@ public class HrBaseEmployeeInfoServiceImpl extends ServiceImpl<HrBaseEmployeeInf
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void delete(List<HrBaseEmployeeInfoIdParam> hrBaseEmployeeInfoIdParamList) {
+    public void delete(HrBaseEmployeeInfoIdParam hrBaseEmployeeInfoIdParamList) {
         // 执行删除
-        this.removeByIds(CollStreamUtil.toList(hrBaseEmployeeInfoIdParamList, HrBaseEmployeeInfoIdParam::getId));
+        String id = hrBaseEmployeeInfoIdParamList.getId();
+        hrBaseEmployeeInfoMapper.deleteById(id);
     }
 
     @Override
@@ -154,7 +156,7 @@ public class HrBaseEmployeeInfoServiceImpl extends ServiceImpl<HrBaseEmployeeInf
 
             Map<String, String> map = new HashMap<>();
             for (HrBaseDepartment department : baseDepartments) {
-                map.put(department.getId(),department.getName());
+                map.put(department.getId().toString(),department.getName());
             }
             for (HrBaseEmployeeInfo info : list) {
                 HrBaseEmployeeInfoVo vo = new HrBaseEmployeeInfoVo();

+ 66 - 0
huimv-farm/src/main/java/vip/xiaonuo/importData/config/ImportConfigure.java

@@ -0,0 +1,66 @@
+/*
+ * Copyright [2022] [https://www.baiduc.com]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.baiduc.com
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.baiduc.com
+ */
+package vip.xiaonuo.importData.config;
+
+
+import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import vip.xiaonuo.common.pojo.CommonResult;
+
+import javax.annotation.Resource;
+
+/**
+ * SaToken鉴权配置
+ *
+ * @HRor xuyuxiang
+ * @date 2021/10/9 14:24
+ **/
+@Configuration
+public class ImportConfigure implements WebMvcConfigurer {
+
+    @Resource
+    private OpenApiExtensionResolver openApiExtensionResolver;
+
+    
+
+
+    @Bean(value = "ImportDocApi")
+    public Docket hrDocApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(new ApiInfoBuilder()
+                        .title("导入模块")
+                        .description("导入模块")
+                        .termsOfServiceUrl("https://www.baidu.com")
+                        .contact(new Contact("SNOWY_TEAM","https://www.baidu.com", ""))
+                        .version("2.0.0")
+                        .build())
+                .globalResponseMessage(RequestMethod.GET, CommonResult.responseList())
+                .globalResponseMessage(RequestMethod.POST, CommonResult.responseList())
+                .groupName("导入模块")
+                .select()
+                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
+                .apis(RequestHandlerSelectors.basePackage("vip.xiaonuo.importData"))
+                .paths(PathSelectors.any())
+                .build().extensions(openApiExtensionResolver.buildExtensions("导入模块"));
+    }
+}

+ 73 - 0
huimv-farm/src/main/java/vip/xiaonuo/importData/controller/ImportHrController.java

@@ -0,0 +1,73 @@
+package vip.xiaonuo.importData.controller;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.github.xiaoymin.knife4j.annotations.ApiSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import vip.xiaonuo.common.pojo.CommonResult;
+import vip.xiaonuo.hr.modular.basedepartment.entity.HrBaseDepartment;
+import vip.xiaonuo.hr.modular.basedepartment.service.HrBaseDepartmentService;
+import vip.xiaonuo.hr.modular.baseemployeeinfo.entity.HrBaseEmployeeInfo;
+import vip.xiaonuo.hr.modular.baseemployeeinfo.service.HrBaseEmployeeInfoService;
+import vip.xiaonuo.importData.entity.HrData;
+import vip.xiaonuo.importData.service.ImportData;
+import vip.xiaonuo.importData.utils.ExcelImportSheet;
+import vip.xiaonuo.money.entity.MoneyBorrowWarning;
+import vip.xiaonuo.money.entity.vo.MoneyBankNameVo;
+import vip.xiaonuo.money.entity.vo.MoneyBorrowPriceVo;
+import vip.xiaonuo.money.param.MoneyBorrowDetailParam;
+import vip.xiaonuo.money.param.MoneyBorrowParam;
+import vip.xiaonuo.money.param.MoneyInOutParam;
+import vip.xiaonuo.money.service.IMoneyBorrowWarningService;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 财务临近还款期预警 前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2024-11-20
+ */
+
+@Api(tags = "导入")
+@ApiSupport(author = "wang", order = 1)
+@RestController
+@Validated
+public class ImportHrController {
+
+
+    @Autowired
+    private ImportData importData;
+
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("hr人员导入")
+    @PostMapping("/importData")
+    @Transactional
+    public CommonResult listBorrowWarning(HttpServletRequest httpServletRequest,@RequestParam(name = "orgId") String orgId,
+                                          @RequestParam(name = "file") MultipartFile files) {
+        return importData.importData(httpServletRequest, orgId, files);
+    }
+}

+ 143 - 0
huimv-farm/src/main/java/vip/xiaonuo/importData/entity/HrData.java

@@ -0,0 +1,143 @@
+package vip.xiaonuo.importData.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class HrData {
+
+    /** ID */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+
+    /** 姓名 */
+    @ApiModelProperty(value = "姓名", position = 3)
+    private String name;
+
+    /** 性别 */
+    @ApiModelProperty(value = "性别 0男 1 女", position = 4)
+    private String gender;
+
+    /** 年龄 */
+    @ApiModelProperty(value = "年龄", position = 5)
+    private String age;
+
+    /** 出生日期 */
+    @ApiModelProperty(value = "出生日期", position = 6)
+    private Date birthday;
+
+    /** 民族 */
+    @ApiModelProperty(value = "民族", position = 7)
+    private String nation;
+
+    /** 籍贯 */
+    @ApiModelProperty(value = "籍贯", position = 8)
+    private String nativePlace;
+
+    /** 家庭住址 */
+    @ApiModelProperty(value = "家庭住址", position = 9)
+    private String homeAddress;
+
+    /** 证件号码 */
+    @ApiModelProperty(value = "证件号码", position = 12)
+    private String idCardNumber;
+
+    /** 文化程度 */
+    @ApiModelProperty(value = "文化程度", position = 13)
+    private String cultureLevel;
+
+    /** 政治面貌 */
+    @ApiModelProperty(value = "政治面貌", position = 14)
+    private String politicalOutlook;
+
+    /** 学历 */
+    @ApiModelProperty(value = "学历 0小学 1初中 2高中 3本科 4研究生", position = 15)
+    private int education;
+
+    /** 手机 */
+    @ApiModelProperty(value = "手机", position = 16)
+    private String phone;
+
+    /** 入职日期 */
+    @ApiModelProperty(value = "入职日期", position = 17)
+    private Date entryDate;
+
+    /** 机构id */
+    @ApiModelProperty(value = "机构id", position = 18)
+//    @Trans(type = TransType.SIMPLE, target = HrBaseDepartment.class, fields = "name", alias = "manager", ref = "managerName")
+    private String departmentId;
+
+    /** 0 未婚 1已婚 */
+    @ApiModelProperty(value = "0 未婚 1已婚", position = 29)
+    private String marriage;
+
+    /** 工龄 */
+    @ApiModelProperty(value = "工龄", position = 30)
+    private Integer seniority;
+
+    @ApiModelProperty(value = "orgId", position =31)
+    private String orgId;
+
+    @ApiModelProperty(value = "户口性质", position =32)
+    private String hukouNature;
+
+    @ApiModelProperty(value = "招入集团时间",position = 33)
+    private Date joinGroup;
+
+    @ApiModelProperty(value = "合同开始时间",position = 34)
+    private Date contactStartTime;
+
+    @ApiModelProperty(value = "专业",position = 35)
+    private String major;
+
+    @ApiModelProperty(value = "毕业院校",position =36 )
+    private String almaMater;
+
+    @ApiModelProperty(value = "职称",position = 37)
+    private String title;
+
+    @ApiModelProperty(value = "现任岗位或职务",position = 38)
+    private String current;
+
+    @ApiModelProperty(value = "新级别",position = 39)
+    private String newLevel;
+
+    @ApiModelProperty(value = "新薪档",position = 40)
+    private String newSalary;
+
+    @ApiModelProperty(value = "转正日期",position = 41)
+    private Date confirmationTime;
+
+    @ApiModelProperty(value = "定额工资",position = 42)
+    private String quotaWages;
+
+    @ApiModelProperty(value = "紧急联系人姓名", position = 44)
+    private String emergencyContactName;
+
+    @ApiModelProperty(value = "紧急联系人电话", position = 45)
+    private String emergencyContactPhone;
+
+    @ApiModelProperty(value = "工资发放处", position = 46)
+    private String payroll;
+
+    @ApiModelProperty(value = "社保", position = 47)
+    private String socialSecurity;
+
+    @ApiModelProperty(value = "公积金", position = 48)
+    private String providentFund;
+
+    @ApiModelProperty(value = "岗位", position = 49)
+    private String post;
+
+    @ApiModelProperty(value = "部门名称", position = 50)
+    private String departmentName;
+
+    @ApiModelProperty(value = "序号", position = 51)
+    private String number;
+
+}

+ 13 - 0
huimv-farm/src/main/java/vip/xiaonuo/importData/service/ImportData.java

@@ -0,0 +1,13 @@
+package vip.xiaonuo.importData.service;
+
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import vip.xiaonuo.common.pojo.CommonResult;
+
+import javax.servlet.http.HttpServletRequest;
+
+public interface ImportData {
+
+    CommonResult importData(HttpServletRequest httpServletRequest, @RequestParam(name = "orgId") String orgId,
+                            @RequestParam(name = "file") MultipartFile files);
+}

+ 194 - 0
huimv-farm/src/main/java/vip/xiaonuo/importData/service/impl/ImportDataImpl.java

@@ -0,0 +1,194 @@
+package vip.xiaonuo.importData.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.druid.sql.visitor.functions.If;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import vip.xiaonuo.common.pojo.CommonResult;
+import vip.xiaonuo.hr.modular.basedepartment.entity.HrBaseDepartment;
+import vip.xiaonuo.hr.modular.basedepartment.service.HrBaseDepartmentService;
+import vip.xiaonuo.hr.modular.baseemployeeinfo.entity.HrBaseEmployeeInfo;
+import vip.xiaonuo.hr.modular.baseemployeeinfo.service.HrBaseEmployeeInfoService;
+import vip.xiaonuo.importData.entity.HrData;
+import vip.xiaonuo.importData.service.ImportData;
+import vip.xiaonuo.importData.utils.ExcelImportSheet;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class ImportDataImpl implements ImportData {
+
+    @Autowired
+    private HrBaseDepartmentService departmentService;
+    @Autowired
+    private HrBaseEmployeeInfoService infoService;
+
+    @Override
+    @Transactional
+    public CommonResult importData(HttpServletRequest httpServletRequest, String orgId, MultipartFile files) {
+        Map<String , String> map = new HashMap<>();
+        //表头与键值对的映射关系
+        map.put("部门" , "departmentName");
+        map.put("岗位" , "post");
+        map.put("序号" , "number");
+        map.put("姓名" , "name");
+        map.put("性别" , "gender");
+        map.put("政治面貌" , "politicalOutlook");
+        map.put("民族" , "nation");
+        map.put("户口性质" , "hukouNature");
+        map.put("出生年月" , "birthday");
+        map.put("年龄(周岁)" , "age");
+        map.put("身份证号码" , "idCardNumber");
+        map.put("招入集团时间" , "joinGroup");
+        map.put("入职时间" , "entryDate");
+        map.put("工龄" , "seniority");
+        map.put("合同起止时间" , "contactStartTime");
+        map.put("文化程度" , "cultureLevel");
+        map.put("专业" , "major");
+        map.put("毕业院校" , "almaMater");
+        map.put("职称" , "title");
+        map.put("现任职务或岗位" , "current");
+        map.put("新级别" , "newLevel");
+        map.put("新薪档" , "newSalary");
+        map.put("转正日期" , "confirmationTime");
+        map.put("定额工资" , "quotaWages");
+        map.put("籍贯" , "nativePlace");
+        map.put("家庭地址或通讯地址" , "homeAddress");
+        map.put("手机" , "phone");
+        map.put("紧急联系人姓名" , "emergencyContactName");
+        map.put("紧急联系人电话" , "emergencyContactPhone");
+        map.put("工资发放处" , "payroll");
+        map.put("社保" , "socialSecurity");
+        map.put("公积金" , "providentFund");
+        map.put("婚姻" , "marriage");
+
+        try(
+                //这里面的对象会自动关闭
+                InputStream in = files.getInputStream();
+                Workbook workbook = ExcelImportSheet.getTypeFromExtends(in , files.getOriginalFilename())
+        ) {
+
+            //根据名称获取单张表对象 也可以使用getSheetAt(int index)获取单张表的对象 获取第一张表
+            Sheet sheet = workbook.getSheetAt(0);
+            List<HrData> list = ExcelImportSheet.getListFromExcel(sheet , HrData.class , map);
+
+            for (HrData hrData : list) {
+                String department = hrData.getDepartmentName();
+                System.out.println("这个是部门的名称:"+department);
+                if ("".equals(department) || null == department) {
+                } else {
+                    HrBaseDepartment departments = departmentService.getOne(new QueryWrapper<HrBaseDepartment>().eq("name", department).eq("org_id",orgId));
+                    if (ObjectUtil.isNotEmpty(departments)) {
+                    } else {
+                        HrBaseDepartment department1 = new HrBaseDepartment();
+                        department1.setOrgId(orgId);
+                        department1.setName(department);
+                        department1.setCreateTime(new Date());
+                        departmentService.save(department1);
+                    }
+                }
+            }
+            List<HrBaseDepartment> departments1 = departmentService.list(new QueryWrapper<HrBaseDepartment>().eq("org_id", orgId));
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            for (HrData hrData : list) {
+                HrBaseEmployeeInfo info = new HrBaseEmployeeInfo();
+                BeanUtil.copyProperties(hrData, info);
+              /*  if ("".equals(hrData.getBirthday1()) || null == hrData.getBirthday1()) {
+                } else {
+                    Date parse = sdf.parse(hrData.getBirthday1());
+                    info.setBirthday(parse);
+                }
+                if ("".equals(hrData.getJoinGroup1()) || null == hrData.getJoinGroup1()) {
+                } else {
+                    Date parse = sdf.parse(hrData.getJoinGroup1());
+                    info.setJoinGroup(parse);
+                }
+                if ("".equals(hrData.getEntryDate1()) || null == hrData.getEntryDate1()) {
+                } else {
+                    Date parse = sdf.parse(hrData.getEntryDate1());
+                    info.setEntryDate(parse);
+                }
+                if ("".equals(hrData.getContactStartTime1()) || null == hrData.getContactStartTime1()) {
+                } else {
+                    Date parse = sdf.parse(hrData.getContactStartTime1());
+                    info.setContactStartTime(parse);
+                }
+                if ("".equals(hrData.getConfirmationTime1()) || null == hrData.getConfirmationTime1()) {
+                } else {
+                    Date parse = sdf.parse(hrData.getConfirmationTime1());
+                    info.setConfirmationTime(parse);
+                }*/
+                info.setOrgId(orgId);
+                for (HrBaseDepartment department : departments1) {
+                    if (department.getName().equals(hrData.getDepartmentName())) {
+                        info.setDepartmentName(department.getName());
+                        info.setDepartmentId(department.getId().toString());
+                    }
+                }
+                if ("男".equals(hrData.getGender()) || "男性".equals(hrData.getGender())) {
+                    info.setGender("0");
+                }
+                if ("女".equals(hrData.getGender()) || "女性".equals(hrData.getGender())) {
+                    info.setGender("1");
+                }
+                if ("已婚".equals(hrData.getMarriage())) {
+                    info.setMarriage("1");
+                }
+                if ("未婚".equals(hrData.getMarriage())) {
+                    info.setMarriage("0");
+                }
+                if ("小学".equals(hrData.getCultureLevel())) {
+                    info.setEducation(0);
+                }
+                if ("初中".equals(hrData.getCultureLevel())) {
+                    info.setEducation(1);
+                }
+                if ("高中".equals(hrData.getCultureLevel())) {
+                    info.setEducation(2);
+                }
+                if ("本科".equals(hrData.getCultureLevel())) {
+                    info.setEducation(3);
+                }
+                if ("研究生".equals(hrData.getCultureLevel())|| "硕士".equals(hrData.getCultureLevel())) {
+                    info.setEducation(4);
+                }
+                if ("博士".equals(hrData.getCultureLevel())|| "博士研究生".equals(hrData.getCultureLevel())) {
+                    info.setEducation(5);
+                }
+
+                if ("".equals(hrData.getIdCardNumber()) || null == hrData.getIdCardNumber()) {
+                    return CommonResult.error("表格中存在身份证号为空!请检查后重新导入");
+                } else {
+                    HrBaseEmployeeInfo infos = infoService.getOne(new QueryWrapper<HrBaseEmployeeInfo>().eq("ID_CARD_NUMBER", hrData.getIdCardNumber()));
+                    if (ObjectUtil.isEmpty(infos)) {
+                        infoService.save(info);
+                    } else {
+                        info.setId(infos.getId());
+                        infoService.updateById(info);
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return CommonResult.error();
+        }finally {
+            //写着好看的
+        }
+        return CommonResult.ok();
+    }
+}

+ 192 - 0
huimv-farm/src/main/java/vip/xiaonuo/importData/utils/ExcelImportSheet.java

@@ -0,0 +1,192 @@
+package vip.xiaonuo.importData.utils;
+
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * @author 三文鱼先生
+ * @title
+ * @description 导入工具类
+ * @date 2022/8/17
+ **/
+public class ExcelImportSheet {
+
+    /**
+     * @description 根据文件后缀获取相应的Workbook对象
+     * @author 三文鱼先生
+     * @date 9:46 2022/8/17
+     * @param in 用于构建Workbook对象的输入流
+     * @param fileName 文件名称
+     * @return org.apache.poi.ss.usermodel.Workbook
+     **/
+    public static Workbook getTypeFromExtends(InputStream in , String fileName) throws Exception {
+        String[] str = fileName.split("\\.");
+        //获取文件后缀
+        String extend = str[1];
+        if(extend.equals("xls")) {
+            //2003版的excel
+            return new HSSFWorkbook(in);
+        } else if(extend.equals("xlsx")){
+            //2007版的excel
+            return new XSSFWorkbook(in);
+        }else {
+            throw new Exception("请检查文件类型是否正确。");
+        }
+    }
+
+    /**
+     * @description 将单个sheet里的数据获取到List<T>的泛型列表里面
+     * @author 三文鱼先生
+     * @date 9:47 2022/8/17
+     * @param sheet 单个的工作表
+     * @param cs 生成的对象类名
+     * @param map 表头与对象属性映射
+     * @return java.util.List<T>
+     **/
+    public static <T> List<T> getListFromExcel(Sheet sheet , Class cs , Map<String , String> map) throws Exception {
+        T e;
+        List<T> list = new ArrayList<>();
+        //根据第一行获取表头对应的属性顺序
+        List<String> paramsList = getMethodFromFirstRow(sheet , map);
+        //根据类和属性顺序的List 获取属性对应的类型属性
+        List<Class> typeClass = getParamsType(cs , paramsList);
+        //遍历所有行 从第二行开始 首行是表头字段
+        for (int i = sheet.getFirstRowNum() + 1; i <= sheet.getLastRowNum(); i++) {
+            //单元行
+            Row row = sheet.getRow(i);
+            //一行对应一个T,将对象强转为泛型
+            e = (T) cs.newInstance();
+            //遍历单元行的每一列 设置值给泛型e
+
+            for (int j = 0; j < row.getLastCellNum(); j++) {
+                //获取一个单元格
+                Cell cell = row.getCell(j);
+
+                //调用泛型对象的set方法设置单元格里的值 这也就是为什么我们要获取属性顺序以及其对应的类型
+                cs.getMethod(getSetterMethodName(paramsList.get(j)) , typeClass.get(j))
+                        .invoke(e , getValueFromType(cell , typeClass.get(j)));
+            }
+            list.add(e);
+        }
+        return list;
+    }
+
+    /**
+     * @description 获取属性的setter方法
+     * @author 三文鱼先生
+     * @date 9:54 2022/8/17
+     * @param param 属性
+     * @return java.lang.String 返回一个setXxx
+     **/
+    public static String getSetterMethodName(String param) {
+        char[] chars = param.toCharArray();
+        //首字母大写
+        if(Character.isLowerCase(chars[0])) {
+            chars[0] -= 32;
+        }
+        //拼接set方法
+        return "set" + new String(chars);
+    }
+
+    /**
+     * @description 从第一行(表头)获取字段对应的属性的顺序
+     * @author 三文鱼先生
+     * @date 9:51 2022/8/17
+     * @param sheet 工作表
+     * @param map 表头字段与对象属性的映射
+     * @return java.util.List<java.lang.String> 属性的集合
+     **/
+    public static List<String> getMethodFromFirstRow(Sheet sheet , Map<String,String> map) throws Exception {
+        //获取表头
+        Row row = sheet.getRow(sheet.getFirstRowNum());
+        //获取到的属性列表
+        List<String> paramsList = new ArrayList<>();
+        //遍历表头
+        for(int i = row.getFirstCellNum(); i  < row.getLastCellNum(); i++) {
+            Cell cell = row.getCell(i);
+            //获取行字符串的值
+            String str = cell.getStringCellValue();
+            //键值对映射获取对应方法名称
+            if(map.containsKey(str)) {
+                //获取对应属性的set方法
+                paramsList.add(map.get(str));
+            } else {
+                throw new Exception("请检查首行数据是否正确。");
+            }
+        }
+        return  paramsList;
+    }
+
+    /**
+     * @description  根据对象和属性顺序列表,返回对应顺序的参数类型List
+     * @author 三文鱼先生
+     * @date 9:55 2022/8/17
+     * @param cs 对象类
+     * @param paramsList 表头对应的属性顺序List
+     * @return java.util.List<java.lang.Class>
+     **/
+    public static List<Class> getParamsType(Class cs , List<String> paramsList) {
+        List<Class> typeClass = new ArrayList<>();
+        //对象的所有属性
+        Field[] fields = cs.getDeclaredFields();
+        //临时的属性 - 类型映射
+        Map<String , Class> map = new HashMap();
+        //获取属性名称及类型
+        for (Field field : fields) {
+            map.put(field.getName(), field.getType());
+        }
+        //遍历属性List获取对应的类型List
+        for (String s : paramsList) {
+            typeClass.add(map.get(s));
+        }
+        return typeClass;
+    }
+
+
+    /**
+     * @description 根据对应的Class获取将对应的值类型
+     * @author 三文鱼先生
+     * @date 9:59 2022/8/17
+     * @param cell
+     * @param cs
+     * @return java.lang.Object
+     **/
+    public static Object getValueFromType(Cell cell , Class cs) {
+        if(boolean.class.equals(cs)){
+            //boolean类型
+            cell.setCellType(CellType.BOOLEAN);
+            return cell.getBooleanCellValue();
+        }else if (Date.class.equals(cs)) {
+            //日期类型 此种数据并未测试
+            return cell.getDateCellValue();
+        } else if (int.class.equals(cs) || Integer.class.equals(cs)){
+            //int类型
+            cell.setCellType(CellType.NUMERIC);
+            return (int)cell.getNumericCellValue();
+        } else if(double.class.equals(cs) || Double.class.equals(cs)) {
+            //double类型
+            cell.setCellType(CellType.NUMERIC);
+            return cell.getNumericCellValue();
+        }else if(BigDecimal.class.equals(cs) || BigDecimal.class.equals(cs)) {
+            //bigdecimal类型
+            cell.setCellType(CellType.NUMERIC);
+            return cell.getNumericCellValue();
+        }  //字符串类型
+        if (cs.equals(String.class)) {
+            //设置对应的类型
+            cell.setCellType(CellType.STRING);
+            return cell.getStringCellValue();
+        }
+        //这里还可以填充其他类型
+        else {
+            //未知类型 默认为错误类型
+            return cell.getErrorCellValue();
+        }
+    }
+}