Commit c24048da authored by hongguangwu's avatar hongguangwu

MVP1.7.0 批量更新档案

parent 3aa83e4c
...@@ -31,14 +31,14 @@ import java.io.Serializable; ...@@ -31,14 +31,14 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 预入职-员工 * 预入职-员工
* *
* @author hgw * @author hgw
* @date 2024-06-17 11:24:00 * @date 2024-06-17 11:24:00
*/ */
@Data @Data
@TableName("t_pre_emp_declaration") @TableName("t_pre_emp_declaration")
@Schema(description = "预入职-员工明") @Schema(description = "预入职-员工明")
public class TPreEmpDeclaration implements Serializable { public class TPreEmpDeclaration implements Serializable {
/** /**
......
...@@ -231,12 +231,12 @@ public class TPreEmpMain extends BaseEntity { ...@@ -231,12 +231,12 @@ public class TPreEmpMain extends BaseEntity {
@Schema(description = "结算主体ID") @Schema(description = "结算主体ID")
private String settleDomain; private String settleDomain;
/** /**
* 员工明表ID,新申明要加一条新数据,关联这个主表 * 员工明表ID,新申明要加一条新数据,关联这个主表
*/ */
@ExcelAttribute(name = "员工明表ID", maxLength = 32) @ExcelAttribute(name = "员工明表ID", maxLength = 32)
@Length(max = 32, message = "员工明表ID不能超过32个字符") @Length(max = 32, message = "员工明表ID不能超过32个字符")
@ExcelProperty("员工明表ID") @ExcelProperty("员工明表ID")
@Schema(description = "员工明表ID,新申明要加一条新数据,关联这个主表") @Schema(description = "员工明表ID,新申明要加一条新数据,关联这个主表")
private String declarationId; private String declarationId;
// 数据来源 默认0: '扫码进入', 1: 'PC批量导入' // 数据来源 默认0: '扫码进入', 1: 'PC批量导入'
......
...@@ -22,7 +22,7 @@ public class EmpMainDetailVo implements Serializable { ...@@ -22,7 +22,7 @@ public class EmpMainDetailVo implements Serializable {
private TEmpBadRecord tEmpBadRecord; private TEmpBadRecord tEmpBadRecord;
// 紧急联络人 // 紧急联络人
private TEmpContactInfo tEmpContactInfo; private TEmpContactInfo tEmpContactInfo;
// 员工 // 员工
private TPreEmpDeclaration tEmpDeclaration; private TPreEmpDeclaration tEmpDeclaration;
// 员工伤残信息表 // 员工伤残信息表
private TEmpDisabilityInfo tEmpDisabilityInfo; private TEmpDisabilityInfo tEmpDisabilityInfo;
......
...@@ -245,4 +245,35 @@ public class EmployeeInsertVO extends RowIndex implements Serializable { ...@@ -245,4 +245,35 @@ public class EmployeeInsertVO extends RowIndex implements Serializable {
@ExcelProperty(value = "通信地址-详细地址") @ExcelProperty(value = "通信地址-详细地址")
private String contactAddress; private String contactAddress;
// 紧急联系人姓名 与本人关系 联系地址-省 联系地址-市 联系地址-区/县 联系地址-详细地址 手机号码(紧急联系人)
@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;
// 银行卡号 开户总行 开户省 开户市 开户支行 计税月份
@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;
} }
...@@ -39,7 +39,7 @@ public class PreEmpMainDetailVo implements Serializable { ...@@ -39,7 +39,7 @@ public class PreEmpMainDetailVo implements Serializable {
private TPreEmpBadRecord tpreEmpBadRecord; private TPreEmpBadRecord tpreEmpBadRecord;
// 预入职-紧急联络人 // 预入职-紧急联络人
private TPreEmpContactInfo tpreEmpContactInfo; private TPreEmpContactInfo tpreEmpContactInfo;
// 预入职-员工 // 预入职-员工
private TPreEmpDeclaration tpreEmpDeclaration; private TPreEmpDeclaration tpreEmpDeclaration;
// 预入职-员工伤残信息表 // 预入职-员工伤残信息表
private TPreEmpDisabilityInfo tpreEmpDisabilityInfo; private TPreEmpDisabilityInfo tpreEmpDisabilityInfo;
......
/*
* 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.Date;
/**
* 档案批量更新导入的表格内容
*
* @author hgw
* @date 2024-10-17 15:30:41
*/
@Data
public class PreUploadEmpImportTwoVo 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 = "身份证开始日期", isDate = true)
private String validityStart;
@ExcelAttribute(name = "身份证截止日期", 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, maxLength = 32)
private String empMarriStatus;
@ExcelAttribute(name = "民族", isDataId = true, dataType = ExcelAttributeConstants.EMP_NATIONAL, maxLength = 32)
private String empNational;
@ExcelAttribute(name = "政治面貌", isDataId = true, dataType = ExcelAttributeConstants.EMP_POLITICAL, maxLength = 32)
private String politicalStatus;
@ExcelAttribute(name = "手机号码", isPhone = 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, maxLength = 32)
private String empRegisType;
@ExcelAttribute(name = "档案所在地-省", isArea = true)
private String fileProvince;
@ExcelAttribute(name = "档案所在地-市", isArea = true, parentField = "fileProvince")
private String fileCity;
@ExcelAttribute(name = "档案所在地-区/县", isArea = true, parentField = "fileCity")
private String fileTown;
@ExcelAttribute(name = "通信地址-省", isArea = true)
private String contactProvince;
@ExcelAttribute(name = "通信地址-市", isArea = true, parentField = "contactProvince")
private String contactCity;
@ExcelAttribute(name = "通信地址-区/县", isArea = true, parentField = "contactCity")
private String contactTown;
@ExcelAttribute(name = "通信地址-详细地址", maxLength = 200)
private String contactAddress;
@ExcelAttribute(name = "备注", maxLength = 200)
private String remark;
// 预入职-员工学历信息表
// private TPreEmpEducation tpreEmpEducation
// 学历 学校 专业 教育开始时间 教育结束时间 是否大专及以上 最高学历
@ExcelAttribute(name = "是否大专及以上", isDataId = true, readConverterExp = "0=否,1=是")
private String isCollege;
@ExcelAttribute(name = "最高学历", isDataId = true, dataType = ExcelAttributeConstants.EDUCATION, 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;
// 紧急联系人
// private TPreEmpContactInfo tpreEmpContactInfo
// 紧急联系人姓名 与本人关系 联系地址-省 联系地址-市 联系地址-区/县 联系地址-详细地址 手机号码(紧急联系人)
@ExcelAttribute(name = "紧急联系人姓名", errorInfo = "紧急联系人姓名不能为空", maxLength = 20)
private String contactEmpName;
@ExcelAttribute(name = "紧急联系人与本人关系", errorInfo = "与本人关系不能为空", maxLength = 50)
private String relationType;
@ExcelAttribute(name = "联系地址-省", isArea = true)
private String relationProvince;
@ExcelAttribute(name = "联系地址-市", isArea = true, parentField = "relationProvince")
private String relationCity;
@ExcelAttribute(name = "联系地址-区/县", isArea = true, parentField = "relationCity")
private String relationTown;
@ExcelAttribute(name = "联系地址-详细地址", errorInfo = "联系地址-街道、详情不能为空", maxLength = 100)
private String address;
@ExcelAttribute(name = "手机号码(紧急联系人)", isPhone = true, errorInfo = "手机号码(紧急联系人)不能为空", maxLength = 20)
private String tel;
// 银行卡号 开户总行 开户省 开户市 开户支行 计税月份
@ExcelAttribute(name = "银行卡号", 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 String isCollegeValue;
@ExcelAttribute(name = "学历-值")
private String educationNameValue;
// 银行卡号 开户总行 开户省 开户市 开户支行 计税月份
@ExcelAttribute(name = "开户省-值")
private String bankProvinceValue;
@ExcelAttribute(name = "开户市-值")
private String bankCityValue;
@ExcelAttribute(name = "计税月份-值")
private String taxMonthValue;
@ExcelAttribute(name = "身份证开始日期-值")
private Date validityStartValue;
@ExcelAttribute(name = "身份证截止日期-值")
private Date validityEndValue;
// 字典值结束
@TableField(exist = false)
private String errorInfo;
}
...@@ -93,7 +93,7 @@ public class PreUploadEmpImportVo implements Serializable { ...@@ -93,7 +93,7 @@ public class PreUploadEmpImportVo implements Serializable {
// 紧急联系人姓名 与本人关系 联系地址-省 联系地址-市 联系地址-区/县 联系地址-详细地址 手机号码(紧急联系人) // 紧急联系人姓名 与本人关系 联系地址-省 联系地址-市 联系地址-区/县 联系地址-详细地址 手机号码(紧急联系人)
@ExcelAttribute(name = "紧急联系人姓名", isNotEmpty = true, errorInfo = "紧急联系人姓名不能为空", maxLength = 20) @ExcelAttribute(name = "紧急联系人姓名", isNotEmpty = true, errorInfo = "紧急联系人姓名不能为空", maxLength = 20)
private String contactEmpName; private String contactEmpName;
@ExcelAttribute(name = "与本人关系", isNotEmpty = true, errorInfo = "与本人关系不能为空", maxLength = 50) @ExcelAttribute(name = "紧急联系人与本人关系", isNotEmpty = true, errorInfo = "与本人关系不能为空", maxLength = 50)
private String relationType; private String relationType;
@ExcelAttribute(name = "联系地址-省", isNotEmpty = true, isArea = true) @ExcelAttribute(name = "联系地址-省", isNotEmpty = true, isArea = true)
private String relationProvince; private String relationProvince;
...@@ -144,9 +144,9 @@ public class PreUploadEmpImportVo implements Serializable { ...@@ -144,9 +144,9 @@ public class PreUploadEmpImportVo implements Serializable {
// 成员姓名 与本人关系 手机号码(家庭成员) // 成员姓名 与本人关系 手机号码(家庭成员)
// 预入职-员工家庭信息表 // 预入职-员工家庭信息表
// private List<TPreEmpFamily> tpreEmpFamilyList // private List<TPreEmpFamily> tpreEmpFamilyList
@ExcelAttribute(name = "成员姓名", maxLength = 32) @ExcelAttribute(name = "家庭成员成员姓名", maxLength = 32)
private String familyName; private String familyName;
@ExcelAttribute(name = "与本人关系", isMark = true,isDataId = true,dataType = ExcelAttributeConstants.FAMILY_RELATION, maxLength = 32) @ExcelAttribute(name = "家庭成员与本人关系", isMark = true,isDataId = true,dataType = ExcelAttributeConstants.FAMILY_RELATION, maxLength = 32)
private String relationshipSelf; private String relationshipSelf;
@ExcelAttribute(name = "手机号码(家庭成员)", isMark = true, isPhone = true, maxLength = 32) @ExcelAttribute(name = "手机号码(家庭成员)", isMark = true, isPhone = true, maxLength = 32)
private String contractTel; private String contractTel;
...@@ -287,6 +287,11 @@ public class PreUploadEmpImportVo implements Serializable { ...@@ -287,6 +287,11 @@ public class PreUploadEmpImportVo implements Serializable {
private String bankCityValue; private String bankCityValue;
@ExcelAttribute(name = "计税月份") @ExcelAttribute(name = "计税月份")
private String taxMonthValue; private String taxMonthValue;
@ExcelAttribute(name = "身份证开始日期")
private Date validityStartValue;
@ExcelAttribute(name = "身份证截止日期")
private Date validityEndValue;
// 字典值结束 // 字典值结束
// 附属信息 // 附属信息
......
...@@ -348,6 +348,21 @@ public class TEmployeeInfoController { ...@@ -348,6 +348,21 @@ public class TEmployeeInfoController {
return tEmployeeInfoService.batchUpdateEmployee(file.getInputStream(),exportFields); return tEmployeeInfoService.batchUpdateEmployee(file.getInputStream(),exportFields);
} }
/**
* @Description: 批量更新人员和银行信息
* @Author: hgw
* @Date: 2024-10-16 17:41:04
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
@SneakyThrows
@Operation(summary = "批量更新人员和银行信息", description = "批量更新人员和银行信息 hasPermission('employee_batch_update_bank')")
@SysLog("批量更新人员和银行信息")
@PostMapping("/batchUpdateEmployeeAndBank")
// @PreAuthorize("@pms.hasPermission('employee_batch_update_bank')")
public R<List<PreUploadEmpImportTwoVo>> batchUpdateEmployeeAndBank(MultipartFile file, PreUploadImportParamVo vo) throws Exception {
return tEmployeeInfoService.batchUpdateEmployeeAndBank(file, vo);
}
/** /**
* 批量导出人员档案信息 * 批量导出人员档案信息
* *
......
...@@ -258,8 +258,9 @@ public class TPreEmpMainController { ...@@ -258,8 +258,9 @@ public class TPreEmpMainController {
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo> * @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo>
**/ **/
@SysLog("预入职批量导入") @SysLog("预入职批量导入")
@Operation(description = "预入职批量导入") @Operation(summary = "预入职批量导入", description = "预入职批量导入 hasPermission('pre_emp_batch_upload')")
@PostMapping("/uploadPreEmp") @PostMapping("/uploadPreEmp")
// @PreAuthorize("@pms.hasPermission('pre_emp_batch_upload')")
public R<List<PreUploadEmpImportVo>> uploadPreEmp(MultipartFile file, PreUploadImportParamVo vo) throws Exception { public R<List<PreUploadEmpImportVo>> uploadPreEmp(MultipartFile file, PreUploadImportParamVo vo) throws Exception {
return tPreEmpMainService.uploadPreEmp(file, vo); return tPreEmpMainService.uploadPreEmp(file, vo);
} }
......
...@@ -24,6 +24,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo; ...@@ -24,6 +24,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author fxj * @author fxj
* @date 2024-06-17 14:29:11 * @date 2024-06-17 14:29:11
...@@ -37,4 +39,13 @@ public interface TEmpContactInfoMapper extends BaseMapper<TEmpContactInfo> { ...@@ -37,4 +39,13 @@ public interface TEmpContactInfoMapper extends BaseMapper<TEmpContactInfo> {
* @return * @return
*/ */
IPage<TEmpContactInfo> getTEmpContactInfoPage(Page<TEmpContactInfo> page, @Param("tEmpContactInfo") TEmpContactInfo tEmpContactInfo); IPage<TEmpContactInfo> getTEmpContactInfoPage(Page<TEmpContactInfo> page, @Param("tEmpContactInfo") TEmpContactInfo tEmpContactInfo);
/**
* @param deptId
* @Description: 获取紧急联系人信息
* @Author: hgw
* @Date: 2024/10/17 19:42
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo>
**/
List<TEmpContactInfo> getContactByDeptId(@Param("deptId") String deptId);
} }
...@@ -48,6 +48,9 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> { ...@@ -48,6 +48,9 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
List<TEmployeeInfo> getList(@Param("tEmployeeInfo") TEmployeeInfo tEmployeeInfo); List<TEmployeeInfo> getList(@Param("tEmployeeInfo") TEmployeeInfo tEmployeeInfo);
// 批量更新使用,按项目查询人员信息
List<TEmployeeInfo> getListByDeptId(@Param("deptId") String deptId);
// hgw 2022-6-22 15:32:39 根据身份证查询一批档案 // hgw 2022-6-22 15:32:39 根据身份证查询一批档案
List<TEmployeeInfo> getListByIdCard(@Param("idCardList") List<String> idCardList); List<TEmployeeInfo> getListByIdCard(@Param("idCardList") List<String> idCardList);
......
...@@ -22,7 +22,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpDeclaration; ...@@ -22,7 +22,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpDeclaration;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* 预入职-员工 * 预入职-员工
* *
* @author hgw * @author hgw
* @date 2024-06-17 11:24:00 * @date 2024-06-17 11:24:00
...@@ -30,7 +30,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -30,7 +30,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface TPreEmpDeclarationMapper extends BaseMapper<TPreEmpDeclaration> { public interface TPreEmpDeclarationMapper extends BaseMapper<TPreEmpDeclaration> {
/** /**
* 预入职-员工明简单分页查询 * 预入职-员工明简单分页查询
* *
* @return * @return
*/ */
......
...@@ -48,6 +48,14 @@ public interface TEmpContactInfoService extends IService<TEmpContactInfo> { ...@@ -48,6 +48,14 @@ public interface TEmpContactInfoService extends IService<TEmpContactInfo> {
void listExport(HttpServletResponse response, TEmpContactInfoSearchVo searchVo); void listExport(HttpServletResponse response, TEmpContactInfoSearchVo searchVo);
List<TEmpContactInfo> noPageDiy(TEmpContactInfoSearchVo searchVo); List<TEmpContactInfo> noPageDiy(TEmpContactInfoSearchVo searchVo);
/**
* @Description: 获取紧急联系人
* @Author: hgw
* @Date: 2024/10/17 19:40
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo>
**/
List<TEmpContactInfo> getContactByDeptId(String deptId);
TEmpContactInfo getByEmpId(String empId); TEmpContactInfo getByEmpId(String empId);
} }
...@@ -24,6 +24,7 @@ import com.pig4cloud.plugin.excel.vo.ErrorMessage; ...@@ -24,6 +24,7 @@ import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*; import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.InputStream; import java.io.InputStream;
...@@ -169,6 +170,9 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> { ...@@ -169,6 +170,9 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
**/ **/
R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream,String[] exportFields); R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream,String[] exportFields);
// 批量更新人员和银行信息
R<List<PreUploadEmpImportTwoVo>> batchUpdateEmployeeAndBank(MultipartFile file, PreUploadImportParamVo paramVo) throws Exception ;
void updateEducationOfEmp(EmpEducationUpdateVO education); void updateEducationOfEmp(EmpEducationUpdateVO education);
/** /**
......
...@@ -21,14 +21,14 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -21,14 +21,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpDeclaration; import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpDeclaration;
/** /**
* 预入职-员工 * 预入职-员工
* *
* @author hgw * @author hgw
* @date 2024-06-17 11:24:00 * @date 2024-06-17 11:24:00
*/ */
public interface TPreEmpDeclarationService extends IService<TPreEmpDeclaration> { public interface TPreEmpDeclarationService extends IService<TPreEmpDeclaration> {
/** /**
* 预入职-员工明简单分页查询 * 预入职-员工明简单分页查询
* *
* @return * @return
*/ */
......
...@@ -262,4 +262,9 @@ public class TEmpContactInfoServiceImpl extends ServiceImpl<TEmpContactInfoMappe ...@@ -262,4 +262,9 @@ public class TEmpContactInfoServiceImpl extends ServiceImpl<TEmpContactInfoMappe
.orderByDesc(TEmpContactInfo::getCreateTime).last(CommonConstants.LAST_ONE_SQL)); .orderByDesc(TEmpContactInfo::getCreateTime).last(CommonConstants.LAST_ONE_SQL));
} }
@Override
public List<TEmpContactInfo> getContactByDeptId(String deptId) {
return baseMapper.getContactByDeptId(deptId);
}
} }
...@@ -21,7 +21,6 @@ import cn.hutool.core.collection.CollUtil; ...@@ -21,7 +21,6 @@ import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder; import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
...@@ -32,8 +31,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -32,8 +31,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
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.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckMobile; 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.constants.EmployeeConstants; import com.yifu.cloud.plus.v1.yifu.archives.constants.EmployeeConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*; import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeContractAuditMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeContractAuditMapper;
...@@ -43,14 +44,19 @@ import com.yifu.cloud.plus.v1.yifu.archives.service.*; ...@@ -43,14 +44,19 @@ import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*; import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelColumnVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; 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.DaprCheckProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties; import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil; import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
...@@ -69,11 +75,13 @@ import org.springframework.cache.support.SimpleValueWrapper; ...@@ -69,11 +75,13 @@ import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -88,7 +96,7 @@ import java.util.*; ...@@ -88,7 +96,7 @@ import java.util.*;
@Log4j2 @Log4j2
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@EnableConfigurationProperties({DaprUpmsProperties.class, DaprCheckProperties.class}) @EnableConfigurationProperties({DaprUpmsProperties.class, DaprCheckProperties.class, DaprSalaryProperties.class, DaprCheckProperties.class})
public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, TEmployeeInfo> implements TEmployeeInfoService { public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, TEmployeeInfo> implements TEmployeeInfoService {
// 缓存信息 // 缓存信息
...@@ -96,8 +104,14 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -96,8 +104,14 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
private final TEmployeeProjectService tEmployeeProjectService; private final TEmployeeProjectService tEmployeeProjectService;
private final DaprCheckProperties daprCheckProperties; private final DaprCheckProperties daprCheckProperties;
private final DaprUpmsProperties daprUpmsProperties; private final DaprUpmsProperties daprUpmsProperties;
// // 档案批量更新校验开户行
private final DaprSalaryProperties salaryProperties;
// 档案批量更新校验身份证、卡号、手机号
private final DaprCheckProperties checkProperties;
private final TEmployeeLogService tEmployeeLogService; private final TEmployeeLogService tEmployeeLogService;
private final TEmpEducationService tEmpEducationService; private final TEmpEducationService tEmpEducationService;
// 档案批量更新使用的紧急联系人
private final TEmpContactInfoService tEmpContactInfoService;
private final TSettleDomainService tSettleDomainService; private final TSettleDomainService tSettleDomainService;
private final TEmployeeContractAuditMapper contractAuditMapper; private final TEmployeeContractAuditMapper contractAuditMapper;
...@@ -128,7 +142,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -128,7 +142,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
leavePageCount = baseMapper.getLeavePageCount(employeeInfo); leavePageCount = baseMapper.getLeavePageCount(employeeInfo);
page.setTotal(leavePageCount); page.setTotal(leavePageCount);
if (leavePageCount > 0L) { if (leavePageCount > 0L) {
page.setPages((long) Math.ceil(1.0*leavePageCount / page.getSize())); page.setPages((long) Math.ceil(1.0 * leavePageCount / page.getSize()));
} }
if (page.getCurrent() < 1) { if (page.getCurrent() < 1) {
page.setCurrent(1L); page.setCurrent(1L);
...@@ -136,7 +150,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -136,7 +150,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
if (page.getSize() < 1) { if (page.getSize() < 1) {
page.setSize(10L); page.setSize(10L);
} }
List<TEmployeeInfo> list = baseMapper.getLeavePage(employeeInfo,(page.getCurrent() - 1) * page.getSize(), page.getSize()); List<TEmployeeInfo> list = baseMapper.getLeavePage(employeeInfo, (page.getCurrent() - 1) * page.getSize(), page.getSize());
page.setRecords(list); page.setRecords(list);
return page; return page;
} else { } else {
...@@ -253,10 +267,10 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -253,10 +267,10 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
this.doUpdateEducationCore(education, employeeInfo); this.doUpdateEducationCore(education, employeeInfo);
// 更新其他附件信息 fxj 2024-09-09 // 更新其他附件信息 fxj 2024-09-09
if (updateOtherAtta(employeeInfo)){ if (updateOtherAtta(employeeInfo)) {
// 获取最新附件信息 fxj 2024-09-09 // 获取最新附件信息 fxj 2024-09-09
getAttaInfo(employeeInfo); getAttaInfo(employeeInfo);
} else{ } else {
old.setOtherFiles(null); old.setOtherFiles(null);
employeeInfo.setOtherFiles(null); employeeInfo.setOtherFiles(null);
} }
...@@ -271,39 +285,39 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -271,39 +285,39 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
private boolean updateOtherAtta(TEmployeeInfo employeeInfo) { private boolean updateOtherAtta(TEmployeeInfo employeeInfo) {
List<TEmpOtherFile> otherFileList = employeeInfo.getOtherFiles(); List<TEmpOtherFile> otherFileList = employeeInfo.getOtherFiles();
boolean flag = false; boolean flag = false;
if (Common.isNotNull(otherFileList)){ if (Common.isNotNull(otherFileList)) {
List<TAttaInfo> attaInfos = new ArrayList<>(); List<TAttaInfo> attaInfos = new ArrayList<>();
for (TEmpOtherFile otherFile:otherFileList){ for (TEmpOtherFile otherFile : otherFileList) {
//处理新增或删除其他附件分租的逻辑 //处理新增或删除其他附件分租的逻辑
if (!flag){ if (!flag) {
flag = handleOtherFile(otherFile); flag = handleOtherFile(otherFile);
}else { } else {
handleOtherFile(otherFile); handleOtherFile(otherFile);
} }
if (Common.isNotNull(otherFile.getAttaList())){ if (Common.isNotNull(otherFile.getAttaList())) {
attaInfos.addAll(otherFile.getAttaList()); attaInfos.addAll(otherFile.getAttaList());
} }
} }
if (Common.isNotNull(attaInfos)){ if (Common.isNotNull(attaInfos)) {
List<String> deleteIds = new ArrayList<>(); List<String> deleteIds = new ArrayList<>();
List<TAttaInfo> adds = new ArrayList<>(); List<TAttaInfo> adds = new ArrayList<>();
for (TAttaInfo attaInfo:attaInfos){ for (TAttaInfo attaInfo : attaInfos) {
if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())){ if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())) {
adds.add(attaInfo); adds.add(attaInfo);
} }
if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())){ if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())) {
deleteIds.add(attaInfo.getId()); deleteIds.add(attaInfo.getId());
} }
} }
if (Common.isNotNull(deleteIds)){ if (Common.isNotNull(deleteIds)) {
attaInfoService.removeBatchByIds(deleteIds); attaInfoService.removeBatchByIds(deleteIds);
flag =true; flag = true;
} }
if (Common.isNotNull(adds)){ if (Common.isNotNull(adds)) {
attaInfoService.updateBatchById(adds); attaInfoService.updateBatchById(adds);
flag =true; flag = true;
} }
} }
} }
...@@ -312,33 +326,33 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -312,33 +326,33 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 仿写房工更新附件 // 仿写房工更新附件
private boolean updateAtta(TEmployeeInfo employeeInfo, TEmployeeInfo old) { private boolean updateAtta(TEmployeeInfo employeeInfo, TEmployeeInfo old) {
List<TAttaInfo> attaInfos = employeeInfo.getAttaList(); List<TAttaInfo> attaInfos = employeeInfo.getAttaList();
boolean flag = false; boolean flag = false;
if (Common.isNotNull(attaInfos)){ if (Common.isNotNull(attaInfos)) {
List<String> deleteIds = new ArrayList<>(); List<String> deleteIds = new ArrayList<>();
List<TAttaInfo> adds = new ArrayList<>(); List<TAttaInfo> adds = new ArrayList<>();
for (TAttaInfo attaInfo : attaInfos){ for (TAttaInfo attaInfo : attaInfos) {
if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())){ if (CommonConstants.ZERO_STRING.equals(attaInfo.getHandleType())) {
setAttaLogByRelationType(employeeInfo, attaInfo); setAttaLogByRelationType(employeeInfo, attaInfo);
adds.add(attaInfo); adds.add(attaInfo);
} }
if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())){ if (CommonConstants.TWO_STRING.equals(attaInfo.getHandleType())) {
setAttaLogByRelationType(old, attaInfo); setAttaLogByRelationType(old, attaInfo);
deleteIds.add(attaInfo.getId()); deleteIds.add(attaInfo.getId());
} }
if (CommonConstants.ONE_STRING.equals(attaInfo.getHandleType()) if (CommonConstants.ONE_STRING.equals(attaInfo.getHandleType())
|| CommonConstants.THREE_STRING.equals(attaInfo.getHandleType())){ || CommonConstants.THREE_STRING.equals(attaInfo.getHandleType())) {
setAttaLogByRelationType(employeeInfo, attaInfo); setAttaLogByRelationType(employeeInfo, attaInfo);
setAttaLogByRelationType(old, attaInfo); setAttaLogByRelationType(old, attaInfo);
} }
} }
if (Common.isNotNull(deleteIds)){ if (Common.isNotNull(deleteIds)) {
attaInfoService.removeBatchByIds(deleteIds); attaInfoService.removeBatchByIds(deleteIds);
flag =true; flag = true;
} }
if (Common.isNotNull(adds)){ if (Common.isNotNull(adds)) {
attaInfoService.updateBatchById(adds); attaInfoService.updateBatchById(adds);
flag =true; flag = true;
} }
} }
return flag; return flag;
...@@ -347,7 +361,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -347,7 +361,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
/** /**
* @param employeeInfo * @param employeeInfo
* @param attaInfo * @param attaInfo
* @Description: 根据类型塞附件,记录变更日志使用的 * @Description: 根据类型塞附件,记录变更日志使用的
* @Author: hgw * @Author: hgw
* @Date: 2024/10/16 10:34 * @Date: 2024/10/16 10:34
* @return: void * @return: void
...@@ -359,49 +373,64 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -359,49 +373,64 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
* 25 户口本本人页26学信27预入职其他附件 * 25 户口本本人页26学信27预入职其他附件
*/ */
switch (attaInfo.getRelationType()) { switch (attaInfo.getRelationType()) {
case "9": employeeInfo.setAttaIdCardOne(attaInfo); break; case "9":
case "24": employeeInfo.setAttaIdCardTwo(attaInfo); break; employeeInfo.setAttaIdCardOne(attaInfo);
case "10": employeeInfo.setAttaRegistrationOne(attaInfo); break; break;
case "25": employeeInfo.setAttaRegistrationTwo(attaInfo); break; case "24":
case "21": employeeInfo.setAttaDeclearOne(attaInfo); break; employeeInfo.setAttaIdCardTwo(attaInfo);
case "22": employeeInfo.setAttaDeclearTwo(attaInfo); break; break;
default:break; case "10":
employeeInfo.setAttaRegistrationOne(attaInfo);
break;
case "25":
employeeInfo.setAttaRegistrationTwo(attaInfo);
break;
case "21":
employeeInfo.setAttaDeclearOne(attaInfo);
break;
case "22":
employeeInfo.setAttaDeclearTwo(attaInfo);
break;
default:
break;
} }
} }
private boolean handleOtherFile(TEmpOtherFile otherFile) { private boolean handleOtherFile(TEmpOtherFile otherFile) {
boolean flag =false; boolean flag = false;
// 新增时先增加 empOtherFile // 新增时先增加 empOtherFile
if (CommonConstants.ZERO_STRING.equals(otherFile.getHandleType())){ if (CommonConstants.ZERO_STRING.equals(otherFile.getHandleType())) {
empOtherFileService.save(otherFile); empOtherFileService.save(otherFile);
flag = true; flag = true;
if (Common.isNotNull(otherFile.getAttaList())){ if (Common.isNotNull(otherFile.getAttaList())) {
for (TAttaInfo info: otherFile.getAttaList()){ for (TAttaInfo info : otherFile.getAttaList()) {
info.setDomainId(otherFile.getId()); info.setDomainId(otherFile.getId());
} }
} }
// 更新 // 更新
}if (CommonConstants.ONE_STRING.equals(otherFile.getHandleType())){ }
if (CommonConstants.ONE_STRING.equals(otherFile.getHandleType())) {
flag = true; flag = true;
if (Common.isNotNull(otherFile.getId())){ if (Common.isNotNull(otherFile.getId())) {
empOtherFileService.updateById(otherFile); empOtherFileService.updateById(otherFile);
if (Common.isNotNull(otherFile.getAttaList())){ if (Common.isNotNull(otherFile.getAttaList())) {
for (TAttaInfo info: otherFile.getAttaList()){ for (TAttaInfo info : otherFile.getAttaList()) {
info.setDomainId(otherFile.getId()); info.setDomainId(otherFile.getId());
} }
} }
} }
// 删除时 // 删除时
}if (CommonConstants.THREE_STRING.equals(otherFile.getHandleType())){ }
if (Common.isNotNull(otherFile.getId())){ if (CommonConstants.THREE_STRING.equals(otherFile.getHandleType())) {
if (Common.isNotNull(otherFile.getAttaList())){ if (Common.isNotNull(otherFile.getId())) {
for (TAttaInfo info: otherFile.getAttaList()){ if (Common.isNotNull(otherFile.getAttaList())) {
for (TAttaInfo info : otherFile.getAttaList()) {
info.setDomainId(otherFile.getId()); info.setDomainId(otherFile.getId());
} }
} }
} }
// 删除时 // 删除时
}else if (CommonConstants.TWO_STRING.equals(otherFile.getHandleType())){ } else if (CommonConstants.TWO_STRING.equals(otherFile.getHandleType())) {
empOtherFileService.removeById(otherFile.getId()); empOtherFileService.removeById(otherFile.getId());
flag = true; flag = true;
} }
...@@ -410,15 +439,15 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -410,15 +439,15 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
private void getAttaInfo(TEmployeeInfo emp) { private void getAttaInfo(TEmployeeInfo emp) {
List<TEmpOtherFile> otherFiles = otherFileService.getListByEmpId(emp.getId()); List<TEmpOtherFile> otherFiles = otherFileService.getListByEmpId(emp.getId());
if (Common.isNotNull(otherFiles)){ if (Common.isNotNull(otherFiles)) {
List<TAttaInfo> attaInfos; List<TAttaInfo> attaInfos;
for (TEmpOtherFile file:otherFiles){ for (TEmpOtherFile file : otherFiles) {
attaInfos = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId,file.getId())); attaInfos = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, file.getId()));
if (Common.isNotNull(attaInfos)){ if (Common.isNotNull(attaInfos)) {
URL url; URL url;
for (TAttaInfo atta:attaInfos){ for (TAttaInfo atta : attaInfos) {
url = ossUtil.getObjectUrl(null, atta.getAttaSrc()); url = ossUtil.getObjectUrl(null, atta.getAttaSrc());
if (Common.isNotNull(url)){ if (Common.isNotNull(url)) {
atta.setAttaUrl(url.toString()); atta.setAttaUrl(url.toString());
} }
} }
...@@ -432,11 +461,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -432,11 +461,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 仿写房工附件接口 // 仿写房工附件接口
private void getEmpAttaInfo(TEmployeeInfo emp) { private void getEmpAttaInfo(TEmployeeInfo emp) {
List<TAttaInfo> attaInfos = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, emp.getId())); List<TAttaInfo> attaInfos = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, emp.getId()));
if (Common.isNotNull(attaInfos)){ if (Common.isNotNull(attaInfos)) {
URL url; URL url;
for (TAttaInfo atta:attaInfos){ for (TAttaInfo atta : attaInfos) {
url = ossUtil.getObjectUrl(null, atta.getAttaSrc()); url = ossUtil.getObjectUrl(null, atta.getAttaSrc());
if (Common.isNotNull(url)){ if (Common.isNotNull(url)) {
atta.setAttaUrl(url.toString()); atta.setAttaUrl(url.toString());
} }
} }
...@@ -1016,12 +1045,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1016,12 +1045,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
errorMsgMap.put(lineNum, new ErrorMessage("户口性质必填")); errorMsgMap.put(lineNum, new ErrorMessage("户口性质必填"));
} }
//婚姻状态不可为空 //婚姻状态不可为空
if(Common.isEmpty(employeeInfo.getEmpMarriStatus())){ if (Common.isEmpty(employeeInfo.getEmpMarriStatus())) {
errorMsg.add(EmployeeConstants.MARRY_STATUS_NOT_NULL); errorMsg.add(EmployeeConstants.MARRY_STATUS_NOT_NULL);
errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.MARRY_STATUS_NOT_NULL)); errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.MARRY_STATUS_NOT_NULL));
} }
//政治面貌不可为空 //政治面貌不可为空
if(Common.isEmpty(employeeInfo.getPoliticalStatus())){ if (Common.isEmpty(employeeInfo.getPoliticalStatus())) {
errorMsg.add(EmployeeConstants.POLITICAL_STATUS_NOT_NULL); errorMsg.add(EmployeeConstants.POLITICAL_STATUS_NOT_NULL);
errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.POLITICAL_STATUS_NOT_NULL)); errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.POLITICAL_STATUS_NOT_NULL));
} }
...@@ -1099,7 +1128,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1099,7 +1128,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
//MVP1.6.7-huyc-身份证期限截止日期调整-校验日期 //MVP1.6.7-huyc-身份证期限截止日期调整-校验日期
if (Common.isNotNull(employeeInfo.getValidityEnd()) && !"长期".equals(employeeInfo.getValidityEnd()) && if (Common.isNotNull(employeeInfo.getValidityEnd()) && !"长期".equals(employeeInfo.getValidityEnd()) &&
!DateUtil.checkStringToDate(employeeInfo.getValidityEnd(),DateUtil.ISO_EXPANDED_DATE_FORMAT)) { !DateUtil.checkStringToDate(employeeInfo.getValidityEnd(), DateUtil.ISO_EXPANDED_DATE_FORMAT)) {
errorMsg.add(EmployeeConstants.VALIDITY_END_FORMAT); errorMsg.add(EmployeeConstants.VALIDITY_END_FORMAT);
errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.VALIDITY_END_FORMAT)); errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.VALIDITY_END_FORMAT));
} }
...@@ -1497,7 +1526,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1497,7 +1526,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
if (Common.isNotNull(excel.getFileTown())) { if (Common.isNotNull(excel.getFileTown())) {
saveEmp.setFileTown(Integer.parseInt(excel.getFileTown())); saveEmp.setFileTown(Integer.parseInt(excel.getFileTown()));
}else { } else {
saveEmp.setFileTown(null); saveEmp.setFileTown(null);
} }
if (Common.isNotNull(excel.getIsCollege())) { if (Common.isNotNull(excel.getIsCollege())) {
...@@ -1711,7 +1740,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1711,7 +1740,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
@Override @Override
public R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream,String[] exportFields) { public R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream, String[] exportFields) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmployeeInsertVO> util1 = new ExcelUtil<>(EmployeeInsertVO.class); ExcelUtil<EmployeeInsertVO> util1 = new ExcelUtil<>(EmployeeInsertVO.class);
// 写法2: // 写法2:
...@@ -1760,7 +1789,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1760,7 +1789,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
private void saveData() { private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size()); log.info("{}条数据,开始存储数据库!", cachedDataList.size());
if (!cachedDataList.isEmpty()) { if (!cachedDataList.isEmpty()) {
batchUpdateCore(cachedDataList, errorMessageList,exportFields); batchUpdateCore(cachedDataList, errorMessageList, exportFields);
} }
log.info("存储数据库成功!"); log.info("存储数据库成功!");
} }
...@@ -1794,10 +1823,10 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1794,10 +1823,10 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return R.failed(errorMessageList); return R.failed(errorMessageList);
} }
//初试化表头用于校验省市县 //初试化表头用于校验省市县
HashMap<String,String> headMap = new HashMap<>(); HashMap<String, String> headMap = new HashMap<>();
if (Common.isNotNull(exportFields)){ if (Common.isNotNull(exportFields)) {
for (int i=0; i < exportFields.length; i++){ for (int i = 0; i < exportFields.length; i++) {
headMap.put(exportFields[i],exportFields[i]); headMap.put(exportFields[i], exportFields[i]);
} }
} }
...@@ -2028,7 +2057,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2028,7 +2057,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
if (Common.isNotNull(excel.getValidityEnd())) { if (Common.isNotNull(excel.getValidityEnd())) {
//MVP1.6.7-huyc-身份证期限截止日期调整-校验日期 //MVP1.6.7-huyc-身份证期限截止日期调整-校验日期
if (!"长期".equals(excel.getValidityEnd()) && !DateUtil.checkStringToDate( if (!"长期".equals(excel.getValidityEnd()) && !DateUtil.checkStringToDate(
excel.getValidityEnd(),DateUtil.ISO_EXPANDED_DATE_FORMAT)) { excel.getValidityEnd(), DateUtil.ISO_EXPANDED_DATE_FORMAT)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_END, excel.getEmpIdcard())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_END, excel.getEmpIdcard()));
} else { } else {
if ("长期".equals(excel.getValidityEnd())) { if ("长期".equals(excel.getValidityEnd())) {
...@@ -2047,7 +2076,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2047,7 +2076,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
if (Common.isNotNull(excel.getFileTown())) { if (Common.isNotNull(excel.getFileTown())) {
saveEmp.setFileTown(Integer.parseInt(excel.getFileTown())); saveEmp.setFileTown(Integer.parseInt(excel.getFileTown()));
}else { } else {
saveEmp.setFileTown(null); saveEmp.setFileTown(null);
} }
// 邮箱 // 邮箱
...@@ -2096,7 +2125,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2096,7 +2125,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
// 档案地和通信地址 校验 // 档案地和通信地址 校验
if (Common.isNotNull(headMap.get("档案所在省")) if (Common.isNotNull(headMap.get("档案所在省"))
|| Common.isNotNull(headMap.get("档案所在市"))){ || Common.isNotNull(headMap.get("档案所在市"))) {
if (Common.isEmpty(excel.getFileProvince())) { if (Common.isEmpty(excel.getFileProvince())) {
errorMsg.add(EmployeeConstants.FILE_PROVINCE); errorMsg.add(EmployeeConstants.FILE_PROVINCE);
} }
...@@ -2106,12 +2135,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2106,12 +2135,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
if (Common.isNotNull(headMap.get("通信地址-省")) if (Common.isNotNull(headMap.get("通信地址-省"))
|| Common.isNotNull(headMap.get("通信地址-市")) || Common.isNotNull(headMap.get("通信地址-市"))
|| Common.isNotNull(headMap.get("通信地址-区/县"))){ || Common.isNotNull(headMap.get("通信地址-区/县"))) {
if (Common.isEmpty(excel.getContactTown())) { if (Common.isEmpty(excel.getContactTown())) {
errorMsg.add(EmployeeConstants.CONTACT_PROVINCE); errorMsg.add(EmployeeConstants.CONTACT_PROVINCE);
} }
} }
if (Common.isNotNull(headMap.get("通信地址-详细地址"))){ if (Common.isNotNull(headMap.get("通信地址-详细地址"))) {
if (Common.isEmpty(excel.getContactAddress())) { if (Common.isEmpty(excel.getContactAddress())) {
errorMsg.add(EmployeeConstants.CONTACT_ADDRESS); errorMsg.add(EmployeeConstants.CONTACT_ADDRESS);
} }
...@@ -2300,47 +2329,47 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2300,47 +2329,47 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
out = response.getOutputStream(); out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA); response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list); //EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class); ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
// 获取所有字典type // 获取所有字典type
Map<String,String> nameAndDicTypeMap = util.getConverterDicType(); Map<String, String> nameAndDicTypeMap = util.getConverterDicType();
// 获取所有字典对应的值 // 获取所有字典对应的值
Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE); Map<String, String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE);
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeExportVO.class) ExcelWriter excelWriter = EasyExcel.write(out, EmployeeExportVO.class)
.registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap)) .registerConverter(new DictConverter(nameAndDicTypeMap, redisLabelMap))
.includeColumnFieldNames(searchVo.getExportFields()).build(); .includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT){ if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet; WriteSheet writeSheet;
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; ) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo); list = noPageDiy(searchVo);
if (Common.isNotNull(list)){ if (Common.isNotNull(list)) {
writeSheet = EasyExcel.writerSheet("人员档案批量导出"+index).build(); writeSheet = EasyExcel.writerSheet("人员档案批量导出" + index).build();
excelWriter.write(list,writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
} }
i = i + CommonConstants.EXCEL_EXPORT_LIMIT; i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)){ if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
} }
}else { } else {
WriteSheet writeSheet = EasyExcel.writerSheet("人员档案批量导出"+index).build(); WriteSheet writeSheet = EasyExcel.writerSheet("人员档案批量导出" + index).build();
excelWriter.write(list,writeSheet); excelWriter.write(list, writeSheet);
} }
if (Common.isNotNull(list)){ if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
out.flush(); out.flush();
excelWriter.finish(); excelWriter.finish();
}catch (Exception e){ } catch (Exception e) {
log.error("执行异常" ,e); log.error("执行异常", e);
}finally { } finally {
try { try {
if (null != out) { if (null != out) {
out.close(); out.close();
...@@ -2378,11 +2407,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2378,11 +2407,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
out = response.getOutputStream(); out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA); response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeLeaveExportVO.class).includeColumnFieldNames(searchVo.getExportFields()).build(); ExcelWriter excelWriter = EasyExcel.write(out, EmployeeLeaveExportVO.class).includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT){ if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet; WriteSheet writeSheet;
ExcelUtil<EmployeeLeaveExportVO> util; ExcelUtil<EmployeeLeaveExportVO> util;
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; ) {
...@@ -2390,28 +2419,28 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2390,28 +2419,28 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageLeaveDiy(searchVo); list = noPageLeaveDiy(searchVo);
if (Common.isNotNull(list)){ if (Common.isNotNull(list)) {
writeSheet = EasyExcel.writerSheet("离职档案批量导出"+index).build(); writeSheet = EasyExcel.writerSheet("离职档案批量导出" + index).build();
excelWriter.write(list,writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
} }
i = i + CommonConstants.EXCEL_EXPORT_LIMIT; i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)){ if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
} }
}else { } else {
WriteSheet writeSheet = EasyExcel.writerSheet("离职档案批量导出"+index).build(); WriteSheet writeSheet = EasyExcel.writerSheet("离职档案批量导出" + index).build();
excelWriter.write(list,writeSheet); excelWriter.write(list, writeSheet);
} }
if (Common.isNotNull(list)){ if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
out.flush(); out.flush();
excelWriter.finish(); excelWriter.finish();
}catch (Exception e){ } catch (Exception e) {
log.error("执行异常" ,e); log.error("执行异常", e);
}finally { } finally {
try { try {
if (null != out) { if (null != out) {
out.close(); out.close();
...@@ -2471,7 +2500,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2471,7 +2500,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 新增项目档案不需要返回ID // 新增项目档案不需要返回ID
saveProject(empAddsMap, projectsMap); saveProject(empAddsMap, projectsMap);
// 新增合同 // 新增合同
saveContract(projectsMap, contractsMap,empAddsMap); saveContract(projectsMap, contractsMap, empAddsMap);
addVo.setProjectsMap(projectsMap); addVo.setProjectsMap(projectsMap);
addVo.setEmpAddsMap(empAddsMap); addVo.setEmpAddsMap(empAddsMap);
addVo.setContractsMap(contractsMap); addVo.setContractsMap(contractsMap);
...@@ -2479,51 +2508,51 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2479,51 +2508,51 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
/** /**
* @return
* @Author fxj * @Author fxj
* @Description 派单审核通过 同步人员档案 项目档案 合同状态信息 * @Description 派单审核通过 同步人员档案 项目档案 合同状态信息
* @Date 19:30 2022/8/1 * @Date 19:30 2022/8/1
* @Param * @Param
* @return
**/ **/
@Override @Override
public Boolean updateEmpInfo(UpdateEmpVo vo) { public Boolean updateEmpInfo(UpdateEmpVo vo) {
if (Common.isNotNull(vo)){ if (Common.isNotNull(vo)) {
TEmployeeInfo employeeInfo = null; TEmployeeInfo employeeInfo = null;
TEmployeeProject p = null; TEmployeeProject p = null;
if (Common.isNotNull(vo.getEmpIdCard())){ if (Common.isNotNull(vo.getEmpIdCard())) {
if (CommonConstants.ZERO_STRING.equals(vo.getType())){ if (CommonConstants.ZERO_STRING.equals(vo.getType())) {
employeeInfo = baseMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda() employeeInfo = baseMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getDeleteFlag,CommonConstants.ZERO_STRING) .eq(TEmployeeInfo::getDeleteFlag, CommonConstants.ZERO_STRING)
.eq(TEmployeeInfo::getEmpIdcard,vo.getEmpIdCard()) .eq(TEmployeeInfo::getEmpIdcard, vo.getEmpIdCard())
.last(CommonConstants.LAST_ONE_SQL)); .last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(employeeInfo)){ if (Common.isNotNull(employeeInfo)) {
if(Common.isNotNull(vo.getContactAddress())) { if (Common.isNotNull(vo.getContactAddress())) {
employeeInfo.setContactAddress(vo.getContactAddress()); employeeInfo.setContactAddress(vo.getContactAddress());
} }
employeeInfo.setStatus(CommonConstants.ONE_INT); employeeInfo.setStatus(CommonConstants.ONE_INT);
baseMapper.updateById(employeeInfo); baseMapper.updateById(employeeInfo);
} }
if (Common.isNotNull(vo.getProjectNo())){ if (Common.isNotNull(vo.getProjectNo())) {
p = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query().lambda() p = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getDeleteFlag,CommonConstants.ZERO_INT) .eq(TEmployeeProject::getDeleteFlag, CommonConstants.ZERO_INT)
.eq(TEmployeeProject::getEmpIdcard,vo.getEmpIdCard()) .eq(TEmployeeProject::getEmpIdcard, vo.getEmpIdCard())
.eq(TEmployeeProject::getDeptNo,vo.getProjectNo()) .eq(TEmployeeProject::getDeptNo, vo.getProjectNo())
.eq(TEmployeeProject::getStatus,CommonConstants.ZERO_INT) .eq(TEmployeeProject::getStatus, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)); .last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(p)){ if (Common.isNotNull(p)) {
p.setStatus(CommonConstants.ONE_INT); p.setStatus(CommonConstants.ONE_INT);
tEmployeeProjectService.updateById(p); tEmployeeProjectService.updateById(p);
} }
} }
} }
if (Common.isNotNull(vo.getContractId())){ if (Common.isNotNull(vo.getContractId())) {
TEmployeeContractInfo c = contractServicer.getOne(Wrappers.<TEmployeeContractInfo>query().lambda() TEmployeeContractInfo c = contractServicer.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
.eq(TEmployeeContractInfo::getDeleteFlag,CommonConstants.ZERO_INT) .eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.eq(TEmployeeContractInfo::getId,vo.getContractId()) .eq(TEmployeeContractInfo::getId, vo.getContractId())
.eq(TEmployeeContractInfo::getAuditStatus,CommonConstants.ONE_INT) .eq(TEmployeeContractInfo::getAuditStatus, CommonConstants.ONE_INT)
.last(CommonConstants.LAST_ONE_SQL)); .last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(c)){ if (Common.isNotNull(c)) {
TEmployeeContractAudit contractAudit = new TEmployeeContractAudit(); TEmployeeContractAudit contractAudit = new TEmployeeContractAudit();
contractAudit.setLinkId(c.getId()); contractAudit.setLinkId(c.getId());
contractAudit.setLinkType(CommonConstants.ONE_INT); contractAudit.setLinkType(CommonConstants.ONE_INT);
...@@ -2532,18 +2561,18 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2532,18 +2561,18 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
contractAudit.setCreateTime(LocalDateTime.now()); contractAudit.setCreateTime(LocalDateTime.now());
//审核通过 //审核通过
c.setAuditUserName(vo.getCreateName()); c.setAuditUserName(vo.getCreateName());
if (CommonConstants.ZERO_STRING.equals(vo.getType())){ if (CommonConstants.ZERO_STRING.equals(vo.getType())) {
c.setAuditStatus(CommonConstants.TWO_INT); c.setAuditStatus(CommonConstants.TWO_INT);
c.setInUse(CommonConstants.ZERO_STRING); c.setInUse(CommonConstants.ZERO_STRING);
c.setAuditTimeLast(LocalDateTime.now()); c.setAuditTimeLast(LocalDateTime.now());
contractAudit.setAuditStatus("审核通过"); contractAudit.setAuditStatus("审核通过");
contractAudit.setRemark(vo.getRemarkTemp()); contractAudit.setRemark(vo.getRemarkTemp());
contractAudit.setRootName("合同审核"); contractAudit.setRootName("合同审核");
contractServicer.updateInUseStatusById(c.getEmpId(),c.getDeptNo(),c.getId()); contractServicer.updateInUseStatusById(c.getEmpId(), c.getDeptNo(), c.getId());
tEmployeeProjectService.updateContractStatus(c.getEmpId(), c.getSettleDomain(), CommonConstants.ONE_INT); tEmployeeProjectService.updateContractStatus(c.getEmpId(), c.getSettleDomain(), CommonConstants.ONE_INT);
baseMapper.updateContractStatus(c.getEmpId(),CommonConstants.ONE_INT); baseMapper.updateContractStatus(c.getEmpId(), CommonConstants.ONE_INT);
//审核不同 //审核不同
}else if (CommonConstants.ONE_STRING.equals(vo.getType())){ } else if (CommonConstants.ONE_STRING.equals(vo.getType())) {
c.setAuditStatus(CommonConstants.THREE_INT); c.setAuditStatus(CommonConstants.THREE_INT);
c.setInUse(CommonConstants.ONE_STRING); c.setInUse(CommonConstants.ONE_STRING);
contractAudit.setAuditStatus("审核不通过"); contractAudit.setAuditStatus("审核不通过");
...@@ -2562,13 +2591,13 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2562,13 +2591,13 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
@Override @Override
public Boolean checkMobile(String mobile) { public Boolean checkMobile(String mobile) {
if (Common.isEmpty(mobile)){ if (Common.isEmpty(mobile)) {
return true; return true;
} }
return baseMapper.selectCount(Wrappers.<TEmployeeInfo>query().lambda() return baseMapper.selectCount(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getFileStatus,CommonConstants.ZERO_STRING) .eq(TEmployeeInfo::getFileStatus, CommonConstants.ZERO_STRING)
.eq(TEmployeeInfo::getEmpPhone,mobile) .eq(TEmployeeInfo::getEmpPhone, mobile)
.eq(TEmployeeInfo::getDeleteFlag,CommonConstants.ZERO_STRING)) > 0; .eq(TEmployeeInfo::getDeleteFlag, CommonConstants.ZERO_STRING)) > 0;
} }
@Override @Override
...@@ -2603,13 +2632,13 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2603,13 +2632,13 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
contract = new TEmployeeContractInfo(); contract = new TEmployeeContractInfo();
BeanUtil.copyProperties(contractAdd, contract); BeanUtil.copyProperties(contractAdd, contract);
if (Common.isEmpty(contract.getEmpId()) && Common.isNotNull(projectsMap)) { if (Common.isEmpty(contract.getEmpId()) && Common.isNotNull(projectsMap)) {
project = projectsMap.get(contract.getEmpIdcard()+CommonConstants.DOWN_LINE_STRING+contract.getDeptNo()); project = projectsMap.get(contract.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + contract.getDeptNo());
if (Common.isNotNull(project)) { if (Common.isNotNull(project)) {
contract.setEmpId(project.getId()); contract.setEmpId(project.getId());
contract.setEmpNo(project.getEmpNo()); contract.setEmpNo(project.getEmpNo());
} }
emp = empAddsMap.get(contract.getEmpIdcard()); emp = empAddsMap.get(contract.getEmpIdcard());
if (Common.isNotNull(emp)){ if (Common.isNotNull(emp)) {
contract.setEmpId(emp.getId()); contract.setEmpId(emp.getId());
contract.setEmpNatrue(emp.getEmpNatrue()); contract.setEmpNatrue(emp.getEmpNatrue());
contract.setFileProvince(emp.getFileProvince()); contract.setFileProvince(emp.getFileProvince());
...@@ -2631,7 +2660,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2631,7 +2660,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
contractsMap.put(contractAdd.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + contractAdd.getDeptNo(), contractAdd); contractsMap.put(contractAdd.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + contractAdd.getDeptNo(), contractAdd);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(contractAdd.getEmpIdcard() + CommonConstants.COLON_STRING + "派单新增合同失败",e); log.error(contractAdd.getEmpIdcard() + CommonConstants.COLON_STRING + "派单新增合同失败", e);
} }
} }
} }
...@@ -2663,37 +2692,37 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2663,37 +2692,37 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
BeanUtil.copyProperties(empAdd, employeeInfo); BeanUtil.copyProperties(empAdd, employeeInfo);
employeeInfo.setEmpCode(getCode()); employeeInfo.setEmpCode(getCode());
employeeInfo.setContactAddress(empAdd.getContactAddress()); employeeInfo.setContactAddress(empAdd.getContactAddress());
if(empAdd.getHignEducation().equals("文盲")) { if (empAdd.getHignEducation().equals("文盲")) {
employeeInfo.setHignEducation("1"); employeeInfo.setHignEducation("1");
} }
if(empAdd.getHignEducation().equals("小学")) { if (empAdd.getHignEducation().equals("小学")) {
employeeInfo.setHignEducation("2"); employeeInfo.setHignEducation("2");
} }
if(empAdd.getHignEducation().equals("初中")) { if (empAdd.getHignEducation().equals("初中")) {
employeeInfo.setHignEducation("3"); employeeInfo.setHignEducation("3");
} }
if(empAdd.getHignEducation().equals("高中")) { if (empAdd.getHignEducation().equals("高中")) {
employeeInfo.setHignEducation("4"); employeeInfo.setHignEducation("4");
} }
if(empAdd.getHignEducation().equals("大专")) { if (empAdd.getHignEducation().equals("大专")) {
employeeInfo.setHignEducation("5"); employeeInfo.setHignEducation("5");
} }
if(empAdd.getHignEducation().equals("本科")) { if (empAdd.getHignEducation().equals("本科")) {
employeeInfo.setHignEducation("6"); employeeInfo.setHignEducation("6");
} }
if(empAdd.getHignEducation().equals("硕士")) { if (empAdd.getHignEducation().equals("硕士")) {
employeeInfo.setHignEducation("7"); employeeInfo.setHignEducation("7");
} }
if(empAdd.getHignEducation().equals("博士")) { if (empAdd.getHignEducation().equals("博士")) {
employeeInfo.setHignEducation("8"); employeeInfo.setHignEducation("8");
} }
if(empAdd.getHignEducation().equals("技工")) { if (empAdd.getHignEducation().equals("技工")) {
employeeInfo.setHignEducation("9"); employeeInfo.setHignEducation("9");
} }
if(empAdd.getHignEducation().equals("职高")) { if (empAdd.getHignEducation().equals("职高")) {
employeeInfo.setHignEducation("10"); employeeInfo.setHignEducation("10");
} }
if(empAdd.getHignEducation().equals("中专")) { if (empAdd.getHignEducation().equals("中专")) {
employeeInfo.setHignEducation("11"); employeeInfo.setHignEducation("11");
} }
if ("5".equals(employeeInfo.getHignEducation()) if ("5".equals(employeeInfo.getHignEducation())
...@@ -2718,7 +2747,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2718,7 +2747,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
empAddsMap.put(empAdd.getEmpIdcard(), empAdd); empAddsMap.put(empAdd.getEmpIdcard(), empAdd);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(empAdd.getEmpIdcard() + CommonConstants.COLON_STRING + "派单新增档案失败",e); log.error(empAdd.getEmpIdcard() + CommonConstants.COLON_STRING + "派单新增档案失败", e);
} }
} }
} }
...@@ -2731,7 +2760,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2731,7 +2760,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
EmpAddDispatchVo emp; EmpAddDispatchVo emp;
for (Map.Entry<String, EmpProjectDispatchVo> entry : projectsMap.entrySet()) { for (Map.Entry<String, EmpProjectDispatchVo> entry : projectsMap.entrySet()) {
projectAdd = entry.getValue(); projectAdd = entry.getValue();
if (Common.isNotNull(projectAdd.getPostUpdate()) && projectAdd.getPostUpdate()){ if (Common.isNotNull(projectAdd.getPostUpdate()) && projectAdd.getPostUpdate()) {
continue; continue;
} }
try { try {
...@@ -2758,9 +2787,9 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2758,9 +2787,9 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
.eq(TEmployeeInfo::getFileStatus, CommonConstants.ZERO_INT)); .eq(TEmployeeInfo::getFileStatus, CommonConstants.ZERO_INT));
if (Common.isNotNull(tEmployeeInfo)) { if (Common.isNotNull(tEmployeeInfo)) {
TEmployeeInfo tEmployeeInfoCompare = baseMapper.selectById(tEmployeeInfo.getId()); TEmployeeInfo tEmployeeInfoCompare = baseMapper.selectById(tEmployeeInfo.getId());
if (Common.isNotNull(tEmployeeInfo.getProjectNum())){ if (Common.isNotNull(tEmployeeInfo.getProjectNum())) {
tEmployeeInfo.setProjectNum(tEmployeeInfo.getProjectNum() + CommonConstants.ONE_INT); tEmployeeInfo.setProjectNum(tEmployeeInfo.getProjectNum() + CommonConstants.ONE_INT);
}else { } else {
tEmployeeInfo.setProjectNum(CommonConstants.ONE_INT); tEmployeeInfo.setProjectNum(CommonConstants.ONE_INT);
} }
...@@ -2770,11 +2799,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2770,11 +2799,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error(projectAdd.getEmpIdcard() + CommonConstants.COLON_STRING + "派单新增项目档案失败",e); log.error(projectAdd.getEmpIdcard() + CommonConstants.COLON_STRING + "派单新增项目档案失败", e);
} }
} }
} }
} }
private void updateProjectPost(Map<String, EmpProjectDispatchVo> projectsMap) { private void updateProjectPost(Map<String, EmpProjectDispatchVo> projectsMap) {
if (Common.isNotNull(projectsMap)) { if (Common.isNotNull(projectsMap)) {
EmpProjectDispatchVo projectAdd; EmpProjectDispatchVo projectAdd;
...@@ -2795,7 +2825,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2795,7 +2825,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
**/ **/
@Override @Override
public Boolean updateEmployeeInfoInsuranceStatus(EmpStatusVo vo) { public Boolean updateEmployeeInfoInsuranceStatus(EmpStatusVo vo) {
if (Common.isEmpty(vo) || null == vo.getEmpInfo() || vo.getEmpInfo().isEmpty()){ if (Common.isEmpty(vo) || null == vo.getEmpInfo() || vo.getEmpInfo().isEmpty()) {
return false; return false;
} }
for (EmpIdCardAndDeptVo emp : vo.getEmpInfo()) { for (EmpIdCardAndDeptVo emp : vo.getEmpInfo()) {
...@@ -2812,7 +2842,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2812,7 +2842,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
**/ **/
@Override @Override
public Boolean updateEmployeeInfoSalaryStatus(EmpStatusVo vo) { public Boolean updateEmployeeInfoSalaryStatus(EmpStatusVo vo) {
if (Common.isEmpty(vo) || null == vo.getEmpInfo() || vo.getEmpInfo().isEmpty()){ if (Common.isEmpty(vo) || null == vo.getEmpInfo() || vo.getEmpInfo().isEmpty()) {
return false; return false;
} }
for (EmpIdCardAndDeptVo emp : vo.getEmpInfo()) { for (EmpIdCardAndDeptVo emp : vo.getEmpInfo()) {
...@@ -2847,7 +2877,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2847,7 +2877,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
@Override @Override
public void updateContractStatus(String empId, int status) { public void updateContractStatus(String empId, int status) {
baseMapper.updateContractStatus(empId,status); baseMapper.updateContractStatus(empId, status);
} }
@Override @Override
...@@ -2875,7 +2905,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2875,7 +2905,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
* @return: com.yifu.cloud.plus.v1.yifu.archives.vo.HcmEmployeeInfoVO * @return: com.yifu.cloud.plus.v1.yifu.archives.vo.HcmEmployeeInfoVO
**/ **/
private HcmEmployeeInfoVO getHcmEmployeeInfoVoByIdCard(String idCard) { private HcmEmployeeInfoVO getHcmEmployeeInfoVoByIdCard(String idCard) {
HcmEmployeeInfoVO vo= new HcmEmployeeInfoVO(); HcmEmployeeInfoVO vo = new HcmEmployeeInfoVO();
// 基础信息 // 基础信息
vo.setArchiveBasic(baseMapper.getHcmArchiveBasicVo(idCard)); vo.setArchiveBasic(baseMapper.getHcmArchiveBasicVo(idCard));
vo.setArchiveJob(baseMapper.getHcmArchiveJobVo(idCard)); vo.setArchiveJob(baseMapper.getHcmArchiveJobVo(idCard));
...@@ -2885,6 +2915,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2885,6 +2915,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
vo.setContract(baseMapper.getHcmContractVo(idCard)); vo.setContract(baseMapper.getHcmContractVo(idCard));
return vo; return vo;
} }
/** /**
* @Author fxj * @Author fxj
* @Description 每年1月1号刷新在职和离职人员的年龄信息 公式:当前年-出生年 * @Description 每年1月1号刷新在职和离职人员的年龄信息 公式:当前年-出生年
...@@ -2902,12 +2933,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2902,12 +2933,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
@Override @Override
public R<TEmployeeInfo> getByIdAssociate(String id) { public R<TEmployeeInfo> getByIdAssociate(String id) {
if (Common.isEmpty(id)){ if (Common.isEmpty(id)) {
return R.failed(CommonConstants.PARAM_INFO_ERROR); return R.failed(CommonConstants.PARAM_INFO_ERROR);
} }
TEmployeeInfo employeeInfo = baseMapper.selectById(id); TEmployeeInfo employeeInfo = baseMapper.selectById(id);
if (Common.isEmpty(employeeInfo)){ if (Common.isEmpty(employeeInfo)) {
return R.failed(CommonConstants.NO_DATA_TO_HANDLE); return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
} }
TPreEmpDeclaration tPreEmpDeclaration = declarationMapper.getTPreEmpDeclarationList(); TPreEmpDeclaration tPreEmpDeclaration = declarationMapper.getTPreEmpDeclarationList();
employeeInfo.setTPreEmpDeclaration(tPreEmpDeclaration); employeeInfo.setTPreEmpDeclaration(tPreEmpDeclaration);
...@@ -2915,46 +2946,47 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2915,46 +2946,47 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
getEmpAttaInfo(employeeInfo); getEmpAttaInfo(employeeInfo);
return R.ok(employeeInfo); return R.ok(employeeInfo);
} }
/** /**
* @return
* @Author fxj * @Author fxj
* @Description 获取人员档案附件信息下载ZIP * @Description 获取人员档案附件信息下载ZIP
* @Date 11:13 2024/9/10 * @Date 11:13 2024/9/10
* @Param * @Param
* @return
**/ **/
@Override @Override
public void exportEmployeeFile(String id, HttpServletResponse response) throws Exception{ public void exportEmployeeFile(String id, HttpServletResponse response) throws Exception {
if (Common.isEmpty(id)){ if (Common.isEmpty(id)) {
throw new RuntimeException(CommonConstants.PARAM_IS_NOT_ERROR); throw new RuntimeException(CommonConstants.PARAM_IS_NOT_ERROR);
} }
TEmployeeInfo emp = baseMapper.selectById(id); TEmployeeInfo emp = baseMapper.selectById(id);
if (Common.isEmpty(emp)){ if (Common.isEmpty(emp)) {
throw new RuntimeException(CommonConstants.NO_DATA_TO_HANDLE); throw new RuntimeException(CommonConstants.NO_DATA_TO_HANDLE);
} }
List<TAttaInfo> handles = new ArrayList<>(); List<TAttaInfo> handles = new ArrayList<>();
HttpGet httpGet; HttpGet httpGet;
//初始化导出 response //初始化导出 response
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("content-type","application/octet-stream"); response.setHeader("content-type", "application/octet-stream");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION,"attachment; filename="+URLEncoder.encode(emp.getEmpName()+emp.getEmpIdcard(),"UTF-8")+".zip"); response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode(emp.getEmpName() + emp.getEmpIdcard(), "UTF-8") + ".zip");
ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(response.getOutputStream()); ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(response.getOutputStream());
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
// 获取人员档案所有的附件信息 // 获取人员档案所有的附件信息
getFilesInfo(id, handles); getFilesInfo(id, handles);
// 处理附件 压缩并下载 // 处理附件 压缩并下载
if (Common.isNotNull(handles)){ if (Common.isNotNull(handles)) {
try { try {
CloseableHttpResponse response1; CloseableHttpResponse response1;
HttpEntity entity; HttpEntity entity;
byte[] data; byte[] data;
HashMap<String,Integer> groupNameMap = new HashMap<>(); HashMap<String, Integer> groupNameMap = new HashMap<>();
ZipArchiveEntry entry; ZipArchiveEntry entry;
for (TAttaInfo fileAtta:handles){ for (TAttaInfo fileAtta : handles) {
httpGet = new HttpGet(fileAtta.getAttaUrl()); httpGet = new HttpGet(fileAtta.getAttaUrl());
response1 = httpClient.execute(httpGet); response1 = httpClient.execute(httpGet);
entity = response1.getEntity(); entity = response1.getEntity();
data = EntityUtils.toByteArray(entity); data = EntityUtils.toByteArray(entity);
entry = new ZipArchiveEntry(initFileName(fileAtta,groupNameMap)); entry = new ZipArchiveEntry(initFileName(fileAtta, groupNameMap));
zipOutput.putArchiveEntry(entry); zipOutput.putArchiveEntry(entry);
zipOutput.write(data); zipOutput.write(data);
zipOutput.closeArchiveEntry(); zipOutput.closeArchiveEntry();
...@@ -2970,15 +3002,15 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2970,15 +3002,15 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
List<TAttaInfo> attas; List<TAttaInfo> attas;
URL url; URL url;
// 获取其他附件 // 获取其他附件
List<TEmpOtherFile> otherFiles = otherFileService.list(Wrappers.<TEmpOtherFile>query().lambda().eq(TEmpOtherFile::getEmpId, id)); List<TEmpOtherFile> otherFiles = otherFileService.list(Wrappers.<TEmpOtherFile>query().lambda().eq(TEmpOtherFile::getEmpId, id));
if (Common.isNotNull(otherFiles)){ if (Common.isNotNull(otherFiles)) {
try { try {
for (TEmpOtherFile otherFile:otherFiles){ for (TEmpOtherFile otherFile : otherFiles) {
attas = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId,otherFile.getId())); attas = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, otherFile.getId()));
if (Common.isNotNull(attas)){ if (Common.isNotNull(attas)) {
for (TAttaInfo atta:attas){ for (TAttaInfo atta : attas) {
url = ossUtil.getObjectUrl(null, atta.getAttaSrc()); url = ossUtil.getObjectUrl(null, atta.getAttaSrc());
atta.setAttaUrl(url.toString().replace("http","https")); atta.setAttaUrl(url.toString().replace("http", "https"));
atta.setGroupName(otherFile.getAttaName()); atta.setGroupName(otherFile.getAttaName());
handles.add(atta); handles.add(atta);
} }
...@@ -2991,46 +3023,46 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2991,46 +3023,46 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 获取其他附件以外的附件如身份证正反面 // 获取其他附件以外的附件如身份证正反面
attas = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, id)); attas = attaInfoService.list(Wrappers.<TAttaInfo>query().lambda().eq(TAttaInfo::getDomainId, id));
if (Common.isNotNull(attas)) { if (Common.isNotNull(attas)) {
for (TAttaInfo atta:attas){ for (TAttaInfo atta : attas) {
if (CommonConstants.TWENTY_THREE_STRING.equals(atta.getRelationType())){ if (CommonConstants.TWENTY_THREE_STRING.equals(atta.getRelationType())) {
continue; continue;
} }
url = ossUtil.getObjectUrl(null, atta.getAttaSrc()); url = ossUtil.getObjectUrl(null, atta.getAttaSrc());
atta.setAttaUrl(url.toString().replace("http","https")); atta.setAttaUrl(url.toString().replace("http", "https"));
handles.add(atta); handles.add(atta);
} }
} }
} }
private String initFileName(TAttaInfo fileAtta,HashMap<String,Integer> groupNameMap ) { private String initFileName(TAttaInfo fileAtta, HashMap<String, Integer> groupNameMap) {
/** /**
* 关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单6招投标7业务评估8二维码9身份证 10 户口本 * 关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单6招投标7业务评估8二维码9身份证 10 户口本
* ;21(预入职申明签名);22(预入职确认签名);23(预入职pdf文件);0(最高教育经历);2(执业资格证书);24 身份证国徽 * ;21(预入职申明签名);22(预入职确认签名);23(预入职pdf文件);0(最高教育经历);2(执业资格证书);24 身份证国徽
* 25 户口本本人页26学信27预入职其他附件 * 25 户口本本人页26学信27预入职其他附件
*/ */
if (CommonConstants.NINE_STRING.equals(fileAtta.getRelationType())){ if (CommonConstants.NINE_STRING.equals(fileAtta.getRelationType())) {
return "身份证1"+fileAtta.getAttaType(); return "身份证1" + fileAtta.getAttaType();
}else if (CommonConstants.TWENTY_FOUR_STRING.equals(fileAtta.getRelationType())){ } else if (CommonConstants.TWENTY_FOUR_STRING.equals(fileAtta.getRelationType())) {
return "身份证2"+fileAtta.getAttaType(); return "身份证2" + fileAtta.getAttaType();
}else if (CommonConstants.TWENTY_ONE_STRING.equals(fileAtta.getRelationType())){ } else if (CommonConstants.TWENTY_ONE_STRING.equals(fileAtta.getRelationType())) {
return "签名1"+fileAtta.getAttaType(); return "签名1" + fileAtta.getAttaType();
}else if (CommonConstants.TWENTY_TWO_STRING.equals(fileAtta.getRelationType())){ } else if (CommonConstants.TWENTY_TWO_STRING.equals(fileAtta.getRelationType())) {
return "签名2"+fileAtta.getAttaType(); return "签名2" + fileAtta.getAttaType();
}else if (CommonConstants.TEN_STRING.equals(fileAtta.getRelationType())){ } else if (CommonConstants.TEN_STRING.equals(fileAtta.getRelationType())) {
return "户口本1"+fileAtta.getAttaType(); return "户口本1" + fileAtta.getAttaType();
}else if (CommonConstants.TWENTY_FIVE_STRING.equals(fileAtta.getRelationType())){ } else if (CommonConstants.TWENTY_FIVE_STRING.equals(fileAtta.getRelationType())) {
return "户口本2"+fileAtta.getAttaType(); return "户口本2" + fileAtta.getAttaType();
}else if (CommonConstants.TWENTY_SEVEN_STRING.equals(fileAtta.getRelationType())){ } else if (CommonConstants.TWENTY_SEVEN_STRING.equals(fileAtta.getRelationType())) {
if (Common.isNotNull(fileAtta.getGroupName())){ if (Common.isNotNull(fileAtta.getGroupName())) {
if (Common.isNotNull(groupNameMap.get(fileAtta.getGroupName()))){ if (Common.isNotNull(groupNameMap.get(fileAtta.getGroupName()))) {
groupNameMap.put(fileAtta.getGroupName(),groupNameMap.get(fileAtta.getGroupName())+1); groupNameMap.put(fileAtta.getGroupName(), groupNameMap.get(fileAtta.getGroupName()) + 1);
}else { } else {
groupNameMap.put(fileAtta.getGroupName(),1); groupNameMap.put(fileAtta.getGroupName(), 1);
} }
return fileAtta.getGroupName() + groupNameMap.get(fileAtta.getGroupName())+fileAtta.getAttaType(); return fileAtta.getGroupName() + groupNameMap.get(fileAtta.getGroupName()) + fileAtta.getAttaType();
} }
return fileAtta.getGroupName()+fileAtta.getAttaType(); return fileAtta.getGroupName() + fileAtta.getAttaType();
}else { } else {
return fileAtta.getAttaName(); return fileAtta.getAttaName();
} }
} }
...@@ -3041,4 +3073,711 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -3041,4 +3073,711 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return baseMapper.getListByIdCardList(idList); return baseMapper.getListByIdCardList(idList);
} }
/**
* @Description: 批量更新人员和银行信息
* @Author: hgw
* @Date: 2024/10/16 17:43
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
@Override
public R<List<PreUploadEmpImportTwoVo>> batchUpdateEmployeeAndBank(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("未找到项目!");
}
//对前端传递的文件进行校验
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;
ExcelSheetVo vo;
List<String> specialIdCardList = null;
int maxRow = 1000;
if (filename.endsWith(".xlsx")) {
voR = DiyExcelImportUtil.readXlsx(inputStream, specialIdCardList, false, paramVo.getSheetName(), maxRow);
} else {
return R.failed("请使用标准模板(高版本的EXCEL)导入!");
}
if (voR != null && voR.getCode() == CommonConstants.SUCCESS) {
vo = voR.getData();
} else {
return R.failed(voR == null ? "人员批量更新识别表格异常!" : voR.getMsg());
}
String[] modelTitle = {"员工姓名", "身份证号", "员工类型", "身份证开始日期", "身份证截止日期", "婚姻状况", "民族"
, "政治面貌", "手机号码", "邮箱", "户籍所在地-省", "户籍所在地-市", "户籍所在地-区/县", "户口性质", "档案所在地-省"
, "档案所在地-市", "档案所在地-区/县", "通信地址-省", "通信地址-市", "通信地址-区/县", "通信地址-详细地址"
, "备注", "是否大专及以上", "最高学历", "学校", "专业", "入学时间", "毕业时间", "紧急联系人姓名"
, "紧急联系人与本人关系", "联系地址-省", "联系地址-市", "联系地址-区/县", "联系地址-详细地址"
, "手机号码(紧急联系人)", "银行卡号", "开户总行", "开户省", "开户市", "开户支行", "计税月份"};
Map<String, String> modelTitleMap = new HashMap<>();
for (String title : modelTitle) {
modelTitleMap.put(title, title);
}
int modelLength = vo.getTitleList().size();
// 需要成对出现的表头
Map<String, Integer> pairsSchool = new HashMap<>();
pairsSchool.put("入学时间", CommonConstants.ZERO_INT);
pairsSchool.put("毕业时间", CommonConstants.ZERO_INT);
Map<String, Integer> pairsIdCard = new HashMap<>();
pairsIdCard.put("身份证开始日期", CommonConstants.ZERO_INT);
pairsIdCard.put("身份证截止日期", CommonConstants.ZERO_INT);
Map<String, Integer> pairsHuJi = new HashMap<>();
pairsHuJi.put("户籍所在省", CommonConstants.ZERO_INT);
pairsHuJi.put("户籍所在市", CommonConstants.ZERO_INT);
pairsHuJi.put("户籍所在县", CommonConstants.ZERO_INT);
Map<String, Integer> pairsDang = new HashMap<>();
pairsDang.put("档案所在省", CommonConstants.ZERO_INT);
pairsDang.put("档案所在市", CommonConstants.ZERO_INT);
pairsDang.put("档案所在县", CommonConstants.ZERO_INT);
Map<String, Integer> pairsTong = new HashMap<>();
pairsTong.put("通信地址-省", CommonConstants.ZERO_INT);
pairsTong.put("通信地址-市", CommonConstants.ZERO_INT);
pairsTong.put("通信地址-区/县", CommonConstants.ZERO_INT);
Map<String, Integer> pairsLian = new HashMap<>();
pairsLian.put("联系地址-省", CommonConstants.ZERO_INT);
pairsLian.put("联系地址-市", CommonConstants.ZERO_INT);
pairsLian.put("联系地址-区/县", CommonConstants.ZERO_INT);
Map<String, Integer> pairsKai = new HashMap<>();
pairsKai.put("开户省", CommonConstants.ZERO_INT);
pairsKai.put("开户市", CommonConstants.ZERO_INT);
// 1 验证表头:
ExcelColumnVo title;
// 标题行的内容
String titleStr;
if (vo.getTitleList() != null && !vo.getTitleList().isEmpty()) {
StringBuilder errorTitle = new StringBuilder();
for (int i = 0; i < vo.getTitleList().size(); i++) {
title = vo.getTitleList().get(i);
titleStr = title.getContent();
if (modelTitleMap.get(titleStr) == null) {
errorTitle.append("第").append((i + 1)).append("列表头:").append(titleStr).append("不存在模板中;");
}
// 验证联动表头
if (pairsSchool.get(titleStr) != null) {
pairsSchool.remove(titleStr);
}
if (pairsIdCard.get(titleStr) != null) {
pairsIdCard.remove(titleStr);
}
if (pairsHuJi.get(titleStr) != null) {
pairsHuJi.remove(titleStr);
}
if (pairsDang.get(titleStr) != null) {
pairsDang.remove(titleStr);
}
if (pairsTong.get(titleStr) != null) {
pairsTong.remove(titleStr);
}
if (pairsLian.get(titleStr) != null) {
pairsLian.remove(titleStr);
}
if (pairsKai.get(titleStr) != null) {
pairsKai.remove(titleStr);
}
}
if (pairsSchool.size() == 1) {
errorTitle.append("入学时间与毕业时间需要成对出现;");
}
if (pairsIdCard.size() == 1) {
errorTitle.append("身份证开始与截止日期需要成对出现;");
}
if (pairsHuJi.size() == 1 || pairsHuJi.size() == 2) {
errorTitle.append("户籍所在地省市县需要成对出现;");
}
if (pairsDang.size() == 1 || pairsDang.size() == 2) {
errorTitle.append("档案所在地省市县需要成对出现;");
}
if (pairsTong.size() == 1 || pairsTong.size() == 2) {
errorTitle.append("通信地址省市县需要成对出现;");
}
if (pairsLian.size() == 1 || pairsLian.size() == 2) {
errorTitle.append("联系地址省市县需要成对出现;");
}
if (pairsKai.size() == 1) {
errorTitle.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;
if (Common.isEmpty(bankRes) || bankRes.getData() == null || bankRes.getData().getBankMap() == null) {
return R.failed("获取薪资服务开户行信息失败!");
} else {
bankMap = bankRes.getData().getBankMap();
}
PreUploadEmpImportTwoVo detail;
List<String> mobileList = new ArrayList<>();
List<TCheckBankNo> bankList = new ArrayList<>();
YifuUser user = SecurityUtils.getUser();
TCheckBankNo bankCheck;
Map<Integer, String> titleMap = new HashMap<>();
Map<String, String> fieldMap = new HashMap<>();
// 得到类的所有field
Field[] allFields = PreUploadEmpImportTwoVo.class.getDeclaredFields();
// 从map中得到对应列的field
Field field;
// 将有注解的field存放到fieldsMap中
Map<String, Field> fieldsMap = new HashMap<>();
ExcelAttribute attr; //获取属性对应的注解属性
for (int i = 0; i < allFields.length; i++) {
field = allFields[i];
if (field.isAnnotationPresent(ExcelAttribute.class)) {
// 设置类的私有字段属性可访问
field.setAccessible(true);
fieldsMap.put(field.getName(), field);
attr = field.getAnnotation(ExcelAttribute.class);
if (attr != null) {
fieldMap.put(attr.name(), field.getName());
}
}
}
// 组装表头与内容的对应
for (int i = 0; i < vo.getTitleList().size(); i++) {
title = vo.getTitleList().get(i);
titleStr = title.getContent();
if (Common.isNotNull(titleStr) && fieldMap.get(titleStr) != null) {
titleMap.put(i, fieldMap.get(titleStr));
}
}
Class<?> fieldType; // 取得类型,并根据对象类型设置值
List<PreUploadEmpImportTwoVo> excelList = new ArrayList<>();
String idNumber = "empIdcard";
Map<String, Integer> phoneTitleMap = new HashMap<>();
phoneTitleMap.put("empPhone", CommonConstants.ZERO_INT);
phoneTitleMap.put("tel", CommonConstants.ZERO_INT);
phoneTitleMap.put("contractTel", CommonConstants.ZERO_INT);
String shuName;
String shuValue;
String dictValue;
// 必填项未填写
StringBuilder errorMust;
// 格式不正确
StringBuilder errorFormat;
// 校验是否通过
StringBuilder errorCheck;
// 不存在档案,则仅返回这个信息
String errorCur;
// 已存在的主档案Map
Map<String, String> empMap = new HashMap<>();
// 已存在的主档案
String curVo;
// 档案map
Map<String, TEmployeeInfo> existEmpMap = this.getMapByDeptId(paramVo.getDeptId());
Map<String, TEmpContactInfo> existContactMap = this.getTEmpContactInfoMapByDeptId(paramVo.getDeptId());
TEmployeeInfo saveEmp;
// 字典Map
Map<String, String> dictMap = new HashMap<>();
// 存放父级area的值
Map<String, String> parentAreaMap = new HashMap<>();
Map<String, Date> startDateMap;
// 手机号是否已存在
List<String> phoneList = new ArrayList<>();
String errorCurInfo = "该项目下无此员工,请核实";
String errorCurInfoStatus = "该人员档案状态未在档,请核实";
for (Map<String, String> rowMap : vo.getContentList()) {
curVo = null;
errorMust = new StringBuilder();
errorFormat = new StringBuilder();
errorCheck = new StringBuilder();
// 每一行都要初始化起始时间
startDateMap = new HashMap<>();
detail = new PreUploadEmpImportTwoVo();
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);
}
}
if (phoneTitleMap.get(shuName) != null && Common.isNotNull(shuValue)) {
phoneList.add(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 = DiyExcelImportUtil.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)) {
DiyExcelImportUtil.setFields(field, shuValue, fieldType, detail);
}
// 塞字典返回的值
if (Common.isNotNull(dictValue)) {
field = fieldsMap.get(shuName + "Value");
if (field != null) {
fieldType = field.getType();
if (Common.isNotNull(fieldType)) {
DiyExcelImportUtil.setFieldsValue(field, dictValue, fieldType, detail);
}
}
}
}
}
}
}
}
// 第一步:校验是否通过:身份证号是否有(反馈信息:身份证号不存在)→人员是否已在项(或已导入待审核)
// (反馈信息:人员已在项,如需更新信息,请点击“批量更新”入口更新;人员“待审核”,如需更新,可“审核不通过”再次导入)
if (Common.isNotNull(detail.getEmpIdcard())) {
saveEmp = existEmpMap.get(detail.getEmpIdcard());
errorCur = null;
// 档案存在
if (saveEmp != null) {
if (saveEmp.getFileStatus() == CommonConstants.ZERO_INT) {
// 第二步:其他信息并行校验
// 1必填项未填写:紧急联系人
// 2格式不正确:计税月份
// 3校验是否通过:姓名&身份证号是否一致、手机号是否真实、姓名&银行卡号是否一致
// 1必填项未填写:紧急联系人
// 有主档案,则判断附属信息是否联动必填
// 主的其他信息必填校验
if (Common.isEmpty(detail.getEmpIdcard())) {
errorMust.append("身份证号;");
}
// 2格式不正确:在循环里已经判断了
// 3校验是否通过:姓名&身份证号是否一致、手机号是否真实、姓名&银行卡号是否一致
if (Common.isNotNull(detail.getEmpName())) {
if (Common.isNotNull(detail.getBankNo())) {
bankCheck = new TCheckBankNo();
bankCheck.setBankNo(detail.getBankNo());
bankCheck.setName(detail.getEmpName());
bankList.add(bankCheck);
} else {
errorMust.append("有银行卡号则员工姓名必填;");
}
}
// 手机号码
if (Common.isNotNull(detail.getEmpPhone())) {
mobileList.add(detail.getEmpPhone());
}
// 手机号码(紧急联系人)
if (Common.isNotNull(detail.getTel())) {
mobileList.add(detail.getTel());
}
} else if (saveEmp.getFileStatus() == CommonConstants.ONE_INT) {
errorCur = errorCurInfoStatus;
}
} else {
errorCur = errorCurInfo;
}
if (Common.isNotNull(errorCur)) {
detail.setErrorInfo(errorCur);
empMap.put(detail.getEmpIdcard(), CommonConstants.ZERO_STRING);
} else {
StringBuilder errorInfo = new StringBuilder();
if (errorCheck.length() > 0) {
errorInfo.append("校验不通过:").append(errorCheck);
}
if (errorMust.length() > 0) {
errorInfo.append("必填项未填写:").append(errorMust);
}
if (errorFormat.length() > 0) {
errorInfo.append("格式不正确:").append(errorFormat);
}
detail.setErrorInfo(errorInfo.toString());
empMap.put(detail.getEmpIdcard(), CommonConstants.ZERO_STRING);
}
} else {
detail.setErrorInfo("身份证号不存在!");
}
excelList.add(detail);
}
// 先校验手机号是否已存在系统里
Map<String, TEmployeeInfo> existPhoneMap = new HashMap<>();
if (!phoneList.isEmpty()) {
List<TEmployeeInfo> phones = baseMapper.getListByPhone(phoneList);
for (TEmployeeInfo employeeInfo : phones) {
existPhoneMap.put(employeeInfo.getEmpPhone(), employeeInfo);
}
}
// 批量校验 卡号与手机号
Map<String, Boolean> bankNoMap = new HashMap<>();
Map<String, Boolean> phoneMap = 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();
}
}
Boolean resultB;
// 要保存的list
List<PreUploadEmpImportTwoVo> saveExcelList = new ArrayList<>();
List<TEmployeeInfo> saveList = new ArrayList<>();
// 返回的错误excel
List<PreUploadEmpImportTwoVo> errorList = new ArrayList<>();
// 用于查询预入职相关信息
List<String> idCardList = new ArrayList<>();
// 是否全部正确
boolean allTrue = true;
for (PreUploadEmpImportTwoVo info : excelList) {
errorCheck = new StringBuilder();
errorCur = info.getErrorInfo();
if (Common.isEmpty(errorCur) || !(errorCur.contains(errorCurInfo) || errorCur.contains(errorCurInfoStatus))) {
if (Common.isNotNull(info.getEmpName())) {
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())) {
checkPhoneInfo(errorCheck, existPhoneMap, phoneMap, info, info.getEmpPhone(), "手机号码");
}
// 手机号码(紧急联系人)
if (Common.isNotNull(info.getTel())) {
checkPhoneInfo(errorCheck, existPhoneMap, phoneMap, info, info.getTel(), "手机号码(紧急联系人)");
}
if (errorCheck.length() > 0) {
info.setErrorInfo(info.getErrorInfo() + "校验未通过:" + errorCheck);
allTrue = false;
} else if (Common.isEmpty(info.getErrorInfo())) {
// 全部验证成功
saveExcelList.add(info);
idCardList.add(info.getEmpIdcard());
} else {
allTrue = false;
}
} else {
allTrue = false;
}
errorList.add(info);
}
// 验证通过的,开始保存
if (!saveExcelList.isEmpty()) {
// 组装1 预入职 档案
String empId;
String empIdCard;
Date endDate = DateUtil.stringToDate("2999-12-31", DateUtil.ISO_EXPANDED_DATE_FORMAT);
// 原先的档案信息
TEmployeeInfo oldEmp;
// 新老档案vo
EmployeeNewOldVO newOld;
// 新老档案List
List<EmployeeNewOldVO> updateList = new ArrayList<>();
// 紧急联系人新增或更新
List<TEmpContactInfo> saveContact = new ArrayList<>();
TEmpContactInfo contact;
for (PreUploadEmpImportTwoVo excel : saveExcelList) {
saveEmp = existEmpMap.get(excel.getEmpIdcard());
if (saveEmp != null) {
empId = saveEmp.getId();
empIdCard = saveEmp.getEmpIdcard();
// 可以更新
oldEmp = new TEmployeeInfo();
BeanUtil.copyProperties(saveEmp, oldEmp);
if (Common.isNotNull(excel.getEmpPhone())) {
saveEmp.setEmpPhone(excel.getEmpPhone());
}
if (Common.isNotNull(excel.getEmpMarriStatusValue())) {
saveEmp.setEmpMarriStatus(excel.getEmpMarriStatusValue());
}
// 校验字典数据是否正确-民族
if (Common.isNotNull(excel.getEmpNationalValue())) {
saveEmp.setEmpNational(excel.getEmpNationalValue());
}
// 校验字典数据是否正确-政治面貌
if (Common.isNotNull(excel.getPoliticalStatusValue())) {
saveEmp.setPoliticalStatus(excel.getPoliticalStatusValue());
}
// 校验字典数据是否正确-户口性质
if (Common.isNotNull(excel.getEmpRegisTypeValue())) {
saveEmp.setEmpRegisType(excel.getEmpRegisTypeValue());
}
// 校验字典数据是否正确-最高学历
if (Common.isNotNull(excel.getEducationNameValue())) {
saveEmp.setHignEducation(excel.getEducationNameValue());
}
// 校验字典数据是否正确-员工类型
if (Common.isNotNull(excel.getEmpNatrueValue())) {
saveEmp.setEmpNatrue(excel.getEmpNatrueValue());
}
// 户籍所在地
if (Common.isNotNull(excel.getIdProvinceValue())) {
saveEmp.setIdProvince(Integer.parseInt(excel.getIdProvinceValue()));
}
if (Common.isNotNull(excel.getIdCityValue())) {
saveEmp.setIdCity(Integer.parseInt(excel.getIdCityValue()));
}
if (Common.isNotNull(excel.getIdTownValue())) {
saveEmp.setIdTown(Integer.parseInt(excel.getIdTownValue()));
}
if (Common.isNotNull(excel.getIsCollegeValue())) {
saveEmp.setIsCollege(Integer.parseInt(excel.getIsCollegeValue()));
}
if (Common.isNotNull(excel.getValidityStartValue())) {
saveEmp.setValidityStart(excel.getValidityStartValue());
}
if (Common.isNotNull(excel.getValidityEnd())) {
if ("长期".equals(excel.getValidityEnd())) {
saveEmp.setValidityEnd(endDate);
} else {
saveEmp.setValidityEnd(excel.getValidityEndValue());
}
}
// 档案所在地
if (Common.isNotNull(excel.getFileProvinceValue())) {
saveEmp.setFileProvince(Integer.parseInt(excel.getFileProvinceValue()));
}
if (Common.isNotNull(excel.getFileCityValue())) {
saveEmp.setFileCity(Integer.parseInt(excel.getFileCityValue()));
}
if (Common.isNotNull(excel.getFileTownValue())) {
saveEmp.setFileTown(Integer.parseInt(excel.getFileTownValue()));
}else {
saveEmp.setFileTown(null);
}
// 邮箱
if (Common.isNotNull(excel.getEmpEmail())) {
saveEmp.setEmpEmail(excel.getEmpEmail());
}
if (Common.isNotNull(excel.getSchool())) {
saveEmp.setSchool(excel.getSchool());
}
if (Common.isNotNull(excel.getMajor())) {
saveEmp.setMajor(excel.getMajor());
}
// 通信地址所在地
if (Common.isNotNull(excel.getContactProvinceValue())) {
saveEmp.setContactProvince(excel.getContactProvinceValue());
}
if (Common.isNotNull(excel.getContactCityValue())) {
saveEmp.setContactCity(excel.getContactCityValue());
}
if (Common.isNotNull(excel.getContactTownValue())) {
saveEmp.setContactTown(excel.getContactTownValue());
}
if (Common.isNotNull(excel.getContactAddress())) {
saveEmp.setContactAddress(excel.getContactAddress());
}
if (Common.isNotNull(excel.getRemark())) {
saveEmp.setRemark(excel.getRemark());
}
if (Common.isNotNull(excel.getEntryDateValue())) {
saveEmp.setAdmissionDate(excel.getEntryDateValue());
}
if (Common.isNotNull(excel.getGradutionDateValue())) {
saveEmp.setGradutionDate(excel.getGradutionDateValue());
}
if (Common.isNotNull(excel.getBankNo())) {
saveEmp.setBankNo(excel.getBankNo());
}
if (Common.isNotNull(excel.getBankName())) {
saveEmp.setBankName(excel.getBankName());
}
if (Common.isNotNull(excel.getBankSubName())) {
saveEmp.setBankSubName(excel.getBankSubName());
}
if (Common.isNotNull(excel.getBankProvinceValue())) {
saveEmp.setBankProvince(excel.getBankProvinceValue());
}
if (Common.isNotNull(excel.getBankCityValue())) {
saveEmp.setBankCity(excel.getBankCityValue());
}
if (Common.isNotNull(excel.getTaxMonthValue())) {
saveEmp.setTaxMonth(excel.getTaxMonthValue());
}
// 更新时,不需要更新其余信息
newOld = new EmployeeNewOldVO();
newOld.setNewEmployee(saveEmp);
newOld.setOldEmployee(oldEmp);
updateList.add(newOld);
saveEmp.setUpdateBy(user.getId());
saveEmp.setUpdateTime(LocalDateTime.now());
saveList.add(saveEmp);
if (Common.isNotNull(excel.getRelationProvinceValue())
|| Common.isNotNull(excel.getAddress())
|| Common.isNotNull(excel.getTel())
|| Common.isNotNull(excel.getRelationType())
|| Common.isNotNull(excel.getContactEmpName())) {
contact = existContactMap.get(excel.getEmpIdcard());
if (contact == null) {
contact = new TEmpContactInfo();
}
contact.setEmpId(empId);
contact.setEmpIdcard(empIdCard);
if (Common.isNotNull(excel.getRelationProvinceValue())) {
contact.setRelationProvince(excel.getRelationProvinceValue());
}
if (Common.isNotNull(excel.getRelationCityValue())) {
contact.setRelationCity(excel.getRelationCityValue());
}
if (Common.isNotNull(excel.getRelationTownValue())) {
contact.setRelationTown(excel.getRelationTownValue());
}
if (Common.isNotNull(excel.getAddress())) {
contact.setAddress(excel.getAddress());
}
if (Common.isNotNull(excel.getTel())) {
contact.setTel(excel.getTel());
}
if (Common.isNotNull(excel.getRelationType())) {
contact.setRelationType(excel.getRelationType());
}
if (Common.isNotNull(excel.getContactEmpName())) {
contact.setEmpName(excel.getContactEmpName());
}
saveContact.add(contact);
}
}
}
// 紧急联系人信息
if (!saveContact.isEmpty()) {
tEmpContactInfoService.saveOrUpdateBatch(saveContact);
}
// 更新
this.updateBatchById(saveList);
// 更新学历-房
this.saveOrUpdateEducation(saveList);
// 记录变更日志
for (EmployeeNewOldVO newOldInfo : updateList) {
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0]
, newOldInfo.getOldEmployee().getId(), ""
, newOldInfo.getOldEmployee(), newOldInfo.getNewEmployee());
}
}
if (allTrue) {
//数据保存
return R.ok();
} else {
return R.failed(errorList);
}
} else {
return R.failed("未识别到表格内容行!请检查表格!");
}
}
private void checkPhoneInfo(StringBuilder errorCheck, Map<String, TEmployeeInfo> existPhoneMap
, Map<String, Boolean> phoneMap, PreUploadEmpImportTwoVo info, String phone, String phoneName) {
Boolean resultB;
TEmployeeInfo existEmp = existPhoneMap.get(phone);
// 手机号已存在
if (existEmp != null) {
// 非自己使用的
if (!existEmp.getEmpIdcard().equals(info.getEmpIdcard())) {
errorCheck.append(phoneName).append("已被其他身份证使用;");
}
} else {
resultB = phoneMap.get(phone);
if (resultB != null) {
if (!resultB) {
errorCheck.append(phoneName).append("校验不通过;");
}
} else {
errorCheck.append(phoneName).append("未校验;");
}
}
}
/**
* @param deptId 项目Id
* @Description: 更具项目找人
* @Author: hgw
* @Date: 2024/10/17 16:33
* @return: java.util.Map<java.lang.String, com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo>
**/
private Map<String, TEmployeeInfo> getMapByDeptId(String deptId) {
Map<String, TEmployeeInfo> preMap = new HashMap<>();
if (Common.isNotNull(deptId)) {
List<TEmployeeInfo> preList = baseMapper.getListByDeptId(deptId);
if (preList != null && !preList.isEmpty()) {
for (TEmployeeInfo pre : preList) {
preMap.put(pre.getEmpIdcard(), pre);
}
}
}
return preMap;
}
private Map<String, TEmpContactInfo> getTEmpContactInfoMapByDeptId(String deptId) {
Map<String, TEmpContactInfo> contactMap = new HashMap<>();
if (Common.isNotNull(deptId)) {
List<TEmpContactInfo> contactList = tEmpContactInfoService.getContactByDeptId(deptId);
if (contactList != null && !contactList.isEmpty()) {
for (TEmpContactInfo contact : contactList) {
contactMap.put(contact.getEmpIdcard(), contact);
}
}
}
return contactMap;
}
} }
/*
* 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.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.lock.annotation.Lock4j;
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.pig4cloud.plugin.excel.vo.ErrorMessage;
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.constants.EmployeeConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeContractAuditMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TPreEmpDeclarationMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelColumnVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelSheetVo;
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.config.DaprUpmsProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.http.HttpHeaders;
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.time.LocalDateTime;
import java.util.*;
/**
* 人员档案表
*
* @author hgw
* @date 2022-06-20 09:55:06
*/
@Log4j2
@Service
@RequiredArgsConstructor
@EnableConfigurationProperties({DaprUpmsProperties.class, DaprCheckProperties.class, DaprSalaryProperties.class})
public class TEmployeeInfoServiceImplCopy extends ServiceImpl<TEmployeeInfoMapper, TEmployeeInfo> {
// 缓存信息
private final CacheManager cacheManager;
private final TEmployeeProjectService tEmployeeProjectService;
private final DaprCheckProperties daprCheckProperties;
private final DaprUpmsProperties daprUpmsProperties;
private final DaprSalaryProperties salaryProperties;
private final TEmployeeLogService tEmployeeLogService;
private final TEmpEducationService tEmpEducationService;
private final TSettleDomainService tSettleDomainService;
private final TEmployeeContractAuditMapper contractAuditMapper;
private final TEmployeeContractInfoService contractServicer;
private final TEmpOtherFileService otherFileService;
private final TAttaInfoService attaInfoService;
private final TEmpOtherFileService empOtherFileService;
private final TPreEmpDeclarationMapper declarationMapper;
@Autowired
private OSSUtil ossUtil;
private R<List<ErrorMessage>> batchUpdateCore(List<EmployeeInsertVO> excelVOList,
List<ErrorMessage> errorMessageList,
String[] exportFields) {
YifuUser user = SecurityUtils.getUser();
Set<String> errorMsg;
if (user == null || Common.isEmpty(user.getId())) {
errorMsg = new HashSet<>();
errorMsg.add(CommonConstants.PLEASE_LOG_IN);
errorMessageList.add(new ErrorMessage(2L, errorMsg));
return R.failed(errorMessageList);
}
if (excelVOList == null || excelVOList.isEmpty()) {
errorMsg = new HashSet<>();
errorMsg.add(CommonConstants.DATA_CAN_NOT_EMPTY);
errorMessageList.add(new ErrorMessage(2L, errorMsg));
return R.failed(errorMessageList);
}
//初试化表头用于校验省市县
HashMap<String,String> headMap = new HashMap<>();
if (Common.isNotNull(exportFields)){
for (int i=0; i < exportFields.length; i++){
headMap.put(exportFields[i],exportFields[i]);
}
}
// 通用校验获取失败的数据
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
// 获取身份证、手机号列表,批量查询档案
List<String> idCardList = new ArrayList<>();
List<String> phoneList = new ArrayList<>();
long lineNum;
for (int i = 0; i < excelVOList.size(); i++) {
lineNum = i + 2L;
// 判空
if (Common.isEmpty(excelVOList.get(i).getEmpIdcard())) {
errorMsgMap.put(lineNum, new ErrorMessage("员工身份证必填"));
} else {
idCardList.add(excelVOList.get(i).getEmpIdcard());
}
if (Common.isNotNull(excelVOList.get(i).getEmpPhone())) {
phoneList.add(excelVOList.get(i).getEmpPhone());
}
if (Common.isEmpty(excelVOList.get(i).getEmpName())) {
errorMsgMap.put(lineNum, new ErrorMessage("员工姓名必填"));
}
}
if (Common.isNotNull(errorMessageList)) {
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(), errorMessage));
}
// 查找档案库
Map<String, TEmployeeInfo> existEmpMap = new HashMap<>();
Map<String, TEmployeeInfo> existPhoneMap = new HashMap<>();
if (!idCardList.isEmpty()) {
List<TEmployeeInfo> cards = baseMapper.getListByIdCard(idCardList);
for (TEmployeeInfo employeeInfo : cards) {
existEmpMap.put(employeeInfo.getEmpIdcard(), employeeInfo);
}
}
if (!phoneList.isEmpty()) {
List<TEmployeeInfo> phones = baseMapper.getListByPhone(phoneList);
for (TEmployeeInfo employeeInfo : phones) {
existPhoneMap.put(employeeInfo.getEmpPhone(), employeeInfo);
}
}
// 个性化校验逻辑
EmployeeInsertVO excel;
// 需要保存的档案信息
TEmployeeInfo saveEmp;
// 原先的档案信息
TEmployeeInfo oldEmp;
// 已存在的档案
TEmployeeInfo existEmp;
// 存储可保存的档案信息
List<TEmployeeInfo> saveList = new ArrayList<>();
// 新老档案vo
EmployeeNewOldVO newOld;
// 新老档案List
List<EmployeeNewOldVO> updateList = new ArrayList<>();
// 调用字典服务,渲染字典值
R<Map<String, Map<String, Map<String, String>>>> dictR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/dict/inner/getDictToLable", null, Map.class, SecurityConstants.FROM_IN);
Map<String, Map<String, Map<String, String>>> dictDataMap;
Map<String, Map<String, String>> dictMap;
// 婚姻状况
Map<String, String> empMarriMap;
// 民族
Map<String, String> empNationalMap;
// 政治面貌
Map<String, String> empPoliticalMap;
// 户口性质
Map<String, String> regisTypeMap;
// 最高学历
Map<String, String> educationMap;
// 员工类型
Map<String, String> empNatrueMap;
if (dictR == null || dictR.getData() == null) {
return R.failed("获取字典失败!");
} else {
dictDataMap = dictR.getData();
dictMap = dictDataMap.get("data");
empMarriMap = dictMap.get("emp_married");
empNationalMap = dictMap.get("emp_national");
empPoliticalMap = dictMap.get("emp_political");
regisTypeMap = dictMap.get("emp_registype");
educationMap = dictMap.get("education");
empNatrueMap = dictMap.get("emp_natrue");
}
String areaStr;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i);
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get((excel.getRowIndex())))) {
continue;
}
errorMsg = new HashSet<>();
saveEmp = existEmpMap.get(excel.getEmpIdcard());
// 档案存在
if (saveEmp != null) {
// 档案在职
if (saveEmp.getFileStatus() == CommonConstants.ZERO_INT) {
// 可以更新
oldEmp = new TEmployeeInfo();
BeanUtil.copyProperties(saveEmp, oldEmp);
if (Common.isNotNull(excel.getEmpPhone())) {
saveEmp.setEmpPhone(excel.getEmpPhone());
}
// 校验手机号
if (Common.isNotNull(excel.getEmpPhone())) {
existEmp = existPhoneMap.get(excel.getEmpPhone());
// 手机号已存在
if (existEmp != null) {
// 非自己使用的
if (!existEmp.getEmpIdcard().equals(excel.getEmpIdcard())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_EXIST_ERROR, existEmp.getEmpIdcard()));
}
} else {
// 调用校验服务-校验手机号
TCheckMobile checkMobile = new TCheckMobile();
checkMobile.setMobile(excel.getEmpPhone());
R<TCheckMobile> a = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkOneMobile", checkMobile, TCheckMobile.class, SecurityConstants.FROM_IN);
if (a != null && a.getData() != null) {
checkMobile = a.getData();
if (checkMobile != null && Common.isNotNull(checkMobile.getStatus())) {
if (!CommonConstants.ONE_STRING.equals(checkMobile.getStatus())) {
errorMsg.add(checkMobile.getMessage());
}
} else {
errorMsg.add(EmployeeConstants.CHECK_ERROR);
}
} else {
errorMsg.add(EmployeeConstants.CHECK_ERROR);
}
}
}
// 校验字典数据是否正确-婚姻
if (Common.isNotNull(excel.getEmpMarriStatus())) {
if (empMarriMap.get(excel.getEmpMarriStatus()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_MARRIED_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpMarriStatus(empMarriMap.get(excel.getEmpMarriStatus()));
}
}
// 校验字典数据是否正确-民族
if (Common.isNotNull(excel.getEmpNational())) {
if (empNationalMap.get(excel.getEmpNational()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NATIONAL_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpNational(empNationalMap.get(excel.getEmpNational()));
}
}
// 校验字典数据是否正确-政治面貌
if (Common.isNotNull(excel.getPoliticalStatus())) {
if (empPoliticalMap.get(excel.getPoliticalStatus()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_POLITICAL_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setPoliticalStatus(empPoliticalMap.get(excel.getPoliticalStatus()));
}
}
// 校验字典数据是否正确-户口性质
if (Common.isNotNull(excel.getEmpRegisType())) {
if (regisTypeMap.get(excel.getEmpRegisType()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_REGISTYPE_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpRegisType(regisTypeMap.get(excel.getEmpRegisType()));
}
}
// 校验字典数据是否正确-最高学历
if (Common.isNotNull(excel.getHignEducation())) {
if (educationMap.get(excel.getHignEducation()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_EDUCATION_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setHignEducation(educationMap.get(excel.getHignEducation()));
}
}
// 校验字典数据是否正确-员工类型
if (Common.isNotNull(excel.getEmpNatrue())) {
if (empNatrueMap.get(excel.getEmpNatrue()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NATRUE_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpNatrue(empNatrueMap.get(excel.getEmpNatrue()));
}
}
// 户籍所在地
if (Common.isNotNull(excel.getIdProvince())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdProvince().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setIdProvince(Integer.parseInt(areaStr));
}
}
if (Common.isNotNull(excel.getIdCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdCity().trim() + CommonConstants.DOWN_LINE_STRING + excel.getIdProvince().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setIdCity(Integer.parseInt(areaStr));
}
}
if (Common.isNotNull(excel.getIdTown())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdTown().trim() + CommonConstants.DOWN_LINE_STRING + excel.getIdCity().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setIdTown(Integer.parseInt(areaStr));
}
}
if (Common.isNotNull(excel.getIsCollege())) {
if (CommonConstants.IS_TRUE.equals(excel.getIsCollege())) {
saveEmp.setIsCollege(CommonConstants.ONE_INT);
} else if (CommonConstants.IS_FALSE.equals(excel.getIsCollege())) {
saveEmp.setIsCollege(CommonConstants.ZERO_INT);
} else {
errorMsg.add(EmployeeConstants.IS_OR_NOT);
}
}
if (Common.isNotNull(excel.getValidityStart())) {
saveEmp.setValidityStart(excel.getValidityStart());
}
if (Common.isNotNull(excel.getValidityEnd())) {
//MVP1.6.7-huyc-身份证期限截止日期调整-校验日期
if (!"长期".equals(excel.getValidityEnd()) && !DateUtil.checkStringToDate(
excel.getValidityEnd(),DateUtil.ISO_EXPANDED_DATE_FORMAT)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_END, excel.getEmpIdcard()));
} else {
if ("长期".equals(excel.getValidityEnd())) {
saveEmp.setValidityEnd(DateUtil.stringToDate("2999-12-31", DateUtil.ISO_EXPANDED_DATE_FORMAT));
} else {
saveEmp.setValidityEnd(DateUtil.stringToDate(excel.getValidityEnd(), DateUtil.ISO_EXPANDED_DATE_FORMAT));
}
}
}
// 档案所在地
if (Common.isNotNull(excel.getFileProvince())) {
saveEmp.setFileProvince(Integer.parseInt(excel.getFileProvince()));
}
if (Common.isNotNull(excel.getFileCity())) {
saveEmp.setFileCity(Integer.parseInt(excel.getFileCity()));
}
if (Common.isNotNull(excel.getFileTown())) {
saveEmp.setFileTown(Integer.parseInt(excel.getFileTown()));
}else {
saveEmp.setFileTown(null);
}
// 邮箱
if (Common.isNotNull(excel.getEmpEmail())) {
if (excel.getEmpEmail().contains("@")) {
if (excel.getEmpEmail().length() < 50) {
saveEmp.setEmpEmail(excel.getEmpEmail());
} else {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_EMAIL_LENGTH, excel.getEmpIdcard()));
}
} else {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_EMAIL_CHECK, excel.getEmpIdcard()));
}
}
if (Common.isNotNull(excel.getSchool())) {
if (excel.getSchool().length() > 50) {
errorMsg.add(EmployeeConstants.SCHOOL_LENGTH);
} else {
saveEmp.setSchool(excel.getSchool());
}
}
if (Common.isNotNull(excel.getMajor())) {
if (excel.getMajor().length() > 50) {
errorMsg.add(EmployeeConstants.MAJOR_LENGTH);
} else {
saveEmp.setMajor(excel.getMajor());
}
}
// 通信地址所在地
if (Common.isNotNull(excel.getContactProvince())) {
saveEmp.setContactProvince(excel.getContactProvince());
}
if (Common.isNotNull(excel.getContactCity())) {
saveEmp.setContactCity(excel.getContactCity());
}
if (Common.isNotNull(excel.getContactTown())) {
saveEmp.setContactTown(excel.getContactTown());
}
if (Common.isNotNull(excel.getContactAddress())) {
if (excel.getContactAddress().length() > 200) {
errorMsg.add(EmployeeConstants.CONTACT_ADDRESS_LENGTH);
} else {
saveEmp.setContactAddress(excel.getContactAddress());
}
}
// 档案地和通信地址 校验
if (Common.isNotNull(headMap.get("档案所在省"))
|| Common.isNotNull(headMap.get("档案所在市"))){
if (Common.isEmpty(excel.getFileProvince())) {
errorMsg.add(EmployeeConstants.FILE_PROVINCE);
}
if (Common.isEmpty(excel.getFileCity())) {
errorMsg.add(EmployeeConstants.FILE_PROVINCE);
}
}
if (Common.isNotNull(headMap.get("通信地址-省"))
|| Common.isNotNull(headMap.get("通信地址-市"))
|| Common.isNotNull(headMap.get("通信地址-区/县"))){
if (Common.isEmpty(excel.getContactTown())) {
errorMsg.add(EmployeeConstants.CONTACT_PROVINCE);
}
}
if (Common.isNotNull(headMap.get("通信地址-详细地址"))){
if (Common.isEmpty(excel.getContactAddress())) {
errorMsg.add(EmployeeConstants.CONTACT_ADDRESS);
}
}
if (Common.isNotNull(excel.getRemark())) {
if (excel.getRemark().length() > 200) {
errorMsg.add(EmployeeConstants.REMARL_LENGTH);
} else {
saveEmp.setRemark(excel.getRemark());
}
}
if (Common.isNotNull(excel.getAdmissionDate())) {
saveEmp.setAdmissionDate(excel.getAdmissionDate());
}
if (Common.isNotNull(excel.getGradutionDate())) {
saveEmp.setGradutionDate(excel.getGradutionDate());
}
if (Common.isNotNull(excel.getPost())) {
if (excel.getPost().length() > 20) {
errorMsg.add(EmployeeConstants.POST_LENGTH);
} else {
saveEmp.setPost(excel.getPost());
}
}
if (Common.isNotNull(excel.getDeptNo())) {
if (excel.getDeptNo().length() > 20) {
errorMsg.add(EmployeeConstants.DEPT_NO_LENGTH);
} else {
saveEmp.setDeptNo(excel.getDeptNo());
}
}
// 判断空值
//this.judgeNull(errorMsg, saveEmp);
// 更新时,不需要更新其余信息
newOld = new EmployeeNewOldVO();
newOld.setNewEmployee(saveEmp);
newOld.setOldEmployee(oldEmp);
updateList.add(newOld);
saveEmp.setUpdateBy(user.getId());
saveEmp.setUpdateTime(LocalDateTime.now());
saveList.add(saveEmp);
} else if (saveEmp.getFileStatus() == CommonConstants.ONE_INT) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NOT_EXISTS, excel.getEmpIdcard()));
}
} else {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NOT_EXISTS, excel.getEmpIdcard()));
}
// 数据合法情况
if (!CollUtil.isEmpty(errorMsg)) {
// 数据不合法
errorMessageList.add(new ErrorMessage(excel.getRowIndex().longValue(), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
} else {
// 更新
this.updateBatchById(saveList);
// 更新学历-房
//this.saveOrUpdateEducation(saveList);
// 记录变更日志
for (EmployeeNewOldVO newOldInfo : updateList) {
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0]
, newOldInfo.getOldEmployee().getId(), ""
, newOldInfo.getOldEmployee(), newOldInfo.getNewEmployee());
}
}
return R.ok();
}
}
...@@ -24,7 +24,7 @@ import lombok.extern.log4j.Log4j2; ...@@ -24,7 +24,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* 预入职-员工 * 预入职-员工
* *
* @author hgw * @author hgw
* @date 2024-06-17 11:24:00 * @date 2024-06-17 11:24:00
...@@ -33,7 +33,7 @@ import org.springframework.stereotype.Service; ...@@ -33,7 +33,7 @@ import org.springframework.stereotype.Service;
@Service @Service
public class TPreEmpDeclarationServiceImpl extends ServiceImpl<TPreEmpDeclarationMapper, TPreEmpDeclaration> implements TPreEmpDeclarationService { public class TPreEmpDeclarationServiceImpl extends ServiceImpl<TPreEmpDeclarationMapper, TPreEmpDeclaration> implements TPreEmpDeclarationService {
/** /**
* 预入职-员工明简单分页查询 * 预入职-员工明简单分页查询
* *
* @return * @return
*/ */
......
...@@ -45,6 +45,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil; ...@@ -45,6 +45,8 @@ 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.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.alisms.AliSmsResult; import com.yifu.cloud.plus.v1.yifu.common.core.util.alisms.AliSmsResult;
import com.yifu.cloud.plus.v1.yifu.common.core.util.alisms.SmsUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.alisms.SmsUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelColumnVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; 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.DaprCheckProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties; import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties;
...@@ -52,8 +54,6 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil; ...@@ -52,8 +54,6 @@ 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.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; 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.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 com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -97,7 +97,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -97,7 +97,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
private final TPreEmpWorkRecordingService tPreEmpWorkRecordingService; private final TPreEmpWorkRecordingService tPreEmpWorkRecordingService;
// 预入职-紧急联络人 // 预入职-紧急联络人
private final TPreEmpContactInfoService tPreEmpContactInfoService; private final TPreEmpContactInfoService tPreEmpContactInfoService;
// 预入职-员工 // 预入职-员工
private final TPreEmpDeclarationService tPreEmpDeclarationService; private final TPreEmpDeclarationService tPreEmpDeclarationService;
// 预入职-员工伤残信息表 // 预入职-员工伤残信息表
private final TPreEmpDisabilityInfoService tPreEmpDisabilityInfoService; private final TPreEmpDisabilityInfoService tPreEmpDisabilityInfoService;
...@@ -264,7 +264,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -264,7 +264,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
main.setBusinessSecondType(dept.getBusinessSecondType()); main.setBusinessSecondType(dept.getBusinessSecondType());
main.setBusinessThirdType(dept.getBusinessThirdType()); main.setBusinessThirdType(dept.getBusinessThirdType());
main.setStatus(CommonConstants.FIVE_STRING); main.setStatus(CommonConstants.FIVE_STRING);
// 预入职-员工 // 预入职-员工
TPreEmpDeclaration tPreEmpDeclaration; TPreEmpDeclaration tPreEmpDeclaration;
if (Common.isNotNull(main.getDeclarationId())) { if (Common.isNotNull(main.getDeclarationId())) {
tPreEmpDeclaration = tPreEmpDeclarationService.getById(main.getDeclarationId()); tPreEmpDeclaration = tPreEmpDeclarationService.getById(main.getDeclarationId());
...@@ -332,7 +332,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -332,7 +332,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
String id = main.getId(); String id = main.getId();
vo.setMain(main); vo.setMain(main);
if (vo.getTpreEmpDeclaration() == null) { if (vo.getTpreEmpDeclaration() == null) {
// 预入职-员工 // 预入职-员工
TPreEmpDeclaration tPreEmpDeclaration; TPreEmpDeclaration tPreEmpDeclaration;
if (Common.isNotNull(main.getDeclarationId())) { if (Common.isNotNull(main.getDeclarationId())) {
tPreEmpDeclaration = tPreEmpDeclarationService.getById(main.getDeclarationId()); tPreEmpDeclaration = tPreEmpDeclarationService.getById(main.getDeclarationId());
...@@ -778,7 +778,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -778,7 +778,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
// 预入职-紧急联络人 // 预入职-紧急联络人
TPreEmpContactInfo tPreEmpContactInfo = tPreEmpContactInfoService.getTPreEmpContactInfoList(id); TPreEmpContactInfo tPreEmpContactInfo = tPreEmpContactInfoService.getTPreEmpContactInfoList(id);
vo.setTpreEmpContactInfo(tPreEmpContactInfo); vo.setTpreEmpContactInfo(tPreEmpContactInfo);
// 预入职-员工 // 预入职-员工
TPreEmpDeclaration tPreEmpDeclaration; TPreEmpDeclaration tPreEmpDeclaration;
if (Common.isNotNull(main.getDeclarationId())) { if (Common.isNotNull(main.getDeclarationId())) {
tPreEmpDeclaration = tPreEmpDeclarationService.getById(main.getDeclarationId()); tPreEmpDeclaration = tPreEmpDeclarationService.getById(main.getDeclarationId());
...@@ -2578,10 +2578,10 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -2578,10 +2578,10 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
if (dept == null || Common.isEmpty(dept.getId())) { if (dept == null || Common.isEmpty(dept.getId())) {
return R.failed("未找到项目!"); return R.failed("未找到项目!");
} }
// 预入职-员工 // 预入职-员工
TPreEmpDeclaration tPreEmpDeclaration = tPreEmpDeclarationService.getTPreEmpDeclarationList(); TPreEmpDeclaration tPreEmpDeclaration = tPreEmpDeclarationService.getTPreEmpDeclarationList();
if (tPreEmpDeclaration == null || Common.isEmpty(tPreEmpDeclaration.getId())) { if (tPreEmpDeclaration == null || Common.isEmpty(tPreEmpDeclaration.getId())) {
return R.failed("请联系管理员添加员工明TPreEmpDeclaration数据!"); return R.failed("请联系管理员添加员工明TPreEmpDeclaration数据!");
} }
String declarId = tPreEmpDeclaration.getId(); String declarId = tPreEmpDeclaration.getId();
//对前端传递的文件进行校验 //对前端传递的文件进行校验
...@@ -2602,19 +2602,21 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -2602,19 +2602,21 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
List<String> specialIdCardList = null; List<String> specialIdCardList = null;
int maxRow = 1000; int maxRow = 1000;
if (filename.endsWith(".xlsx")) { if (filename.endsWith(".xlsx")) {
voR = readXlsx(inputStream, specialIdCardList, false, paramVo.getSheetName(), maxRow); voR = DiyExcelImportUtil.readXlsx(inputStream, specialIdCardList, false, paramVo.getSheetName(), maxRow);
} else {
return R.failed("请使用标准模板(高版本的EXCEL)导入!");
} }
if (voR != null && voR.getCode() == CommonConstants.SUCCESS) { if (voR != null && voR.getCode() == CommonConstants.SUCCESS) {
vo = voR.getData(); vo = voR.getData();
} else { } else {
return R.failed(voR == null ? "识别表格异常!" : voR.getMsg()); return R.failed(voR == null ? "预入职导入识别表格异常!" : voR.getMsg());
} }
String[] modelTitle = {"员工类型", "员工姓名", "身份证号", "身份证开始日期", "身份证截止日期", "婚姻状况", "民族" String[] modelTitle = {"员工类型", "员工姓名", "身份证号", "身份证开始日期", "身份证截止日期", "婚姻状况", "民族"
, "政治面貌", "手机号码", "邮箱", "户籍所在地-省", "户籍所在地-市", "户籍所在地-区/县", "户口性质", "档案所在地-省" , "政治面貌", "手机号码", "邮箱", "户籍所在地-省", "户籍所在地-市", "户籍所在地-区/县", "户口性质", "档案所在地-省"
, "档案所在地-市", "档案所在地-区/县", "通信地址-省", "通信地址-市", "通信地址-区/县", "通信地址-详细地址" , "档案所在地-市", "档案所在地-区/县", "通信地址-省", "通信地址-市", "通信地址-区/县", "通信地址-详细地址"
, "紧急联系人姓名", "与本人关系", "联系地址-省", "联系地址-市", "联系地址-区/县", "联系地址-详细地址" , "紧急联系人姓名", "紧急联系人与本人关系", "联系地址-省", "联系地址-市", "联系地址-区/县", "联系地址-详细地址"
, "手机号码(紧急联系人)", "学历", "学校", "专业", "教育开始时间", "教育结束时间", "是否为首份工作", "工作单位" , "手机号码(紧急联系人)", "学历", "学校", "专业", "教育开始时间", "教育结束时间", "是否为首份工作", "工作单位"
, "工作岗位", "开始工作日期", "结束工作日期", "成员姓名", "与本人关系", "手机号码(家庭成员)", "是否有职业资格证书" , "工作岗位", "开始工作日期", "结束工作日期", "家庭成员姓名", "家庭成员与本人关系", "手机号码(家庭成员)", "是否有职业资格证书"
, "申报年度", "职业资格名称", "是否曾被认定为工伤", "是否有职业病", "职业病名称", "是否有传染性疾病", "传染病名称" , "申报年度", "职业资格名称", "是否曾被认定为工伤", "是否有职业病", "职业病名称", "是否有传染性疾病", "传染病名称"
, "是否被劳动能力鉴定委员会鉴定为具有伤残等级", "伤残病名称", "伤残等级" , "是否被劳动能力鉴定委员会鉴定为具有伤残等级", "伤残病名称", "伤残等级"
, "是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种", "是否曾经或正在追究与承担过刑事责任" , "是否从事过井下、高空、高温、特别繁重体力劳动以及有毒有害工种", "是否曾经或正在追究与承担过刑事责任"
...@@ -2740,23 +2742,22 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -2740,23 +2742,22 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
if (Common.isNotNull(shuValue)) { if (Common.isNotNull(shuValue)) {
shuValue = shuValue.trim(); shuValue = shuValue.trim();
//校验字段是否符合要求 返回错误信息 //校验字段是否符合要求 返回错误信息
dictValue = this.validateUtil(shuValue, attr, errorFormat, dictMap, parentAreaMap, shuName, curVo != null, startDateMap); dictValue = DiyExcelImportUtil.validateUtil(shuValue, attr, errorFormat, dictMap, parentAreaMap, shuName, curVo != null, startDateMap);
//校验字段是否符合要求2 开户行 //校验字段是否符合要求2 开户行
if (curVo == null && "bankName".equals(shuName) && bankMap.get(shuValue) == null) { if (curVo == null && "bankName".equals(shuName) && bankMap.get(shuValue) == null) {
errorFormat.append(attr.name()).append("_不符合财务要求,请查薪资配置;"); errorFormat.append(attr.name()).append("_不符合财务要求,请查薪资配置;");
} }
fieldType = field.getType(); fieldType = field.getType();
if (Common.isNotNull(fieldType)) { if (Common.isNotNull(fieldType)) {
this.setFields(field, shuValue, attr, fieldType, detail); DiyExcelImportUtil.setFields(field, shuValue, fieldType, detail);
} }
// 塞字典返回的值 // 塞字典返回的值
if (Common.isNotNull(dictValue)) { if (Common.isNotNull(dictValue)) {
field = fieldsMap.get(shuName + "Value"); field = fieldsMap.get(shuName + "Value");
if (field != null) { if (field != null) {
attr = field.getAnnotation(ExcelAttribute.class);
fieldType = field.getType(); fieldType = field.getType();
if (Common.isNotNull(fieldType)) { if (Common.isNotNull(fieldType)) {
this.setFields(field, dictValue, attr, fieldType, detail); DiyExcelImportUtil.setFieldsValue(field, dictValue, fieldType, detail);
} }
} }
} }
...@@ -3077,6 +3078,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3077,6 +3078,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
TPreEmpProfessionalQualification tPreEmpProfessionalQualification; TPreEmpProfessionalQualification tPreEmpProfessionalQualification;
String mainId; String mainId;
String empIdCard; String empIdCard;
Date endDate = DateUtil.stringToDate("2999-12-31", DateUtil.ISO_EXPANDED_DATE_FORMAT);
// 组装附属信息 // 组装附属信息
for (PreUploadEmpImportVo info : saveList) { for (PreUploadEmpImportVo info : saveList) {
main = saveMainMap.get(info.getEmpIdcard()); main = saveMainMap.get(info.getEmpIdcard());
...@@ -3107,6 +3109,12 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3107,6 +3109,12 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
tPreEmployeeInfo.setCreateBy(user.getId()); tPreEmployeeInfo.setCreateBy(user.getId());
tPreEmployeeInfo.setCreateName(user.getNickname()); tPreEmployeeInfo.setCreateName(user.getNickname());
tPreEmployeeInfo.setCreateTime(LocalDateTime.now()); tPreEmployeeInfo.setCreateTime(LocalDateTime.now());
tPreEmployeeInfo.setValidityStart(info.getValidityStartValue());
if ("长期".equals(info.getValidityEnd())) {
tPreEmployeeInfo.setValidityEnd(endDate);
} else {
tPreEmployeeInfo.setValidityEnd(info.getValidityEndValue());
}
tPreEmployeeInfo.setEmpNatrue(info.getEmpNatrueValue()); tPreEmployeeInfo.setEmpNatrue(info.getEmpNatrueValue());
tPreEmployeeInfo.setEmpSex(IdCardUtil.getSex(empIdCard)); tPreEmployeeInfo.setEmpSex(IdCardUtil.getSex(empIdCard));
tPreEmployeeInfo.setEmpBirthday(IdCardUtil.getBirthdate(empIdCard)); tPreEmployeeInfo.setEmpBirthday(IdCardUtil.getBirthdate(empIdCard));
...@@ -3151,18 +3159,21 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3151,18 +3159,21 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
tPreEmployeeInfo.setAdmissionDate(info.getEntryDateValue()); tPreEmployeeInfo.setAdmissionDate(info.getEntryDateValue());
tPreEmployeeInfo.setGradutionDate(info.getGradutionDateValue()); tPreEmployeeInfo.setGradutionDate(info.getGradutionDateValue());
tPreEmployeeInfo.setContactAddress(info.getContactAddress()); tPreEmployeeInfo.setContactAddress(info.getContactAddress());
tPreEmployeeInfo.setBankName(info.getBankName()); // 2024-10-17 14:30:06 倩倩上午测试用例评审会说要联动导入,没有卡号,后面填写的不生效:
tPreEmployeeInfo.setBankProvince(info.getBankProvinceValue()); if (Common.isNotNull(info.getBankNo())) {
tPreEmployeeInfo.setBankCity(info.getBankCityValue()); tPreEmployeeInfo.setBankName(info.getBankName());
tPreEmployeeInfo.setBankSubName(info.getBankSubName()); tPreEmployeeInfo.setBankProvince(info.getBankProvinceValue());
tPreEmployeeInfo.setBankNo(info.getBankNo()); tPreEmployeeInfo.setBankCity(info.getBankCityValue());
tPreEmployeeInfo.setTaxMonth(info.getTaxMonthValue()); tPreEmployeeInfo.setBankSubName(info.getBankSubName());
tPreEmployeeInfo.setBankNo(info.getBankNo());
tPreEmployeeInfo.setTaxMonth(info.getTaxMonthValue());
}
tPreEmployeeInfo.setTaxMonthFlag(CommonConstants.ONE_STRING); tPreEmployeeInfo.setTaxMonthFlag(CommonConstants.ONE_STRING);
tPreEmployeeInfo.setContactProvince(info.getContactProvinceValue()); tPreEmployeeInfo.setContactProvince(info.getContactProvinceValue());
tPreEmployeeInfo.setContactCity(info.getContactCityValue()); tPreEmployeeInfo.setContactCity(info.getContactCityValue());
tPreEmployeeInfo.setContactTown(info.getContactTownValue()); tPreEmployeeInfo.setContactTown(info.getContactTownValue());
tPreEmployeeInfo.setFirstWorkFlag(info.getFirstWorkFlag()); tPreEmployeeInfo.setFirstWorkFlag(info.getFirstWorkFlagValue());
tPreEmployeeInfo.setHaveQualification(info.getHaveQualification()); tPreEmployeeInfo.setHaveQualification(info.getHaveQualificationValue());
tPreEmployeeInfo.setFileSource(CommonConstants.SEVEN_STRING); tPreEmployeeInfo.setFileSource(CommonConstants.SEVEN_STRING);
preEmployeeInfoList.add(tPreEmployeeInfo); preEmployeeInfoList.add(tPreEmployeeInfo);
...@@ -3289,8 +3300,8 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3289,8 +3300,8 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
// 主要工作经历 // 主要工作经历
if (Common.isNotNull(info.getFirstWorkFlag()) if (Common.isNotNull(info.getFirstWorkFlag())
&& CommonConstants.ONE_STRING.equals(main.getFirstWorkFlag()) && CommonConstants.IS_FALSE.equals(main.getFirstWorkFlag())
&& CommonConstants.ONE_STRING.equals(info.getFirstWorkFlag())) { && CommonConstants.IS_FALSE.equals(info.getFirstWorkFlag())) {
tPreEmpWorkRecording = new TPreEmpWorkRecording(); tPreEmpWorkRecording = new TPreEmpWorkRecording();
tPreEmpWorkRecording.setSettleDomain(deptId); tPreEmpWorkRecording.setSettleDomain(deptId);
tPreEmpWorkRecording.setEmpId(empId); tPreEmpWorkRecording.setEmpId(empId);
...@@ -3312,8 +3323,8 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3312,8 +3323,8 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
// 职业资格信息——职业资格证书 // 职业资格信息——职业资格证书
if (Common.isNotNull(info.getHaveQualification()) if (Common.isNotNull(info.getHaveQualification())
&& CommonConstants.ZERO_STRING.equals(main.getHaveQualification()) && CommonConstants.IS_TRUE.equals(main.getHaveQualification())
&& CommonConstants.ZERO_STRING.equals(info.getHaveQualification())) { && CommonConstants.IS_TRUE.equals(info.getHaveQualification())) {
tPreEmpProfessionalQualification = new TPreEmpProfessionalQualification(); tPreEmpProfessionalQualification = new TPreEmpProfessionalQualification();
tPreEmpProfessionalQualification.setPreMainId(mainId); tPreEmpProfessionalQualification.setPreMainId(mainId);
tPreEmpProfessionalQualification.setSettleDomain(deptId); tPreEmpProfessionalQualification.setSettleDomain(deptId);
...@@ -3395,203 +3406,6 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3395,203 +3406,6 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
return preMap; 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);
tempStr = c.trim();
}
}
//手机号码校验
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("_超出最大长度;");
}
// 字典
if (attr.isDataId() && null != dictMap) {
tempStr = null;
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("_小于起始日期;");
}
}
}
}
} 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);
tempStr = c.trim();
}
}
}
//手机号码校验
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);
}
}
}
// 字典
if (attr.isDataId() && null != dictMap) {
tempStr = null;
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) { private void judgeBank(PreUploadEmpImportVo detail, StringBuilder errorMust) {
if (Common.isNotNull(detail.getBankNo()) && (Common.isEmpty(detail.getBankName()) if (Common.isNotNull(detail.getBankNo()) && (Common.isEmpty(detail.getBankName())
|| Common.isEmpty(detail.getBankProvince()) || Common.isEmpty(detail.getBankProvince())
...@@ -3713,359 +3527,6 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -3713,359 +3527,6 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
} }
} }
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}.*$");
}
/** /**
* 根据身份证与姓名查询用户手机号和来源 * 根据身份证与姓名查询用户手机号和来源
* *
......
...@@ -108,4 +108,13 @@ ...@@ -108,4 +108,13 @@
<include refid="tEmpContactInfo_where"/> <include refid="tEmpContactInfo_where"/>
</where> </where>
</select> </select>
<select id="getContactByDeptId" resultMap="tEmpContactInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_emp_contact_info a
left join t_employee_project b on a.EMP_IDCARD = b.EMP_IDCARD
where b.DEPT_ID = #{deptId}
GROUP BY a.EMP_IDCARD
</select>
</mapper> </mapper>
...@@ -764,6 +764,16 @@ ...@@ -764,6 +764,16 @@
</foreach> </foreach>
</select> </select>
<!-- hgw 根据身份证查询 -->
<select id="getListByDeptId" resultMap="tEmployeeInfoMap">
select
<include refid="baseParam"/>
from t_employee_info a
left join t_employee_project b on a.EMP_IDCARD = b.EMP_IDCARD
where a.DELETE_FLAG = '0' and b.DEPT_ID = #{deptId}
GROUP BY a.EMP_IDCARD
</select>
<select id="getListByIdCardList" resultMap="tEmployeeInfoMap"> <select id="getListByIdCardList" resultMap="tEmployeeInfoMap">
select select
<include refid="baseParam"/> <include refid="baseParam"/>
......
...@@ -115,5 +115,11 @@ ...@@ -115,5 +115,11 @@
<artifactId>lock4j-redis-template-spring-boot-starter</artifactId> <artifactId>lock4j-redis-template-spring-boot-starter</artifactId>
<version>2.2.4</version> <version>2.2.4</version>
</dependency> </dependency>
<!-- 读取excel -->
<dependency>
<groupId>com.monitorjbl</groupId>
<artifactId>xlsx-streamer</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ValidityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelColumnVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelSheetVo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.*;
import com.monitorjbl.xlsx.StreamingReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Author hgw
* @Date 2024-10-17 14:37:50
* @Description 自己写的识别excel内容
* @Version 1.0
*/
@Data
@Slf4j
public class DiyExcelImportUtil implements Serializable {
public static 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}.*$");
}
/**
* @Description: 判断字段格式
* @Author: hgw
* @Date: 2024/10/14 11:38
* @return: java.lang.String
**/
public static 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);
tempStr = c.trim();
}
}
//手机号码校验
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("_超出最大长度;");
}
// 字典
if (attr.isDataId() && null != dictMap) {
tempStr = null;
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("_小于起始日期;");
}
}
}
}
} 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);
tempStr = c.trim();
}
}
}
//手机号码校验
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);
}
}
}
// 字典
if (attr.isDataId() && null != dictMap) {
tempStr = null;
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 static boolean getMatchRes(String c, ExcelAttribute attr, String pattern) {
return !c.matches(Common.isEmpty(attr.pattern()) ? pattern : attr.pattern());
}
private static 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;
}
// 塞翻译后的值
public static <T> void setFieldsValue(Field field, String cellValueStr, 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, entity);
} else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) {
setIntegerField(field, cellValueStr, entity);
} else {
field.set(entity, cellValueStr);
}
}
// 塞导入的值
public static <T> void setFields(Field field, String cellValueStr, Class<?> fieldType, T entity) throws IllegalAccessException {
if (String.class == fieldType) {
field.set(entity, cellValueStr);
} else if (Date.class == fieldType && Common.isNotNull(cellValueStr.trim())) {
setDateField(field, cellValueStr, 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
**/
public 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);
}
}
public static <T> void setDateField(Field field, String cellValueStr, 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));
}
public 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));
}
}
}
package com.yifu.cloud.plus.v1.yifu.common.core.vo;
import lombok.Getter;
import lombok.Setter;
/**
* @author hgw
* @description 薪资原表识别的 列内容 vo
* @date 2024-4-3 09:15:24
*/
@Getter
@Setter
public class ExcelColumnVo {
// 列号
private int lineNum;
// 列内容
private String content;
}
package com.yifu.cloud.plus.v1.yifu.common.core.vo;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
/**
* @author hgw
* @description 薪资原表识别的 sheet vo
* @date 2024-4-3 09:15:24
*/
@Getter
@Setter
public class ExcelSheetVo {
// 数据行
private int dataNum;
// sheet名
private String sheetName;
// 解析过程发现的错误信息
private String errorInfo;
// 标题行
private List<ExcelColumnVo> titleList;
// 内容行+列
private List<Map<String, String>> contentList;
}
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