Commit cbf55a66 authored by hongguangwu's avatar hongguangwu

MVP1.7.0 预入职导入

parent 93071bf8
......@@ -567,4 +567,9 @@ public class TEmployeeInfo extends BaseEntity {
*/
@TableField(exist = false)
private List<TEmpOtherFile> otherFiles;
// 档案编辑的其他附件之外的附件,例如:身份证正反面,户口本2页、员工声明、员工确认
@TableField(exist = false)
private List<TAttaInfo> attaList;
}
......@@ -31,6 +31,7 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
/**
* 预入职-主表
......@@ -238,6 +239,12 @@ public class TPreEmpMain extends BaseEntity {
@Schema(description = "员工申明表ID,新申明要加一条新数据,关联这个主表")
private String declarationId;
// 数据来源 默认0: '扫码进入', 1: 'PC批量导入'
@ExcelAttribute(name = "数据来源", maxLength = 32)
@ExcelProperty("数据来源")
@Schema(description = "数据来源")
private String sourType;
@Schema(description = "状态多个")
@TableField(exist = false)
private String[] statusArray;
......@@ -266,4 +273,20 @@ public class TPreEmpMain extends BaseEntity {
@TableField(exist = false)
private String ids;
// 导入预入职使用
@TableField(exist = false)
private String firstWorkFlag;
@TableField(exist = false)
private String haveQualification;
/**
* 其他附件
*/
@TableField(exist = false)
private List<TPreEmpOtherFile> otherFiles;
// 档案编辑的其他附件之外的附件,例如:身份证正反面,户口本2页、员工声明、员工确认
@TableField(exist = false)
private List<TAttaInfo> attaList;
}
......@@ -100,4 +100,11 @@ public class TPreEmpOtherFile {
**/
@TableField(exist = false)
private List<TAttaInfo> attaList;
/**
* 档案编辑其他附件分租信息处理类型 0 新增 1 更新 2 删除 3 不变
*/
@TableField(exist = false)
private String handleType;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 预入职导入的表格内容
*
* @author hgw
* @date 2024-10-12 15:12:02
*/
@Data
public class PreUploadEmpImportVo implements Serializable {
// (字典值,0外包1派遣2代理)
@ExcelAttribute(name = "员工类型", isDataId = true, dataType = ExcelAttributeConstants.EMP_NATRUE, maxLength = 2)
private String empNatrue;
@ExcelAttribute(name = "员工姓名", maxLength = 32)
private String empName;
@ExcelAttribute(name = "身份证号", isNotEmpty = true, maxLength = 20)
private String empIdcard;
//@ExcelAttribute(name = "性别", maxLength = 32)
//private String empSex;
//@ExcelAttribute(name = "身份证期限", isDate = true)
//private String cardType;
@ExcelAttribute(name = "身份证开始日期", isNotEmpty = true, isDate = true)
private String validityStart;
@ExcelAttribute(name = "身份证截止日期", isNotEmpty = true, isDate = true, pattern = "validityStart")
private String validityEnd;
//@ExcelAttribute(name = "出生日期", isDate = true)
//private String empBirthday;
//@ExcelAttribute(name = "年龄")
//private Integer empAge;
@ExcelAttribute(name = "婚姻状况", isDataId = true, dataType = ExcelAttributeConstants.EMP_MARRIED, isNotEmpty = true, maxLength = 32)
private String empMarriStatus;
@ExcelAttribute(name = "民族", isDataId = true, dataType = ExcelAttributeConstants.EMP_NATIONAL, isNotEmpty = true, maxLength = 32)
private String empNational;
@ExcelAttribute(name = "政治面貌", isDataId = true, dataType = ExcelAttributeConstants.EMP_POLITICAL, isNotEmpty = true, maxLength = 32)
private String politicalStatus;
@ExcelAttribute(name = "手机号码", isPhone = true, isNotEmpty = true, maxLength = 32)
private String empPhone;
@ExcelAttribute(name = "邮箱", maxLength = 50)
private String empEmail;
// 区域ID
@ExcelAttribute(name = "户籍所在地-省", isArea = true)
private String idProvince;
@ExcelAttribute(name = "户籍所在地-市", isArea = true, parentField = "idProvince")
private String idCity;
@ExcelAttribute(name = "户籍所在地-区/县", isArea = true, parentField = "idCity")
private String idTown;
@ExcelAttribute(name = "户口性质", isDataId = true, dataType = ExcelAttributeConstants.EMP_REGISTYPE, isNotEmpty = true, maxLength = 32)
private String empRegisType;
@ExcelAttribute(name = "档案所在地-省", isNotEmpty = true, isArea = true)
private String fileProvince;
@ExcelAttribute(name = "档案所在地-市", isNotEmpty = true, isArea = true, parentField = "fileProvince")
private String fileCity;
@ExcelAttribute(name = "档案所在地-区/县", isArea = true, parentField = "fileCity")
private String fileTown;
@ExcelAttribute(name = "通信地址-省", isNotEmpty = true, isArea = true)
private String contactProvince;
@ExcelAttribute(name = "通信地址-市", isNotEmpty = true, isArea = true, parentField = "contactProvince")
private String contactCity;
@ExcelAttribute(name = "通信地址-区/县", isNotEmpty = true, isArea = true, parentField = "contactCity")
private String contactTown;
@ExcelAttribute(name = "通信地址-详细地址", isNotEmpty = true, maxLength = 200)
private String contactAddress;
// 紧急联系人
// private TPreEmpContactInfo tpreEmpContactInfo
// 紧急联系人姓名 与本人关系 联系地址-省 联系地址-市 联系地址-区/县 联系地址-详细地址 手机号码(紧急联系人)
@ExcelAttribute(name = "紧急联系人姓名", isNotEmpty = true, errorInfo = "紧急联系人姓名不能为空", maxLength = 20)
private String contactEmpName;
@ExcelAttribute(name = "与本人关系", isNotEmpty = true, errorInfo = "与本人关系不能为空", maxLength = 50)
private String relationType;
@ExcelAttribute(name = "联系地址-省", isNotEmpty = true, isArea = true)
private String relationProvince;
@ExcelAttribute(name = "联系地址-市", isNotEmpty = true, isArea = true, parentField = "relationProvince")
private String relationCity;
@ExcelAttribute(name = "联系地址-区/县", isNotEmpty = true, isArea = true, parentField = "relationCity")
private String relationTown;
@ExcelAttribute(name = "联系地址-详细地址", isNotEmpty = true, errorInfo = "联系地址-街道、详情不能为空", maxLength = 100)
private String address;
@ExcelAttribute(name = "手机号码(紧急联系人)", isPhone = true, isNotEmpty = true, errorInfo = "手机号码(紧急联系人)不能为空", maxLength = 20)
private String tel;
// 预入职-员工学历信息表
// private TPreEmpEducation tpreEmpEducation
// 学历 学校 专业 教育开始时间 教育结束时间 是否大专及以上 最高学历
@ExcelAttribute(name = "学历", isDataId = true, dataType = ExcelAttributeConstants.EDUCATION, isNotEmpty = true, maxLength = 32)
private String educationName;
@ExcelAttribute(name = "学校", maxLength = 64)
private String school;
@ExcelAttribute(name = "专业", maxLength = 64)
private String major;
@ExcelAttribute(name = "教育开始时间", isDate = true)
private String entryDate;
@ExcelAttribute(name = "教育结束时间", isDate = true, pattern = "entryDate")
private String gradutionDate;
// 非表头:是否大专及以上(0否1是)
//@ExcelAttribute(name = "是否大专及以上")
//private String isCollege;
// 非表头:最高学历标识0是/1否
//@ExcelAttribute(name = "最高学历", maxLength = 1)
//private String highIdentification;
// 是否为首份工作 工作单位 工作岗位 开始工作日期 结束工作日期
// 预入职-员工工作履历信息表
// private List<TPreEmpWorkRecording> tpreEmpWorkRecordingList
// 是否为首份工作 0是/1否
@ExcelAttribute(name = "是否为首份工作", isMark = true, isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 1)
private String firstWorkFlag;
@ExcelAttribute(name = "工作单位", errorInfo = "工作单位不能为空", maxLength = 100)
private String workUnit;
@ExcelAttribute(name = "工作岗位", maxLength = 100)
private String workJob;
@ExcelAttribute(name = "开始工作日期", isMark = true, errorInfo = "开始工作日期不能为空", isDate = true)
private String startDate;
@ExcelAttribute(name = "结束工作日期", isMark = true, isDate = true, pattern = "startDate")
private String endDate;
// 成员姓名 与本人关系 手机号码(家庭成员)
// 预入职-员工家庭信息表
// private List<TPreEmpFamily> tpreEmpFamilyList
@ExcelAttribute(name = "成员姓名", maxLength = 32)
private String familyName;
@ExcelAttribute(name = "与本人关系", isMark = true, maxLength = 32)
private String relationshipSelf;
@ExcelAttribute(name = "手机号码(家庭成员)", isMark = true, isPhone = true, maxLength = 32)
private String contractTel;
// 是否有职业资格证书 申报年度 职业资格名称
// 预入职-员工职业资格信息表
// private List<TPreEmpProfessionalQualification> tpreEmpProfessionalQualificationList
@ExcelAttribute(name = "是否有职业资格证书", isMark = true, isNotEmpty = true, isDataId = true, readConverterExp = "0=是,1=否")
private String haveQualification;
@ExcelAttribute(name = "申报年度", isMark = true, isDate = true, dateFormat = "yyyy", maxLength = 32)
private String declareYear;
@ExcelAttribute(name = "职业资格名称", isMark = true, isDataId = true, dataType = ExcelAttributeConstants.QUALIFICATION_TYPE, errorInfo = "职业资格名称不能为空", maxLength = 32)
private String qualificationType;
// 是否曾被认定为工伤 是否有职业病 职业病名称 是否有传染性疾病 传染病名称 是否被劳动能力鉴定委员会鉴定为具有伤残等级 伤残病名称 伤残等级
// 是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种
// 预入职-员工伤残信息表
// private TPreEmpDisabilityInfo tpreEmpDisabilityInfo
// 是否工伤标识0是/1否
@ExcelAttribute(name = "是否曾被认定为工伤", isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 1)
private String injuryIdentification;
// 是否职业病 0是/1否
@ExcelAttribute(name = "是否有职业病", isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 1)
private String occupationalDiseaseFlag;
@ExcelAttribute(name = "职业病名称")
private String occupationalDisease;
// 是否传染病病 0是/1否
@ExcelAttribute(name = "是否有传染性疾病", isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 1)
private String infectiousDiseaseFlag;
@ExcelAttribute(name = "传染病名称")
private String infectiousName;
// 是否持有残疾人证明 0是/1否
@ExcelAttribute(name = "是否被劳动能力鉴定委员会鉴定为具有伤残等级", isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 1)
private String disabilityFlag;
@ExcelAttribute(name = "伤残病名称")
private String disabilityName;
@ExcelAttribute(name = "伤残等级",isDataId = true, dataType = ExcelAttributeConstants.DISABILITY_GRADE)
private String disabilityLevel;
// 是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种 0是/1否
@ExcelAttribute(name = "是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种", isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 1)
private String otherFlag;
// 是否曾经或正在追究与承担过刑事责任
// 预入职-员工不良记录表
// private TPreEmpBadRecord tpreEmpBadRecord
@ExcelAttribute(name = "是否曾经或正在追究与承担过刑事责任", isDataId = true, readConverterExp = "0=是,1=否", isNotEmpty = true, maxLength = 200)
private String remark;
// 银行卡号 开户总行 开户省 开户市 开户支行 计税月份
@ExcelAttribute(name = "银行卡号", isNotEmpty = true, maxLength = 50)
private String bankNo;
@ExcelAttribute(name = "开户行总行", maxLength = 50)
private String bankName;
@ExcelAttribute(name = "开户省", isArea = true)
private String bankProvince;
@ExcelAttribute(name = "开户市", isArea = true, parentField = "bankProvince")
private String bankCity;
@ExcelAttribute(name = "开户支行", maxLength = 50)
private String bankSubName;
@ExcelAttribute(name = "计税月份", isDate = true, dateFormat = "yyyyMM", maxLength = 6)
private String taxMonth;
// 字典值起始
@ExcelAttribute(name = "员工类型")
private String empNatrueValue;
@ExcelAttribute(name = "婚姻状况")
private String empMarriStatusValue;
@ExcelAttribute(name = "民族")
private String empNationalValue;
@ExcelAttribute(name = "政治面貌")
private String politicalStatusValue;
@ExcelAttribute(name = "户籍所在地-省")
private String idProvinceValue;
@ExcelAttribute(name = "户籍所在地-市")
private String idCityValue;
@ExcelAttribute(name = "户籍所在地-县")
private String idTownValue;
@ExcelAttribute(name = "户口性质")
private String empRegisTypeValue;
@ExcelAttribute(name = "档案所在地-省")
private String fileProvinceValue;
@ExcelAttribute(name = "档案所在地-市")
private String fileCityValue;
@ExcelAttribute(name = "档案所在地-县")
private String fileTownValue;
@ExcelAttribute(name = "通信地址-省")
private String contactProvinceValue;
@ExcelAttribute(name = "通信地址-市")
private String contactCityValue;
@ExcelAttribute(name = "通信地址-县")
private String contactTownValue;
// 紧急联系人
@ExcelAttribute(name = "联系地址-省")
private String relationProvinceValue;
@ExcelAttribute(name = "联系地址-市")
private String relationCityValue;
@ExcelAttribute(name = "联系地址-县")
private String relationTownValue;
@ExcelAttribute(name = "教育开始时间")
private Date entryDateValue;
@ExcelAttribute(name = "教育结束时间")
private Date gradutionDateValue;
@ExcelAttribute(name = "开始工作日期")
private Date startDateValue;
@ExcelAttribute(name = "结束工作日期")
private Date endDateValue;
// 预入职-员工学历信息表
@ExcelAttribute(name = "学历")
private String educationNameValue;
// 预入职-员工工作履历信息表
@ExcelAttribute(name = "是否为首份工作")
private String firstWorkFlagValue;
// 预入职-员工职业资格信息表
@ExcelAttribute(name = "是否有职业资格证书")
private String haveQualificationValue;
@ExcelAttribute(name = "申报年度")
private String declareYearValue;
@ExcelAttribute(name = "职业资格名称")
private String qualificationTypeValue;
// 预入职-员工伤残信息表
@ExcelAttribute(name = "是否曾被认定为工伤")
private String injuryIdentificationValue;
@ExcelAttribute(name = "是否有职业病")
private String occupationalDiseaseFlagValue;
@ExcelAttribute(name = "是否有传染性疾病")
private String infectiousDiseaseFlagValue;
@ExcelAttribute(name = "是否被劳动能力鉴定委员会鉴定为具有伤残等级")
private String disabilityFlagValue;
@ExcelAttribute(name = "伤残等级")
private String disabilityLevelValue;
@ExcelAttribute(name = "是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种")
private String otherFlagValue;
// 银行卡号 开户总行 开户省 开户市 开户支行 计税月份
@ExcelAttribute(name = "开户省")
private String bankProvinceValue;
@ExcelAttribute(name = "开户市")
private String bankCityValue;
@ExcelAttribute(name = "计税月份")
private String taxMonthValue;
// 字典值结束
// 附属信息
List<PreUploadEmpImportVo> otherList = new ArrayList<>();
// 是否主信息,未false,则仅更新附属信息
@TableField(exist = false)
private Boolean isMain;
@TableField(exist = false)
private String errorInfo;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import lombok.Getter;
import lombok.Setter;
/**
* @author hgw
* @description 预入职导入入参
* @date 2024-10-12 11:16:17
*/
@Getter
@Setter
public class PreUploadImportParamVo {
// 结算主体;必填
String deptId;
// sheetName;必填
String sheetName;
}
......@@ -105,6 +105,12 @@
<artifactId>javase</artifactId>
<version>3.5.1</version>
</dependency>
<!-- 读取excel -->
<dependency>
<groupId>com.monitorjbl</groupId>
<artifactId>xlsx-streamer</artifactId>
<version>2.2.0</version>
</dependency>
<!-- 二维码生成JAR结束 -->
</dependencies>
......
......@@ -21,9 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpMain;
import com.yifu.cloud.plus.v1.yifu.archives.service.TPreEmpMainService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.PreEmpMainDetailVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TPreEmpMainSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
......@@ -126,6 +124,7 @@ public class TPreEmpMainController {
/**
* 预入职批量完善信息
*
* @author hgw
* @date 2024-6-21 15:25:20
**/
......@@ -152,6 +151,7 @@ public class TPreEmpMainController {
/**
* 预入职批量审核
*
* @author hgw
* @date 2024-6-24 12:00:53
**/
......@@ -241,6 +241,7 @@ public class TPreEmpMainController {
**/
@Operation(summary = "导出预入职-全量", description = "导出预入职-全量 hasPermission('archives_tpreempmain-export-all')")
@PostMapping("/exportAll")
@SysLog("导出预入职-全量")
//@PreAuthorize("@pms.hasPermission('archives_tpreempmain-export-all')")
public void exportAll(HttpServletResponse response, @RequestBody TPreEmpMainSearchVo searchVo) {
YifuUser user = SecurityUtils.getUser();
......@@ -248,4 +249,18 @@ public class TPreEmpMainController {
tPreEmpMainService.exportAll(response, searchVo);
}
/**
* @param file
* @Description: 预入职批量导入
* @Author: hgw
* @Date: 2024/10/12 9:24
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo>
**/
@SysLog("预入职批量导入")
@Operation(description = "预入职批量导入")
@PostMapping("/uploadPreEmp")
public R<List<PreUploadEmpImportVo>> uploadPreEmp(MultipartFile file, PreUploadImportParamVo vo) throws Exception {
return tPreEmpMainService.uploadPreEmp(file, vo);
}
}
......@@ -51,6 +51,8 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
// hgw 2022-6-22 15:32:39 根据身份证查询一批档案
List<TEmployeeInfo> getListByIdCard(@Param("idCardList") List<String> idCardList);
List<TEmployeeInfo> getListByIdCardList(@Param("idCardList") List<String> idCardList);
// hgw 2022-6-22 15:32:39 根据手机号查询一批档案
List<TEmployeeInfo> getListByPhone(@Param("phoneList") List<String> phoneList);
......
......@@ -65,6 +65,9 @@ public interface TPreEmpMainMapper extends BaseMapper<TPreEmpMain> {
TPreEmpMain getTPreEmpMainByCardAndDept(@Param("empIdCard") String empIdCard, @Param("deptId") String deptId);
/* 导入预入职时,查询所有身份证的预入职使用的,查出来删除附属信息 */
List<String> getTPreEmpMainListByCardAndDept(@Param("empIdCardList") List<String> empIdCardList, @Param("deptId") String deptId);
TPreEmpMain getTPreEmpMainByCardAndDeptNo(@Param("empIdCard") String empIdCard, @Param("deptNo") String deptNo);
// 以下都是清空临时表的数据
......@@ -76,4 +79,18 @@ public interface TPreEmpMainMapper extends BaseMapper<TPreEmpMain> {
void deleteEmployeeByMainId(@Param("preMainId") String preMainId);
void deleteProjectByMainId(@Param("preMainId") String preMainId);
// 以下都是清空临时表的数据
void deleteBadByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteContactByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteDisabilityByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteEducationByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteFamilyByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteEmployeeByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteProjectByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteWorkRecordingByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteProfessionalByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteOtherFileByMainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deleteAttaByDomainIdList(@Param("preMainIdList") List<String> preMainIdList);
void deletePreMainIdList(@Param("preMainIdList") List<String> preMainIdList);
}
......@@ -260,4 +260,8 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
R<TEmployeeInfo> getByIdAssociate(String id);
void exportEmployeeFile(String id, HttpServletResponse response) throws Exception;
// 预入职批量导入使用
List<TEmployeeInfo> getListByIdCardList(List<String> idList);
}
......@@ -272,4 +272,14 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> {
void updateContractStatus(String empId, String deptId, int status);
void updatePostByEmpDeptNo(String deptNo, String post, String empIdcard);
/**
* @param deptId 项目id
* @Description: 获取项目下的未删除的在项的人员
* @Author: hgw
* @Date: 2024/10/14 16:28
* @return: java.util.Map<java.lang.String, com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject>
**/
Map<String, TEmployeeProject> getMapByDeptIdAndDelete(String deptId);
}
......@@ -21,11 +21,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpMain;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.PreEmpMainDetailVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TPreEmpMainSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
......@@ -64,8 +63,10 @@ public interface TPreEmpMainService extends IService<TPreEmpMain> {
// 单个完善信息
R<String> doImproveInformation(PreEmpMainDetailVo vo);
// 草稿
R<String> saveDraftPreEmpMain(PreEmpMainDetailVo vo);
// 保存
R<String> savePreEmpMain(PreEmpMainDetailVo vo);
......@@ -74,6 +75,7 @@ public interface TPreEmpMainService extends IService<TPreEmpMain> {
// 导出
void listExport(HttpServletResponse response, TPreEmpMainSearchVo searchVo);
// 导出全量
void exportAll(HttpServletResponse response, TPreEmpMainSearchVo searchVo);
......@@ -85,4 +87,12 @@ public interface TPreEmpMainService extends IService<TPreEmpMain> {
// 批量审核
R<List<ErrorVO>> doBatchAudit(List<String> ids, String status, String auditRemark);
/**
* @Description: 预入职批量导入
* @Author: hgw
* @Date: 2024/10/12 9:27
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.archives.vo.PreEmpMainDetailVo>>
**/
R<List<PreUploadEmpImportVo>> uploadPreEmp(MultipartFile file, PreUploadImportParamVo vo) throws Exception;
}
......@@ -249,7 +249,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
TEmpEducation education = new TEmpEducation();
this.doUpdateEducationCore(education, employeeInfo);
// 更新附件信息 fxj 2024-09-09
// 更新其他附件信息 fxj 2024-09-09
if (updateOtherAtta(employeeInfo)){
// 获取最新附件信息 fxj 2024-09-09
getAttaInfo(employeeInfo);
......@@ -257,8 +257,14 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
old.setOtherFiles(null);
employeeInfo.setOtherFiles(null);
}
// 更新附件信息 hgw 2024-10-15
if (updateAtta(employeeInfo)){
// 获取最新附件信息
getEmpAttaInfo(employeeInfo);
} else{
old.setAttaList(null);
employeeInfo.setAttaList(null);
}
// 记录变更日志
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0], old.getId(), "", old, employeeInfo);
return R.ok(this.updateById(employeeInfo));
......@@ -304,6 +310,33 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return flag;
}
// 仿写房工更新附件
private boolean updateAtta(TEmployeeInfo employeeInfo) {
List<TAttaInfo> attaInfos = employeeInfo.getAttaList();
boolean flag = false;
if (Common.isNotNull(attaInfos)){
List<String> deleteIds = new ArrayList<>();
List<TAttaInfo> adds = new ArrayList<>();
for (TAttaInfo attaInfo : attaInfos){
if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())){
adds.add(attaInfo);
}
if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())){
deleteIds.add(attaInfo.getId());
}
}
if (Common.isNotNull(deleteIds)){
attaInfoService.removeBatchByIds(deleteIds);
flag =true;
}
if (Common.isNotNull(adds)){
attaInfoService.updateBatchById(adds);
flag =true;
}
}
return flag;
}
private boolean handleOtherFile(TEmpOtherFile otherFile) {
boolean flag =false;
// 新增时先增加 empOtherFile
......@@ -364,6 +397,21 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
emp.setOtherFiles(otherFiles);
}
// 仿写房工附件接口
private void getEmpAttaInfo(TEmployeeInfo emp) {
List<TAttaInfo> attaInfos = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, emp.getId()));
if (Common.isNotNull(attaInfos)){
URL url;
for (TAttaInfo atta:attaInfos){
url = ossUtil.getObjectUrl(null, atta.getAttaSrc());
if (Common.isNotNull(url)){
atta.setAttaUrl(url.toString());
}
}
}
emp.setAttaList(attaInfos);
}
@Override
public R<String> deleteEmployee(String id) {
TEmployeeInfo employee = this.getById(id);
......@@ -2830,6 +2878,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
getAttaInfo(employeeInfo);
getEmpAttaInfo(employeeInfo);
return R.ok(employeeInfo);
}
/**
......@@ -2951,4 +3000,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return fileAtta.getAttaName();
}
}
@Override
public List<TEmployeeInfo> getListByIdCardList(List<String> idList) {
return baseMapper.getListByIdCardList(idList);
}
}
......@@ -1924,4 +1924,22 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
audit.setCreateName(tEmployeeContractInfo.getAuditUserName());
tEmployeeContractAuditService.save(audit);
}
@Override
public Map<String, TEmployeeProject> getMapByDeptIdAndDelete(String deptId) {
Map<String, TEmployeeProject> proMap = new HashMap<>();
if (Common.isNotNull(deptId)) {
List<TEmployeeProject> projectList = this.list(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getDeptId, deptId)
.ne(TEmployeeProject::getProjectStatus, CommonConstants.ONE_INT)
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.ZERO_STRING));
if (projectList != null && !projectList.isEmpty()) {
for (TEmployeeProject pro : projectList) {
proMap.put(pro.getEmpIdcard(), pro);
}
}
}
return proMap;
}
}
......@@ -31,37 +31,52 @@ 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.monitorjbl.xlsx.StreamingReader;
import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckMobile;
import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TPreEmpMainMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.archives.utils.ExcelStyle;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprCheckProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelColumnVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.compress.utils.Lists;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
......@@ -73,7 +88,7 @@ import java.util.regex.Pattern;
@Log4j2
@AllArgsConstructor
@Service
@EnableConfigurationProperties(DaprSalaryProperties.class)
@EnableConfigurationProperties({DaprSalaryProperties.class, DaprCheckProperties.class})
public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreEmpMain> implements TPreEmpMainService {
// 预入职-员工不良记录表
private final TPreEmpBadRecordService tPreEmpBadRecordService;
......@@ -129,6 +144,8 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
// 薪资服务,获取计税月份
private final DaprSalaryProperties salaryProperties;
// 导入批量校验身份证、卡号、手机号
private final DaprCheckProperties checkProperties;
private final OSSUtil ossUtil;
......@@ -891,7 +908,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
return R.failed("计税月份为6位年月,例如:202407!");
}
if (Common.isNotNull(tPreEmployee.getTaxMonthFlag()) && CommonConstants.ZERO_STRING.equals(tPreEmployee.getTaxMonthFlag())
&& oldPreEmployee != null && !oldPreEmployee.getTaxMonth().equals(tPreEmployee.getTaxMonth()) ) {
&& oldPreEmployee != null && !oldPreEmployee.getTaxMonth().equals(tPreEmployee.getTaxMonth())) {
return R.failed("本年度有发薪纪录,计税月份不可编辑!");
}
}
......@@ -908,9 +925,122 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
main.setEmpNatrue(tPreEmployee.getEmpNatrue());
main.setStatus(CommonConstants.TWO_STRING);
this.updateById(main);
if (CommonConstants.ONE_STRING.equals(main.getSourType())) {
// 更新其他附件信息 fxj 2024-09-09
updateOtherAtta(main);
// 更新附件信息 hgw 2024-10-15
updateAtta(main);
}
return R.ok("已完善!");
}
private boolean updateOtherAtta(TPreEmpMain employeeInfo) {
List<TPreEmpOtherFile> otherFileList = employeeInfo.getOtherFiles();
boolean flag = false;
if (Common.isNotNull(otherFileList)){
List<TAttaInfo> attaInfos = new ArrayList<>();
for (TPreEmpOtherFile otherFile:otherFileList){
//处理新增或删除其他附件分租的逻辑
if (!flag){
flag = handleOtherFile(otherFile);
}else {
handleOtherFile(otherFile);
}
if (Common.isNotNull(otherFile.getAttaList())){
attaInfos.addAll(otherFile.getAttaList());
}
}
if (Common.isNotNull(attaInfos)){
List<String> deleteIds = new ArrayList<>();
List<TAttaInfo> adds = new ArrayList<>();
for (TAttaInfo attaInfo:attaInfos){
if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())){
adds.add(attaInfo);
}
if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())){
deleteIds.add(attaInfo.getId());
}
}
if (Common.isNotNull(deleteIds)){
tAttaInfoService.removeBatchByIds(deleteIds);
flag =true;
}
if (Common.isNotNull(adds)){
tAttaInfoService.updateBatchById(adds);
flag =true;
}
}
}
return flag;
}
// 仿写房工更新附件
private boolean updateAtta(TPreEmpMain employeeInfo) {
List<TAttaInfo> attaInfos = employeeInfo.getAttaList();
boolean flag = false;
if (Common.isNotNull(attaInfos)){
List<String> deleteIds = new ArrayList<>();
List<TAttaInfo> adds = new ArrayList<>();
for (TAttaInfo attaInfo : attaInfos){
if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())){
adds.add(attaInfo);
}
if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())){
deleteIds.add(attaInfo.getId());
}
}
if (Common.isNotNull(deleteIds)){
tAttaInfoService.removeBatchByIds(deleteIds);
flag =true;
}
if (Common.isNotNull(adds)){
tAttaInfoService.updateBatchById(adds);
flag =true;
}
}
return flag;
}
private boolean handleOtherFile(TPreEmpOtherFile otherFile) {
boolean flag =false;
// 新增时先增加 empOtherFile
if (CommonConstants.ZERO_STRING.equals(otherFile.getHandleType())){
tPreEmpOtherFileService.save(otherFile);
flag = true;
if (Common.isNotNull(otherFile.getAttaList())){
for (TAttaInfo info: otherFile.getAttaList()){
info.setDomainId(otherFile.getId());
}
}
// 更新
}if (CommonConstants.ONE_STRING.equals(otherFile.getHandleType())){
flag = true;
if (Common.isNotNull(otherFile.getId())){
tPreEmpOtherFileService.updateById(otherFile);
if (Common.isNotNull(otherFile.getAttaList())){
for (TAttaInfo info: otherFile.getAttaList()){
info.setDomainId(otherFile.getId());
}
}
}
// 删除时
}if (CommonConstants.THREE_STRING.equals(otherFile.getHandleType())){
if (Common.isNotNull(otherFile.getId())){
if (Common.isNotNull(otherFile.getAttaList())){
for (TAttaInfo info: otherFile.getAttaList()){
info.setDomainId(otherFile.getId());
}
}
}
// 删除时
}else if (CommonConstants.TWO_STRING.equals(otherFile.getHandleType())){
tPreEmpOtherFileService.removeById(otherFile.getId());
flag = true;
}
return flag;
}
/**
* @param vo
* @Description: 草稿
......@@ -965,6 +1095,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
main.setCreateBy(user.getId());
main.setCreateName(user.getNickname());
main.setCreateTime(LocalDateTime.now());
main.setSourType(CommonConstants.ZERO_STRING);
this.saveOrUpdate(main);
String mainId = main.getId();
......@@ -1163,7 +1294,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
}
} catch (Exception e) {
log.error("档案预入职C端保存异常:", e);
throw new RuntimeException("保存失败,请联系管理员!!预入职主键【" + main.getId() +"】");
throw new RuntimeException("保存失败,请联系管理员!!预入职主键【" + main.getId() + "】");
}
}
......@@ -1803,7 +1934,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
// 出生日期
String idCardDate = idCard.substring(6, 14);
Date empBirthday = DateUtil.stringToDateByPatten(idCardDate, "yyyyMMdd");
Date empBirthday = DateUtil.stringDateFormat(idCardDate, "yyyyMMdd");
employeeInfo.setEmpBirthday(empBirthday);
// 性别
......@@ -2115,7 +2246,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
}
} catch (Exception e) {
log.error("档案预入职审核异常:", e);
throw new RuntimeException("保存失败,请联系管理员!!预入职主键【" + preEmpMain.getId() +"】");
throw new RuntimeException("保存失败,请联系管理员!!预入职主键【" + preEmpMain.getId() + "】");
}
}
......@@ -2392,4 +2523,1484 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
}
}
/**
* @param file 文件流
* @Description: 导入预入职
* @Author: hgw
* @Date: 2024/10/12 9:28
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.archives.vo.PreEmpMainDetailVo>>
**/
@Override
public R<List<PreUploadEmpImportVo>> uploadPreEmp(MultipartFile file, PreUploadImportParamVo paramVo) throws Exception {
// 自定义解析Excel,判断表头、必填、格式;
// 按项目查项目人员、档案人员、预入职人员;
// 有项目人员,仅更新,否则看预入职人员,新增或更新,加导入标签;
// 返回结果list。
//对前端传递的文件进行校验
if (paramVo == null || Common.isEmpty(paramVo.getDeptId())) {
return R.failed("请前端传参!");
}
String deptId = paramVo.getDeptId();
TSettleDomain dept = tSettleDomainService.getById(deptId);
if (dept == null || Common.isEmpty(dept.getId())) {
return R.failed("未找到项目!");
}
// 预入职-员工申明
TPreEmpDeclaration tPreEmpDeclaration = tPreEmpDeclarationService.getTPreEmpDeclarationList();
if (tPreEmpDeclaration == null || Common.isEmpty(tPreEmpDeclaration.getId())) {
return R.failed("请联系管理员添加员工申明TPreEmpDeclaration数据!");
}
String declarId = tPreEmpDeclaration.getId();
//对前端传递的文件进行校验
if (file == null || file.isEmpty()) {
return R.failed("文件为空,重新上传");
}
//获取文件名称 判断文件是否为 Execl
String filename = file.getOriginalFilename();
if (filename == null || Common.isEmpty(filename)) {
return R.failed("文件名称为空,请重新上传!");
}
if (!(filename.endsWith(".xls") || filename.endsWith(".xlsx"))) {
return R.failed("文件名称格式有误,请重新上传!" + filename);
}
InputStream inputStream = file.getInputStream();
R<ExcelSheetVo> voR = null;
ExcelSheetVo vo;
List<String> specialIdCardList = null;
int maxRow = 1000;
if (filename.endsWith(".xlsx")) {
voR = readXlsx(inputStream, specialIdCardList, false, paramVo.getSheetName(), maxRow);
}
if (voR != null && voR.getCode() == CommonConstants.SUCCESS) {
vo = voR.getData();
} else {
return R.failed(voR == null ? "识别表格异常!" : voR.getMsg());
}
String[] modelTitle = {"员工类型", "员工姓名", "身份证号", "身份证开始日期", "身份证截止日期", "婚姻状况", "民族"
, "政治面貌", "手机号码", "邮箱", "户籍所在地-省", "户籍所在地-市", "户籍所在地-区/县", "户口性质", "档案所在地-省"
, "档案所在地-市", "档案所在地-区/县", "通信地址-省", "通信地址-市", "通信地址-区/县", "通信地址-详细地址"
, "紧急联系人姓名", "与本人关系", "联系地址-省", "联系地址-市", "联系地址-区/县", "联系地址-详细地址"
, "手机号码(紧急联系人)", "学历", "学校", "专业", "教育开始时间", "教育结束时间", "是否为首份工作", "工作单位"
, "工作岗位", "开始工作日期", "结束工作日期", "成员姓名", "与本人关系", "手机号码(家庭成员)", "是否有职业资格证书"
, "申报年度", "职业资格名称", "是否曾被认定为工伤", "是否有职业病", "职业病名称", "是否有传染性疾病", "传染病名称"
, "是否被劳动能力鉴定委员会鉴定为具有伤残等级", "伤残病名称", "伤残等级"
, "是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种", "是否曾经或正在追究与承担过刑事责任"
, "银行卡号", "开户总行", "开户省", "开户市", "开户支行", "计税月份"};
int modelLength = modelTitle.length;
// 1 验证表头:
if (vo.getTitleList() != null && !vo.getTitleList().isEmpty()) {
if (vo.getTitleList().size() != modelLength) {
return R.failed("请检查表头列数!模板列数为:" + modelLength + ",您导入的表头列数为:" + vo.getTitleList().size());
}
ExcelColumnVo title;
// 标题行的内容
String titleStr;
StringBuilder errorTitle = new StringBuilder();
for (int i = 0; i < vo.getTitleList().size(); i++) {
title = vo.getTitleList().get(i);
titleStr = title.getContent();
if (!modelTitle[i].equals(titleStr)) {
errorTitle.append("第").append((i + 1)).append("列表头应为:").append(modelTitle[i]).append(",您的表头为").append(titleStr).append(";");
}
}
if (errorTitle.length() > 0) {
return R.failed("表头错误:" + errorTitle + " 请检查调整后再次导入");
}
} else {
return R.failed("表格没有表头,请检查表格数据!");
}
// 2 读取内容:
if (vo.getContentList() != null && !vo.getContentList().isEmpty()) {
// 薪资服务的开户行
R<TBankNameMapVo> bankRes = HttpDaprUtil.invokeMethodPost(salaryProperties.getAppUrl()
, salaryProperties.getAppId(), "/tbankset/inner/getBankMap", null, TBankNameMapVo.class, SecurityConstants.FROM_IN);
Map<String, String> bankMap = new HashMap<>();
if (Common.isEmpty(bankRes) || bankRes.getData() == null || bankRes.getData().getBankMap() == null){
return R.failed("获取薪资服务开户行信息失败!");
} else {
bankMap = bankRes.getData().getBankMap();
}
PreUploadEmpImportVo detail;
List<TCheckIdCard> checkList = new ArrayList<>();
List<String> mobileList = new ArrayList<>();
List<TCheckBankNo> bankList = new ArrayList<>();
YifuUser user = SecurityUtils.getUser();
TCheckIdCard idCardCheck;
TCheckBankNo bankCheck;
Map<Integer, String> titleMap = new HashMap<>();
// 得到类的所有field
Field[] allFields = PreUploadEmpImportVo.class.getDeclaredFields();
// 从map中得到对应列的field
Field field;
// 将有注解的field存放到fieldsMap中
Map<String, Field> fieldsMap = new HashMap<>();
for (int i = 0; i < allFields.length; i++) {
field = allFields[i];
if (field.isAnnotationPresent(ExcelAttribute.class)) {
// 设置类的私有字段属性可访问
field.setAccessible(true);
fieldsMap.put(field.getName(), field);
titleMap.put(i, field.getName());
}
}
ExcelAttribute attr; //获取属性对应的注解属性
Class<?> fieldType; // 取得类型,并根据对象类型设置值
List<PreUploadEmpImportVo> excelList = new ArrayList<>();
String idNumber = "empIdcard";
String shuName;
String shuValue;
String dictValue;
// 必填项未填写
StringBuilder errorMust;
// 格式不正确
StringBuilder errorFormat;
// 校验是否通过
StringBuilder errorCheck;
// 已存在的主档案Map
Map<String, PreUploadEmpImportVo> empMap = new HashMap<>();
// 已存在的主档案
PreUploadEmpImportVo curVo;
// 人员map
Map<String, TEmployeeProject> proMap = tEmployeeProjectService.getMapByDeptIdAndDelete(paramVo.getDeptId());
TEmployeeProject project;
// 预入职map
Map<String, TPreEmpMain> preMap = this.getMapByDeptId(paramVo.getDeptId());
TPreEmpMain main;
// 字典Map
Map<String, String> dictMap = new HashMap<>();
// 存放父级area的值
Map<String, String> parentAreaMap = new HashMap<>();
Map<String, Date> startDateMap = new HashMap<>();
for (Map<String, String> rowMap : vo.getContentList()) {
curVo = null;
errorMust = new StringBuilder();
errorFormat = new StringBuilder();
// 每一行都要初始化起始时间
startDateMap = new HashMap<>();
detail = new PreUploadEmpImportVo();
for (int i = 0; i < modelLength; i++) {
shuName = titleMap.get(i);
shuValue = rowMap.get(String.valueOf(i));
if (Common.isNotNull(shuName)) {
// 忽略Value的值
if (!shuName.contains("Value")) {
if (idNumber.equals(shuName)) {
if (Common.isEmpty(shuValue)) {
errorMust.append("身份证号;");
} else {
curVo = empMap.get(shuValue);
}
}
field = fieldsMap.get(shuName);
if (field != null) {
attr = field.getAnnotation(ExcelAttribute.class);
if (curVo == null) {
// 必填
if (attr.isNotEmpty() && Common.isEmpty(shuValue)) {
errorMust.append(attr.name()).append(";");
}
}
if (Common.isNotNull(shuValue)) {
shuValue = shuValue.trim();
//校验字段是否符合要求 返回错误信息
dictValue = this.validateUtil(shuValue, attr, errorFormat, dictMap, parentAreaMap, shuName, curVo != null, startDateMap);
//校验字段是否符合要求2 开户行
if (curVo == null && "bankName".equals(shuName) && bankMap.get(shuValue) == null) {
errorFormat.append(attr.name()).append("_不符合财务要求,请查薪资配置;");
}
fieldType = field.getType();
if (Common.isNotNull(fieldType)) {
this.setFields(field, shuValue, attr, fieldType, detail);
}
// 塞字典返回的值
if (Common.isNotNull(dictValue)) {
field = fieldsMap.get(shuName + "Value");
if (field != null) {
attr = field.getAnnotation(ExcelAttribute.class);
fieldType = field.getType();
if (Common.isNotNull(fieldType)) {
this.setFields(field, dictValue, attr, fieldType, detail);
}
}
}
}
}
}
}
}
// 第一步:校验是否通过:身份证号是否有(反馈信息:身份证号不存在)→人员是否已在项(或已导入待审核)
// (反馈信息:人员已在项,如需更新信息,请点击“批量更新”入口更新;人员“待审核”,如需更新,可“审核不通过”再次导入)
if (Common.isNotNull(detail.getEmpIdcard())) {
project = proMap.get(detail.getEmpIdcard());
if (project != null) {
detail.setErrorInfo("人员已在项,如需更新信息,请点击“批量更新”入口更新");
} else {
main = preMap.get(detail.getEmpIdcard());
if (main != null && Common.isNotNull(main.getStatus()) && CommonConstants.TWO_STRING.equals(main.getStatus())) {
detail.setErrorInfo("人员“待审核”,如需更新,可“审核不通过”再次导入");
} else {
// 第二步:其他信息并行校验
// 1必填项未填写:紧急联系人
// 2格式不正确:计税月份
// 3校验是否通过:姓名&身份证号是否一致、手机号是否真实、姓名&银行卡号是否一致
// 1必填项未填写:紧急联系人
// 有主档案,则判断附属信息是否联动必填
if (curVo != null) {
// 主要工作经历
// 主要家庭成员信息
// 职业资格信息——职业资格证书
if (Common.isEmpty(detail.getFirstWorkFlag())
&& Common.isEmpty(detail.getFamilyName())
&& Common.isEmpty(detail.getHaveQualification())) {
errorMust.append("附属信息:主要工作经历、主要家庭成员信息、职业资格信息不能都为空!");
} else {
// 主要工作经历
judgeWorkFlag(detail, errorMust);
// 主要家庭成员信息
judgeFamily(detail, errorMust);
// 职业资格信息——职业资格证书
judgeQualification(detail, errorMust);
}
} else {
// 主的其他信息必填校验
if (Common.isEmpty(detail.getEmpNatrue())) {
errorMust.append("员工类型;");
}
if (Common.isEmpty(detail.getEmpName())) {
errorMust.append("员工姓名;");
}
// 主的其他联动必填
// 最高教育经历
judgeEducation(detail, errorMust);
// 主要工作经历
judgeWorkFlag(detail, errorMust);
// 主要家庭成员信息
judgeFamily(detail, errorMust);
// 职业资格信息——职业资格证书
judgeQualification(detail, errorMust);
// 伤残信息
judgeDisability(detail, errorMust);
// 银行卡号
judgeBank(detail, errorMust);
}
// 2格式不正确:在循环里已经判断了
// 3校验是否通过:姓名&身份证号是否一致、手机号是否真实、姓名&银行卡号是否一致
if (curVo != null) {
if (Common.isNotNull(detail.getContractTel())) {
mobileList.add(detail.getContractTel());
}
} else {
if (Common.isNotNull(detail.getEmpName())) {
if (Common.isNotNull(detail.getEmpIdcard())) {
idCardCheck = new TCheckIdCard();
idCardCheck.setIdCard(detail.getEmpIdcard());
idCardCheck.setName(detail.getEmpName());
idCardCheck.setCreateUser(user.getId());
idCardCheck.setReason(user.getNickname());
checkList.add(idCardCheck);
}
if (Common.isNotNull(detail.getBankNo())) {
bankCheck = new TCheckBankNo();
bankCheck.setBankNo(detail.getBankNo());
bankCheck.setName(detail.getEmpName());
bankList.add(bankCheck);
}
}
// 手机号码
if (Common.isNotNull(detail.getEmpPhone())) {
mobileList.add(detail.getEmpPhone());
}
// 手机号码(紧急联系人)
if (Common.isNotNull(detail.getTel())) {
mobileList.add(detail.getTel());
}
// 手机号码(家庭成员)
if (Common.isNotNull(detail.getContractTel())) {
mobileList.add(detail.getContractTel());
}
}
StringBuilder errorInfo = new StringBuilder();
if (errorMust.length() > 0) {
errorInfo.append("必填项未填写:").append(errorMust);
}
if (errorFormat.length() > 0) {
errorInfo.append("格式不正确:").append(errorFormat);
}
detail.setErrorInfo(errorInfo.toString());
if (curVo != null) {
//List<PreUploadEmpImportVo> otherList = curVo.getOtherList();
//otherList.add(detail);
//empMap.put(detail.getEmpIdcard(), curVo);
detail.setIsMain(false);
} else {
detail.setIsMain(true);
empMap.put(detail.getEmpIdcard(), detail);
}
}
}
} else {
detail.setErrorInfo("身份证号不存在!");
}
excelList.add(detail);
}
// 批量校验 卡号与手机号
Map<String, Boolean> bankNoMap = new HashMap<>();
Map<String, Boolean> phoneMap = new HashMap<>();
Map<String, Boolean> idCardMap = new HashMap<>();
if (!bankList.isEmpty()) {
R<CheckBatchVo> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckbankno/inner/checkBankNoBatch", bankList, CheckBatchVo.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
bankNoMap = checkListR.getData().getCheckMap();
}
}
if (!mobileList.isEmpty()) {
R<CheckBatchVo> phoneR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckmobile/inner/checkMobileBatch", mobileList, CheckBatchVo.class, SecurityConstants.FROM_IN);
if (phoneR != null && phoneR.getData() != null) {
phoneMap = phoneR.getData().getCheckMap();
}
}
if (!checkList.isEmpty()) {
R<CheckBatchVo> idCardR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardBatch", checkList, CheckBatchVo.class, SecurityConstants.FROM_IN);
if (idCardR != null && idCardR.getData() != null) {
idCardMap = idCardR.getData().getCheckMap();
}
}
int idCardFlag = 0;
if (idCardMap != null && !idCardMap.isEmpty()) {
if (idCardMap.get("全部正确") != null) {
idCardFlag = 1;
}
if (idCardMap.get("全部错误") != null) {
idCardFlag = 2;
}
}
Boolean resultB;
// 要保存的list
List<PreUploadEmpImportVo> saveList = new ArrayList<>();
// 返回的错误excel
List<PreUploadEmpImportVo> errorList = new ArrayList<>();
// 用于查询预入职相关信息
List<String> idCardList = new ArrayList<>();
for (PreUploadEmpImportVo info : excelList) {
errorCheck = new StringBuilder();
if (Common.isNotNull(info.getEmpName())) {
if (idCardFlag == 0) {
if (Common.isNotNull(info.getEmpIdcard())) {
resultB = idCardMap.get(info.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + info.getEmpName());
if (resultB != null) {
if (!resultB) {
errorCheck.append("姓名&身份证号不一致;");
}
} else {
errorCheck.append("姓名&身份证号未校验;");
}
}
} else if (idCardFlag == 2) {
errorCheck.append("姓名&身份证号不一致;");
}
if (Common.isNotNull(info.getBankNo())) {
resultB = bankNoMap.get(info.getBankNo());
if (resultB != null) {
if (!resultB) {
errorCheck.append("姓名&银行卡号不一致;");
}
} else {
errorCheck.append("姓名&银行卡号未校验;");
}
}
}
// 手机号码
if (Common.isNotNull(info.getEmpPhone())) {
resultB = phoneMap.get(info.getEmpPhone());
if (resultB != null) {
if (!resultB) {
errorCheck.append("手机号码校验不通过;");
}
} else {
errorCheck.append("手机号码未校验;");
}
}
// 手机号码(紧急联系人)
if (Common.isNotNull(info.getTel())) {
resultB = phoneMap.get(info.getTel());
if (resultB != null) {
if (!resultB) {
errorCheck.append("手机号码(紧急联系人)校验不通过;");
}
} else {
errorCheck.append("手机号码(紧急联系人)未校验;");
}
}
// 手机号码(家庭成员)
if (Common.isNotNull(info.getContractTel())) {
resultB = phoneMap.get(info.getContractTel());
if (resultB != null) {
if (!resultB) {
errorCheck.append("手机号码(家庭成员)校验不通过;");
}
} else {
errorCheck.append("手机号码(家庭成员)未校验;");
}
}
if (errorCheck.length() > 0) {
info.setErrorInfo(info.getErrorInfo() + "校验未通过:" + errorCheck);
errorList.add(info);
} else if (Common.isEmpty(info.getErrorInfo())) {
// 全部验证成功
saveList.add(info);
idCardList.add(info.getEmpIdcard());
} else {
errorList.add(info);
}
}
// boolean flag = false;
// 验证通过的,开始保存
if (!saveList.isEmpty()) {
List<String> preList = baseMapper.getTPreEmpMainListByCardAndDept(idCardList, deptId);
if (preList != null && !preList.isEmpty()) {
baseMapper.deleteBadByMainIdList(preList);
baseMapper.deleteContactByMainIdList(preList);
baseMapper.deleteDisabilityByMainIdList(preList);
baseMapper.deleteEducationByMainIdList(preList);
baseMapper.deleteFamilyByMainIdList(preList);
baseMapper.deleteEmployeeByMainIdList(preList);
baseMapper.deleteProjectByMainIdList(preList);
baseMapper.deleteWorkRecordingByMainIdList(preList);
baseMapper.deleteProfessionalByMainIdList(preList);
baseMapper.deleteOtherFileByMainIdList(preList);
baseMapper.deleteAttaByDomainIdList(preList);
baseMapper.deletePreMainIdList(preList);
}
// 保存主表信息
List<TPreEmpMain> mainList = new ArrayList<>();
for (PreUploadEmpImportVo info : saveList) {
if (Common.isNotNull(info.getIsMain()) && Boolean.TRUE.equals(info.getIsMain())) {
main = new TPreEmpMain();
main.setSourType(CommonConstants.ONE_STRING);
main.setEmpIdcard(info.getEmpIdcard());
main.setEmpName(info.getEmpName());
main.setSettleDomain(dept.getId());
main.setDeptId(dept.getId());
main.setDeptName(dept.getDepartName());
main.setDeptNo(dept.getDepartNo());
main.setUnitId(dept.getCustomerId());
main.setUnitName(dept.getCustomerName());
main.setUnitNo(dept.getCustomerNo());
main.setBusinessPrimaryType(dept.getBusinessPrimaryType());
main.setBusinessSecondType(dept.getBusinessSecondType());
main.setBusinessThirdType(dept.getBusinessThirdType());
main.setStatus(CommonConstants.ONE_STRING);
main.setDeclarationId(declarId);
main.setEmpPhone(info.getEmpPhone());
main.setEmpNatrue(info.getEmpNatrueValue());
// 给下面的附属信息使用的
main.setFirstWorkFlag(info.getFirstWorkFlag());
main.setHaveQualification(info.getHaveQualification());
mainList.add(main);
}
}
this.saveBatch(mainList);
Map<String, TPreEmpMain> saveMainMap = new HashMap<>();
for (TPreEmpMain saveMain : mainList) {
saveMainMap.put(saveMain.getEmpIdcard(), saveMain);
}
List<TEmployeeInfo> oldEmpList = tEmployeeInfoService.getListByIdCardList(idCardList);
Map<String, TEmployeeInfo> oldEmpMap = new HashMap<>();
if (oldEmpList != null && !oldEmpList.isEmpty()) {
for (TEmployeeInfo e : oldEmpList) {
oldEmpMap.put(e.getEmpIdcard(), e);
}
}
TEmployeeInfo employee;
TPreEmployeeInfo tPreEmployeeInfo;
TPreEmployeeProject tPreEmployeeProject;
String empId = null;
// 组装1 预入职 档案
List<TPreEmployeeInfo> preEmployeeInfoList = new ArrayList<>();
List<TPreEmployeeProject> preEmployeeProjectList = new ArrayList<>();
List<TPreEmpBadRecord> preEmpBadRecordList = new ArrayList<>();
List<TPreEmpContactInfo> preEmpContactInfoList = new ArrayList<>();
List<TPreEmpDisabilityInfo> preEmpDisabilityInfoList = new ArrayList<>();
List<TPreEmpEducation> preEmpEducationList = new ArrayList<>();
List<TPreEmpFamily> preEmpFamilyList = new ArrayList<>();
List<TPreEmpWorkRecording> preEmpWorkRecordingList = new ArrayList<>();
TPreEmpBadRecord tPreEmpBadRecord;
TPreEmpContactInfo tPreEmpContactInfo;
TPreEmpDisabilityInfo tPreEmpDisabilityInfo;
TPreEmpEducation tPreEmpEducation;
TPreEmpFamily tPreEmpFamily;
TPreEmpWorkRecording tPreEmpWorkRecording;
String mainId;
String empIdCard;
// 组装附属信息
for (PreUploadEmpImportVo info : saveList) {
main = saveMainMap.get(info.getEmpIdcard());
empId = null;
if (main != null) {
employee = null;
mainId = main.getId();
empIdCard = main.getEmpIdcard();
// 1、2、预入职档案表、项目档案表
if (Common.isNotNull(info.getIsMain()) && Boolean.TRUE.equals(info.getIsMain())) {
tPreEmployeeInfo = new TPreEmployeeInfo();
tPreEmployeeProject = new TPreEmployeeProject();
employee = oldEmpMap.get(info.getEmpIdcard());
project = proMap.get(info.getEmpIdcard());
tPreEmployeeInfo.setEmpName(main.getEmpName());
tPreEmployeeInfo.setEmpIdcard(main.getEmpIdcard());
if (employee != null) {
empId = employee.getId();
BeanUtil.copyProperties(employee, tPreEmployeeInfo, ID);
tPreEmployeeInfo.setOldId(employee.getId());
if (project != null) {
BeanUtil.copyProperties(project, tPreEmployeeProject, ID);
tPreEmployeeProject.setOldId(project.getId());
}
} else {
tPreEmployeeProject.setEmpName(main.getEmpName());
tPreEmployeeProject.setEmpIdcard(main.getEmpIdcard());
tPreEmployeeProject.setUnitId(dept.getCustomerId());
tPreEmployeeProject.setUnitName(dept.getCustomerName());
tPreEmployeeProject.setUnitNo(dept.getCustomerNo());
tPreEmployeeProject.setBusinessPrimaryType(dept.getBusinessPrimaryType());
tPreEmployeeProject.setBusinessSecondType(dept.getBusinessSecondType());
tPreEmployeeProject.setBusinessThirdType(dept.getBusinessThirdType());
tPreEmployeeProject.setDeptId(main.getDeptId());
tPreEmployeeProject.setDeptName(main.getDeptName());
tPreEmployeeProject.setDeptNo(main.getDeptNo());
}
tPreEmployeeInfo.setPreMainId(mainId);
tPreEmployeeInfo.setCreateBy(user.getId());
tPreEmployeeInfo.setCreateName(user.getNickname());
tPreEmployeeInfo.setCreateTime(LocalDateTime.now());
tPreEmployeeInfo.setEmpNatrue(info.getEmpNatrueValue());
tPreEmployeeInfo.setEmpSex(IdCardUtil.getSex(empIdCard));
tPreEmployeeInfo.setEmpBirthday(IdCardUtil.getBirthdate(empIdCard));
tPreEmployeeInfo.setEmpAge(IdCardUtil.IdNOToAge(empIdCard));
tPreEmployeeInfo.setEmpMarriStatus(info.getEmpMarriStatusValue());
tPreEmployeeInfo.setEmpNational(info.getEmpNationalValue());
tPreEmployeeInfo.setPoliticalStatus(info.getPoliticalStatusValue());
tPreEmployeeInfo.setEmpEmail(info.getEmpEmail());
tPreEmployeeInfo.setEmpPhone(info.getEmpPhone());
if (Common.isNotNull(info.getIdProvinceValue())) {
tPreEmployeeInfo.setIdProvince(Integer.parseInt(info.getIdProvinceValue()));
}
if (Common.isNotNull(info.getIdCityValue())) {
tPreEmployeeInfo.setIdCity(Integer.parseInt(info.getIdCityValue()));
}
if (Common.isNotNull(info.getIdTownValue())) {
tPreEmployeeInfo.setIdTown(Integer.parseInt(info.getIdTownValue()));
}
tPreEmployeeInfo.setEmpRegisType(info.getEmpRegisTypeValue());
if (Common.isNotNull(info.getFileProvinceValue())) {
tPreEmployeeInfo.setFileProvince(Integer.parseInt(info.getFileProvinceValue()));
}
if (Common.isNotNull(info.getFileCityValue())) {
tPreEmployeeInfo.setFileCity(Integer.parseInt(info.getFileCityValue()));
}
if (Common.isNotNull(info.getFileTownValue())) {
tPreEmployeeInfo.setFileTown(Integer.parseInt(info.getFileTownValue()));
}
if (Common.isNotNull(info.getEducationNameValue())) {
tPreEmployeeInfo.setHignEducation(info.getEducationNameValue());
if ("5".equals(info.getEducationNameValue())
|| "6".equals(info.getEducationNameValue())
|| "7".equals(info.getEducationNameValue())
|| "8".equals(info.getEducationNameValue())) {
tPreEmployeeInfo.setIsCollege(CommonConstants.ONE_INT);
} else {
tPreEmployeeInfo.setIsCollege(CommonConstants.ZERO_INT);
}
}
tPreEmployeeInfo.setSchool(info.getSchool());
tPreEmployeeInfo.setMajor(info.getMajor());
tPreEmployeeInfo.setAdmissionDate(info.getEntryDateValue());
tPreEmployeeInfo.setGradutionDate(info.getGradutionDateValue());
tPreEmployeeInfo.setContactAddress(info.getContactAddress());
tPreEmployeeInfo.setBankName(info.getBankName());
tPreEmployeeInfo.setBankProvince(info.getBankProvinceValue());
tPreEmployeeInfo.setBankCity(info.getBankCityValue());
tPreEmployeeInfo.setBankSubName(info.getBankSubName());
tPreEmployeeInfo.setBankNo(info.getBankNo());
tPreEmployeeInfo.setTaxMonth(info.getTaxMonthValue());
tPreEmployeeInfo.setTaxMonthFlag(CommonConstants.ONE_STRING);
tPreEmployeeInfo.setContactProvince(info.getContactProvinceValue());
tPreEmployeeInfo.setContactCity(info.getContactCityValue());
tPreEmployeeInfo.setContactTown(info.getContactTownValue());
tPreEmployeeInfo.setFirstWorkFlag(info.getFirstWorkFlag());
tPreEmployeeInfo.setHaveQualification(info.getHaveQualification());
tPreEmployeeInfo.setFileSource(CommonConstants.SEVEN_STRING);
preEmployeeInfoList.add(tPreEmployeeInfo);
tPreEmployeeProject.setPreMainId(mainId);
tPreEmployeeProject.setCreateBy(user.getId());
tPreEmployeeProject.setCreateName(user.getNickname());
tPreEmployeeProject.setCreateTime(LocalDateTime.now());
tPreEmployeeProject.setProjectSource(CommonConstants.EIGHT_STRING);
preEmployeeProjectList.add(tPreEmployeeProject);
// 其他附属信息
tPreEmpBadRecord = new TPreEmpBadRecord();
tPreEmpBadRecord.setPreMainId(mainId);
tPreEmpBadRecord.setSettleDomain(deptId);
tPreEmpBadRecord.setProject(dept.getDepartName());
tPreEmpBadRecord.setProjectCode(dept.getDepartNo());
tPreEmpBadRecord.setEmpIdcard(empIdCard);
tPreEmpBadRecord.setCreateBy(user.getId());
tPreEmpBadRecord.setCreateName(user.getNickname());
tPreEmpBadRecord.setCreateTime(LocalDateTime.now());
if ("是".equals(info.getRemark())) {
tPreEmpBadRecord.setRemark("未曾经或正在追究与承担过刑事责任");
} else {
tPreEmpBadRecord.setRemark("曾经或正在追究与承担过刑事责任");
}
preEmpBadRecordList.add(tPreEmpBadRecord);
// 紧急联系人
tPreEmpContactInfo = new TPreEmpContactInfo();
tPreEmpContactInfo.setEmpId(empId);
tPreEmpContactInfo.setPreMainId(mainId);
tPreEmpContactInfo.setCreateBy(user.getId());
tPreEmpContactInfo.setCreateName(user.getNickname());
tPreEmpContactInfo.setCreateTime(LocalDateTime.now());
// 紧急联系人姓名 与本人关系 联系地址-省 联系地址-市 联系地址-区/县 联系地址-详细地址 手机号码(紧急联系人)
tPreEmpContactInfo.setEmpName(info.getContactEmpName());
tPreEmpContactInfo.setRelationType(info.getRelationType());
tPreEmpContactInfo.setRelationProvince(info.getRelationProvinceValue());
tPreEmpContactInfo.setRelationCity(info.getRelationCityValue());
tPreEmpContactInfo.setRelationTown(info.getRelationTownValue());
tPreEmpContactInfo.setAddress(info.getAddress());
tPreEmpContactInfo.setTel(info.getTel());
preEmpContactInfoList.add(tPreEmpContactInfo);
// 伤残
tPreEmpDisabilityInfo = new TPreEmpDisabilityInfo();
tPreEmpDisabilityInfo.setPreMainId(mainId);
tPreEmpDisabilityInfo.setSettleDomain(deptId);
tPreEmpDisabilityInfo.setEmpId(empId);
if (employee != null) {
tPreEmpDisabilityInfo.setEmpName(employee.getEmpName());
tPreEmpDisabilityInfo.setEmpCode(employee.getEmpCode());
}
tPreEmpDisabilityInfo.setEmpIdcard(empIdCard);
tPreEmpDisabilityInfo.setCreateBy(user.getId());
tPreEmpDisabilityInfo.setCreateName(user.getNickname());
tPreEmpDisabilityInfo.setCreateTime(LocalDateTime.now());
// 是否曾被认定为工伤 是否有职业病 职业病名称 是否有传染性疾病 传染病名称 是否被劳动能力鉴定委员会鉴定为具有伤残等级 伤残病名称 伤残等级 是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种
tPreEmpDisabilityInfo.setInjuryIdentification(info.getInjuryIdentificationValue());
tPreEmpDisabilityInfo.setOccupationalDiseaseFlag(info.getOccupationalDiseaseFlagValue());
tPreEmpDisabilityInfo.setOccupationalDisease(info.getOccupationalDisease());
tPreEmpDisabilityInfo.setInfectiousDiseaseFlag(info.getInfectiousDiseaseFlagValue());
tPreEmpDisabilityInfo.setInfectiousName(info.getInfectiousName());
tPreEmpDisabilityInfo.setDisabilityFlag(info.getDisabilityFlagValue());
tPreEmpDisabilityInfo.setDisabilityName(info.getDisabilityName());
tPreEmpDisabilityInfo.setDisabilityLevel(info.getDisabilityLevelValue());
tPreEmpDisabilityInfo.setOtherFlag(info.getOtherFlagValue());
tPreEmpDisabilityInfo.setRemark(info.getRemark());
preEmpDisabilityInfoList.add(tPreEmpDisabilityInfo);
// 最高教育经历
tPreEmpEducation = new TPreEmpEducation();
tPreEmpEducation.setPreMainId(mainId);
tPreEmpEducation.setSettleDomain(deptId);
tPreEmpEducation.setEmpId(empId);
if (employee != null) {
tPreEmpEducation.setEmpName(employee.getEmpName());
tPreEmpEducation.setEmpCode(employee.getEmpCode());
}
tPreEmpEducation.setEmpIdcard(empIdCard);
tPreEmpEducation.setCreateBy(user.getId());
tPreEmpEducation.setCreateName(user.getNickname());
tPreEmpEducation.setCreateTime(LocalDateTime.now());
// 学历 学校 专业 教育开始时间 教育结束时间
tPreEmpEducation.setEducationName(info.getEducationNameValue());
tPreEmpEducation.setSchool(info.getSchool());
tPreEmpEducation.setMajor(info.getMajor());
tPreEmpEducation.setEntryDate(info.getEntryDateValue());
tPreEmpEducation.setGradutionDate(info.getGradutionDateValue());
preEmpEducationList.add(tPreEmpEducation);
}
// 主要家庭成员信息
if (Common.isNotNull(info.getFamilyName())) {
tPreEmpFamily = new TPreEmpFamily();
tPreEmpFamily.setSettleDomain(deptId);
tPreEmpFamily.setEmpId(empId);
if (employee != null) {
tPreEmpFamily.setEmpName(employee.getEmpName());
tPreEmpFamily.setEmpCode(employee.getEmpCode());
}
tPreEmpFamily.setEmpIdcard(empIdCard);
tPreEmpFamily.setPreMainId(mainId);
tPreEmpFamily.setCreateBy(user.getId());
tPreEmpFamily.setCreateName(user.getNickname());
tPreEmpFamily.setCreateTime(LocalDateTime.now());
tPreEmpFamily.setFamilyName(info.getFamilyName());
tPreEmpFamily.setRelationshipSelf(info.getRelationshipSelf());
tPreEmpFamily.setContractTel(info.getContractTel());
preEmpFamilyList.add(tPreEmpFamily);
}
// 主要工作经历
if (Common.isNotNull(info.getFirstWorkFlag())
&& CommonConstants.IS_FALSE.equals(main.getFirstWorkFlag())
&& CommonConstants.IS_FALSE.equals(info.getFirstWorkFlag())) {
tPreEmpWorkRecording = new TPreEmpWorkRecording();
tPreEmpWorkRecording.setSettleDomain(deptId);
tPreEmpWorkRecording.setEmpId(empId);
if (employee != null) {
tPreEmpWorkRecording.setEmpName(employee.getEmpName());
tPreEmpWorkRecording.setEmpCode(employee.getEmpCode());
}
tPreEmpWorkRecording.setEmpIdcard(empIdCard);
tPreEmpWorkRecording.setPreMainId(mainId);
tPreEmpWorkRecording.setCreateBy(user.getId());
tPreEmpWorkRecording.setCreateName(user.getNickname());
tPreEmpWorkRecording.setCreateTime(LocalDateTime.now());
tPreEmpWorkRecording.setWorkUnit(info.getWorkUnit());
tPreEmpWorkRecording.setWorkJob(info.getWorkJob());
tPreEmpWorkRecording.setStartDate(info.getStartDateValue());
tPreEmpWorkRecording.setEndDate(info.getEndDateValue());
preEmpWorkRecordingList.add(tPreEmpWorkRecording);
}
// 职业资格信息——职业资格证书
if (Common.isNotNull(info.getHaveQualification())
&& CommonConstants.IS_TRUE.equals(main.getHaveQualification())
&& CommonConstants.IS_TRUE.equals(info.getHaveQualification())) {
tPreEmpWorkRecording = new TPreEmpWorkRecording();
tPreEmpWorkRecording.setSettleDomain(deptId);
tPreEmpWorkRecording.setEmpId(empId);
if (employee != null) {
tPreEmpWorkRecording.setEmpName(employee.getEmpName());
tPreEmpWorkRecording.setEmpCode(employee.getEmpCode());
}
tPreEmpWorkRecording.setEmpIdcard(empIdCard);
tPreEmpWorkRecording.setPreMainId(mainId);
tPreEmpWorkRecording.setCreateBy(user.getId());
tPreEmpWorkRecording.setCreateName(user.getNickname());
tPreEmpWorkRecording.setCreateTime(LocalDateTime.now());
tPreEmpWorkRecording.setWorkUnit(info.getWorkUnit());
tPreEmpWorkRecording.setWorkJob(info.getWorkJob());
tPreEmpWorkRecording.setStartDate(info.getStartDateValue());
tPreEmpWorkRecording.setEndDate(info.getEndDateValue());
preEmpWorkRecordingList.add(tPreEmpWorkRecording);
}
}
}
if (!preEmployeeInfoList.isEmpty()) {
tPreEmployeeInfoService.saveBatch(preEmployeeInfoList);
}
if (!preEmployeeProjectList.isEmpty()) {
tPreEmployeeProjectService.saveBatch(preEmployeeProjectList);
}
if (!preEmpBadRecordList.isEmpty()) {
tPreEmpBadRecordService.saveBatch(preEmpBadRecordList);
}
if (!preEmpContactInfoList.isEmpty()) {
tPreEmpContactInfoService.saveBatch(preEmpContactInfoList);
}
if (!preEmpDisabilityInfoList.isEmpty()) {
tPreEmpDisabilityInfoService.saveBatch(preEmpDisabilityInfoList);
}
if (!preEmpEducationList.isEmpty()) {
tPreEmpEducationService.saveBatch(preEmpEducationList);
}
if (!preEmpFamilyList.isEmpty()) {
tPreEmpFamilyService.saveBatch(preEmpFamilyList);
}
if (!preEmpWorkRecordingList.isEmpty()) {
tPreEmpWorkRecordingService.saveBatch(preEmpWorkRecordingList);
}
}
if (!errorList.isEmpty()) {
return new R<>(CommonConstants.TWO_INT, "失败数据:", excelList);
} else {
//数据保存
return R.ok(excelList);
}
} else {
return R.failed("未识别导表格内容行!请检查表格!");
}
}
/**
* @param deptId
* @Description: 查找项目下的预入职信息
* @Author: hgw
* @Date: 2024/10/14 16:31
* @return: java.util.Map<java.lang.String, com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpMain>
**/
private Map<String, TPreEmpMain> getMapByDeptId(String deptId) {
Map<String, TPreEmpMain> preMap = new HashMap<>();
if (Common.isNotNull(deptId)) {
List<TPreEmpMain> preList = this.list(Wrappers.<TPreEmpMain>query().lambda()
.eq(TPreEmpMain::getDeptId, deptId)
.ne(TPreEmpMain::getStatus, CommonConstants.FIVE_STRING));
if (preList != null && !preList.isEmpty()) {
for (TPreEmpMain pre : preList) {
preMap.put(pre.getEmpIdcard(), pre);
}
}
}
return preMap;
}
private boolean getMatchRes(String c, ExcelAttribute attr, String pattern) {
return !c.matches(Common.isEmpty(attr.pattern()) ? pattern : attr.pattern());
}
/**
* @Description: 判断字段格式
* @Author: hgw
* @Date: 2024/10/14 11:38
* @return: java.lang.String
**/
private String validateUtil(String c, ExcelAttribute attr, StringBuilder errorFormat, Map<String, String> dictMap
, Map<String, String> parentAreaMap, String shuName, boolean onlyList, Map<String, Date> startDateMap) {
String tempStr = null;
Date dateValue = null;
//非空校验
if (Common.isNotNull(c)) {
// 仅校验附属信息
if (onlyList) {
if (attr.isMark()) {
if (attr.isDate()) {
String format = "yyyyMMdd";
if (Common.isNotNull(attr.dateFormat())) {
format = attr.dateFormat();
}
dateValue = DateUtil.stringDateFormat(c.trim(), format);
if (null == dateValue) {
errorFormat.append(attr.name()).append(";");
} else {
startDateMap.put(shuName, dateValue);
}
}
//手机号码校验
if (attr.isPhone() && getMatchRes(c.trim(), attr, ValidityConstants.MOBILE_PATTERN)) {
errorFormat.append(attr.name()).append(";");
}
//最大长度校验
if (attr.maxLength() > 0 && c.length() > attr.maxLength()) {
errorFormat.append(attr.name()).append("_超出最大长度;");
}
}
} else {
//日期格式校验
if (attr.isDate()) {
if (!("validityEnd".equals(shuName) && "长期".equals(c))) {
String format = "yyyyMMdd";
if (Common.isNotNull(attr.dateFormat())) {
format = attr.dateFormat();
}
dateValue = DateUtil.stringDateFormat(c.trim(), format);
if (null == dateValue) {
errorFormat.append(attr.name()).append(";");
} else {
startDateMap.put(shuName, dateValue);
}
}
}
//手机号码校验
if (attr.isPhone() && getMatchRes(c.trim(), attr, ValidityConstants.MOBILE_PATTERN)) {
errorFormat.append(attr.name()).append(";");
}
//身份证校验
if (attr.isIdCard() && getMatchRes(c.trim(), attr, ValidityConstants.IDCARD_PATTERN)) {
errorFormat.append(attr.name()).append(";");
}
//最大长度校验
if (attr.maxLength() > 0 && c.length() > attr.maxLength()) {
errorFormat.append(attr.name()).append("_超出最大长度;");
}
// 区域
if (attr.isArea()) {
//区域字段处理
if (Common.isEmpty(attr.parentField())) {
tempStr = dictMap.get(c + "_0");
if (Common.isEmpty(tempStr)) {
tempStr = String.valueOf(RedisUtil.redis.opsForValue().get(CacheConstants.AREA_VALUE + c));
if (Common.isEmpty(tempStr)) {
errorFormat.append(attr.name()).append(";");
} else {
parentAreaMap.put(shuName, c);
dictMap.put(c + "_0", tempStr);
}
} else {
parentAreaMap.put(shuName, c);
}
} else {
tempStr = dictMap.get(c.trim() + "_" + parentAreaMap.get(attr.parentField()));
if (Common.isEmpty(tempStr)) {
tempStr = String.valueOf(RedisUtil.redis.opsForValue().get(CacheConstants.AREA_VALUE + c + "_" + parentAreaMap.get(attr.parentField())));
if (Common.isEmpty(tempStr)) {
errorFormat.append(attr.name()).append(";");
} else {
parentAreaMap.put(shuName, c);
dictMap.put(c.trim() + "_" + parentAreaMap.get(attr.parentField()), tempStr);
}
} else {
parentAreaMap.put(shuName, c);
}
}
}
// 字典
tempStr = null;
if (attr.isDataId() && null != dictMap) {
if (Common.isNotNull(attr.readConverterExp())) {
String[] convertSource = attr.readConverterExp().split(",");
String[] itemArray;
for (String item : convertSource) {
itemArray = item.split("=");
if (itemArray.length>1 && itemArray[1].equals(c)) {
tempStr = itemArray[0];
break;
}
}
} else {
tempStr = getLableIdByValue(attr, dictMap, c);
}
if (Common.isEmpty(tempStr)) {
errorFormat.append(attr.name()).append("_未找到字典值;");
}
}
}
// 时间大小比较
if (Common.isNotNull(attr.pattern())) {
if (!("validityEnd".equals(shuName) && "长期".equals(c)) && dateValue != null) {
Date startDate = startDateMap.get(attr.pattern());
if (startDate != null && !dateValue.after(startDate)) {
errorFormat.append(attr.name()).append("_小于起始日期;");
}
}
}
}
return tempStr;
}
private String getLableIdByValue(ExcelAttribute attr, Map<String, String> dictMap, String value) {
String tempValue = null;
if (null != dictMap && dictMap.size() > 0 && Common.isNotNull(value)) {
if (Common.isNotNull(attr.dataType())) {
tempValue = dictMap.get(attr.dataType() + CommonConstants.DOWN_LINE_STRING + value);
if (Common.isEmpty(tempValue)){
tempValue = dictMap.get(attr.dataType() + CommonConstants.DOWN_LINE_STRING +"id"+CommonConstants.DOWN_LINE_STRING + value);
}
} else {
tempValue = dictMap.get(value);
}
}
// 默认字典获取不到 去 缓存获取
if (Common.isEmpty(tempValue) && Common.isNotNull(attr.dataType())) {
Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue()
.get(CacheConstants.DICT_DETAILS
+ CommonConstants.COLON_STRING
+ attr.dataType());
if (dicObj != null) {
for (Map.Entry<String, String> entry : dicObj.entrySet()) {
if (Common.isNotNull(entry.getValue()) && entry.getValue().equals(value.trim())) {
tempValue = entry.getKey();
dictMap.put(attr.dataType() + CommonConstants.DOWN_LINE_STRING + value, tempValue);
break;
}
}
}
}
return tempValue;
}
private void judgeBank(PreUploadEmpImportVo detail, StringBuilder errorMust) {
if (Common.isNotNull(detail.getBankNo()) && (Common.isEmpty(detail.getBankName())
|| Common.isEmpty(detail.getBankProvince())
|| Common.isEmpty(detail.getBankCity())
|| Common.isEmpty(detail.getTaxMonth()) )) {
errorMust.append("银行卡号不为空则必填:");
if (Common.isEmpty(detail.getBankName())) {
errorMust.append("开户行总行;");
}
if (Common.isEmpty(detail.getBankProvince())) {
errorMust.append("开户省;");
}
if (Common.isEmpty(detail.getBankCity())) {
errorMust.append("开户市;");
}
if (Common.isEmpty(detail.getTaxMonth())) {
errorMust.append("计税月份;");
}
}
}
private void judgeDisability(PreUploadEmpImportVo detail, StringBuilder errorMust) {
if (Common.isNotNull(detail.getOccupationalDiseaseFlag())
&& detail.getOccupationalDiseaseFlag().contains("是")
&& Common.isEmpty(detail.getOccupationalDisease())) {
errorMust.append("是否有职业病为是则必填:职业病名称;");
}
if (Common.isNotNull(detail.getInfectiousDiseaseFlag())
&& detail.getInfectiousDiseaseFlag().contains("是")
&& Common.isEmpty(detail.getInfectiousName())) {
errorMust.append("是否有传染性疾病为是则必填:传染病名称;");
}
if (Common.isNotNull(detail.getDisabilityFlag())
&& detail.getDisabilityFlag().contains("是")
&& (Common.isEmpty(detail.getDisabilityName())
|| Common.isEmpty(detail.getDisabilityLevel()))) {
errorMust.append("是否被劳动能力鉴定委员会鉴定为具有伤残等级为是则必填:");
if (Common.isEmpty(detail.getDisabilityName())) {
errorMust.append("伤残病名称;");
}
if (Common.isEmpty(detail.getDisabilityLevel())) {
errorMust.append("伤残等级;");
}
}
}
private void judgeQualification(PreUploadEmpImportVo detail, StringBuilder errorMust) {
if (Common.isNotNull(detail.getHaveQualification())
&& detail.getHaveQualification().contains("是") && (Common.isEmpty(detail.getDeclareYear())
|| Common.isEmpty(detail.getQualificationType()))) {
errorMust.append("是否有职业资格证书为是则必填:");
if (Common.isEmpty(detail.getDeclareYear())) {
errorMust.append("申报年度;");
}
if (Common.isEmpty(detail.getQualificationType())) {
errorMust.append("职业资格名称;");
}
}
}
private void judgeFamily(PreUploadEmpImportVo detail, StringBuilder errorMust) {
if (Common.isNotNull(detail.getFamilyName()) && (Common.isEmpty(detail.getRelationshipSelf())
|| Common.isEmpty(detail.getContractTel()))) {
errorMust.append("成员姓名填写则必填:");
if (Common.isEmpty(detail.getRelationshipSelf())) {
errorMust.append("与本人关系;");
}
if (Common.isEmpty(detail.getContractTel())) {
errorMust.append("手机号码(家庭成员);");
}
}
}
private void judgeWorkFlag(PreUploadEmpImportVo detail, StringBuilder errorMust) {
if (Common.isNotNull(detail.getFirstWorkFlag())
&& detail.getFirstWorkFlag().contains("否") && (Common.isEmpty(detail.getWorkUnit())
|| Common.isEmpty(detail.getWorkJob())
|| Common.isEmpty(detail.getStartDate())
|| Common.isEmpty(detail.getEndDate()))) {
errorMust.append("是否为首份工作为否则必填:");
if (Common.isEmpty(detail.getWorkUnit())) {
errorMust.append("工作单位;");
}
if (Common.isEmpty(detail.getWorkJob())) {
errorMust.append("工作岗位;");
}
if (Common.isEmpty(detail.getStartDate())) {
errorMust.append("开始工作日期;");
}
if (Common.isEmpty(detail.getEndDate())) {
errorMust.append("结束工作日期;");
}
}
}
private void judgeEducation(PreUploadEmpImportVo detail, StringBuilder errorMust) {
boolean isCollege = Common.isNotNull(detail.getEducationName())
&& (detail.getEducationName().contains("大专")
|| detail.getEducationName().contains("本科")
|| detail.getEducationName().contains("硕士")
|| detail.getEducationName().contains("博士"));
if (isCollege && (Common.isEmpty(detail.getSchool())
|| Common.isEmpty(detail.getMajor())
|| Common.isEmpty(detail.getEntryDate())
|| Common.isEmpty(detail.getGradutionDate()))) {
errorMust.append("大专及以上则必填:");
if (Common.isEmpty(detail.getSchool())) {
errorMust.append("学校;");
}
if (Common.isEmpty(detail.getMajor())) {
errorMust.append("专业;");
}
if (Common.isEmpty(detail.getEntryDate())) {
errorMust.append("教育开始时间;");
}
if (Common.isEmpty(detail.getGradutionDate())) {
errorMust.append("教育结束时间;");
}
}
}
public <T> void setFields(Field field, String cellValueStr, ExcelAttribute attr
, Class<?> fieldType, T entity) throws IllegalAccessException {
if (String.class == fieldType) {
setStringField(field, cellValueStr, entity);
} else if (Date.class == fieldType && Common.isNotNull(cellValueStr.trim())) {
setDateField(field, cellValueStr, attr, entity);
} else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) {
setIntegerField(field, cellValueStr, entity);
} else {
field.set(entity, cellValueStr);
}
}
/**
* @Description: 判断固定字符串,塞值
* @Author: hgw
* @Date: 2021/1/11 11:47
* @return: void
**/
private static <T> void setStringField(Field field, String cellValueStr, T entity) throws IllegalAccessException {
if ("是".equals(cellValueStr)) {
field.set(entity, "0");
} else if ("否".equals(cellValueStr)) {
field.set(entity, "1");
} else {
field.set(entity, cellValueStr);
}
}
private static <T> void setDateField(Field field, String cellValueStr, ExcelAttribute attr, T entity) throws IllegalAccessException {
String patten = DateUtil.ISO_DATE_FORMAT;
if (cellValueStr.contains("-")) {
patten = DateUtil.ISO_EXPANDED_DATE_FORMAT;
} else if (cellValueStr.contains("/")) {
patten = DateUtil.DATETIME_PATTERN_XIEGANG;
}
field.set(entity, DateUtil.stringDateFormat(cellValueStr.trim(), patten));
}
private static <T> void setIntegerField(Field field, String cellValueStr, T entity) throws IllegalAccessException {
if ("否".equals(cellValueStr)) {
field.set(entity, 0);
} else if ("是".equals(cellValueStr)) {
field.set(entity, 1);
} else {
field.set(entity, Integer.parseInt(cellValueStr));
}
}
private R<ExcelSheetVo> readXlsx(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag
, String sheetName, int maxRow) throws IOException {
ExcelSheetVo sheetVo = new ExcelSheetVo();
Workbook sheets = null;
try {
List<ExcelColumnVo> titleList;
List<ExcelColumnVo> columnList;
ExcelColumnVo columnVo;
// 内容list
List<Map<String, String>> contentList;
// 每一行的内容map
Map<String, String> contentMap;
// 存储每一列有值的表头
Map<String, String> titleMap = new HashMap<>();
sheets = StreamingReader.builder()
.rowCacheSize(1000) // 缓存到内存中的行数(默认是10)
.bufferSize(10240) // 读取资源时,缓存到内存的字节大小(默认是1024)
.open(inputStream);
// 获取sheet数量
int sheetNum = sheets.getNumberOfSheets();
// 每个单元格内容
String cellValue;
// 内容行
int dataRow;
// 身份证所在列
int idCardColumn = -1;
// 空白列起始号
int nullColumn = -1;
// 上一个空白行
int preNullColumn = -1;
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int nullColumnNum = 0;
// 极限空白列,超过阈值,将不继续循环列
int maxNullColumNum = 60;
int rowLastCellNum = -1;
String idCardValue = null;
// 数据行是否被确认,true否
boolean dataRowFlag;
// 超过极限空白列maxNullColumNum,只循环表头 true:未超越
boolean nullFlag = true;
// 极限空白表头列,超过阈值,将不继续循环列
int maxTitleNullColumNum = 1;
// 极限空白身份证,超过将不循环行
int maxIdCardNullRow = 1;
int idCardNullNum = 0;
Cell cell;
// 循环每个sheet
Sheet sheetAt;
for (int i = 0; i < sheetNum; i++) {
sheetAt = sheets.getSheetAt(i);
if ((Common.isEmpty(sheetName) && i == 0) || (Common.isNotNull(sheetAt.getSheetName()) && Common.isNotNull(sheetName)
&& sheetName.equals(sheetAt.getSheetName()))) {
if (sheetAt.getLastRowNum() > maxRow) {
return R.failed("未避免等待较长时间,请单表不要上传超过" + maxRow + "行的数据!");
}
contentList = new ArrayList<>();
// 塞sheet名称
sheetVo.setSheetName(sheetAt.getSheetName());
titleList = new ArrayList<>();
// 初始化每个sheet的数据行
dataRow = 0;
dataRowFlag = true;
// 循环当前sheet的每行内容
idCardNullNum = 0;
int rowNum = 0;
for (Row row : sheetAt) {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
nullFlag = true;
idCardValue = null;
contentMap = new HashMap<>();
columnList = new ArrayList<>();
if (row != null) {
rowLastCellNum = row.getLastCellNum();
for (int cellNum = 0; cellNum < rowLastCellNum; cellNum++) {
columnVo = new ExcelColumnVo();
try {
cell = row.getCell(cellNum);
if (cell == null) {
cellValue = "";
} else {
if (cell.getCellType() == CellType.FORMULA) {
cellValue = String.valueOf(cell.getStringCellValue());
} else if (CellType.STRING == cell.getCellType()) {
cellValue = row.getCell(cellNum).getStringCellValue();
} else if (CellType.NUMERIC == cell.getCellType()) {
try {
cellValue = String.valueOf(row.getCell(cellNum).getNumericCellValue());
if (cellValue.contains("E")) {
cellValue = String.valueOf(new DecimalFormat("#").format(row.getCell(cellNum).getNumericCellValue()));
}
} catch (NumberFormatException e) {
cell.setCellType(CellType.STRING);
cellValue = String.valueOf(row.getCell(cellNum).getStringCellValue());
}
} else if (HSSFDateUtil.isCellDateFormatted(cell)) {
cellValue = String.valueOf(row.getCell(cellNum).getDateCellValue());
} else if (CellType.BOOLEAN == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue());
} else {
cellValue = row.getCell(cellNum).getStringCellValue();
}
}
} catch (Exception e) {
cellValue = "";
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
}
columnVo.setLineNum(cellNum);
if (Common.isNotNull(cellValue)) {
cellValue = cellValue.trim().replaceAll("\\s+", "");
titleMap.put(String.valueOf(cellNum), cellValue);
}
columnVo.setContent(cellValue);
if (dataRowFlag) {
if (idCardColumn != -1) {
if (idCardColumn == cellNum && Common.isNotNull(cellValue) &&
(((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum;
dataRowFlag = false;
}
} else {
if (Common.isNotNull(cellValue) &&
(((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum;
idCardColumn = cellNum;
dataRowFlag = false;
}
}
}
if (nullFlag) {
contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) {
if (Common.isEmpty(cellValue)) {
if (titleMap.get(String.valueOf(cellNum)) != null) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum)));
} else {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
columnVo.setContent("空白列" + cellNum);
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
columnList.add(columnVo);
}
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
}
if (nullColumnNum >= maxNullColumNum) {
for (int num = maxNullColumNum - 1; num >= 0; num--) {
if (dataRowFlag) {
columnList.remove(nullColumn + num);
}
contentMap.remove(String.valueOf(nullColumn + num));
}
nullFlag = false;
}
if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue;
}
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
// 表头Map超过50,跳出当前行的列循环
if (nullColumnNum >= maxTitleNullColumNum) {
break;
}
}
}
if (!dataRowFlag) {
if (idCardColumn != -1) {
if (Common.isEmpty(idCardValue)) {
idCardNullNum++;
}
if (Common.isNotNull(idCardValue) && (
regIdCard(idCardValue)
// 特殊身份证允许识别
|| regSpecialIdCard(idCardValue, specialIdCardList)
|| regIdCardError(idCardValue))) {
contentList.add(contentMap);
}
}
} else {
titleList = new ArrayList<>(columnList);
}
}
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
rowNum++;
if (titleFlag && !dataRowFlag) {
break;
}
if (idCardNullNum >= maxIdCardNullRow) {
break;
}
}
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList);
return R.ok(sheetVo);
}
}
} catch (Exception e) {
e.printStackTrace();
if (sheets != null) {
sheets.close();
}
} finally {
if (sheets != null) {
sheets.close();
}
}
return R.ok(sheetVo);
}
/**
* @param content
* @Description: 判断身份证格式:18位数字,17位数字+X,15位数字,14位数字+X
* 格式正确返回true
* @Author: hgw
* @Date: 2022/5/13 11:53
* @return: boolean
**/
private static boolean regIdCard(String content) {
boolean flag = false;
Pattern p = Pattern.compile("\\d{18}|\\d{17}X|\\d{15}|\\d{14}X");
Matcher m = p.matcher(content);
if (m.matches()) {
flag = true;
}
return flag;
}
/**
* @param content
* @Description: 判断特殊身份证
* 格式正确返回true
* @Author: hgw
* @Date: 2024-4-8 15:33:04
* @return: boolean
**/
private static boolean regSpecialIdCard(String content, List<String> specialIdCardList) {
if (specialIdCardList != null && !specialIdCardList.isEmpty()) {
for (int i = 0; i < specialIdCardList.size(); i++) {
if (specialIdCardList.get(i).equals(content)) {
return true;
}
}
}
return false;
}
/**
* @param content
* @Description: 判断类似身份证的数据,进识别行,提示客服该行错误:14位数字
* 格式正确返回true
* @Author: hgw
* @Date: 2022/5/13 11:53
* @return: boolean
**/
private static boolean regIdCardError(String content) {
return content.matches("^.*\\d{14}.*$");
}
}
......@@ -764,6 +764,17 @@
</foreach>
</select>
<select id="getListByIdCardList" resultMap="tEmployeeInfoMap">
select
<include refid="baseParam"/>
from t_employee_info a
where
a.DELETE_FLAG = '0' and a.EMP_IDCARD in
<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!-- hgw 根据手机号查询 -->
<select id="getListByPhone" resultMap="tEmployeeInfoMap">
select
......
......@@ -52,6 +52,7 @@
<result property="updateTime" column="UPDATE_TIME"/>
<result property="settleDomain" column="SETTLE_DOMAIN"/>
<result property="declarationId" column="DECLARATION_ID"/>
<result property="sourType" column="SOUR_TYPE"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
......@@ -81,7 +82,8 @@
a.CREATE_TIME,
a.UPDATE_TIME,
a.SETTLE_DOMAIN,
a.DECLARATION_ID
a.DECLARATION_ID,
a.SOUR_TYPE
</sql>
<sql id="tPreEmpMain_where">
<if test="tPreEmpMain != null">
......@@ -514,6 +516,17 @@
limit 1
</select>
<!-- 导入预入职时,查询所有身份证的预入职使用的,查出来删除附属信息 -->
<select id="getTPreEmpMainListByCardAndDept" resultType="java.lang.String">
SELECT
a.ID
FROM t_pre_emp_main a
where a.DEPT_ID = #{deptId} AND a.EMP_IDCARD in
<foreach collection="empIdCardList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</select>
<!--tPreEmpMain简单分页查询-->
<select id="getTPreEmpMainByCardAndDeptNo" resultMap="tPreEmpMainMap">
SELECT
......@@ -545,4 +558,79 @@
delete from t_pre_employee_project where PRE_MAIN_ID = #{preMainId}
</delete>
<delete id="deleteBadByMainIdList">
delete from t_pre_emp_bad_record where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteContactByMainIdList">
delete from t_pre_emp_contact_info where PRE_MAIN_ID = in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteDisabilityByMainIdList">
delete from t_pre_emp_disability_info where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteEducationByMainIdList">
delete from t_pre_emp_education where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteFamilyByMainIdList">
delete from t_pre_emp_family where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteEmployeeByMainIdList">
delete from t_pre_employee_info where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteProjectByMainIdList">
delete from t_pre_employee_project where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteWorkRecordingByMainIdList">
delete from t_pre_emp_work_recording where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteProfessionalByMainIdList">
delete from t_pre_emp_professional_qualification where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteOtherFileByMainIdList">
delete from t_pre_emp_other_file where PRE_MAIN_ID in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deleteAttaByDomainIdList">
delete from t_atta_info where domain_id in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<delete id="deletePreMainIdList">
delete from t_pre_emp_main where id in
<foreach collection="preMainIdList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
</mapper>
......@@ -2,8 +2,10 @@ package com.yifu.cloud.plus.v1.check.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService;
import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import com.yifu.cloud.plus.v1.check.vo.CheckIdCardListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
......@@ -19,6 +21,7 @@ import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
/**
......@@ -176,7 +179,21 @@ public class TCheckIdCardController {
@SysLog("校验薪资姓名身份证")
@PostMapping("/checkSalaryIdCard")
public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkSalaryIdCard(checkList);
return tCheckIdCardService.checkSalaryIdCard(checkList, null);
}
/**
* @Description: 预入职导入使用的批量姓名身份证校验
* @Author: hgw
* @Date: 2024-10-15 11:54:47
* @return: com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo
**/
@Operation(description = "预入职导入使用的批量姓名身份证校验")
@SysLog("预入职导入使用的批量姓名身份证校验" )
@Inner
@PostMapping("/inner/checkIdCardBatch" )
public CheckBatchVo checkIdCardBatch(@RequestBody List<TCheckIdCard> list){
return tCheckIdCardService.checkIdCardBatch(list);
}
/**
......@@ -204,7 +221,7 @@ public class TCheckIdCardController {
@PostMapping("/inner/checkIdCardList")
public CheckIdCardListVo checkIdCardList(@RequestBody CheckIdCardListVo vo) {
CheckIdCardListVo returnVo = new CheckIdCardListVo();
R<List<TCheckIdCard>> checkR = tCheckIdCardService.checkSalaryIdCard(vo.getCheckList());
R<List<TCheckIdCard>> checkR = tCheckIdCardService.checkSalaryIdCard(vo.getCheckList(), null);
if (checkR != null) {
if (checkR.getCode() == CommonConstants.SUCCESS) {
returnVo.setCode(CommonConstants.SUCCESS);
......
......@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import java.util.List;
import java.util.Map;
......@@ -47,7 +49,17 @@ public interface TCheckIdCardService extends IService<TCheckIdCard> {
TCheckIdCard checkIdCardSingle(TCheckIdCard tCheckIdCard);
R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList);
R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList, YifuUser user);
/**
* @param list
* @Description: 预入职导入使用的批量姓名身份证校验
* @Author: hgw
* @Date: 2024/10/15 11:36
* @return: com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
**/
CheckBatchVo checkIdCardBatch(List<TCheckIdCard> list);
/**
* @Description: C端预入职校验
* @Author: hgw
......
......@@ -8,20 +8,21 @@ import com.yifu.cloud.plus.v1.check.entity.*;
import com.yifu.cloud.plus.v1.check.mapper.TCheckIdCardMapper;
import com.yifu.cloud.plus.v1.check.service.*;
import com.yifu.cloud.plus.v1.check.utils.ChecksUtil;
import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -430,13 +431,15 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
}
@Override
public R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList) {
public R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList, YifuUser user) {
TCanCheck tCanCheck= canCheckService.getById(1);
boolean canCheck = false;
if (tCanCheck != null && tCanCheck.getCanCheck() == 1) {
canCheck = true;
}
YifuUser user = SecurityUtils.getUser();
if (user == null) {
user = SecurityUtils.getUser();
}
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("请登录!");
}
......@@ -574,6 +577,45 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
return R.failed("数据为空!");
}
/**
* @Description: 预入职导入使用的批量姓名身份证校验
* @Author: hgw
* @Date: 2024/10/15 11:54
* @return: com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
**/
@Override
public CheckBatchVo checkIdCardBatch(List<TCheckIdCard> list) {
CheckBatchVo vo = new CheckBatchVo();
Map<String, Boolean> checkMap = new HashMap<>();
if (list != null && !list.isEmpty()) {
Set<String> dbAuthsSet = new HashSet<>();
Collection<? extends GrantedAuthority> authorities = AuthorityUtils
.createAuthorityList(dbAuthsSet.toArray(new String[0]));
YifuUser user = new YifuUser(list.get(0).getCreateUser(), 1L, "", list.get(0).getReason(),
list.get(0).getReason(), "0", SecurityConstants.BCRYPT + "123456",
"12345678911", true, true, true,
true,
"1", authorities, "1",
null, null,
null);
// 调用以前的批量校验
R<List<TCheckIdCard>> returnR = this.checkSalaryIdCard(list, user);
if (returnR != null) {
if (returnR.getCode() == CommonConstants.SUCCESS) {
checkMap.put("全部正确", true);
} else if (returnR.getData() != null) {
for (TCheckIdCard c : returnR.getData()) {
checkMap.put(c.getIdCard()+CommonConstants.DOWN_LINE_STRING+c.getName(), Common.isNotNull(c.getIsTrue()) && c.getIsTrue() == 1);
}
} else {
checkMap.put("全部错误", false);
}
}
}
vo.setCheckMap(checkMap);
return vo;
}
/**
* @Description: 多线程调用api,每次调用前查询一下数据库:
* @Author: hgw
......
......@@ -301,6 +301,31 @@ public class DateUtil {
}
}
/**
* @Description: 格式化字符串日期
* @Author: hgw
* @Date: 2024/10/14 21:08
* @return: java.util.Date
**/
public static Date stringDateFormat(String dateText, String format) {
if (dateText == null) {
return null;
}
try {
// 兼容多格式,格式化为没有分隔符的格式:
if (format == null || (format.length() != 4 && format.length() != 6)) {
format = ISO_DATE_FORMAT;
}
DateFormat df = new SimpleDateFormat(format);
df.setLenient(false);
return df.parse( dateText.replace("/","").replace("-","")
.replace(CommonConstants.YEAR,"").replace(CommonConstants.MONTH,"")
.replace(CommonConstants.DAY,""));
} catch (ParseException e) {
return null;
}
}
/**
* @return Timestamp
*/
......
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import lombok.Data;
import java.util.Map;
/**
* @Description: 开户行名称合理性map
* @Author: hgw
* @Date: 2024/10/15 9:28
* @return:
**/
@Data
public class TBankNameMapVo {
private Map<String, String> bankMap;
}
......@@ -24,8 +24,10 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TBankSet;
import com.yifu.cloud.plus.v1.yifu.salary.service.TBankSetService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankSetSearchVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
......@@ -80,6 +82,22 @@ public class TBankSetController {
return new R<>(tBankSetService.getTBankSetIdNameList(tBankSet));
}
/**
* @Description: 获取开户行
* @Author: hgw
* @Date: 2024/10/15 9:32
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo
**/
@Operation(description = "获取开户行")
@SysLog("获取开户行")
@Inner
@PostMapping("/inner/getBankMap")
public TBankNameMapVo getBankMap() {
TBankNameMapVo vo = new TBankNameMapVo();
vo.setBankMap(tBankSetService.getBankMap(null));
return vo;
}
/**
* 不分页查询
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment